feat: 品牌重命名 claude → csc 并注册 update 命令
- 将用户可见的 CLI 提示从 claude 替换为 csc(错误信息、用法说明、文档) - 注册 csc update / csc upgrade 子命令 - 设置 MACRO.PACKAGE_URL 为 @costrict/csc - 更新 auto-updater 和启动流文档
This commit is contained in:
parent
efedc9ff33
commit
4d446823ea
|
|
@ -16,7 +16,7 @@ Claude Code 拥有一套复杂的多策略自动更新系统,支持三种安
|
||||||
| `npm-global` | `npm install -g` / `bun install -g` | 是(静默) |
|
| `npm-global` | `npm install -g` / `bun install -g` | 是(静默) |
|
||||||
| `npm-local` | `npm install` 到 `~/.claude/local/` | 是(静默) |
|
| `npm-local` | `npm install` 到 `~/.claude/local/` | 是(静默) |
|
||||||
| `package-manager` | 显示通知,附带对应操作系统的升级命令 | 否(仅通知) |
|
| `package-manager` | 显示通知,附带对应操作系统的升级命令 | 否(仅通知) |
|
||||||
| `development` | 不适用 — 执行 `claude update` 时报错 | 不适用 |
|
| `development` | 不适用 — 执行 `csc update` 时报错 | 不适用 |
|
||||||
|
|
||||||
### 策略路由
|
### 策略路由
|
||||||
|
|
||||||
|
|
@ -95,7 +95,7 @@ void assertMinVersion();
|
||||||
|
|
||||||
## 手动 CLI 命令
|
## 手动 CLI 命令
|
||||||
|
|
||||||
### `claude update` / `claude upgrade`
|
### `csc update` / `claude upgrade`
|
||||||
|
|
||||||
**文件**: `src/cli/update.ts`
|
**文件**: `src/cli/update.ts`
|
||||||
|
|
||||||
|
|
@ -258,7 +258,7 @@ React hook `useUpdateNotification(updatedVersion)` — 确保每次 semver 变
|
||||||
| 文件 | 职责 |
|
| 文件 | 职责 |
|
||||||
|---|---|
|
|---|---|
|
||||||
| `src/utils/autoUpdater.ts` | 核心逻辑:版本检查、npm 安装、文件锁、最低/最高版本门控 |
|
| `src/utils/autoUpdater.ts` | 核心逻辑:版本检查、npm 安装、文件锁、最低/最高版本门控 |
|
||||||
| `src/cli/update.ts` | `claude update` 命令处理 |
|
| `src/cli/update.ts` | `csc update` 命令处理 |
|
||||||
| `src/utils/nativeInstaller/installer.ts` | 原生二进制安装器:下载、版本管理、符号链接、清理 |
|
| `src/utils/nativeInstaller/installer.ts` | 原生二进制安装器:下载、版本管理、符号链接、清理 |
|
||||||
| `src/utils/nativeInstaller/download.ts` | 从 GCS/Artifactory 下载二进制文件并校验 |
|
| `src/utils/nativeInstaller/download.ts` | 从 GCS/Artifactory 下载二进制文件并校验 |
|
||||||
| `src/utils/localInstaller.ts` | 本地安装器(`~/.claude/local/`)基于 npm |
|
| `src/utils/localInstaller.ts` | 本地安装器(`~/.claude/local/`)基于 npm |
|
||||||
|
|
@ -308,5 +308,5 @@ REPL 运行中(每 30 分钟)
|
||||||
└── 显示 "Run: brew upgrade ..."(不自动安装)
|
└── 显示 "Run: brew upgrade ..."(不自动安装)
|
||||||
|
|
||||||
手动操作
|
手动操作
|
||||||
└── claude update → 完整诊断 + 安装编排
|
└── csc update → 完整诊断 + 安装编排
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -294,7 +294,7 @@ action(async (prompt, options) => {
|
||||||
| `claude setup-token` | 4267 | 设置长期认证 token |
|
| `claude setup-token` | 4267 | 设置长期认证 token |
|
||||||
| `claude agents` | 4278 | 列出已配置的 agents |
|
| `claude agents` | 4278 | 列出已配置的 agents |
|
||||||
| `claude doctor` | 4346 | 健康检查 |
|
| `claude doctor` | 4346 | 健康检查 |
|
||||||
| `claude update` | 4362 | 检查更新 |
|
| `csc update` | 4362 | 检查更新 |
|
||||||
| `claude install` | 4394 | 安装原生构建 |
|
| `claude install` | 4394 | 安装原生构建 |
|
||||||
| `claude log` | 4411 | 查看对话日志(内部) |
|
| `claude log` | 4411 | 查看对话日志(内部) |
|
||||||
| `claude completion` | 4491 | Shell 自动补全 |
|
| `claude completion` | 4491 | Shell 自动补全 |
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ export function getMacroDefines(): Record<string, string> {
|
||||||
"MACRO.FEEDBACK_CHANNEL": JSON.stringify(""),
|
"MACRO.FEEDBACK_CHANNEL": JSON.stringify(""),
|
||||||
"MACRO.ISSUES_EXPLAINER": JSON.stringify(""),
|
"MACRO.ISSUES_EXPLAINER": JSON.stringify(""),
|
||||||
"MACRO.NATIVE_PACKAGE_URL": JSON.stringify(""),
|
"MACRO.NATIVE_PACKAGE_URL": JSON.stringify(""),
|
||||||
"MACRO.PACKAGE_URL": JSON.stringify(""),
|
"MACRO.PACKAGE_URL": JSON.stringify("@costrict/csc"),
|
||||||
"MACRO.VERSION_CHANGELOG": JSON.stringify(""),
|
"MACRO.VERSION_CHANGELOG": JSON.stringify(""),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -421,7 +421,7 @@ export async function initReplBridge(
|
||||||
`[bridge:repl] Skipping: ${versionError}`,
|
`[bridge:repl] Skipping: ${versionError}`,
|
||||||
true,
|
true,
|
||||||
)
|
)
|
||||||
onStateChange?.('failed', 'run `claude update` to upgrade')
|
onStateChange?.('failed', 'run `csc update` to upgrade')
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
logForDebugging(
|
logForDebugging(
|
||||||
|
|
@ -462,7 +462,7 @@ export async function initReplBridge(
|
||||||
const versionError = checkBridgeMinVersion()
|
const versionError = checkBridgeMinVersion()
|
||||||
if (versionError) {
|
if (versionError) {
|
||||||
logBridgeSkip('version_too_old', `[bridge:repl] Skipping: ${versionError}`)
|
logBridgeSkip('version_too_old', `[bridge:repl] Skipping: ${versionError}`)
|
||||||
onStateChange?.('failed', 'run `claude update` to upgrade')
|
onStateChange?.('failed', 'run `csc update` to upgrade')
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5051,7 +5051,7 @@ async function loadInitialMessages(
|
||||||
)
|
)
|
||||||
if (!parsedSessionId) {
|
if (!parsedSessionId) {
|
||||||
let errorMessage =
|
let errorMessage =
|
||||||
'Error: --resume requires a valid session ID when used with --print. Usage: claude -p --resume <session-id>'
|
'Error: --resume requires a valid session ID when used with --print. Usage: csc -p --resume <session-id>'
|
||||||
if (typeof options.resume === 'string') {
|
if (typeof options.resume === 'string') {
|
||||||
errorMessage += `. Session IDs must be in UUID format (e.g., 550e8400-e29b-41d4-a716-446655440000). Provided value "${options.resume}" is not a valid UUID`
|
errorMessage += `. Session IDs must be in UUID format (e.g., 550e8400-e29b-41d4-a716-446655440000). Provided value "${options.resume}" is not a valid UUID`
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -87,12 +87,12 @@ export function registerMcpAddCommand(mcp: Command): void {
|
||||||
if (!name) {
|
if (!name) {
|
||||||
cliError(
|
cliError(
|
||||||
'Error: Server name is required.\n' +
|
'Error: Server name is required.\n' +
|
||||||
'Usage: claude mcp add <name> <command> [args...]',
|
'Usage: csc mcp add <name> <command> [args...]',
|
||||||
)
|
)
|
||||||
} else if (!actualCommand) {
|
} else if (!actualCommand) {
|
||||||
cliError(
|
cliError(
|
||||||
'Error: Command is required when server name is provided.\n' +
|
'Error: Command is required when server name is provided.\n' +
|
||||||
'Usage: claude mcp add <name> <command> [args...]',
|
'Usage: csc mcp add <name> <command> [args...]',
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
14
src/main.tsx
14
src/main.tsx
|
|
@ -4937,7 +4937,7 @@ async function run(): Promise<CommanderCommand> {
|
||||||
if (!isRemoteTuiEnabled && !hasInitialPrompt) {
|
if (!isRemoteTuiEnabled && !hasInitialPrompt) {
|
||||||
return await exitWithError(
|
return await exitWithError(
|
||||||
root,
|
root,
|
||||||
'Error: --remote requires a description.\nUsage: claude --remote "your task description"',
|
'Error: --remote requires a description.\nUsage: csc --remote "your task description"',
|
||||||
() => gracefulShutdown(1),
|
() => gracefulShutdown(1),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -6479,7 +6479,7 @@ async function run(): Promise<CommanderCommand> {
|
||||||
// (e.g. `--debug assistant`) and the position-0 predicate
|
// (e.g. `--debug assistant`) and the position-0 predicate
|
||||||
// didn't match. Print usage like the ssh stub does.
|
// didn't match. Print usage like the ssh stub does.
|
||||||
process.stderr.write(
|
process.stderr.write(
|
||||||
"Usage: claude assistant [sessionId]\n\n" +
|
"Usage: csc assistant [sessionId]\n\n" +
|
||||||
"Attach the REPL as a viewer client to a running bridge session.\n" +
|
"Attach the REPL as a viewer client to a running bridge session.\n" +
|
||||||
"Omit sessionId to discover and pick from available sessions.\n",
|
"Omit sessionId to discover and pick from available sessions.\n",
|
||||||
);
|
);
|
||||||
|
|
@ -6487,6 +6487,16 @@ async function run(): Promise<CommanderCommand> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update command - check and install updates
|
||||||
|
program
|
||||||
|
.command('update')
|
||||||
|
.alias('upgrade')
|
||||||
|
.description('Check for updates and install the latest version')
|
||||||
|
.action(async () => {
|
||||||
|
const { update } = await import('./cli/update.js')
|
||||||
|
await update()
|
||||||
|
})
|
||||||
|
|
||||||
// Doctor command - check installation health
|
// Doctor command - check installation health
|
||||||
program
|
program
|
||||||
.command('doctor')
|
.command('doctor')
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ export type MaxVersionConfig = {
|
||||||
*
|
*
|
||||||
* Versioning approach:
|
* Versioning approach:
|
||||||
* 1. For version requirements/compatibility (assertMinVersion), we use semver comparison that ignores build metadata
|
* 1. For version requirements/compatibility (assertMinVersion), we use semver comparison that ignores build metadata
|
||||||
* 2. For updates ('claude update'), we use exact string comparison to detect any change, including SHA
|
* 2. For updates ('csc update'), we use exact string comparison to detect any change, including SHA
|
||||||
* - This ensures users always get the latest build, even when only the SHA changes
|
* - This ensures users always get the latest build, even when only the SHA changes
|
||||||
* - The UI clearly shows both versions including build metadata
|
* - The UI clearly shows both versions including build metadata
|
||||||
*
|
*
|
||||||
|
|
@ -87,7 +87,7 @@ It looks like your version of CoStrict (${MACRO.VERSION}) needs an update.
|
||||||
A newer version (${versionConfig.minVersion} or higher) is required to continue.
|
A newer version (${versionConfig.minVersion} or higher) is required to continue.
|
||||||
|
|
||||||
To update, please run:
|
To update, please run:
|
||||||
claude update
|
csc update
|
||||||
|
|
||||||
This will ensure you have access to the latest features and improvements.
|
This will ensure you have access to the latest features and improvements.
|
||||||
`)
|
`)
|
||||||
|
|
@ -488,7 +488,7 @@ This configuration is not supported for updates.
|
||||||
To fix this issue:
|
To fix this issue:
|
||||||
1. Install Node.js within your Linux distribution: e.g. sudo apt install nodejs npm
|
1. Install Node.js within your Linux distribution: e.g. sudo apt install nodejs npm
|
||||||
2. Make sure Linux NPM is in your PATH before the Windows version
|
2. Make sure Linux NPM is in your PATH before the Windows version
|
||||||
3. Try updating again with 'claude update'
|
3. Try updating again with 'csc update'
|
||||||
`)
|
`)
|
||||||
return 'install_failed'
|
return 'install_failed'
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -135,7 +135,7 @@ export async function setupShellCompletion(theme: ThemeName): Promise<string> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Regenerate cached shell completion scripts in ~/.claude/.
|
* Regenerate cached shell completion scripts in ~/.claude/.
|
||||||
* Called after `claude update` so completions stay in sync with the new binary.
|
* Called after `csc update` so completions stay in sync with the new binary.
|
||||||
*/
|
*/
|
||||||
export async function regenerateCompletionCache(): Promise<void> {
|
export async function regenerateCompletionCache(): Promise<void> {
|
||||||
const shell = detectShell()
|
const shell = detectShell()
|
||||||
|
|
|
||||||
|
|
@ -137,7 +137,7 @@ function printResumeHint(): void {
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
const sessionId = getSessionId()
|
const sessionId = getSessionId()
|
||||||
// Don't show resume hint if no session file exists (e.g., subcommands like `claude update`)
|
// Don't show resume hint if no session file exists (e.g., subcommands like `csc update`)
|
||||||
if (!sessionIdExists(sessionId)) {
|
if (!sessionIdExists(sessionId)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user