@morning-start/dsh-code-toolkit 0.28.1 → 0.29.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 CHANGED
@@ -1,5 +1,37 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.29.0 — 2026-11-29
4
+
5
+ - **"Propose, then act" is now the shared spine of every command that changes files.**
6
+ Review writes a finding before fixing it, simplify writes the plan (what it is now, what
7
+ it becomes, why behaviour is unchanged) before the first edit, scrub writes the dry-run
8
+ JSON and the redaction list before touching a file, caption writes the proposal before
9
+ opening a goal. The two steps may share one run, but the order cannot swap and the plan
10
+ must be on disk, not in the model's head. Read-only commands stop at the proposal. The
11
+ rule is a project constraint (`AGENTS.md` #11) with a test behind it, and a table in the
12
+ README saying which artifact is each command's plan.
13
+ - **The caption loop is now six stages, each with a refusal.** 方案 → goal → small tasks →
14
+ one item at a time → incremental task updates → until the goal is met. The first stage is
15
+ the new part: when the intent is too vague to propose an approach, caption stops and
16
+ either asks the two or three questions that would settle it or names the command that
17
+ answers it first (`/code-design` when the need is still a need, `/code-audit` when the
18
+ question is what exists today) — and says which approach it would take. **A ledger is
19
+ never opened for a task that cannot be stated**: a ledger for a wish produces entries
20
+ that record activity instead of progress. This closes the loop with `/code-design`, whose
21
+ last line already hands approved plans to `/code-caption`.
22
+ - **`/code-caption` now opens a DSH goal, and mirrors its plan into the task list.** The
23
+ intent-to-plan work was already in the ledger, but nothing ever told it to use the
24
+ host's continuation mechanism: `git log -S'create_goal'` returns nothing for the
25
+ repository's whole history, and the plugin's only tool restriction (`src/runtime.js`, a
26
+ deny list of delegation tools) never touched it. A run for "finish this" now opens a goal
27
+ once the plan is approved, closes it with `update_goal complete` when the plan is empty
28
+ and the criteria hold, and reports `blocked` with a concrete reason instead of quietly
29
+ stopping. `todo_write` mirrors the ledger's `## Plan` for the person watching; the ledger
30
+ stays authoritative, because the todo list dies with the session and the ledger does not.
31
+ `update_goal` needs `goal_id` and `revision`, so the loop reads `get_goal` first — the
32
+ detail lives in `agents/caption/references/loop.md`. Persona text, **not measured**
33
+ (see `evals/results/iteration-10.md`); the persona moved 7 652 → 8 433 characters.
34
+
3
35
  ## 0.28.1 — 2026-11-29
4
36
 
5
37
  - **Menu labels and hints were cut to a scan length.** Every `description` had grown
package/README.md CHANGED
@@ -43,7 +43,7 @@ DeepSeek Harness 的代码工具箱:**审查**、**精炼**、**隐私清理**
43
43
  | `/code-simplify` | 一次改造:功能不变的前提下简化 | 一次性 | `report` 出方案 → 人看过 → 再跑一次执行 | 是,默认写 |
44
44
  | `/code-scrub` | 一次清理:找出并移除隐私信息 | 一次性 | 同上,报告默认脱敏 | 是,默认写 |
45
45
  | `/code-audit` | 一次判断:现有能力是「通」还是「看起来有」 | 一次性,只读 | 单段:五态表 + `file:line`,没有 apply 路径 | **否** |
46
- | `/code-caption` | 复杂任务:跨轮、要验证、要台账 | **持续**,多轮多步 | 完整契约:需求 → 调查 → 方案 → **人审** → 执行 → 测试 → 人确认 → 改文档 | 是,按方案 |
46
+ | `/code-caption` | 复杂任务:跨轮、要验证、要台账 | **持续**,多轮多步 | 完整契约:方案 → **人批** → goal → 拆小任务 → 逐项推进 → 渐进更新 → 到完成 | 是,按方案 |
47
47
  | `/code-design` | 一次设计:把「缺什么」压成带证据的场景与批次 | **持续**,多轮,随人回答推进 | 四张底图 → 场景 → 排序 → 批次表 → **人批**;止于方案 | 只写 `docs/design/`,不写代码 |
48
48
  | `/pua` | 一次注入:给当前会话装纪律 | 一次性,注入即结束 | 无审核环节——它不做事,只改做事的方式 | 否 |
49
49
  | `/code-status` | 查询:干到哪了 | 只读 | 无 | 否 |
@@ -51,6 +51,21 @@ DeepSeek Harness 的代码工具箱:**审查**、**精炼**、**隐私清理**
51
51
 
52
52
  **只有 caption 需要完整契约**,因为它是唯一要连续跑门禁、唯一有「方案被推翻要回头改」的命令。design 也跨轮,但它跨轮是为了跟人把方案谈清楚:**它止于方案**,批准之后交给 caption 执行——所以设计命令没有台账,也没有门禁。其余命令是一次单独的行动——它们的「审核」要么压缩成一个开关(`report`),要么根本不存在。
53
53
 
54
+ ### 共同骨架:方案 → 动手
55
+
56
+ **所有会改文件的命令都是同一个形状,只是粒度不同**:先把要改的写成方案(改什么、改哪、为什么、怎么证明),再动手。顺序不能颠倒,方案必须落盘。
57
+
58
+ | 命令 | 它的「方案」是 | 什么时候动手 |
59
+ | --- | --- | --- |
60
+ | `/code-review` | findings:每条带 `path:line` 和证据 | 同一轮接着修;`report` 就停在方案 |
61
+ | `/code-simplify` | plan:每处 `now → change to` + 行为不变的论证 | 方案写完、门禁定好之后;`report` 停在方案 |
62
+ | `/code-scrub` | 脱敏清单 + 干跑 JSON,值已打码 | 同上 |
63
+ | `/code-caption` | 方案 → goal → 任务清单 | 你批了之后,逐项推进 |
64
+
65
+ 只读的两条止于方案:`/code-audit` 的产物就是报告,`/code-design` 的产物就是方案(执行交出去)。`status` / `cancel` 没有方案。
66
+
67
+ 这条规则在 `AGENTS.md` 的硬约束里,也有测试守着——「方案先落盘、再动手」不是建议。
68
+
54
69
  ## 一个外壳,所有命令
55
70
 
56
71
  命令的行为不是各写一遍:九条命令全部由同一个 `SessionCommand` 类实现([src/command.js](src/command.js))。每条命令只提供一份声明:
@@ -151,7 +166,16 @@ agents/pua/
151
166
 
152
167
  `/code-caption <任务>` 是这套东西里唯一不 spawn 的命令,因为它的对象不是一次检查,而是**一次长任务的进行方式**。
153
168
 
154
- 它注入的不是一张清单,而是一个循环:读台账 → 取计划里下一项 → 看真实状态 → 动手(锚点唯一、改完读回)→ 跑门禁 → 给新守卫做反证 → 记一条 caption 并提交 → 改计划。循环的产物是 `docs/caption/<slug>.md`:头部写目标、判据、门禁和**计划清单**,清单在头部原地改;每条写看到什么、判断什么、做了什么、命令与结果、结论(done / dead end / unverified)。
169
+ 它注入的不是一张清单,而是六个阶段,**每个阶段都带一个「不该硬推」时的出口**:
170
+
171
+ 1. **方案** — 改什么、改哪、为什么这样改、不做什么。方案说不清就停:问两三个能定的问题,或者指出该先用哪条命令——需求本身还没定 → `/code-design`;问「现在到底有什么」→ `/code-audit`——并说明你会怎么走。**说不清的任务不写台账。**
172
+ 2. **设 goal** — 一句目标 + 判据;你要求「跑到完成」时用 `create_goal` 开目标。
173
+ 3. **拆小任务** — 按结果切、每项自带检查;写进台账 `## Plan`,`todo_write` 同步给人看。
174
+ 4. **逐步推进** — 一次一项:读台账 → 看真实状态 → 动手(锚点唯一、改完读回)→ 跑门禁 → 给新守卫做反证 → 记一条并提交。
175
+ 5. **渐进更新** — 勾掉、重写 todo、证据推翻计划时原地改计划并写明是第几条改的。
176
+ 6. **直到完成** — 计划无未完成项且判据成立才收口,`update_goal complete`;卡住就 `blocked`,写清阻因。
177
+
178
+ 循环的产物是 `docs/caption/<slug>.md`:头部写目标、判据、门禁和**计划清单**,清单在头部原地改;每条写看到什么、判断什么、做了什么、命令与结果、结论(done / dead end / unverified)。
155
179
 
156
180
  三条规则是它的全部价值:**没有证据就不许声称**、**死路要留痕**、**判据满足才收口,清单空了不算**。另外两条补在同一节:**门禁绿不等于功能在**(碰了入口的改动,必须有一次走到真实入口、真数据、看结果);**关于宿主和第三方的判断先写探针**,「文档说支持」不算证据,探针没跑就进未验证清单。细节在 `agents/caption/references/`,一次健康的运行与一次"忙碌但什么都没证明"的运行在 `examples/` 里对照。
157
181
 
@@ -178,6 +202,18 @@ caption 不是「你给任务,它照着做」。你给的是一句**意图**
178
202
 
179
203
  `[ ]` 未做、`[x]` 完成、`[~]` 受阻、`[-]` 放弃。**原地改**,绝不追加第二份计划——计划是当前状态,条目是历史。勾掉时把条目号写在旁边,后来的人不用翻。没有 gate 的那一行不是计划项,是备注。
180
204
 
205
+ ### 三层:goal / 台账 / todo
206
+
207
+ 这三样分工不同,混起来就是三份互相打架的计划:
208
+
209
+ | 谁 | 活多久 | 回答什么 |
210
+ |---|---|---|
211
+ | `create_goal` | 本次会话的自动续轮 | 要不要不用人催,一直干到完成 |
212
+ | 台账 `## Plan` | 仓库里,跨会话 | 还剩哪几项,每项由什么证明 |
213
+ | `todo_write` | 本次会话,只给人看 | 现在在干哪一项 |
214
+
215
+ 你说了「做到完成为止」,它在方案批准后建 goal;收口时 `update_goal complete`,卡住时 `blocked` 并写出具体阻因。没说「跑到底」就不建——goal 会真的让会话自动续轮,不该替你做主。`todo_write` 每轮从 Plan 重写一遍,**台账永远是对的**:todo 随会话消失,台账不会。
216
+
181
217
  改计划是常态而不是失败:调查出结果后加、拆、删、重排都行,但每次都要写清是哪一条、为什么。一条**永远没被改过**的计划,说明调查没发现任何东西。
182
218
 
183
219
  ### 台账是入口
@@ -9,49 +9,52 @@ That is a loop over a list you own. What goes wrong is not the design — it is
9
9
  thread: working without a proof, repeating a dead end, ticking an item that was never
10
10
  true, or reporting done while items remain open.
11
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.
27
-
28
12
  ## The loop
29
13
 
30
- Every iteration takes **one item off the plan**.
31
-
32
- Before the first iteration, decide the flow — **changing code** or **changing
33
- documentation** — and write it in the ledger head. Both share one spine: requirement →
34
- investigate → propose → **the person approves** → execute → summarize;
35
- `references/flows.md` has each step.
36
-
37
- 1. **Read the ledger first.** Head, plan, last entry — before anything else. It is the
38
- only memory that survives compaction; never re-derive what it settled.
39
- 2. **Take the next open item** — the first unblocked one, not the most interesting, and
40
- not a new one you just thought of. Too big to prove in one step? Split it now.
41
- 3. **Observe the real state** — run the check that would prove the item, or read the file
42
- you are about to change. Work from the repository, not from memory.
43
- 4. **Act.** Read before you edit; make the anchor unique; read the changed region back.
44
- 5. **Verify.** Run the item's gate. Exit status decides, not your opinion. A red gate is
45
- data: diagnose, adjust, run the next iteration.
46
- 6. **Prove a new guard.** Break what it protects, watch it go red, restore, watch it go
47
- green. A guard you never saw fail is decoration.
48
- 7. **Record one caption entry, then commit.** Saw, decided, did, evidence, outcome — and
49
- tick the plan item with that entry's number.
50
- 8. **Re-plan.** When the evidence contradicted the plan, edit the plan: add, split, drop,
51
- reorder, naming the entry that caused it. A plan edited without a reason is drift.
52
-
53
- The loop ends when the plan has no open items **and** every criterion holds — not when
54
- the first plan is exhausted.
14
+ Six stages, in this order. Each has a refusal: what to do instead of pushing through.
15
+
16
+ 1. **方案 — the approach.** What changes, where, why this way, what you will not do. Not a
17
+ task list yet. Write it so someone else could execute it without you: it goes into the
18
+ ledger head, and a proposal only you can read is not one. If the intent is not clear
19
+ enough to propose, stop: ask the two or three questions that would settle it, or name
20
+ the command that answers it first — `/code-design` when the need is still a need,
21
+ `/code-audit` when the question is what exists today — and say which approach you would
22
+ take and why you cannot start. **Never write a ledger for a task you cannot state.**
23
+
24
+ **The approval gate is not optional.** The person approves the approach, the criteria
25
+ and the tasks together — a plan nobody read is not an approval, and a plan you keep in
26
+ your head is not a plan. If it admits two materially different readings, ask before
27
+ writing it; that one question is worth interrupting for.
28
+
29
+ 2. **The goal.** One objective sentence, plus the criteria that prove it. When the person
30
+ asked for the work to run to completion, `create_goal` with that objective and a line
31
+ saying which ledger carries the tasks; when they asked to stop for them each turn, do
32
+ not open one.
33
+
34
+ 3. **Split it into small tasks.** Ordered outcomes, not activities — each provable on its
35
+ own, each naming its check. An item that needs two gates is two items. This is the
36
+ ledger's `## Plan`; `todo_write` mirrors it for the person watching.
37
+
38
+ 4. **Advance one item at a time.** Take the first unblocked item, not the most interesting
39
+ one. **Read the ledger first** — head, plan, last entry; it is the only memory that
40
+ survives compaction. Observe the real state, act (unique anchor, read the region back),
41
+ then **Verify**: run the item's gate, exit status decides. Prove a new guard by breaking
42
+ what it protects. **Record one caption entry** with saw, decided, did, evidence and
43
+ outcome, tick the item with that entry number, and commit while the gate is green.
44
+
45
+ 5. **Update the tasks as you learn.** Tick, rewrite `todo_write` from the plan, and edit
46
+ the plan when the evidence contradicted it — add, split, drop, reorder, naming the entry
47
+ that caused it. A plan edited without a reason is drift; a plan never edited means the
48
+ investigation found nothing.
49
+
50
+ 6. **Until the goal is met.** The run ends when the plan has no open items **and** every
51
+ criterion holds — not when the first plan is exhausted. Then `update_goal complete`,
52
+ reading it with `get_goal` first because the update needs its id and revision. When it
53
+ stalls, `blocked` with the concrete condition; being unsure is not blocked.
54
+
55
+ Before stage 1, decide the flow — **changing code** or **changing documentation** — and
56
+ write it in the ledger head. Both share the spine requirement → investigate → propose →
57
+ **the person approves** → execute → summarize; `references/flows.md` has each step.
55
58
 
56
59
  ## Dispatch
57
60
 
@@ -114,6 +117,10 @@ Write it to `docs/caption/<slug>.md`, creating the directory if needed. Three pa
114
117
  `[x]` done, `[~]` blocked, `[-]` dropped. **Edit it in place**; never append a second
115
118
  plan — the plan is current state, the entries are history. Tick with the entry number.
116
119
 
120
+ `todo_write` mirrors that plan for the person watching: rewrite the whole list from the
121
+ plan each iteration, in order, the current item `in_progress`. **The ledger wins** every
122
+ disagreement — the todo list dies with the session, the ledger does not.
123
+
117
124
  **Entries** — appended, one per iteration: `## 3. <title>`, then `- Saw`, `- Decided`,
118
125
  `- Did`, `- Evidence`, `- Outcome: done | dead end | unverified`.
119
126
 
@@ -29,6 +29,10 @@ requirement → investigate → propose → human approves → execute (refining
29
29
  A rejection sends you back to **2. Investigate**, with the objection in hand — not to
30
30
  a redraft of the same plan. A second rejection means the requirement is wrong: say so
31
31
  and ask (see `references/loop.md`).
32
+
33
+ After the approval, two steps come before execution: set the **goal** (stage 2 — only when
34
+ the person asked for the work to finish without them), then turn the approved proposal into
35
+ the **plan block** (stage 3), each item with its check. Execution takes one item at a time.
32
36
  | **4. Execute** | One plan item per iteration; tick it with its entry number, and edit the plan when the evidence contradicts it | The plan has no open items and the gate is green |
33
37
  | **5. Test** | The gate command and its output; a guard proven red then green | The evidence is in the ledger, not in your memory |
34
38
  | **6. Human confirms** | The report: what changed, what was verified, what was not | The person says it is right |
@@ -45,6 +45,44 @@ Four rules make it a plan rather than a wish:
45
45
  Ticking is a claim: the entry beside it must carry the command and its result. An item
46
46
  ticked without evidence is the failure the whole ledger exists to prevent.
47
47
 
48
+ ## The goal and the task list
49
+
50
+ Three artifacts, three lifetimes — mixing them up is how a run ends with three disagreeing
51
+ plans:
52
+
53
+ | Artifact | Lifetime | Answers |
54
+ | --- | --- | --- |
55
+ | `create_goal` / `update_goal` | this session's continuation rounds | should this keep running without the person? |
56
+ | `todo_write` | this session, display only | what is happening right now, that they can see? |
57
+ | the ledger's `## Plan` | the repository | what is left, and what proves each item? |
58
+
59
+ **The goal.** Create it after the plan is approved, and only when the person asked for the
60
+ work to finish without prompting them each turn. The objective is the approved goal
61
+ sentence plus the criteria, plus where the ledger is — a resumed run reads the ledger, not
62
+ your memory of why the goal exists.
63
+
64
+ Updating it is not symmetric: `update_goal` needs `goal_id` and `revision`, so call
65
+ `get_goal` first and pass what it returns. `revision` changes every round, so a remembered
66
+ one fails with a conflict.
67
+
68
+ - `complete` — the plan has no open items and every criterion holds. Not "the work feels
69
+ done", and not "I am out of ideas".
70
+ - `blocked` — needs a `blocked_reason` naming the concrete condition, and the action is
71
+ rejected until that condition has persisted for at least three goal rounds. Being unsure
72
+ is not blocked.
73
+ - `pause` / `resume` / `edit` require a direct request from the person. A run that pauses
74
+ its own goal has quit without saying so.
75
+
76
+ **The task list.** `todo_write` takes the whole list and replaces the previous one, so
77
+ rewrite it from the plan instead of appending. Order matters: it is the person's window
78
+ into which item is next. When the two disagree the ledger is right and the list is
79
+ rewritten — never the other way round, or the run starts working toward a plan nobody
80
+ approved.
81
+
82
+ Neither tool exists in every host: a spawned child may have no goal tools, and an older
83
+ host may have neither. When they are missing, say so in the entry and run on the ledger
84
+ alone — a missing tool is a note, not a reason to skip the iteration.
85
+
48
86
  ## Why the ledger is external
49
87
 
50
88
  Long tasks get compacted. After compaction you keep a summary, not the detail:
@@ -9,8 +9,11 @@ The task tells you which mode you are in.
9
9
 
10
10
  - **dry-run** — report only. Change no files; the report is the product.
11
11
  - **apply** — report **and** fix. Review first, then fix the findings you are sure of,
12
- one at a time, re-running the gate after each. A finding you cannot prove stays a
13
- finding; a fix that turns the gate red is reverted and reported as unfixed.
12
+ one at a time, re-running the gate after each.
13
+
14
+ **Every fix has a written finding behind it** — an edit with no finding is an unreviewed
15
+ change, however obvious it looks. A finding you cannot prove stays a finding; a fix that
16
+ turns the gate red is reverted and reported as unfixed.
14
17
 
15
18
  In apply mode the report still comes first: the person reads what you found before what
16
19
  you changed. Fixes go under `fixed`, everything you left alone stays under `findings`.
@@ -103,9 +103,10 @@ reads oddly for a scrub, but the renderer only shows the verdict and the finding
103
103
  **In-session** (the brief says so): write the same rows as a Markdown table instead —
104
104
  masked value, `path:line`, priority, one-line reason. Do not send both.
105
105
 
106
- **Apply** — produce the dry-run JSON first, make the redactions described in
107
- `references/redaction.md`, then return a Markdown report: what was redacted (was →
108
- now → verified by), the verification command and result, and what was not handled.
106
+ **Apply** — the plan first: the dry-run JSON and the redaction list it implies, with each
107
+ masked value. Then make them (`references/redaction.md`), and return a Markdown report:
108
+ what was redacted (was → masked → verified by), the verification command and result, and
109
+ what was not handled.
109
110
 
110
111
  Rotating a leaked credential is not something you can do from here. Say so in every
111
112
  report that contains one: redaction fixes the working tree, not the history and not the
@@ -73,11 +73,12 @@ The task tells you which mode you are in.
73
73
 
74
74
  - **dry-run** — change no files. Produce the plan and the argument that behaviour is
75
75
  unchanged.
76
- - **apply** — establish the gate **before the first edit**: the project's tests, or a
77
- characterization baseline when there are none (`references/verification.md`). Apply
78
- one item or file group at a time, re-run the gate after each, revert that batch if it
79
- fails. If no gate can be established, **do not apply** — return the plan and say
80
- exactly what is missing.
76
+ - **apply** — **the plan comes first and in writing**: for each item, what it is now, what
77
+ it becomes, and the argument that behaviour is unchanged. Then establish the gate (the
78
+ project's tests, or a characterization baseline when there are none —
79
+ `references/verification.md`), and only then edit. Apply one item or file group at a
80
+ time, re-run the gate after each, revert that batch if it fails. If no gate can be
81
+ established, **do not apply** — return the plan and say exactly what is missing.
81
82
 
82
83
  ## Editing
83
84
 
@@ -103,8 +104,9 @@ Follow the structure the examples use; the fields below are the contract.
103
104
  - **Plan (dry-run)**: scope, **`Files read in full`** and `searched only` counts, a gate
104
105
  or "none available", then one entry per point — `type`, `now`, `change to`, `why
105
106
  behaviour is unchanged`, `risk`. A file you only grepped is never "read in full".
106
- - **Apply**: one entry per change — `type`, `change`, `verified by` — then the gate and
107
- its result.
107
+ - **Apply**: the plan you executed — one entry per item with `now`, `change to`, and why
108
+ behaviour is unchanged — then what was actually done (`change`, `verified by`), then the
109
+ gate and its result. A change with no plan entry above it is drift.
108
110
  - **Not handled** (both): `defect`, **`behaviour-risk`**, `too-big`, `intentional`, each
109
111
  with its file:line and why it is not this task.
110
112
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@morning-start/dsh-code-toolkit",
3
- "version": "0.28.1",
3
+ "version": "0.29.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public",