@fitlab-ai/agent-infra 0.7.4 → 0.7.6
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/bin/cli.ts +13 -11
- package/dist/bin/cli.js +13 -11
- package/dist/lib/init.js +1 -1
- package/dist/lib/merge.js +1 -1
- package/dist/lib/sandbox/commands/create.js +26 -4
- package/dist/lib/sandbox/index.js +21 -21
- package/dist/lib/sandbox/tools.js +20 -1
- package/dist/lib/task/commands/log.js +56 -6
- package/dist/lib/task/index.js +13 -13
- package/dist/lib/update.js +1 -1
- package/lib/init.ts +1 -1
- package/lib/merge.ts +1 -1
- package/lib/sandbox/commands/create.ts +33 -4
- package/lib/sandbox/index.ts +21 -21
- package/lib/sandbox/tools.ts +28 -1
- package/lib/task/commands/log.ts +59 -6
- package/lib/task/index.ts +13 -13
- package/lib/update.ts +1 -1
- package/package.json +1 -1
- package/templates/.agents/rules/README.en.md +7 -3
- package/templates/.agents/rules/README.zh-CN.md +7 -3
- package/templates/.agents/rules/cli-help-format.en.md +49 -0
- package/templates/.agents/rules/cli-help-format.zh-CN.md +49 -0
- package/templates/.agents/rules/no-mid-flow-questions.en.md +25 -2
- package/templates/.agents/rules/no-mid-flow-questions.zh-CN.md +25 -2
- package/templates/.agents/rules/pr-sync.github.en.md +8 -6
- package/templates/.agents/rules/pr-sync.github.zh-CN.md +8 -6
- package/templates/.agents/rules/review-handshake.en.md +97 -0
- package/templates/.agents/rules/review-handshake.zh-CN.md +97 -0
- package/templates/.agents/rules/task-management.en.md +25 -0
- package/templates/.agents/rules/task-management.zh-CN.md +29 -0
- package/templates/.agents/scripts/lib/post-review-commit.js +56 -0
- package/templates/.agents/scripts/lib/review-artifacts.js +117 -0
- package/templates/.agents/scripts/review-diff-fingerprint.js +99 -0
- package/templates/.agents/scripts/validate-artifact.js +251 -2
- package/templates/.agents/skills/analyze-task/SKILL.en.md +63 -6
- package/templates/.agents/skills/analyze-task/SKILL.zh-CN.md +63 -6
- package/templates/.agents/skills/block-task/SKILL.en.md +10 -0
- package/templates/.agents/skills/block-task/SKILL.zh-CN.md +10 -0
- package/templates/.agents/skills/cancel-task/SKILL.en.md +10 -0
- package/templates/.agents/skills/cancel-task/SKILL.zh-CN.md +11 -1
- package/templates/.agents/skills/close-codescan/SKILL.en.md +10 -0
- package/templates/.agents/skills/close-codescan/SKILL.zh-CN.md +10 -0
- package/templates/.agents/skills/close-dependabot/SKILL.en.md +10 -0
- package/templates/.agents/skills/close-dependabot/SKILL.zh-CN.md +10 -0
- package/templates/.agents/skills/code-task/SKILL.en.md +11 -0
- package/templates/.agents/skills/code-task/SKILL.zh-CN.md +11 -0
- package/templates/.agents/skills/code-task/config/verify.en.json +3 -0
- package/templates/.agents/skills/code-task/config/verify.zh-CN.json +3 -0
- package/templates/.agents/skills/code-task/reference/fix-mode.en.md +5 -3
- package/templates/.agents/skills/code-task/reference/fix-mode.zh-CN.md +5 -3
- package/templates/.agents/skills/code-task/reference/report-template.en.md +4 -4
- package/templates/.agents/skills/code-task/reference/report-template.zh-CN.md +4 -4
- package/templates/.agents/skills/code-task/scripts/detect-mode.js +2 -107
- package/templates/.agents/skills/commit/SKILL.en.md +16 -0
- package/templates/.agents/skills/commit/SKILL.zh-CN.md +16 -0
- package/templates/.agents/skills/commit/reference/task-status-update.en.md +8 -0
- package/templates/.agents/skills/commit/reference/task-status-update.zh-CN.md +8 -0
- package/templates/.agents/skills/complete-task/SKILL.en.md +20 -0
- package/templates/.agents/skills/complete-task/SKILL.zh-CN.md +20 -0
- package/templates/.agents/skills/complete-task/config/verify.en.json +2 -0
- package/templates/.agents/skills/complete-task/config/verify.zh-CN.json +2 -0
- package/templates/.agents/skills/create-pr/SKILL.en.md +20 -1
- package/templates/.agents/skills/create-pr/SKILL.zh-CN.md +20 -1
- package/templates/.agents/skills/create-pr/reference/comment-publish.en.md +1 -1
- package/templates/.agents/skills/create-pr/reference/comment-publish.zh-CN.md +1 -1
- package/templates/.agents/skills/create-release-note/SKILL.en.md +16 -1
- package/templates/.agents/skills/create-release-note/SKILL.zh-CN.md +16 -1
- package/templates/.agents/skills/create-task/SKILL.en.md +11 -0
- package/templates/.agents/skills/create-task/SKILL.zh-CN.md +14 -3
- package/templates/.agents/skills/import-codescan/SKILL.en.md +11 -0
- package/templates/.agents/skills/import-codescan/SKILL.zh-CN.md +11 -0
- package/templates/.agents/skills/import-dependabot/SKILL.en.md +11 -0
- package/templates/.agents/skills/import-dependabot/SKILL.zh-CN.md +11 -0
- package/templates/.agents/skills/import-issue/SKILL.en.md +16 -0
- package/templates/.agents/skills/import-issue/SKILL.zh-CN.md +16 -0
- package/templates/.agents/skills/plan-task/SKILL.en.md +13 -1
- package/templates/.agents/skills/plan-task/SKILL.zh-CN.md +13 -1
- package/templates/.agents/skills/plan-task/config/verify.en.json +3 -0
- package/templates/.agents/skills/plan-task/config/verify.zh-CN.json +3 -0
- package/templates/.agents/skills/restore-task/SKILL.en.md +10 -0
- package/templates/.agents/skills/restore-task/SKILL.zh-CN.md +10 -0
- package/templates/.agents/skills/review-analysis/SKILL.en.md +10 -0
- package/templates/.agents/skills/review-analysis/SKILL.zh-CN.md +10 -0
- package/templates/.agents/skills/review-analysis/config/verify.en.json +2 -1
- package/templates/.agents/skills/review-analysis/config/verify.zh-CN.json +2 -1
- package/templates/.agents/skills/review-analysis/reference/output-templates.en.md +5 -4
- package/templates/.agents/skills/review-analysis/reference/output-templates.zh-CN.md +5 -4
- package/templates/.agents/skills/review-analysis/reference/report-template.en.md +4 -0
- package/templates/.agents/skills/review-analysis/reference/report-template.zh-CN.md +4 -0
- package/templates/.agents/skills/review-analysis/reference/review-criteria.en.md +1 -0
- package/templates/.agents/skills/review-analysis/reference/review-criteria.zh-CN.md +1 -0
- package/templates/.agents/skills/review-code/SKILL.en.md +14 -1
- package/templates/.agents/skills/review-code/SKILL.zh-CN.md +14 -1
- package/templates/.agents/skills/review-code/config/verify.en.json +5 -2
- package/templates/.agents/skills/review-code/config/verify.zh-CN.json +5 -2
- package/templates/.agents/skills/review-code/reference/output-templates.en.md +5 -4
- package/templates/.agents/skills/review-code/reference/output-templates.zh-CN.md +5 -4
- package/templates/.agents/skills/review-code/reference/report-template.en.md +6 -0
- package/templates/.agents/skills/review-code/reference/report-template.zh-CN.md +6 -0
- package/templates/.agents/skills/review-code/reference/review-criteria.en.md +1 -0
- package/templates/.agents/skills/review-code/reference/review-criteria.zh-CN.md +1 -0
- package/templates/.agents/skills/review-plan/SKILL.en.md +10 -0
- package/templates/.agents/skills/review-plan/SKILL.zh-CN.md +10 -0
- package/templates/.agents/skills/review-plan/config/verify.en.json +2 -1
- package/templates/.agents/skills/review-plan/config/verify.zh-CN.json +2 -1
- package/templates/.agents/skills/review-plan/reference/output-templates.en.md +5 -4
- package/templates/.agents/skills/review-plan/reference/output-templates.zh-CN.md +5 -4
- package/templates/.agents/skills/review-plan/reference/report-template.en.md +4 -0
- package/templates/.agents/skills/review-plan/reference/report-template.zh-CN.md +4 -0
- package/templates/.agents/skills/review-plan/reference/review-criteria.en.md +1 -0
- package/templates/.agents/skills/review-plan/reference/review-criteria.zh-CN.md +1 -0
- package/templates/.agents/skills/watch-pr/SKILL.en.md +10 -0
- package/templates/.agents/skills/watch-pr/SKILL.zh-CN.md +10 -0
- package/templates/.agents/templates/task.en.md +12 -0
- package/templates/.agents/templates/task.zh-CN.md +12 -0
- package/templates/.github/workflows/metadata-sync.yml +1 -1
- package/templates/.github/workflows/pr-label.yml +1 -1
- package/templates/.github/workflows/status-label.yml +1 -1
package/lib/task/commands/log.ts
CHANGED
|
@@ -4,13 +4,15 @@ import { resolveTaskRef } from '../resolve-ref.ts';
|
|
|
4
4
|
|
|
5
5
|
const USAGE = `Usage: ai task log <N | #N | TASK-id>
|
|
6
6
|
|
|
7
|
-
Renders a task's activity log as a
|
|
7
|
+
Renders a task's activity log as a per-step status table. A step's start and
|
|
8
|
+
completion are paired onto one row: STARTED holds the start time, DONE the
|
|
9
|
+
completion time (or '(in progress)' while still running).
|
|
8
10
|
<ref> Bare numeric / '#N' short id, or a full TASK-YYYYMMDD-HHMMSS id.
|
|
9
11
|
|
|
10
|
-
Columns: # (
|
|
12
|
+
Columns: # (row) / STEP / AGENT / STARTED / DONE / NOTE
|
|
11
13
|
`;
|
|
12
14
|
|
|
13
|
-
const TABLE_HEADERS = ['#', '
|
|
15
|
+
const TABLE_HEADERS = ['#', 'STEP', 'AGENT', 'STARTED', 'DONE', 'NOTE'] as const;
|
|
14
16
|
|
|
15
17
|
// The activity-log H2 heading is language-dependent (zh template / en template).
|
|
16
18
|
const HEADING_RE = /^##\s+(活动日志|Activity Log)\s*$/;
|
|
@@ -23,6 +25,17 @@ const ENTRY_RE =
|
|
|
23
25
|
|
|
24
26
|
type LogEntry = { time: string; step: string; agent: string; note: string };
|
|
25
27
|
|
|
28
|
+
// One rendered row = one step instance. `started`/`done` are timestamps; an empty
|
|
29
|
+
// `done` with a non-empty `started` means the step is still in flight, while an
|
|
30
|
+
// empty `started` is a historical done-only entry (no start marker was written).
|
|
31
|
+
type StepRow = { step: string; agent: string; started: string; done: string; note: string };
|
|
32
|
+
|
|
33
|
+
// A start marker reuses the normal entry grammar and only suffixes its action
|
|
34
|
+
// with ` [started]`; the matching done entry carries the identical base action
|
|
35
|
+
// without the suffix. Pairing therefore keys on the base action (including any
|
|
36
|
+
// `(Round N)`), so every round and every repeated execution pairs on its own.
|
|
37
|
+
const STARTED_SUFFIX_RE = /\s*\[started\]\s*$/;
|
|
38
|
+
|
|
26
39
|
function parseActivityLog(content: string): { sectionFound: boolean; entries: LogEntry[] } {
|
|
27
40
|
const lines = content.split('\n');
|
|
28
41
|
let i = 0;
|
|
@@ -44,6 +57,38 @@ function parseActivityLog(content: string): { sectionFound: boolean; entries: Lo
|
|
|
44
57
|
return { sectionFound: true, entries: parsed.map((p) => p.entry) };
|
|
45
58
|
}
|
|
46
59
|
|
|
60
|
+
// Collapse a chronological entry list into per-step rows: a `[started]` marker
|
|
61
|
+
// opens a row, the next matching done entry fills it in place (FIFO per base
|
|
62
|
+
// action). Started-only rows stay in flight; done-only entries (legacy logs with
|
|
63
|
+
// no start marker) render as standalone rows. Result order = first-seen order,
|
|
64
|
+
// which is already ascending because `entries` is sorted ascending.
|
|
65
|
+
function pairEntries(entries: LogEntry[]): StepRow[] {
|
|
66
|
+
const rows: StepRow[] = [];
|
|
67
|
+
const open = new Map<string, StepRow[]>();
|
|
68
|
+
for (const e of entries) {
|
|
69
|
+
const isStarted = STARTED_SUFFIX_RE.test(e.step);
|
|
70
|
+
const base = e.step.replace(STARTED_SUFFIX_RE, '');
|
|
71
|
+
if (isStarted) {
|
|
72
|
+
const row: StepRow = { step: base, agent: e.agent, started: e.time, done: '', note: e.note };
|
|
73
|
+
rows.push(row);
|
|
74
|
+
const queue = open.get(base);
|
|
75
|
+
if (queue) queue.push(row);
|
|
76
|
+
else open.set(base, [row]);
|
|
77
|
+
} else {
|
|
78
|
+
const pending = open.get(base)?.shift();
|
|
79
|
+
if (pending) {
|
|
80
|
+
// Done fills the open row; the done entry carries the meaningful note.
|
|
81
|
+
pending.done = e.time;
|
|
82
|
+
pending.agent = e.agent;
|
|
83
|
+
pending.note = e.note;
|
|
84
|
+
} else {
|
|
85
|
+
rows.push({ step: base, agent: e.agent, started: '', done: e.time, note: e.note });
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return rows;
|
|
90
|
+
}
|
|
91
|
+
|
|
47
92
|
function log(args: string[] = []): void {
|
|
48
93
|
if (args.length === 0 || args[0] === '--help' || args[0] === '-h') {
|
|
49
94
|
process.stdout.write(USAGE);
|
|
@@ -70,11 +115,19 @@ function log(args: string[] = []): void {
|
|
|
70
115
|
process.exitCode = 1;
|
|
71
116
|
return;
|
|
72
117
|
}
|
|
73
|
-
const
|
|
118
|
+
const steps = pairEntries(entries);
|
|
119
|
+
const rows = steps.map((s, idx) => [
|
|
120
|
+
String(idx + 1),
|
|
121
|
+
s.step,
|
|
122
|
+
s.agent,
|
|
123
|
+
s.started,
|
|
124
|
+
s.done || (s.started ? '(in progress)' : ''),
|
|
125
|
+
s.note
|
|
126
|
+
]);
|
|
74
127
|
for (const line of formatTable(TABLE_HEADERS, rows, { zebra: Boolean(process.stdout.isTTY) })) {
|
|
75
128
|
process.stdout.write(`${line}\n`);
|
|
76
129
|
}
|
|
77
|
-
process.stdout.write(`Total: ${
|
|
130
|
+
process.stdout.write(`Total: ${steps.length} steps\n`);
|
|
78
131
|
}
|
|
79
132
|
|
|
80
|
-
export { log, parseActivityLog };
|
|
133
|
+
export { log, parseActivityLog, pairEntries };
|
package/lib/task/index.ts
CHANGED
|
@@ -38,14 +38,9 @@ export async function runTask(args: string[]): Promise<void> {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
switch (subcommand) {
|
|
41
|
-
case '
|
|
42
|
-
const {
|
|
43
|
-
|
|
44
|
-
break;
|
|
45
|
-
}
|
|
46
|
-
case 'show': {
|
|
47
|
-
const { show } = await import('./commands/show.ts');
|
|
48
|
-
show(rest);
|
|
41
|
+
case 'cat': {
|
|
42
|
+
const { cat } = await import('./commands/cat.ts');
|
|
43
|
+
cat(rest);
|
|
49
44
|
break;
|
|
50
45
|
}
|
|
51
46
|
case 'files': {
|
|
@@ -53,11 +48,6 @@ export async function runTask(args: string[]): Promise<void> {
|
|
|
53
48
|
files(rest);
|
|
54
49
|
break;
|
|
55
50
|
}
|
|
56
|
-
case 'cat': {
|
|
57
|
-
const { cat } = await import('./commands/cat.ts');
|
|
58
|
-
cat(rest);
|
|
59
|
-
break;
|
|
60
|
-
}
|
|
61
51
|
case 'grep': {
|
|
62
52
|
const { grep } = await import('./commands/grep.ts');
|
|
63
53
|
grep(rest);
|
|
@@ -68,6 +58,16 @@ export async function runTask(args: string[]): Promise<void> {
|
|
|
68
58
|
log(rest);
|
|
69
59
|
break;
|
|
70
60
|
}
|
|
61
|
+
case 'ls': {
|
|
62
|
+
const { ls } = await import('./commands/ls.ts');
|
|
63
|
+
ls(rest);
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
case 'show': {
|
|
67
|
+
const { show } = await import('./commands/show.ts');
|
|
68
|
+
show(rest);
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
71
|
case 'status': {
|
|
72
72
|
const { status } = await import('./commands/status.ts');
|
|
73
73
|
status(rest);
|
package/lib/update.ts
CHANGED
|
@@ -119,7 +119,7 @@ function syncFileRegistry(config: UpdateConfig, platformType: string, enabledTUI
|
|
|
119
119
|
|
|
120
120
|
async function cmdUpdate(): Promise<void> {
|
|
121
121
|
console.log('');
|
|
122
|
-
console.log('
|
|
122
|
+
console.log(' ai update');
|
|
123
123
|
console.log(' ==================================');
|
|
124
124
|
console.log('');
|
|
125
125
|
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@ so you can quickly find "which ones to read" without opening each file.
|
|
|
8
8
|
|
|
9
9
|
## General Principles
|
|
10
10
|
|
|
11
|
-
- [`no-mid-flow-questions.md`](no-mid-flow-questions.md) — Silence during SKILL runs: no user questions by default, plus
|
|
11
|
+
- [`no-mid-flow-questions.md`](no-mid-flow-questions.md) — Silence during SKILL runs: no user questions by default, plus the exceptions the rule lists.
|
|
12
12
|
- [`next-step-output.md`](next-step-output.md) — "Next step" output rules: task short-id rendering and the `Completed at` trailer.
|
|
13
13
|
- [`version-stamp.md`](version-stamp.md) — How and when to stamp `agent_infra_version`.
|
|
14
14
|
- [`debugging-guide.md`](debugging-guide.md) — Structured debugging flow: gather evidence → form hypothesis → verify hypothesis → fix the root cause; no blind patch-and-retry.
|
|
@@ -25,6 +25,7 @@ so you can quickly find "which ones to read" without opening each file.
|
|
|
25
25
|
## Task Workflow
|
|
26
26
|
|
|
27
27
|
- [`task-management.md`](task-management.md) — Task intent detection and workflow-command mapping.
|
|
28
|
+
- [`review-handshake.md`](review-handshake.md) — Three-stage bidirectional review handshake: four-state disposition, symmetric evidence, disagreement ledger, convergence and post-review commit gate.
|
|
28
29
|
- [`task-short-id.md`](task-short-id.md) — Resolution, allocation and lifecycle of `#NN` / bare-number short ids.
|
|
29
30
|
- [`milestone-inference.md`](milestone-inference.md) — Milestone inference for create-task / code-task / create-pr.
|
|
30
31
|
- [`label-milestone-setup.md`](label-milestone-setup.md) — Platform commands to initialize labels / milestones.
|
|
@@ -35,7 +36,10 @@ so you can quickly find "which ones to read" without opening each file.
|
|
|
35
36
|
- [`commit-and-pr.md`](commit-and-pr.md) — Conventional Commits message and PR conventions.
|
|
36
37
|
- [`release-commands.md`](release-commands.md) — Read past releases, query merged PRs, publish release notes.
|
|
37
38
|
|
|
38
|
-
## Testing
|
|
39
|
+
## Testing
|
|
39
40
|
|
|
40
41
|
- [`testing-discipline.md`](testing-discipline.md) — Test-writing discipline: prefer structural asserts, no brittle wording matches.
|
|
41
|
-
|
|
42
|
+
|
|
43
|
+
## CLI
|
|
44
|
+
|
|
45
|
+
- [`cli-help-format.md`](cli-help-format.md) — CLI help text conventions: unify display name on `ai`, `Usage:`+`Commands:` structure, alphabetical command order (top-level and namespace-level help only).
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
## 通用准则
|
|
9
9
|
|
|
10
|
-
- [`no-mid-flow-questions.md`](no-mid-flow-questions.md) — SKILL
|
|
10
|
+
- [`no-mid-flow-questions.md`](no-mid-flow-questions.md) — SKILL 执行期禁言:默认不向用户提问,及规则列明的例外。
|
|
11
11
|
- [`next-step-output.md`](next-step-output.md) — 「下一步」输出规则:任务短号渲染与 `Completed at` 收尾行。
|
|
12
12
|
- [`version-stamp.md`](version-stamp.md) — `agent_infra_version` 版本戳的取值命令与写入时机。
|
|
13
13
|
- [`debugging-guide.md`](debugging-guide.md) — 结构化调试流程:收集证据→形成假设→验证假设→修复根因,禁止盲目改代码重试。
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
## 任务工作流
|
|
25
25
|
|
|
26
26
|
- [`task-management.md`](task-management.md) — 任务语义识别与工作流命令映射。
|
|
27
|
+
- [`review-handshake.md`](review-handshake.md) — 三阶段双向审查握手协议:四态处置、对称证据、分歧账本、收敛与 post-review commit 门禁。
|
|
27
28
|
- [`task-short-id.md`](task-short-id.md) — 任务短号 `#NN` / 裸数字的解析、分配与生命周期。
|
|
28
29
|
- [`milestone-inference.md`](milestone-inference.md) — create-task / code-task / create-pr 的 milestone 推断。
|
|
29
30
|
- [`label-milestone-setup.md`](label-milestone-setup.md) — 初始化 label / milestone 的平台命令集。
|
|
@@ -34,7 +35,10 @@
|
|
|
34
35
|
- [`commit-and-pr.md`](commit-and-pr.md) — Conventional Commits 提交信息与 PR 规范。
|
|
35
36
|
- [`release-commands.md`](release-commands.md) — 读取历史 release、查询已合并 PR、发布 Release notes。
|
|
36
37
|
|
|
37
|
-
##
|
|
38
|
+
## 测试
|
|
38
39
|
|
|
39
40
|
- [`testing-discipline.md`](testing-discipline.md) — 测试编写纪律:结构性断言优先,禁止脆弱的措辞匹配。
|
|
40
|
-
|
|
41
|
+
|
|
42
|
+
## CLI
|
|
43
|
+
|
|
44
|
+
- [`cli-help-format.md`](cli-help-format.md) — CLI help 文案约定:展示名统一 `ai`、`Usage:`+`Commands:` 结构、命令按字母序(仅顶层与命名空间级 help)。
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# CLI help text conventions
|
|
2
|
+
|
|
3
|
+
Unify the help text display structure, display name, and command ordering of the `ai` / `agent-infra` CLI so newly added subcommands follow them automatically and never drift across levels again. Read this file before adding or changing CLI help text.
|
|
4
|
+
|
|
5
|
+
## Scope
|
|
6
|
+
|
|
7
|
+
- **Display name `ai`**: applies to **all** user-facing help / usage / banner text — top-level, namespace-level, and the single-line usage / startup banners of leaf commands such as `merge` / `init` / `update`. The only exceptions: the top-level help first line keeps the brand + version line `agent-infra ${VERSION}`, and `@fitlab-ai/agent-infra` in package names / install commands / repo URLs stays as-is.
|
|
8
|
+
- **Structure & ordering** (`Usage:` + `Commands:` structure, alphabetical command order): applies only to levels that carry a `Commands:` listing — top-level help (`bin/cli.ts`) and namespace-level help (e.g. `ai sandbox` / `ai task`). Leaf commands have only a single-line usage and need no `Commands:` structure.
|
|
9
|
+
|
|
10
|
+
## Display name
|
|
11
|
+
|
|
12
|
+
- Use **`ai`** as the command display name in help text (the recommended short form; `package.json`'s `bin` registers both `ai` and `agent-infra`).
|
|
13
|
+
- Keep the top-level help first line as the brand + version line `agent-infra ${VERSION} - bootstrap ...` (it is the brand and version marker that several tests anchor on).
|
|
14
|
+
- Keep `@fitlab-ai/agent-infra` in install methods, package names, and repo URLs as-is (those are package names, not command display names).
|
|
15
|
+
|
|
16
|
+
## List structure
|
|
17
|
+
|
|
18
|
+
Namespace-level and top-level help follow:
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
Usage: ai <ns> <command> [options]
|
|
22
|
+
|
|
23
|
+
Commands:
|
|
24
|
+
<command> <description aligned from two spaces>
|
|
25
|
+
...
|
|
26
|
+
|
|
27
|
+
Run 'ai <ns> <command> --help' for details.
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
- The `Commands:` block uses bare command names (no repeated binary name), two-space indent, descriptions aligned to the longest command name.
|
|
31
|
+
- Namespace-level help ends with a `Run 'ai <ns> <command> --help' for details.` footer.
|
|
32
|
+
- Top-level help has no uniform subcommand `--help` convention, so the footer is not required there; if an `Examples:` section exists, its command display name is also `ai`.
|
|
33
|
+
|
|
34
|
+
## Ordering
|
|
35
|
+
|
|
36
|
+
Command lists, `Examples`, and command enumerations embedded in descriptions are all sorted by the **first token of the command, in ascending alphabetical order**:
|
|
37
|
+
|
|
38
|
+
- Multi-token commands (e.g. `vm status|start|stop`) sort by the first token (`vm`).
|
|
39
|
+
- Commands with angle/square-bracket parameters sort by the command name (the bare word before the parameters).
|
|
40
|
+
- Case-insensitive.
|
|
41
|
+
|
|
42
|
+
## Checklist for adding a subcommand
|
|
43
|
+
|
|
44
|
+
When adding a subcommand:
|
|
45
|
+
|
|
46
|
+
1. Insert the command at the correct alphabetical position in `Commands:`.
|
|
47
|
+
2. If it has examples, insert them at the alphabetical position in `Examples:`.
|
|
48
|
+
3. If a top-level `task` / `sandbox` description has an embedded command enumeration, update its alphabetical order too.
|
|
49
|
+
4. Sync the corresponding help test's **structural** assertions (whether the command appears, whether the `Usage:` / `Commands:` header exists); do not bind to full sentences (see [`testing-discipline.md`](testing-discipline.md)).
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# CLI help 文案约定
|
|
2
|
+
|
|
3
|
+
统一 `ai` / `agent-infra` CLI 的 help 文案展示结构、展示名与命令排序,让后续新增子命令自动遵守,避免跨层级再次漂移。新增或调整 CLI help 文案前先读取本文件。
|
|
4
|
+
|
|
5
|
+
## 适用范围
|
|
6
|
+
|
|
7
|
+
- **展示名 `ai`**:适用于**所有**面向用户的 help / usage / 交互横幅文案——顶层、命名空间级,以及 `merge` / `init` / `update` 等叶子命令的单行 usage 与启动横幅,统一用 `ai`。唯一例外:顶层 help 首行保留品牌 + 版本行 `agent-infra ${VERSION}`;包名 / 安装命令 / 仓库 URL 中的 `@fitlab-ai/agent-infra` 保持原样。
|
|
8
|
+
- **结构与排序**(`Usage:` + `Commands:` 结构、命令按字母序):仅适用于带 `Commands:` 子清单的层级——顶层 help(`bin/cli.ts`)与命名空间级 help(如 `ai sandbox` / `ai task`)。叶子命令只有单行 usage,无需 `Commands:` 结构。
|
|
9
|
+
|
|
10
|
+
## 展示名
|
|
11
|
+
|
|
12
|
+
- help 文案中的命令展示名统一用 **`ai`**(推荐简写,`package.json` 的 `bin` 同时注册 `ai` 与 `agent-infra`)。
|
|
13
|
+
- 顶层 help 首行保留品牌 + 版本行 `agent-infra ${VERSION} - bootstrap ...`(这是品牌与版本标识,多处测试锚定它)。
|
|
14
|
+
- 安装方式、包名、仓库 URL 中的 `@fitlab-ai/agent-infra` 等保持原样(是包名而非命令展示名)。
|
|
15
|
+
|
|
16
|
+
## 列表结构
|
|
17
|
+
|
|
18
|
+
命名空间级与顶层 help 统一为:
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
Usage: ai <ns> <command> [options]
|
|
22
|
+
|
|
23
|
+
Commands:
|
|
24
|
+
<command> <两空格起对齐的描述>
|
|
25
|
+
...
|
|
26
|
+
|
|
27
|
+
Run 'ai <ns> <command> --help' for details.
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
- `Commands:` 块用裸命令名(不重复二进制名),两空格缩进,描述按最长命令名对齐。
|
|
31
|
+
- 命名空间级 help 末尾加 `Run 'ai <ns> <command> --help' for details.` footer。
|
|
32
|
+
- 顶层 help 无统一子命令 `--help` 约定,故不强制加该 footer;如有 `Examples:` 段,命令展示名同样用 `ai`。
|
|
33
|
+
|
|
34
|
+
## 排序
|
|
35
|
+
|
|
36
|
+
命令清单、`Examples`、描述中内嵌的命令枚举,一律按**命令首 token 的字母升序**排列:
|
|
37
|
+
|
|
38
|
+
- 多 token 命令(如 `vm status|start|stop`)按首 token(`vm`)排序。
|
|
39
|
+
- 带尖括号 / 方括号参数的命令按命令名(参数前的裸词)排序。
|
|
40
|
+
- 大小写不敏感。
|
|
41
|
+
|
|
42
|
+
## 新增子命令检查清单
|
|
43
|
+
|
|
44
|
+
新增一个子命令时:
|
|
45
|
+
|
|
46
|
+
1. 把命令插入 `Commands:` 的字母序正确位置。
|
|
47
|
+
2. 如有示例,插入 `Examples:` 的字母序位置。
|
|
48
|
+
3. 若顶层 `task` / `sandbox` 等描述中有内嵌命令枚举,同步更新其字母序。
|
|
49
|
+
4. 同步对应 help 测试的**结构性**断言(命令是否出现、`Usage:` / `Commands:` 头是否存在),不要绑定整句文案(见 [`testing-discipline.md`](testing-discipline.md))。
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# General Rule - No Mid-Flow Questions During SKILL Execution
|
|
2
2
|
|
|
3
3
|
> **Scope**: this rule applies to **all SKILL** executions.
|
|
4
|
-
> Only the
|
|
4
|
+
> Only the exemption categories listed below may ask the user; any other mid-flow question is a violation.
|
|
5
5
|
|
|
6
6
|
## Exemption Categories
|
|
7
7
|
|
|
@@ -27,9 +27,21 @@ SKILLs currently covered by this exemption:
|
|
|
27
27
|
- `init-labels`: may confirm before deleting legacy labels not in the final mapping
|
|
28
28
|
- `commit`: may stop and confirm when its plan conflicts with the user's uncommitted changes
|
|
29
29
|
|
|
30
|
+
### Exemption 3: Entry-point requirement-sufficiency clarification
|
|
31
|
+
|
|
32
|
+
Allowed only when a SKILL judges, **at its entry point**, whether the current task's requirement information is sufficient for a reliable analysis; it may then ask the user about the **missing requirement information** to converge the requirements. Constraints:
|
|
33
|
+
|
|
34
|
+
- Limited to the `analyze-task` entry point; ask one question at a time and wait for the answer before asking the next;
|
|
35
|
+
- Used only to fill requirement-sufficiency gaps; it must **not** be used to solicit implementation / technical-choice preferences (those still go into the artifact's `## Open Questions` per the default clause);
|
|
36
|
+
- Exit the questioning and proceed to normal analysis once the question budget is reached or the user says "just analyze / skip".
|
|
37
|
+
|
|
38
|
+
SKILLs currently covered by this exemption:
|
|
39
|
+
|
|
40
|
+
- `analyze-task`: when the task description/requirements are insufficient for a reliable analysis, it may ask questions one at a time at the entry point to converge the requirements
|
|
41
|
+
|
|
30
42
|
## No-Mid-Flow-Questions Clause (default behavior)
|
|
31
43
|
|
|
32
|
-
For every SKILL execution context not covered by
|
|
44
|
+
For every SKILL execution context not covered by any exemption above, the default behavior is:
|
|
33
45
|
|
|
34
46
|
1. Do not call any user-question tool, including but not limited to `AskUserQuestion` and equivalent mechanisms that ask the user to choose.
|
|
35
47
|
2. When uncertain, proceed with the most robust option without interrupting the flow. Use this priority order:
|
|
@@ -41,6 +53,17 @@ For every SKILL execution context not covered by the two exemptions above, the d
|
|
|
41
53
|
- Meaning: the assumptions section records assumptions used for this run that may be revisited later; the open questions section records unresolved questions for human review
|
|
42
54
|
- If the artifact template does not reserve these sections, append them as needed. If there are no assumptions or open questions, do not force empty sections.
|
|
43
55
|
|
|
56
|
+
## Key Design Decision Marking And Ledgering
|
|
57
|
+
|
|
58
|
+
When an open question is a key design decision that needs human judgment, the executor must mark the item with `[needs-human-decision]` and write the matching `HD-` row to task.md `## Review Disagreement Ledger` according to `.agents/rules/review-handshake.md`.
|
|
59
|
+
|
|
60
|
+
Use these checks together:
|
|
61
|
+
|
|
62
|
+
- **Source test**: can the conclusion be uniquely derived from the task description, existing requirements, code conventions, or an approved plan? If not, and multiple reasonable options exist, it is a choice.
|
|
63
|
+
- **Impact test**: does the choice change scope, boundaries, defaults, thresholds, become irreversible / costly, or set precedent for later tasks? Any hit upgrades it to a key design decision.
|
|
64
|
+
- **Small-impact exemption**: if it is only a local, reversible, low-cost execution detail, record it under `## Assumptions` instead of upgrading it to a human ruling.
|
|
65
|
+
- **Fallback**: when unsure whether it is key, treat it as key; `review-*` must check whether the executor missed any `[needs-human-decision]` markings that should have been upgraded.
|
|
66
|
+
|
|
44
67
|
## Human Review Checkpoint Semantics
|
|
45
68
|
|
|
46
69
|
A mandatory human review checkpoint means:
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# 通用规则 - SKILL 执行禁言
|
|
2
2
|
|
|
3
3
|
> **适用范围**:本规则适用于**所有 SKILL** 的执行过程。
|
|
4
|
-
>
|
|
4
|
+
> 仅以下列出的例外可向用户提问;不属于这些例外的发问一律按违规处理。
|
|
5
5
|
|
|
6
6
|
## 例外类型
|
|
7
7
|
|
|
@@ -27,9 +27,21 @@
|
|
|
27
27
|
- `init-labels`:删除不在最终映射中的旧 label 前可确认
|
|
28
28
|
- `commit`:检测到与用户未提交改动冲突时可停下确认
|
|
29
29
|
|
|
30
|
+
### 例外 3:入口式需求充分性澄清
|
|
31
|
+
|
|
32
|
+
仅当 SKILL 在**入口处**判断「当前任务的需求信息是否充分到可以可靠分析」时,可就**缺失的需求信息**向用户提问以收敛需求。约束:
|
|
33
|
+
|
|
34
|
+
- 仅限 `analyze-task` 入口;一次只问一个问题,等用户回答后再问下一个;
|
|
35
|
+
- 仅用于补齐需求充分性,**不得**借此征求实现方案 / 技术选型偏好(这些仍按禁言铁律写入产物的 `## 未决问题`);
|
|
36
|
+
- 达到提问预算上限或用户表示「直接分析 / skip」即退出提问,进入正常分析。
|
|
37
|
+
|
|
38
|
+
当前归入本例外的 SKILL:
|
|
39
|
+
|
|
40
|
+
- `analyze-task`:任务描述/需求信息不足以支撑可靠分析时,可在入口处逐个提问收敛需求
|
|
41
|
+
|
|
30
42
|
## 禁言条款(默认行为)
|
|
31
43
|
|
|
32
|
-
|
|
44
|
+
不属于上述任一例外的所有 SKILL 执行场景,遵循以下默认行为:
|
|
33
45
|
|
|
34
46
|
1. **禁止调用**任何向用户发问的工具(包括但不限于 `AskUserQuestion` 及等价的「征求用户选择」机制)。
|
|
35
47
|
2. **不确定时**,按「最稳健方案」自主推进,不中断对话。最稳健方案的判定优先级:
|
|
@@ -41,6 +53,17 @@
|
|
|
41
53
|
- 含义:`假设` 段记录本次按某假设推进、未来若假设不成立可推翻;`未决问题` 段记录本次未决、需要人工审查时裁定的问题
|
|
42
54
|
- 产物模板未预留这两段时,按需追加;没有假设或未决问题时不必强行写空段。
|
|
43
55
|
|
|
56
|
+
## 关键设计决策标记与落账
|
|
57
|
+
|
|
58
|
+
当未决问题属于需要人工裁定的关键设计决策时,执行方必须在该条目前标记 `[needs-human-decision]`,并按 `.agents/rules/review-handshake.md` 在 task.md `## 审查分歧账本` 写入 `HD-` 行。
|
|
59
|
+
|
|
60
|
+
判定时同时使用以下检查:
|
|
61
|
+
|
|
62
|
+
- **来源测试**:结论是否能从任务描述、既有需求、代码约定或已批准方案中唯一推出?若不能,且存在多个合理选项,则它是选择题。
|
|
63
|
+
- **影响测试**:该选择是否改变范围、边界、默认值、阈值,是否不可逆 / 成本较高,或是否会扩散成后续任务先例?任一命中即升级为关键设计决策。
|
|
64
|
+
- **小影响豁免**:若它只是局部、可逆、低成本的执行细节,写入 `## 假设` 即可,不升级为人工裁决。
|
|
65
|
+
- **兜底**:无法判断是否关键时按关键处理;`review-*` 需要复核执行方是否漏标应升级的 `[needs-human-decision]`。
|
|
66
|
+
|
|
44
67
|
## 人工审查检查点语义
|
|
45
68
|
|
|
46
69
|
「强制性人工审查检查点」(mandatory human review checkpoint)的语义是:
|
|
@@ -32,7 +32,11 @@ Aggregation rules:
|
|
|
32
32
|
- build the review-history table from `review-code*` and `code*`
|
|
33
33
|
- extract the test summary from `code*`
|
|
34
34
|
- if one artifact class is missing, treat it as "no data for this stage" and continue
|
|
35
|
-
- Manual verification section:
|
|
35
|
+
- Manual verification section: include only post-code-stage checks that still require a human to execute or judge and that the AI cannot close on its own.
|
|
36
|
+
- **Admission boundary**: the verification result depends on a real environment, permissions, account, external system, or human judgment, and cannot be closed by an agent rerunning tests, adding checks, or continuing the fix loop.
|
|
37
|
+
- **Sources**: `review-code*` "Environment-Blocked Findings", plus `code*` items that satisfy the boundary above.
|
|
38
|
+
- **Wording**: each retained item must state at least "what to verify + location (file/change/scope) + why only a human can verify it".
|
|
39
|
+
- **Empty rendering**: when there are no retained items, do NOT use the ⚠️ alarm style (it falsely implies a problem). Render the whole block as: heading `### ✅ No Manual Verification Needed` and a single line `No items in this change require manual confirmation.`, with no item list. Only use the `### ⚠️ Manual Verification Required` heading + item list when retained items exist.
|
|
36
40
|
|
|
37
41
|
## Comment Body Template
|
|
38
42
|
|
|
@@ -47,11 +51,7 @@ Use this canonical comment body template:
|
|
|
47
51
|
|
|
48
52
|
**Updated At**: {current-time}
|
|
49
53
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
> Items in this change that need human confirmation/fallback; reviewers can reply under this comment once verified.
|
|
53
|
-
|
|
54
|
-
- {manual-verify-item}
|
|
54
|
+
{manual-verify-section}
|
|
55
55
|
|
|
56
56
|
### Key Technical Decisions
|
|
57
57
|
|
|
@@ -72,6 +72,8 @@ Use this canonical comment body template:
|
|
|
72
72
|
*Generated by {agent} · Internal tracking: {task-id}*
|
|
73
73
|
```
|
|
74
74
|
|
|
75
|
+
> Render `{manual-verify-section}` per the "manual verification section" aggregation rule above: with retained items → `### ⚠️ Manual Verification Required` heading + quote + item list; with none → `### ✅ No Manual Verification Needed` heading + a single line `No items in this change require manual confirmation.` (no ⚠️, no list).
|
|
76
|
+
|
|
75
77
|
## Comment Lookup And Update
|
|
76
78
|
|
|
77
79
|
Fetch existing comments through the Issues comments API, not the dedicated PR comments API.
|
|
@@ -32,7 +32,11 @@
|
|
|
32
32
|
- 用 `review-code*` 与 `code*` 构建审查历程表
|
|
33
33
|
- 从 `code*` 提取测试结果摘要
|
|
34
34
|
- 某一类产物缺失时,按“无该阶段数据”处理并继续生成
|
|
35
|
-
-
|
|
35
|
+
- 需人工校验段落:只收进入 code 阶段后仍需人实际执行或判断、AI 无法自行关闭的校验点。
|
|
36
|
+
- **准入边界**:校验结论依赖真实环境、权限、账号、外部系统或人工判断,且无法通过 agent 重跑测试、补充检查或继续修复自行关闭。
|
|
37
|
+
- **来源**:`review-code*` 的「环境性遗留」,以及 `code*` 中满足上述边界的校验点。
|
|
38
|
+
- **写法**:每条保留项至少写明「校验什么 + 定位(文件/改动/范围)+ 为什么只能由人校验」。
|
|
39
|
+
- **空集渲染**:无保留项时,不要使用 ⚠️ 告警样式(会让人误以为有问题)。整段降级渲染为:标题 `### ✅ 无需人工校验`,正文一行 `本次改动无需人工确认事项。`,不带条目列表。有保留项时才用 `### ⚠️ 需人工校验` 标题 + 条目列表。
|
|
36
40
|
|
|
37
41
|
## 评论体模板
|
|
38
42
|
|
|
@@ -47,11 +51,7 @@
|
|
|
47
51
|
|
|
48
52
|
**更新时间**:{当前时间}
|
|
49
53
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
> 本次改动中需人工确认/兜底的事项;reviewer 校验后可在本评论下回复收尾。
|
|
53
|
-
|
|
54
|
-
- {manual-verify-item}
|
|
54
|
+
{manual-verify-section}
|
|
55
55
|
|
|
56
56
|
### 关键技术决策
|
|
57
57
|
|
|
@@ -72,6 +72,8 @@
|
|
|
72
72
|
*由 {agent} 自动生成 · 内部追踪:{task-id}*
|
|
73
73
|
```
|
|
74
74
|
|
|
75
|
+
> `{manual-verify-section}` 按上文「需人工校验段落」聚合规则渲染:有保留项 → `### ⚠️ 需人工校验` 标题 + 引用说明 + 条目列表;无保留项 → `### ✅ 无需人工校验` 标题 + 一行 `本次改动无需人工确认事项。`(不带 ⚠️、不带列表)。
|
|
76
|
+
|
|
75
77
|
## 评论查找与更新
|
|
76
78
|
|
|
77
79
|
已有评论必须通过 Issues comments API 获取,而不是单独的 PR comments API。
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# Bidirectional Review Handshake Protocol
|
|
2
|
+
|
|
3
|
+
> Shared by executor and reviewer across all three stages (analysis / plan / code) when running the `review-*` and `*-task` skills.
|
|
4
|
+
> This file is the **single source of truth** for the protocol; each SKILL only `Read`s it and never re-copies the vocabulary.
|
|
5
|
+
|
|
6
|
+
## Core principles
|
|
7
|
+
|
|
8
|
+
- **A review finding is input to be verified, not a command to execute.** The executor must verify each finding before disposing of it — neither rubber-stamping nor blindly refuting.
|
|
9
|
+
- **Symmetric evidence burden**: every disposition, whether accept or refute, must carry **commensurate evidence**. "Accept" is not a zero-cost default path.
|
|
10
|
+
- **Converge before advancing**: while any unclosed disagreement, alternative fix, cannot-judge, or post-review commit exists, do not silently advance to the next stage, archive, or merge.
|
|
11
|
+
|
|
12
|
+
## Executor four-state disposition (`*-task` skills, when responding to the prior review round in Round ≥ 2)
|
|
13
|
+
|
|
14
|
+
For each finding in the latest `review-*`, first Read/Grep the cited `file:line` / command, then assign one status:
|
|
15
|
+
|
|
16
|
+
| Status | Meaning | Required evidence |
|
|
17
|
+
|--------|---------|-------------------|
|
|
18
|
+
| `accepted` | Valid; will fix as suggested | `file:line` of the fix, or the change to be applied this round |
|
|
19
|
+
| `adjusted` | Valid, but an alternative fix is used | the alternative + why it is better; awaits reviewer confirmation |
|
|
20
|
+
| `refuted` | After verification, judged invalid / hallucinated / based on a wrong `file:line` | counter-evidence (`file:line` or raw command output); awaits reviewer confirmation |
|
|
21
|
+
| `cannot-judge` | Insufficient evidence to decide | the verification path attempted; handed to reviewer/human |
|
|
22
|
+
|
|
23
|
+
## Reviewer hand-back duty (`review-*` skills, when re-reviewing the executor response)
|
|
24
|
+
|
|
25
|
+
After the executor gives `adjusted` / `refuted` / `cannot-judge`, the reviewer must respond per item — never re-reading the original finding nor ignoring the hand-back:
|
|
26
|
+
|
|
27
|
+
- **Withdraw the finding** → set the ledger row to `confirmed` (accepts the refutation).
|
|
28
|
+
- **Accept the alternative fix** → set to `confirmed`.
|
|
29
|
+
- **Hold with new evidence** → set back to `open` (with new evidence, returned to the executor).
|
|
30
|
+
- **Escalate to human** → set to `needs-human-decision`.
|
|
31
|
+
|
|
32
|
+
## Convergence termination (loop guard)
|
|
33
|
+
|
|
34
|
+
- The per-finding handshake round limit is `MAX_HANDSHAKE_ROUNDS`, default **3**, overridable via `review.maxHandshakeRounds` in `.agents/.airc.json`.
|
|
35
|
+
- When a finding's `round` reaches the limit without entering a terminal state, it must be forced to `needs-human-decision`; the gate rejects rows that hit the limit without escalating.
|
|
36
|
+
- `needs-human-decision` keeps blocking completion until a human records a ruling in the task.md `## 人工裁决` section and flips the row to `human-decided`.
|
|
37
|
+
|
|
38
|
+
## Same-model convergence-bias mitigation (documentation-level discipline)
|
|
39
|
+
|
|
40
|
+
The executor and reviewer are often the same/similar model and are naturally inclined to agree. When reviewing:
|
|
41
|
+
|
|
42
|
+
1. **Read the evidence before the conclusion**: read the `git diff` / artifact itself and form findings independently **before** reading the executor's conclusions and responses, to avoid being anchored.
|
|
43
|
+
2. **Default-skeptical framing**: treat "looks fine" as unverified; every clearance needs reproducible evidence (see the `Evidence` hard gate in each `review-*`).
|
|
44
|
+
|
|
45
|
+
> The only mechanical lever is the **symmetric-evidence gate** (non-`open` ledger rows must carry evidence); model homogeneity itself is not mechanically checkable, so this section is discipline rather than a gate.
|
|
46
|
+
|
|
47
|
+
## Mechanical ledger (task.md `## 审查分歧账本`)
|
|
48
|
+
|
|
49
|
+
The single source of truth for disagreement state is the fixed `## 审查分歧账本` section in task.md — one parseable Markdown table. The phase-advance and `complete-task` gates read this section.
|
|
50
|
+
|
|
51
|
+
```markdown
|
|
52
|
+
## 审查分歧账本
|
|
53
|
+
|
|
54
|
+
<!-- One row per review finding; state machine / evidence rules in .agents/rules/review-handshake.md. The phase-advance and complete-task gates read this section. -->
|
|
55
|
+
|
|
56
|
+
| id | stage | round | severity | status | evidence |
|
|
57
|
+
|----|-------|-------|----------|--------|----------|
|
|
58
|
+
| CD-1 | code | 1 | blocker | open | review-code.md#1 |
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
- `id`: stage prefix + ordinal — analysis→`AN-`, plan→`PL-`, code→`CD-`; executor-raised human-ruling rows use `HD-`.
|
|
62
|
+
- `stage` ∈ `{analysis, plan, code}` (plus the reserved value `post-review-commit`, used only for post-review exemption rows).
|
|
63
|
+
- `status` legal enum: `open` / `accepted` / `adjusted` / `refuted` / `cannot-judge` / `confirmed` / `needs-human-decision` / `closed` / `human-decided`.
|
|
64
|
+
- **Terminal set (gate passes)**: `{confirmed, closed, human-decided}`; everything else is blocking.
|
|
65
|
+
- **Write responsibility**: `review-*` raises a finding → upsert an `open` row; `*-task` responds → set four-state and fill `evidence`, `round` +1; next `review-*` → `confirmed` / back to `open` / `needs-human-decision`; an executor fix verified by the next review → `closed`; a human ruling → `human-decided`.
|
|
66
|
+
- **Backward compatible**: when task.md has no such section the gate treats it as no open disagreements and passes.
|
|
67
|
+
|
|
68
|
+
### Executor-raised human-ruling rows
|
|
69
|
+
|
|
70
|
+
When an executor marks an item in the artifact `## Open Questions` section as `[needs-human-decision]`, it must upsert the matching `HD-` row in task.md `## Review Disagreement Ledger`:
|
|
71
|
+
|
|
72
|
+
```markdown
|
|
73
|
+
| HD-1 | plan | - | decision | needs-human-decision | plan.md#HD-1 |
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
- `stage` is the stage where the decision arose: `analysis` / `plan` / `code`.
|
|
77
|
+
- `round` is `-` because this is not a review-finding handshake round.
|
|
78
|
+
- `severity` is always `decision`.
|
|
79
|
+
- `status` starts as `needs-human-decision`, so the existing gate blocks it.
|
|
80
|
+
- After a human records the ruling in task.md `## Human Rulings`, flip the matching `HD-` row to `human-decided` and point `evidence` to that ruling.
|
|
81
|
+
|
|
82
|
+
## post-review commit gate (code stage only)
|
|
83
|
+
|
|
84
|
+
- The highest-round `review-code` report records `Review Baseline Commit` (R, `git rev-parse HEAD`) and `Reviewed Diff Fingerprint` (F, full worktree diff fingerprint).
|
|
85
|
+
- `commit` reads only the highest-round `review-code` artifact. When that artifact is Approved, the pre-commit HEAD equals R, and the staged diff fingerprint equals F, task.md receives `last_reviewed_commit` (B, the new commit SHA).
|
|
86
|
+
- The `complete-task` `post-review-commit` gate prefers B; when B is absent or invalid, it falls back to R from the highest-round `review-code` artifact.
|
|
87
|
+
- If new commits touch code / rule paths after B / R, the gate blocks and requires a fresh `review-code`.
|
|
88
|
+
- **Exemption**: append a ledger row `| PRC-1 | post-review-commit | - | - | human-decided | <ruling note> |` recording that a human explicitly allowed those commits without re-review.
|
|
89
|
+
|
|
90
|
+
## Gate behavior cheat sheet
|
|
91
|
+
|
|
92
|
+
| Caller | `review-ledger` scope | `post-review-commit` |
|
|
93
|
+
|--------|-----------------------|----------------------|
|
|
94
|
+
| `plan-task` | only `analysis`-stage rows must be terminal | not attached |
|
|
95
|
+
| `code-task` | `analysis` + `plan`-stage rows must be terminal | not attached |
|
|
96
|
+
| `complete-task` | all stage rows must be terminal | attached (see above) |
|
|
97
|
+
| `analyze-task` | not attached (first stage) | not attached |
|