@hit-sudomaker/ccw 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +54 -52
- package/assets/ccline/config.toml +34 -34
- package/assets/skills/amirc-research/SKILL.md +39 -39
- package/dist/ccline.js +149 -616
- package/dist/ccw.js +167 -378
- package/dist/claude-program.js +191 -0
- package/dist/claude.js +177 -0
- package/dist/cleanup.js +150 -348
- package/dist/effect-machine.js +65 -0
- package/dist/frozen-json.js +99 -0
- package/dist/instance.js +71 -0
- package/dist/machine.js +613 -573
- package/dist/main.js +68 -58
- package/dist/management-catalog.js +60 -54
- package/dist/messages.js +182 -0
- package/dist/model.js +39 -144
- package/dist/npm-registry.js +110 -27
- package/dist/officecli.js +274 -404
- package/dist/planning.js +141 -0
- package/dist/plugins.js +134 -294
- package/dist/program-channels.js +94 -384
- package/dist/program-operations.js +155 -0
- package/dist/read-machine.js +94 -43
- package/dist/render.js +350 -347
- package/dist/settings.js +380 -0
- package/dist/skill-files.js +184 -77
- package/dist/skills.js +393 -237
- package/dist/terminal-view.js +303 -395
- package/dist/terminal.js +207 -467
- package/dist/work.js +135 -0
- package/package.json +1 -2
- package/dist/claude-config.js +0 -347
- package/dist/errors.js +0 -139
- package/dist/legacy-amirc.js +0 -60
- package/dist/mcp.js +0 -299
- package/dist/programs.js +0 -778
- package/dist/run-presentation.js +0 -155
- package/dist/titles.js +0 -43
- package/dist/warnings.js +0 -6
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { knownTitle } from './management-catalog.js';
|
|
3
|
+
import { errorCode, isObject } from './machine.js';
|
|
4
|
+
import { json, userBinary } from './model.js';
|
|
5
|
+
import { npmGlobalRoot, npmVersion, samePath } from './program-channels.js';
|
|
6
|
+
import { NPM_ENABLE_SCRIPTS } from './npm-registry.js';
|
|
7
|
+
/** CCW 管理的 Claude npm 包身份 */
|
|
8
|
+
export const CLAUDE_PACKAGE = '@anthropic-ai/claude-code';
|
|
9
|
+
/** Claude 安装所需的生命周期脚本许可和可选依赖参数 */
|
|
10
|
+
export const CLAUDE_NPM_ARGS = [...NPM_ENABLE_SCRIPTS, '--allow-scripts=' + CLAUDE_PACKAGE, '--include=optional'];
|
|
11
|
+
/**
|
|
12
|
+
* 发现 Claude 的 npm 安装、固定用户目录和 PATH 入口
|
|
13
|
+
*
|
|
14
|
+
* @returns 候选映射、展示项目及 npm 检查问题
|
|
15
|
+
* @throws Error - 固定路径或 PATH 文件检查失败时拒绝
|
|
16
|
+
* @remarks npm 检查失败记入 problems,继续发现其他候选;外部入口只展示
|
|
17
|
+
* 发现仅确认记录及路径,不证明外部程序的身份或版本
|
|
18
|
+
*/
|
|
19
|
+
export async function claudePrograms(ctx) {
|
|
20
|
+
const kind = 'claude';
|
|
21
|
+
const values = new Map();
|
|
22
|
+
const problems = [];
|
|
23
|
+
try {
|
|
24
|
+
const version = await npmVersion(ctx, CLAUDE_PACKAGE);
|
|
25
|
+
if (version !== null) {
|
|
26
|
+
const npmRoot = await npmGlobalRoot(ctx);
|
|
27
|
+
const binary = await claudeNpmBinary(ctx, npmRoot);
|
|
28
|
+
values.set(kind, {
|
|
29
|
+
channel: 'npm',
|
|
30
|
+
binary,
|
|
31
|
+
version,
|
|
32
|
+
npmRoot,
|
|
33
|
+
isMissing: (await ctx.machine.treeStamp(binary)) === null,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
problems.push(errorCode(error));
|
|
39
|
+
}
|
|
40
|
+
const native = userBinary(ctx, 'claude');
|
|
41
|
+
if ((await ctx.machine.treeStamp(native)) !== null)
|
|
42
|
+
values.set(kind + ':external:' + native, { channel: 'manual', binary: native, version: null });
|
|
43
|
+
for (const binary of await ctx.machine.locate(kind)) {
|
|
44
|
+
const canonical = await ctx.machine.realpath(binary);
|
|
45
|
+
if (!canonical)
|
|
46
|
+
continue;
|
|
47
|
+
if ([...values.values()].some(program => samePath(ctx, program.binary, binary) ||
|
|
48
|
+
samePath(ctx, program.binary, canonical) ||
|
|
49
|
+
(program.channel === 'npm' && containsPath(ctx, path.join(program.npmRoot, CLAUDE_PACKAGE), canonical))))
|
|
50
|
+
continue;
|
|
51
|
+
values.set(kind + ':external:' + binary, {
|
|
52
|
+
channel: 'manual',
|
|
53
|
+
binary,
|
|
54
|
+
version: null,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
values,
|
|
59
|
+
problems,
|
|
60
|
+
items: await Promise.all([...values.entries()].map(async ([id, program]) => ({
|
|
61
|
+
id,
|
|
62
|
+
title: knownTitle(kind),
|
|
63
|
+
kind,
|
|
64
|
+
location: program.binary,
|
|
65
|
+
...((await npmLauncher(ctx, program, values.get(kind))) ? { launcherFor: kind } : {}),
|
|
66
|
+
canInstall: program.channel !== 'manual',
|
|
67
|
+
facts: [
|
|
68
|
+
{ code: program.isMissing ? 'program-missing' : 'program-exists', detail: program.channel },
|
|
69
|
+
...(program.version ? [{ code: 'program-version', detail: program.version }] : []),
|
|
70
|
+
...(program.channel === 'manual' ? [{ code: 'external-program-preserved' }] : []),
|
|
71
|
+
],
|
|
72
|
+
canUninstall: program.channel !== 'manual',
|
|
73
|
+
}))),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* 选择 Claude 入口并冻结路径及指纹
|
|
78
|
+
*
|
|
79
|
+
* @returns 每次调用前复核指纹的命令句柄,不安装程序
|
|
80
|
+
* @throws Error - 发现不完整、缺少非 cmd 入口或无法取得指纹时拒绝
|
|
81
|
+
*/
|
|
82
|
+
export async function freezeClaudeCommand(ctx) {
|
|
83
|
+
const found = await claudePrograms(ctx);
|
|
84
|
+
if (found.problems.length)
|
|
85
|
+
throw new Error('installation-state-unconfirmed');
|
|
86
|
+
const program = [...found.values.values()].find(program => !program.isMissing && !program.binary.endsWith('.cmd'));
|
|
87
|
+
if (!program)
|
|
88
|
+
throw new Error('claude-not-installed');
|
|
89
|
+
const binary = program.binary;
|
|
90
|
+
const stamp = await ctx.machine.fingerprint(binary);
|
|
91
|
+
if (stamp === null)
|
|
92
|
+
throw new Error('program-not-ready');
|
|
93
|
+
return bindClaudeCommand(ctx, () => binary, async () => {
|
|
94
|
+
if ((await ctx.machine.fingerprint(binary)) !== stamp)
|
|
95
|
+
throw new Error('program-changed');
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* 将 Claude 命令绑定到可核验的入口
|
|
100
|
+
*
|
|
101
|
+
* @param binary - 核验后读取入口,可随安装结果更新
|
|
102
|
+
* @param verify - 每次执行前的身份或依赖检查,拒绝时停止执行
|
|
103
|
+
* @returns 保留原始命令结果的句柄,不据此确认操作成功
|
|
104
|
+
* @remarks --help 和 auth status 使用只读能力,其余使用写能力;JS 入口由当前 Node 执行
|
|
105
|
+
*/
|
|
106
|
+
export function bindClaudeCommand(ctx, binary, verify) {
|
|
107
|
+
return {
|
|
108
|
+
verify,
|
|
109
|
+
async execute(args, isInteractive = false) {
|
|
110
|
+
await verify();
|
|
111
|
+
const target = binary();
|
|
112
|
+
const observe = args.includes('--help') || (args[0] === 'auth' && args[1] === 'status');
|
|
113
|
+
return (observe ? ctx.machine : ctx.effects).execute(target.endsWith('.js') ? process.execPath : target, target.endsWith('.js') ? [target, ...args] : args, { env: claudeEnvironment(ctx), cwd: ctx.home, isInteractive });
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* 从 npm 清单解析 Claude 包内的命令入口
|
|
119
|
+
*
|
|
120
|
+
* @param root - 已选定的 npm 全局包目录
|
|
121
|
+
* @returns 绝对入口路径,不保证文件存在
|
|
122
|
+
* @throws Error - 清单不可读、未声明命令或入口越出包目录时拒绝
|
|
123
|
+
*/
|
|
124
|
+
export async function claudeNpmBinary(ctx, root) {
|
|
125
|
+
const directory = path.join(root, CLAUDE_PACKAGE);
|
|
126
|
+
const manifest = await json(ctx.machine, path.join(directory, 'package.json'));
|
|
127
|
+
const relative = typeof manifest.bin === 'string' ? manifest.bin : isObject(manifest.bin) ? manifest.bin.claude : undefined;
|
|
128
|
+
if (typeof relative !== 'string')
|
|
129
|
+
throw new Error('program-not-ready');
|
|
130
|
+
const binary = path.resolve(directory, relative);
|
|
131
|
+
if (!binary.startsWith(`${directory}${path.sep}`))
|
|
132
|
+
throw new Error('invalid-program-entry');
|
|
133
|
+
return binary;
|
|
134
|
+
}
|
|
135
|
+
function containsPath(ctx, directory, file) {
|
|
136
|
+
const root = path.resolve(directory);
|
|
137
|
+
const target = path.resolve(file);
|
|
138
|
+
return ctx.platform === 'win32'
|
|
139
|
+
? target.toLowerCase().startsWith(`${root.toLowerCase()}${path.sep}`)
|
|
140
|
+
: target.startsWith(`${root}${path.sep}`);
|
|
141
|
+
}
|
|
142
|
+
async function npmLauncher(ctx, candidate, installed) {
|
|
143
|
+
if (ctx.platform !== 'win32' || candidate.channel !== 'manual' || installed?.channel !== 'npm')
|
|
144
|
+
return false;
|
|
145
|
+
if (!samePath(ctx, path.dirname(candidate.binary), path.dirname(installed.npmRoot)))
|
|
146
|
+
return false;
|
|
147
|
+
if (!['claude', 'claude.cmd', 'claude.ps1'].includes(path.basename(candidate.binary).toLowerCase()))
|
|
148
|
+
return false;
|
|
149
|
+
// 只关联相同 npm 前缀内明确调用已知入口的脚本;此关联不参与执行资格判断
|
|
150
|
+
try {
|
|
151
|
+
const source = (await ctx.machine.read(candidate.binary))?.replaceAll('\\', '/');
|
|
152
|
+
const target = path.relative(path.dirname(candidate.binary), installed.binary).replaceAll('\\', '/');
|
|
153
|
+
return (source
|
|
154
|
+
?.split(/\r?\n/)
|
|
155
|
+
.some(line => [`"%dp0%/${target}"`, `& "$basedir/${target}"`, `exec "$basedir/${target}"`].some(call => line.trim().startsWith(call))) ?? false);
|
|
156
|
+
}
|
|
157
|
+
catch (error) {
|
|
158
|
+
if (errorCode(error) === 'cancelled')
|
|
159
|
+
throw error;
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* 生成指向本次配置根的 Claude 环境覆盖
|
|
165
|
+
*
|
|
166
|
+
* @param ctx - 含用户目录与状态文件路径的上下文
|
|
167
|
+
* @returns 默认状态文件位置下取消 CLAUDE_CONFIG_DIR 覆盖,否则使用当前配置根
|
|
168
|
+
*/
|
|
169
|
+
function claudeEnvironment(ctx) {
|
|
170
|
+
return { CLAUDE_CONFIG_DIR: ctx.stateFile === path.join(ctx.home, '.claude.json') ? undefined : ctx.claudeRoot };
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* 检查当前是否存在可识别的 Claude 进程
|
|
174
|
+
*
|
|
175
|
+
* @param machine - 提供进程枚举的读取能力
|
|
176
|
+
* @param signal - 传给枚举过程的取消信号
|
|
177
|
+
* @returns 存在为 true,不存在为 false,枚举未确认时为 null
|
|
178
|
+
* @throws Error - 底层读取拒绝时原样传播
|
|
179
|
+
*/
|
|
180
|
+
export async function claudeRunning(machine, signal) {
|
|
181
|
+
const found = await machine.processes(signal ? { signal } : undefined);
|
|
182
|
+
if (found === null)
|
|
183
|
+
return null;
|
|
184
|
+
return found.some(entry => claudeProcessActive(entry.name, entry.command));
|
|
185
|
+
}
|
|
186
|
+
/** 根据进程名称或 Node 命令行识别 Claude,不读取进程状态 */
|
|
187
|
+
function claudeProcessActive(name, command) {
|
|
188
|
+
return (/(?:^|[\\/])(?:claude|Claude Code)(?:\.exe)?$/i.test(name) ||
|
|
189
|
+
(/(?:^|[\\/])node(?:js)?(?:\.exe)?$/i.test(name) &&
|
|
190
|
+
/(?:^|[\\/\s"'])@anthropic-ai[\\/]claude-code(?:[\\/]|$)/i.test(command)));
|
|
191
|
+
}
|
package/dist/claude.js
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { inspectSettings, prepareSettings } from './settings.js';
|
|
2
|
+
import { knownTitle } from './management-catalog.js';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { errorCode, isObject } from './machine.js';
|
|
5
|
+
import { claudeRunning } from './claude-program.js';
|
|
6
|
+
import { isExactVersion, NPM_OFFICIAL, resolveNpmView } from './npm-registry.js';
|
|
7
|
+
import { CLAUDE_PACKAGE, CLAUDE_NPM_ARGS, claudeNpmBinary, bindClaudeCommand, claudePrograms, } from './claude-program.js';
|
|
8
|
+
import { freezeNpmScope } from './program-channels.js';
|
|
9
|
+
import { npmProgram } from './program-operations.js';
|
|
10
|
+
import { step, sequence } from './work.js';
|
|
11
|
+
import { prepareDataCleanup } from './cleanup.js';
|
|
12
|
+
const STABLE_METADATA_TIMEOUT_MS = 5_000;
|
|
13
|
+
/**
|
|
14
|
+
* 管理 Claude 程序、默认设置、模型配置和官方登录
|
|
15
|
+
*
|
|
16
|
+
* @remarks 仅管理 npm 渠道,安装与更新使用当次 stable 并补齐默认设置
|
|
17
|
+
* 卸载要求 Claude 已停止;外部安装只展示
|
|
18
|
+
*/
|
|
19
|
+
export function createClaudeDomain(ctx) {
|
|
20
|
+
return {
|
|
21
|
+
async inspect() {
|
|
22
|
+
const checks = [
|
|
23
|
+
['claude', () => inspectClaudePrograms(ctx)],
|
|
24
|
+
['settings', async () => ({ items: [await inspectSettings(ctx)], problems: [] })],
|
|
25
|
+
];
|
|
26
|
+
const results = await Promise.all(checks.map(async ([name, read]) => {
|
|
27
|
+
try {
|
|
28
|
+
return await read();
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
return { items: [], problems: [{ code: errorCode(error), detail: name }] };
|
|
32
|
+
}
|
|
33
|
+
}));
|
|
34
|
+
return { items: results.flatMap(result => result.items), problems: results.flatMap(result => result.problems) };
|
|
35
|
+
},
|
|
36
|
+
async prepare(selection, claude) {
|
|
37
|
+
if (selection.id.startsWith('data:'))
|
|
38
|
+
return prepareDataCleanup(ctx, selection);
|
|
39
|
+
if (selection.id === 'settings') {
|
|
40
|
+
const login = selection.action === 'configure' && selection.fields?.mode === 'official' && selection.fields.login === 'yes';
|
|
41
|
+
return prepareSettings(ctx, selection, login ? await claude?.() : undefined);
|
|
42
|
+
}
|
|
43
|
+
if (selection.id.split(':')[0] !== 'claude')
|
|
44
|
+
throw new Error('unknown-selection');
|
|
45
|
+
return prepareClaudeProgram(ctx, selection);
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
async function inspectClaudePrograms(ctx) {
|
|
50
|
+
const found = await claudePrograms(ctx);
|
|
51
|
+
return {
|
|
52
|
+
items: found.items.length
|
|
53
|
+
? found.items
|
|
54
|
+
: [
|
|
55
|
+
{
|
|
56
|
+
id: 'claude',
|
|
57
|
+
title: knownTitle('claude'),
|
|
58
|
+
kind: 'claude',
|
|
59
|
+
location: ctx.settingsFile,
|
|
60
|
+
canInstall: true,
|
|
61
|
+
facts: [{ code: found.problems.length ? 'inspection-incomplete' : 'not-installed' }],
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
problems: found.problems.map(code => ({ code, detail: 'claude' })),
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
async function prepareClaudeProgram(ctx, selection) {
|
|
68
|
+
const { id, action } = selection;
|
|
69
|
+
const kind = 'claude';
|
|
70
|
+
const found = await claudePrograms(ctx);
|
|
71
|
+
const program = found.values.get(id) ?? (id === kind && found.values.size === 1 ? [...found.values.values()][0] : undefined);
|
|
72
|
+
if (id !== kind && program === undefined)
|
|
73
|
+
throw new Error('program-changed');
|
|
74
|
+
if (id === kind && !program && found.values.size > 1)
|
|
75
|
+
throw new Error('channel-not-supported');
|
|
76
|
+
if (found.problems.length && !(action === 'uninstall' && program && program.channel !== 'npm'))
|
|
77
|
+
throw new Error('installation-state-unconfirmed');
|
|
78
|
+
if (action === 'detach')
|
|
79
|
+
throw new Error('action-unavailable');
|
|
80
|
+
const programStamp = program ? await ctx.machine.treeStamp(program.binary) : null;
|
|
81
|
+
if (action === 'install' && program && !program.isMissing && programStamp === null)
|
|
82
|
+
throw new Error('program-changed');
|
|
83
|
+
const operation = await prepareClaudeInstallation(ctx, action, program);
|
|
84
|
+
if (action !== 'install')
|
|
85
|
+
return operation;
|
|
86
|
+
const defaults = await prepareSettings(ctx, { id: 'settings', action: 'configure' });
|
|
87
|
+
return {
|
|
88
|
+
...sequence([operation, defaults]),
|
|
89
|
+
action: operation.action ?? 'install',
|
|
90
|
+
...(operation.claude ? { claude: operation.claude } : {}),
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
async function prepareClaudeInstallation(ctx, action, program) {
|
|
94
|
+
if (program && program.channel !== 'npm')
|
|
95
|
+
throw new Error('channel-not-supported');
|
|
96
|
+
if (!['install', 'update', 'uninstall'].includes(action))
|
|
97
|
+
throw new Error('action-unavailable');
|
|
98
|
+
const scope = await freezeNpmScope(ctx);
|
|
99
|
+
const beforeVersion = program?.version ?? null;
|
|
100
|
+
const binary = program?.binary ?? path.join(scope.npmRoot, CLAUDE_PACKAGE, 'cli.js');
|
|
101
|
+
const beforeStamp = await ctx.machine.fingerprint(binary);
|
|
102
|
+
if (action === 'uninstall' && !program)
|
|
103
|
+
throw new Error('program-not-installed');
|
|
104
|
+
const release = action === 'uninstall' ? null : await stableClaudeVersion(ctx);
|
|
105
|
+
if (action === 'uninstall')
|
|
106
|
+
await assertClaudeStopped(ctx);
|
|
107
|
+
const changeCode = action === 'uninstall' ? 'program-uninstall' : beforeVersion ? 'program-update' : 'program-install';
|
|
108
|
+
const job = npmProgram(ctx, {
|
|
109
|
+
name: CLAUDE_PACKAGE,
|
|
110
|
+
readBinary: () => claudeNpmBinary(ctx, scope.npmRoot),
|
|
111
|
+
binary,
|
|
112
|
+
beforeVersion,
|
|
113
|
+
beforeStamp,
|
|
114
|
+
version: release?.value ?? null,
|
|
115
|
+
registry: release?.registry ?? null,
|
|
116
|
+
scope,
|
|
117
|
+
args: CLAUDE_NPM_ARGS,
|
|
118
|
+
...(action === 'uninstall' ? { assertReady: () => assertClaudeStopped(ctx) } : {}),
|
|
119
|
+
}, [{ code: changeCode, detail: release?.value ?? binary }, { code: 'keep-user-data' }]);
|
|
120
|
+
const operation = release
|
|
121
|
+
? sequence([
|
|
122
|
+
job,
|
|
123
|
+
step([], async () => {
|
|
124
|
+
const target = job.binary();
|
|
125
|
+
const result = await ctx.machine.execute(target.endsWith('.js') ? process.execPath : target, target.endsWith('.js') ? [target, '--version'] : ['--version']);
|
|
126
|
+
if (result.failed || result.code !== 0 || result.stdout.trim().split(/\s/)[0] !== release.value)
|
|
127
|
+
throw new Error('binary-version-mismatch');
|
|
128
|
+
return {
|
|
129
|
+
state: 'complete',
|
|
130
|
+
effects: [{ state: 'done', code: 'program-ready' }],
|
|
131
|
+
};
|
|
132
|
+
}),
|
|
133
|
+
])
|
|
134
|
+
: job;
|
|
135
|
+
return {
|
|
136
|
+
...operation,
|
|
137
|
+
action: action === 'uninstall' ? 'uninstall' : beforeVersion ? 'update' : 'install',
|
|
138
|
+
...(release
|
|
139
|
+
? {
|
|
140
|
+
claude: bindClaudeCommand(ctx, () => job.binary(), async () => {
|
|
141
|
+
await operation.verify();
|
|
142
|
+
if (!operation.result().complete)
|
|
143
|
+
throw new Error('dependency-not-ready');
|
|
144
|
+
}),
|
|
145
|
+
}
|
|
146
|
+
: {}),
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
async function stableClaudeVersion(ctx) {
|
|
150
|
+
const release = await resolveNpmView(ctx.machine, `${CLAUDE_PACKAGE}@stable`, 'version', exactVersion);
|
|
151
|
+
if (release !== null)
|
|
152
|
+
return release;
|
|
153
|
+
// npm 查询未得到有效版本时才读取官方稳定版元数据,返回值仍绑定官方来源
|
|
154
|
+
try {
|
|
155
|
+
const metadata = JSON.parse(await ctx.machine.fetchText(`${NPM_OFFICIAL}/@anthropic-ai%2Fclaude-code/stable`, {
|
|
156
|
+
timeoutMs: STABLE_METADATA_TIMEOUT_MS,
|
|
157
|
+
}));
|
|
158
|
+
if (!isObject(metadata))
|
|
159
|
+
throw new Error('invalid-release');
|
|
160
|
+
const version = exactVersion(metadata.version);
|
|
161
|
+
if (version === null)
|
|
162
|
+
throw new Error('invalid-release');
|
|
163
|
+
return { value: version, registry: NPM_OFFICIAL };
|
|
164
|
+
}
|
|
165
|
+
catch {
|
|
166
|
+
throw new Error('stable-release-unavailable');
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
function exactVersion(value) {
|
|
170
|
+
return isExactVersion(value) ? value : null;
|
|
171
|
+
}
|
|
172
|
+
/** 卸载前后核对 Claude 进程,通用 npm 执行器不识别具体包名 */
|
|
173
|
+
async function assertClaudeStopped(ctx) {
|
|
174
|
+
const running = await claudeRunning(ctx.machine);
|
|
175
|
+
if (running !== false)
|
|
176
|
+
throw new Error(running ? 'claude-running' : 'process-state-unconfirmed');
|
|
177
|
+
}
|