flow-comet 1.5.0 → 1.6.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/.flow-comet/rules/flow-comet-orchestration.md +1 -2
- package/.flow-comet/skills/flow-comet/INSTALLED_VERSION +1 -1
- package/.flow-comet/skills/flow-comet/SKILL.md +21 -3
- package/.flow-comet/skills/flow-comet/reference/TEST-MATRIX.md +9 -8
- package/.flow-comet/skills/flow-comet/reference/dsh-platform.md +9 -2
- package/.flow-comet/skills/flow-comet/scripts/guard-self-test.mjs +4233 -94
- package/.flow-comet/skills/flow-comet/scripts/protocol-utils.mjs +24 -4
- package/.flow-comet/skills/flow-comet/scripts/route-node.mjs +697 -15
- package/.flow-comet/skills/flow-comet/scripts/state-schema.mjs +69 -0
- package/.flow-comet/skills/flow-comet/scripts/system-test.mjs +1718 -5
- package/.flow-comet/skills/flow-comet/scripts/task-parsing.mjs +13 -0
- package/.flow-comet/skills/flow-comet/scripts/workflow-guard.mjs +429 -276
- package/.flow-comet/skills/flow-comet/scripts/workflow-handoff.mjs +330 -13
- package/.flow-comet/skills/flow-comet/scripts/workflow-state.mjs +423 -38
- package/.flow-comet/skills/flow-comet-archive/SKILL.md +15 -0
- package/.flow-comet/skills/flow-comet-execute/SKILL.md +19 -1
- package/.flow-comet/skills/flow-comet-review/SKILL.md +21 -3
- package/.flow-comet/skills/flow-comet-subagent-execute/SKILL.md +12 -3
- package/.flow-comet/skills/flow-comet-verify/SKILL.md +19 -4
- package/README.md +7 -3
- package/package.json +1 -1
- package/scripts/dsh-bridge.mjs +2 -2
- package/scripts/prepare-env.mjs +102 -54
package/scripts/prepare-env.mjs
CHANGED
|
@@ -150,7 +150,7 @@ const PLATFORMS = {
|
|
|
150
150
|
const settings = injectSettingsHook(claudeDir);
|
|
151
151
|
const injected = !!(settings.hooks && settings.hooks.PreToolUse);
|
|
152
152
|
stats.files++;
|
|
153
|
-
console.log(`[
|
|
153
|
+
console.log(`[flow-comet] settings.local.json ${injected ? '注入完成(保留既有字段)' : '已生成'}`);
|
|
154
154
|
},
|
|
155
155
|
// rules 注入:.claude/rules/ 整树复制(自动加载 markdown 指令)
|
|
156
156
|
installRules(target, stats) {
|
|
@@ -193,13 +193,13 @@ const PLATFORMS = {
|
|
|
193
193
|
injectCodexHook(codexDir, target);
|
|
194
194
|
injectCodexConfig(codexDir);
|
|
195
195
|
stats.files += 2;
|
|
196
|
-
console.log('[
|
|
196
|
+
console.log('[flow-comet] .codex/hooks.json + config.toml 注入完成(hooks 启用,保留既有字段)');
|
|
197
197
|
},
|
|
198
198
|
// rules 注入:AGENTS.md 托管区内联(Codex 指令唯一自动加载路径;.codex/rules/ 是命令批准规则目录,不混用;
|
|
199
199
|
// 注入函数与托管区标记 codex/dsh 共用——任一平台卸载可清,另一平台重装恢复)
|
|
200
200
|
installRules(target, stats) {
|
|
201
201
|
if (injectManagedRules(target, stats)) {
|
|
202
|
-
console.log('[
|
|
202
|
+
console.log('[flow-comet] AGENTS.md 托管区注入完成(保留托管区外用户内容)');
|
|
203
203
|
}
|
|
204
204
|
},
|
|
205
205
|
// purge 清理:只清 flow-comet 技能(.agents/ 为多工具共享位置——非 flow-comet 条目保留)
|
|
@@ -263,17 +263,17 @@ const PLATFORMS = {
|
|
|
263
263
|
reportLoaderVersionTransition(loaderSrc, loaderDst);
|
|
264
264
|
fs.copyFileSync(loaderSrc, loaderDst);
|
|
265
265
|
stats.files++;
|
|
266
|
-
console.log('[
|
|
266
|
+
console.log('[flow-comet] 桥接 loader 已复制到 $DSH_HOME/plugins/dsh-flow-comet-bridge.mjs');
|
|
267
267
|
injectDshCordisPatch(dshHome, loaderDst);
|
|
268
268
|
stats.files++;
|
|
269
|
-
console.log('[
|
|
269
|
+
console.log('[flow-comet] $DSH_HOME/cordis.patch.yml 托管块注入完成(读-合并-写,保留既有块)');
|
|
270
270
|
} else {
|
|
271
271
|
// 容错:scripts/dsh-bridge.mjs 由并行任务新建——源缺失时 WARN 跳过 loader 复制
|
|
272
272
|
// **并跳过 cordis.patch.yml 托管块注入**(避免注入指向不存在文件的 file:// 引用,
|
|
273
273
|
// 导致 dsh 每次启动尝试加载不存在的插件);仍完成其余安装
|
|
274
274
|
// (AGENTS.md 托管区 / skills 复制照常)
|
|
275
275
|
console.warn(
|
|
276
|
-
'[
|
|
276
|
+
'[flow-comet] 警告: scripts/dsh-bridge.mjs 不存在——跳过 loader 复制与 cordis.patch.yml 托管块注入' +
|
|
277
277
|
'(dsh 桥接拦截暂不生效,待源文件就位后重跑 prepare-env)'
|
|
278
278
|
);
|
|
279
279
|
}
|
|
@@ -281,7 +281,7 @@ const PLATFORMS = {
|
|
|
281
281
|
// rules 注入:AGENTS.md 托管区(与 codex 共用注入函数与托管区标记——任一平台卸载可清)
|
|
282
282
|
installRules(target, stats) {
|
|
283
283
|
if (injectManagedRules(target, stats)) {
|
|
284
|
-
console.log('[
|
|
284
|
+
console.log('[flow-comet] AGENTS.md 托管区注入完成(保留托管区外用户内容)');
|
|
285
285
|
}
|
|
286
286
|
},
|
|
287
287
|
// purge 清理:项目级 .dsh/skills 下全部 flow-comet* 技能(.dsh/skills 为 dsh 技能位置——
|
|
@@ -330,7 +330,7 @@ const PLATFORMS = {
|
|
|
330
330
|
// 全局挂载语义警示:loader 位于 $DSH_HOME(所有 profile / 所有项目共享)——
|
|
331
331
|
// 任一项目 purge 都会连带移除,其它已安装 flow-comet 的项目将静默失去拦截
|
|
332
332
|
console.warn(
|
|
333
|
-
'[
|
|
333
|
+
'[flow-comet] 全局桥接 loader 被移除,其它已安装 flow-comet 的项目将停止拦截' +
|
|
334
334
|
'($DSH_HOME 全局挂载——如需恢复请重跑 prepare-env --platform dsh)'
|
|
335
335
|
);
|
|
336
336
|
}
|
|
@@ -355,6 +355,15 @@ function parseArgs(argv) {
|
|
|
355
355
|
let purge = false;
|
|
356
356
|
let yes = false;
|
|
357
357
|
let platform = null;
|
|
358
|
+
// 零参数 = 没说要做什么:**不安装**,打印用法并非零退出。
|
|
359
|
+
// 修复前它等价于 `fcomet init`(在 cwd 做一次完整安装:建 .claude/、拉 flow-kit/、改写 .gitignore)
|
|
360
|
+
// ——误敲或试探性执行会在当前目录铺开一套环境。`init` 词元仍可选:`fcomet --target X`
|
|
361
|
+
// 与 `fcomet init --target X` 等价(有参数即表达了意图)。
|
|
362
|
+
if (args.length === 0) {
|
|
363
|
+
console.error('[flow-comet] 未指定任何参数——裸执行不安装。');
|
|
364
|
+
printUsage((line) => console.error(line));
|
|
365
|
+
process.exit(1);
|
|
366
|
+
}
|
|
358
367
|
// 命令形态容忍(npm bin 形态 `fcomet init`):包管理器垫片把 `init` 当位置词元传给脚本。
|
|
359
368
|
// 只吃掉**一个**精确等于 `init` 且位于位置参数首位的词元(其前只允许选项词元);
|
|
360
369
|
// 其它非 `--` 开头词元仍按既有语义报「未知参数」——变形词元(如 `int`/`inti`)
|
|
@@ -385,6 +394,11 @@ function parseArgs(argv) {
|
|
|
385
394
|
} else if (a === '--help' || a === '-h') {
|
|
386
395
|
printUsage();
|
|
387
396
|
process.exit(0);
|
|
397
|
+
} else if (a === '--version' || a === '-v') {
|
|
398
|
+
// 版本查询:输出本工具的版本标识(与随包分发、写入目标项目的是同一来源——
|
|
399
|
+
// 见 resolveInstalledVersion;单一来源,不另设版本常量)。
|
|
400
|
+
console.log(resolveInstalledVersion() || 'unknown');
|
|
401
|
+
process.exit(0);
|
|
388
402
|
} else {
|
|
389
403
|
throw new Error(`未知参数: ${a}`);
|
|
390
404
|
}
|
|
@@ -392,15 +406,18 @@ function parseArgs(argv) {
|
|
|
392
406
|
return { target: target ? path.resolve(target) : process.cwd(), purge, yes, platform };
|
|
393
407
|
}
|
|
394
408
|
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
409
|
+
// 用法输出:默认写 stdout(--help);出错时由调用方传入 stderr 写入函数(用法错误走 stderr)。
|
|
410
|
+
function printUsage(write = console.log) {
|
|
411
|
+
write('用法: fcomet init [--target <dir>] [--platform <claude-code|codex|dsh|claude-code,dsh|all>] [--purge --yes]');
|
|
412
|
+
write(' (`fcomet` 与 `flow-comet` 是同一安装器的两个命令名;`init` 词元可省略——`fcomet --target X`');
|
|
413
|
+
write(' 等价于 `fcomet init --target X`;不带任何参数时不安装,只打印本用法)');
|
|
414
|
+
write(' 仓库内直调: node scripts/prepare-env.mjs [--target <dir>] [--platform <...>] [--purge --yes]');
|
|
415
|
+
write(' 从权威源 .flow-comet/ 安装/更新 <dir> 环境(含运行时位置迁移与 .gitignore 纳管)');
|
|
416
|
+
write(' --target 缺省 = 当前工作目录(cwd)');
|
|
417
|
+
write(' --platform 指定平台(claude-code / codex / dsh;逗号分隔多选或 all 全部平台)');
|
|
418
|
+
write(' 缺省 = TTY 交互多选(@clack/prompts,未安装回退 readline)> 探测目标项目 > 默认 claude-code');
|
|
419
|
+
write(' --purge 破坏性:先删除目标平台生成物再重新生成(默认不删除;需 --yes 确认)');
|
|
420
|
+
write(' --version 打印版本标识(等价 -v);--help 打印本用法');
|
|
404
421
|
}
|
|
405
422
|
|
|
406
423
|
// 探测目标项目既有平台痕迹(三痕迹,一次计算复用于探测 / TTY 预勾选 / 多痕迹判定):
|
|
@@ -443,7 +460,7 @@ async function promptPlatformSelection(probe, traces, multiTrace) {
|
|
|
443
460
|
return promptPlatformSelectionReadline(probe, traces, multiTrace);
|
|
444
461
|
}
|
|
445
462
|
const selected = await clack.multiselect({
|
|
446
|
-
message: '[
|
|
463
|
+
message: '[flow-comet] 选择要安装的平台(方向键移动、空格勾选、回车确认)',
|
|
447
464
|
options,
|
|
448
465
|
required: true,
|
|
449
466
|
initialValues: initialValues.length > 0 ? initialValues : undefined,
|
|
@@ -470,7 +487,7 @@ async function promptPlatformSelectionReadline(probe, traces, multiTrace) {
|
|
|
470
487
|
? `(检测到目标项目已有 ${probe === 'claude-code' ? '.claude/' : probe === 'codex' ? '.codex/' : '.dsh/'} 痕迹)`
|
|
471
488
|
: '';
|
|
472
489
|
const answer = await rl.question(
|
|
473
|
-
`[
|
|
490
|
+
`[flow-comet] 选择要安装的平台(可多选)${probeNote}:\n` +
|
|
474
491
|
` 1) Claude Code (claude-code)${traceNote('claude-code', '.claude/')}\n` +
|
|
475
492
|
` 2) Codex (codex)${traceNote('codex', '.codex/')}\n` +
|
|
476
493
|
` 3) DeepSeek Harness (dsh)${traceNote('dsh', '.dsh/')}\n` +
|
|
@@ -539,7 +556,7 @@ async function resolvePlatform(target, platformArg) {
|
|
|
539
556
|
}
|
|
540
557
|
if (multiTrace) {
|
|
541
558
|
const fallbackId = probe ?? 'claude-code';
|
|
542
|
-
console.log(`[
|
|
559
|
+
console.log(`[flow-comet] 检测到目标项目同时有 .claude/、.codex/ 或 .dsh/ 中的多个痕迹——默认安装 ${PLATFORMS[fallbackId].label}。`);
|
|
543
560
|
console.log(' 如需其它平台或组合:交互终端运行,或显式 --platform dsh / claude-code,dsh / all。');
|
|
544
561
|
}
|
|
545
562
|
return [PLATFORMS[probe ?? 'claude-code']];
|
|
@@ -778,7 +795,7 @@ function migrateRuntimeFiles(target) {
|
|
|
778
795
|
for (const entry of RUNTIME_FILE_MIGRATIONS) {
|
|
779
796
|
migrateRuntimeFile(target, entry, report);
|
|
780
797
|
}
|
|
781
|
-
console.log(`[
|
|
798
|
+
console.log(`[flow-comet] 运行时文件迁移(${LEGACY_RUNTIME_DIR}/ → ${RUNTIME_DIR}/;白名单 ${RUNTIME_FILE_MIGRATIONS.length} 项):`);
|
|
782
799
|
for (const line of report.migrated) {
|
|
783
800
|
console.log(` - 已迁移: ${line}`);
|
|
784
801
|
}
|
|
@@ -808,7 +825,7 @@ function isRuntimeDirIgnoreLine(line) {
|
|
|
808
825
|
*/
|
|
809
826
|
function manageGitignore(target) {
|
|
810
827
|
if (fs.existsSync(path.join(target, RUNTIME_DIR, 'skills', 'flow-comet', 'SKILL.md'))) {
|
|
811
|
-
console.log(`[
|
|
828
|
+
console.log(`[flow-comet] .gitignore 纳管跳过: 当前目录是 flow-comet 源仓库(${RUNTIME_DIR}/ 为权威源,需保持被版本控制跟踪)`);
|
|
812
829
|
return;
|
|
813
830
|
}
|
|
814
831
|
const gitignorePath = path.join(target, '.gitignore');
|
|
@@ -826,14 +843,14 @@ function manageGitignore(target) {
|
|
|
826
843
|
}
|
|
827
844
|
}
|
|
828
845
|
if (existing.split(/\r?\n/).some(isRuntimeDirIgnoreLine)) {
|
|
829
|
-
console.log(`[
|
|
846
|
+
console.log(`[flow-comet] .gitignore 已含 ${RUNTIME_DIR}/ 条目——保持原样(幂等)`);
|
|
830
847
|
return;
|
|
831
848
|
}
|
|
832
849
|
const eol = existing.includes('\r\n') ? '\r\n' : '\n';
|
|
833
850
|
const appended = ['# flow-comet 运行时文件(不随仓库分发)', `${RUNTIME_DIR}/`].join(eol);
|
|
834
851
|
const separator = !fileExists || existing === '' || existing.endsWith('\n') ? '' : eol;
|
|
835
852
|
fs.writeFileSync(gitignorePath, existing + separator + appended + eol, 'utf8');
|
|
836
|
-
console.log(`[
|
|
853
|
+
console.log(`[flow-comet] .gitignore 追加 ${RUNTIME_DIR}/ 条目(既有内容原样保留): ${gitignorePath}`);
|
|
837
854
|
}
|
|
838
855
|
|
|
839
856
|
// ---------- settings.local.json 注入(Claude Code 平台;参考 comet installClaudeCodeHooks) ----------
|
|
@@ -948,7 +965,7 @@ function injectSettingsHook(claudeDir) {
|
|
|
948
965
|
if (existingHooks.PreToolUse !== undefined && !Array.isArray(existingHooks.PreToolUse)) {
|
|
949
966
|
// PreToolUse 非数组(手写变体):保留原值 + 警告,不注入(避免破坏用户结构)
|
|
950
967
|
console.error(
|
|
951
|
-
'[
|
|
968
|
+
'[flow-comet] 警告: settings.local.json 的 hooks.PreToolUse 不是数组(可能是手写变体)——' +
|
|
952
969
|
'为保护用户配置,未注入 comet hook。请手动添加(见 README 方案 B)。'
|
|
953
970
|
);
|
|
954
971
|
return settings;
|
|
@@ -1188,13 +1205,13 @@ function compareBridgeVersions(a, b) {
|
|
|
1188
1205
|
|
|
1189
1206
|
/**
|
|
1190
1207
|
* 覆盖前版本比对明示:从权威源 loader 与已装 loader 各提取版本戳,按数值序输出
|
|
1191
|
-
* 首次安装 / 升级 A→B / 降级 A→B / 版本一致 四类结论之一(人读、带 [
|
|
1208
|
+
* 首次安装 / 升级 A→B / 降级 A→B / 版本一致 四类结论之一(人读、带 [flow-comet] 前缀)。
|
|
1192
1209
|
* 任一侧提取失败(文件缺失/无标记行)→ 告警并跳过比对——不抛错、不中断安装;
|
|
1193
1210
|
* 覆盖动作(copyFileSync)由调用方照常执行,幂等语义不变。
|
|
1194
1211
|
*/
|
|
1195
1212
|
function reportLoaderVersionTransition(loaderSrc, loaderDst) {
|
|
1196
1213
|
if (!fs.existsSync(loaderDst)) {
|
|
1197
|
-
console.log('[
|
|
1214
|
+
console.log('[flow-comet] 桥接 loader 首次安装($DSH_HOME/plugins 无已装 loader)');
|
|
1198
1215
|
return;
|
|
1199
1216
|
}
|
|
1200
1217
|
const src = extractBridgeVersion(loaderSrc);
|
|
@@ -1203,7 +1220,7 @@ function reportLoaderVersionTransition(loaderSrc, loaderDst) {
|
|
|
1203
1220
|
const failedSide = !src.ok ? '权威源 loader' : '已装 loader';
|
|
1204
1221
|
const reason = !src.ok ? src.reason : installed.reason;
|
|
1205
1222
|
console.warn(
|
|
1206
|
-
`[
|
|
1223
|
+
`[flow-comet] 警告: ${failedSide} 版本戳提取失败(${reason})——跳过版本比对,继续覆盖安装`
|
|
1207
1224
|
);
|
|
1208
1225
|
return;
|
|
1209
1226
|
}
|
|
@@ -1211,11 +1228,11 @@ function reportLoaderVersionTransition(loaderSrc, loaderDst) {
|
|
|
1211
1228
|
const b = src.version;
|
|
1212
1229
|
const cmp = compareBridgeVersions(a, b);
|
|
1213
1230
|
if (cmp < 0) {
|
|
1214
|
-
console.log(`[
|
|
1231
|
+
console.log(`[flow-comet] 桥接 loader 升级 ${a} → ${b}`);
|
|
1215
1232
|
} else if (cmp > 0) {
|
|
1216
|
-
console.log(`[
|
|
1233
|
+
console.log(`[flow-comet] 桥接 loader 降级 ${a} → ${b}`);
|
|
1217
1234
|
} else {
|
|
1218
|
-
console.log(`[
|
|
1235
|
+
console.log(`[flow-comet] 桥接 loader 版本一致(${a})`);
|
|
1219
1236
|
}
|
|
1220
1237
|
}
|
|
1221
1238
|
|
|
@@ -1321,17 +1338,48 @@ function stripManagedBlock(content, startMarker, endMarker) {
|
|
|
1321
1338
|
|
|
1322
1339
|
// ---------- 版本标识(全部平台共用) ----------
|
|
1323
1340
|
|
|
1341
|
+
/**
|
|
1342
|
+
* 目录**本身**是否为 git 仓库根。判据 = `git rev-parse --show-toplevel` 指回自身。
|
|
1343
|
+
* git 从 cwd 起**向上**找仓库,故嵌套在别人仓库里的目录同样能拿到结果——必须比对。
|
|
1344
|
+
* 同时静音 stderr:git 在非仓库目录会打印 `fatal: not a git repository`,不该漏给用户。
|
|
1345
|
+
*/
|
|
1346
|
+
function isRepositoryRoot(dir) {
|
|
1347
|
+
try {
|
|
1348
|
+
const top = execFileSync('git', ['rev-parse', '--show-toplevel'], {
|
|
1349
|
+
cwd: dir, encoding: 'utf8', timeout: 30000, stdio: ['ignore', 'pipe', 'ignore'],
|
|
1350
|
+
}).trim();
|
|
1351
|
+
if (!top) return false;
|
|
1352
|
+
const normalize = (value) => {
|
|
1353
|
+
let resolved = value;
|
|
1354
|
+
try { resolved = fs.realpathSync(value); } catch { /* 取不到真实路径时用词法路径 */ }
|
|
1355
|
+
return process.platform === 'win32' ? resolved.toLowerCase() : resolved;
|
|
1356
|
+
};
|
|
1357
|
+
return normalize(top) === normalize(dir);
|
|
1358
|
+
} catch {
|
|
1359
|
+
return false; // 无 git / 非仓库:一律不采信
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
1362
|
+
|
|
1324
1363
|
/**
|
|
1325
1364
|
* 版本标识:优先从源仓库 git describe 生成(多人协作精确检测——发布版 = 精确 tag,
|
|
1326
1365
|
* 开发态 = "<tag>-<领先提交数>-g<hash>",提 issue 时维护者可据此判断包含哪些积累);
|
|
1327
1366
|
* 无 git(纯手动复制兜底)时用权威源随技能包分发的 INSTALLED_VERSION(最近发布版本)。
|
|
1367
|
+
*
|
|
1368
|
+
* **采信 git 的前提 = 本目录就是仓库根**(仓库检出形态)。包被装在别人的仓库里时
|
|
1369
|
+
* (本地安装进项目 → `<项目>/node_modules/flow-comet`),git 会向上找到**宿主仓库**,
|
|
1370
|
+
* 把宿主 tag 当成流工具版本——该值是错的,且它正是写进目标项目版本标识的那个值
|
|
1371
|
+
* (issue 报版本 / bridge-check 比对 / 套件跨值守卫会跟着全错)。故非仓库根一律回退包内文件。
|
|
1328
1372
|
*/
|
|
1329
1373
|
function resolveInstalledVersion() {
|
|
1330
1374
|
let installedVersion = '';
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1375
|
+
if (isRepositoryRoot(REPO_ROOT)) {
|
|
1376
|
+
try {
|
|
1377
|
+
const desc = execFileSync('git', ['describe', '--tags'], {
|
|
1378
|
+
cwd: REPO_ROOT, encoding: 'utf8', timeout: 30000, stdio: ['ignore', 'pipe', 'ignore'],
|
|
1379
|
+
}).trim();
|
|
1380
|
+
if (desc) installedVersion = desc.replace(/^v/, ''); // 剥 v 前缀,与 CHANGELOG 版本号一致
|
|
1381
|
+
} catch { /* 无 tag:回退权威源文件 */ }
|
|
1382
|
+
}
|
|
1335
1383
|
if (!installedVersion) {
|
|
1336
1384
|
const bundled = path.join(BUNDLE_DRAFTS, 'skills', 'flow-comet', 'INSTALLED_VERSION');
|
|
1337
1385
|
if (fs.existsSync(bundled)) installedVersion = fs.readFileSync(bundled, 'utf8').trim();
|
|
@@ -1358,9 +1406,9 @@ function gitErrorFirstLine(err) {
|
|
|
1358
1406
|
/** 手动获取指引(clone/checkout 失败或目录非上游克隆时打印——含上游 URL 与目标路径;不抛错) */
|
|
1359
1407
|
function printFlowKitManualGuide(target) {
|
|
1360
1408
|
const flowKitDir = path.join(target, 'flow-kit');
|
|
1361
|
-
console.warn(`[
|
|
1362
|
-
console.warn(`[
|
|
1363
|
-
console.warn('[
|
|
1409
|
+
console.warn(`[flow-comet] 手动获取指引: git clone ${FLOW_KIT_UPSTREAM_URL} "${flowKitDir}"`);
|
|
1410
|
+
console.warn(`[flow-comet] 然后锁定快照: git -C "${flowKitDir}" checkout --detach ${FLOW_KIT_LOCKED_COMMIT.slice(0, FLOW_KIT_SHORT_SHA_LEN)}`);
|
|
1411
|
+
console.warn('[flow-comet] 未获取 flow-kit 时技能协议引用悬空、guard 段名基准退化为内置 fallback——其余安装职责不受影响。');
|
|
1364
1412
|
}
|
|
1365
1413
|
|
|
1366
1414
|
/**
|
|
@@ -1403,10 +1451,10 @@ function ensureFlowKit(target) {
|
|
|
1403
1451
|
encoding: 'utf8',
|
|
1404
1452
|
timeout: FLOW_KIT_GIT_TIMEOUT_MS,
|
|
1405
1453
|
});
|
|
1406
|
-
console.log(`[
|
|
1454
|
+
console.log(`[flow-comet] 已获取 flow-kit(锁定 ${shortLock})`);
|
|
1407
1455
|
} catch (err) {
|
|
1408
1456
|
// 路径 4:clone/checkout 任一失败 → WARN + 手动指引,不抛错
|
|
1409
|
-
console.warn(`[
|
|
1457
|
+
console.warn(`[flow-comet] 警告: flow-kit 自动获取失败(${gitErrorFirstLine(err)})`);
|
|
1410
1458
|
printFlowKitManualGuide(target);
|
|
1411
1459
|
}
|
|
1412
1460
|
return;
|
|
@@ -1417,9 +1465,9 @@ function ensureFlowKit(target) {
|
|
|
1417
1465
|
if (originStatus !== 'match') {
|
|
1418
1466
|
// 路径 3:同名非克隆目录(或 remote 无法确认归属)→ 跳过 + 指引,绝不改动
|
|
1419
1467
|
if (originStatus === 'unreadable') {
|
|
1420
|
-
console.warn('[
|
|
1468
|
+
console.warn('[flow-comet] 警告: flow-kit 目录存在且含 .git,但 origin remote 读取失败——无法确认归属');
|
|
1421
1469
|
}
|
|
1422
|
-
console.log('[
|
|
1470
|
+
console.log('[flow-comet] 目录存在但非上游克隆,已跳过');
|
|
1423
1471
|
printFlowKitManualGuide(target);
|
|
1424
1472
|
return;
|
|
1425
1473
|
}
|
|
@@ -1430,18 +1478,18 @@ function ensureFlowKit(target) {
|
|
|
1430
1478
|
timeout: FLOW_KIT_GIT_TIMEOUT_MS,
|
|
1431
1479
|
}).trim();
|
|
1432
1480
|
const shortHead = head.slice(0, FLOW_KIT_SHORT_SHA_LEN);
|
|
1433
|
-
console.log(`[
|
|
1481
|
+
console.log(`[flow-comet] 已有 flow-kit(HEAD=${shortHead},推荐锁定点=${shortLock})`);
|
|
1434
1482
|
if (head === FLOW_KIT_LOCKED_COMMIT) {
|
|
1435
|
-
console.log('[
|
|
1483
|
+
console.log('[flow-comet] 当前 HEAD 与推荐锁定点一致。');
|
|
1436
1484
|
} else {
|
|
1437
1485
|
console.warn(
|
|
1438
|
-
`[
|
|
1486
|
+
`[flow-comet] 差异影响: 当前 HEAD 与推荐锁定点不一致——guard 段名基准与协议引用可能偏离安装器锁定内容` +
|
|
1439
1487
|
`(安装器绝不改动已有克隆;如需对齐请手动执行 git -C "${flowKitDir}" fetch 后 checkout --detach ${shortLock})`
|
|
1440
1488
|
);
|
|
1441
1489
|
}
|
|
1442
1490
|
} catch (err) {
|
|
1443
1491
|
// HEAD 只读失败同样不改动、不中断安装(保守降级为警告)
|
|
1444
|
-
console.warn(`[
|
|
1492
|
+
console.warn(`[flow-comet] 警告: flow-kit HEAD 读取失败(${gitErrorFirstLine(err)}),已跳过比对`);
|
|
1445
1493
|
}
|
|
1446
1494
|
}
|
|
1447
1495
|
|
|
@@ -1468,13 +1516,13 @@ async function main() {
|
|
|
1468
1516
|
|
|
1469
1517
|
// --purge(已在上方确认 --yes):逐平台删除生成物后重新生成
|
|
1470
1518
|
if (purge) {
|
|
1471
|
-
console.error(`[
|
|
1519
|
+
console.error(`[flow-comet] 警告: --purge 将删除 ${platformsLabel} 平台的以下生成物(不可恢复):`);
|
|
1472
1520
|
for (const platform of platforms) {
|
|
1473
1521
|
for (const entry of platform.purge(target)) {
|
|
1474
1522
|
console.error(` - ${entry}`);
|
|
1475
1523
|
}
|
|
1476
1524
|
}
|
|
1477
|
-
console.error('[
|
|
1525
|
+
console.error('[flow-comet] 已删除,开始重新生成。');
|
|
1478
1526
|
}
|
|
1479
1527
|
|
|
1480
1528
|
// flow-kit 获取链路(ADR-008 / D1~D6——平台无关,平台循环之前调用一次;
|
|
@@ -1486,7 +1534,7 @@ async function main() {
|
|
|
1486
1534
|
const stats = { dirs: 0, files: 0, skills: [] };
|
|
1487
1535
|
|
|
1488
1536
|
// 覆盖前打印将覆盖的生成物清单(默认非破坏:只覆盖生成物)
|
|
1489
|
-
console.log(`[
|
|
1537
|
+
console.log(`[flow-comet] 平台: ${platform.label} — 将覆盖以下生成物(其他内容保留):`);
|
|
1490
1538
|
console.log(` - ${skillRoot}`);
|
|
1491
1539
|
for (const line of platform.overwriteDescription(target)) {
|
|
1492
1540
|
console.log(` - ${line}`);
|
|
@@ -1513,7 +1561,7 @@ async function main() {
|
|
|
1513
1561
|
}
|
|
1514
1562
|
const replacedFiles = applyPathReplacements(skillRoot, platform.pathReplacements);
|
|
1515
1563
|
if (replacedFiles > 0) {
|
|
1516
|
-
console.log(`[
|
|
1564
|
+
console.log(`[flow-comet] 平台路径替换: ${replacedFiles} 个 .md 文件(${platform.label} 命令路径)`);
|
|
1517
1565
|
}
|
|
1518
1566
|
|
|
1519
1567
|
// 4. 版本标识(写入平台技能根,随技能包分发)
|
|
@@ -1522,11 +1570,11 @@ async function main() {
|
|
|
1522
1570
|
stats.files++;
|
|
1523
1571
|
|
|
1524
1572
|
// 摘要(逐平台)
|
|
1525
|
-
console.log(`[
|
|
1573
|
+
console.log(`[flow-comet] 已准备环境: ${target}(${platform.label})`);
|
|
1526
1574
|
console.log(
|
|
1527
|
-
`[
|
|
1575
|
+
`[flow-comet] 目录 ${stats.dirs} 个、文件 ${stats.files} 个、skills ${stats.skills.length} 个`
|
|
1528
1576
|
);
|
|
1529
|
-
console.log(`[
|
|
1577
|
+
console.log(`[flow-comet] skills: ${stats.skills.join(', ')}`);
|
|
1530
1578
|
}
|
|
1531
1579
|
|
|
1532
1580
|
// 执行顺序第三段:.gitignore 保守纳管(部署成功后执行——失败即中止,可重跑自愈)
|
|
@@ -1536,6 +1584,6 @@ async function main() {
|
|
|
1536
1584
|
try {
|
|
1537
1585
|
await main();
|
|
1538
1586
|
} catch (err) {
|
|
1539
|
-
console.error(`[
|
|
1587
|
+
console.error(`[flow-comet] 错误: ${err.message}`);
|
|
1540
1588
|
process.exit(1);
|
|
1541
1589
|
}
|