The comet update command provides a streamlined mechanism for keeping both the Comet CLI and its deployed agent skills up to date. It automates the detection of existing installations across multiple AI platforms and scopes, performs a self-update via npm, and synchronizes the latest bundled skills while preserving the user's previously selected language (English or Chinese).
The update logic is encapsulated in src/commands/update.ts src/commands/update.ts218-320 It follows a two-stage execution flow:
@rpamis/comet package itself using npm install src/commands/update.ts184-216.claude/skills/, .cursor/rules/) and overwrites them with the latest versions from the updated package assets src/commands/update.ts257-285The following diagram illustrates the detection and execution flow of the updateCommand.
Update Command Execution Flow
Sources: src/commands/update.ts218-285 src/commands/update.ts80-103
Comet must determine both the scope of the npm installation (to run the correct npm command) and the specific AI platforms where skills are currently deployed.
The function detectCometPackageScope identifies if Comet is installed as a project dependency or a global package src/commands/update.ts134-159
node_modules folder inside the project path src/commands/update.ts138-139 or if @rpamis/comet is listed in the project's package.json dependencies src/commands/update.ts149-155The detectInstalledCometTargets function iterates through all supported PLATFORMS src/core/platforms.ts30-88 and both InstallScope types (project, global) to find active installations src/commands/update.ts105-127
skills directory containing files starting with comet via hasLocalCometSkills src/commands/update.ts67-78getPlatformSkillsDir to resolve platform-specific paths like .claude or .cursor src/commands/update.ts60Entity Mapping: Detection Logic
Sources: src/commands/update.ts23-36 src/commands/update.ts105-127
A key feature of comet update is its ability to remember the user's language preference without storing a separate configuration file.
The detectInstalledCometLanguage function reads the existing SKILL.md file from the target platform's directory src/commands/update.ts85-100 It uses a Unicode regex check /[\u3400-\u9fff]/u to determine if the content contains CJK characters src/commands/update.ts95
skills-zh asset directory src/commands/update.ts43-45skills directory src/commands/update.ts102Once targets are identified, the command calls copyCometSkillsForPlatform src/core/skills.ts33-88 This process:
assets/manifest.json via getManifestSkills src/commands/update.ts265assets/skills or assets/skills-zh) based on the detected language src/commands/update.ts43-45copyCometRulesForPlatform and installCometHooksForPlatform to ensure project-level constraints and pre-tool hooks are updated src/commands/update.ts281-282Sources: src/commands/update.ts80-103 src/commands/update.ts257-285 test/ts/update.test.ts43-63
The command supports several flags to control its behavior, particularly useful for CI/CD or specialized environments.
| Flag | Description |
|---|---|
--skip-npm | Skips the npm install step and only updates agent skills using the currently installed package assets src/commands/update.ts227 |
--scope <scope> | Forces the update to a specific scope (project or global), bypassing auto-detection src/commands/update.ts225 |
--language <lang> | Overrides language detection for the skill update src/commands/update.ts268 |
--json | Outputs the update results (npm status and list of updated platforms) in a structured JSON format src/commands/update.ts249-254 |
The updateCometNpmPackage function spawns a child process to run npm install src/commands/update.ts184-216
npm.cmd via getNpmExecutable() src/commands/update.ts180-182stdio: 'inherit' to allow the user to see the npm progress src/commands/update.ts199 In --json mode, it uses stdio: 'ignore' to prevent npm output from corrupting the JSON document src/commands/update.ts199buildNpmUpdateArgs, appending @latest to the package name and forcing the official registry src/commands/update.ts161-165Sources: src/commands/update.ts23-28 src/commands/update.ts161-165 src/commands/update.ts184-216
Refresh this wiki
This wiki was recently refreshed. Please wait 7 days to refresh again.