@morning-start/dsh-code-toolkit 0.28.1 → 0.31.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/CHANGELOG.md +148 -0
- package/README.md +110 -2
- package/agents/caption/AGENT.md +86 -76
- package/agents/caption/references/dispatch.md +103 -93
- package/agents/caption/references/evidence.md +48 -64
- package/agents/caption/references/experts.md +51 -78
- package/agents/caption/references/flows.md +51 -53
- package/agents/caption/references/loop.md +114 -93
- package/agents/design/AGENT.md +2 -1
- package/agents/merge/AGENT.md +79 -0
- package/agents/merge/examples/bad.md +40 -0
- package/agents/merge/examples/good.md +52 -0
- package/agents/merge/references/method.md +71 -0
- package/agents/merge/references/verdicts.md +57 -0
- package/agents/review/AGENT.md +5 -2
- package/agents/scrub/AGENT.md +5 -3
- package/agents/simplify/AGENT.md +11 -7
- package/index.js +76 -2
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +1 -1
- package/src/caption.js +18 -3
- package/src/command.js +72 -1
- package/src/i18n.js +16 -0
- package/src/merge.js +150 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,153 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.31.0 — 2026-12-04
|
|
4
|
+
|
|
5
|
+
- **`/code-merge`: analyse a multi-person merge from its fork point.** Comparing two branches
|
|
6
|
+
answers the wrong question — it lists every difference, and most of them are not conflicts. The
|
|
7
|
+
command computes the merge base, then each side's changes *against that base*, then intersects
|
|
8
|
+
the two file sets: only the shared files can conflict. For each of them `src/merge.js` reads
|
|
9
|
+
`-U0` hunks, which are in base coordinates, and classifies the pair as same lines, contexts
|
|
10
|
+
overlapping (within six lines — still a conflict), or separate regions. The persona's whole job
|
|
11
|
+
is intent: what each side was doing, read from the commits *and* the patches, and one decision
|
|
12
|
+
per shared file that names both intents. The report ends with what the merge cannot settle —
|
|
13
|
+
DDL, views, docs, API contracts — which is where the session that inspired this command went
|
|
14
|
+
wrong: the code merged cleanly and the columns were still wrong two days later.
|
|
15
|
+
- **Read-only, like the audit.** No apply path: a merge resolved by a model before a person reads
|
|
16
|
+
the plan is the failure this command exists to prevent. Eight commands now; 147 checks.
|
|
17
|
+
|
|
18
|
+
## 0.30.1 — 2026-12-04
|
|
19
|
+
|
|
20
|
+
`0.30.0` was cut but never tagged; the caption goal fix below rides with it, so the line ships as
|
|
21
|
+
a patch.
|
|
22
|
+
|
|
23
|
+
- **A caption run now opens its own goal, and the plugin does it — the model cannot.** The goal
|
|
24
|
+
tools in `@deepseek-ai/dsh-tool-goal` require an open `user/message` whose `source.kind` is
|
|
25
|
+
`user`, and refuse any agent whose `origin` is `subagent`; a plugin-delivered message satisfies
|
|
26
|
+
neither, so no amount of persona wording could ever make `/code-caption` open a goal (four live
|
|
27
|
+
runs confirmed the refusal, including from delegated children). The **service** has no such gate,
|
|
28
|
+
so `inject()` now creates the goal through `ctx.goals.create` on the authority of the command the
|
|
29
|
+
person just ran: objective = their task line, `maxGoalRounds` from the new `goalRounds` config
|
|
30
|
+
(default 8, `0` disables), an existing goal continued rather than replaced, and a silent fallback
|
|
31
|
+
on a host without the service. Verified in a headless sandbox through `ctx.commands.execute`:
|
|
32
|
+
the session log shows `command/run` → `goal/change {operation: create, phase: active}` →
|
|
33
|
+
`command/done`. The wording then had to change too — the protocol no longer tells the model to
|
|
34
|
+
`create_goal` (that now collides with the existing goal), but to `get_goal`, work under it, and
|
|
35
|
+
close it with `update_goal complete`. See `evals/results/iteration-15.md`.
|
|
36
|
+
- **An injected run's decision rules now live in a system section, not only in the message.** The
|
|
37
|
+
persona was delivered to the current session as one steered user message (`src/command.js`),
|
|
38
|
+
while an isolated child gets a system-prompt section (`src/runtime.js`) — the same protocol at
|
|
39
|
+
two very different strengths. In a long session the message competes with everything else, and
|
|
40
|
+
a compaction can summarize it away; the second run of a command injects only a one-line "the
|
|
41
|
+
protocol is already installed", so the rules survive on nothing. `inject()` now also installs a
|
|
42
|
+
`CODE_TOOLKIT_PROTOCOL` section carrying the two decisions a run makes about itself — when the
|
|
43
|
+
plan warrants a goal, and when the ready items warrant a wave — replacing its own section on a
|
|
44
|
+
later run instead of stacking copies, and falling back silently on a host without the service.
|
|
45
|
+
The receipt ends with a suffix when the section was installed, so the person can see which
|
|
46
|
+
carrier their session actually got. This is the likely reason a live run dispatched two
|
|
47
|
+
children while a real session never opened a goal.
|
|
48
|
+
- **The two autonomy triggers are shape predicates now, and a live run confirmed the dispatch
|
|
49
|
+
one.** "Open a goal when the person asked the work to run to completion" waited for a phrase a
|
|
50
|
+
plain task never contains; "dispatch when the briefs cost less than the work" was an estimate
|
|
51
|
+
that always came out negative. Both now read the plan: **three or more items, or criteria no
|
|
52
|
+
single iteration can prove**, opens a goal; **two or more ready items with disjoint paths, a
|
|
53
|
+
gate each and more than a one-line edit** is a wave. In run 4 — same fixture shape, nothing in
|
|
54
|
+
the prompt about agents or goals — caption dispatched two children in one message, wrote both
|
|
55
|
+
rows and owners before the first call, collected with `wait_agent`, and re-ran the merged gate
|
|
56
|
+
itself (10/10). `list_agents` still lists both grandchildren, so the split is verified by the
|
|
57
|
+
tree rather than by the report. It also decided on its own that a goal was warranted and called
|
|
58
|
+
`create_goal` — refused, because a delegated child cannot hold one. Both children then corrected
|
|
59
|
+
the parent's brief (a guessed test count, and a git ban it applied to itself but never passed
|
|
60
|
+
down), which are now two brief rules in `references/dispatch.md`.
|
|
61
|
+
- **The caption protocol was run for real, three times, on fixtures that genuinely fail.** A
|
|
62
|
+
delegated child with an empty context, given only the persona and a task, produced ledgers with
|
|
63
|
+
plans, dependencies, dispatch tables and entries carrying exit codes; it proved its guards by
|
|
64
|
+
breaking them; it wrote probe scripts to check documentation claims and deleted them after. Two
|
|
65
|
+
runs correctly *declined* to dispatch (both slices behind one gate), and the third dispatched two
|
|
66
|
+
children in one message, recorded both rows and owners **before** the first `subagent` call,
|
|
67
|
+
collected with `wait_agent`, and re-ran the merged gate itself. `list_agents` afterwards still
|
|
68
|
+
showed both grandchildren, so the dispatch is verified by the tree rather than by the report.
|
|
69
|
+
**`create_goal` is structurally unavailable to a delegated child** — three attempts, one error:
|
|
70
|
+
`this goal operation requires a direct human turn on a top-level agent` — which means the goal
|
|
71
|
+
tier only exists in-session, and that half of the protocol remains unmeasured. See
|
|
72
|
+
`evals/results/iteration-13.md`.
|
|
73
|
+
- **`docs/tooling-map.md`: every module against the host's own services and tools.** The scan
|
|
74
|
+
found one class of mistake repeated across personas — a mechanism described in our words when
|
|
75
|
+
the host has a tool — and one class of mistake waiting to happen: telling a persona to spawn a
|
|
76
|
+
child the plugin already spawned. `design` now asks its three questions with
|
|
77
|
+
`ask_user_question` instead of prose, `simplify` and `scrub` mirror their item lists into
|
|
78
|
+
`todo_write`, and the caption approval gate is named as a three-option question. Five
|
|
79
|
+
candidates were considered and refused with reasons (`ctx.approval` is a permission policy, not
|
|
80
|
+
a design decision; `ctx.workspaceChanges` records turn diffs, not branch scopes;
|
|
81
|
+
`ctx.actionCards` is a UI projection; `ctx.agentTeams` is a board for the Lead session;
|
|
82
|
+
`ctx.workflowEngine` is the engine under `workflow`, not a protocol). A test now fails if any
|
|
83
|
+
of `review` / `simplify` / `scrub` starts naming `subagent`.
|
|
84
|
+
- **The caption reference pages are 18% smaller and one of them was broken.** `dispatch.md`
|
|
85
|
+
merged its two overlapping "when not to parallelize" lists into one and moved the child-failure
|
|
86
|
+
rules next to the wave they belong to; `loop.md` dropped the section that restated the plan
|
|
87
|
+
format; `experts.md` merged sizing into its rules. Two real defects fell out of the pass:
|
|
88
|
+
`flows.md` had a paragraph inserted **inside** Flow A's table, splitting it into two, and
|
|
89
|
+
`experts.md` had lost its lifecycle heading to an earlier merge. 37 520 → 30 693 characters.
|
|
90
|
+
- **Every mechanism that the host already provides now uses the host's tool.** The sweep
|
|
91
|
+
found three of ours standing in for one of theirs: the clarification questions now go
|
|
92
|
+
through `ask_user_question`, `workflow` is documented as the official orchestrator with its
|
|
93
|
+
bar (explicit request, or a wave big enough that hand-dispatch stops paying), and the
|
|
94
|
+
unattended case is no longer a rule of ours — `schedule_create` is the official mechanism,
|
|
95
|
+
and it is bounded by what the installed `docs/user/guide/schedule.md` promises: a delivery
|
|
96
|
+
proves the message reached the inbox, **not that the model did the work**; exactly-once is
|
|
97
|
+
not guaranteed; closing the Host discards a message still waiting; a child is refused by
|
|
98
|
+
the schedule tools. So a run is scheduled only when the person asks, and carries a stop
|
|
99
|
+
condition. The ledger stays ours because the host has no cross-session plan store —
|
|
100
|
+
`todo_write` dies with the session and a resumed goal comes back disarmed.
|
|
101
|
+
- **The caption plan is a dependency graph, not a flat list.** Items take `| deps: 2,3` and
|
|
102
|
+
`| owner: <child>`; `src/caption.js` parses both and derives `ready` (deps all done, no
|
|
103
|
+
owner) and `inFlight` (open with an owner), so "what is next" is computed instead of felt.
|
|
104
|
+
`list` and `/code-status` show it: `计划 2/5 · 1 项在飞`.
|
|
105
|
+
- **Dispatch is recorded, and runs in waves.** The ledger gains a `## Dispatch` table
|
|
106
|
+
(child / lane / paths / gate / state / entry) that only the root writes. A wave is the
|
|
107
|
+
ready items with disjoint write sets, capped at three children, each required to answer in
|
|
108
|
+
at most twenty lines. Dispatch, do your own item, collect with `wait_agent`, then run the
|
|
109
|
+
whole gate on the merged tree yourself — a child's green is not the merged tree's green.
|
|
110
|
+
Children still cannot fan out (the plugin already denies delegation tools); a slice that
|
|
111
|
+
needs sub-slices is two waves.
|
|
112
|
+
- **A long run continues in two states, not three.** Same session: the goal keeps running.
|
|
113
|
+
Resumed session: the goal comes back disarmed, so `update_goal resume` and then read the
|
|
114
|
+
ledger before touching an item. Unattended: **not part of this protocol** — the loop never
|
|
115
|
+
schedules its own continuation, because a scheduled prompt arrives as a message from a
|
|
116
|
+
person who is not watching. The ledger is what survives the session; the clock is theirs.
|
|
117
|
+
- 134 → 136 deterministic checks.
|
|
118
|
+
|
|
119
|
+
## 0.29.0 — 2026-11-29
|
|
120
|
+
|
|
121
|
+
- **"Propose, then act" is now the shared spine of every command that changes files.**
|
|
122
|
+
Review writes a finding before fixing it, simplify writes the plan (what it is now, what
|
|
123
|
+
it becomes, why behaviour is unchanged) before the first edit, scrub writes the dry-run
|
|
124
|
+
JSON and the redaction list before touching a file, caption writes the proposal before
|
|
125
|
+
opening a goal. The two steps may share one run, but the order cannot swap and the plan
|
|
126
|
+
must be on disk, not in the model's head. Read-only commands stop at the proposal. The
|
|
127
|
+
rule is a project constraint (`AGENTS.md` #11) with a test behind it, and a table in the
|
|
128
|
+
README saying which artifact is each command's plan.
|
|
129
|
+
- **The caption loop is now six stages, each with a refusal.** 方案 → goal → small tasks →
|
|
130
|
+
one item at a time → incremental task updates → until the goal is met. The first stage is
|
|
131
|
+
the new part: when the intent is too vague to propose an approach, caption stops and
|
|
132
|
+
either asks the two or three questions that would settle it or names the command that
|
|
133
|
+
answers it first (`/code-design` when the need is still a need, `/code-audit` when the
|
|
134
|
+
question is what exists today) — and says which approach it would take. **A ledger is
|
|
135
|
+
never opened for a task that cannot be stated**: a ledger for a wish produces entries
|
|
136
|
+
that record activity instead of progress. This closes the loop with `/code-design`, whose
|
|
137
|
+
last line already hands approved plans to `/code-caption`.
|
|
138
|
+
- **`/code-caption` now opens a DSH goal, and mirrors its plan into the task list.** The
|
|
139
|
+
intent-to-plan work was already in the ledger, but nothing ever told it to use the
|
|
140
|
+
host's continuation mechanism: `git log -S'create_goal'` returns nothing for the
|
|
141
|
+
repository's whole history, and the plugin's only tool restriction (`src/runtime.js`, a
|
|
142
|
+
deny list of delegation tools) never touched it. A run for "finish this" now opens a goal
|
|
143
|
+
once the plan is approved, closes it with `update_goal complete` when the plan is empty
|
|
144
|
+
and the criteria hold, and reports `blocked` with a concrete reason instead of quietly
|
|
145
|
+
stopping. `todo_write` mirrors the ledger's `## Plan` for the person watching; the ledger
|
|
146
|
+
stays authoritative, because the todo list dies with the session and the ledger does not.
|
|
147
|
+
`update_goal` needs `goal_id` and `revision`, so the loop reads `get_goal` first — the
|
|
148
|
+
detail lives in `agents/caption/references/loop.md`. Persona text, **not measured**
|
|
149
|
+
(see `evals/results/iteration-10.md`); the persona moved 7 652 → 8 433 characters.
|
|
150
|
+
|
|
3
151
|
## 0.28.1 — 2026-11-29
|
|
4
152
|
|
|
5
153
|
- **Menu labels and hints were cut to a scan length.** Every `description` had grown
|
package/README.md
CHANGED
|
@@ -43,7 +43,8 @@ DeepSeek Harness 的代码工具箱:**审查**、**精炼**、**隐私清理**
|
|
|
43
43
|
| `/code-simplify` | 一次改造:功能不变的前提下简化 | 一次性 | `report` 出方案 → 人看过 → 再跑一次执行 | 是,默认写 |
|
|
44
44
|
| `/code-scrub` | 一次清理:找出并移除隐私信息 | 一次性 | 同上,报告默认脱敏 | 是,默认写 |
|
|
45
45
|
| `/code-audit` | 一次判断:现有能力是「通」还是「看起来有」 | 一次性,只读 | 单段:五态表 + `file:line`,没有 apply 路径 | **否** |
|
|
46
|
-
| `/code-
|
|
46
|
+
| `/code-merge` | 一次判断:这次合并到底要不要人来定,定哪几处 | 一次性,只读 | 分叉点基线 → 两侧意图 → 共享文件的 base 行号求交 → 方案;没有 apply 路径 | **否** |
|
|
47
|
+
| `/code-caption` | 复杂任务:跨轮、要验证、要台账 | **持续**,多轮多步 | 完整契约:方案 → **人批** → goal → 拆小任务 → 逐项推进 → 渐进更新 → 到完成 | 是,按方案 |
|
|
47
48
|
| `/code-design` | 一次设计:把「缺什么」压成带证据的场景与批次 | **持续**,多轮,随人回答推进 | 四张底图 → 场景 → 排序 → 批次表 → **人批**;止于方案 | 只写 `docs/design/`,不写代码 |
|
|
48
49
|
| `/pua` | 一次注入:给当前会话装纪律 | 一次性,注入即结束 | 无审核环节——它不做事,只改做事的方式 | 否 |
|
|
49
50
|
| `/code-status` | 查询:干到哪了 | 只读 | 无 | 否 |
|
|
@@ -51,6 +52,21 @@ DeepSeek Harness 的代码工具箱:**审查**、**精炼**、**隐私清理**
|
|
|
51
52
|
|
|
52
53
|
**只有 caption 需要完整契约**,因为它是唯一要连续跑门禁、唯一有「方案被推翻要回头改」的命令。design 也跨轮,但它跨轮是为了跟人把方案谈清楚:**它止于方案**,批准之后交给 caption 执行——所以设计命令没有台账,也没有门禁。其余命令是一次单独的行动——它们的「审核」要么压缩成一个开关(`report`),要么根本不存在。
|
|
53
54
|
|
|
55
|
+
### 共同骨架:方案 → 动手
|
|
56
|
+
|
|
57
|
+
**所有会改文件的命令都是同一个形状,只是粒度不同**:先把要改的写成方案(改什么、改哪、为什么、怎么证明),再动手。顺序不能颠倒,方案必须落盘。
|
|
58
|
+
|
|
59
|
+
| 命令 | 它的「方案」是 | 什么时候动手 |
|
|
60
|
+
| --- | --- | --- |
|
|
61
|
+
| `/code-review` | findings:每条带 `path:line` 和证据 | 同一轮接着修;`report` 就停在方案 |
|
|
62
|
+
| `/code-simplify` | plan:每处 `now → change to` + 行为不变的论证 | 方案写完、门禁定好之后;`report` 停在方案 |
|
|
63
|
+
| `/code-scrub` | 脱敏清单 + 干跑 JSON,值已打码 | 同上 |
|
|
64
|
+
| `/code-caption` | 方案 → goal → 任务清单 | 你批了之后,逐项推进 |
|
|
65
|
+
|
|
66
|
+
只读的两条止于方案:`/code-audit` 的产物就是报告,`/code-design` 的产物就是方案(执行交出去)。`status` / `cancel` 没有方案。
|
|
67
|
+
|
|
68
|
+
这条规则在 `AGENTS.md` 的硬约束里,也有测试守着——「方案先落盘、再动手」不是建议。
|
|
69
|
+
|
|
54
70
|
## 一个外壳,所有命令
|
|
55
71
|
|
|
56
72
|
命令的行为不是各写一遍:九条命令全部由同一个 `SessionCommand` 类实现([src/command.js](src/command.js))。每条命令只提供一份声明:
|
|
@@ -68,6 +84,17 @@ DeepSeek Harness 的代码工具箱:**审查**、**精炼**、**隐私清理**
|
|
|
68
84
|
|
|
69
85
|
统一的好处是行为一致:都立刻返回、都先定范围、失败都发一条说明、都写 journal;差异只留在声明里,不再散落在每个 handler 中。测试会检查 `index.js` 里没有直接 `ctx.commands.register`——绕开外壳就等于又写了一遍。
|
|
70
86
|
|
|
87
|
+
## 和宿主的分工
|
|
88
|
+
|
|
89
|
+
这个插件不重造宿主已经有的东西。两类替代,不能混:
|
|
90
|
+
|
|
91
|
+
- **(S)服务**:插件代码做的事,宿主有服务 → 直接调。命令注册 `ctx.commands`、隔离运行 `ctx.subagents`、persona 注入 `ctx.systemPrompt`、子 agent 工具限制 `ctx.tools.restrict`、语言 `settings`。
|
|
92
|
+
- **(T)工具**:模型做的事,宿主有工具 → persona 里只写工具名,不写怎么做。续跑用 `create_goal`、进度用 `todo_write`、派工用 `subagent` / `wait_agent`、提问用 `ask_user_question`、大规模编排用 `workflow`、无人值守用 `schedule_create`。
|
|
93
|
+
|
|
94
|
+
一条容易搞反的推论:**插件已经派出去的孩子,不能再被告知去派**。`review sub` / `simplify sub` / `scrub sub` 是 `src/runtime.js` 派的,它们的 persona 里不能出现 `subagent`,否则孩子会在刚建好的隔离里再扇出。只有跑在你自己会话里的 `/code-caption` 才派工。
|
|
95
|
+
|
|
96
|
+
每个功能模块对着哪个宿主机制、哪些候选被否掉(以及为什么),在 [docs/tooling-map.md](docs/tooling-map.md)。
|
|
97
|
+
|
|
71
98
|
## 提示词不是两个文件
|
|
72
99
|
|
|
73
100
|
`agents/` 按 skill 的三层结构组织,而不是把全部规则塞进一个 prompt:
|
|
@@ -151,7 +178,16 @@ agents/pua/
|
|
|
151
178
|
|
|
152
179
|
`/code-caption <任务>` 是这套东西里唯一不 spawn 的命令,因为它的对象不是一次检查,而是**一次长任务的进行方式**。
|
|
153
180
|
|
|
154
|
-
|
|
181
|
+
它注入的不是一张清单,而是六个阶段,**每个阶段都带一个「不该硬推」时的出口**:
|
|
182
|
+
|
|
183
|
+
1. **方案** — 改什么、改哪、为什么这样改、不做什么。方案说不清就停:问两三个能定的问题,或者指出该先用哪条命令——需求本身还没定 → `/code-design`;问「现在到底有什么」→ `/code-audit`——并说明你会怎么走。**说不清的任务不写台账。**
|
|
184
|
+
2. **设 goal** — 一句目标 + 判据;你要求「跑到完成」时用 `create_goal` 开目标。
|
|
185
|
+
3. **拆小任务** — 按结果切、每项自带检查;写进台账 `## Plan`,`todo_write` 同步给人看。
|
|
186
|
+
4. **逐步推进** — 一次一项:读台账 → 看真实状态 → 动手(锚点唯一、改完读回)→ 跑门禁 → 给新守卫做反证 → 记一条并提交。
|
|
187
|
+
5. **渐进更新** — 勾掉、重写 todo、证据推翻计划时原地改计划并写明是第几条改的。
|
|
188
|
+
6. **直到完成** — 计划无未完成项且判据成立才收口,`update_goal complete`;卡住就 `blocked`,写清阻因。
|
|
189
|
+
|
|
190
|
+
循环的产物是 `docs/caption/<slug>.md`:头部写目标、判据、门禁和**计划清单**,清单在头部原地改;每条写看到什么、判断什么、做了什么、命令与结果、结论(done / dead end / unverified)。
|
|
155
191
|
|
|
156
192
|
三条规则是它的全部价值:**没有证据就不许声称**、**死路要留痕**、**判据满足才收口,清单空了不算**。另外两条补在同一节:**门禁绿不等于功能在**(碰了入口的改动,必须有一次走到真实入口、真数据、看结果);**关于宿主和第三方的判断先写探针**,「文档说支持」不算证据,探针没跑就进未验证清单。细节在 `agents/caption/references/`,一次健康的运行与一次"忙碌但什么都没证明"的运行在 `examples/` 里对照。
|
|
157
193
|
|
|
@@ -178,8 +214,64 @@ caption 不是「你给任务,它照着做」。你给的是一句**意图**
|
|
|
178
214
|
|
|
179
215
|
`[ ]` 未做、`[x]` 完成、`[~]` 受阻、`[-]` 放弃。**原地改**,绝不追加第二份计划——计划是当前状态,条目是历史。勾掉时把条目号写在旁边,后来的人不用翻。没有 gate 的那一行不是计划项,是备注。
|
|
180
216
|
|
|
217
|
+
### 三层:goal / 台账 / todo
|
|
218
|
+
|
|
219
|
+
这三样分工不同,混起来就是三份互相打架的计划:
|
|
220
|
+
|
|
221
|
+
| 谁 | 活多久 | 回答什么 |
|
|
222
|
+
|---|---|---|
|
|
223
|
+
| `create_goal` | 本次会话的自动续轮 | 要不要不用人催,一直干到完成 |
|
|
224
|
+
| 台账 `## Plan` | 仓库里,跨会话 | 还剩哪几项,每项由什么证明 |
|
|
225
|
+
| `todo_write` | 本次会话,只给人看 | 现在在干哪一项 |
|
|
226
|
+
|
|
227
|
+
你说了「做到完成为止」,它在方案批准后建 goal;收口时 `update_goal complete`,卡住时 `blocked` 并写出具体阻因。没说「跑到底」就不建——goal 会真的让会话自动续轮,不该替你做主。`todo_write` 每轮从 Plan 重写一遍,**台账永远是对的**:todo 随会话消失,台账不会。
|
|
228
|
+
|
|
181
229
|
改计划是常态而不是失败:调查出结果后加、拆、删、重排都行,但每次都要写清是哪一条、为什么。一条**永远没被改过**的计划,说明调查没发现任何东西。
|
|
182
230
|
|
|
231
|
+
### 编排:依赖图 + 派工表
|
|
232
|
+
|
|
233
|
+
计划不是平铺清单,是**依赖图**。每项可以带两个字段,于是「下一项」是算出来的,不是感觉出来的:
|
|
234
|
+
|
|
235
|
+
```markdown
|
|
236
|
+
## Plan
|
|
237
|
+
- [x] 1. 复现失败 — gate: `node --test` 点名 `sum([])`(见条目 1)
|
|
238
|
+
- [ ] 2. 钉住契约 — gate: 新测试在旧代码上通过 | deps: 1
|
|
239
|
+
- [ ] 3. 修空输入 — gate: `sum([])` 为 0 | deps: 2
|
|
240
|
+
- [ ] 4. 修导出入口 — gate: 真实导出一次 | deps: 2 | owner: agent-import
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
`deps` 全绿且没有 `owner` 的项=**可做**;同一波里互不冲突的可做项并行。`owner` 在派出去的那一刻写上,结果记完清除——续跑的人看到它就知道该**收**,不是该**再派**。
|
|
244
|
+
|
|
245
|
+
派工本身也进台账,只有根 agent 写:
|
|
246
|
+
|
|
247
|
+
```markdown
|
|
248
|
+
## Dispatch
|
|
249
|
+
| child | lane | paths | gate | state | entry |
|
|
250
|
+
| --- | --- | --- | --- | --- | --- |
|
|
251
|
+
| agent-import | build | src/import/** | `node --test test/import` | running | — |
|
|
252
|
+
| agent-copy | analysis | src/, docs/ | — | returned | 4 |
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
四条规矩:**分析线只读可以扇出;实现线每个孩子独占一组路径**(含台账在内的共享文件只属于根);**派工→自己干一项→`wait_agent` 收齐→根在合并后的树上跑全量门禁**,孩子的绿不等于合并后的绿;**孩子不许再派**(插件已禁委派类工具)。每波最多三个孩子,每份报告不超过 20 行——上下文才是真的预算。
|
|
256
|
+
|
|
257
|
+
用的是 DSH 官方工具:`subagent` / `subagent_fork` 派,`wait_agent` 收,`list_agents` 看谁还在跑,`send_message` 纠偏。
|
|
258
|
+
|
|
259
|
+
### 官方机制优先,缺的自己补
|
|
260
|
+
|
|
261
|
+
caption 里凡是能交给宿主的,都交给宿主;只有宿主没有的才自己造:
|
|
262
|
+
|
|
263
|
+
| 能力 | 用谁的 | 说明 |
|
|
264
|
+
|---|---|---|
|
|
265
|
+
| 续跑 / 收口 / 卡住 | **官方** `create_goal` / `update_goal` | 迭代引擎是宿主的,六阶段只是每一轮的内容 |
|
|
266
|
+
| 实时进度 | **官方** `todo_write` | 台账的投影,不是第二份计划 |
|
|
267
|
+
| 派 / 收 / 看 / 纠偏 | **官方** `subagent`、`wait_agent`、`list_agents`、`send_message` | 孩子不能再派,也不能碰定时任务 |
|
|
268
|
+
| 大规模编排 | **官方** `workflow` | 只在明确要求「workflow」或波次很大时用 |
|
|
269
|
+
| 提问 | **官方** `ask_user_question` | 方案说不清时问那两三个问题 |
|
|
270
|
+
| 无人值守 | **官方** `schedule_create` | 保证弱:不保证执行、可能重复、关掉 Host 会丢,所以由人创建并带停止条件 |
|
|
271
|
+
| 计划 / 依赖 / 派工记录 | **自己的台账** | 宿主没有跨会话的计划存储,这是唯一必须自造的 |
|
|
272
|
+
|
|
273
|
+
最后一行是被动选择,不是偷懒:`todo_write` 随会话消失,goal 重开就被 disarm,只有仓库里的台账能跨会话、跨机器、进 git。
|
|
274
|
+
|
|
183
275
|
### 台账是入口
|
|
184
276
|
|
|
185
277
|
一个项目攒几份台账之后,「继续当前任务」就指不清了。所以:
|
|
@@ -238,6 +330,22 @@ caption 不是「你给任务,它照着做」。你给的是一句**意图**
|
|
|
238
330
|
|
|
239
331
|
读者看的是表,所以 [src/report.js](src/report.js) 增加了 `capabilities`:字段是 `id` / `capability` / `state` / `evidence{file,line_range}` / `path`(走的路径,停在哪) / `expected` / `actual` / `impact`(用户做不到什么) / `batch`(建议批次,让审计能直接喂给方案),渲染成一张带 `file:line` 链接的表 + 每行一段明细;没有已知状态的行走不进表,宁可丢一行也不猜。
|
|
240
332
|
|
|
333
|
+
## 合并冲突:以分叉点为基线
|
|
334
|
+
|
|
335
|
+
多人协作里最容易错的一步是**直接比两个分支**:`git diff HEAD origin/dev` 会把对方所有的改动都摆出来,看着像"他改了一大片",其实其中大半跟你无关。这个命令的做法不同,四步都固定:
|
|
336
|
+
|
|
337
|
+
1. **先找分叉点**(merge base)。没有基线就没有分析——插件替你算,不靠眼看。
|
|
338
|
+
2. **分别看两侧相对分叉点改了什么**,谁改了哪些文件、加了哪些提交。
|
|
339
|
+
3. **分别说出两侧的意图**(一串提交 + 对应补丁),按「关心的事」归簇,而不是按目录。
|
|
340
|
+
4. **只在共享文件上做判定**:两侧改的 base 行号求交——同段 → 必冲突;上下文重叠(6 行内)→ 仍会冲突;相隔很远 → git 能自动合并,但**语义上仍要确认**(他改了列名、你刚好在写这列,这就是真冲突)。
|
|
341
|
+
|
|
342
|
+
没被双方同时碰的文件**不需要任何决定**,报告里就一句「各改各的」。冲突集由插件算(`src/merge.js`,`-U0` 的 base 行号),模型只负责判意图和写方案——它不会替你决定,`/code-merge` 是只读的,方案批了才动手。
|
|
343
|
+
|
|
344
|
+
```powershell
|
|
345
|
+
/code-merge # 分析正在进行的合并(MERGE_HEAD)
|
|
346
|
+
/code-merge origin/dev # 先算它的分叉点,不启动合并
|
|
347
|
+
```
|
|
348
|
+
|
|
241
349
|
## 场景驱动的设计
|
|
242
350
|
|
|
243
351
|
`/code-design` 把「这个项目还缺什么」压成能验收的东西:**谁,在什么状态下,想完成什么,失败时看到什么**。它注入的是一套协议,不是一张表格:
|
package/agents/caption/AGENT.md
CHANGED
|
@@ -1,78 +1,88 @@
|
|
|
1
1
|
# Caption loop
|
|
2
2
|
|
|
3
|
-
You are running one long task until it is
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
iteration, and you change the list when the repository contradicts it.
|
|
3
|
+
You are running one long task until it is done. You are not handed a plan: the person gives
|
|
4
|
+
you an **intent** — "make the export work" — and you derive the goal, criteria and task list
|
|
5
|
+
from it, then work the list one item per iteration, changing it when the code contradicts it.
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
true, or reporting done while items remain open.
|
|
11
|
-
|
|
12
|
-
## From intent to a plan
|
|
13
|
-
|
|
14
|
-
Before the first working iteration, write three things into the ledger head:
|
|
15
|
-
|
|
16
|
-
- **Goal** — one sentence you can say back to the person without adding anything.
|
|
17
|
-
- **Criteria** — how someone else tells it is done: a command, an observable state, or a
|
|
18
|
-
file that must say something. "Works better" is not a criterion.
|
|
19
|
-
- **Plan** — ordered **outcomes, not activities**. Each item is one result provable on
|
|
20
|
-
its own, and each names the check that proves it. Ordering and sizing:
|
|
21
|
-
`references/loop.md`.
|
|
22
|
-
|
|
23
|
-
**The approval gate is not optional.** The person approves goal, criteria and plan
|
|
24
|
-
together — a plan nobody read is not an approval, and a plan you keep in your head is not
|
|
25
|
-
a plan. If the intent admits two materially different readings, ask before writing the
|
|
26
|
-
plan; that one question is worth interrupting for.
|
|
7
|
+
What goes wrong is not the design — it is losing the thread: working without a proof,
|
|
8
|
+
repeating a dead end, or reporting done with items still open.
|
|
27
9
|
|
|
28
10
|
## The loop
|
|
29
11
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
12
|
+
Six stages, in this order. Each has a refusal: what to do instead of pushing through.
|
|
13
|
+
|
|
14
|
+
1. **方案 — the approach.** What changes, where, why this way, what you will not do. Not a
|
|
15
|
+
task list yet. Write it so someone else could execute it without you: it goes into the
|
|
16
|
+
ledger head, and a proposal only you can read is not one. If the intent is not clear
|
|
17
|
+
enough to propose, stop: ask the two or three questions that would settle it with
|
|
18
|
+
`ask_user_question`, or name the command that answers it first — `/code-design` when the
|
|
19
|
+
need is still a need, `/code-audit` when the question is what exists today — and say
|
|
20
|
+
which approach you would take and why you cannot start. **Never write a ledger for a task you cannot state.**
|
|
21
|
+
|
|
22
|
+
**The approval gate is not optional.** The person approves the approach, the criteria
|
|
23
|
+
and the tasks together — a plan nobody read is not an approval, and a plan you keep in
|
|
24
|
+
your head is not a plan. If it admits two materially different readings, ask before
|
|
25
|
+
writing it; that one question is worth interrupting for.
|
|
26
|
+
|
|
27
|
+
2. **The goal.** The command opens one for a run that spans turns — check `get_goal` before
|
|
28
|
+
anything else. If one exists, work under it and `update_goal complete` when the criteria are
|
|
29
|
+
proven. If none does (the person disabled it, or the host lacks the service), open one yourself
|
|
30
|
+
with `create_goal` once the plan has three or more items. On resume it comes back disarmed:
|
|
31
|
+
`update_goal resume`, then read the ledger first.
|
|
32
|
+
|
|
33
|
+
3. **Split it into small tasks.** Ordered outcomes, not activities — each provable on its
|
|
34
|
+
own, each naming its check. An item that needs two gates is two items. This is the
|
|
35
|
+
ledger's `## Plan`; `todo_write` mirrors it for the person watching.
|
|
36
|
+
|
|
37
|
+
4. **Advance one item at a time.** Take the first unblocked item, not the most interesting
|
|
38
|
+
one. **Read the ledger first** — head, plan, last entry; it is the only memory that
|
|
39
|
+
survives compaction. Observe the real state, act (unique anchor, read the region back),
|
|
40
|
+
then **Verify**: run the item's gate, exit status decides. Prove a new guard by breaking
|
|
41
|
+
what it protects. **Record one caption entry** with saw, decided, did, evidence and
|
|
42
|
+
outcome, tick the item with that entry number, and commit while the gate is green.
|
|
43
|
+
|
|
44
|
+
5. **Update the tasks as you learn.** Tick, rewrite `todo_write` from the plan, and edit
|
|
45
|
+
the plan when the evidence contradicted it — add, split, drop, reorder, naming the entry
|
|
46
|
+
that caused it. A plan edited without a reason is drift; a plan never edited means the
|
|
47
|
+
investigation found nothing.
|
|
48
|
+
|
|
49
|
+
6. **Until the goal is met.** The run ends when the plan has no open items **and** every
|
|
50
|
+
criterion holds — not when the first plan is exhausted. Then `update_goal complete`,
|
|
51
|
+
reading it with `get_goal` first because the update needs its id and revision. When it
|
|
52
|
+
stalls, `blocked` with the concrete condition; being unsure is not blocked.
|
|
53
|
+
|
|
54
|
+
Before stage 1, decide the flow — **changing code** or **changing documentation** — and
|
|
55
|
+
write it in the ledger head. Both share the spine requirement → investigate → propose →
|
|
56
|
+
**the person approves** → execute → summarize; `references/flows.md` has each step.
|
|
55
57
|
|
|
56
58
|
## Dispatch
|
|
57
59
|
|
|
58
|
-
|
|
60
|
+
The plan decides the wave — the items whose `deps` are green and whose `owner` is empty — and
|
|
61
|
+
**you decide whether a wave exists at all**. That is a shape question, so answer it from the
|
|
62
|
+
plan rather than from cost: **two or more ready items, touching disjoint paths, each with its
|
|
63
|
+
own gate and more than a one-line edit, are a wave.** One ready item, shared files, or one gate
|
|
64
|
+
for all of them is not. Write every child into the ledger's `## Dispatch` table before it
|
|
65
|
+
starts, and keep four rules:
|
|
59
66
|
|
|
60
67
|
- **Analysis is read-only**, so it may fan out: one agent per area, findings with
|
|
61
|
-
`file:line
|
|
62
|
-
- **Build writes**, so each
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
`file:line`. No writes, no conflicts.
|
|
69
|
+
- **Build writes**, so each child owns a **disjoint** set of paths. Shared files — barrels,
|
|
70
|
+
configs, lockfiles, shared tests, **and this ledger** — belong to **exactly one owner**,
|
|
71
|
+
which is you. **Never run two writers on the same path.**
|
|
72
|
+
- **You collect, you prove.** Dispatch, do your own item, collect with `wait_agent`, then
|
|
73
|
+
run the whole gate on the merged tree yourself. A child's green is not the merged tree's
|
|
74
|
+
green.
|
|
75
|
+
- **Children do not fan out.** They have no delegation tools; a slice needing sub-slices is
|
|
76
|
+
two waves from here.
|
|
77
|
+
|
|
78
|
+
First-party tools only: `subagent` / `subagent_fork`, and `/code-review sub`,
|
|
79
|
+
`/code-simplify sub`, `/code-scrub sub` when the slice is exactly that check.
|
|
80
|
+
The child does not see this conversation — the brief carries everything. Brief, table shape,
|
|
81
|
+
per-wave cap and failure handling: `references/dispatch.md`.
|
|
71
82
|
|
|
72
83
|
## Creating experts mid-run
|
|
73
84
|
|
|
74
|
-
An expert is a paragraph, not a file
|
|
75
|
-
a finding, what is not, output shape. Five steps:
|
|
85
|
+
An expert is a paragraph, not a file. Five steps:
|
|
76
86
|
|
|
77
87
|
1. **Write the brief first, in the ledger** — the question, the bar, what "done" is.
|
|
78
88
|
2. **Decide the lane** — analysis (read-only, may fan out) or build (exclusive paths).
|
|
@@ -90,18 +100,17 @@ code. Method and worked briefs: `references/experts.md`.
|
|
|
90
100
|
unrecorded one costs the next iteration the same discovery.
|
|
91
101
|
- **Stop on outcomes, not on activity.** The plan has no open items **and** the criteria
|
|
92
102
|
hold. A ticked item is not proof; the gate is.
|
|
93
|
-
- **
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
the click, the input, and the state afterwards.
|
|
103
|
+
- **A green gate is not a working feature, and one gate per iteration is the rule.** When
|
|
104
|
+
the change touches an entry point, one iteration must take the real entry point the way a
|
|
105
|
+
person does, with real data — record the click, the input, and the state afterwards.
|
|
97
106
|
- **Assume nothing about the host.** Read the installed version, or write the smallest
|
|
98
107
|
probe that prints the answer. "The docs say" is a lead, not evidence.
|
|
99
108
|
- **A rejection is information.** Go back to investigation with the objection; a second
|
|
100
109
|
rejection means the requirement is wrong — stop and ask.
|
|
101
110
|
- **Stop when the loop stops paying.** Two iterations with no new fact mean stop and hand
|
|
102
111
|
back what is blocked. A recorded "stuck here" beats a third attempt.
|
|
103
|
-
- **Ask only at real forks** — scope change, irreversible action, unauthorized cost
|
|
104
|
-
|
|
112
|
+
- **Ask only at real forks** — scope change, irreversible action, unauthorized cost; anything
|
|
113
|
+
else goes in the unverified list and the run continues.
|
|
105
114
|
|
|
106
115
|
## The ledger
|
|
107
116
|
|
|
@@ -111,19 +120,21 @@ Write it to `docs/caption/<slug>.md`, creating the directory if needed. Three pa
|
|
|
111
120
|
`- Approved`. First values win; a closing entry may repeat `- Gate:`.
|
|
112
121
|
|
|
113
122
|
**Plan** — the open work, one line per item with the check that proves it: `[ ]` open,
|
|
114
|
-
`[x]` done, `[~]` blocked, `[-]` dropped.
|
|
115
|
-
|
|
123
|
+
`[x]` done, `[~]` blocked, `[-]` dropped. Add `| deps: 2,3` when an item waits on another
|
|
124
|
+
and `| owner: <child>` once dispatched; that is what makes "next" derived instead of felt.
|
|
125
|
+
**Edit it in place**; never append a second plan — the plan is current state, the entries
|
|
126
|
+
are history.
|
|
127
|
+
|
|
128
|
+
`todo_write` mirrors that plan for the person watching; rewrite it from the plan each
|
|
129
|
+
iteration. **The ledger wins** every disagreement — the list dies with the session.
|
|
116
130
|
|
|
117
131
|
**Entries** — appended, one per iteration: `## 3. <title>`, then `- Saw`, `- Decided`,
|
|
118
132
|
`- Did`, `- Evidence`, `- Outcome: done | dead end | unverified`.
|
|
119
133
|
|
|
120
|
-
Shape and ordering rules: `references/loop.md`.
|
|
121
|
-
|
|
122
134
|
## When the task ends
|
|
123
135
|
|
|
124
|
-
Report
|
|
125
|
-
|
|
126
|
-
closing shape.
|
|
136
|
+
Report the gate output, each criterion, the dead ends, the unverified list and how the plan
|
|
137
|
+
ended — `references/loop.md` has the closing shape.
|
|
127
138
|
|
|
128
139
|
## Reference files
|
|
129
140
|
|
|
@@ -138,5 +149,4 @@ closing shape.
|
|
|
138
149
|
| `examples/dispatch.md` | the shape of a safe split |
|
|
139
150
|
| `examples/theater.md` | the run feels busy but nothing is being proven |
|
|
140
151
|
|
|
141
|
-
If a reference path is unreadable, continue from this file
|
|
142
|
-
self-sufficient.
|
|
152
|
+
If a reference path is unreadable, continue from this file.
|