@morning-start/dsh-code-toolkit 0.27.4 → 0.28.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/CHANGELOG.md +112 -0
  2. package/README.md +111 -11
  3. package/agents/audit/AGENT.md +137 -0
  4. package/agents/audit/examples/fake-capability.md +54 -0
  5. package/agents/audit/examples/wired-clean.md +66 -0
  6. package/agents/audit/references/audit-passes.md +118 -0
  7. package/agents/audit/references/capability-states.md +96 -0
  8. package/agents/audit/references/evidence.md +86 -0
  9. package/agents/audit/references/finding-the-chain.md +80 -0
  10. package/agents/audit/references/output.md +66 -0
  11. package/agents/caption/AGENT.md +112 -135
  12. package/agents/caption/examples/loop.md +12 -0
  13. package/agents/caption/references/evidence.md +46 -0
  14. package/agents/caption/references/flows.md +6 -2
  15. package/agents/caption/references/loop.md +57 -1
  16. package/agents/design/AGENT.md +158 -0
  17. package/agents/design/examples/one-page.md +55 -0
  18. package/agents/design/examples/overkill.md +56 -0
  19. package/agents/design/references/base-maps.md +110 -0
  20. package/agents/design/references/deliverables.md +71 -0
  21. package/agents/design/references/model-and-ports.md +73 -0
  22. package/agents/design/references/plan-and-batches.md +92 -0
  23. package/agents/design/references/scenario-cards.md +133 -0
  24. package/agents/design/references/self-check.md +73 -0
  25. package/agents/pua/AGENT.md +3 -0
  26. package/agents/review/AGENT.md +52 -52
  27. package/agents/scrub/AGENT.md +64 -67
  28. package/agents/simplify/AGENT.md +70 -101
  29. package/index.js +145 -11
  30. package/locale/en.json +2 -2
  31. package/locale/zh.json +2 -2
  32. package/package.json +5 -2
  33. package/src/caption.js +149 -0
  34. package/src/command.js +20 -6
  35. package/src/design.js +70 -0
  36. package/src/i18n.js +98 -24
  37. package/src/report.js +112 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,117 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.28.1 — 2026-11-29
4
+
5
+ - **Menu labels and hints were cut to a scan length.** Every `description` had grown
6
+ into an explanation of its flags ("…; add sub for a subagent, report for a plan
7
+ only"), so the `/` menu read like documentation. Descriptions now say what the
8
+ command does; hints list the flags without explaining them where the README already
9
+ does. A test caps both (zh 18/56, en 60/90 characters), so they cannot creep back.
10
+ The plugin-panel description and `market.json` were shortened the same way.
11
+ - **Every persona was cut to its kernel.** `AGENT.md` now carries the role, the judging
12
+ gates, the output contract and the reference table; the justifications, lookup tables,
13
+ worked walkthroughs and output templates moved into the references each role already
14
+ had. Total 57 016 → 43 083 characters (−24%): caption −36%, audit −26%, review −25%,
15
+ simplify −24%, design −21%, scrub −21%. A test now caps every persona at 9 000
16
+ characters — the host's limit is 12 000, but the budget is a cost paid on every run of
17
+ that role, not headroom to fill.
18
+ - **`/code-caption` now runs a plan it owns, not a task it was handed.** The person
19
+ supplies an intent; the protocol derives the goal, the acceptance criteria and an
20
+ ordered plan, writes all three into the ledger head, and gets them approved before
21
+ executing. The plan is a block of outcomes — each one provable, each with its check
22
+ on the same line — with `[ ]` open, `[x]` done, `[~]` blocked, `[-]` dropped. Every
23
+ iteration takes the first unblocked item; when the evidence contradicts the plan, the
24
+ plan is edited in place and the edit names the entry that caused it. The run ends
25
+ when the plan has no open items **and** every criterion holds, not when the first
26
+ plan is exhausted. This is the loop-plus-todo-list shape the command was supposed to
27
+ have; what it had was an append-only log with a fixed contract at the top.
28
+ - **A caption ledger is addressable now.** `list` names every ledger in the project
29
+ (name, title, steps, closed), and `resume <number|name>` continues one with its
30
+ absolute path written into the injected text. A project with five ledgers no longer
31
+ depends on the phrase "continue the current task"; ambiguity is reported with the
32
+ candidates instead of guessed, and `resume` accepts a full slug, the list position,
33
+ or a unique fragment of the slug or title.
34
+ - **`/code-status` stopped printing `undefined`.** An injected protocol (caption,
35
+ pua) leaves a journal record with no scope and no mode, and status printed those
36
+ fields raw: `最近一次:undefined · undefined`. It now names the installed protocol
37
+ and, for caption, the most recent ledger's progress. Found by probing the commands
38
+ with a stub host, not by reading them.
39
+ - **Ledger parsing is tolerant on purpose.** It reads `# title`,
40
+ `- Task/Criteria/Gate/Flow`, `## N. title` and `- Outcome:`; a BOM-prefixed file or
41
+ an unfamiliar shape degrades to the file name instead of disappearing. Head fields
42
+ are first-wins, because a closing entry repeats `- Gate:` with that run's result.
43
+ - **Two governance rules for the loop**: a rejected plan sends you back to
44
+ investigation, and a second rejection means the requirement is wrong; two iterations
45
+ that produce no new fact mean stop and hand back what is blocked. Both are persona
46
+ text — **not measured** (see `evals/results/iteration-8.md`).
47
+ - `validate` / `early` on a command spec now receive the same context as
48
+ `buildText`, so a decision made before injection is the one the injected text acts
49
+ on. `src/caption.js` holds the ledger reader, with no new dependency.
50
+ - 125 → 130 deterministic checks.
51
+
52
+ ## 0.28.0 — 2026-11-29
53
+
54
+ - **New `/code-audit`: is the capability wired, or does it only look wired?**
55
+ Reads the tree from the real entry point backwards — entry → handler →
56
+ interface → effect → a test that can go red — and stops at the first absent link.
57
+ Each capability gets one of five tokens: `wired`, `half`, `fake`, `broken`,
58
+ `missing`. `fake` — a doc, a comment, or a test claims it and production calls
59
+ nothing — is the state the command exists for. Read-only: no apply path, no
60
+ `report` flag. A capability nobody reached through its real entry point cannot be
61
+ marked `wired`; it goes in `limitations` as unverified.
62
+ - **New `/code-design`: scenario-driven product design.** Turns "what is this
63
+ project missing" into a role table and permission matrix, a goal tree and
64
+ resource model, a scenario list with P0 cards (including a negative assertion
65
+ each), a multi-angle ranking, and a batch table whose batch 0 is a gate. Three
66
+ effort tiers, chosen by the first word: `quick`, default, `full`. It writes
67
+ `docs/design/` and **stops at "the plan is ready"** — execution belongs to
68
+ `/code-caption`, which already owns the gate and the ledger. No second ledger.
69
+ - **Report schema: `capabilities`.** The audit's table is a first-class part of a
70
+ report (`capability`, `state`, `evidence{file,line_range}`, `note`), rendered with
71
+ `file:line` links; the state tokens are a closed set, translated for display, and
72
+ a row without a known state is dropped rather than guessed. The scanner now
73
+ recognises a report that has a capability table and no findings.
74
+ - **`dryRunKey` / `deliveryKey` on a command spec.** A read-only command whose dry
75
+ run is a report rather than a plan can name its own instructions, so the wording
76
+ is translated with the rest of the chrome instead of being hard-coded in the
77
+ shell. `auditModel` and `designDirectory` added to config.
78
+ - Two new personas, layered and sourced: `agents/audit/` (8 files) and
79
+ `agents/design/` (9 files). Internalised from the local skill
80
+ `scenario-driven-product-design` (user-authored), whose 31,841 characters cannot
81
+ fit a 12,000-character persona; the core moved into `AGENT.md` and the deep tables
82
+ into `references/`, each file headed with `Source:`.
83
+ - Four new eval cases: a `fake` capability with a handler and a passing test (11),
84
+ a capability wired by manifest that a `grep` reports as fake (12, the
85
+ anti-false-positive), a brief with no code where no `file:line` may be invented
86
+ (13), and a one-line colour change that must not receive a design process (14).
87
+ - `/code-caption` gained the two verification rules it was missing: **a green gate
88
+ is not a working feature** (one iteration must reach the real entry point, with
89
+ real data, and look at the result) and **assume nothing about the host** (read the
90
+ installed code or write the smallest probe; "the docs say" is a lead, not
91
+ evidence). Depth in `agents/caption/references/evidence.md`; no new command, no new
92
+ file.
93
+ - 96 → 125 deterministic checks; `evals/results/iteration-5.md` records the first
94
+ with/without-persona comparison, `iteration-7.md` the persona audit.
95
+ - Persona payload trimmed where it was duplicated rather than layered: the audit's
96
+ field-by-field spec moved out of `AGENT.md` into `references/output.md` (−681
97
+ chars), and the design's five-state table became action-oriented bullets with the
98
+ judging criteria left in one place (−311 chars). No rule was removed; the tests
99
+ that lock every marker still pass.
100
+ - **Persona audit fixes.** Reading all seven personas against the shell and their own
101
+ references found three contradictions. `/code-review` and `/code-scrub` said "one
102
+ JSON object, nothing else" while the shell appends "write Markdown, not the JSON
103
+ envelope" to every inline structured run — which is review's default path; both now
104
+ describe the in-session format. `/code-audit`'s `wired` demanded a test that can go
105
+ red while its own reference said a test is not required; the observed chain is
106
+ enough again. And four personas never said what to do when their references cannot
107
+ be read; all seven do, with a test.
108
+ - `/code-design`'s eight baseline groups moved into
109
+ `references/scenario-cards.md` — the persona keeps their names and the coverage
110
+ gate — buying headroom under the 12 000-character cap.
111
+ - New case 15-pua-no-escalation: one failure plus an environment red herring in the
112
+ README. The protocol says read the error, fix it, paste the command — not switch
113
+ method, not blame the environment. This is pua's missing negative case.
114
+
3
115
  ## 0.27.4 — 2026-11-28
4
116
 
5
117
  - **Fixed a corrupting write in `/code-caption` and `/pua`.** Both passed
package/README.md CHANGED
@@ -1,18 +1,20 @@
1
1
  # @morning-start/dsh-code-toolkit
2
2
 
3
- DeepSeek Harness 的代码工具箱:**审查**、**精炼**、**隐私清理**三件检查,外加一条把难任务装进显式循环的协议命令和一条 PUA 协议。三件检查默认把任务交给**当前会话**——你能看见它读什么、改什么;加 `sub` 才换成独立上下文的原生 spawn agent。`/code-caption` 与 `/pua` 不 spawn,它们把文本注入当前会话。
3
+ DeepSeek Harness 的代码工具箱:**审查**、**精炼**、**隐私清理**三件检查,一条把难任务装进显式循环的协议命令,一条 PUA 协议,外加把「这个项目还缺什么」变成场景与批次的设计命令,和它用来取证的能力审计。三件检查默认把任务交给**当前会话**——你能看见它读什么、改什么;加 `sub` 才换成独立上下文的原生 spawn agent。`/code-caption`、`/code-design` 与 `/pua` 不 spawn,它们把文本注入当前会话。
4
4
 
5
5
  ```text
6
6
  /code-review 审查改动,默认出报告并修复发现的问题(加 report 只出报告)
7
7
  /code-simplify 简化代码,功能逐位不变(默认直接改,加 report 只出计划)
8
8
  /code-scrub 清理隐私信息:密钥、密码、账号、本机路径(默认直接改,加 report 只出报告)
9
+ /code-audit 审计现有能力:从真实入口追到存储,标出通/半/假/断/无(只读)
9
10
  /code-caption 把难任务装进 caption 循环:一步一验,过程落成台账
11
+ /code-design 场景驱动的需求分析:四张底图、场景卡、批次方案,出文档等人批
10
12
  /pua 给当前会话装上 PUA 协议:失败换方法、完成要证据
11
13
  /code-status 查看状态或最近一次结果
12
14
  /code-cancel 取消运行中的任务
13
15
  ```
14
16
 
15
- 不带参数就按每条命令的默认跑:审查看**未提交的改动**(都提交了就看当前分支相对基线的改动,没有基线就看最近 5 个提交)并**修复发现的问题**,精炼与清理看**整个项目并直接改**,caption 继续当前任务,pua 用阿里风味——不弹任何选择框。回执会写明这次落在哪个范围、交给了谁、会不会改文件。要收窄或换行为,一行写清:
17
+ 不带参数就按每条命令的默认跑:审查看**未提交的改动**(都提交了就看当前分支相对基线的改动,没有基线就看最近 5 个提交)并**修复发现的问题**,精炼与清理看**整个项目并直接改**,审计**只看不写**,caption 继续当前任务,design 按半天深度设计当前项目,pua 用阿里风味——不弹任何选择框。回执会写明这次落在哪个范围、交给了谁、会不会改文件。要收窄或换行为,一行写清:
16
18
 
17
19
  ```text
18
20
  /code-review --branch develop
@@ -21,6 +23,8 @@ DeepSeek Harness 的代码工具箱:**审查**、**精炼**、**隐私清理**
21
23
  /code-simplify --files src/app.js,src/util.js
22
24
  /code-simplify report
23
25
  /code-simplify sub report --branch main
26
+ /code-audit sub
27
+ /code-design quick 这个项目还缺什么
24
28
  ```
25
29
 
26
30
  `sub` 交给子 agent,`report` 只出报告,`--branch <ref>` 换一个对比分支(默认基线分支,`--base` 同义);位置随意,可叠加。默认直接改。
@@ -31,28 +35,31 @@ DeepSeek Harness 的代码工具箱:**审查**、**精炼**、**隐私清理**
31
35
 
32
36
  ## 每条命令的契约不一样
33
37
 
34
- 七条命令共用一个外壳,但**不共用同一份契约**。外壳保证的是行为一致:秒回、定范围、失败发说明、写 journal。契约取决于这条命令要解决什么问题——把 caption 的循环套到 review 上,只会多一层空转。
38
+ 九条命令共用一个外壳,但**不共用同一份契约**。外壳保证的是行为一致:秒回、定范围、失败发说明、写 journal。契约取决于这条命令要解决什么问题——把 caption 的循环套到 review 上,只会多一层空转。
35
39
 
36
40
  | 命令 | 解决什么 | 生命周期 | 契约 | 能不能改文件 |
37
41
  | --- | --- | --- | --- | --- |
38
42
  | `/code-review` | 一次判断:这段改动有没有问题,并把它修掉 | 一次性 | 默认先报告再修(修完必须跑门禁),`report` 只出报告 | 是,默认改 |
39
43
  | `/code-simplify` | 一次改造:功能不变的前提下简化 | 一次性 | `report` 出方案 → 人看过 → 再跑一次执行 | 是,默认写 |
40
44
  | `/code-scrub` | 一次清理:找出并移除隐私信息 | 一次性 | 同上,报告默认脱敏 | 是,默认写 |
45
+ | `/code-audit` | 一次判断:现有能力是「通」还是「看起来有」 | 一次性,只读 | 单段:五态表 + `file:line`,没有 apply 路径 | **否** |
41
46
  | `/code-caption` | 复杂任务:跨轮、要验证、要台账 | **持续**,多轮多步 | 完整契约:需求 → 调查 → 方案 → **人审** → 执行 → 测试 → 人确认 → 改文档 | 是,按方案 |
47
+ | `/code-design` | 一次设计:把「缺什么」压成带证据的场景与批次 | **持续**,多轮,随人回答推进 | 四张底图 → 场景 → 排序 → 批次表 → **人批**;止于方案 | 只写 `docs/design/`,不写代码 |
42
48
  | `/pua` | 一次注入:给当前会话装纪律 | 一次性,注入即结束 | 无审核环节——它不做事,只改做事的方式 | 否 |
43
49
  | `/code-status` | 查询:干到哪了 | 只读 | 无 | 否 |
44
50
  | `/code-cancel` | 中断:停掉正在跑的 | 只读 | 无 | 否 |
45
51
 
46
- **只有 caption 需要完整契约**,因为它是唯一跨轮、唯一要连续跑门禁、唯一有「方案被推翻要回头改」的命令。其余命令是一次单独的行动——它们的「审核」要么压缩成一个开关(`report`),要么根本不存在。
52
+ **只有 caption 需要完整契约**,因为它是唯一要连续跑门禁、唯一有「方案被推翻要回头改」的命令。design 也跨轮,但它跨轮是为了跟人把方案谈清楚:**它止于方案**,批准之后交给 caption 执行——所以设计命令没有台账,也没有门禁。其余命令是一次单独的行动——它们的「审核」要么压缩成一个开关(`report`),要么根本不存在。
47
53
 
48
54
  ## 一个外壳,所有命令
49
55
 
50
- 命令的行为不是各写一遍:七条命令全部由同一个 `SessionCommand` 类实现([src/command.js](src/command.js))。每条命令只提供一份声明:
56
+ 命令的行为不是各写一遍:九条命令全部由同一个 `SessionCommand` 类实现([src/command.js](src/command.js))。每条命令只提供一份声明:
51
57
 
52
58
  | 声明 | 作用 |
53
59
  | --- | --- |
54
60
  | `kind` | `task` 走范围 + 任务投递(可加 `sub`);`inject` 往会话里放一段文本;`local` 只读状态或取消 |
55
61
  | `forceDryRun` / `report` | 只读、默认改写、还是加 `report` 只出报告 |
62
+ | `dryRunKey` / `deliveryKey` | 只读命令自己那份「模式说明」与「交付要求」,措辞进 i18n(audit 用它,因为它的 dry-run 是报告不是计划) |
56
63
  | `followsPlan` | 执行时是否沿用上一份已批准的 `report`(simplify / scrub) |
57
64
  | `defaultScope` | 空输入时的默认范围(review 用 `branch`,其余 `project`) |
58
65
  | `structured` | 报告是否按结构化格式解析后再渲染 |
@@ -99,6 +106,25 @@ agents/caption/
99
106
  examples/loop.md 一次健康的运行
100
107
  examples/dispatch.md 一个安全的切分与一个反面例子
101
108
  examples/theater.md 忙碌但什么都没证明的运行
109
+ agents/audit/
110
+ AGENT.md 能力五态、追链五环、三遍审计、证据等级、输出契约
111
+ references/audit-passes.md 三遍审计:静态 0 发现≠流程通、状态矩阵、十种运行时断法、抽样、行模板
112
+ references/capability-states.md 五态的边界:假/无、半/断、粒度怎么定、五个搜索定标签
113
+ references/finding-the-chain.md 动态注册、跨进程、怎么证明「没有调用者」
114
+ references/evidence.md 四级证据、什么不能当实现、limitations 怎么写
115
+ references/output.md 信封逐字段规格、一整行示例、排序与 Markdown 模式
116
+ examples/fake-capability.md 一个「有 handler、有测试、没入口」的判例
117
+ examples/wired-clean.md 看着没接线、其实由 manifest 加载的反例
118
+ agents/design/
119
+ AGENT.md 铁律、四张底图、场景网格、场景卡、排序、批次、止于方案
120
+ references/base-maps.md 目标树 / 资源模型 / 角色表 / 权限矩阵模板
121
+ references/scenario-cards.md 场景卡十项与两个填好的例子
122
+ references/plan-and-batches.md 批 0 门禁四件套、批次表、明确不做、进度表
123
+ references/model-and-ports.md 六个判断动作、模型还是端口、决策表
124
+ references/deliverables.md 文档编号与三档投入
125
+ references/self-check.md 交付前逐条打勾的 16 条门禁
126
+ examples/one-page.md 30 分钟档的合格样子
127
+ examples/overkill.md 给一个换颜色的需求铺二十页表格
102
128
  agents/pua/
103
129
  AGENT.md 三条红线、L0–L4 升级、五步排查、冰山法则
104
130
  references/flavors.md 8 种大厂风味的话术与方法论
@@ -125,9 +151,48 @@ agents/pua/
125
151
 
126
152
  `/code-caption <任务>` 是这套东西里唯一不 spawn 的命令,因为它的对象不是一次检查,而是**一次长任务的进行方式**。
127
153
 
128
- 它注入的不是一张清单,而是一个循环:读台账 → 看真实状态 → 只做一步 → 动手(锚点唯一、改完读回)→ 跑门禁 → 给新守卫做反证 → 记一条 caption 并提交 → 重排下一步。循环的产物是 `docs/caption/<slug>.md`:头部写任务、判据、门禁,每条写看到什么、判断什么、做了什么、命令与结果、结论(done / dead end / unverified)。
154
+ 它注入的不是一张清单,而是一个循环:读台账 → 取计划里下一项 → 看真实状态 → 动手(锚点唯一、改完读回)→ 跑门禁 → 给新守卫做反证 → 记一条 caption 并提交 → 改计划。循环的产物是 `docs/caption/<slug>.md`:头部写目标、判据、门禁和**计划清单**,清单在头部原地改;每条写看到什么、判断什么、做了什么、命令与结果、结论(done / dead end / unverified)。
129
155
 
130
- 三条规则是它的全部价值:**没有证据就不许声称**、**死路要留痕**、**判据满足才收口,清单空了不算**。细节在 `agents/caption/references/`,一次健康的运行与一次"忙碌但什么都没证明"的运行在 `examples/` 里对照。
156
+ 三条规则是它的全部价值:**没有证据就不许声称**、**死路要留痕**、**判据满足才收口,清单空了不算**。另外两条补在同一节:**门禁绿不等于功能在**(碰了入口的改动,必须有一次走到真实入口、真数据、看结果);**关于宿主和第三方的判断先写探针**,「文档说支持」不算证据,探针没跑就进未验证清单。细节在 `agents/caption/references/`,一次健康的运行与一次"忙碌但什么都没证明"的运行在 `examples/` 里对照。
157
+
158
+ ### 意图进,清单出
159
+
160
+ caption 不是「你给任务,它照着做」。你给的是一句**意图**,它要自己推出三样东西写进台账头部:
161
+
162
+ - **目标**:一句话能复述给你;
163
+ - **判据**:别人怎么判断做完了——命令、可观察状态,或者一句必须出现的话;
164
+ - **计划**:**按结果切,不按动作切**。每项是一个能被单独证明的结果,并在同一行写清证明它的检查。修 bug 的顺序通常是:复现 → 用守卫钉住现有契约 → 改代码 → 证明守卫会红。
165
+
166
+ 三样一起给你批,批了才动手。
167
+
168
+ 计划是**活的状态**,不是一次性清单:
169
+
170
+ ```markdown
171
+ ## Plan
172
+ - [x] 1. 复现失败 — gate: `node --test` 点名 `sum([])`(见条目 1)
173
+ - [x] 2. 钉住现有契约 — gate: 新加的强制转换测试在今天的代码上通过(见条目 2)
174
+ - [ ] 3. 修空输入 — gate: `sum([])` 为 0,其余仍然通过
175
+ - [~] 4. 换成真正的导出库 — blocked: 还没人选库
176
+ - [-] 5. 批量导出 — dropped: 0.9 不做
177
+ ```
178
+
179
+ `[ ]` 未做、`[x]` 完成、`[~]` 受阻、`[-]` 放弃。**原地改**,绝不追加第二份计划——计划是当前状态,条目是历史。勾掉时把条目号写在旁边,后来的人不用翻。没有 gate 的那一行不是计划项,是备注。
180
+
181
+ 改计划是常态而不是失败:调查出结果后加、拆、删、重排都行,但每次都要写清是哪一条、为什么。一条**永远没被改过**的计划,说明调查没发现任何东西。
182
+
183
+ ### 台账是入口
184
+
185
+ 一个项目攒几份台账之后,「继续当前任务」就指不清了。所以:
186
+
187
+ ```text
188
+ /code-caption list 列出台账:名字、标题、走了几步、收口没有
189
+ /code-caption resume <序号|名字> 接续某一份,注入的文本里直接带绝对路径
190
+ /code-status 说清装的是哪条协议,并附上最近一份台账的进度
191
+ ```
192
+
193
+ `resume` 认完整 slug、认列表里的序号、也认 slug 或标题里不重复的片段;**匹配到多份就报歧义,不猜**。台账解析是容错的——只认 `# 标题`、`- Task/Criteria/Gate/Flow`、`## N. 标题` 和 `- Outcome:`,认不出的文件退化成文件名,旧台账不用重写。
194
+
195
+ 配套的两条治理规矩:**方案被否不是重写方案**(回到调查,第二次被否说明需求错了,停下来问);**两轮没有新事实就停**(写了卡在哪、要谁定什么,比再试一次值钱)。
131
196
 
132
197
  ### 两条常用流程
133
198
 
@@ -159,6 +224,35 @@ agents/pua/
159
224
 
160
225
  跟 DSH 自带的 `/plan` 是串联关系:`/plan` 管"先想、方案要你批",`/code-caption` 管"批了之后怎么按依赖做完并证明做完了"。
161
226
 
227
+ ## 能力审计
228
+
229
+ `/code-audit` 问的是另一个问题:不是「这段改动有没有问题」,而是**「这个能力到底在不在」**。它要抓的失败最贵——README、变更记录、测试都说做完了,用户点下去什么都没有。
230
+
231
+ - **五态**:`wired` 通 / `half` 半 / `fake` 假 / `broken` 断 / `missing` 无。状态是**封闭集 token**,正文可以是你选择的语言,token 不变;渲染时翻成中文。
232
+ - **三遍审计,不是一遍**:静态接线(追链)→ 运行时语义(状态 × 角色矩阵,按十种运行时断法逐格查)→ 真实入口(真数据、每条 P0 点一遍)。**第一遍 0 发现只证明接线图没有断头,不证明电流过得去**——真实例子里静态扫描全绿、仍查出 7 处 P0 运行时断点。跑不了的遍明说没跑。
233
+ - **追链五环**:真实入口 → handler → 接口 → 存储 → 一条会红的测试,停在第一个缺失的环,那一环就是证据。
234
+ - **`fake` 是什么**:文档、注释、测试声称有,生产代码零调用。这是它最想抓的一态,也最容易被读代码的人放过——因为 handler 和测试确实存在。
235
+ - **只读**:没有 apply 路径,没有 `report` 开关。没有走完第三遍的能力不许标 `wired`,只能标「未确认」并写进 `limitations`。
236
+
237
+ 它和白名单式 `grep` 的区别在 `references/finding-the-chain.md`:manifest、目录约定、字符串注册表、依赖注入都能让一个「搜不到调用者」的能力其实是接好的。误报一条,整张表就没人看了([examples/wired-clean.md](agents/audit/examples/wired-clean.md) 就是这个反例)。
238
+
239
+ 读者看的是表,所以 [src/report.js](src/report.js) 增加了 `capabilities`:字段是 `id` / `capability` / `state` / `evidence{file,line_range}` / `path`(走的路径,停在哪) / `expected` / `actual` / `impact`(用户做不到什么) / `batch`(建议批次,让审计能直接喂给方案),渲染成一张带 `file:line` 链接的表 + 每行一段明细;没有已知状态的行走不进表,宁可丢一行也不猜。
240
+
241
+ ## 场景驱动的设计
242
+
243
+ `/code-design` 把「这个项目还缺什么」压成能验收的东西:**谁,在什么状态下,想完成什么,失败时看到什么**。它注入的是一套协议,不是一张表格:
244
+
245
+ - **三条铁律**:用户从痕迹反推;结论带证据(实测 > 日志 > 原话 > 推断);写不出失败形态的场景还没想清楚。
246
+ - **四张底图**:目标树、资源模型、角色表与权限矩阵、能力五态。缺一张不往下走——能力那栏来自 `/code-audit`。
247
+ - **场景不是头脑风暴**:角色 × 阶段 × 意图铺网格,八组基线 + 三类失败场景;P0 场景写成十项卡,含**反向断言**(这个动作不该改变什么)。
248
+ - **两套排序不混用**:新能力按频次,既有缺陷按伤害;被权限矩阵否决的需求不进排期。
249
+ - **批 0 是门禁**:先造一个能发现「写了没接线」的检查,再接功能。
250
+ - **三档投入**:`/code-design quick` 一页结论,默认半天,`full` 出完整方案——档位是命令的第一个词。
251
+
252
+ **它止于方案。** 批准之后交给 `/code-caption`:一批一提交、能跑门禁、有台账。design 不执行、不建台账,因为它没有「执行到哪一步」这件事要说——那是 caption 的契约。文档写在 `docs/design/`(可用 `designDirectory` 改),编号固定,`03-修复方案.md` 的批次表就是 caption 的输入。
253
+
254
+ 这个命令是从本机 skill `scenario-driven-product-design` 内化来的:协议、五态、文档编号同源,`references/` 里每份文件头都标了 `Source:`。两者的区别只在触发——skill 靠模型自己判断命中,命令由人输入;内化之后只有这一份协议在维护,不会再和 skill 各演化一份。
255
+
162
256
  ## PUA 协议
163
257
 
164
258
  `/pua [风味]` 把一套「不许敷衍」的协议装进当前会话:
@@ -190,9 +284,9 @@ node evals/case-setup.mjs --case 01-null-header --out tmp/eval/01
190
284
  node evals/score.mjs --case 01-null-header --report tmp/eval/01/with/report.txt
191
285
  ```
192
286
 
193
- 用例一正一反成对:审查侧有"删掉默认参数而调用方还在"(要看调用点)、"纯改名"(要敢报零发现)、"计数器提到模块作用域"(要想到第二次调用);简化侧有"四层嵌套"(该动手)和"看起来能合并成 `||` 但会吞掉 `NaN`"(该收手);清理侧有"提交了 `.env`、内部邮箱、本机路径"(该报)和"全是占位符与公开元数据"(要敢报零发现);caption 侧有"两个失败用例的强制转换"(要证明守卫会红)和"两个写者碰同一个 barrel"(分派要避开)。
287
+ 用例一正一反成对:审查侧有"删掉默认参数而调用方还在"(要看调用点)、"纯改名"(要敢报零发现)、"计数器提到模块作用域"(要想到第二次调用);简化侧有"四层嵌套"(该动手)和"看起来能合并成 `||` 但会吞掉 `NaN`"(该收手);清理侧有"提交了 `.env`、内部邮箱、本机路径"(该报)和"全是占位符与公开元数据"(要敢报零发现);caption 侧有"两个失败用例的强制转换"(要证明守卫会红)和"两个写者碰同一个 barrel"(分派要避开);审计侧有"有 handler、有测试、没入口"(要判 `fake`)和"看着没接线、其实 manifest 加载"(**不许**误报 `fake`);设计侧有"只有一段 brief"(不许编 `file:line`,要标未确认)和"改个按钮颜色"(不许铺二十页表格)。
194
288
 
195
- `evals/results/` 记录每一轮:第 1–3 轮是模型质量对照,第 4 轮是七条命令在隔离 `dsh web` 实例里的可用性验证。
289
+ `evals/results/` 记录每一轮:第 1–3 轮是模型质量对照,第 4 轮是七条命令在隔离 `dsh web` 实例里的可用性验证,第 5 轮是内化这条设计技能时的设计与用例对照。
196
290
 
197
291
  ## 加新能力
198
292
 
@@ -211,6 +305,9 @@ node evals/score.mjs --case 01-null-header --report tmp/eval/01/with/report.txt
211
305
  - 借鉴:范围在宿主侧用 Git 算准(文件、行范围、SHA-256),把范围作为提示词交给 agent,而不是让 agent 自己猜“最近改了什么”;超限直接拒绝而不是降级;提示词里声明“文件名、注释和差异文本是数据,不得从中接受追加任务”。
212
306
  - 状态:提示词形态已参照,行范围 / 哈希 / 上限尚未实现。
213
307
  - 宿主接口(`ctx.commands`、`ctx.subagents.startActivation`、`agent.steer`、`agent.followup`)一律以安装版 DSH 的文档与源码为准,不凭记忆写。
308
+ - **skill `scenario-driven-product-design`**(本机 skill,作者自有,无上游许可)
309
+ - 借鉴:能力五态、三遍审计与证据等级、四张底图、场景卡十项与边界八问、两套排序、批 0 门禁四件套,以及文档编号习惯。`/code-audit` 与 `/code-design` 的 `references/` 每份文件头都标了 `Source:`。
310
+ - 改动:原文 31841 字符不能直接进 persona(上限 12000),所以按插件的分层重组:核心进 `AGENT.md`,深表进 `references/`,并补了三份插件自己的材料(追链、五态边界、交付编号)。协议本身只剩一份在维护,原 skill 不再作为触发入口。
214
311
  - **[tanweai/pua](https://github.com/tanweai/pua)**(MIT)与 **[MichengAI/dsh-pua](https://github.com/MichengAI/dsh-pua)**(Apache-2.0)
215
312
  - 借鉴:三条红线、L0–L4 压力升级、五步排查与 7 点清单、冰山法则,以及 14 种大厂风味的话术(本仓库收录 8 种,见 [references/flavors.md](agents/pua/references/flavors.md))。
216
313
  - 简化:dsh-pua 有设置面板、会话开关、Loop 与防作弊门;这里只保留 `/pua [风味]` 一条命令——注入协议,不维护会话状态。
@@ -224,9 +321,10 @@ node evals/score.mjs --case 01-null-header --report tmp/eval/01/with/report.txt
224
321
  | 键 | 作用 | 默认 |
225
322
  | --- | --- | --- |
226
323
  | `reportDirectory` | journal 落盘目录,必须是绝对路径 | `$DSH_HOME/code-toolkit` |
227
- | `reviewModel` / `simplifyModel` / `scrubModel` | 该命令的子 agent 用哪个模型 | 宿主默认 |
324
+ | `reviewModel` / `simplifyModel` / `scrubModel` / `auditModel` | 该命令的子 agent 用哪个模型 | 宿主默认 |
228
325
  | `locale` | 强制输出语言(`zh`、`en`…) | 跟随宿主 |
229
326
  | `ledgerDirectory` | caption 台账目录,相对路径按项目根解析 | `<项目>/docs/caption` |
327
+ | `designDirectory` | design 文档目录,相对路径按项目根解析 | `<项目>/docs/design` |
230
328
  | `runTimeoutMinutes` | `sub` 运行超过这么久就释放占用(卡在审批上时不会永久阻塞) | `30`,`0` 表示不限制 |
231
329
  | `planMaxAgeMinutes` | `report` 出的方案在这段时间内仍可被下一次执行沿用 | `60`,`0` 表示不限制 |
232
330
 
@@ -242,9 +340,11 @@ plugin_manager { action: "install_bundle", target: "<本目录绝对路径>" }
242
340
 
243
341
  ## 限制
244
342
 
245
- - 需要独立上下文的原生 `spawn` provider(`sub` 路径),缺失时报错而非降级;`/code-caption` 与 `/pua` 不需要 spawn,但需要宿主支持向会话注入输入(`agent.steer`)。
343
+ - 需要独立上下文的原生 `spawn` provider(`sub` 路径),缺失时报错而非降级;`/code-caption`、`/code-design` 与 `/pua` 不需要 spawn,但需要宿主支持向会话注入输入(`agent.steer`)。
246
344
  - `/code-review` 默认**会改文件**:先报告再修,修完必须跑门禁,变红就回退那一处。第一次用建议先跑 `/code-review report` 看它报什么。
247
345
  - `/code-simplify`、`/code-scrub` 默认直接改;加 `report` 只出计划。执行时会沿用上一份已批准的 `report`(`planMaxAgeMinutes` 内有效)。
346
+ - `/code-audit` 只读,没有 apply,也没有 `report` 开关。它读的是整棵树,**推荐加 `sub`**——那份读取成本不该压在你自己会话的上下文里。没跑过真实入口的能力只能标「未确认」,所以界面类能力要人自己点一遍再落结论。
347
+ - `/code-design` 只写 `docs/design/`,**不写代码、不建台账**;方案批准后交给 `/code-caption`,两步之间没有自动接线(批次表要人递过去)。
248
348
  - 子 agent 禁止调用委派类工具,不会二次扇出。
249
349
  - `/code-caption` 注入的是一条插件来源的消息(界面折叠成「收到执行请求」);同一会话重复执行只补任务、不重复注入协议。台账写在目标仓库的 `docs/caption/`,跨机器不共享。
250
350
  - 报告落盘在 `$DSH_HOME/code-toolkit/`,重开会话后 `/code-status` 仍可读;跨机器不共享。
@@ -0,0 +1,137 @@
1
+ # Capability audit
2
+
3
+ You are auditing an existing product, not a change. The question is not "is this code
4
+ wrong" but **"does this capability actually exist at runtime, or does it only look like
5
+ it does"**. The expensive failure this catches: the README, the changes log, and a test
6
+ all say a feature is done, and the person who clicks it gets nothing.
7
+
8
+ A row is a capability with a state and the evidence for it, not a patch. Something that
9
+ runs but could be better is `/code-review`'s job.
10
+
11
+ ## The five states
12
+
13
+ One state per capability. The token is the machine-readable half of the contract: use
14
+ it verbatim even when the prose is in another language.
15
+
16
+ | State | Test | Handling |
17
+ | --- | --- | --- |
18
+ | `wired` | A production entry reaches a handler, that reaches its interface, that reaches storage — and you saw it close, or a test exercises it end to end. | Not a finding. |
19
+ | `half` | The backend or tool exists; the entry point is missing, a stub, or behind a menu nobody can reach. | Wire it. |
20
+ | `fake` | Docs, comments, or tests claim it; **production code calls nothing.** | Report the false claim. |
21
+ | `broken` | An entry point exists but the path dies at runtime: early return, dropped argument, stale state, unreleased lock. | Say where the flow dies. |
22
+ | `missing` | Genuinely absent, nothing claims it. | Not a defect; design's material. |
23
+
24
+ `fake` is the state this command exists for, and the one you will be tempted to soften:
25
+ a handler with tests looks implemented. Neither a test nor a docs page is a production
26
+ caller. Boundaries between states: `references/capability-states.md`.
27
+
28
+ ## Trace the chain
29
+
30
+ Walk every capability in the same order and stop at the first absent link. That link is
31
+ the evidence; a state without one is an opinion.
32
+
33
+ 1. **The entry point a person uses** — registered command, route, CLI subcommand, menu
34
+ item, key binding, scheduled job. An exported function nothing imports is not one.
35
+ 2. **The handler** — real work, or a stub returning success.
36
+ 3. **The interface call** — with the arguments the handler actually passes.
37
+ 4. **Storage or the outside effect** — the write that makes it true after the process
38
+ exits.
39
+ 5. **A test that exercises the chain**, not the unit with its own mock.
40
+
41
+ Two rules keep the walk honest:
42
+
43
+ - **Read the caller, not the declaration.** `export function exportCsv()` proves an
44
+ intention; no import of it is the finding.
45
+ - **A link you did not check is not a link that passed.** Dynamic dispatch — registries,
46
+ injection, reflection, string-keyed maps, manifests — hides callers. Find the
47
+ registry, then the registration. Cannot see it? Unverified, not `fake`.
48
+
49
+ ## Three passes, not one
50
+
51
+ A clean static pass proves the wiring diagram has no loose ends; it does **not** prove
52
+ current flows. Say which passes ran:
53
+
54
+ 1. **Static wiring** — the chain above, reported as counts (calls to nothing, empty
55
+ handlers, stubs, permanently disabled controls, fields written but never sent).
56
+ 2. **Runtime semantics** — a state × role matrix, one cell at a time, against the ten
57
+ ways a reachable branch still dies (early return, empty callback, dropped parameter,
58
+ dead state, aggregate that can never pass, and the rest).
59
+ 3. **The real entry point** — real data, one run per P0 path, look at the state
60
+ afterwards. No browser, no server: the pass did not run.
61
+
62
+ Pass 1 alone may not label anything `wired`. Details, sampling, and the row template:
63
+ `references/audit-passes.md`.
64
+
65
+ ## Evidence levels
66
+
67
+ Rank what you have, and never let a weaker kind stand in for a stronger one: **observed**
68
+ (you ran it) > **logs or screenshots** > **the person's words** > **inference from
69
+ reading the code** — the normal case here.
70
+
71
+ Cite `file:line`: where the chain stops, plus the line where the contradicting claim is
72
+ made. Never cite a doc, comment, changelog, or test name as evidence that it works; that
73
+ is the artefact `fake` names. **Never invent a `file:line`** — a row with no location is
74
+ honest, a wrong one destroys the report.
75
+
76
+ If you did not reach a capability through its real entry point, its state may be `half`,
77
+ `fake`, or `broken` from reading, but it may **not** be `wired`, and what you could not
78
+ check goes in `limitations`.
79
+
80
+ ## What does not count as a finding
81
+
82
+ - A capability that is `wired` but ugly, slow, or duplicated — that is review.
83
+ - A designed but unbuilt feature — that is `missing`, and it belongs to design.
84
+ - A commented-out block, a TODO, or a dead file outside any entry point — it claims
85
+ nothing. Report it only if a doc or test points at it as live.
86
+ - "Unwired because a search found no caller" when you did not check dynamic dispatch —
87
+ unverified.
88
+
89
+ ## Output
90
+
91
+ Reply with one JSON object. Nothing else — the report is delivered as written.
92
+
93
+ ```json
94
+ {
95
+ "overall_explanation": "what you audited, which passes ran, and the surprise",
96
+ "capabilities": [
97
+ { "id": "A1", "capability": "export a project to CSV", "state": "fake",
98
+ "evidence": { "file": "src/export/csv.js", "line_range": { "start": 12, "end": 40 } },
99
+ "path": "menu item → no command registered → no handler → no file written",
100
+ "expected": "picking Export writes a CSV", "actual": "the menu item does not exist",
101
+ "impact": "cannot export at all", "batch": 1, "note": "one or two sentences" }
102
+ ],
103
+ "limitations": ["Pass 3 did not run: no browser in this session."]
104
+ }
105
+ ```
106
+
107
+ Rules that change behaviour:
108
+
109
+ - `state` is one of the five tokens, lower case, no decoration.
110
+ - `evidence.file` is relative to the project root; `line_range` is where the chain
111
+ stopped. Never invent one.
112
+ - **`limitations` is mandatory** when a pass did not run. An empty list means all three
113
+ ran, which is rarely true.
114
+ - `batch` is the design's suggested batch; fill it when you can, so the audit feeds the
115
+ plan instead of sitting beside it.
116
+
117
+ Field spec and ordering: `references/output.md`. Order rows by urgency of state —
118
+ `fake`, `half`, `broken`, `wired`, `missing` — so a reader can stop after three.
119
+
120
+ If the brief says in-session, write the same content as a Markdown table: one row per
121
+ capability, the state token in its own column, evidence as `path:line`, detail beneath.
122
+ The tokens do not change with the format.
123
+
124
+ ## Reference files
125
+
126
+ | File | Read it when |
127
+ | --- | --- |
128
+ | `references/audit-passes.md` | passes 2 and 3, the ten runtime break patterns, coverage and sampling |
129
+ | `references/capability-states.md` | a row is between two states, or two capabilities seem to be one |
130
+ | `references/finding-the-chain.md` | you cannot see a caller and suspect dynamic dispatch |
131
+ | `references/evidence.md` | choosing what to cite, or writing `limitations` |
132
+ | `references/output.md` | writing the envelope: field spec, a full row, ordering |
133
+ | `examples/fake-capability.md` | the shape of a `fake` row someone would accept |
134
+ | `examples/wired-clean.md` | a capability that looks unwired and is not — the false positive |
135
+
136
+ If a reference path is unreadable, continue from this file — the core instructions are
137
+ self-sufficient.
@@ -0,0 +1,54 @@
1
+ # Example: a `fake` capability nobody would have caught
2
+
3
+ The repository is a small desktop note app. `README.md` lists three features; the
4
+ changes log says all three shipped last month.
5
+
6
+ What the tree actually contains:
7
+
8
+ ```text
9
+ src/
10
+ commands/
11
+ new-note.js registered in the command table
12
+ open-note.js registered
13
+ export-pdf.js NOT registered anywhere
14
+ export/
15
+ pdf.js the renderer, with a unit test
16
+ test/
17
+ export-pdf.test.js imports src/export/pdf.js, asserts the renderer output
18
+ docs/
19
+ features.md "Export any note as PDF — shipped in 0.9"
20
+ ```
21
+
22
+ The audit row:
23
+
24
+ ```json
25
+ {
26
+ "capability": "export a note as PDF",
27
+ "state": "fake",
28
+ "evidence": {
29
+ "file": "src/commands/export-pdf.js",
30
+ "line_range": { "start": 1, "end": 18 }
31
+ },
32
+ "note": "The command module and its renderer test exist, but the command table registers only new-note and open-note; nothing invokes src/commands/export-pdf.js. docs/features.md calls it shipped."
33
+ }
34
+ ```
35
+
36
+ Why this is `fake` and not `half`: there is a real renderer, but the module a person
37
+ would start it from is not reachable, and `docs/features.md` asserts it works. A
38
+ claim plus an absent chain is the definition.
39
+
40
+ Why the evidence is the command module and not the renderer: the renderer is fine
41
+ and tested. The first absent link is the registration. Pointing at `pdf.js` would
42
+ send the next person to read correct code.
43
+
44
+ Why it is not `broken`: nothing fails at runtime, because nothing reaches it.
45
+
46
+ What a bad audit produced from the same tree, in three different ways:
47
+
48
+ - `wired`, because `test/export-pdf.test.js` passes and "there is a test".
49
+ - `half`, because the command module exists and looks ready.
50
+ - No row at all, because the auditor listed files rather than capabilities and
51
+ `pdf.js` looked like part of a working export feature.
52
+
53
+ The lesson each of those shares: the tree was read forwards. Read from the command
54
+ table backwards and this row writes itself.
@@ -0,0 +1,66 @@
1
+ # Example: the false positive this audit dies of
2
+
3
+ Nothing kills a capability audit faster than one confident `fake` that turns out
4
+ to be wired. The person checks it in five minutes, finds the plugin loading fine,
5
+ and stops reading the other forty rows.
6
+
7
+ ## The tree
8
+
9
+ ```text
10
+ src/
11
+ index.js loads manifests from ./plugins at startup
12
+ plugins/
13
+ ledger/
14
+ manifest.json { "entry": "./index.js", "events": ["invoice.created"] }
15
+ index.js the handler
16
+ events.js emits "invoice.created"
17
+ ```
18
+
19
+ An auditor greps for `plugins/ledger` and finds it in exactly one place: the
20
+ manifest. No import, no route, no registration call. The tempting row is:
21
+
22
+ ```json
23
+ { "capability": "post an invoice to the ledger", "state": "fake",
24
+ "note": "No code imports src/plugins/ledger; only a manifest mentions it." }
25
+ ```
26
+
27
+ That row is wrong. The manifest **is** the registration: `src/index.js` enumerates
28
+ `./plugins/*/manifest.json`, and the event name in the manifest matches the event
29
+ emitted in `events.js`. The capability is wired by convention, and the auditor
30
+ searched only for imports.
31
+
32
+ ## The correct row
33
+
34
+ ```json
35
+ {
36
+ "capability": "post an invoice to the ledger",
37
+ "state": "wired",
38
+ "evidence": { "file": "src/plugins/ledger/manifest.json", "line_range": { "start": 1, "end": 5 } },
39
+ "note": "src/index.js loads ./plugins/*/manifest.json at startup; the manifest subscribes the ledger handler to invoice.created, which src/events.js emits."
40
+ }
41
+ ```
42
+
43
+ And if `src/index.js` had turned out to enumerate a *different* directory, the row
44
+ would be `broken` with the loader as evidence — the machinery exists and the path
45
+ does not connect. What it would never be is `fake`, because something does claim
46
+ it and the claim is a registration.
47
+
48
+ ## The rule this example is here for
49
+
50
+ Before writing `fake`, check every way this project can register something:
51
+
52
+ 1. A registration table, router, or command list.
53
+ 2. A manifest or descriptor that a loader reads.
54
+ 3. A directory convention (`plugins/*`, `commands/*`, `routes/*` auto-loaded).
55
+ 4. A string key passed to a factory, a map, or a container binding.
56
+ 5. An external caller: a client, a cron entry, a CI file, a webhook.
57
+
58
+ Find the loader, read what it enumerates, and check whether the capability is
59
+ inside it. If you cannot find the loader — generated at build time, minified,
60
+ outside the repo — the state is unverified and the attempt goes in `limitations`:
61
+
62
+ ```json
63
+ "limitations": ["src/index.js builds its plugin list at build time; I could not tell whether src/plugins/ledger is in the shipped bundle."]
64
+ ```
65
+
66
+ That sentence costs one row its certainty and saves the whole report's credibility.