agentic-flow-kit 0.6.0 → 0.8.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.
Files changed (31) hide show
  1. package/modules/hosts/opencode/commands/{sync-hosts.md → wf-sync-hosts.md} +1 -1
  2. package/modules/hosts/trae/commands/wf-sync-hosts.md +1 -1
  3. package/package.json +1 -1
  4. package/src/doctor.mjs +9 -4
  5. package/src/profiles.mjs +19 -2
  6. package/src/sync-hosts.mjs +12 -6
  7. package/src/sync-hosts.test.mjs +14 -11
  8. package/templates/AGENTS.md +1 -1
  9. package/templates/_agents/commands/sync-hosts.md +1 -1
  10. package/templates/_agents/metric-claims.txt +81 -0
  11. package/templates/_agents/scripts/check-ledger.mjs +65 -0
  12. package/templates/_agents/scripts/check-ledger.test.mjs +127 -0
  13. package/templates/_agents/scripts/check-loop.mjs +277 -1
  14. package/templates/_agents/scripts/check-loop.test.mjs +496 -1
  15. package/templates/_agents/scripts/doctor.test.mjs +10 -5
  16. package/templates/_agents/scripts/gate-checklist.mjs +1 -0
  17. package/templates/_agents/scripts/gen-workflow-metrics.mjs +21 -2
  18. package/templates/_agents/scripts/source-sync-check.mjs +13 -2
  19. package/templates/_agents/scripts/source-sync-check.test.mjs +37 -0
  20. package/templates/_agents/scripts/workflows-check.test.mjs +14 -3
  21. package/templates/_githooks/pre-commit +17 -1
  22. /package/modules/hosts/opencode/commands/{build.md → wf-build.md} +0 -0
  23. /package/modules/hosts/opencode/commands/{deploy.md → wf-deploy.md} +0 -0
  24. /package/modules/hosts/opencode/commands/{design.md → wf-design.md} +0 -0
  25. /package/modules/hosts/opencode/commands/{gate-checklist.md → wf-gate-checklist.md} +0 -0
  26. /package/modules/hosts/opencode/commands/{maintain.md → wf-maintain.md} +0 -0
  27. /package/modules/hosts/opencode/commands/{new-task.md → wf-new-task.md} +0 -0
  28. /package/modules/hosts/opencode/commands/{plan.md → wf-plan.md} +0 -0
  29. /package/modules/hosts/opencode/commands/{review.md → wf-review.md} +0 -0
  30. /package/modules/hosts/opencode/commands/{source-sync-check.md → wf-source-sync-check.md} +0 -0
  31. /package/modules/hosts/opencode/commands/{test.md → wf-test.md} +0 -0
@@ -240,5 +240,42 @@ if (!SRC_ROOT) {
240
240
  check('S14 内容差异(甲 vs 乙)→ 报漂移(归一只认 CRLF 不吞内容)', r.drift.length === 1 && r.drift[0].rel === 'commands/a.md', JSON.stringify(r.drift));
241
241
  }
242
242
 
243
+ // ---- 场景 15-16:项目自持架子文件排除(2026-09-28 runtime-env 双源冲突)----
244
+ {
245
+ // S15 notes/runtime-env.md **两侧都被排除**——包源只发骨架、装户填实况,两处本就该不同。
246
+ // 回归:首版只过滤装副本一侧 → 排除件变成「包源有/装副本无」的**缺失**,--gate 仍 exit 1
247
+ // (实测:漂移 1 → 缺失 1)。故断言 missing/drift 皆为空。
248
+ const root = fs.mkdtempSync(path.join(os.tmpdir(), 'fk-ssc-owned-'));
249
+ const pkgRoot = path.join(root, 'pkg');
250
+ const target = path.join(root, 'target');
251
+ const pkgBase = path.join(pkgRoot, 'templates', '_agents', 'notes');
252
+ const tgtBase = path.join(target, '.agents', 'notes');
253
+ fs.mkdirSync(pkgBase, { recursive: true });
254
+ fs.mkdirSync(tgtBase, { recursive: true });
255
+ fs.writeFileSync(path.join(pkgBase, 'runtime-env.md'), '# 骨架\n> 项目按实际填写\n');
256
+ fs.writeFileSync(path.join(tgtBase, 'runtime-env.md'), '# 实况\n> 本机 sh 路径已接\n');
257
+ const r = sourceSyncCheck({ pkgRoot, target });
258
+ check('S15 项目自持 runtime-env.md 两侧内容不同 → 既不报缺失也不报漂移(双侧排除)',
259
+ r.missing.length === 0 && r.drift.length === 0,
260
+ JSON.stringify({ missing: r.missing, drift: r.drift }));
261
+ }
262
+ {
263
+ // S16 排除**只针对该文件**——同目录其他 .md 仍受双源门禁约束(防排除范围被误放大)
264
+ const root = fs.mkdtempSync(path.join(os.tmpdir(), 'fk-ssc-owned2-'));
265
+ const pkgRoot = path.join(root, 'pkg');
266
+ const target = path.join(root, 'target');
267
+ const pkgBase = path.join(pkgRoot, 'templates', '_agents', 'notes');
268
+ const tgtBase = path.join(target, '.agents', 'notes');
269
+ fs.mkdirSync(pkgBase, { recursive: true });
270
+ fs.mkdirSync(tgtBase, { recursive: true });
271
+ fs.writeFileSync(path.join(pkgBase, 'runtime-env.md'), '# 骨架\n');
272
+ fs.writeFileSync(path.join(tgtBase, 'runtime-env.md'), '# 实况\n');
273
+ fs.writeFileSync(path.join(pkgBase, 'other.md'), '# v1\n');
274
+ fs.writeFileSync(path.join(tgtBase, 'other.md'), '# v2\n');
275
+ const r = sourceSyncCheck({ pkgRoot, target });
276
+ check('S16 排除不放大——同目录 other.md 内容不同仍报漂移',
277
+ r.drift.length === 1 && r.drift[0].rel === 'notes/other.md', JSON.stringify(r.drift));
278
+ }
279
+
243
280
  console.log('\n合计: PASS ' + pass + ' / FAIL ' + failCount);
244
281
  process.exit(failCount ? 1 : 0);
@@ -226,12 +226,23 @@ const fm = (extra = '') => `---\nname: t\ndescription: t\n${extra}---\n\n# w\n\n
226
226
 
227
227
  // ---- S14 真实仓库自扫 baseline:0 error(_TEMPLATE 排除后三份可执行件全过)----
228
228
  {
229
+ // **本场景是包源仓库的 baseline 断言,装户环境应 SKIP**(2026-09-28 修正):
230
+ // 它上溯三级定位「真实仓库」,从 `templates/_agents/scripts/` 出发正确落在包源根;
231
+ // 但从装户的 `.agents/scripts/` 出发会落到 `<install>/..`,扫不到可执行编排件 →
232
+ // `files.length >= 3` 必假。首版没区分这两种上下文,导致**装户径下该套件恒红**——
233
+ // 实测:CI 新增「shipped 套件」步骤后,`.agents/scripts/workflows-check.test.mjs`
234
+ // 报 `FAIL S14(扫描面:)`(空扫描面),而包源侧同字节跑出 15/0。
235
+ // 判据:扫不到任何可执行件 = 本环境不适用 → SKIP(沿 doctor.test.mjs 同口径)。
229
236
  const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', '..', '..');
230
237
  const r = lintWorkflows({ root: ROOT });
231
238
  const names = r.files.map((f) => f.file).join('、');
232
- check('S14 真实仓库 .agents/workflows/ 自扫 0 error(扫描面:' + names + ')',
233
- r.errorCount === 0 && r.files.length >= 3,
234
- JSON.stringify(r.files.filter((f) => f.errors.length).map((f) => ({ f: f.file, e: f.errors }))));
239
+ if (r.files.length === 0) {
240
+ check('S14 真实仓库自扫 SKIP(本环境无 .agents/workflows/ 可执行件——装户径,沿 doctor.test 同口径)', true);
241
+ } else {
242
+ check('S14 真实仓库 .agents/workflows/ 自扫 0 error(扫描面:' + names + ')',
243
+ r.errorCount === 0 && r.files.length >= 3,
244
+ JSON.stringify(r.files.filter((f) => f.errors.length).map((f) => ({ f: f.file, e: f.errors }))));
245
+ }
235
246
  }
236
247
 
237
248
  // ---- S14 human 确认门(第四形态):单形态全绿 / 双填 E9 / ×retries W4 / 缺列兼容 ----
@@ -1,6 +1,6 @@
1
1
  #!/bin/sh
2
2
  # Git 原生 pre-commit hook(经 core.hooksPath 挂载,git 执行、不依赖 agent 客户端)— agentic-flow-kit 通用编排
3
- # 通用门禁序:闭环配对(增量) → wiki 台账(增量) → 常驻面体积预算(增量) → 双源一致性(增量) → 项目门禁(local-pre-commit) → 敏感信息扫描+条件构建(commit-check.cjs)
3
+ # 通用门禁序:闭环配对(增量) → wiki 台账(增量) → 常驻面体积预算(增量) → 双源一致性(增量) → managed 台账快检(包源恒跑) → 项目门禁(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)——门禁清单只此一份,避免两处分叉
@@ -46,6 +46,22 @@ if [ -d templates/_agents ] && [ -f .agents/scripts/source-sync-check.mjs ] \
46
46
  fi
47
47
  fi
48
48
 
49
+ # managed 台账快检(包源环境恒跑,2026-09-28 ledger-precommit-gate;同日独立复核 P2-2 采纳):
50
+ # kit.json 台账 sha ↔ 盘面工作树(LF 归一,同 doctor §4 口径)——拦「台账 sha 预 landing」:台账记了
51
+ # 盘面尚不存在的内容 sha。双源门禁对此静默(templates↔.agents 成对回退时两侧一致),doctor §4 只在
52
+ # 手动全量跑——该故障模式三次真实发生(0272a1c 预入 / ff3c721 还原窗口 / 537df18 闭合),本块补齐
53
+ # 提交时刻的第三边。恒跑不作暂存触发:预 landing 是仓态而非暂存态,暂存 grep 有前缀缝(如 .githooks/*
54
+ # managed 件单边漂移不命中),毫秒级 80 份 hash 不构成开销理由。比较工作树而非暂存区(沿双源门禁
55
+ # 口径)。装户环境(无 templates/_agents/ 包源)自然跳过——装户 managed 手改走 doctor §4 WARN 口径,
56
+ # 不硬拦。已知边界:managed 删除即拦(sync 对 removed 只报不删,删件须手动同步装副本并重跑 sync 刷
57
+ # 台账)。
58
+ if [ -d templates/_agents ] && [ -f .agents/scripts/check-ledger.mjs ]; then
59
+ if ! node .agents/scripts/check-ledger.mjs; then
60
+ echo "pre-commit: managed 台账快检未通过,提交已阻止——kit.json 与盘面不一致,跑 node bin/flow-kit.mjs sync 成对后原路重试" >&2
61
+ exit 1
62
+ fi
63
+ fi
64
+
49
65
  # 项目门禁挂载点:.agents/hooks/local-pre-commit(项目自建门禁/门禁模块接线处,存在即执行)
50
66
  if [ -f .agents/hooks/local-pre-commit ]; then
51
67
  run_gate "项目门禁(local-pre-commit)" .agents/hooks/local-pre-commit