agentic-flow-kit 1.7.15 → 1.7.16

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.
Files changed (101) hide show
  1. package/README.md +41 -3
  2. package/modules/hosts/claude/commands/wf-design.md +5 -4
  3. package/modules/hosts/claude/commands/wf-new-task.md +42 -21
  4. package/modules/hosts/claude/commands/wf-review.md +1 -1
  5. package/modules/hosts/claude/commands/wf-sync-hosts.md +7 -13
  6. package/modules/hosts/claude/commands/wf-test.md +1 -1
  7. package/modules/hosts/codex/commands/wf-design.md +5 -4
  8. package/modules/hosts/codex/commands/wf-new-task.md +42 -21
  9. package/modules/hosts/codex/commands/wf-review.md +1 -1
  10. package/modules/hosts/codex/commands/wf-sync-hosts.md +7 -13
  11. package/modules/hosts/codex/commands/wf-test.md +1 -1
  12. package/modules/hosts/cursor/commands/wf-design.md +5 -4
  13. package/modules/hosts/cursor/commands/wf-new-task.md +42 -21
  14. package/modules/hosts/cursor/commands/wf-review.md +1 -1
  15. package/modules/hosts/cursor/commands/wf-sync-hosts.md +7 -13
  16. package/modules/hosts/cursor/commands/wf-test.md +1 -1
  17. package/modules/hosts/opencode/commands/wf-design.md +5 -4
  18. package/modules/hosts/opencode/commands/wf-new-task.md +42 -21
  19. package/modules/hosts/opencode/commands/wf-review.md +1 -1
  20. package/modules/hosts/opencode/commands/wf-sync-hosts.md +7 -13
  21. package/modules/hosts/opencode/commands/wf-test.md +1 -1
  22. package/modules/hosts/trae/commands/wf-design.md +5 -4
  23. package/modules/hosts/trae/commands/wf-new-task.md +42 -21
  24. package/modules/hosts/trae/commands/wf-review.md +1 -1
  25. package/modules/hosts/trae/commands/wf-sync-hosts.md +7 -13
  26. package/modules/hosts/trae/commands/wf-test.md +1 -1
  27. package/package.json +1 -1
  28. package/src/cli.mjs +43 -4
  29. package/src/doctor.mjs +37 -1
  30. package/src/executor.mjs +245 -0
  31. package/src/executor.test.mjs +292 -0
  32. package/src/init.mjs +7 -0
  33. package/src/profiles.mjs +3 -0
  34. package/src/render.mjs +3 -3
  35. package/src/sync-hosts.mjs +37 -43
  36. package/src/sync-hosts.test.mjs +67 -56
  37. package/templates/.gitattributes +8 -0
  38. package/templates/AGENTS.md +1 -1
  39. package/templates/_agents/commands/design.md +5 -4
  40. package/templates/_agents/commands/new-task.md +42 -21
  41. package/templates/_agents/commands/review.md +1 -1
  42. package/templates/_agents/commands/sync-hosts.md +7 -13
  43. package/templates/_agents/commands/test.md +1 -1
  44. package/templates/_agents/control-surfaces.txt +1 -1
  45. package/templates/_agents/engine-lock.json +246 -0
  46. package/templates/_agents/lane-surfaces.txt +1 -1
  47. package/templates/_agents/level-hints.txt +30 -0
  48. package/templates/_agents/scripts/agg-delegations.test.mjs +5 -3
  49. package/templates/_agents/scripts/check-engine-integrity.mjs +55 -126
  50. package/templates/_agents/scripts/check-engine-integrity.test.mjs +33 -45
  51. package/templates/_agents/scripts/check-lane-surface.mjs +72 -23
  52. package/templates/_agents/scripts/check-lane-surface.test.mjs +66 -0
  53. package/templates/_agents/scripts/check-ledger-invariant.mjs +112 -14
  54. package/templates/_agents/scripts/check-ledger-invariant.test.mjs +5 -1
  55. package/templates/_agents/scripts/check-loop-rev.test.mjs +6 -4
  56. package/templates/_agents/scripts/check-loop.mjs +49 -41
  57. package/templates/_agents/scripts/check-loop.test.mjs +18 -13
  58. package/templates/_agents/scripts/check-metric-claims.mjs +4 -2
  59. package/templates/_agents/scripts/compact-ledgers.mjs +97 -0
  60. package/templates/_agents/scripts/compact-ledgers.test.mjs +162 -0
  61. package/templates/_agents/scripts/confirm-doc.mjs +40 -11
  62. package/templates/_agents/scripts/doctor.test.mjs +44 -1
  63. package/templates/_agents/scripts/edit-face-check.test.mjs +5 -4
  64. package/templates/_agents/scripts/fill-intent.mjs +2 -2
  65. package/templates/_agents/scripts/fixture-scripts.mjs +153 -0
  66. package/templates/_agents/scripts/fixture-scripts.test.mjs +107 -0
  67. package/templates/_agents/scripts/gate-checklist.mjs +4 -9
  68. package/templates/_agents/scripts/gate-checklist.test.mjs +2 -11
  69. package/templates/_agents/scripts/gen-workflow-dashboard.mjs +8 -11
  70. package/templates/_agents/scripts/gen-workflow-metrics.mjs +9 -33
  71. package/templates/_agents/scripts/git-merge-jsonl.mjs +63 -0
  72. package/templates/_agents/scripts/git-merge-jsonl.test.mjs +125 -0
  73. package/templates/_agents/scripts/ledger-doc-chain.test.mjs +166 -0
  74. package/templates/_agents/scripts/ledger-loader.mjs +108 -0
  75. package/templates/_agents/scripts/ledger-loader.test.mjs +131 -0
  76. package/templates/_agents/scripts/ledger-prune.mjs +96 -0
  77. package/templates/_agents/scripts/ledger-prune.test.mjs +120 -0
  78. package/templates/_agents/scripts/ledger-ts-monotonic.test.mjs +135 -0
  79. package/templates/_agents/scripts/level-criteria.mjs +232 -0
  80. package/templates/_agents/scripts/level-criteria.test.mjs +279 -0
  81. package/templates/_agents/scripts/pipeline-run.mjs +4 -2
  82. package/templates/_agents/scripts/policy.mjs +47 -0
  83. package/templates/_agents/scripts/stage-gates.mjs +4 -9
  84. package/templates/_agents/scripts/wf-journal.test.mjs +1 -1
  85. package/templates/_agents/scripts/wiki-search.test.mjs +5 -6
  86. package/templates/_agents/scripts/workflows-check.mjs +1 -1
  87. package/templates/_agents/workflows/pipeline-closing.md +4 -5
  88. package/templates/_githooks/pre-commit +3 -34
  89. package/templates/_githooks/pre-push +3 -3
  90. package/templates/workflow/README.md +11 -0
  91. package/modules/hosts/claude/commands/wf-source-sync-check.md +0 -89
  92. package/modules/hosts/codex/commands/wf-source-sync-check.md +0 -89
  93. package/modules/hosts/cursor/commands/wf-source-sync-check.md +0 -89
  94. package/modules/hosts/opencode/commands/wf-source-sync-check.md +0 -89
  95. package/modules/hosts/trae/commands/wf-source-sync-check.md +0 -90
  96. package/templates/_agents/commands/source-sync-check.md +0 -103
  97. package/templates/_agents/scripts/check-ledger.mjs +0 -109
  98. package/templates/_agents/scripts/check-ledger.test.mjs +0 -199
  99. package/templates/_agents/scripts/source-sync-check.mjs +0 -156
  100. package/templates/_agents/scripts/source-sync-check.test.mjs +0 -286
  101. package/templates/_agents/workflows/source-sync-repair.md +0 -30
@@ -6,22 +6,21 @@ import fs from 'node:fs';
6
6
  import path from 'node:path';
7
7
  import os from 'node:os';
8
8
  import { spawnSync } from 'node:child_process';
9
- import { fileURLToPath } from 'node:url';
10
9
 
11
- const SRC = path.dirname(fileURLToPath(import.meta.url));
12
10
  let pass = 0, fail = 0;
13
11
  const check = (name, cond, detail = '') => {
14
12
  if (cond) { pass++; console.log(`PASS ${name}`); }
15
13
  else { fail++; console.log(`FAIL ${name}${detail ? `——${detail}` : ''}`); }
16
14
  };
17
15
 
18
- const COPIED = ['wiki-search.mjs', 'kb-search.mjs', 'workflow-enums.mjs'];
16
+ // 夹具闭包(2026-10-12 fixture-closure-rootfix):入口只写 wiki-search.mjs,kb-search 及其传递依赖
17
+ // (workflow-enums.mjs 等)由闭包自动带入——此前手写枚举,漏拷即 import 失败 → 假绿。
18
+ const { copyScriptClosure, copyAgentsFiles } = await import('./fixture-scripts.mjs');
19
19
  function mkFixture() {
20
20
  const fx = fs.mkdtempSync(path.join(os.tmpdir(), 'ws-'));
21
21
  fs.mkdirSync(path.join(fx, '.agents', 'scripts'), { recursive: true });
22
- for (const f of COPIED) fs.copyFileSync(path.join(SRC, f), path.join(fx, '.agents', 'scripts', f));
23
- for (const f of ['workflow-enums.txt', 'workflow-modules.txt'])
24
- fs.copyFileSync(path.join(SRC, '..', f), path.join(fx, '.agents', f));
22
+ copyScriptClosure(path.join(fx, '.agents', 'scripts'), ['wiki-search.mjs']);
23
+ copyAgentsFiles(path.join(fx, '.agents'), ['workflow-enums.txt', 'workflow-modules.txt']);
25
24
  fs.mkdirSync(path.join(fx, 'wiki', '测试主题'), { recursive: true });
26
25
  fs.writeFileSync(path.join(fx, 'wiki', '测试主题', '说明.md'), '# 说明\n\n编码模板的领域知识条目。\n');
27
26
  fs.mkdirSync(path.join(fx, 'workflow', 'intents'), { recursive: true });
@@ -27,7 +27,7 @@
27
27
  // 到首个非 `|` 行截止;仅此一张表——编排脚本按机制文档只允许一张 stages 表。
28
28
  // 用法:node .agents/scripts/workflows-check.mjs [--root <目标根>] [--json]
29
29
  // 默认根 = process.cwd()(doctor 以 cwd=target 调用;仓库根直跑即自扫)
30
- // 零依赖;只报告不修复(B-b 决策口径,同 source-sync-check)
30
+ // 零依赖;只报告不修复(B-b 决策口径)
31
31
  // 测试:node templates/_agents/scripts/workflows-check.test.mjs(fixture + 真实仓库 baseline)
32
32
  import fs from 'node:fs';
33
33
  import path from 'node:path';
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: pipeline-closing
3
- description: 推广环节 6 阶段闭环——起草 intent + plan(双写)→ 用户对话内确认 → 按 plan 改动面实施 → 3 关静态门(source-sync-check / npm test / doctor)→ 关单留痕(intent + plan → done + docs commit)。可复用于本项目所有 L1 推广环节(新增工具 / 微改动 / 协议修补)
3
+ description: 推广环节 6 阶段闭环——起草 intent + plan(双写)→ 用户对话内确认 → 按 plan 改动面实施 → 2 关静态门(npm test / doctor)→ 关单留痕(intent + plan → done + docs commit)。可复用于本项目所有 L1 推广环节(新增工具 / 微改动 / 协议修补)
4
4
  concurrency: 2
5
5
  ---
6
6
  # workflow — pipeline-closing(推广环节 6 阶段闭环)
@@ -13,14 +13,13 @@ concurrency: 2
13
13
  | gate-doc | author | — | — | — | — | — | node .agents/scripts/fill-intent.test.mjs && node .agents/scripts/fill-plan.test.mjs | | |
14
14
  | confirm | gate-doc | — | — | plan 草稿全文过目,用户对话内一句"可以" → plan 状态 draft → approved + 回填「确认与复核」节 | — | plan 状态 approved + 「确认结果:approved(YYYY-MM-DD 用户对话内确认)」 | | 用户确认(plan 确认门) | |
15
15
  | plan-commit | confirm | implementer | — | 提交 plan 立项 commit(docs(workflow)) | workflow/intents/, workflow/plans/, workflow/INDEX.md | pre-commit 钩子全过;commit message 含 plan 改动面摘要 | | | 0 |
16
- | build | plan-commit | implementer | — | 按 plan §改动面 执行(含双源纪律:包源改了装副本手动同步) | 见 plan | plan 改动面全部完成;双源文件 sha 一致 | | | 1 |
17
- | gate-sync | build | — | — | — | — | — | node .agents/scripts/source-sync-check.mjs --diff(必须 0 差异) | | |
16
+ | build | plan-commit | implementer | — | 按 plan §改动面 执行 | 见 plan | plan 改动面全部完成 | | | 1 |
18
17
  | gate-test | build | — | — | — | — | — | npm test(必须全绿) | | |
19
18
  | gate-doctor | build | — | — | — | — | — | node bin/flow-kit.mjs doctor(必须 0 FAIL) | | |
20
- | feat-commit | gate-sync,gate-test,gate-doctor | implementer | — | 提交 feat commit(feat(模块名)) | 工作区所有变更文件 | pre-commit 钩子全过;commit message 含 build 改动面摘要 | | | 0 |
19
+ | feat-commit | gate-test,gate-doctor | implementer | — | 提交 feat commit(feat(模块名)) | 工作区所有变更文件 | pre-commit 钩子全过;commit message 含 build 改动面摘要 | | | 0 |
21
20
  | closeout | feat-commit | implementer | — | 补 intent 8 条验收勾验 + plan → done + 关单 docs commit 留痕;同步 INDEX.md(如适用) | workflow/intents/<date>-<topic>.md, workflow/plans/<date>-<topic>.md, workflow/INDEX.md | intent + plan 状态均 done;8 条验收勾验含 commit SHA 证据;commit message 含关单 commit + 8 条勾验摘要 | | | 0 |
22
21
 
23
- **编排语义**:第 0 层 author → 第 1 层 gate-doc + confirm(confirm 为 human 确认门形态——宿主 AI 停下询问用户,不派子智能体;通过才派下层)→ 第 2 层 plan-commit → 第 3 层 build → 第 4 层 3 关静态门(并行 fan-out)→ 第 5 层 feat-commit → 第 6 层 closeout。失败且 retries > 0 → 重派(全新上下文);gate 非零 / human 驳回 → 中止后续、汇总报告失败项。每个 stage 每次尝试出结果记 `wf-journal.mjs add`;中止续跑先 `wf-journal.mjs status --wf pipeline-closing`(已 pass 不重跑)。
22
+ **编排语义**:第 0 层 author → 第 1 层 gate-doc + confirm(confirm 为 human 确认门形态——宿主 AI 停下询问用户,不派子智能体;通过才派下层)→ 第 2 层 plan-commit → 第 3 层 build → 第 4 层 2 关静态门(并行 fan-out)→ 第 5 层 feat-commit → 第 6 层 closeout。失败且 retries > 0 → 重派(全新上下文);gate 非零 / human 驳回 → 中止后续、汇总报告失败项。每个 stage 每次尝试出结果记 `wf-journal.mjs add`;中止续跑先 `wf-journal.mjs status --wf pipeline-closing`(已 pass 不重跑)。
24
23
 
25
24
  **纪律**(先读):
26
25
  - 声明随 plan 确认后方可执行——本 workflow 是 plan 任务拆解的执行器;plan 草稿先经用户对话内确认。
@@ -1,6 +1,6 @@
1
1
  #!/bin/sh
2
2
  # Git 原生 pre-commit hook(经 core.hooksPath 挂载,git 执行、不依赖 agent 客户端)— agentic-flow-kit 通用编排
3
- # 通用门禁序:闭环配对(增量) → 泳道完整性(增量) → wiki 台账(增量) → 常驻面体积预算(增量) → 双源一致性(增量) → managed 台账快检(包源恒跑) → 项目门禁(local-pre-commit) → 敏感信息扫描+条件构建(commit-check.cjs)
3
+ # 通用门禁序:闭环配对(增量) → 泳道完整性(增量) → wiki 台账(增量) → 常驻面体积预算(增量) → 确认台账不变量(暂存触台账) → 项目门禁(local-pre-commit) → 敏感信息扫描+条件构建(commit-check.cjs)
4
4
  # 项目专属门禁(架构红线/业务守卫等)放 .agents/hooks/local-pre-commit——存在即在本钩子内执行,返回非零即阻断提交
5
5
  # 合并提交场景由 .githooks/pre-merge-commit 原样转发到本脚本(合并时 git 调的是 pre-merge-commit,
6
6
  # 不是 pre-commit)——门禁清单只此一份,避免两处分叉
@@ -21,7 +21,7 @@ run_gate() {
21
21
  # 闭环配对门禁(增量版,check-pairing-incremental.sh:本次暂存的 intents/incidents 入口须已有同名 plan)
22
22
  # experiment/* 泳道分支(2026-09-30 hybrid-governance-explore-hardening):降级为 advisory——快速 PoC
23
23
  # 迭代不因闭环文档断档被拦(断档报告照出),转正合入 main 由 pre-push 加固门(check-loop --hardening)兜底。
24
- # 仅降级闭环文档面:双源 / 台账 / 常驻面 / 敏感信息扫描等门禁不豁免。分支不可判(detached HEAD 等)走严格模式。
24
+ # 仅降级闭环文档面:常驻面 / 敏感信息扫描等门禁不豁免。分支不可判(detached HEAD 等)走严格模式。
25
25
  pairing_gate_mode=strict
26
26
  case "$(git rev-parse --abbrev-ref HEAD 2>/dev/null)" in
27
27
  experiment/*) pairing_gate_mode=advisory ;;
@@ -44,7 +44,7 @@ fi
44
44
  # 检查 B「探索标记缺失」——experiment/* 分支暂存 intent 缺「阶段: exploring」→ 拦(标记零成本,
45
45
  # advisory 免纪律不免标记——标记是加固门覆盖率的前提)。
46
46
  # 旧装副本无脚本自然跳过;node 缺失时本门跳过(其后 commit-check 节点检查仍会拦提交,无空洞)。
47
- # 注意:不经 run_gate(其实现为 sh "$@",会把 node 当脚本解释——直接 node 调用,模式同双源门禁块)。
47
+ # 注意:不经 run_gate(其实现为 sh "$@",会把 node 当脚本解释——直接 node 调用)。
48
48
  if [ -f .agents/scripts/check-lane-surface.mjs ] && command -v node >/dev/null 2>&1; then
49
49
  if ! node .agents/scripts/check-lane-surface.mjs; then
50
50
  echo "pre-commit: 泳道完整性(增量)未通过,提交已阻止" >&2
@@ -62,37 +62,6 @@ if [ -f .agents/scripts/rule-budget.sh ] && [ -f .agents/rule-budgets.txt ]; the
62
62
  run_gate "常驻面体积预算" .agents/scripts/rule-budget.sh --staged
63
63
  fi
64
64
 
65
- # 双源一致性(增量,2026-09-27 audit-gate-hardening):包源 templates/_agents/ 与装副本 .agents/ 须同提交成对。
66
- # 暂存触及任一侧时跑 source-sync-check --gate(缺失/漂移 exit 1,孤儿只报告)——拦「包源改了装副本没跟」
67
- # (doctor §4 台账 sha 对此静默:盘面=台账即 PASS;该故障模式曾两次真实发生,见 incidents/2026-09-25-wf-runtime)。
68
- # 比较工作树而非暂存区(口径沿 check-pairing-incremental 先例):两侧都已改好、分两笔提交时不拦——最终一致即可。
69
- # 已知边界(复核 P2-2 声明,2026-09-27 gate-hardening-p2-batch):包源删除文件不触发缺失/漂移——装副本残件
70
- # 退化为「孤儿」只报告不计失败,删包源时须手动同步清理装副本(sync 对 removed 同样仅报告不删盘)。
71
- # 装户环境(无 templates/_agents/ 包源)自然跳过。
72
- if [ -d templates/_agents ] && [ -f .agents/scripts/source-sync-check.mjs ] \
73
- && git -c core.quotepath=off diff --cached --name-only | grep -qE '^(templates/_agents/|\.agents/)'; then
74
- if ! node .agents/scripts/source-sync-check.mjs --gate; then
75
- echo "pre-commit: 双源一致性(增量)未通过,提交已阻止——单边改动先跑 node bin/flow-kit.mjs sync 成对后原路重试" >&2
76
- exit 1
77
- fi
78
- fi
79
-
80
- # managed 台账快检(包源环境恒跑,2026-09-28 ledger-precommit-gate;同日独立复核 P2-2 采纳):
81
- # kit.json 台账 sha ↔ 盘面工作树(LF 归一,同 doctor §4 口径)——拦「台账 sha 预 landing」:台账记了
82
- # 盘面尚不存在的内容 sha。双源门禁对此静默(templates↔.agents 成对回退时两侧一致),doctor §4 只在
83
- # 手动全量跑——该故障模式三次真实发生(0272a1c 预入 / ff3c721 还原窗口 / 537df18 闭合),本块补齐
84
- # 提交时刻的第三边。恒跑不作暂存触发:预 landing 是仓态而非暂存态,暂存 grep 有前缀缝(如 .githooks/*
85
- # managed 件单边漂移不命中),毫秒级 80 份 hash 不构成开销理由。比较工作树而非暂存区(沿双源门禁
86
- # 口径)。装户环境(无 templates/_agents/ 包源)自然跳过——装户 managed 手改走 doctor §4 WARN 口径,
87
- # 不硬拦。已知边界:managed 删除即拦(sync 对 removed 只报不删,删件须手动同步装副本并重跑 sync 刷
88
- # 台账)。
89
- if [ -d templates/_agents ] && [ -f .agents/scripts/check-ledger.mjs ]; then
90
- if ! node .agents/scripts/check-ledger.mjs; then
91
- echo "pre-commit: managed 台账快检未通过,提交已阻止——kit.json 与盘面不一致,跑 node bin/flow-kit.mjs sync 成对后原路重试" >&2
92
- exit 1
93
- fi
94
- fi
95
-
96
65
  # 确认台账不变量前置(--staged,2026-10-02 ledger-ci-invariant):暂存的 confirmations.jsonl 必须
97
66
  # 是 HEAD 的逐字节前缀扩展(append-only)——本地提交时刻即拦「顺手重写台账」,CI 历史全扫兜底。
98
67
  # guard 旧装副本自然跳过;暂存未触台账静默。
@@ -12,9 +12,9 @@
12
12
  # (intent approved/done + 同名 plan 在场 + L2/L3 另须同名 spec;判据见 check-loop.mjs 加固门段),
13
13
  # hard 失败即阻断 push,防「未文档化的探索件」进 main。
14
14
  #
15
- # 机器门:本地钩子(唯一机器门)——kit 不附带 CI 配置,装户仓裸装无跨环境保证。
16
- # kit 源仓:.github/workflows/ci.yml 于 push main / 全部 PR 复跑 check-loop / doctor / source-sync-check --gate / workflows-check 四道门。
17
- # 装户仓(无 templates/ 包源):无 CI——source-sync-check --gate / doctor / flow-kit 命令不适用(引用即失败),本地钩子即全部机器门。
15
+ # 机器门:本地钩子跑 check-loop.sh。装户仓的远端门是随包下发的 .github/workflows/kit-ci.yml(verify.mjs)。
16
+ # kit 源仓:.github/workflows/ci.yml 于 push main / 全部 PR 跑 npm test(lint + 全量套件)。
17
+ # 装户仓无包源 templates/:sync-hosts 等包源命令不适用。本地钩子仍是提交时刻的机器门。
18
18
  # 不要用 `git push --no-verify` 绕开——发现 hard-block 应先修 workflow 文档再推。
19
19
 
20
20
  cd "$(git rev-parse --show-toplevel)" || exit 1
@@ -54,6 +54,17 @@
54
54
  4. **敏感信息**:pre-commit 的 commit-check 扫描密钥。
55
55
  5. **双源与台账**:doctor 核对 managed / owned 的 sha;引擎改动改包源 `templates/` 再 `sync`。
56
56
  6. **台账不可变**(2026-10-02 ledger-ci-invariant):`confirmations.jsonl` 历史行禁删改(append-only 前缀不变量,机器门 = CI 历史全扫 + pre-commit `--staged` 前置);误写/修正只能**追加补偿行**,篡改历史属审计事件(`git revert` 整个提交后重新追加)。
57
+ 7. **台账并发三形态与修剪通道**(2026-10-12,台账是尾部追加形态,撞三种正常协作):
58
+
59
+ | 形态 | 机制 | 用法 |
60
+ |---|---|---|
61
+ | 多人/多分支合并冲突 | `.gitattributes` 的 `.agents/*.jsonl merge=jsonl-union` → `git-merge-jsonl.mjs` 并集去重(两侧行全保留,无冲突可解) | 需目标仓 `.gitattributes` 有该行 + 本机 `git config merge.jsonl-union.driver "node .agents/scripts/git-merge-jsonl.mjs %O %A %B"`(`init` 自动配) |
62
+ | 单机多 worktree 并行 append | `confirm-doc --shard` 写 `.agents/confirmations.d/<doc>.jsonl`,各写各的互不覆盖;里程碑跑 `compact-ledgers.mjs [--execute]` 并回主台账 | `--shard` **依赖 doc 链口径**(`kit.json` 须 `policyVersion: 8`+),缺锚时参数期直接拒 |
63
+ | 所有者明令删某批文档 | **特许修剪**:同笔提交 `.agents/ledger-prune-manifest.json`(`{ts, authority, reason, removes:[被删行 sha256], docs:[家族名]}`),门禁逐行对账放行 | 无 manifest 的删/改/重排**仍全拦** |
64
+
65
+ 哈希链的域是「同一 doc 的逻辑序」而非文件物理序——并发 append / 并集合并 / 分片归并都不会打断它;就地改行、删行、插行三类篡改照拦。诚实边界:manifest 是可写文件,**刻意伪造即可让任意删行合法化**(与「台账本地可写」同级),本通道只把「顺手手改」抬到「提交一份可被 git 历史对质的凭据」。
66
+
67
+ > **存量装户迁移动作**:`merge=jsonl-union` 属 `.gitattributes`,而该文件是**项目自持(owned)**、`sync` 永不覆盖——升级后**不会自动获得**,需手动在目标仓 `.gitattributes` 补一行 `.agents/*.jsonl merge=jsonl-union`。driver 是本机态配置、不跨机共享(漏配退化为文本冲突,不静默丢数据但要人工解)。
57
68
 
58
69
  其余检查(占位符、引用、模块字段、常驻面预算、量化签名、阶段索引、适配器断线、引擎脚本测试覆盖(检查 20,包源环境——新增引擎脚本默认必须带 `.test.mjs`,库件/工具须登记 `.agents/scripts-test-exempt.txt`,2026-10-01 gate-script-test-coverage))只在 `audit` 不是 `false` 时出警告。
59
70
 
@@ -1,89 +0,0 @@
1
- ---
2
- description: 装户面同步一致性检查(包源 templates/_agents/ vs 装副本 .agents/ 三类差异:缺失 / 孤儿 / 漂移)
3
- ---
4
-
5
- > **装户边界**:本文档中 `src/`、`bin/flow-kit.mjs`、`templates/_agents/`、`modules/hosts/` 为 kit 包源仓视角引用——装户仓(无 `templates/` 包源)对应命令不适用,本仓以 `.agents/` 装副本为准。
6
-
7
- # Source-Sync-Check · 装户面同步一致性
8
-
9
- > `templates/_agents/` 包源 vs `.agents/` 装副本——三类差异报告:缺失 / 孤儿 / 漂移。
10
- > managed 文件由 `flow-kit sync` 跟踪;owned 文件由 `flow-kit doctor` §6.6 校验——本工具补"两者都没扫"的真空地带(结构级差异)。
11
-
12
- ## 1. 何时跑
13
-
14
- - 改 `templates/_agents/*` 包源后
15
- - 怀疑装副本未跟包源更新
16
- - 体检装副本完整性(清理前 / 发版前)
17
- - 不跑:仅改装副本 `.agents/*`(B-b 决策「只报告」+ 不反向同步)
18
-
19
- ## 2. 怎么跑
20
-
21
- ### 2.1 默认 `--diff`(仅报告)
22
-
23
- ```
24
- node .agents/scripts/source-sync-check.mjs --diff
25
- node .agents/scripts/source-sync-check.mjs --json # 机器可读
26
- node .agents/scripts/source-sync-check.mjs --pkg-root <path> --target <path> # 自定义路径
27
- ```
28
-
29
- 输出三类:
30
- - **缺失**(missing)——包源有 / 装副本无(如新增文件 init 未执行)
31
- - **孤儿**(orphan)——包源无 / 装副本有(如历史残留 / 用户本地添加)
32
- - **漂移**(drift)——两者都有但 sha 不一致(如包源改了装副本未跟)
33
-
34
- **排除**:
35
- - `templates/_agents/cache/`(运行时缓存,与 `flow-kit sync` 既有约定一致)
36
- - `.agents/kit.json` / `.agents/settings.json`(init 渲染产物,不属双源)
37
-
38
- ### 2.2 输出示例
39
-
40
- ```
41
- ▶ flow-kit source-sync-check --diff
42
- 包源 (templates/_agents/) 49 份 | 装副本 (.agents/) 49 份
43
- 缺失(包源有 / 装副本 无)1:
44
- - scripts/source-sync-check.mjs
45
- 孤儿(包源无 / 装副本 有)1:
46
- - hooks/commit-check.config.json
47
- 漂移(包源装副本都有但 sha 不一致)3:
48
- - commands/maintain.md pkg=3782b695… tgt=26203f7b…
49
- - notes/runtime-env.md pkg=aedde1ba… tgt=ad08441e…
50
- - scripts/ensure-board.mjs pkg=e66653b0… tgt=b6f3cc9b…
51
- ```
52
-
53
- ### 2.3 自验
54
-
55
- ```
56
- node .agents/scripts/source-sync-check.test.mjs # 11 场景全过
57
- npm test # 含 source-sync-check 套件
58
- flow-kit doctor # 10/0/0
59
- ```
60
-
61
- ## 3. 边界(不要做)
62
-
63
- - 不要自动化同步(B-b 决策「只报告不修复」——与 `gate-checklist` 同源)
64
- - 不改 managed 台账跟踪逻辑(`sync.mjs` 不动)
65
- - 不改 owned 漂移校验(`doctor.mjs` §6.6 不动)
66
- - 不反向同步——装副本独自有文件(如 hooks/commit-check.config.json)可能是装户配置,不应被删
67
- - 不检查注册表内宿主 `modules/hosts/` 薄适配漂移(那是 `flow-kit sync-hosts` 范围)
68
-
69
- ## 4. 当前已识别的真实漂点(首次实测,2026-09-25)
70
-
71
- - **缺失**:本工具写完后未同步装副本(预期内——随本次 commit 解决)
72
- - **孤儿**:`.agents/hooks/commit-check.config.json`(装副本独有,疑似装户配置)
73
- - **漂移**:`commands/maintain.md` / `notes/runtime-env.md` / `scripts/ensure-board.mjs`
74
-
75
- 修复留后续 incident / intent 跟踪(不在本次范围)。
76
-
77
- ## 5. 与既有工具的关系
78
-
79
- | 工具 | 作用域 | 算法 |
80
- |---|---|---|
81
- | `flow-kit sync` | managed 文件(kit.json 台账跟踪)| 三态覆盖 + 加新 + 报错缺 |
82
- | `flow-kit doctor` §6.6 | owned 文件(kit.owned 哈希比对)| 盘面 sha vs 台账哈希 |
83
- | **`flow-kit source-sync-check`** | **所有文件结构(包源 ↔ 装副本全集)** | **sha 全量比对 + 缺失/孤儿分类** |
84
-
85
- 三者互补,不重叠。
86
-
87
- ## 6. 相关留痕
88
-
89
- - 立法出处:2026-09-25 source-sync-check(intent/plan;父事件 = 包源改了装副本未同步,本工具预防性体检)——留痕在包源仓 git 历史与 CHANGELOG,装户径不引实例路径
@@ -1,89 +0,0 @@
1
- ---
2
- description: 装户面同步一致性检查(包源 templates/_agents/ vs 装副本 .agents/ 三类差异:缺失 / 孤儿 / 漂移)
3
- ---
4
-
5
- > **装户边界**:本文档中 `src/`、`bin/flow-kit.mjs`、`templates/_agents/`、`modules/hosts/` 为 kit 包源仓视角引用——装户仓(无 `templates/` 包源)对应命令不适用,本仓以 `.agents/` 装副本为准。
6
-
7
- # Source-Sync-Check · 装户面同步一致性
8
-
9
- > `templates/_agents/` 包源 vs `.agents/` 装副本——三类差异报告:缺失 / 孤儿 / 漂移。
10
- > managed 文件由 `flow-kit sync` 跟踪;owned 文件由 `flow-kit doctor` §6.6 校验——本工具补"两者都没扫"的真空地带(结构级差异)。
11
-
12
- ## 1. 何时跑
13
-
14
- - 改 `templates/_agents/*` 包源后
15
- - 怀疑装副本未跟包源更新
16
- - 体检装副本完整性(清理前 / 发版前)
17
- - 不跑:仅改装副本 `.agents/*`(B-b 决策「只报告」+ 不反向同步)
18
-
19
- ## 2. 怎么跑
20
-
21
- ### 2.1 默认 `--diff`(仅报告)
22
-
23
- ```
24
- node .agents/scripts/source-sync-check.mjs --diff
25
- node .agents/scripts/source-sync-check.mjs --json # 机器可读
26
- node .agents/scripts/source-sync-check.mjs --pkg-root <path> --target <path> # 自定义路径
27
- ```
28
-
29
- 输出三类:
30
- - **缺失**(missing)——包源有 / 装副本无(如新增文件 init 未执行)
31
- - **孤儿**(orphan)——包源无 / 装副本有(如历史残留 / 用户本地添加)
32
- - **漂移**(drift)——两者都有但 sha 不一致(如包源改了装副本未跟)
33
-
34
- **排除**:
35
- - `templates/_agents/cache/`(运行时缓存,与 `flow-kit sync` 既有约定一致)
36
- - `.agents/kit.json` / `.agents/settings.json`(init 渲染产物,不属双源)
37
-
38
- ### 2.2 输出示例
39
-
40
- ```
41
- ▶ flow-kit source-sync-check --diff
42
- 包源 (templates/_agents/) 49 份 | 装副本 (.agents/) 49 份
43
- 缺失(包源有 / 装副本 无)1:
44
- - scripts/source-sync-check.mjs
45
- 孤儿(包源无 / 装副本 有)1:
46
- - hooks/commit-check.config.json
47
- 漂移(包源装副本都有但 sha 不一致)3:
48
- - commands/maintain.md pkg=3782b695… tgt=26203f7b…
49
- - notes/runtime-env.md pkg=aedde1ba… tgt=ad08441e…
50
- - scripts/ensure-board.mjs pkg=e66653b0… tgt=b6f3cc9b…
51
- ```
52
-
53
- ### 2.3 自验
54
-
55
- ```
56
- node .agents/scripts/source-sync-check.test.mjs # 11 场景全过
57
- npm test # 含 source-sync-check 套件
58
- flow-kit doctor # 10/0/0
59
- ```
60
-
61
- ## 3. 边界(不要做)
62
-
63
- - 不要自动化同步(B-b 决策「只报告不修复」——与 `gate-checklist` 同源)
64
- - 不改 managed 台账跟踪逻辑(`sync.mjs` 不动)
65
- - 不改 owned 漂移校验(`doctor.mjs` §6.6 不动)
66
- - 不反向同步——装副本独自有文件(如 hooks/commit-check.config.json)可能是装户配置,不应被删
67
- - 不检查注册表内宿主 `modules/hosts/` 薄适配漂移(那是 `flow-kit sync-hosts` 范围)
68
-
69
- ## 4. 当前已识别的真实漂点(首次实测,2026-09-25)
70
-
71
- - **缺失**:本工具写完后未同步装副本(预期内——随本次 commit 解决)
72
- - **孤儿**:`.agents/hooks/commit-check.config.json`(装副本独有,疑似装户配置)
73
- - **漂移**:`commands/maintain.md` / `notes/runtime-env.md` / `scripts/ensure-board.mjs`
74
-
75
- 修复留后续 incident / intent 跟踪(不在本次范围)。
76
-
77
- ## 5. 与既有工具的关系
78
-
79
- | 工具 | 作用域 | 算法 |
80
- |---|---|---|
81
- | `flow-kit sync` | managed 文件(kit.json 台账跟踪)| 三态覆盖 + 加新 + 报错缺 |
82
- | `flow-kit doctor` §6.6 | owned 文件(kit.owned 哈希比对)| 盘面 sha vs 台账哈希 |
83
- | **`flow-kit source-sync-check`** | **所有文件结构(包源 ↔ 装副本全集)** | **sha 全量比对 + 缺失/孤儿分类** |
84
-
85
- 三者互补,不重叠。
86
-
87
- ## 6. 相关留痕
88
-
89
- - 立法出处:2026-09-25 source-sync-check(intent/plan;父事件 = 包源改了装副本未同步,本工具预防性体检)——留痕在包源仓 git 历史与 CHANGELOG,装户径不引实例路径
@@ -1,89 +0,0 @@
1
- ---
2
- description: 装户面同步一致性检查(包源 templates/_agents/ vs 装副本 .agents/ 三类差异:缺失 / 孤儿 / 漂移)
3
- ---
4
-
5
- > **装户边界**:本文档中 `src/`、`bin/flow-kit.mjs`、`templates/_agents/`、`modules/hosts/` 为 kit 包源仓视角引用——装户仓(无 `templates/` 包源)对应命令不适用,本仓以 `.agents/` 装副本为准。
6
-
7
- # Source-Sync-Check · 装户面同步一致性
8
-
9
- > `templates/_agents/` 包源 vs `.agents/` 装副本——三类差异报告:缺失 / 孤儿 / 漂移。
10
- > managed 文件由 `flow-kit sync` 跟踪;owned 文件由 `flow-kit doctor` §6.6 校验——本工具补"两者都没扫"的真空地带(结构级差异)。
11
-
12
- ## 1. 何时跑
13
-
14
- - 改 `templates/_agents/*` 包源后
15
- - 怀疑装副本未跟包源更新
16
- - 体检装副本完整性(清理前 / 发版前)
17
- - 不跑:仅改装副本 `.agents/*`(B-b 决策「只报告」+ 不反向同步)
18
-
19
- ## 2. 怎么跑
20
-
21
- ### 2.1 默认 `--diff`(仅报告)
22
-
23
- ```
24
- node .agents/scripts/source-sync-check.mjs --diff
25
- node .agents/scripts/source-sync-check.mjs --json # 机器可读
26
- node .agents/scripts/source-sync-check.mjs --pkg-root <path> --target <path> # 自定义路径
27
- ```
28
-
29
- 输出三类:
30
- - **缺失**(missing)——包源有 / 装副本无(如新增文件 init 未执行)
31
- - **孤儿**(orphan)——包源无 / 装副本有(如历史残留 / 用户本地添加)
32
- - **漂移**(drift)——两者都有但 sha 不一致(如包源改了装副本未跟)
33
-
34
- **排除**:
35
- - `templates/_agents/cache/`(运行时缓存,与 `flow-kit sync` 既有约定一致)
36
- - `.agents/kit.json` / `.agents/settings.json`(init 渲染产物,不属双源)
37
-
38
- ### 2.2 输出示例
39
-
40
- ```
41
- ▶ flow-kit source-sync-check --diff
42
- 包源 (templates/_agents/) 49 份 | 装副本 (.agents/) 49 份
43
- 缺失(包源有 / 装副本 无)1:
44
- - scripts/source-sync-check.mjs
45
- 孤儿(包源无 / 装副本 有)1:
46
- - hooks/commit-check.config.json
47
- 漂移(包源装副本都有但 sha 不一致)3:
48
- - commands/maintain.md pkg=3782b695… tgt=26203f7b…
49
- - notes/runtime-env.md pkg=aedde1ba… tgt=ad08441e…
50
- - scripts/ensure-board.mjs pkg=e66653b0… tgt=b6f3cc9b…
51
- ```
52
-
53
- ### 2.3 自验
54
-
55
- ```
56
- node .agents/scripts/source-sync-check.test.mjs # 11 场景全过
57
- npm test # 含 source-sync-check 套件
58
- flow-kit doctor # 10/0/0
59
- ```
60
-
61
- ## 3. 边界(不要做)
62
-
63
- - 不要自动化同步(B-b 决策「只报告不修复」——与 `gate-checklist` 同源)
64
- - 不改 managed 台账跟踪逻辑(`sync.mjs` 不动)
65
- - 不改 owned 漂移校验(`doctor.mjs` §6.6 不动)
66
- - 不反向同步——装副本独自有文件(如 hooks/commit-check.config.json)可能是装户配置,不应被删
67
- - 不检查注册表内宿主 `modules/hosts/` 薄适配漂移(那是 `flow-kit sync-hosts` 范围)
68
-
69
- ## 4. 当前已识别的真实漂点(首次实测,2026-09-25)
70
-
71
- - **缺失**:本工具写完后未同步装副本(预期内——随本次 commit 解决)
72
- - **孤儿**:`.agents/hooks/commit-check.config.json`(装副本独有,疑似装户配置)
73
- - **漂移**:`commands/maintain.md` / `notes/runtime-env.md` / `scripts/ensure-board.mjs`
74
-
75
- 修复留后续 incident / intent 跟踪(不在本次范围)。
76
-
77
- ## 5. 与既有工具的关系
78
-
79
- | 工具 | 作用域 | 算法 |
80
- |---|---|---|
81
- | `flow-kit sync` | managed 文件(kit.json 台账跟踪)| 三态覆盖 + 加新 + 报错缺 |
82
- | `flow-kit doctor` §6.6 | owned 文件(kit.owned 哈希比对)| 盘面 sha vs 台账哈希 |
83
- | **`flow-kit source-sync-check`** | **所有文件结构(包源 ↔ 装副本全集)** | **sha 全量比对 + 缺失/孤儿分类** |
84
-
85
- 三者互补,不重叠。
86
-
87
- ## 6. 相关留痕
88
-
89
- - 立法出处:2026-09-25 source-sync-check(intent/plan;父事件 = 包源改了装副本未同步,本工具预防性体检)——留痕在包源仓 git 历史与 CHANGELOG,装户径不引实例路径
@@ -1,89 +0,0 @@
1
- ---
2
- description: 装户面同步一致性检查(包源 templates/_agents/ vs 装副本 .agents/ 三类差异:缺失 / 孤儿 / 漂移;横向工具)
3
- ---
4
-
5
- > **装户边界**:本文档中 `src/`、`bin/flow-kit.mjs`、`templates/_agents/`、`modules/hosts/` 为 kit 包源仓视角引用——装户仓(无 `templates/` 包源)对应命令不适用,本仓以 `.agents/` 装副本为准。
6
-
7
- # Source-Sync-Check · 装户面同步一致性
8
-
9
- > `templates/_agents/` 包源 vs `.agents/` 装副本——三类差异报告:缺失 / 孤儿 / 漂移。
10
- > managed 文件由 `flow-kit sync` 跟踪;owned 文件由 `flow-kit doctor` §6.6 校验——本工具补"两者都没扫"的真空地带(结构级差异)。
11
-
12
- ## 1. 何时跑
13
-
14
- - 改 `templates/_agents/*` 包源后
15
- - 怀疑装副本未跟包源更新
16
- - 体检装副本完整性(清理前 / 发版前)
17
- - 不跑:仅改装副本 `.agents/*`(B-b 决策「只报告」+ 不反向同步)
18
-
19
- ## 2. 怎么跑
20
-
21
- ### 2.1 默认 `--diff`(仅报告)
22
-
23
- ```
24
- node .agents/scripts/source-sync-check.mjs --diff
25
- node .agents/scripts/source-sync-check.mjs --json # 机器可读
26
- node .agents/scripts/source-sync-check.mjs --pkg-root <path> --target <path> # 自定义路径
27
- ```
28
-
29
- 输出三类:
30
- - **缺失**(missing)——包源有 / 装副本无(如新增文件 init 未执行)
31
- - **孤儿**(orphan)——包源无 / 装副本有(如历史残留 / 用户本地添加)
32
- - **漂移**(drift)——两者都有但 sha 不一致(如包源改了装副本未跟)
33
-
34
- **排除**:
35
- - `templates/_agents/cache/`(运行时缓存,与 `flow-kit sync` 既有约定一致)
36
- - `.agents/kit.json` / `.agents/settings.json`(init 渲染产物,不属双源)
37
-
38
- ### 2.2 输出示例
39
-
40
- ```
41
- ▶ flow-kit source-sync-check --diff
42
- 包源 (templates/_agents/) 49 份 | 装副本 (.agents/) 49 份
43
- 缺失(包源有 / 装副本 无)1:
44
- - scripts/source-sync-check.mjs
45
- 孤儿(包源无 / 装副本 有)1:
46
- - hooks/commit-check.config.json
47
- 漂移(包源装副本都有但 sha 不一致)3:
48
- - commands/maintain.md pkg=3782b695… tgt=26203f7b…
49
- - notes/runtime-env.md pkg=aedde1ba… tgt=ad08441e…
50
- - scripts/ensure-board.mjs pkg=e66653b0… tgt=b6f3cc9b…
51
- ```
52
-
53
- ### 2.3 自验
54
-
55
- ```
56
- node .agents/scripts/source-sync-check.test.mjs # 11 场景全过
57
- npm test # 含 source-sync-check 套件
58
- flow-kit doctor # 10/0/0
59
- ```
60
-
61
- ## 3. 边界(不要做)
62
-
63
- - 不要自动化同步(B-b 决策「只报告不修复」——与 `gate-checklist` 同源)
64
- - 不改 managed 台账跟踪逻辑(`sync.mjs` 不动)
65
- - 不改 owned 漂移校验(`doctor.mjs` §6.6 不动)
66
- - 不反向同步——装副本独自有文件(如 hooks/commit-check.config.json)可能是装户配置,不应被删
67
- - 不检查注册表内宿主 `modules/hosts/` 薄适配漂移(那是 `flow-kit sync-hosts` 范围)
68
-
69
- ## 4. 当前已识别的真实漂点(首次实测,2026-09-25)
70
-
71
- - **缺失**:本工具写完后未同步装副本(预期内——随本次 commit 解决)
72
- - **孤儿**:`.agents/hooks/commit-check.config.json`(装副本独有,疑似装户配置)
73
- - **漂移**:`commands/maintain.md` / `notes/runtime-env.md` / `scripts/ensure-board.mjs`
74
-
75
- 修复留后续 incident / intent 跟踪(不在本次范围)。
76
-
77
- ## 5. 与既有工具的关系
78
-
79
- | 工具 | 作用域 | 算法 |
80
- |---|---|---|
81
- | `flow-kit sync` | managed 文件(kit.json 台账跟踪)| 三态覆盖 + 加新 + 报错缺 |
82
- | `flow-kit doctor` §6.6 | owned 文件(kit.owned 哈希比对)| 盘面 sha vs 台账哈希 |
83
- | **`flow-kit source-sync-check`** | **所有文件结构(包源 ↔ 装副本全集)** | **sha 全量比对 + 缺失/孤儿分类** |
84
-
85
- 三者互补,不重叠。
86
-
87
- ## 6. 相关留痕
88
-
89
- - 立法出处:2026-09-25 source-sync-check(intent/plan;父事件 = 包源改了装副本未同步,本工具预防性体检)——留痕在包源仓 git 历史与 CHANGELOG,装户径不引实例路径
@@ -1,90 +0,0 @@
1
- ---
2
- name: wf-source-sync-check
3
- description: 装户面同步一致性检查(包源 templates/_agents/ vs 装副本 .agents/ 三类差异:缺失 / 孤儿 / 漂移;横向工具)
4
- ---
5
-
6
- > **装户边界**:本文档中 `src/`、`bin/flow-kit.mjs`、`templates/_agents/`、`modules/hosts/` 为 kit 包源仓视角引用——装户仓(无 `templates/` 包源)对应命令不适用,本仓以 `.agents/` 装副本为准。
7
-
8
- # Source-Sync-Check · 装户面同步一致性
9
-
10
- > `templates/_agents/` 包源 vs `.agents/` 装副本——三类差异报告:缺失 / 孤儿 / 漂移。
11
- > managed 文件由 `flow-kit sync` 跟踪;owned 文件由 `flow-kit doctor` §6.6 校验——本工具补"两者都没扫"的真空地带(结构级差异)。
12
-
13
- ## 1. 何时跑
14
-
15
- - 改 `templates/_agents/*` 包源后
16
- - 怀疑装副本未跟包源更新
17
- - 体检装副本完整性(清理前 / 发版前)
18
- - 不跑:仅改装副本 `.agents/*`(B-b 决策「只报告」+ 不反向同步)
19
-
20
- ## 2. 怎么跑
21
-
22
- ### 2.1 默认 `--diff`(仅报告)
23
-
24
- ```
25
- node .agents/scripts/source-sync-check.mjs --diff
26
- node .agents/scripts/source-sync-check.mjs --json # 机器可读
27
- node .agents/scripts/source-sync-check.mjs --pkg-root <path> --target <path> # 自定义路径
28
- ```
29
-
30
- 输出三类:
31
- - **缺失**(missing)——包源有 / 装副本无(如新增文件 init 未执行)
32
- - **孤儿**(orphan)——包源无 / 装副本有(如历史残留 / 用户本地添加)
33
- - **漂移**(drift)——两者都有但 sha 不一致(如包源改了装副本未跟)
34
-
35
- **排除**:
36
- - `templates/_agents/cache/`(运行时缓存,与 `flow-kit sync` 既有约定一致)
37
- - `.agents/kit.json` / `.agents/settings.json`(init 渲染产物,不属双源)
38
-
39
- ### 2.2 输出示例
40
-
41
- ```
42
- ▶ flow-kit source-sync-check --diff
43
- 包源 (templates/_agents/) 49 份 | 装副本 (.agents/) 49 份
44
- 缺失(包源有 / 装副本 无)1:
45
- - scripts/source-sync-check.mjs
46
- 孤儿(包源无 / 装副本 有)1:
47
- - hooks/commit-check.config.json
48
- 漂移(包源装副本都有但 sha 不一致)3:
49
- - commands/maintain.md pkg=3782b695… tgt=26203f7b…
50
- - notes/runtime-env.md pkg=aedde1ba… tgt=ad08441e…
51
- - scripts/ensure-board.mjs pkg=e66653b0… tgt=b6f3cc9b…
52
- ```
53
-
54
- ### 2.3 自验
55
-
56
- ```
57
- node .agents/scripts/source-sync-check.test.mjs # 11 场景全过
58
- npm test # 含 source-sync-check 套件
59
- flow-kit doctor # 10/0/0
60
- ```
61
-
62
- ## 3. 边界(不要做)
63
-
64
- - 不要自动化同步(B-b 决策「只报告不修复」——与 `gate-checklist` 同源)
65
- - 不改 managed 台账跟踪逻辑(`sync.mjs` 不动)
66
- - 不改 owned 漂移校验(`doctor.mjs` §6.6 不动)
67
- - 不反向同步——装副本独自有文件(如 hooks/commit-check.config.json)可能是装户配置,不应被删
68
- - 不检查注册表内宿主 `modules/hosts/` 薄适配漂移(那是 `flow-kit sync-hosts` 范围)
69
-
70
- ## 4. 当前已识别的真实漂点(首次实测,2026-09-25)
71
-
72
- - **缺失**:本工具写完后未同步装副本(预期内——随本次 commit 解决)
73
- - **孤儿**:`.agents/hooks/commit-check.config.json`(装副本独有,疑似装户配置)
74
- - **漂移**:`commands/maintain.md` / `notes/runtime-env.md` / `scripts/ensure-board.mjs`
75
-
76
- 修复留后续 incident / intent 跟踪(不在本次范围)。
77
-
78
- ## 5. 与既有工具的关系
79
-
80
- | 工具 | 作用域 | 算法 |
81
- |---|---|---|
82
- | `flow-kit sync` | managed 文件(kit.json 台账跟踪)| 三态覆盖 + 加新 + 报错缺 |
83
- | `flow-kit doctor` §6.6 | owned 文件(kit.owned 哈希比对)| 盘面 sha vs 台账哈希 |
84
- | **`flow-kit source-sync-check`** | **所有文件结构(包源 ↔ 装副本全集)** | **sha 全量比对 + 缺失/孤儿分类** |
85
-
86
- 三者互补,不重叠。
87
-
88
- ## 6. 相关留痕
89
-
90
- - 立法出处:2026-09-25 source-sync-check(intent/plan;父事件 = 包源改了装副本未同步,本工具预防性体检)——留痕在包源仓 git 历史与 CHANGELOG,装户径不引实例路径