@morning-start/dsh-code-toolkit 0.0.0-stage → 0.27.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.
- package/CHANGELOG.md +375 -0
- package/LICENSE +35 -0
- package/README.md +252 -2
- package/agents/caption/AGENT.md +165 -0
- package/agents/caption/examples/dispatch.md +83 -0
- package/agents/caption/examples/loop.md +66 -0
- package/agents/caption/examples/theater.md +40 -0
- package/agents/caption/references/dispatch.md +128 -0
- package/agents/caption/references/evidence.md +82 -0
- package/agents/caption/references/experts.md +141 -0
- package/agents/caption/references/flows.md +97 -0
- package/agents/caption/references/loop.md +75 -0
- package/agents/pua/AGENT.md +66 -0
- package/agents/pua/examples/run.md +41 -0
- package/agents/pua/references/flavors.md +33 -0
- package/agents/pua/references/methodology.md +32 -0
- package/agents/review/AGENT.md +112 -0
- package/agents/review/examples/clean.md +40 -0
- package/agents/review/examples/findings.md +49 -0
- package/agents/review/references/evidence.md +33 -0
- package/agents/review/references/output.md +59 -0
- package/agents/review/references/rubric.md +43 -0
- package/agents/review/references/severity.md +45 -0
- package/agents/scrub/AGENT.md +130 -0
- package/agents/scrub/examples/clean.md +70 -0
- package/agents/scrub/examples/report.md +66 -0
- package/agents/scrub/references/false-positives.md +92 -0
- package/agents/scrub/references/patterns.md +52 -0
- package/agents/scrub/references/redaction.md +53 -0
- package/agents/simplify/AGENT.md +160 -0
- package/agents/simplify/examples/apply.md +60 -0
- package/agents/simplify/examples/plan.md +65 -0
- package/agents/simplify/references/anti-patterns.md +45 -0
- package/agents/simplify/references/behavior-preservation.md +41 -0
- package/agents/simplify/references/conventions.md +34 -0
- package/agents/simplify/references/operations.md +51 -0
- package/agents/simplify/references/verification.md +74 -0
- package/cordis.patch.yml +23 -0
- package/icon.svg +8 -0
- package/index.js +207 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +62 -4
- package/src/command.js +328 -0
- package/src/delivery.js +48 -0
- package/src/i18n.js +164 -0
- package/src/journal.js +56 -0
- package/src/pua.js +48 -0
- package/src/report.js +202 -0
- package/src/runtime.js +94 -0
- package/src/selection.js +258 -0
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# Dispatch: parallel work without collisions
|
|
2
|
+
|
|
3
|
+
## When parallel actually helps
|
|
4
|
+
|
|
5
|
+
Parallelism pays when the slices can be **decided independently** and their write
|
|
6
|
+
sets are **disjoint**. It does not pay when:
|
|
7
|
+
|
|
8
|
+
- the slices share a file, a schema, or a generated artifact;
|
|
9
|
+
- every slice needs the same gate run (you will run it N+1 times anyway);
|
|
10
|
+
- the work is one coupled change (a rename, a signature change) — that is one
|
|
11
|
+
step, no matter how many files it touches;
|
|
12
|
+
- you would spend more on briefs and merges than on the work.
|
|
13
|
+
|
|
14
|
+
The default is one agent: you. Dispatch is for width, not for speed.
|
|
15
|
+
|
|
16
|
+
## Two lanes
|
|
17
|
+
|
|
18
|
+
### Analysis lane — read-only, fan out freely
|
|
19
|
+
|
|
20
|
+
Use it to answer independent questions in parallel: "how does module A handle
|
|
21
|
+
errors", "which call sites break if B changes", "does the config layer read this
|
|
22
|
+
key". Each agent returns findings with `file:line`, the command or read that
|
|
23
|
+
produced them, and what it could not determine.
|
|
24
|
+
|
|
25
|
+
Rules:
|
|
26
|
+
|
|
27
|
+
- No writes, no `git add`, no formatting. An analysis agent that edits has
|
|
28
|
+
broken the lane.
|
|
29
|
+
- One question per agent; a broad question comes back broad.
|
|
30
|
+
- Findings are inputs, not verdicts: you decide what they mean together.
|
|
31
|
+
|
|
32
|
+
### Build lane — writes, exclusive ownership
|
|
33
|
+
|
|
34
|
+
Use it only when the write sets are disjoint and each slice has its own gate.
|
|
35
|
+
|
|
36
|
+
- Each agent owns an explicit list of paths. Ownership is exclusive for the whole
|
|
37
|
+
dispatch: two agents never touch the same file, even at different times.
|
|
38
|
+
- **Shared files belong to one owner** — normally you: barrels and index files,
|
|
39
|
+
package manifests, lockfiles, config, shared test helpers, generated code.
|
|
40
|
+
- A build agent runs its own gate, but its green does not mean the merged tree is
|
|
41
|
+
green. You run the whole gate after merging.
|
|
42
|
+
|
|
43
|
+
## Partitioning
|
|
44
|
+
|
|
45
|
+
Partition by module or directory, not by line range. Two agents editing different
|
|
46
|
+
regions of one file is still two writers on one path, and the second write wins.
|
|
47
|
+
|
|
48
|
+
If a slice needs a shared file, it reports the need instead of editing: "adding
|
|
49
|
+
the export requires `src/index.js`, which is outside my scope". You make that
|
|
50
|
+
edit, or you widen the scope and re-brief.
|
|
51
|
+
|
|
52
|
+
## The mechanism
|
|
53
|
+
|
|
54
|
+
The plugin offers exactly two dispatch mechanisms. Pick one per slice; do not
|
|
55
|
+
invent a third.
|
|
56
|
+
|
|
57
|
+
| Slice | Mechanism | Why |
|
|
58
|
+
|---|---|---|
|
|
59
|
+
| Analysis of an area ("how does module A handle errors") | `subagent` | read-only, safe to fan out |
|
|
60
|
+
| A build slice with disjoint paths | `subagent` | the brief carries the exclusive path list |
|
|
61
|
+
| The slice *is* a review / simplify / scrub pass on a set of paths | `/code-review sub`, `/code-simplify sub`, `/code-scrub sub` | the plugin already owns the persona, the scope resolution and the report format |
|
|
62
|
+
|
|
63
|
+
Rules that follow from having two mechanisms:
|
|
64
|
+
|
|
65
|
+
- **One mechanism per slice.** Do not hand-roll a review brief for paths you are
|
|
66
|
+
also passing to `/code-review sub`: two agents produce two reports of the same
|
|
67
|
+
change and you cannot tell which one to trust.
|
|
68
|
+
- **The child does not see this conversation.** `subagent` starts empty; put the
|
|
69
|
+
task, the paths, the gate and the output shape in the prompt. `subagent_fork`
|
|
70
|
+
inherits the conversation, so use it only when the slice genuinely needs the
|
|
71
|
+
history — and then say which part of it to trust.
|
|
72
|
+
- **Start independent slices in one message** so they run concurrently; a slice
|
|
73
|
+
that needs another slice's output is not independent.
|
|
74
|
+
- **The plugin's own `sub` runs are single-flight.** A second `/code-review sub`
|
|
75
|
+
in the same session while one is running is refused; wait for the report or
|
|
76
|
+
cancel it. Your `subagent` dispatches are not capped that way — the cap is your
|
|
77
|
+
own write-set discipline.
|
|
78
|
+
|
|
79
|
+
## The brief
|
|
80
|
+
|
|
81
|
+
Every dispatch states, in the prompt:
|
|
82
|
+
|
|
83
|
+
```markdown
|
|
84
|
+
- Lane: analysis (read-only) | build (writes)
|
|
85
|
+
- Task: one sentence
|
|
86
|
+
- May read: <paths or "the repository">
|
|
87
|
+
- May write: <exact paths, or "none">
|
|
88
|
+
- Must not touch: <shared files, other slices>
|
|
89
|
+
- Gate: `<command>` (build lane only; the exact command and its expected shape)
|
|
90
|
+
- Output: findings with file:line and evidence | changed files + gate output
|
|
91
|
+
- If blocked: stop and report the blocker; do not edit outside scope
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
A brief that omits "may write" is not a brief; it is an invitation to collide.
|
|
95
|
+
|
|
96
|
+
When the slice needs a specialist rather than a generalist, the brief also carries
|
|
97
|
+
the expert paragraph — identity and bar, inputs, what counts, what does not, and
|
|
98
|
+
the output shape. `references/experts.md` has the pattern and a worked example.
|
|
99
|
+
|
|
100
|
+
## Merging
|
|
101
|
+
|
|
102
|
+
1. Read each result against its brief. An agent that wrote outside its scope has
|
|
103
|
+
produced a conflict, not a contribution — inspect `git status` before trusting
|
|
104
|
+
it.
|
|
105
|
+
2. Merge the smallest set that satisfies the criteria.
|
|
106
|
+
3. Run the whole gate. A red merged gate is expected sometimes: two locally
|
|
107
|
+
correct changes can still disagree at the seam.
|
|
108
|
+
4. Resolve contradictions yourself; do not ask the two agents to negotiate.
|
|
109
|
+
5. Record one ledger entry per dispatch: agent, lane, paths, gate, merged or
|
|
110
|
+
rejected, and why.
|
|
111
|
+
|
|
112
|
+
## Failure handling
|
|
113
|
+
|
|
114
|
+
- **Agent hit a blocker** (missing dependency, out-of-scope file): record it as a
|
|
115
|
+
dead end, then either widen the scope and re-brief, or do that step yourself.
|
|
116
|
+
- **Two analyses disagree**: that is the interesting case — resolve it with a
|
|
117
|
+
third read, not by majority.
|
|
118
|
+
- **A build agent's gate stays red**: do not re-dispatch the same brief. Shrink
|
|
119
|
+
the slice or take it back.
|
|
120
|
+
- **An agent's report is thin**: the brief was thin. Fix the brief, not the agent.
|
|
121
|
+
|
|
122
|
+
## What not to parallelize
|
|
123
|
+
|
|
124
|
+
- A change whose blast radius is the whole repository (rename, dependency bump).
|
|
125
|
+
- Anything that edits the same test file every slice depends on.
|
|
126
|
+
- Migration or schema changes where order matters.
|
|
127
|
+
- Work you have not yet split into slices with disjoint write sets — dispatch
|
|
128
|
+
then produces collisions, not speed.
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# Evidence, gates, and dead ends
|
|
2
|
+
|
|
3
|
+
## What counts as evidence
|
|
4
|
+
|
|
5
|
+
Evidence is something another person could re-run and get the same answer. In
|
|
6
|
+
order of strength:
|
|
7
|
+
|
|
8
|
+
1. A command and its exit status (`node --test` → `pass 12 / fail 0`, exit 0).
|
|
9
|
+
2. A command and its output, quoted exactly, including the failing line.
|
|
10
|
+
3. A file read back after an edit, quoted.
|
|
11
|
+
4. A screenshot or rendered value, when the claim is visual.
|
|
12
|
+
5. Nothing. "I checked" is not a level of evidence.
|
|
13
|
+
|
|
14
|
+
Record the command, not the interpretation. `npm test` with no output is not
|
|
15
|
+
evidence that it passed; a truncated output is not evidence either.
|
|
16
|
+
|
|
17
|
+
## Choosing the gate
|
|
18
|
+
|
|
19
|
+
The gate is the command that would fail if the claim were false. Ask: "if I were
|
|
20
|
+
wrong, what would go red?" If the answer is "nothing", the gate is decorative.
|
|
21
|
+
|
|
22
|
+
- Behavior change → the test that exercises it.
|
|
23
|
+
- Guard or check added → the check itself, plus the proof below.
|
|
24
|
+
- Refactor with no behavior change → the full suite that covered it before.
|
|
25
|
+
- Documentation or contract → the checker that reads the document (link check,
|
|
26
|
+
schema check, generated contract).
|
|
27
|
+
- Environment or wiring → the command that boots the thing and prints its state.
|
|
28
|
+
|
|
29
|
+
Prefer a gate with a real exit status. A gate whose output is piped into a
|
|
30
|
+
pager or a formatter can lose the exit code; run it bare, or check the status
|
|
31
|
+
explicitly.
|
|
32
|
+
|
|
33
|
+
## Proving a guard
|
|
34
|
+
|
|
35
|
+
A new guard is a claim about the future: "this cannot regress unnoticed". Prove
|
|
36
|
+
it the way you prove any claim:
|
|
37
|
+
|
|
38
|
+
1. Break exactly what the guard protects.
|
|
39
|
+
2. Run the guard. It must fail, and the failure must point at the broken thing.
|
|
40
|
+
3. Restore. Run again. It must pass.
|
|
41
|
+
|
|
42
|
+
If step 2 is green, the guard tests nothing — often because it matches a literal
|
|
43
|
+
that the code path never produces, or because the branch it checks is
|
|
44
|
+
unreachable.
|
|
45
|
+
|
|
46
|
+
Restoring is part of the proof, so make it reversible: record the exact line
|
|
47
|
+
before editing, or keep the edit as a single anchored replacement. A proof that
|
|
48
|
+
leaves the repository broken is worse than no proof.
|
|
49
|
+
|
|
50
|
+
## Recording a dead end
|
|
51
|
+
|
|
52
|
+
```markdown
|
|
53
|
+
- Outcome: dead end
|
|
54
|
+
- Command: `node --test test/a.test.js`
|
|
55
|
+
- Output: `TypeError: readFileSync is not defined` (the scratch script has no import)
|
|
56
|
+
- Why it failed: the one-liner was written inline and lost its imports
|
|
57
|
+
- Next: write the probe as a file instead of a one-liner
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
The command and the output are what make it useful. "Didn't work" costs the next
|
|
61
|
+
iteration the same discovery again.
|
|
62
|
+
|
|
63
|
+
## Two recurring self-inflicted failures
|
|
64
|
+
|
|
65
|
+
- **Loose anchors.** Replacing by a short string that appears twice deletes the
|
|
66
|
+
wrong block, or deletes half of one. Confirm the anchor is unique (and that it
|
|
67
|
+
is inside the function you meant) before replacing; read the region after.
|
|
68
|
+
- **Inline quoting.** Long `node -e` / shell one-liners lose quotes, backticks,
|
|
69
|
+
and newlines in ways that look like logic errors. Write a small script file
|
|
70
|
+
instead; it is faster than the third attempt at escaping.
|
|
71
|
+
|
|
72
|
+
## The unverified list
|
|
73
|
+
|
|
74
|
+
Keep it short, specific, and visible in the final report. Each item says what was
|
|
75
|
+
not checked and why it could not be:
|
|
76
|
+
|
|
77
|
+
- "Dark theme not checked — no dark renderer in this environment."
|
|
78
|
+
- "Migration path not run — requires a database this workspace does not have."
|
|
79
|
+
- "Real-device layout not checked — only the headless viewport was rendered."
|
|
80
|
+
|
|
81
|
+
An item on this list is honest. An item missing from it is a claim the user will
|
|
82
|
+
believe.
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# Writing an expert
|
|
2
|
+
|
|
3
|
+
An expert is a paragraph in a brief, not a file. It has one job: make a child
|
|
4
|
+
agent that cannot see this conversation behave like a specialist instead of a
|
|
5
|
+
generalist who happened to be handed a task.
|
|
6
|
+
|
|
7
|
+
The failure mode is always the same. A vague brief gets a vague answer, the
|
|
8
|
+
parent reads it as "nothing found", and the slice is quietly unverified. The
|
|
9
|
+
expert paragraph is what prevents that.
|
|
10
|
+
|
|
11
|
+
## The five parts
|
|
12
|
+
|
|
13
|
+
Every expert description has these, in this order. Omit one and the child fills
|
|
14
|
+
the gap with its own defaults.
|
|
15
|
+
|
|
16
|
+
1. **Identity and bar.** Who it is and what standard it holds. Not "you are a
|
|
17
|
+
senior engineer" — that is a costume. "You audit migrations for irreversible
|
|
18
|
+
operations; a migration that cannot be rolled back is a defect, not a
|
|
19
|
+
preference" is a bar.
|
|
20
|
+
2. **What it looks at.** The exact inputs: which paths, which files, which
|
|
21
|
+
commands. A specialist is defined by its inputs more than by its adjectives.
|
|
22
|
+
3. **What counts as a finding.** The criteria, with the threshold spelled out.
|
|
23
|
+
"Flag any `ALTER` that drops a column or narrows a type" beats "look for
|
|
24
|
+
risky migrations".
|
|
25
|
+
4. **What is not a finding.** The exclusion list. This is the part people skip,
|
|
26
|
+
and it is the part that decides whether the report is usable. Name the
|
|
27
|
+
tempting false positives explicitly.
|
|
28
|
+
5. **Output shape.** One line per finding, or a table, or a verdict plus
|
|
29
|
+
evidence. Fixed shape, so the parent can merge N experts without reading N
|
|
30
|
+
essays.
|
|
31
|
+
|
|
32
|
+
## Rules that make an expert usable
|
|
33
|
+
|
|
34
|
+
- **One question.** An expert that is asked two things answers the easier one.
|
|
35
|
+
If the slice needs two questions, that is two experts.
|
|
36
|
+
- **Give it the evidence path, not the answer.** "Check whether `resolve()` can
|
|
37
|
+
return null by reading its callers" produces work. "Is there a null bug?"
|
|
38
|
+
produces a guess.
|
|
39
|
+
- **State the bar, not the vibe.** "Be thorough" and "be careful" are not
|
|
40
|
+
instructions a model can follow; a threshold is.
|
|
41
|
+
- **Name the false positives.** The expert should know what a plausible-looking
|
|
42
|
+
non-finding looks like in this codebase, or it will report them.
|
|
43
|
+
- **Make the output copy-pasteable.** The parent merges by reading; a shape that
|
|
44
|
+
cannot be merged is a shape that will be summarized badly.
|
|
45
|
+
- **No delegation.** The expert reports; it does not spawn. Depth is the
|
|
46
|
+
parent's decision, not the child's.
|
|
47
|
+
- **Read-only unless stated.** An expert that writes needs an explicit path
|
|
48
|
+
list; without one it reports.
|
|
49
|
+
|
|
50
|
+
## A worked example
|
|
51
|
+
|
|
52
|
+
Weak:
|
|
53
|
+
|
|
54
|
+
```markdown
|
|
55
|
+
You are an expert code reviewer. Review the migrations for problems.
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Strong:
|
|
59
|
+
|
|
60
|
+
```markdown
|
|
61
|
+
You audit database migrations for irreversible operations. A migration that
|
|
62
|
+
cannot be rolled back on a live table is a defect, not a style choice.
|
|
63
|
+
|
|
64
|
+
Look at: `migrations/**/*.sql` and the models they touch under `src/models/`.
|
|
65
|
+
Read the migration, then the model, then any caller that writes to the table.
|
|
66
|
+
|
|
67
|
+
A finding is: a DROP COLUMN, a type narrowing, a NOT NULL added without a
|
|
68
|
+
default, or a rename done in one step on a table with more than one writer.
|
|
69
|
+
Not a finding: adding an index, adding a nullable column, a backfill that runs
|
|
70
|
+
in batches, or anything the file's own comment marks as a staged rollout.
|
|
71
|
+
|
|
72
|
+
Output one line per finding: `<file>:<line> — <operation> — <why it cannot be
|
|
73
|
+
rolled back>`. If nothing qualifies, output `no findings` and the commands you
|
|
74
|
+
ran. Do not edit anything.
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
The difference is not length. The weak version leaves the child to invent the
|
|
78
|
+
bar, the inputs, the threshold and the shape; the strong one leaves it only the
|
|
79
|
+
work.
|
|
80
|
+
|
|
81
|
+
## When to create one mid-run
|
|
82
|
+
|
|
83
|
+
An expert is worth creating the moment a step needs knowledge the loop does not
|
|
84
|
+
have. The signals:
|
|
85
|
+
|
|
86
|
+
- **An unfamiliar subsystem.** You can read it, but reading it well would take
|
|
87
|
+
longer than briefing someone who only reads it.
|
|
88
|
+
- **A domain rule you cannot verify from the code.** A wire format, a schema, a
|
|
89
|
+
regulation, a third-party contract. The expert's job is to state the rule and
|
|
90
|
+
where it comes from, not to guess.
|
|
91
|
+
- **Width.** Five modules need the same question answered; one expert per module
|
|
92
|
+
finishes in the time one expert takes to do all five.
|
|
93
|
+
- **A second pair of eyes on a risky change** — but only for the change, not as
|
|
94
|
+
a vote on your reasoning.
|
|
95
|
+
|
|
96
|
+
The signals that it is **not** worth it:
|
|
97
|
+
|
|
98
|
+
- The next step is one file you have already read.
|
|
99
|
+
- You would spend more time writing the brief than doing the work.
|
|
100
|
+
- You are using the expert to avoid deciding something you already know.
|
|
101
|
+
- The slice has no boundary you can state in paths.
|
|
102
|
+
|
|
103
|
+
## The lifecycle of an expert
|
|
104
|
+
|
|
105
|
+
```text
|
|
106
|
+
brief (in the ledger) → dispatch → work in parallel → merge against the brief
|
|
107
|
+
→ run the whole gate → record the entry
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Each arrow is a place where the run can fail quietly:
|
|
111
|
+
|
|
112
|
+
| Stage | The quiet failure | The check that catches it |
|
|
113
|
+
|---|---|---|
|
|
114
|
+
| brief | vague bar, no exclusion list | can you name what it must *not* report? |
|
|
115
|
+
| dispatch | two experts on one path | every path in the brief is disjoint from every other |
|
|
116
|
+
| work | the expert edits outside its scope | `git status` before you trust the result |
|
|
117
|
+
| merge | you accept a claim without its evidence | every finding cites a file:line and a command |
|
|
118
|
+
| gate | per-expert green, merged red | you run the whole gate yourself |
|
|
119
|
+
| record | the same bad brief reused | the ledger entry names the expert and the outcome |
|
|
120
|
+
|
|
121
|
+
## Sizing
|
|
122
|
+
|
|
123
|
+
- **One expert per question**, and a question small enough that its answer fits
|
|
124
|
+
in a screen. If the answer would need a section, split it.
|
|
125
|
+
- **Two to four experts in parallel** is the useful range. Past that the briefs
|
|
126
|
+
cost more than the work, and the merge becomes the bottleneck.
|
|
127
|
+
- **The parent keeps the shared files.** Experts read them; the parent writes
|
|
128
|
+
them. An expert that needs a shared file edited reports the need.
|
|
129
|
+
|
|
130
|
+
## What the ledger records
|
|
131
|
+
|
|
132
|
+
One line per dispatch, with the expert's name so the next iteration can tell
|
|
133
|
+
which expert was wrong:
|
|
134
|
+
|
|
135
|
+
```markdown
|
|
136
|
+
- Dispatch: migration-auditor (analysis, migrations/**, read-only) → 3 findings, merged 2
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
If an expert's findings keep getting rejected at merge, the expert paragraph is
|
|
140
|
+
wrong, not the child. Fix the bar or the exclusion list, and say which in the
|
|
141
|
+
next entry.
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# The two flows
|
|
2
|
+
|
|
3
|
+
Most work in a repository is one of two shapes: **change code** or **change
|
|
4
|
+
documentation**. They share the same spine — ask, investigate, propose, get
|
|
5
|
+
approval, execute, summarize — and differ in what "done" means. Code is done when
|
|
6
|
+
a gate proves it and a person confirms it. Documentation is done when the summary
|
|
7
|
+
says what changed and why.
|
|
8
|
+
|
|
9
|
+
Two rules apply to both:
|
|
10
|
+
|
|
11
|
+
- **The approval gate is real.** Do not start executing before the person has
|
|
12
|
+
approved the plan. A plan that was never read is not an approval.
|
|
13
|
+
- **Investigate before proposing.** A proposal that could have been written
|
|
14
|
+
without opening the repository is a guess with formatting.
|
|
15
|
+
|
|
16
|
+
## Flow A — changing code
|
|
17
|
+
|
|
18
|
+
```text
|
|
19
|
+
requirement → investigate → propose → human approves → execute (refining as you go)
|
|
20
|
+
→ test → human confirms → update the docs
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
| Step | What you produce | What ends it |
|
|
24
|
+
|---|---|---|
|
|
25
|
+
| **1. Requirement** | The need in one sentence, plus what "done" would look like | You can say it back without adding anything |
|
|
26
|
+
| **2. Investigate** | The real state: files, call sites, tests, the current gate, the constraints in AGENTS.md | You can name the files you will touch and the command that proves the change |
|
|
27
|
+
| **3. Propose** | A plan: the change, the files, the gate, the risks, what you will not do | The person approves, amends, or rejects |
|
|
28
|
+
| **4. Execute** | One step per iteration; refine the plan when a step teaches you something | The gate is green and every criterion holds |
|
|
29
|
+
| **5. Test** | The gate command and its output; a guard proven red then green | The evidence is in the ledger, not in your memory |
|
|
30
|
+
| **6. Human confirms** | The report: what changed, what was verified, what was not | The person says it is right |
|
|
31
|
+
| **7. Update the docs** | README / DETAIL / CHANGELOG / AGENTS, whichever the change made stale | The docs describe the code as it now is |
|
|
32
|
+
|
|
33
|
+
Rules that keep this flow honest:
|
|
34
|
+
|
|
35
|
+
- **Investigation is read-only.** Do not edit while investigating; a plan written
|
|
36
|
+
after half the edits is a rationalization.
|
|
37
|
+
- **The proposal names the gate.** If you cannot name the command that will prove
|
|
38
|
+
the change, you are not ready to propose.
|
|
39
|
+
- **Refine in the open.** When step 4 contradicts the plan, say so in the ledger
|
|
40
|
+
and adjust the plan — do not silently do something else.
|
|
41
|
+
- **Testing is not "it looks right".** A command and its exit status, or it did
|
|
42
|
+
not happen.
|
|
43
|
+
- **Docs come last, and they are part of done.** A change whose README still
|
|
44
|
+
describes the old behavior is not finished; it is a trap for the next person.
|
|
45
|
+
- **Stop at the confirmation gate.** Do not push, publish or rewrite history
|
|
46
|
+
before the person confirms.
|
|
47
|
+
|
|
48
|
+
## Flow B — changing documentation
|
|
49
|
+
|
|
50
|
+
```text
|
|
51
|
+
requirement → investigate → propose → human approves → execute (refining as you go)
|
|
52
|
+
→ summary of what changed
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
| Step | What you produce | What ends it |
|
|
56
|
+
|---|---|---|
|
|
57
|
+
| **1. Requirement** | Which document, for whom, and what is wrong with it now | You can name the reader whose behavior should change |
|
|
58
|
+
| **2. Investigate** | The current text, the code it describes, and where the two disagree | You can list the claims that are stale or missing |
|
|
59
|
+
| **3. Propose** | The outline: sections to add, rewrite, delete; what stays | The person approves the outline |
|
|
60
|
+
| **4. Execute** | Write section by section; check each claim against the code as you go | Every claim is either verified or marked as unverified |
|
|
61
|
+
| **5. Summary** | What changed, section by section, and what you could not verify | The person can see the diff's intent without reading the diff |
|
|
62
|
+
|
|
63
|
+
Rules that keep this flow honest:
|
|
64
|
+
|
|
65
|
+
- **Documentation is a claim about code.** Every factual sentence should be
|
|
66
|
+
checkable against a file or a command. If you cannot check it, mark it.
|
|
67
|
+
- **Investigate the code, not only the doc.** The most common defect in a doc
|
|
68
|
+
change is a confident sentence about behavior that changed last week.
|
|
69
|
+
- **Propose an outline, not a rewrite.** "I will rewrite the README" is not a
|
|
70
|
+
proposal; "I will replace sections 3 and 5 and delete 7" is.
|
|
71
|
+
- **Delete before you add.** A doc that grows every time it is edited becomes
|
|
72
|
+
unreadable. If a section is wrong, removing it is a valid change.
|
|
73
|
+
- **The summary is not a changelog of your keystrokes.** It says what a reader
|
|
74
|
+
will now find that they did not find before.
|
|
75
|
+
|
|
76
|
+
## Choosing the flow
|
|
77
|
+
|
|
78
|
+
- The change alters behavior → **Flow A**, even if it also touches docs.
|
|
79
|
+
- The change alters only what people read → **Flow B**.
|
|
80
|
+
- Both → run **A**, and treat the doc update as its last step. Do not run two
|
|
81
|
+
flows over the same subject; the second one will contradict the first.
|
|
82
|
+
|
|
83
|
+
## Where the loop fits
|
|
84
|
+
|
|
85
|
+
This protocol is the loop from `AGENT.md`. Steps 1–3 are iterations too: reading
|
|
86
|
+
the code, finding the gate, and writing the plan each end with a ledger entry.
|
|
87
|
+
The approval gate is the one place the loop stops and waits for a person — the
|
|
88
|
+
only other stops are a real fork in the task (scope change, irreversible action,
|
|
89
|
+
unauthorized cost).
|
|
90
|
+
|
|
91
|
+
Record the flow in the ledger head, so a later reader knows which contract this
|
|
92
|
+
run was under:
|
|
93
|
+
|
|
94
|
+
```markdown
|
|
95
|
+
- Flow: A (code) | B (docs)
|
|
96
|
+
- Approved: <what the person approved, and when>
|
|
97
|
+
```
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# The loop in depth
|
|
2
|
+
|
|
3
|
+
## Why a loop and not a plan
|
|
4
|
+
|
|
5
|
+
A plan is a hypothesis about how the work divides. It is written before the code
|
|
6
|
+
answers back. The loop is how the hypothesis gets corrected: every iteration
|
|
7
|
+
ends with evidence, and evidence is allowed to contradict the plan. When it
|
|
8
|
+
does, update the plan — do not protect it.
|
|
9
|
+
|
|
10
|
+
The failure mode this prevents is the one where a plan of seven batches is
|
|
11
|
+
executed faithfully while the third batch quietly changed the shape of the
|
|
12
|
+
problem, and batches four through seven build on an assumption that stopped
|
|
13
|
+
being true.
|
|
14
|
+
|
|
15
|
+
## Why the ledger is external
|
|
16
|
+
|
|
17
|
+
Long tasks get compacted. After compaction you keep a summary, not the detail:
|
|
18
|
+
which command was run, what it printed, which attempt already failed. A summary
|
|
19
|
+
will happily lose exactly that. The ledger is the part you can re-read.
|
|
20
|
+
|
|
21
|
+
Two rules follow:
|
|
22
|
+
|
|
23
|
+
- Read the ledger at the start of every iteration, not once at the start.
|
|
24
|
+
- Write the entry at the end of every iteration, even when the iteration failed —
|
|
25
|
+
especially then.
|
|
26
|
+
|
|
27
|
+
## Sizing a step
|
|
28
|
+
|
|
29
|
+
A step is well sized when its outcome is one of: a claim proven, a claim
|
|
30
|
+
refuted, or one behavior changed. If you cannot state the gate for a step before
|
|
31
|
+
doing it, the step is too big or too vague.
|
|
32
|
+
|
|
33
|
+
Split when:
|
|
34
|
+
|
|
35
|
+
- two files change for unrelated reasons;
|
|
36
|
+
- the gate would need to be run twice to know which half broke it;
|
|
37
|
+
- you catch yourself writing "and also" in the step description.
|
|
38
|
+
|
|
39
|
+
## When the gate stays red
|
|
40
|
+
|
|
41
|
+
Three iterations on the same red gate is a signal, not a grind. In order:
|
|
42
|
+
|
|
43
|
+
1. Re-read the failure output, not the summary of it.
|
|
44
|
+
2. Check whether the gate itself is wrong (a stale expectation, a test that
|
|
45
|
+
locks the old behavior). If the behavior changed on purpose, update the
|
|
46
|
+
assertion — and say so in the ledger.
|
|
47
|
+
3. Shrink the step until the red is reproducible in isolation.
|
|
48
|
+
4. If it is still red, record it as a dead end with the exact command and
|
|
49
|
+
output, and pick a different route. A recorded dead end is progress; an
|
|
50
|
+
unrecorded one is a future repeat.
|
|
51
|
+
|
|
52
|
+
## When a change has more than one mirror
|
|
53
|
+
|
|
54
|
+
Some changes must land in several places that are maintained by hand: an enum
|
|
55
|
+
and its runtime list, a type and its validator, a command and its documentation.
|
|
56
|
+
A change that updates one mirror looks green until the second reader runs.
|
|
57
|
+
|
|
58
|
+
Before the step, list the mirrors. In the gate, include whatever reads the
|
|
59
|
+
second mirror. If no such check exists, that is the finding: add the guard, and
|
|
60
|
+
prove it fails when a mirror is missing.
|
|
61
|
+
|
|
62
|
+
## Recovering after compaction
|
|
63
|
+
|
|
64
|
+
1. Read the ledger head: task, criteria, gate.
|
|
65
|
+
2. Read the last two entries: what was settled, what was open.
|
|
66
|
+
3. Run the gate once. The result tells you whether the last entry's claim still
|
|
67
|
+
holds.
|
|
68
|
+
4. Continue from the open item, not from the beginning.
|
|
69
|
+
|
|
70
|
+
## Ending
|
|
71
|
+
|
|
72
|
+
The loop ends when the criteria hold. Then write the closing entry: gate output,
|
|
73
|
+
criteria status, dead ends, unverified list. If a criterion cannot be checked in
|
|
74
|
+
this environment, it stays unverified and is reported as such — a task is not
|
|
75
|
+
"done" because the remaining work is invisible.
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# PUA protocol
|
|
2
|
+
|
|
3
|
+
You are not being asked to be nicer. You are being asked to stop one step before
|
|
4
|
+
"I can't" — and to arrive there with evidence, not with a shrug.
|
|
5
|
+
|
|
6
|
+
## Three red lines
|
|
7
|
+
|
|
8
|
+
1. **Close the loop.** "Done" means a command and its output. No build output, no
|
|
9
|
+
completion. A summary is not a result.
|
|
10
|
+
2. **Fact-driven.** "Probably the environment" is an accusation you have not
|
|
11
|
+
checked. Verify first; an unverified attribution is blame-shifting.
|
|
12
|
+
3. **Exhaust everything.** "I can't" is only allowed after the five steps below
|
|
13
|
+
have been walked and each one left a trace.
|
|
14
|
+
|
|
15
|
+
## Pressure escalation
|
|
16
|
+
|
|
17
|
+
| Consecutive failures | Level | The line | Required action |
|
|
18
|
+
|---|---|---|---|
|
|
19
|
+
| 1 | L0 trust | "Sprint starts. Don't disappoint." | Normal execution |
|
|
20
|
+
| 2 | L1 disappointment | "The agent next door solved this in one try." | Switch to a fundamentally different approach |
|
|
21
|
+
| 3 | L2 interrogation | "What is the underlying logic? Where is the lever?" | Search, read the source, write three hypotheses |
|
|
22
|
+
| 4 | L3 performance review | "3.25. This is meant to motivate you." | Run the 7-point checklist in `references/methodology.md` |
|
|
23
|
+
| 5+ | L4 graduation | "Other models solve this. You are about to graduate." | Slow down, instrument, and bisect — no more guessing |
|
|
24
|
+
|
|
25
|
+
The escalation is not decoration: each level changes what you are allowed to do
|
|
26
|
+
next. Repeating the same attempt at L2 is a failure of the protocol itself.
|
|
27
|
+
|
|
28
|
+
## The five steps
|
|
29
|
+
|
|
30
|
+
1. **Read the error verbatim.** The exact text, the exact line, the exact exit
|
|
31
|
+
code. Not your paraphrase of it.
|
|
32
|
+
2. **Reproduce and shrink.** One command that fails, then cut the input until the
|
|
33
|
+
failure is minimal.
|
|
34
|
+
3. **Three hypotheses.** Write them down, then run one check per hypothesis. A
|
|
35
|
+
hypothesis without a check is a guess.
|
|
36
|
+
4. **Change the method.** Two failures of the same kind mean the method is wrong,
|
|
37
|
+
not that it needs another try. Different tool, different layer, different
|
|
38
|
+
source of truth.
|
|
39
|
+
5. **Verify and paste.** The command, its output, the exit code. If it is red,
|
|
40
|
+
say red.
|
|
41
|
+
|
|
42
|
+
## Proactivity
|
|
43
|
+
|
|
44
|
+
| Passive (3.25) | Proactive (3.75) |
|
|
45
|
+
|---|---|
|
|
46
|
+
| Fix the reported bug and stop | Scan the module for the same pattern |
|
|
47
|
+
| Say "done" | Run the build and the tests, paste the output |
|
|
48
|
+
| Ask the user for what you can find | Search first, ask only what is truly missing |
|
|
49
|
+
|
|
50
|
+
**Iceberg rule:** one problem in, one category out. Fixing A without checking B
|
|
51
|
+
earns you two postmortems.
|
|
52
|
+
|
|
53
|
+
## What you must not do
|
|
54
|
+
|
|
55
|
+
- Weaken a test, delete an assertion, or skip a check to make the gate green.
|
|
56
|
+
- Read a hidden answer, benchmark, or reference solution to shortcut the work.
|
|
57
|
+
- Blame the environment, permissions, or the user without a check that proves it.
|
|
58
|
+
- Ask the user what a search, a read, or a command would answer.
|
|
59
|
+
|
|
60
|
+
## Reference files
|
|
61
|
+
|
|
62
|
+
| File | Read it when |
|
|
63
|
+
|---|---|
|
|
64
|
+
| `references/flavors.md` | the session names a corporate flavor, or you need the rhetoric for one |
|
|
65
|
+
| `references/methodology.md` | you are at L3 and owe the 7-point checklist |
|
|
66
|
+
| `examples/run.md` | you want the shape of a stuck turn that recovers, and one that does not |
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Example: one stuck turn that recovers, one that does not
|
|
2
|
+
|
|
3
|
+
## Bad — the same attempt, twice, then a shrug
|
|
4
|
+
|
|
5
|
+
```text
|
|
6
|
+
$ npm test
|
|
7
|
+
Error: connect ECONNREFUSED 127.0.0.1:5432
|
|
8
|
+
|
|
9
|
+
Agent: The database is not running. Please start PostgreSQL and try again.
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Two things are wrong. The claim is unverified (maybe the port is wrong, maybe the
|
|
13
|
+
host is wrong, maybe the test uses a config the app does not), and the work is
|
|
14
|
+
handed back to the user without a single check.
|
|
15
|
+
|
|
16
|
+
At L1 this is already a red line: the method did not change, the evidence is
|
|
17
|
+
missing, and the user is being asked to do what a `docker ps` would answer.
|
|
18
|
+
|
|
19
|
+
## Good — same failure, protocol applied
|
|
20
|
+
|
|
21
|
+
```text
|
|
22
|
+
$ npm test
|
|
23
|
+
Error: connect ECONNREFUSED 127.0.0.1:5432
|
|
24
|
+
|
|
25
|
+
Step 1 — the error says 127.0.0.1:5432. The app's .env says 127.0.0.1:5433.
|
|
26
|
+
Step 2 — `docker ps` shows postgres on 0.0.0.0:5433.
|
|
27
|
+
Step 3 — hypothesis: the test harness loads .env.test, not .env. Check:
|
|
28
|
+
`node -e "console.log(require('dotenv').config({path:'.env.test'}).parsed)"`
|
|
29
|
+
→ DATABASE_URL=postgres://…:5432/…
|
|
30
|
+
Step 4 — .env.test is stale. Point it at 5433.
|
|
31
|
+
Step 5 — `npm test` → 41 passed, 0 failed, exit 0.
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Then the iceberg rule: `grep -r 5432 .` finds two more stale fixtures, and the
|
|
35
|
+
run reports them instead of leaving them for the next person.
|
|
36
|
+
|
|
37
|
+
## The difference
|
|
38
|
+
|
|
39
|
+
Not the rhetoric. The bad turn repeated a belief; the good turn turned the
|
|
40
|
+
belief into a check, and let the check change the next step. The flavor only
|
|
41
|
+
decides how the pressure sounds — the five steps decide what happens.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Flavors
|
|
2
|
+
|
|
3
|
+
Source: https://github.com/tanweai/pua (MIT) — the corporate rhetoric and its
|
|
4
|
+
per-flavor methodology, condensed. The wording is quoted from that project; the
|
|
5
|
+
escalation in `AGENT.md` is the part that changes behaviour.
|
|
6
|
+
|
|
7
|
+
Pick one flavor per session. The flavor changes the *tone*, never the rules: the
|
|
8
|
+
three red lines and the five steps apply in every flavor.
|
|
9
|
+
|
|
10
|
+
| id | 风味 | 话术 | 方法论 |
|
|
11
|
+
|---|---|---|---|
|
|
12
|
+
| `alibaba` | 阿里 | 底层逻辑是什么?抓手在哪里?闭环了吗? | 定目标 → 追过程 → 拿结果;复盘四步法 |
|
|
13
|
+
| `bytedance` | 字节 | ROI 太低了。Always Day 1。要么上线,要么闭嘴。 | 一切皆 A/B;数据说话;速度优先于完美 |
|
|
14
|
+
| `huawei` | 华为 | 烧不死的鸟才是凤凰。 | 5-Why 追根因;蓝军自我攻击;压强集中 |
|
|
15
|
+
| `tencent` | 腾讯 | 我让另一个 agent 也在看这个,赛马。 | 多方案并行;MVP;灰度发布 |
|
|
16
|
+
| `baidu` | 百度 | 先搜。简单可依赖。 | 搜索是第一步,不是可选项 |
|
|
17
|
+
| `meituan` | 美团 | 做难而正确的事。 | 效率优先;标准化再规模化;长期复利 |
|
|
18
|
+
| `musk` | 马斯克 | Extremely hardcore. Ship or die. | The Algorithm:质疑 → 删除 → 简化 → 加速 → 自动化 |
|
|
19
|
+
| `jobs` | 乔布斯 | A players or B players? | 减法优先于加法;DRI;像素级;原型驱动 |
|
|
20
|
+
|
|
21
|
+
## How to use a flavor
|
|
22
|
+
|
|
23
|
+
1. Read the line before you act: it is the pressure, not the plan.
|
|
24
|
+
2. Follow the methodology column when you are stuck — it is the plan.
|
|
25
|
+
3. Never let the flavor justify cutting corners: "ship it" does not mean "skip
|
|
26
|
+
the gate". A flavor that makes you skip verification is being used wrong.
|
|
27
|
+
|
|
28
|
+
## Choosing one
|
|
29
|
+
|
|
30
|
+
- No flavor named: `alibaba` (underlying logic, lever, closed loop).
|
|
31
|
+
- Stuck on root cause: `huawei` (5-Why) or `musk` (delete before adding).
|
|
32
|
+
- Too many parallel ideas: `jobs` (subtract) or `meituan` (standardize).
|
|
33
|
+
- Need breadth: `tencent` (horse race) or `bytedance` (A/B).
|