agentic-flow-kit 0.5.0 → 0.7.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 +2 -0
- package/modules/gates/dotnet-ca/check-architecture.sh +23 -5
- package/modules/hosts/omp/agents/implementer.md +2 -0
- package/modules/hosts/omp/agents/independent-reviewer.md +2 -0
- package/modules/hosts/omp/agents/ui-verifier.md +2 -0
- package/modules/hosts/opencode/agents/implementer.md +2 -0
- package/modules/hosts/opencode/agents/independent-reviewer.md +2 -0
- package/modules/hosts/opencode/agents/ui-verifier.md +2 -0
- package/modules/hosts/opencode/commands/build.md +20 -1
- package/modules/hosts/opencode/commands/design.md +2 -0
- package/modules/hosts/opencode/commands/gate-checklist.md +77 -0
- package/modules/hosts/opencode/commands/maintain.md +2 -3
- package/modules/hosts/opencode/commands/plan.md +4 -1
- package/modules/hosts/opencode/commands/review.md +1 -0
- package/modules/hosts/opencode/commands/source-sync-check.md +89 -0
- package/modules/hosts/opencode/commands/sync-hosts.md +66 -0
- package/modules/hosts/opencode/commands/test.md +4 -2
- package/modules/hosts/trae/agents/implementer.md +2 -0
- package/modules/hosts/trae/agents/independent-reviewer.md +2 -0
- package/modules/hosts/trae/agents/ui-verifier.md +2 -0
- package/modules/hosts/trae/commands/wf-build.md +20 -1
- package/modules/hosts/trae/commands/wf-design.md +2 -0
- package/modules/hosts/trae/commands/wf-gate-checklist.md +78 -0
- package/modules/hosts/trae/commands/wf-maintain.md +2 -3
- package/modules/hosts/trae/commands/wf-plan.md +4 -1
- package/modules/hosts/trae/commands/wf-review.md +1 -0
- package/modules/hosts/trae/commands/wf-source-sync-check.md +90 -0
- package/modules/hosts/trae/commands/wf-sync-hosts.md +67 -0
- package/modules/hosts/trae/commands/wf-test.md +4 -2
- package/modules/hosts/trae/hooks/post-edit-check.cjs +3 -2
- package/modules/hosts/trae/hooks/pre-shell-check.cjs +40 -9
- package/modules/hosts/trae/hooks.json +1 -1
- package/modules/hosts/zcode/agents/implementer.md +2 -0
- package/modules/hosts/zcode/agents/independent-reviewer.md +2 -0
- package/modules/hosts/zcode/agents/ui-verifier.md +2 -0
- package/package.json +2 -2
- package/src/add-gate.mjs +5 -3
- package/src/doctor.mjs +121 -18
- package/src/gate-dotnet-ca.test.mjs +124 -0
- package/src/init.mjs +79 -17
- package/src/init.test.mjs +60 -1
- package/src/profiles.mjs +19 -2
- package/src/render.mjs +64 -4
- package/src/run-tests.mjs +3 -0
- package/src/sync-hosts.mjs +3 -2
- package/src/sync.mjs +64 -20
- package/src/sync.test.mjs +42 -0
- package/src/trae-hooks.test.mjs +115 -0
- package/templates/AGENTS.md +1 -0
- package/templates/_agents/board/index.html +32 -3
- package/templates/_agents/commands/build.md +5 -4
- package/templates/_agents/commands/design.md +1 -0
- package/templates/_agents/commands/maintain.md +1 -2
- package/templates/_agents/commands/plan.md +2 -0
- package/templates/_agents/commands/test.md +2 -1
- package/templates/_agents/hooks/check-pairing-incremental.sh +20 -7
- package/templates/_agents/metric-claims.txt +81 -0
- package/templates/_agents/roles/implementer.md +2 -0
- package/templates/_agents/roles/independent-reviewer.md +2 -0
- package/templates/_agents/roles/ui-verifier.md +2 -0
- package/templates/_agents/scripts/agg-delegations.cjs +39 -30
- package/templates/_agents/scripts/agg-delegations.test.mjs +32 -0
- package/templates/_agents/scripts/check-loop.mjs +538 -16
- package/templates/_agents/scripts/check-loop.test.mjs +1116 -0
- package/templates/_agents/scripts/confirm-doc.mjs +228 -0
- package/templates/_agents/scripts/confirm-doc.test.mjs +321 -0
- package/templates/_agents/scripts/doctor.test.mjs +81 -3
- package/templates/_agents/scripts/ensure-board.mjs +29 -2
- package/templates/_agents/scripts/gate-checklist.mjs +3 -0
- package/templates/_agents/scripts/gate-checklist.test.mjs +3 -3
- package/templates/_agents/scripts/gen-wiki-board.mjs +38 -24
- package/templates/_agents/scripts/gen-wiki-board.test.mjs +18 -0
- package/templates/_agents/scripts/gen-workflow-metrics.mjs +31 -3
- package/templates/_agents/scripts/kb-search.mjs +22 -8
- package/templates/_agents/scripts/kb-search.test.mjs +38 -8
- package/templates/_agents/scripts/source-sync-check.mjs +30 -5
- package/templates/_agents/scripts/source-sync-check.test.mjs +133 -8
- package/templates/_agents/scripts/verify-wiki-consistency.mjs +46 -23
- package/templates/_agents/scripts/workflow-board-server.mjs +64 -9
- package/templates/_agents/scripts/workflow-board-server.test.mjs +136 -0
- package/templates/_agents/scripts/workflow-enums.mjs +4 -2
- package/templates/_agents/scripts/workflows-check.test.mjs +14 -3
- package/templates/_agents/workflow-enums.txt +3 -3
- package/templates/_agents/workflows/_TEMPLATE.md +1 -0
- package/templates/_githooks/pre-commit +16 -1
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: wf-gate-checklist
|
|
3
|
+
description: 三处口径一致性检查(doctor §检查项 ↔ check-loop §检查项,显式配对登记表 + 断档/未登记告警;横向工具)
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Gate-Checklist · 三处口径一致性(显式配对登记表)
|
|
7
|
+
|
|
8
|
+
> `src/doctor.mjs` § 检查项 ↔ `.agents/scripts/check-loop.sh` § 检查项,按脚本内 **PAIRS 登记表**对照。
|
|
9
|
+
> 任何一处加新检查项,另一处不会自动同步——本工具报「未登记」;检查项被删/改号而登记未跟报「断档」。
|
|
10
|
+
> 只报告不修复(B-b 决策):缺点暴露给用户拍板,本工具不自动同步;exit 恒 0。
|
|
11
|
+
|
|
12
|
+
## 何时跑
|
|
13
|
+
|
|
14
|
+
- 改 `src/doctor.mjs` 加新 § 检查项后(同时须登记 PAIRS)
|
|
15
|
+
- 改 `.agents/scripts/check-loop.sh` 加新 § 检查项后(同时须登记 PAIRS)
|
|
16
|
+
- 怀疑两处口径不一致时
|
|
17
|
+
- 不跑:仅改既有检查项的提示文案(不动 § 项与登记表)
|
|
18
|
+
|
|
19
|
+
## 登记表纪律(契约)
|
|
20
|
+
|
|
21
|
+
`templates/_agents/scripts/gate-checklist.mjs` 内 **PAIRS** 是配对单源,三选一登记:
|
|
22
|
+
|
|
23
|
+
| 形态 | 写法 | 含义 |
|
|
24
|
+
|------|------|------|
|
|
25
|
+
| 直接配对 | `{ doctor: 'N', cl: 'M' }` | 同一检查两处实现 |
|
|
26
|
+
| 声明独有 | `{ doctor: 'N', cl: null }` | doctor 装户体检面,无 check-loop 对应(原 intent 拍板只报告不修复) |
|
|
27
|
+
| 经 §7 覆盖 | `{ doctor: '7', cl: 'M' }` | doctor §7 整体运行 check-loop,#M 自动流入 doctor |
|
|
28
|
+
|
|
29
|
+
- 加新 § 检查项不登记 → 工具报「未登记」(新检查项没对账——核心信号)
|
|
30
|
+
- 删/改检查项不动登记表 → 工具报「断档」
|
|
31
|
+
- 关键词匹配已退役(2026-09-25 registry 重写:实测 18×14 项只匹配 2、28 条噪声缺点,真漏点不可见)
|
|
32
|
+
|
|
33
|
+
## 怎么跑
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
node .agents/scripts/gate-checklist.mjs --diff # 人类可读(默认)
|
|
37
|
+
node .agents/scripts/gate-checklist.mjs --json # 机器可读
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
输出四段:总览计数 → 对照表(登记表展开)→ 断档(如有)→ 未登记(如有);全绿时输出「登记完整」。
|
|
41
|
+
|
|
42
|
+
### 输出示例
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
▶ flow-kit gate-checklist --diff(显式配对登记表)
|
|
46
|
+
doctor §检查项: 12 | check-loop §检查项: 14 | 直接配对 2 + 经 §7 覆盖 12 + 声明独有 9
|
|
47
|
+
对照表(登记表展开):
|
|
48
|
+
✓ §5 占位符残留 ↔ #2 模板字段占位符残留(YYYY-MM-DD / <主题> 等…)(占位符残留)
|
|
49
|
+
● §1 Node 版本(声明独有:Node 版本——装户体检独有)
|
|
50
|
+
✓ §7 check-loop ↔ #1 入口文档/spec/plan 同名配对(…(经 §7 整体运行覆盖)
|
|
51
|
+
✅ 登记完整(0 断档 / 0 未登记)
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### 自验
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
node .agents/scripts/gate-checklist.test.mjs # 13 场景全过
|
|
58
|
+
npm test # 含 gate-checklist 套件
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## 边界(不要做)
|
|
62
|
+
|
|
63
|
+
- 不要把「登记完整」当作强制门 —— B-b 决策「只报告不修复」:断档/未登记暴露给 follow-up,exit 恒 0
|
|
64
|
+
- 不要改 doctor / check-loop 检查项来消音 —— 登记表才是该改的地方(配对 / 独有 / 经 §7 三选一)
|
|
65
|
+
- 不要扩展到看板告警 —— 看板当前无告警规则(gen-wiki-board.mjs 不做判定),扩展超出范围
|
|
66
|
+
- 不要绕过登记直接改解析正则 —— 解析面只认 doctor `// N.` 节注释与 check-loop `// N.` 项注释(.mjs 头部清单,fallback 旧装户 .sh `# N.`)
|
|
67
|
+
|
|
68
|
+
## 不在本次同步范围
|
|
69
|
+
|
|
70
|
+
- `.agents/board/` 看板告警(无告警规则)
|
|
71
|
+
- `wiki/知识沉淀总览.html` 渲染(数据来源是 workflow/INDEX.md 与 wiki 目录,非本工具对照)
|
|
72
|
+
- `flow-kit sync` managed 台账追踪(gate-checklist 不在 managed 范围)
|
|
73
|
+
|
|
74
|
+
## 相关留痕
|
|
75
|
+
|
|
76
|
+
- intent(登记表重写):`workflow/intents/2026-09-25-gate-checklist-registry.md`
|
|
77
|
+
- intent(工具首建):`workflow/intents/2026-09-25-gate-checklist.md`
|
|
78
|
+
- 父 incident:`workflow/incidents/2026-09-25-wf-runtime.md`(owned 漂移未对账,催生本工具)
|
|
@@ -11,7 +11,7 @@ description: Maintain 阶段 · 立 incident + 复盘三件套(incident 在 L1
|
|
|
11
11
|
|
|
12
12
|
## 执行
|
|
13
13
|
|
|
14
|
-
> **看板(可选,默认不拉起)**:需要实时看板时手动跑 node .agents/scripts/ensure-board.mjs(跨平台;幂等:探活 / 旧代码自动重启 / 全新启动才弹浏览器;多项目并行自动上探首个可用端口),链接以脚本输出为准(基端口
|
|
14
|
+
> **看板(可选,默认不拉起)**:需要实时看板时手动跑 node .agents/scripts/ensure-board.mjs(跨平台;幂等:探活 / 旧代码自动重启 / 全新启动才弹浏览器;多项目并行自动上探首个可用端口),链接以脚本输出为准(基端口 8933);不开看板不影响任务流程。
|
|
15
15
|
|
|
16
16
|
### 0. 紧急止血(仍在事故中时)
|
|
17
17
|
|
|
@@ -73,6 +73,5 @@ description: Maintain 阶段 · 立 incident + 复盘三件套(incident 在 L1
|
|
|
73
73
|
|
|
74
74
|
## 确认后
|
|
75
75
|
|
|
76
|
-
- incident 状态 → fixed(三件套全落地)
|
|
77
|
-
- 防复发用例通过后 → closed
|
|
76
|
+
- incident 状态 → fixed(三件套全落地);防复发用例通过后 → closed——两跳均走确认门 `node .agents/scripts/confirm-doc.mjs <path>`(open→fixed / fixed→closed,无单跳;2026-09-28 起 check-loop 15 对账,AI 不得直改状态)
|
|
78
77
|
- 若需新 intent → 进 `next: .agents/commands/plan.md`
|
|
@@ -9,11 +9,12 @@ description: Plan 阶段 · 立 intent(AI 起草、用户确认;本阶段不
|
|
|
9
9
|
|
|
10
10
|
## 执行
|
|
11
11
|
|
|
12
|
-
> **看板(可选,默认不拉起)**:需要实时看板时手动跑 node .agents/scripts/ensure-board.mjs(跨平台;幂等:探活 / 旧代码自动重启 / 全新启动才弹浏览器;多项目并行自动上探首个可用端口),链接以脚本输出为准(基端口
|
|
12
|
+
> **看板(可选,默认不拉起)**:需要实时看板时手动跑 node .agents/scripts/ensure-board.mjs(跨平台;幂等:探活 / 旧代码自动重启 / 全新启动才弹浏览器;多项目并行自动上探首个可用端口),链接以脚本输出为准(基端口 8933);不开看板不影响任务流程。
|
|
13
13
|
|
|
14
14
|
1. 若 `workflow/intents/` 已有目标 intent 且状态为 approved → 按级别跳 next(L1 → `build.md`,L2/L3 → `design.md`)
|
|
15
15
|
2. 否则起草新 intent:
|
|
16
16
|
- **先检索同类**:`node .agents/scripts/kb-search.mjs "<关键词>" --scope workflow --type intents,specs`——命中同类先读其结论与验收,新 intent 引用(防重复立项 / 重复踩坑)
|
|
17
|
+
- **填空工具先跑**:`node .agents/scripts/fill-intent.mjs --module <模块> --level <L0|L1|L2|L3> --topic <主题> --output workflow/intents/<date>-<主题>.md --notes "<备注>"`——输出含 frontmatter 5 字段 + 7 节正文(背景与问题/目标/非目标/约束/影响面/触达红线/验收标准)的草稿;AI 据此填实,模板与节标题机器保证不出错
|
|
17
18
|
- 复制 `workflow/intents/_TEMPLATE.md` → `workflow/intents/YYYY-MM-DD-<主题>.md`
|
|
18
19
|
- frontmatter 填 `模块:`(词表见 `.agents/workflow-modules.txt`,新建文档必填,check-loop 会警告)
|
|
19
20
|
- 按 6 节填写:背景与问题 / 目标(可验证) / 非目标 / 约束 / 影响面 / 触达红线(L1 微改动可省非目标/约束两节,不硬填)
|
|
@@ -21,6 +22,8 @@ description: Plan 阶段 · 立 intent(AI 起草、用户确认;本阶段不
|
|
|
21
22
|
3. 写不出可测试判据 = 还没想清楚 → 反问澄清,不要硬填
|
|
22
23
|
4. 起草后停下,输出草稿全文给用户过目,一句"可以"即确认
|
|
23
24
|
|
|
25
|
+
**确认落态唯一入口**(2026-09-27 起):用户在终端跑 `node .agents/scripts/confirm-doc.mjs <path>` 键入「可以」(draft→approved / approved→done;对话内明确确认后 AI 可 `--delegated "<原话>"` 代录,台账如实记 source/quote——**逐件调用 + 逐件原话**(一次一份,build.md「逐件确认」口径;多份并录被 confirm-doc 拒绝。--delegated 每次传当次实际放行的措辞,不复用同句——复用同句使台账 quote 失去分辨力,且相邻同 quote 连跑会触发并录告警))。check-loop 15 如实口径:缺记录/指纹不配对 → hard-block 拦截;伪造台账本地不可机器防,留痕供事后对质;done 内容绑定(2026-09-28 起)——关单编辑(勾验/回填)先于 done 确认、confirm-doc 是最后一次写入,此后修订走 superseded 或新 intent。
|
|
26
|
+
|
|
24
27
|
## 技能辅助(可选,宿主级 skills)
|
|
25
28
|
|
|
26
29
|
- 需求模糊、判据写不出时:用 `grilling`/`grill-me` 拷问需求,答完回填 6 节
|
|
@@ -31,6 +31,7 @@ description: Review · 代码评审(横切,合入前使用;P0/P1/P2 分级
|
|
|
31
31
|
- **Create/Update 校验同口径**:Create 已有校验 Update 必须同口径;被引用的标识符字段禁改
|
|
32
32
|
- **查询分页与状态语义**:分页参数范围校验 + 服务层钳制;非法状态与不存在分离(按项目统一错误口径,如 400 / 404)
|
|
33
33
|
- **spec 承诺的断言落地**:spec §测试列出的用例 / 断言须真落到测试或验证脚本;「写进 spec」不等于「跑得起来」,且常驻断言禁写成随时间增长的行数常量
|
|
34
|
+
- **跨宿主薄适配正文漂移**:改 `templates/_agents/{commands,roles}/*.md` 后必须跑 `flow-kit sync-hosts --apply` 单向同步 4 宿主薄适配(`modules/hosts/<h>/{agents,commands}/*.md`);装户视角由 `flow-kit doctor` §6.7 检查(包源环境 §6.7 skipped)
|
|
34
35
|
|
|
35
36
|
## P2 建议(提醒,不拦合入)
|
|
36
37
|
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: wf-source-sync-check
|
|
3
|
+
description: 装户面同步一致性检查(包源 templates/_agents/ vs 装副本 .agents/ 三类差异:缺失 / 孤儿 / 漂移;横向工具)
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Source-Sync-Check · 装户面同步一致性
|
|
7
|
+
|
|
8
|
+
> `templates/_agents/` 包源 vs `.agents/` 装副本——三类差异报告:缺失 / 孤儿 / 漂移。
|
|
9
|
+
> managed 文件由 `flow-kit sync` 跟踪;owned 文件由 `flow-kit doctor` §6.6 校验——本工具补"两者都没扫"的真空地带(结构级差异)。
|
|
10
|
+
|
|
11
|
+
## 何时跑
|
|
12
|
+
|
|
13
|
+
- 改 `templates/_agents/*` 包源后
|
|
14
|
+
- 怀疑装副本未跟包源更新
|
|
15
|
+
- 体检装副本完整性(清理前 / 发版前)
|
|
16
|
+
- 不跑:仅改装副本 `.agents/*`(B-b 决策「只报告」+ 不反向同步)
|
|
17
|
+
|
|
18
|
+
## 怎么跑
|
|
19
|
+
|
|
20
|
+
### 默认 `--diff`(仅报告)
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
node .agents/scripts/source-sync-check.mjs --diff
|
|
24
|
+
node .agents/scripts/source-sync-check.mjs --json # 机器可读
|
|
25
|
+
node .agents/scripts/source-sync-check.mjs --pkg-root <path> --target <path> # 自定义路径
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
输出三类:
|
|
29
|
+
- **缺失**(missing)——包源有 / 装副本无(如新增文件 init 未执行)
|
|
30
|
+
- **孤儿**(orphan)——包源无 / 装副本有(如历史残留 / 用户本地添加)
|
|
31
|
+
- **漂移**(drift)——两者都有但 sha 不一致(如包源改了装副本未跟)
|
|
32
|
+
|
|
33
|
+
**排除**:
|
|
34
|
+
- `templates/_agents/cache/`(运行时缓存,与 `flow-kit sync` 既有约定一致)
|
|
35
|
+
- `.agents/kit.json` / `.agents/settings.json`(init 渲染产物,不属双源)
|
|
36
|
+
|
|
37
|
+
### 输出示例
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
▶ flow-kit source-sync-check --diff
|
|
41
|
+
包源 (templates/_agents/) 49 份 | 装副本 (.agents/) 49 份
|
|
42
|
+
缺失(包源有 / 装副本 无)1:
|
|
43
|
+
- scripts/source-sync-check.mjs
|
|
44
|
+
孤儿(包源无 / 装副本 有)1:
|
|
45
|
+
- hooks/commit-check.config.json
|
|
46
|
+
漂移(包源装副本都有但 sha 不一致)3:
|
|
47
|
+
- commands/maintain.md pkg=3782b695… tgt=26203f7b…
|
|
48
|
+
- notes/runtime-env.md pkg=aedde1ba… tgt=ad08441e…
|
|
49
|
+
- scripts/ensure-board.mjs pkg=e66653b0… tgt=b6f3cc9b…
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### 自验
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
node .agents/scripts/source-sync-check.test.mjs # 11 场景全过
|
|
56
|
+
npm test # 含 source-sync-check 套件
|
|
57
|
+
flow-kit doctor # 10/0/0
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## 边界(不要做)
|
|
61
|
+
|
|
62
|
+
- 不要自动化同步(B-b 决策「只报告不修复」——与 `gate-checklist` 同源)
|
|
63
|
+
- 不改 managed 台账跟踪逻辑(`sync.mjs` 不动)
|
|
64
|
+
- 不改 owned 漂移校验(`doctor.mjs` §6.6 不动)
|
|
65
|
+
- 不反向同步——装副本独自有文件(如 hooks/commit-check.config.json)可能是装户配置,不应被删
|
|
66
|
+
- 不检查 4 宿主 `modules/hosts/` 薄适配漂移(那是 `flow-kit sync-hosts` 范围)
|
|
67
|
+
|
|
68
|
+
## 当前已识别的真实漂点(首次实测,2026-09-25)
|
|
69
|
+
|
|
70
|
+
- **缺失**:本工具写完后未同步装副本(预期内——随本次 commit 解决)
|
|
71
|
+
- **孤儿**:`.agents/hooks/commit-check.config.json`(装副本独有,疑似装户配置)
|
|
72
|
+
- **漂移**:`commands/maintain.md` / `notes/runtime-env.md` / `scripts/ensure-board.mjs`
|
|
73
|
+
|
|
74
|
+
修复留后续 incident / intent 跟踪(不在本次范围)。
|
|
75
|
+
|
|
76
|
+
## 与既有工具的关系
|
|
77
|
+
|
|
78
|
+
| 工具 | 作用域 | 算法 |
|
|
79
|
+
|---|---|---|
|
|
80
|
+
| `flow-kit sync` | managed 文件(kit.json 台账跟踪)| 三态覆盖 + 加新 + 报错缺 |
|
|
81
|
+
| `flow-kit doctor` §6.6 | owned 文件(kit.owned 哈希比对)| 盘面 sha vs 台账哈希 |
|
|
82
|
+
| **`flow-kit source-sync-check`** | **所有文件结构(包源 ↔ 装副本全集)** | **sha 全量比对 + 缺失/孤儿分类** |
|
|
83
|
+
|
|
84
|
+
三者互补,不重叠。
|
|
85
|
+
|
|
86
|
+
## 相关留痕
|
|
87
|
+
|
|
88
|
+
- intent:`workflow/intents/2026-09-25-source-sync-check.md`
|
|
89
|
+
- plan:`workflow/plans/2026-09-25-source-sync-check.md`
|
|
90
|
+
- 父 incident:`workflow/incidents/2026-09-25-wf-runtime.md`(包源改了装副本未同步——本工具预防性体检)
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: wf-sync-hosts
|
|
3
|
+
description: 跨宿主适配层同步(正文段 sha 比对 + 用户拍板 + 单向 apply;frontmatter 不动;横向工具)
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Sync-Hosts · 跨宿主适配层正文段同步
|
|
7
|
+
|
|
8
|
+
> 改权威源(`templates/_agents/{commands,roles}/*.md`)后薄适配(`modules/hosts/<h>/{agents,commands}/*.md`)要同步——薄适配正文 = 权威源正文,frontmatter 各自保留宿主特化(trae commands 加 `name: wf-X`、opencode/zcode/omp 各自原描述)。
|
|
9
|
+
> 装户视角:`flow-kit doctor` §7.x 跑同名检查(仅装户,包源环境跳过——包源下永远是 drift)。
|
|
10
|
+
|
|
11
|
+
## 何时跑
|
|
12
|
+
|
|
13
|
+
- 改 `templates/_agents/commands/*.md` 正文后(8 个 commands 文件)
|
|
14
|
+
- 改 `templates/_agents/roles/*.md` 正文后(3 个 roles 文件)
|
|
15
|
+
- 装户跑 `flow-kit doctor` 报"跨宿主薄适配正文漂移 N 对" WARN 时
|
|
16
|
+
- 不跑:仅改 frontmatter;改 trae 钩子/规则;改包源其他文件
|
|
17
|
+
|
|
18
|
+
## 怎么跑
|
|
19
|
+
|
|
20
|
+
### 默认 `--diff`(仅报告)
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
node bin/flow-kit.mjs sync-hosts --diff
|
|
24
|
+
node bin/flow-kit.mjs sync-hosts --json # 机器可读
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
输出三类:
|
|
28
|
+
- **正文对齐 N 对** — sha 一致,无需处理
|
|
29
|
+
- **正文段漂移 N(权威源 vs 薄适配 sha 不一致)** — `--apply` 同步方向;不区分"权威源改了"或"薄适配手改了",由用户拍板
|
|
30
|
+
- **⚠️ 权威源声明但薄适配缺失** — `add-host <h>` 接管后跑 `--apply` 才会装(apply 不自动创建)
|
|
31
|
+
- **⚠️ 孤儿薄适配(权威源无对应文件)** — 历史残留或宿主特化,apply 不删
|
|
32
|
+
|
|
33
|
+
### `--apply` 单向同步
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
node bin/flow-kit.mjs sync-hosts --apply
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
按权威源正文覆盖薄适配正文段;薄适配原 frontmatter 保留(trae name: wf-X、opencode 描述、zcode/omp 中文风格各自不动)。apply 不反向同步——薄适配手改了正文也会被覆盖(这是设计选择,避免漂移方向歧义)。
|
|
40
|
+
|
|
41
|
+
### 自验
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
npm test # 含 sync-hosts.test.mjs 8 场景
|
|
45
|
+
node bin/flow-kit.mjs doctor # 装户跑 §7.x PASS;包源跑 §7.x skipped
|
|
46
|
+
sh .agents/scripts/check-loop.sh # Windows 无 sh 时 doctor 已探测分流
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## 边界(不要做)
|
|
50
|
+
|
|
51
|
+
- 不要 `--apply` 反向同步(写权威源):权威源是真相,薄适配手改会被覆盖——这是设计,apply 前先看 `--diff`
|
|
52
|
+
- 不要删除孤儿薄适配:可能是宿主特化或历史残留,apply 不动
|
|
53
|
+
- 不要改 frontmatter 让 sha 凑齐:frontmatter 是宿主特化字段(trae name: wf-X 等),工具不参与
|
|
54
|
+
- 不要把「避免与权威版本漂移」明文加回去——这是旧契约的指针风格,已被 B-b 正文副本取代
|
|
55
|
+
- 装了新宿主后跑 `--apply`:新宿主目录空白,apply 不会自动创建薄适配(薄适配须经 `add-host <h>` 接管)
|
|
56
|
+
|
|
57
|
+
## 不在本次同步范围
|
|
58
|
+
|
|
59
|
+
- trae 钩子(`modules/hosts/trae/hooks/*.cjs`)— 独立演进的工程件
|
|
60
|
+
- trae 规则(`modules/hosts/trae/rules/*.md`)— 同上
|
|
61
|
+
- 包源 .agents/scripts/*.cjs(pre-commit 等钩子)— 同步由 `flow-kit sync` 走 managed 台账负责
|
|
62
|
+
|
|
63
|
+
## 相关留痕
|
|
64
|
+
|
|
65
|
+
- intent:`workflow/intents/2026-09-25-cross-host-sync.md`
|
|
66
|
+
- plan:`workflow/plans/2026-09-25-cross-host-sync.md`(含 B-b 方案拍板)
|
|
67
|
+
- incident:`workflow/incidents/2026-09-25-wf-runtime.md`(双源纪律教训,规范 §7.x 包源环境跳过)
|
|
@@ -15,6 +15,7 @@ description: Test 阶段 · 静态门 + 切库冒烟 + UI 实测 + L2/L3 独立
|
|
|
15
15
|
项目测试命令 # 自动化测试
|
|
16
16
|
项目类型检查命令 # 前端类型检查/构建(涉及前端时跑)
|
|
17
17
|
node .agents/scripts/verify-wiki-consistency.mjs # 触及 wiki/ 时跑(exit 1 即先修台账再继续:跑 gen-wiki-board.mjs 补索引/看板;pre-commit 已按增量自动拦,此行用于改完即验)
|
|
18
|
+
node bin/flow-kit.mjs doctor # §6.5 delegations + §6.6 owned 漂移 + §6.7 跨宿主薄适配正文漂移(装户环境;包源环境 §6.7 skipped)
|
|
18
19
|
```
|
|
19
20
|
|
|
20
21
|
> **环境注记**:本地服务占用构建产物导致编译失败、多会话并行时「谁跑静态门 / 提交谁先停服务」等约定——如有,见项目注记 `.agents/notes/runtime-env.md` §2,跑静态门前先过一眼。
|
|
@@ -23,7 +24,7 @@ node .agents/scripts/verify-wiki-consistency.mjs # 触及 wiki/ 时跑(exit 1
|
|
|
23
24
|
|
|
24
25
|
任一失败 → 不进 UI 实测,回 `build.md` 修复;失败难复现(偶发/跨层)时先用 `diagnosing-bugs` 技能走诊断循环(红→最小化→假设→插桩→修复→回归),修复仍回 `build.md`。
|
|
25
26
|
|
|
26
|
-
> **门禁 / 看板 / wiki 脚本改动**(`.agents/scripts/`、`.agents/hooks/`、`.agents/board/`):按改动对象跑对应 fixture 回归,须全绿——闭环门禁 `
|
|
27
|
+
> **门禁 / 看板 / wiki 脚本改动**(`.agents/scripts/`、`.agents/hooks/`、`.agents/board/`):按改动对象跑对应 fixture 回归,须全绿——闭环门禁 `node .agents/scripts/check-loop.test.mjs`、wiki 生成器 `node .agents/scripts/gen-wiki-board.test.mjs`、提交前 hook 测试(如有);涉及看板告警规则时,用同批 workflow fixture 双跑 `check-loop`(经 shim 或 .mjs 直跑)与看板 `/api/board`,断言 hard-block 集合被看板告警覆盖(防口径分叉)。
|
|
27
28
|
|
|
28
29
|
## 2. 切库冒烟(切换 / 新增目标库后必跑)
|
|
29
30
|
|
|
@@ -56,7 +57,8 @@ node .agents/scripts/verify-wiki-consistency.mjs # 触及 wiki/ 时跑(exit 1
|
|
|
56
57
|
- **关单**(日常闭环点,不依赖是否上 prod):
|
|
57
58
|
- 关单前一键过门:`node .agents/scripts/verify.mjs`(npm test + check-loop 固定编排,任一失败非零退出,非绿不关单)
|
|
58
59
|
- 新需求:逐条勾验入口 intent「验收标准」,每条补「证据:」,intent → done;同名 spec(若有)仍 approved → done
|
|
59
|
-
|
|
60
|
+
**确认落态唯一入口**(2026-09-27 起):用户在终端跑 `node .agents/scripts/confirm-doc.mjs <path>` 键入「可以」(draft→approved / approved→done;对话内明确确认后 AI 可 `--delegated "<原话>"` 代录,台账如实记 source/quote——**逐件调用 + 逐件原话**(一次一份,build.md「逐件确认」口径;多份并录被 confirm-doc 拒绝。--delegated 每次传当次实际放行的措辞,不复用同句——复用同句使台账 quote 失去分辨力,且相邻同 quote 连跑会触发并录告警))。check-loop 15 如实口径:缺记录/指纹不配对 → hard-block 拦截;伪造台账本地不可机器防,留痕供事后对质;done 内容绑定(2026-09-28 起)——**关单编辑(勾验/回填确认结果)先于 done 确认、confirm-doc 是最后一次写入**,此后修订走 superseded 或新 intent。
|
|
61
|
+
- 修复:防复发验证已落地,incident → closed(经确认门 confirm-doc:open→fixed / fixed→closed 两跳、无单跳;2026-09-28 起 check-loop 15 对账——关单编辑先于 closed 确认,口径同 done 内容绑定)
|
|
60
62
|
- **同族收尾**:入口置终态时,同名 plan 一并置 `done`(spec 见上条),不留 `approved` 孤儿(口径同看板「入口已 done,本 plan 未终态」告警)
|
|
61
63
|
- 主智能体自做的 L1+ 新需求在 `workflow/delegations.md`「自做任务结果表」记一行(修复类不重复记)
|
|
62
64
|
- L1:本阶段结束,不进 deploy
|
|
@@ -75,8 +75,9 @@ try {
|
|
|
75
75
|
}));
|
|
76
76
|
process.exit(0);
|
|
77
77
|
}
|
|
78
|
-
// 门禁脚本未装(未跑 add-gate dotnet-ca)≠ 发现违例——区分口径,对齐 pre-shell-check 的 ENOENT 处理(2026-09-24
|
|
79
|
-
|
|
78
|
+
// 门禁脚本未装(未跑 add-gate dotnet-ca)≠ 发现违例——区分口径,对齐 pre-shell-check 的 ENOENT 处理(2026-09-24);
|
|
79
|
+
// status 127 同义(2026-09-27 host-gates-p1 P2-B4:存在的 bash 跑缺失脚本返回 127 而非 ENOENT,实测原分支不可达)
|
|
80
|
+
if (e.code === 'ENOENT' || e.status === 127) {
|
|
80
81
|
console.log(JSON.stringify({
|
|
81
82
|
hookSpecificOutput: {
|
|
82
83
|
hookEventName: 'PostToolUse',
|
|
@@ -76,11 +76,10 @@ function ask(reason) {
|
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
// ── 1) deny/ask 命令门禁 ──────────────────────────────
|
|
79
|
+
// 清单权威源 = .agents/settings.json(p2-batch2 对齐:旧清单多抄了一项 'dotnet ef' 造成双源漂移——
|
|
80
|
+
// settings.json 无此项;EF Migrations 禁令属 dotnet-ca 门禁域,如需恢复请先加进 settings.json 再同步此处)
|
|
79
81
|
const denyList = [
|
|
80
|
-
{ pat: 'dotnet ef', reason: '禁 EF Migrations,Schema 由人工 SQL 维护' },
|
|
81
82
|
{ pat: 'git reset --hard', reason: '禁破坏性重置' },
|
|
82
|
-
{ pat: 'git push --force', reason: '禁强制推送' },
|
|
83
|
-
{ pat: 'git push -f', reason: '禁强制推送' },
|
|
84
83
|
{ pat: 'drop database', reason: '禁删库' }
|
|
85
84
|
];
|
|
86
85
|
const askList = [
|
|
@@ -90,16 +89,46 @@ const askList = [
|
|
|
90
89
|
{ pat: 'rm -rf', reason: '可能递归删除文件' }
|
|
91
90
|
];
|
|
92
91
|
|
|
93
|
-
//
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
92
|
+
// stripMessages:剥 -c/-m 的值(含引号整段)——deny/ask 门与强推检测共用,防 commit 消息字样误触发
|
|
93
|
+
function stripMessages(cmd) {
|
|
94
|
+
return cmd
|
|
95
|
+
.replace(/(^|\s)-[cm]\s+"[^"]*"(?=\s|$)/g, ' ')
|
|
96
|
+
.replace(/(^|\s)-[cm]\s+'[^']*'(?=\s|$)/g, ' ')
|
|
97
|
+
.replace(/(^|\s)-[cm]\s+\S+(?=\s|$)/g, ' ')
|
|
98
|
+
.replace(/\s+/g, ' ').trim();
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// 强推检测 token 化(2026-09-27 host-gates-p1 P1-B2):子串模式 'git push --force' 挡不住换序
|
|
102
|
+
// (git push origin main --force)与 +refspec 变体(git push origin +main)——改为 token 级判定。
|
|
103
|
+
// 复核 P2 收窄(同日):①按 &&/||/;/| 分段,--force 只在 push 段内计数(dotnet build --force 不误并);
|
|
104
|
+
// ②组合短旗标(-vf)与 -f 同为 force;③--force-with-lease 是带尾巴的独立 token 不匹配。
|
|
105
|
+
// p2-batch2 补:先剥 commit 消息(引号感知)再分段——"git commit -m "修 push --force"" 曾被误拦。
|
|
106
|
+
// 本钩子是 core.hooksPath 漏配时的主要强推执行点,语义必须完整。
|
|
107
|
+
function isForcePush(cmd) {
|
|
108
|
+
const stripped = stripMessages(cmd);
|
|
109
|
+
return stripped.split(/&&|\|\||;|\|/).some((seg) => {
|
|
110
|
+
const tokens = seg.replace(/\s+/g, ' ').trim().split(' ').filter(Boolean);
|
|
111
|
+
if (!tokens.includes('push')) return false;
|
|
112
|
+
return tokens.some((t) => t === '--force'
|
|
113
|
+
|| (t.startsWith('-') && !t.startsWith('--') && /^-[a-zA-Z]*f/.test(t))
|
|
114
|
+
|| (t.startsWith('+') && t.length > 1));
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// gateMatch:比裸 includes 收紧三处(2026-09-24;p2-batch2 补 ③)——
|
|
119
|
+
// ① token 边界:'git checkout' 不再误吃 'git commit-msg'
|
|
120
|
+
// ② 剥离 git 全局参 -c <k=v> 与 -m <msg> 后以剥后文本为准——堵 'git -c x=y reset --hard' 绕过
|
|
121
|
+
// ③ 消息字样误触(p2-batch2):带引号多词消息(-m "修 git push --force 误拦")单 token 剥不净——
|
|
122
|
+
// 剥离逻辑收敛到 stripMessages 单源(引号感知)
|
|
97
123
|
function gateMatch(cmd, pat) {
|
|
98
124
|
const re = new RegExp(pat.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') + '(?![\\w-])');
|
|
99
|
-
const norm = cmd
|
|
125
|
+
const norm = stripMessages(cmd);
|
|
100
126
|
return norm !== cmd ? re.test(norm) : re.test(cmd);
|
|
101
127
|
}
|
|
102
128
|
|
|
129
|
+
if (isForcePush(command)) {
|
|
130
|
+
deny('禁止执行: git push 强制推送(--force / -f / +refspec;项目红线:禁强制推送)');
|
|
131
|
+
}
|
|
103
132
|
for (const d of denyList) {
|
|
104
133
|
if (gateMatch(command, d.pat)) {
|
|
105
134
|
deny(`禁止执行: ${d.pat}(项目红线:${d.reason})`);
|
|
@@ -125,6 +154,8 @@ if (!shellBin) {
|
|
|
125
154
|
}
|
|
126
155
|
|
|
127
156
|
// runGate:把 .githooks/ 门禁原始输出透传给 AI;未执行(脚本缺失)与判定失败分开报,避免把 ENOENT 误报成代码违例
|
|
157
|
+
// 127 分支(2026-09-27 host-gates-p1 P2-B4):shell 报 127 = 脚本未装(二进制已在 resolveShell 预检排除)——
|
|
158
|
+
// 实测 ENOENT 分支不可达(execFileSync 对存在的 bash 跑缺失脚本返回 status 127 而非 e.code ENOENT)
|
|
128
159
|
function runGate(scriptRelPath, label, budgetMs) {
|
|
129
160
|
try {
|
|
130
161
|
execFileSync(shellBin, [scriptRelPath], {
|
|
@@ -136,7 +167,7 @@ function runGate(scriptRelPath, label, budgetMs) {
|
|
|
136
167
|
if (e.code === 'ETIMEDOUT') {
|
|
137
168
|
deny(`${label}超时(${scriptRelPath},${Math.round(budgetMs / 1000)} 秒未完成)——检查 dotnet build / npm run build 是否卡住`);
|
|
138
169
|
}
|
|
139
|
-
if (e.code === 'ENOENT') {
|
|
170
|
+
if (e.code === 'ENOENT' || e.status === 127) {
|
|
140
171
|
deny(`门禁未执行(${label}):${scriptRelPath} 不可达——确认仓库完整后重试`);
|
|
141
172
|
}
|
|
142
173
|
const err = String((e.stdout || '') + (e.stderr || '')).slice(0, 1200);
|
|
@@ -4,6 +4,8 @@ description: 在已批准且边界明确的工作包内实现改动或补测试
|
|
|
4
4
|
---
|
|
5
5
|
# Implementer
|
|
6
6
|
|
|
7
|
+
> 公共角色契约(本文件):`.agents/roles/implementer.md`。宿主薄适配(`.opencode/` / `.trae/` / `.zcode/` 下 `agents/implementer.md`)正文段同源本文件,frontmatter 各自保留宿主特化字段(check-loop 检查项 6 按本引用校验适配层不断线)。
|
|
8
|
+
|
|
7
9
|
## 职责
|
|
8
10
|
|
|
9
11
|
执行已经由主智能体和用户确认、范围明确的实现任务。适用范围仅限:
|
|
@@ -4,6 +4,8 @@ description: 只读独立复核(spec 或实现 diff);不改动文件、不
|
|
|
4
4
|
---
|
|
5
5
|
# Independent Reviewer
|
|
6
6
|
|
|
7
|
+
> 公共角色契约(本文件):`.agents/roles/independent-reviewer.md`。宿主薄适配(`.opencode/` / `.trae/` / `.zcode/` 下 `agents/independent-reviewer.md`)正文段同源本文件,frontmatter 各自保留宿主特化字段(check-loop 检查项 6 按本引用校验适配层不断线)。
|
|
8
|
+
|
|
7
9
|
## 职责
|
|
8
10
|
|
|
9
11
|
在独立上下文中对 spec、plan 或代码 diff 做只读复核,发现原作者可能遗漏的正确性、契约、架构、数据安全和回归风险。
|
|
@@ -4,6 +4,8 @@ description: 浏览器实测 UI 改动(只读验证、不留脏数据);结
|
|
|
4
4
|
---
|
|
5
5
|
# UI Verifier
|
|
6
6
|
|
|
7
|
+
> 公共角色契约(本文件):`.agents/roles/ui-verifier.md`。宿主薄适配(`.opencode/` / `.trae/` / `.zcode/` 下 `agents/ui-verifier.md`)正文段同源本文件,frontmatter 各自保留宿主特化字段(check-loop 检查项 6 按本引用校验适配层不断线)。
|
|
8
|
+
|
|
7
9
|
## 职责
|
|
8
10
|
|
|
9
11
|
对已经实现的 UI 改动执行浏览器实测并收集可复核证据。只验证,不修复。
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agentic-flow-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "AI-Native 闭环工作流 + wiki 知识层脚手架——flow-kit init 一条命令为新项目装好 .agents 工作流引擎(阶段命令/角色契约/门禁钩子/kb 检索/看板/规则面预算)+ workflow 文档闭环 + wiki 知识库,装完自包含、零运行时依赖",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "node src/run-tests.mjs",
|
|
8
|
-
"prepack": "node -e \"require('fs').rmSync('templates/_agents/cache',{recursive:true,force:true})\""
|
|
8
|
+
"prepack": "node -e \"require('fs').rmSync('templates/_agents/cache',{recursive:true,force:true})\" && node scripts/check-pack-eol.mjs"
|
|
9
9
|
},
|
|
10
10
|
"bin": {
|
|
11
11
|
"flow-kit": "bin/flow-kit.mjs"
|
package/src/add-gate.mjs
CHANGED
|
@@ -73,15 +73,17 @@ export function addGate(args, pkgRoot) {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
// owned 台账补记(归项目所有,sync 永不覆盖)。接线改写了 local-pre-commit(init 时按模板态记账)——
|
|
76
|
-
// 须同步刷新其 owned 哈希,否则台账停在模板态(Shipyard 回流发现的漂移根因,2026-09-24
|
|
76
|
+
// 须同步刷新其 owned 哈希,否则台账停在模板态(Shipyard 回流发现的漂移根因,2026-09-24)。
|
|
77
|
+
// 记账一律 LF 归一(init-p1-batch P1-4 rider):与 doctor §6.6 / sync ownedSha 同口径,跨 checkout 字节稳定
|
|
78
|
+
const shaText = (p) => sha256(Buffer.from(fs.readFileSync(p, 'utf8').replace(/\r\n/g, '\n'), 'utf8'));
|
|
77
79
|
const ownedLedger = new Map((kit.owned || []).map((f) => [f.rel, f]));
|
|
78
80
|
for (const name of installed) {
|
|
79
81
|
const rel = `.agents/hooks/${name}`;
|
|
80
|
-
ownedLedger.set(rel, { rel, sha256:
|
|
82
|
+
ownedLedger.set(rel, { rel, sha256: shaText(path.join(hooksDir, name)) });
|
|
81
83
|
}
|
|
82
84
|
if (wiredLp) {
|
|
83
85
|
const lpRel = '.agents/hooks/local-pre-commit';
|
|
84
|
-
ownedLedger.set(lpRel, { rel: lpRel, sha256:
|
|
86
|
+
ownedLedger.set(lpRel, { rel: lpRel, sha256: shaText(path.join(hooksDir, 'local-pre-commit')) });
|
|
85
87
|
}
|
|
86
88
|
kit.owned = [...ownedLedger.values()].sort((a, b) => a.rel.localeCompare(b.rel));
|
|
87
89
|
fs.writeFileSync(kitPath, `${JSON.stringify(kit, null, 2)}\n`);
|