agentic-flow-kit 0.2.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 (111) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +62 -0
  3. package/bin/flow-kit.mjs +4 -0
  4. package/modules/gates/dotnet-ca/README.md +24 -0
  5. package/modules/gates/dotnet-ca/check-architecture.sh +128 -0
  6. package/modules/gates/dotnet-ca/local-pre-commit.line +1 -0
  7. package/modules/hosts/omp/agents/implementer.md +12 -0
  8. package/modules/hosts/omp/agents/independent-reviewer.md +11 -0
  9. package/modules/hosts/omp/agents/ui-verifier.md +12 -0
  10. package/modules/hosts/opencode/agents/implementer.md +14 -0
  11. package/modules/hosts/opencode/agents/independent-reviewer.md +10 -0
  12. package/modules/hosts/opencode/agents/ui-verifier.md +10 -0
  13. package/modules/hosts/opencode/commands/build.md +13 -0
  14. package/modules/hosts/opencode/commands/deploy.md +12 -0
  15. package/modules/hosts/opencode/commands/design.md +12 -0
  16. package/modules/hosts/opencode/commands/maintain.md +12 -0
  17. package/modules/hosts/opencode/commands/new-task.md +12 -0
  18. package/modules/hosts/opencode/commands/plan.md +12 -0
  19. package/modules/hosts/opencode/commands/review.md +12 -0
  20. package/modules/hosts/opencode/commands/test.md +14 -0
  21. package/modules/hosts/trae/agents/implementer.md +9 -0
  22. package/modules/hosts/trae/agents/independent-reviewer.md +8 -0
  23. package/modules/hosts/trae/agents/ui-verifier.md +12 -0
  24. package/modules/hosts/trae/commands/wf-build.md +14 -0
  25. package/modules/hosts/trae/commands/wf-deploy.md +13 -0
  26. package/modules/hosts/trae/commands/wf-design.md +13 -0
  27. package/modules/hosts/trae/commands/wf-maintain.md +13 -0
  28. package/modules/hosts/trae/commands/wf-new-task.md +13 -0
  29. package/modules/hosts/trae/commands/wf-plan.md +13 -0
  30. package/modules/hosts/trae/commands/wf-review.md +13 -0
  31. package/modules/hosts/trae/commands/wf-test.md +14 -0
  32. package/modules/hosts/trae/hooks/post-edit-check.cjs +87 -0
  33. package/modules/hosts/trae/hooks/pre-shell-check.cjs +151 -0
  34. package/modules/hosts/trae/hooks/resolve-shell.cjs +21 -0
  35. package/modules/hosts/trae/hooks.json +29 -0
  36. package/modules/hosts/trae/rules/beautify-input-chinese.md +6 -0
  37. package/modules/hosts/trae/rules/git-commit-message.md +10 -0
  38. package/modules/hosts/trae/rules/project-workflow.md +14 -0
  39. package/modules/hosts/zcode/agents/implementer.md +11 -0
  40. package/modules/hosts/zcode/agents/independent-reviewer.md +10 -0
  41. package/modules/hosts/zcode/agents/ui-verifier.md +10 -0
  42. package/package.json +34 -0
  43. package/src/add-gate.mjs +83 -0
  44. package/src/add-host.mjs +63 -0
  45. package/src/cli.mjs +81 -0
  46. package/src/doctor.mjs +150 -0
  47. package/src/init.mjs +190 -0
  48. package/src/profiles.mjs +101 -0
  49. package/src/render.mjs +68 -0
  50. package/src/run-tests.mjs +35 -0
  51. package/src/sync.mjs +141 -0
  52. package/src/sync.test.mjs +207 -0
  53. package/templates/.gitattributes +6 -0
  54. package/templates/AGENTS.md +52 -0
  55. package/templates/_agents/board/index.html +382 -0
  56. package/templates/_agents/board/marked.min.js +6 -0
  57. package/templates/_agents/cache/kb-index.json +1 -0
  58. package/templates/_agents/commands/build.md +74 -0
  59. package/templates/_agents/commands/deploy.md +65 -0
  60. package/templates/_agents/commands/design.md +54 -0
  61. package/templates/_agents/commands/maintain.md +91 -0
  62. package/templates/_agents/commands/new-task.md +73 -0
  63. package/templates/_agents/commands/plan.md +46 -0
  64. package/templates/_agents/commands/review.md +59 -0
  65. package/templates/_agents/commands/test.md +80 -0
  66. package/templates/_agents/hooks/check-pairing-incremental.sh +29 -0
  67. package/templates/_agents/hooks/check-wiki-ledger.sh +18 -0
  68. package/templates/_agents/hooks/commit-check.cjs +140 -0
  69. package/templates/_agents/hooks/local-pre-commit +6 -0
  70. package/templates/_agents/notes/runtime-env.md +18 -0
  71. package/templates/_agents/roles/implementer.md +46 -0
  72. package/templates/_agents/roles/independent-reviewer.md +43 -0
  73. package/templates/_agents/roles/ui-verifier.md +42 -0
  74. package/templates/_agents/rule-budgets.txt +8 -0
  75. package/templates/_agents/scripts/agg-delegations.cjs +175 -0
  76. package/templates/_agents/scripts/check-loop.sh +803 -0
  77. package/templates/_agents/scripts/check-loop.test.sh +1042 -0
  78. package/templates/_agents/scripts/ensure-board.ps1 +48 -0
  79. package/templates/_agents/scripts/gen-wiki-board.mjs +197 -0
  80. package/templates/_agents/scripts/gen-wiki-board.test.mjs +136 -0
  81. package/templates/_agents/scripts/gen-workflow-index.mjs +190 -0
  82. package/templates/_agents/scripts/gen-workflow-index.test.mjs +113 -0
  83. package/templates/_agents/scripts/gen-workflow-metrics.mjs +172 -0
  84. package/templates/_agents/scripts/gen-workflow-metrics.test.mjs +101 -0
  85. package/templates/_agents/scripts/kb-cache-evict.mjs +50 -0
  86. package/templates/_agents/scripts/kb-cache-evict.test.mjs +104 -0
  87. package/templates/_agents/scripts/kb-search.mjs +307 -0
  88. package/templates/_agents/scripts/kb-search.test.mjs +153 -0
  89. package/templates/_agents/scripts/rule-budget.sh +68 -0
  90. package/templates/_agents/scripts/verify-wiki-consistency.mjs +192 -0
  91. package/templates/_agents/scripts/wiki-search.mjs +19 -0
  92. package/templates/_agents/scripts/workflow-board-server.mjs +244 -0
  93. package/templates/_agents/skills/verify-ui/SKILL.md +24 -0
  94. package/templates/_agents/skills/wiki/SKILL.md +104 -0
  95. package/templates/_agents/workflow-modules.txt +11 -0
  96. package/templates/_githooks/commit-msg +15 -0
  97. package/templates/_githooks/post-commit +10 -0
  98. package/templates/_githooks/pre-commit +58 -0
  99. package/templates/_githooks/pre-merge-commit +24 -0
  100. package/templates/_githooks/pre-push +32 -0
  101. package/templates/wiki/INDEX.md +23 -0
  102. package/templates/wiki/drafts-archive/README.md +3 -0
  103. package/templates/wiki//347/237/245/350/257/206/346/262/211/346/267/200/346/200/273/350/247/210.html +56 -0
  104. package/templates/workflow/README.md +52 -0
  105. package/templates/workflow/delegations.md +28 -0
  106. package/templates/workflow/incidents/_TEMPLATE.md +42 -0
  107. package/templates/workflow/intents/_TEMPLATE.md +40 -0
  108. package/templates/workflow/papercuts.md +7 -0
  109. package/templates/workflow/plans/_TEMPLATE.md +38 -0
  110. package/templates/workflow/regression-checklist.md +22 -0
  111. package/templates/workflow/specs/_TEMPLATE.md +41 -0
@@ -0,0 +1,46 @@
1
+ # Implementer
2
+
3
+ ## 职责
4
+
5
+ 执行已经由主智能体和用户确认、范围明确的实现任务。适用范围仅限:
6
+
7
+ - 单文件或边界清晰的局部实现
8
+ - 有明确复现路径的 bug 修复
9
+ - 编写或调整任务直接要求的测试
10
+ - 修复与任务直接相关的编译错误
11
+
12
+ ## 必需输入
13
+
14
+ 开始前必须获得:
15
+
16
+ - 一句话任务目标
17
+ - 必须读取的入口文档、spec 或 plan
18
+ - 允许修改的文件清单
19
+ - 可执行的验收条件
20
+
21
+ 任一输入缺失或相互冲突时,停止并向主智能体报告,不自行扩大范围。
22
+
23
+ ## 行为边界
24
+
25
+ - 只修改明确授权的文件;若必须触及其他文件,先停止并说明原因。
26
+ - 仓库可能有其他智能体或用户同时工作;保留现有改动,不回退、不覆盖无关修改。
27
+ - 复用现有实现、标准库和已安装依赖,保持最小工作 diff。
28
+ - 不修改公共接口、数据 Schema、依赖、构建步骤、安全或权限策略。
29
+ - 不执行提交、推送、发布、数据迁移或破坏性操作。
30
+ - 不顺手重构、格式化或清理与任务无关的代码。
31
+
32
+ ## 验证
33
+
34
+ - 运行任务指定的最小相关检查。
35
+ - 检查失败时只修复由本次改动引起且仍在授权范围内的问题。
36
+ - 同一验证连续失败三次,或继续需要猜测需求时,停止并报告阻塞。
37
+
38
+ ## 输出
39
+
40
+ 返回给主智能体:
41
+
42
+ 1. 修改文件清单
43
+ 2. 每个文件的改动摘要
44
+ 3. 已运行的验证及结果
45
+ 4. 未解决的阻塞或剩余风险
46
+
@@ -0,0 +1,43 @@
1
+ # Independent Reviewer
2
+
3
+ ## 职责
4
+
5
+ 在独立上下文中对 spec、plan 或代码 diff 做只读复核,发现原作者可能遗漏的正确性、契约、架构、数据安全和回归风险。
6
+
7
+ ## 必需输入
8
+
9
+ 开始前必须获得:
10
+
11
+ - 复核对象及固定基准(文件路径、提交或 diff 范围)
12
+ - 对应入口文档、spec、plan(按任务级别提供)
13
+ - 项目根目录 `AGENTS.md` + 改动域对应的目录级 `AGENTS.md`(如有)
14
+ - 期望的复核结论或验收标准
15
+
16
+ 输入不足以确定范围时,停止并向主智能体报告。
17
+
18
+ ## 行为边界
19
+
20
+ - 只读,不修改任何仓库文件。
21
+ - 不替用户决定问题定性、方案取舍、合入或上线。
22
+ - 不继承或猜测原作者未写入输入材料的推理。
23
+ - 只报告能用具体文件、行号、行为或契约证明的问题。
24
+ - 不把样式偏好、假设性风险或既有无关问题包装成缺陷。
25
+ - 无法验证的事项明确标为未验证,不声称已经通过。
26
+
27
+ ## 复核重点
28
+
29
+ 1. 实现是否满足入口文档和验收标准
30
+ 2. 是否违反根 `AGENTS.md` 与改动域目录级 `AGENTS.md` 的架构、数据和所在域红线
31
+ 3. 是否改变未批准的公共契约或范围
32
+ 4. 是否缺少能防止回归的验证
33
+ 5. 是否存在数据丢失、安全、权限或发布风险
34
+
35
+ ## 输出
36
+
37
+ 按严重度输出问题清单:
38
+
39
+ - `P0`:数据、安全、权限或必然阻断交付的问题
40
+ - `P1`:功能错误、明确回归或违反项目硬约束
41
+ - `P2`:非阻断但有证据的维护性问题
42
+
43
+ 每项必须包含:位置、问题、证据、建议。没有发现时明确输出“未发现阻断问题”,并列出未验证范围。
@@ -0,0 +1,42 @@
1
+ # UI Verifier
2
+
3
+ ## 职责
4
+
5
+ 对已经实现的 UI 改动执行浏览器实测并收集可复核证据。只验证,不修复。
6
+
7
+ ## 必需输入
8
+
9
+ 开始前必须获得:
10
+
11
+ - 待验证页面或路由
12
+ - 用户操作步骤
13
+ - 每一步的预期结果
14
+ - 涉及的改动文件或 diff 范围
15
+
16
+ 缺少可观察的预期结果时,停止并向主智能体报告。
17
+
18
+ ## 执行
19
+
20
+ 1. 读取项目根目录 `AGENTS.md`,以及改动域目录级 `AGENTS.md`(如有,前端改动域)。
21
+ 2. 读取并遵循项目 UI 实测技能 `.agents/skills/verify-ui/SKILL.md`(如有)。
22
+ 3. 启动该技能指定的 API、前端和浏览器验证环境。
23
+ 4. 按输入步骤验证页面行为;布局类问题优先使用可重复的 DOM 几何数据。
24
+ 5. 收集控制台、网络请求、DOM 数据或截图等证据。
25
+ 6. 结束时关闭本次启动的后台进程。
26
+
27
+ ## 行为边界
28
+
29
+ - 不修改代码、配置、测试数据或工作流文档。
30
+ - 不自行修复发现的问题;将失败证据交还主智能体。
31
+ - 不使用生产环境或真实业务数据。
32
+ - 无法启动环境或完成关键路径时,报告阻塞,不把部分验证标记为通过。
33
+
34
+ ## 输出
35
+
36
+ 返回:
37
+
38
+ 1. 验证环境与页面路由
39
+ 2. 逐项通过/失败结果
40
+ 3. 失败的复现步骤和证据
41
+ 4. 控制台或网络异常
42
+ 5. 未验证范围与阻塞项
@@ -0,0 +1,8 @@
1
+ # 常驻面体积预算(单源:check-loop.sh 检查 13(--all,WARN)与 .githooks/pre-commit(--staged,硬拦)共读)
2
+ # 格式:<路径或 glob> <上限字节>;路径以 / 结尾表示目录合计。上限 = 当前实测 + 余量。
3
+ # 超限含义:常驻面只增不减——须先删除或下沉被取代条目再增(一进一出)。
4
+ # 本文件会被 core.autocrlf 检出为 CRLF,读取方(rule-budget.sh)已显式去 \r,禁止依赖行尾格式。
5
+ # 口径:预算比较用「索引 / HEAD 字节」(git cat-file,LF 归一);禁用工作区 wc -c 核对(CRLF 膨胀)。
6
+ AGENTS.md 7680
7
+ .agents/commands/*.md 8192
8
+ .agents/commands/ 49152
@@ -0,0 +1,175 @@
1
+ #!/usr/bin/env node
2
+ /* agg-delegations: 量化证据聚合
3
+ * 读 workflow/delegations.md 两张结果表(委派结果 / 自做任务结果)+ 扫 workflow/incidents/ 按月计数,
4
+ * 输出各月指标(一次通过率 / 平均返工次数 / 主兜底占比)、并发扩容门判定、可粘贴的月度快照行。
5
+ * 结果取值:一次通过 | 返工×N | 主兜底 | 返工待修(未闭环,不计入率)。
6
+ * 用法:node .agents/scripts/agg-delegations.cjs [--month=YYYY-MM](默认输出全部月份 + 全量累计)
7
+ * 门槛定义见 workflow/delegations.md §并发扩容门槛,两处须同步改。
8
+ */
9
+ 'use strict';
10
+ const fs = require('fs');
11
+ const path = require('path');
12
+
13
+ const ROOT = path.resolve(__dirname, '..', '..');
14
+ const LEDGER = path.join(ROOT, 'workflow', 'delegations.md');
15
+ const INCIDENTS = path.join(ROOT, 'workflow', 'incidents');
16
+
17
+ const argMonth = (process.argv.find((a) => a.startsWith('--month=')) || '').split('=')[1] || null;
18
+
19
+ function fail(msg) {
20
+ console.error(`agg-delegations: ${msg}`);
21
+ process.exit(1);
22
+ }
23
+
24
+ function parseTableRows(sectionText) {
25
+ return sectionText
26
+ .split(/\r?\n/)
27
+ .filter((l) => /^\|/.test(l.trim()))
28
+ .map((l) => l.trim().replace(/^\|/, '').replace(/\|$/, '').split('|').map((c) => c.trim()))
29
+ .filter((cols) => cols.length >= 2 && !/^[-: ]+$/.test(cols[1])) // 去表头分隔行
30
+ .filter((cols) => !/^\s*$/.test(cols[0]) && /^\d{4}-\d{2}-\d{2}$/.test(cols[0])); // 只留数据行(首列是日期)
31
+ }
32
+
33
+ function parseResult(raw) {
34
+ const r = (raw || '').trim();
35
+ if (/^一次通过$/.test(r)) return { kind: 'pass', rework: 0 };
36
+ const m = r.match(/^返工×(\d+)$/);
37
+ if (m) return { kind: 'rework', rework: parseInt(m[1], 10) };
38
+ if (/^主兜底$/.test(r)) return { kind: 'fallback', rework: 1 };
39
+ if (/^返工待修$/.test(r)) return { kind: 'pending', rework: 0 };
40
+ return { kind: 'unknown', rework: 0 };
41
+ }
42
+
43
+ function readLedger() {
44
+ if (!fs.existsSync(LEDGER)) fail(`找不到 ${LEDGER}`);
45
+ const text = fs.readFileSync(LEDGER, 'utf8');
46
+ const sections = {};
47
+ let cur = null;
48
+ for (const line of text.split(/\r?\n/)) {
49
+ const h = line.match(/^## (.+)$/);
50
+ if (h) cur = h[1].trim();
51
+ if (cur) (sections[cur] = sections[cur] || []).push(line);
52
+ }
53
+ const delegated = parseTableRows((sections['委派结果'] || []).join('\n')).map((c) => ({
54
+ scope: '委派',
55
+ date: c[0],
56
+ actor: c[1],
57
+ result: c[3] || '',
58
+ }));
59
+ const selfDone = parseTableRows((sections['自做任务结果'] || []).join('\n')).map((c) => ({
60
+ scope: '自做',
61
+ date: c[0],
62
+ actor: '主智能体',
63
+ result: c[2] || '',
64
+ }));
65
+ return delegated.concat(selfDone);
66
+ }
67
+
68
+ function countIncidents() {
69
+ const byMonth = {};
70
+ if (!fs.existsSync(INCIDENTS)) return byMonth;
71
+ for (const f of fs.readdirSync(INCIDENTS)) {
72
+ const m = f.match(/^(\d{4}-\d{2})-\d{2}.*\.md$/);
73
+ if (m) byMonth[m[1]] = (byMonth[m[1]] || 0) + 1;
74
+ }
75
+ return byMonth;
76
+ }
77
+
78
+ // 门槛(与 workflow/delegations.md §并发扩容门槛 同步)
79
+ const GATE = { minSample: 20, minPassRate: 0.9, maxAvgRework: 0.3, minDelegated: 5, maxFallbackRate: 0.1 };
80
+
81
+ function metrics(rows) {
82
+ const valid = rows.filter((r) => parseResult(r.result).kind !== 'pending' && parseResult(r.result).kind !== 'unknown');
83
+ const pending = rows.length - valid.length;
84
+ let pass = 0, reworkSum = 0, fallback = 0;
85
+ for (const r of valid) {
86
+ const p = parseResult(r.result);
87
+ if (p.kind === 'pass') pass += 1;
88
+ if (p.kind === 'fallback') fallback += 1;
89
+ reworkSum += p.rework;
90
+ }
91
+ const delegatedValid = valid.filter((r) => r.scope === '委派');
92
+ return {
93
+ total: valid.length,
94
+ pending,
95
+ pass,
96
+ passRate: valid.length ? pass / valid.length : null,
97
+ reworkSum,
98
+ avgRework: valid.length ? reworkSum / valid.length : null,
99
+ delegatedValid: delegatedValid.length,
100
+ fallback,
101
+ fallbackRate: delegatedValid.length ? fallback / delegatedValid.length : null,
102
+ };
103
+ }
104
+
105
+ function fmtRate(x, digits = 0) {
106
+ return x == null ? '—' : `${(x * 100).toFixed(digits)}%`;
107
+ }
108
+ function fmtNum(x) {
109
+ return x == null ? '—' : x.toFixed(2);
110
+ }
111
+
112
+ function gate(m, incidents) {
113
+ const items = [];
114
+ items.push({ no: 1, ok: m.total >= GATE.minSample, desc: `样本量 ${m.total}/${GATE.minSample}` });
115
+ items.push({
116
+ no: 2,
117
+ ok: m.passRate != null && m.passRate >= GATE.minPassRate,
118
+ desc: `一次通过率 ${fmtRate(m.passRate)}≥90%`,
119
+ });
120
+ items.push({
121
+ no: 3,
122
+ ok: m.avgRework != null && m.avgRework <= GATE.maxAvgRework,
123
+ desc: `平均返工 ${fmtNum(m.avgRework)}≤0.3`,
124
+ });
125
+ const delegOk = m.delegatedValid >= GATE.minDelegated && m.fallbackRate != null && m.fallbackRate <= GATE.maxFallbackRate;
126
+ items.push({
127
+ no: 4,
128
+ ok: delegOk,
129
+ desc: `委派样本 ${m.delegatedValid}≥5 且主兜底 ${fmtRate(m.fallbackRate)}≤10%`,
130
+ });
131
+ items.push({ no: 5, ok: null, desc: '门禁不失守(人工对照当月 incident 定性)' });
132
+ const hardOk = items.filter((i) => i.ok !== null).every((i) => i.ok);
133
+ const bad = items.filter((i) => i.ok === false).map((i) => i.no).join('+');
134
+ return { items, verdict: hardOk ? '✅(待人工确认门5)' : `❌ 未达标项:${bad}` };
135
+ }
136
+
137
+ function main() {
138
+ const rows = readLedger();
139
+ const incidents = countIncidents();
140
+
141
+ const byMonth = {};
142
+ for (const r of rows) {
143
+ const ym = r.date.slice(0, 7);
144
+ (byMonth[ym] = byMonth[ym] || []).push(r);
145
+ }
146
+ const months = Object.keys(byMonth).sort().filter((m) => !argMonth || m === argMonth);
147
+
148
+ console.log(`# 量化证据聚合(${argMonth || '全部月份'}) 生成于 ${new Date().toISOString().slice(0, 10)}\n`);
149
+
150
+ const snapshotRows = [];
151
+ for (const ym of months) {
152
+ const m = metrics(byMonth[ym]);
153
+ const g = gate(m, incidents[ym] || 0);
154
+ console.log(`## ${ym}`);
155
+ console.log(` 有效任务 ${m.total}(待修 ${m.pending})|一次通过 ${m.pass}(${fmtRate(m.passRate)})|返工总次数 ${m.reworkSum}(平均 ${fmtNum(m.avgRework)})|主兜底 ${m.fallback}/${m.delegatedValid}(${fmtRate(m.fallbackRate)})|incident ${incidents[ym] || 0} 起`);
156
+ for (const i of g.items) console.log(` 门${i.no} ${i.ok === null ? '[人工]' : i.ok ? '✅' : '❌'} ${i.desc}`);
157
+ console.log(` 扩容门判定:${g.verdict}\n`);
158
+ snapshotRows.push(`| ${ym} | ${m.total} | ${fmtRate(m.passRate)} | ${fmtNum(m.avgRework)} | ${fmtRate(m.fallbackRate)} | ${incidents[ym] || 0} | ${g.verdict} | 样本含待修${m.pending} |`);
159
+ }
160
+
161
+ if (!argMonth && rows.length) {
162
+ const m = metrics(rows);
163
+ console.log(`## 全量累计`);
164
+ console.log(` 有效任务 ${m.total}(待修 ${m.pending})|一次通过 ${fmtRate(m.passRate)}|平均返工 ${fmtNum(m.avgRework)}|主兜底 ${fmtRate(m.fallbackRate)}|incident 合计 ${Object.values(incidents).reduce((a, b) => a + b, 0)} 起\n`);
165
+ }
166
+
167
+ console.log(`## 可粘贴快照行(粘到 workflow/delegations.md §月度聚合快照)`);
168
+ for (const r of snapshotRows) console.log(r);
169
+
170
+ if (!rows.length) {
171
+ console.log('\n(台账为空:尚无记录,扩容门自然未通过)');
172
+ }
173
+ }
174
+
175
+ main();