@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
@@ -0,0 +1,118 @@
1
+ # Three passes, and the ten ways a chain dies at runtime
2
+
3
+ Source: adapted from the local skill `scenario-driven-product-design`
4
+ (`references/audit-and-evidence.md`: 为什么静态扫描不够, 三遍审计, 十种高频断法,
5
+ 覆盖与抽样, 审计产出模板), user-authored, no upstream licence.
6
+
7
+ ## Why one pass is not an audit
8
+
9
+ A real project was scanned statically and came back clean:
10
+
11
+ | Static check | Result |
12
+ | --- | --- |
13
+ | Calls to an RPC the host does not have | 0 |
14
+ | Buttons bound to a missing handler | 0 |
15
+ | Empty stubs (TODO / not implemented) | 0 |
16
+ | Permanently disabled controls | 5, all with an explanatory title |
17
+
18
+ It still had **seven P0 runtime breakpoints**: a click that did nothing, a capability
19
+ that did not exist, data posted to the wrong team, a confirmation that dropped its
20
+ parameters.
21
+
22
+ The scanner asks "does the name exist". It cannot ask "is the branch reachable".
23
+ That is why the audit is three passes, in this order, and why a clean first pass is
24
+ not a result.
25
+
26
+ ## Pass 1 — static wiring
27
+
28
+ Follow the chain: entry point → handler → interface → effect → test. The links and
29
+ the rules are in the "Trace the chain" section of `AGENT.md`.
30
+
31
+ Record what this pass found, as counts, because the numbers are what keeps the report
32
+ honest:
33
+
34
+ | Check | Count | Note |
35
+ | --- | --- | --- |
36
+ | Call to something that does not exist | | client/entry has it, the other side does not |
37
+ | Handler missing or empty | | declared, but the body does nothing |
38
+ | Empty stub | | TODO / not implemented / returns success unconditionally |
39
+ | Permanently disabled | | each one needs a title saying why |
40
+ | Written but never sent | | a field that never reaches the request or the prompt |
41
+
42
+ **Zero findings here proves the wiring diagram has no loose ends. It does not prove
43
+ current flows.** Say exactly that in the report, and continue.
44
+
45
+ ## Pass 2 — runtime semantics
46
+
47
+ Build a matrix first, then read one cell at a time:
48
+
49
+ - rows: the states the product actually has (`draft` / `active` / `in_progress` /
50
+ `blocked` / `archived` / `offline` — whatever this product uses);
51
+ - columns: the roles that act on it;
52
+ - cell: the entry point, the branches, and the expected result.
53
+
54
+ The ten ways a chain dies inside a reachable branch:
55
+
56
+ | # | Break | How to find it |
57
+ | --- | --- | --- |
58
+ | 1 | An early `return` makes later UI unreachable | list every return branch for the same state |
59
+ | 2 | Empty implementation | search empty function bodies and empty `useCallback(() => {}, [])` |
60
+ | 3 | A confirmation drops parameters | compare the first call's arguments with the second's |
61
+ | 4 | Permanently disabled | search `disabled` and for the control that would write the enabling field |
62
+ | 5 | Dead state | the event table against the state machine: is there any event that writes this state |
63
+ | 6 | Parameter discarded | follow a form field through render → request body → prompt, one segment at a time |
64
+ | 7 | Aggregate that can never pass | a gate computed as `every(pass)` while some rows are `pending` |
65
+ | 8 | Time or randomness inside a cached view | search `Date.now()` / `Math.random()` in anything cached or derived |
66
+ | 9 | Stale verdict or snapshot | does a new attempt clear the previous attempt's results |
67
+ | 10 | Error code swallowed | does `catch` re-throw the domain error or flatten it into "internal error" |
68
+
69
+ Two more that only appear when things actually run:
70
+
71
+ - **Ordering**: autosave and undo racing each other; the saved document still shows
72
+ the previous text.
73
+ - **Concurrency**: two roles editing one row with no version or optimistic lock.
74
+
75
+ ## Pass 3 — the real entry point
76
+
77
+ - **Real data**, not only fixtures: a real document, a real ledger, a project with
78
+ history.
79
+ - **Real clicks**: at least one per P0 path. Watch the toast, the ledger, and whether
80
+ the state actually changed.
81
+ - **Real rendering**: every screen in light and dark; record console errors, image
82
+ loads, truncated text.
83
+ - **Record**: what was clicked, what was expected, what happened, where the evidence
84
+ is.
85
+
86
+ A pass you could not run — no GUI, no token, no device — is **not run**. Say so; do
87
+ not convert it into "confirmed".
88
+
89
+ ## Coverage and sampling
90
+
91
+ Full coverage is rarely possible and never has to be claimed:
92
+
93
+ - P0 paths: all of them.
94
+ - P1: sample, but every role gets at least one complete path.
95
+ - Every stage (enter / create / run / intervene / close / look back): at least one.
96
+ - Every failure branch (permission denied, upstream cancelled, crash recovery): at
97
+ least one.
98
+ - Many screens: every entry point, one main path per role, plus the failure branches
99
+ the plan names. The rest is marked **not audited**.
100
+
101
+ End the report with what was audited and what was not, so a reader cannot mistake the
102
+ first for the whole.
103
+
104
+ ## The row
105
+
106
+ One row per capability, with enough to act on without reopening the repository:
107
+
108
+ ```text
109
+ | ID | Capability | Role | Path | Expected | Actual | State | Evidence | Impact | Batch |
110
+ ```
111
+
112
+ - **Path** is the walk, including where it stopped:
113
+ `button → handler → (empty callback) → no request → no state change`.
114
+ - **Impact** is what the person cannot do, in their words: "cannot create or edit a
115
+ role from the settings page".
116
+ - **Batch** is the design's suggested batch number, or empty. Filling it is what lets
117
+ the audit feed the plan instead of sitting beside it.
118
+ - **ID** is stable (`A1`, `A2`…) so a later audit can say "A7 is now wired".
@@ -0,0 +1,96 @@
1
+ # The five states, in detail
2
+
3
+ Source: adapted from the local skill `scenario-driven-product-design`
4
+ (`references/audit-and-evidence.md`), user-authored, no upstream licence; rewritten
5
+ for this plugin's output contract. The state names are that skill's 通/半/假/断/无.
6
+
7
+ The summary in `AGENT.md` is enough to label an obvious row. This file is for the
8
+ rows that sit between two states, which is where an audit is worth reading.
9
+
10
+ ## Choosing between two neighbouring states
11
+
12
+ **`fake` vs `missing`.** The difference is a claim, not code. If a doc, a comment,
13
+ a changelog, a menu label, or a test asserts the capability and the production
14
+ chain is absent, it is `fake` — the cost is that somebody is counting on it. If
15
+ nothing claims it, it is `missing`, and it is design's material rather than a
16
+ defect. Never downgrade a false claim to `missing`: that erases the very thing the
17
+ audit found.
18
+
19
+ **`half` vs `broken`.** Both have a real entry point. Ask whether the missing part
20
+ is *absent* or *present but wrong*: a handler that was never called from anywhere
21
+ is `half`; a handler that is called, with the wrong argument or behind an early
22
+ return, is `broken`. `half` means "wire it"; `broken` means "repair the flow".
23
+
24
+ **`half` vs `fake`.** Is there production code that *does the job*? A handler with
25
+ logic and a test, reachable only through nothing, is `half`. A stub that returns
26
+ `{ ok: true }`, or an exported function nothing imports, is `fake` — no work
27
+ exists behind the claim.
28
+
29
+ **`wired` vs `half`.** One test decides most cases: is there a test that goes red
30
+ when you break the chain? No test is not automatically `half` — a small project can
31
+ be honestly wired without one — but it does mean you must have seen the chain
32
+ yourself, and if you did not, the state is unverified rather than `wired`.
33
+
34
+ **`broken` vs a normal bug.** A bug in a path that runs is review material. `broken`
35
+ is reserved for the capability being unreachable or permanently wrong: the branch
36
+ that always returns early, the state that never leaves `draft`, the queue consumer
37
+ that was never registered.
38
+
39
+ ## Granularity: what counts as one capability
40
+
41
+ A capability is a unit a person would ask for and could be told "yes" or "no"
42
+ about. Choose the level where the answer is meaningful:
43
+
44
+ - Too coarse: "the editor". Every project has a dozen states inside it.
45
+ - Too fine: "the save icon". Its state is the state of "save a document".
46
+ - Right: "save a document locally", "share a document with a teammate", "restore a
47
+ deleted document".
48
+
49
+ Two signs you have split it wrongly:
50
+
51
+ - **Two rows always share a state.** They are one capability; merge them.
52
+ - **One row needs "except".** It is two capabilities; split it (the exception is
53
+ where the states differ).
54
+
55
+ Contexts that share a handler but differ in an entry point are separate rows only
56
+ when they can independently fail — a command and its keyboard shortcut share the
57
+ same chain, so they are one row; a desktop app and its mobile client do not.
58
+
59
+ ## What a state is not
60
+
61
+ - **Not a priority.** A `fake` capability nobody wants is still `fake`; the design
62
+ decides whether it is worth building. Do not encode "important" into the state.
63
+ - **Not a measure of quality.** `wired` says the chain closes, not that the code
64
+ is good.
65
+ - **Not permanent.** Record the evidence you have now. The next audit re-labels;
66
+ that is the point of a fixed vocabulary.
67
+
68
+ ## The five searches that decide the label
69
+
70
+ Do these in order. Each one narrows the state without needing to read the whole tree
71
+ twice:
72
+
73
+ 1. **Production directories**, symbol only — exclude tests and comments. A hit here
74
+ means the code exists; it says nothing about reachability.
75
+ 2. **Test directories**, same symbol. If the only caller is a test, the capability is
76
+ `fake` or `half` no matter how green the suite is — the test is exercising the
77
+ module, not the feature.
78
+ 3. **The entry module / registration table**, by name. This is where `fake` and
79
+ `half` separate: present in the table with a real handler is `half` at worst;
80
+ absent from every registration path is `fake`.
81
+ 4. **Walk the entry**: control or command → handler → interface call. An empty
82
+ callback or a handler that returns success without calling anything is `broken`
83
+ even though every name exists.
84
+ 5. **Run the real path once** if you can. Only this turns the other four into
85
+ `wired`; without it the ceiling is "the chain looks closed".
86
+
87
+ Comments and docs are not searched as evidence at any step. A name in a comment is
88
+ not a caller; that is the specific artefact `fake` describes.
89
+
90
+ ## Recording the trail
91
+
92
+ Each row needs the first absent link, not the last one you looked at. If the entry
93
+ point is missing, say that and stop — do not also report the missing interface,
94
+ because there is nothing yet for an interface to serve. A row whose evidence is the
95
+ *furthest* link reads as a design note; a row whose evidence is the *first* absent
96
+ link reads as a defect.
@@ -0,0 +1,86 @@
1
+ # Evidence, and the word "unverified"
2
+
3
+ Source: adapted from the local skill `scenario-driven-product-design`
4
+ (`references/audit-and-evidence.md`, evidence tiers and the red-flag list),
5
+ user-authored, no upstream licence.
6
+
7
+ An audit is a set of claims about a codebase. This file is about the citation and
8
+ the escape hatch: what may be cited for which state, and how to say "I did not
9
+ check" without making the report useless.
10
+
11
+ ## The four tiers
12
+
13
+ | Tier | What it is | What it can support |
14
+ | --- | --- | --- |
15
+ | Observed | you ran the entry point and saw the result | any state |
16
+ | Recorded | logs, screenshots, an issue with a reproduction | `fake`, `broken` confidently; `wired` if the record is recent and complete |
17
+ | Reported | the person says it does not work | `broken` or `fake` as a lead, to be confirmed by reading |
18
+ | Read | you traced the code and stopped at a link | `half`, `fake`, `broken`; **not** `wired` |
19
+
20
+ The last row is the one to keep in mind: reading can prove the chain is broken, but
21
+ it cannot prove the chain runs. That asymmetry is why `wired` demands a test or a
22
+ run, and everything else does not.
23
+
24
+ ## What may never be cited as implementation
25
+
26
+ - a README section, a docs page, a changelog entry
27
+ - a code comment, a JSDoc block, a TODO
28
+ - a test name, or a test that mocks the layer it should exercise
29
+ - a menu label, a type definition, an exported signature with no caller
30
+ - a config value nothing reads
31
+
32
+ These are **claims**. A claim is exactly what a `fake` row is built on, so citing
33
+ one as evidence inverts the report: the row says "docs say it works, so it works"
34
+ while the state it should carry is `fake`.
35
+
36
+ When a doc does claim it and the chain is absent, cite both: the line where the
37
+ chain stops, and the line where the claim is made. The pair is what makes the row
38
+ actionable — removing the claim is cheaper than building the feature, and often
39
+ the right first move.
40
+
41
+ ## Citing precisely
42
+
43
+ - Path relative to the project root; line range around the decisive statement, not
44
+ the top of the file.
45
+ - One location per row. If the evidence spans two files, cite the one where the
46
+ chain stops and put the other in `note`.
47
+ - A row with no location is acceptable for `missing` and for a capability you only
48
+ heard about. A row with a *guessed* location is not: one invented line makes
49
+ every other citation suspect, and the next person will stop trusting the table.
50
+ - Quote at most a fragment in `note`. The reader can open the file; the note is for
51
+ the reasoning, not the code.
52
+
53
+ ## Limitations
54
+
55
+ `limitations` is mandatory whenever the run could not reach a real entry point.
56
+ Write what you could not do and why, in a form the next run can act on:
57
+
58
+ - "No browser: the export button and the settings screen were judged from the
59
+ router and its handler only."
60
+ - "Two capabilities are behind a feature flag whose value is set per deployment;
61
+ the repository shows both branches, not which one ships."
62
+ - "The registry is generated at build time; I could not tell whether
63
+ `src/export/csv.js` is in it."
64
+
65
+ Three habits that keep the list useful:
66
+
67
+ 1. **Name the capability, not the wish.** "Could not verify S3 upload" beats "some
68
+ things not verified".
69
+ 2. **Say what would settle it.** A run, a file, a person to ask. That sentence is
70
+ the cheapest handoff you can write.
71
+ 3. **Never let it grow silently.** If half the rows are unverified, say that in
72
+ `overall_explanation` — a table that is mostly inference should be read as a
73
+ hypothesis, and the person must know that before they act on it.
74
+
75
+ ## Red flags that usually mean `fake`
76
+
77
+ - a handler registered nowhere, but referenced by a test
78
+ - a screen described in `docs/` that the router does not have
79
+ - a feature flag read by nothing, or always false
80
+ - an interface method with one implementation and no caller
81
+ - a migration or job that no scheduler names
82
+ - an `.env.example` key that no code reads
83
+
84
+ None of these is proof on its own — a convention-based loader, a manifest, or an
85
+ external caller can make each of them real. They are the places to look first, not
86
+ conclusions to write down.
@@ -0,0 +1,80 @@
1
+ # Finding the chain
2
+
3
+ Source: this plugin's own method; the dynamic-dispatch hazard and the
4
+ "read the caller, not the declaration" rule are adapted from the local skill
5
+ `scenario-driven-product-design` (`references/audit-and-evidence.md`),
6
+ user-authored, no upstream licence.
7
+
8
+ Most wrong audit rows come from one mistake: a search found nothing, and the
9
+ absence was reported as a fact. This file is about turning "I could not find it"
10
+ into either a proven absence or an honest `limitations` entry.
11
+
12
+ ## The five link shapes
13
+
14
+ The chain has the same shape everywhere; only the names change.
15
+
16
+ | Link | Common forms |
17
+ | --- | --- |
18
+ | Entry point | slash command, HTTP route, CLI subcommand, menu item, keybinding, scheduled job, event listener on an external event |
19
+ | Handler | the function the entry point invokes: controller, command handler, action, reducer |
20
+ | Interface | service method, client call, job enqueue, IPC message |
21
+ | Effect | database write, file write, outbound request, emitted event |
22
+ | Test | one that breaks when any link above breaks |
23
+
24
+ Find the entry-point registry first. Every framework has one, and it is usually a
25
+ short file: the command table, the router, the CLI parser, the listener
26
+ registration. Read it and you have the complete list of things a person can
27
+ actually start. Then walk *backwards* from it: for each registration, follow the
28
+ handler. Walking backwards is faster and cannot miss a dead handler.
29
+
30
+ ## Dynamic dispatch
31
+
32
+ A plain search misses these, so check each one that the project uses:
33
+
34
+ - **String keys**: `handlers[name]`, `pluginId -> module`, a map built from a
35
+ directory listing.
36
+ - **Convention over registration**: files under `commands/` auto-loaded, routes
37
+ generated from a folder. If so, the folder *is* the registry — list it.
38
+ - **Dependency injection**: a container binding a token to a class, resolved at
39
+ call time.
40
+ - **Manifests**: `package.json`, a plugin descriptor, a config file naming the
41
+ module. The manifest is the caller.
42
+ - **Reflection and `eval`-like loading**: rare, but then read the config that feeds
43
+ it.
44
+
45
+ If the capability's key appears in one of these, follow it to the registration
46
+ before you label anything. A capability registered in a manifest and loaded by
47
+ convention is `wired`; a file sitting in the folder with no manifest entry may be
48
+ `half` or `fake`, and which one depends on whether the loader would pick it up.
49
+
50
+ ## Crossing a boundary
51
+
52
+ When the chain crosses a process or a network edge — a desktop app calling a local
53
+ server, a client calling an API, a worker pulling a queue — audit the two sides
54
+ separately and say so:
55
+
56
+ - The client registers a call but the server has no route → the row is `broken`,
57
+ and the evidence is the missing route.
58
+ - The server has a route nobody calls → `half` on the client side.
59
+ - Both exist but the contract disagrees (field names, auth, units) → `broken`, and
60
+ cite the two lines that disagree.
61
+
62
+ Do not label a distributed chain `wired` from one side alone. If you only read the
63
+ server, the state is unverified.
64
+
65
+ ## Proving an absence
66
+
67
+ An absence is a claim like any other; give it the same treatment.
68
+
69
+ 1. Search the identifier, not the concept: the exported name, the route path, the
70
+ config key — then the registration table by hand.
71
+ 2. Search for the *dynamic* forms above.
72
+ 3. Look at the test that supposedly covers it; if it imports the module directly,
73
+ the test is not a caller either.
74
+ 4. Write the negative result precisely: "no command, route, or manifest registers
75
+ `src/export/csv.js`" is a finding. "I did not see it used" is not.
76
+
77
+ If step 2 could not be completed — you could not find the registry, the loader is
78
+ generated, the bundle is minified — then the honest row is unverified, with the
79
+ attempt in `limitations`. That is a better outcome than a confident `fake` that
80
+ the next person disproves in five minutes.
@@ -0,0 +1,66 @@
1
+ # The audit envelope, field by field
2
+
3
+ Source: this plugin's own contract, shaped by the local skill
4
+ `scenario-driven-product-design` (`references/audit-and-evidence.md`, 审计产出模板),
5
+ user-authored, no upstream licence.
6
+
7
+ `AGENT.md` carries the shape and the rules that change behaviour. This file carries
8
+ the field spec you need while writing the JSON, plus a full row.
9
+
10
+ ## Shape
11
+
12
+ ```json
13
+ {
14
+ "overall_explanation": "one paragraph",
15
+ "capabilities": [ { … one object per capability … } ],
16
+ "limitations": ["what a pass could not reach, and why"]
17
+ }
18
+ ```
19
+
20
+ Nothing else in the reply — the envelope is delivered as written. Add `findings` only
21
+ for a defect that blocks the audit itself (an unreadable file, a broken checkout).
22
+
23
+ ## A full row
24
+
25
+ ```json
26
+ {
27
+ "id": "A1",
28
+ "capability": "export a project to CSV",
29
+ "state": "fake",
30
+ "evidence": { "file": "src/export/csv.js", "line_range": { "start": 12, "end": 40 } },
31
+ "path": "menu item → no command registered → no handler → no file written",
32
+ "expected": "picking Export writes a CSV next to the project",
33
+ "actual": "the menu item does not exist; the module and its test do",
34
+ "impact": "cannot export at all, although docs/usage.md says it shipped",
35
+ "batch": 1,
36
+ "note": "Read the command table backwards; nothing registers src/export/csv.js."
37
+ }
38
+ ```
39
+
40
+ ## Fields
41
+
42
+ | Field | Rule |
43
+ | --- | --- |
44
+ | `id` | Stable across audits (`A1`, `A2`…). Reuse it for the same capability so a later run can say "A7 is now wired". |
45
+ | `capability` | What a person would ask for, not a module: "export a project to CSV", not "csv module". |
46
+ | `state` | Exactly one of the five tokens, lower case, no decoration. |
47
+ | `evidence.file` | Path relative to the project root — the file where the chain stopped. |
48
+ | `evidence.line_range` | The decisive lines, not the top of the file. |
49
+ | `path` | The walk, including where it stopped. This is what a reader checks first. |
50
+ | `expected` | One line: what the person thinks will happen. |
51
+ | `actual` | One line: what does happen. |
52
+ | `impact` | What the person cannot do, in their words — not "feature incomplete". |
53
+ | `batch` | The design's suggested batch number, or omitted. Filling it lets the audit feed the plan. |
54
+ | `note` | One or two sentences: what you did to check, and the first absent link. No patch proposals. |
55
+
56
+ ## Ordering
57
+
58
+ By urgency of state, not by the tree: `fake` first, then `half`, `broken`, `wired`,
59
+ `missing` last. A reader should be able to stop after the first three rows.
60
+
61
+ ## Markdown mode
62
+
63
+ When the brief says this run is in-session, write the same content as Markdown: a
64
+ table with one row per capability, the state token in its own column, evidence as
65
+ `path:line`, and the detail block under it. The tokens do not change with the format
66
+ — they are what the reader sorts by.