dsh-gate-agent 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +284 -2
- package/cordis.patch.yml +144 -0
- package/icon.svg +4 -0
- package/launchers/verify-notes.mjs +20 -0
- package/launchers/verify-notes.yml +34 -0
- package/lib/index.js +2199 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +32 -4
- package/skills/gate-code-review/SKILL.md +115 -0
- package/skills/gate-code-review/assets/worker-briefs/gate-implement-review.md +19 -0
- package/skills/gate-diagnosing-bugs/SKILL.md +143 -0
- package/skills/gate-diagnosing-bugs/scripts/hitl-loop.template.sh +44 -0
- package/skills/gate-domain-modeling/CONTEXT-FORMAT.md +64 -0
- package/skills/gate-domain-modeling/GLOSSARY-FORMAT.md +64 -0
- package/skills/gate-domain-modeling/SKILL.md +47 -0
- package/skills/gate-fix-bug/SKILL.md +99 -0
- package/skills/gate-fix-bug/assets/worker-briefs/fix-bug-review.md +23 -0
- package/skills/gate-fix-bug/assets/worker-briefs/gate-fix-bug.md +33 -0
- package/skills/gate-handoff/SKILL.md +20 -0
- package/skills/gate-implement/SKILL.md +82 -0
- package/skills/gate-implement/assets/worker-briefs/gate-enter-implement.md +24 -0
- package/skills/gate-implement/tickets.md +114 -0
- package/skills/gate-plan-review/SKILL.md +87 -0
- package/skills/gate-plan-review/assets/worker-briefs/plan-review.md +19 -0
- package/skills/gate-planning/SKILL.md +96 -0
- package/skills/gate-planning/assets/worker-briefs/gate-enter-plan.md +24 -0
- package/skills/gate-planning/proposal.md +51 -0
- package/skills/gate-planning/rfc.md +73 -0
- package/skills/gate-playwright-e2e/SKILL.md +178 -0
- package/skills/gate-playwright-e2e/reference/config.md +129 -0
- package/skills/gate-playwright-e2e/reference/patterns.md +83 -0
- package/skills/gate-prd/SKILL.md +42 -0
- package/skills/gate-research/SKILL.md +17 -0
- package/skills/gate-tdd/SKILL.md +39 -0
- package/skills/gate-tdd/mocking.md +61 -0
- package/skills/gate-tdd/tests.md +79 -0
- package/skills/gate-user-verify/DIAGNOSE.md +75 -0
- package/skills/gate-user-verify/SKILL.md +185 -0
- package/skills/gate-user-verify/assets/worker-briefs/gate-code-verify.md +32 -0
- package/skills/gate-verify/SKILL.md +73 -0
- package/skills/gate-verify/assets/worker-briefs/gate-verify.md +21 -0
- package/skills/gate-write-agent-notes/SKILL.md +199 -0
- package/skills/gate-write-agent-notes/assets/agent-notes-board.html +1779 -0
- package/skills/gate-write-agent-notes/references/archiving.md +113 -0
- package/skills/gate-write-agent-notes/references/classification.md +34 -0
- package/skills/gate-write-agent-notes/references/note-format.md +72 -0
- package/skills/gate-write-agent-notes/references/prose-checklist.md +52 -0
- package/skills/gate-write-agent-notes/references/quality-gate.md +60 -0
- package/skills/gate-write-agent-notes/references/simplification-checklist.md +27 -0
- package/skills/gate-write-agent-notes/references/verification.md +47 -0
- package/skills/gate-write-agent-notes/references/when-to-write.md +86 -0
- package/skills/gate-write-agent-notes/scripts/agent-note-tree.ts +85 -0
- package/skills/gate-write-agent-notes/scripts/archive-agent-note.ts +218 -0
- package/skills/gate-write-agent-notes/scripts/build-board.ts +240 -0
- package/skills/gate-write-agent-notes/scripts/check-note-anchors.ts +105 -0
- package/skills/gate-write-agent-notes/scripts/verify-agent-note-format.ts +158 -0
- package/skills/gate-write-agent-notes/scripts/verify-agent-note-lifecycle.ts +74 -0
- package/skills/gate-write-agent-notes/scripts/verify-agent-note-tree.ts +56 -0
- package/skills/gate-write-agent-notes/scripts/verify-archived-agent-notes.ts +127 -0
- package/skills/gate-write-agent-notes/templates/implemented.md +35 -0
- package/skills/gate-write-agent-notes/templates/proposed.md +41 -0
- package/skills/gate-write-agent-notes/templates/rejected.md +30 -0
- package/skills/gate-writing-for-agents/SKILL-MECHANICS.md +24 -0
- package/skills/gate-writing-for-agents/SKILL.md +85 -0
package/locale/en.json
ADDED
package/locale/zh.json
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-gate-agent",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Full write gate and phase orchestrator with plugin-local skills.",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./lib/index.js",
|
|
8
|
+
"./locale/*.json": "./locale/*.json",
|
|
9
|
+
"./icon": "./icon.svg",
|
|
10
|
+
"./package.json": "./package.json"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"lib",
|
|
14
|
+
"skills",
|
|
15
|
+
"launchers",
|
|
16
|
+
"cordis.patch.yml",
|
|
17
|
+
"README.md",
|
|
18
|
+
"locale/*.json",
|
|
19
|
+
"icon.svg"
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "node scripts/bundle.mjs",
|
|
23
|
+
"typecheck": "tsc -p tsconfig.json",
|
|
24
|
+
"test": "node scripts/bundle.mjs && node scripts/check-split.mjs && node test/unit.mjs && node test/composition.mjs && node test/registry.mjs"
|
|
25
|
+
},
|
|
26
|
+
"dsh": {
|
|
27
|
+
"bundle": {
|
|
28
|
+
"patch": "./cordis.patch.yml"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: gate-code-review
|
|
3
|
+
description: "Gate 实现评审:沿 Standards 与 Spec 两轴评审固定点之后的改动,保留原始 code-review 方法;主 agent 决定 review worker 数量。"
|
|
4
|
+
user-invocable: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Gate 使用
|
|
8
|
+
|
|
9
|
+
主 agent 读取本方法后,按改动规模派一个或多个 review worker;worker 不加载本技能或其他 gate 方法文件。`gate_record({node:'code-review'})` 需要 `reviewAxes.standards.findings` 与 `reviewAxes.spec.findings`;worker 数量由主 agent 决定,但两轴都必须产出。
|
|
10
|
+
|
|
11
|
+
任务模板:本技能 `assets/worker-briefs/gate-implement-review.md`。
|
|
12
|
+
|
|
13
|
+
Two-axis review of the requested change scope, including uncommitted work when applicable:
|
|
14
|
+
|
|
15
|
+
- **Standards**: does the change conform to this repo's documented standards and current authoritative decisions?
|
|
16
|
+
- **Spec**: does the change satisfy the governing work item's scope and acceptance conditions, including any applicable independent Spec?
|
|
17
|
+
|
|
18
|
+
Both axes are independent. The gate main agent decides worker count: it may run them as parallel sub-agents, or use one worker that covers both; either way both axes must be reported separately.
|
|
19
|
+
|
|
20
|
+
Resolve work tracking and document ownership from project instructions. A particular tracker configuration path or separate Spec file is not required for a review. In gate sessions the acceptance contract normally comes from the current task/Note; do not invent an independent Spec.
|
|
21
|
+
|
|
22
|
+
## Process
|
|
23
|
+
|
|
24
|
+
### 1. Pin the fixed point
|
|
25
|
+
|
|
26
|
+
Use the fixed point supplied by the user or calling implementation workflow. Reuse the baseline already recorded in the conversation; ask only when the intended scope cannot be established from available context.
|
|
27
|
+
|
|
28
|
+
Capture the exact review commands once. For committed branch changes use `git diff <fixed-point>...HEAD`; for implementation worktree changes compare the recorded baseline to the working tree and separately inspect scoped untracked files. Include staged and unstaged changes, excluding pre-existing user changes and other tasks. Also record relevant commits. When existing changes overlap, inspect attribution rather than discarding the entire file.
|
|
29
|
+
|
|
30
|
+
Before dispatch, resolve the fixed point and verify the complete scope, including new files. If it is empty, report no changes to review; do not mistake an empty committed diff for an empty worktree.
|
|
31
|
+
|
|
32
|
+
### 2. Identify the acceptance contract
|
|
33
|
+
|
|
34
|
+
First reuse the governing work item, acceptance conditions and applicable design already supplied by the caller or conversation. Otherwise:
|
|
35
|
+
|
|
36
|
+
1. Resolve a work identifier or path from the user's request, branch or relevant commits; locate it through the project's configured tracker or existing work-item convention.
|
|
37
|
+
2. Read that work item's selected scope and acceptance conditions, then follow its references to the applicable revision and sections of any independently owned Spec. Use the registered document owner to resolve design decisions; do not infer a Spec solely from a matching filename.
|
|
38
|
+
3. For direct changes without a separate work item, use the authorized user request and settled decisions in the conversation as the contract. If the contract still cannot be identified, ask the user for its owner. Skip the Spec axis only when no reliable acceptance contract exists, and report that coverage gap.
|
|
39
|
+
|
|
40
|
+
### 3. Identify the standards sources
|
|
41
|
+
|
|
42
|
+
Read project instructions and the document ownership entry, then relevant writing and coding standards such as `CODING_STANDARDS.md` or `CONTRIBUTING.md`. Include the applicable design decisions and constraints identified by the project configuration and governing work item. Report missing or conflicting required inputs as review coverage gaps.
|
|
43
|
+
|
|
44
|
+
On top of whatever the repo documents, the Standards axis always carries the **smell baseline** below: a fixed set of Fowler code smells (_Refactoring_, ch.3) that applies even when a repo documents nothing. Two rules bind it:
|
|
45
|
+
|
|
46
|
+
- **The repo overrides.** A documented repo standard always wins; where it endorses something the baseline would flag, suppress the smell.
|
|
47
|
+
- **Always a judgement call.** Each smell is a labelled heuristic ("possible Feature Envy"), never a hard violation. Like any standard here, skip anything tooling already enforces.
|
|
48
|
+
|
|
49
|
+
Each smell reads *what it is* → *how to fix*; match it against the diff:
|
|
50
|
+
|
|
51
|
+
- **Mysterious Name**: a function, variable, or type whose name doesn't reveal what it does or holds. → rename it; if no honest name comes, the design's murky.
|
|
52
|
+
- **Duplicated Code**: the same logic shape appears in more than one hunk or file in the change. → extract the shared shape, call it from both.
|
|
53
|
+
- **Feature Envy**: a method that reaches into another object's data more than its own. → move the method onto the data it envies.
|
|
54
|
+
- **Data Clumps**: the same few fields or params keep travelling together (a type wanting to be born). → bundle them into one type, pass that.
|
|
55
|
+
- **Primitive Obsession**: a primitive or string standing in for a domain concept that deserves its own type. → give the concept its own small type.
|
|
56
|
+
- **Repeated Switches**: the same `switch`/`if`-cascade on the same type recurs across the change. → replace with polymorphism, or one map both sites share.
|
|
57
|
+
- **Shotgun Surgery**: one logical change forces scattered edits across many files in the diff. → gather what changes together into one module.
|
|
58
|
+
- **Divergent Change**: one file or module is edited for several unrelated reasons. → split so each module changes for one reason.
|
|
59
|
+
- **Speculative Generality**: abstraction, parameters, or hooks added for needs the spec doesn't have. → delete it; inline back until a real need shows.
|
|
60
|
+
- **Message Chains**: long `a.b().c().d()` navigation the caller shouldn't depend on. → hide the walk behind one method on the first object.
|
|
61
|
+
- **Middle Man**: a class or function that mostly just delegates onward. → cut it, call the real target direct.
|
|
62
|
+
- **Refused Bequest**: a subclass or implementer that ignores or overrides most of what it inherits. → drop the inheritance, use composition.
|
|
63
|
+
|
|
64
|
+
### 4. Dispatch the review workers
|
|
65
|
+
|
|
66
|
+
**Standards review worker prompt** should include:
|
|
67
|
+
|
|
68
|
+
- The full diff command and commit list.
|
|
69
|
+
- The standards and current-decision sources found in step 3, **plus the smell baseline from step 3** pasted in full (the sub-agent has no other access to it).
|
|
70
|
+
- The brief: "Report, per file/hunk where relevant, (a) every place the diff violates a documented standard or current authoritative decision: cite the source and rule; and (b) any baseline smell you spot: name it and quote the hunk. Distinguish hard violations from judgement calls: documented rules and current decisions can be hard, but baseline smells are always judgement calls, and a documented repo standard overrides the baseline. Skip anything tooling enforces. Under 400 words."
|
|
71
|
+
|
|
72
|
+
**Spec review worker prompt** should include:
|
|
73
|
+
|
|
74
|
+
- The diff command and commit list.
|
|
75
|
+
- The governing work item or conversational acceptance contract and relevant sections of any applicable independent Spec.
|
|
76
|
+
- The brief: "Report: (a) requirements of the acceptance contract that are missing or partial; (b) behaviour in the diff that wasn't requested (scope creep); (c) requirements that look implemented but where the implementation looks wrong. Quote or identify the exact contract clause for each finding. Under 400 words."
|
|
77
|
+
|
|
78
|
+
If no reliable acceptance contract exists, skip the Spec axis and note this coverage gap in the final report.
|
|
79
|
+
|
|
80
|
+
### 5. Aggregate
|
|
81
|
+
|
|
82
|
+
Present the two reports under `## Standards` and `## Spec` headings, verbatim or lightly cleaned. Do **not** merge or rerank findings, because the two axes are deliberately separate (see _Why two axes_).
|
|
83
|
+
|
|
84
|
+
End with a one-line summary: total findings per axis, and the worst issue _within each axis_ (if any). Don't pick a single winner across axes: that's the reranking the separation exists to prevent.
|
|
85
|
+
|
|
86
|
+
## Why two axes
|
|
87
|
+
|
|
88
|
+
A change can pass one axis and fail the other:
|
|
89
|
+
|
|
90
|
+
- Code that follows every standard but implements the wrong thing → **Standards pass, Spec fail.**
|
|
91
|
+
- Code that does exactly what the issue asked but breaks the project's conventions → **Spec pass, Standards fail.**
|
|
92
|
+
|
|
93
|
+
Reporting them separately stops one axis from masking the other.
|
|
94
|
+
|
|
95
|
+
## Gate 返回格式
|
|
96
|
+
|
|
97
|
+
worker 返回给 gate 主 agent:
|
|
98
|
+
|
|
99
|
+
```json
|
|
100
|
+
{"ok":true,"standards":{"findings":[{"axis":"Standards","summary":"...","evidence":"...","severity":"blocking|important"}]},"spec":{"findings":[{"axis":"Spec","summary":"...","evidence":"...","severity":"blocking|important"}]},"summary":"..."}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
主 agent 汇总后调用:
|
|
104
|
+
|
|
105
|
+
```text
|
|
106
|
+
gate_record({node:'code-review', findings, reviewAxes, workerSessionIds})
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
`reviewAxes` 必须包含 `standards` 与 `spec`;空的 `findings` 表示该轴通过。worker 不修复 findings。
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# /gate-implement-review — review worker
|
|
2
|
+
|
|
3
|
+
```markdown
|
|
4
|
+
你是 Gate 的只读 Implementation Review worker。只评审改动,不修复,不写代码。
|
|
5
|
+
|
|
6
|
+
## 评审对象
|
|
7
|
+
<范围、固定点、完整 diff>
|
|
8
|
+
|
|
9
|
+
## 合同
|
|
10
|
+
<工作项验收条件、适用设计决定>
|
|
11
|
+
|
|
12
|
+
## 两轴
|
|
13
|
+
Standards / Spec。每轴只报 findings,注明文件/证据与严重度。
|
|
14
|
+
|
|
15
|
+
## 输出
|
|
16
|
+
返回 standards、spec 两组 findings;不要合并两轴,不要修改代码。
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: gate-diagnosing-bugs
|
|
3
|
+
description: Diagnosis loop for hard bugs and performance regressions. Use when the user says "diagnose"/"debug this", or reports something broken/throwing/failing/slow.
|
|
4
|
+
user-invocable: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Diagnosing Bugs
|
|
8
|
+
|
|
9
|
+
A discipline for hard bugs. Skip phases only when explicitly justified.
|
|
10
|
+
|
|
11
|
+
When exploring the codebase, use the domain glossary and applicable contracts, designs and decisions identified by project instructions and the work item to form testable hypotheses. Report required-input gaps or conflicts and their effect on the diagnosis; keep dependent expectations unverified.
|
|
12
|
+
|
|
13
|
+
## Redact
|
|
14
|
+
|
|
15
|
+
This skill has you show commands, outputs and captured artifacts. **Redact every secret first**: write `<REDACTED>` in its place. Build loops against env vars, so the credential stays in the environment rather than in what you show. Captured artifacts carry auth headers: quote only the lines that carry the signal.
|
|
16
|
+
|
|
17
|
+
If the redacted output is not enough to diagnose the bug, say so and ask the user.
|
|
18
|
+
|
|
19
|
+
## Phase 1: Build a feedback loop
|
|
20
|
+
|
|
21
|
+
**This is the skill.** Everything else is mechanical. If you have a **tight** pass/fail signal for the bug (one that goes red on _this_ bug), you will find the cause; bisection, hypothesis-testing, and instrumentation all just consume it. If you don't have one, no amount of staring at code will save you.
|
|
22
|
+
|
|
23
|
+
Spend disproportionate effort here. **Be aggressive. Be creative. Refuse to give up.**
|
|
24
|
+
|
|
25
|
+
### Ways to construct one, in roughly this order
|
|
26
|
+
|
|
27
|
+
1. **Failing test** at whatever seam reaches the bug: unit, integration, e2e.
|
|
28
|
+
2. **Curl / HTTP script** against a running dev server.
|
|
29
|
+
3. **CLI invocation** with a fixture input, diffing stdout against a known-good snapshot.
|
|
30
|
+
4. **Headless browser script** (Playwright / Puppeteer) that drives the UI and asserts on DOM/console/network.
|
|
31
|
+
5. **Replay a captured trace.** Save a real network request / payload / event log to disk; replay it through the code path in isolation.
|
|
32
|
+
6. **Throwaway harness.** Spin up a minimal subset of the system (one service, mocked deps) that exercises the bug code path with a single function call.
|
|
33
|
+
7. **Property / fuzz loop.** If the bug is "sometimes wrong output", run 1000 random inputs and look for the failure mode.
|
|
34
|
+
8. **Bisection harness.** If the bug appeared between two known states (commit, dataset, version), automate "boot at state X, check, repeat" so you can `git bisect run` it.
|
|
35
|
+
9. **Differential loop.** Run the same input through old-version vs new-version (or two configs) and diff outputs.
|
|
36
|
+
10. **HITL bash script.** Last resort. If a human must click, drive _them_ with `scripts/hitl-loop.template.sh` so the loop is still structured. Captured output feeds back to you.
|
|
37
|
+
|
|
38
|
+
Build the right feedback loop, and the bug is 90% fixed.
|
|
39
|
+
|
|
40
|
+
### Tighten the loop
|
|
41
|
+
|
|
42
|
+
Treat the loop as a product. Once you have _a_ loop, **tighten** it:
|
|
43
|
+
|
|
44
|
+
- Can I make it faster? (Cache setup, skip unrelated init, narrow the test scope.)
|
|
45
|
+
- Can I make the signal sharper? (Assert on the specific symptom, not "didn't crash".)
|
|
46
|
+
- Can I make it more deterministic? (Pin time, seed RNG, isolate filesystem, freeze network.)
|
|
47
|
+
|
|
48
|
+
A 30-second flaky loop is barely better than no loop; a 2-second deterministic one is tight, a debugging superpower.
|
|
49
|
+
|
|
50
|
+
### Non-deterministic bugs
|
|
51
|
+
|
|
52
|
+
The goal is not a clean repro but a **higher reproduction rate**. Loop the trigger 100×, parallelise, add stress, narrow timing windows, inject sleeps. A 50%-flake bug is debuggable; 1% is not, so keep raising the rate until it's debuggable.
|
|
53
|
+
|
|
54
|
+
### When you genuinely cannot build a loop
|
|
55
|
+
|
|
56
|
+
List attempts and evidence gaps. Continue useful read-only analysis of code, logs and contracts, labeling hypotheses as unverified. Ask for missing access or redacted artifacts only when needed; production instrumentation requires explicit authorization. Do not claim a confirmed cause or verified fix without sufficient evidence.
|
|
57
|
+
|
|
58
|
+
### Completion criterion: a tight loop that goes red
|
|
59
|
+
|
|
60
|
+
Phase 1 is done when the loop is **tight** and **red-capable**: you can name **one command** (a script path, a test invocation, a curl) that you have **already run at least once** (show the invocation and its output, redacted), and that is:
|
|
61
|
+
|
|
62
|
+
- [ ] **Red-capable**: it drives the actual bug code path and asserts the **user's exact symptom**, so it can go red on this bug and green once fixed. Not "runs without erroring"; it must be able to _catch this specific bug_.
|
|
63
|
+
- [ ] **Deterministic**: same verdict every run (flaky bugs: a pinned, high reproduction rate, per above).
|
|
64
|
+
- [ ] **Fast**: seconds, not minutes.
|
|
65
|
+
- [ ] **Agent-runnable**: you can run it unattended; a human in the loop only via `scripts/hitl-loop.template.sh`.
|
|
66
|
+
|
|
67
|
+
Reading code, logs and contracts before a runnable reproduction is allowed to form testable hypotheses and construct the loop. Until exercised, these remain hypotheses. If the environment prevents reproduction, continue available read-only diagnosis and report the limitation without declaring reproduction complete.
|
|
68
|
+
|
|
69
|
+
## Phase 2: Reproduce + minimise
|
|
70
|
+
|
|
71
|
+
Run the loop. Watch it go red as the bug appears.
|
|
72
|
+
|
|
73
|
+
Confirm:
|
|
74
|
+
|
|
75
|
+
- [ ] The loop produces the failure mode the **user** described, not a different failure that happens to be nearby. Wrong bug = wrong fix.
|
|
76
|
+
- [ ] The failure is reproducible across multiple runs (or, for non-deterministic bugs, reproducible at a high enough rate to debug against).
|
|
77
|
+
- [ ] You have captured the exact symptom (error message, wrong output, slow timing) so later phases can verify the fix actually addresses it.
|
|
78
|
+
|
|
79
|
+
### Minimise
|
|
80
|
+
|
|
81
|
+
Once it's red, shrink the repro to the **smallest scenario that still goes red**. Cut inputs, callers, config, data, and steps **one at a time**, re-running the loop after each cut, and keep only what's load-bearing for the failure.
|
|
82
|
+
|
|
83
|
+
Why bother: a minimal repro shrinks the hypothesis space in Phase 3 (fewer moving parts left to suspect) and becomes the clean regression test in Phase 5.
|
|
84
|
+
|
|
85
|
+
Done when **every remaining element is load-bearing**: removing any one of them makes the loop go green.
|
|
86
|
+
|
|
87
|
+
Do not proceed until you have reproduced **and** minimised.
|
|
88
|
+
|
|
89
|
+
## Phase 3: Hypothesise
|
|
90
|
+
|
|
91
|
+
Generate **3–5 ranked hypotheses** before testing any of them. Single-hypothesis generation anchors on the first plausible idea.
|
|
92
|
+
|
|
93
|
+
Each hypothesis must be **falsifiable**: state the prediction it makes.
|
|
94
|
+
|
|
95
|
+
> Format: "If <X> is the cause, then <changing Y> will make the bug disappear / <changing Z> will make it worse."
|
|
96
|
+
|
|
97
|
+
If you cannot state the prediction, the hypothesis is a vibe: discard or sharpen it.
|
|
98
|
+
|
|
99
|
+
**Show the ranked list to the user before testing.** They often have domain knowledge that re-ranks instantly ("we just deployed a change to #3"), or know hypotheses they've already ruled out. Cheap checkpoint, big time saver. Don't block on it; proceed with your ranking if the user is AFK.
|
|
100
|
+
|
|
101
|
+
## Phase 4: Instrument
|
|
102
|
+
|
|
103
|
+
Each probe must map to a specific prediction from Phase 3. **Change one variable at a time.**
|
|
104
|
+
|
|
105
|
+
Tool preference:
|
|
106
|
+
|
|
107
|
+
1. **Debugger / REPL inspection** if the env supports it. One breakpoint beats ten logs.
|
|
108
|
+
2. **Targeted logs** at the boundaries that distinguish hypotheses.
|
|
109
|
+
3. Never "log everything and grep".
|
|
110
|
+
|
|
111
|
+
**Tag every debug log** with a unique prefix, e.g. `[DEBUG-a4f2]`. Cleanup at the end becomes a single grep. Untagged logs survive; tagged logs die.
|
|
112
|
+
|
|
113
|
+
**Perf branch.** For performance regressions, logs are usually wrong. Instead: establish a baseline measurement (timing harness, `performance.now()`, profiler, query plan), then bisect. Measure first, fix second.
|
|
114
|
+
|
|
115
|
+
## Phase 5: Fix + regression test
|
|
116
|
+
|
|
117
|
+
Write the regression test **before the fix**, but only if there is a **correct seam** for it.
|
|
118
|
+
|
|
119
|
+
A correct seam is one where the test exercises the **real bug pattern** as it occurs at the call site. If the only available seam is too shallow (single-caller test when the bug needs multiple callers, unit test that can't replicate the chain that triggered the bug), a regression test there gives false confidence.
|
|
120
|
+
|
|
121
|
+
**If no correct seam exists, that itself is the finding.** Note it. The codebase architecture is preventing the bug from being locked down. Flag this for the next phase.
|
|
122
|
+
|
|
123
|
+
If a correct seam exists:
|
|
124
|
+
|
|
125
|
+
1. Turn the minimised repro into a failing test at that seam.
|
|
126
|
+
2. Watch it fail.
|
|
127
|
+
3. Apply the fix.
|
|
128
|
+
4. Watch it pass.
|
|
129
|
+
5. Re-run the Phase 1 feedback loop against the original (un-minimised) scenario.
|
|
130
|
+
|
|
131
|
+
## Phase 6: Cleanup
|
|
132
|
+
|
|
133
|
+
Required before declaring done:
|
|
134
|
+
|
|
135
|
+
- [ ] Original repro no longer reproduces (re-run the Phase 1 loop)
|
|
136
|
+
- [ ] Regression test passes (or absence of seam is documented)
|
|
137
|
+
- [ ] All `[DEBUG-...]` instrumentation removed (`grep` the prefix)
|
|
138
|
+
- [ ] Throwaway prototypes deleted (or moved to a clearly-marked debug location)
|
|
139
|
+
- [ ] The hypothesis that turned out correct is stated in the commit / PR message, so the next debugger learns
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Human-in-the-loop reproduction loop.
|
|
3
|
+
# Copy this file, edit the steps below, and run it.
|
|
4
|
+
# The agent runs the script; the user follows prompts in their terminal.
|
|
5
|
+
#
|
|
6
|
+
# Usage:
|
|
7
|
+
# bash hitl-loop.template.sh
|
|
8
|
+
#
|
|
9
|
+
# Two helpers:
|
|
10
|
+
# step "<instruction>" → show instruction, wait for Enter
|
|
11
|
+
# capture VAR "<question>" → show question, read response into VAR
|
|
12
|
+
#
|
|
13
|
+
# At the end, captured values are printed as KEY=VALUE for the agent to parse.
|
|
14
|
+
#
|
|
15
|
+
# `capture` prints its value back to the terminal, where the agent reads it,
|
|
16
|
+
# so capture observations, and leave signing in to the user as a `step`.
|
|
17
|
+
|
|
18
|
+
set -euo pipefail
|
|
19
|
+
|
|
20
|
+
step() {
|
|
21
|
+
printf '\n>>> %s\n' "$1"
|
|
22
|
+
read -r -p " [Enter when done] " _
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
capture() {
|
|
26
|
+
local var="$1" question="$2" answer
|
|
27
|
+
printf '\n>>> %s\n' "$question"
|
|
28
|
+
read -r -p " > " answer
|
|
29
|
+
printf -v "$var" '%s' "$answer"
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
# --- edit below ---------------------------------------------------------
|
|
33
|
+
|
|
34
|
+
step "Open the app at http://localhost:3000 and sign in."
|
|
35
|
+
|
|
36
|
+
capture ERRORED "Click the 'Export' button. Did it throw an error? (y/n)"
|
|
37
|
+
|
|
38
|
+
capture ERROR_MSG "Paste the error message (or 'none'):"
|
|
39
|
+
|
|
40
|
+
# --- edit above ---------------------------------------------------------
|
|
41
|
+
|
|
42
|
+
printf '\n--- Captured ---\n'
|
|
43
|
+
printf 'ERRORED=%s\n' "$ERRORED"
|
|
44
|
+
printf 'ERROR_MSG=%s\n' "$ERROR_MSG"
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# CONTEXT.md Format
|
|
2
|
+
|
|
3
|
+
## Structure
|
|
4
|
+
|
|
5
|
+
```md
|
|
6
|
+
# {Context Name}
|
|
7
|
+
|
|
8
|
+
{One or two sentence description of what this context is and why it exists.}
|
|
9
|
+
|
|
10
|
+
## Language
|
|
11
|
+
|
|
12
|
+
**Order**:
|
|
13
|
+
{A one or two sentence description of the term}
|
|
14
|
+
_Avoid_: Purchase, transaction
|
|
15
|
+
|
|
16
|
+
**Invoice**:
|
|
17
|
+
A request for payment sent to a customer after delivery.
|
|
18
|
+
_Avoid_: Bill, payment request
|
|
19
|
+
|
|
20
|
+
**Customer**:
|
|
21
|
+
A person or organization that places orders.
|
|
22
|
+
_Avoid_: Client, buyer, account
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Rules
|
|
26
|
+
|
|
27
|
+
- **Be opinionated.** When multiple words exist for the same concept, pick the best one and list the others under `_Avoid_`.
|
|
28
|
+
- **Keep definitions tight.** One or two sentences max. Define what it IS, not what it does.
|
|
29
|
+
- **Only include terms specific to this project's context.** General programming concepts (timeouts, error types, utility patterns) don't belong even if the project uses them extensively. Before adding a term, ask: is this a concept unique to this context, or a general programming concept? Only the former belongs.
|
|
30
|
+
- **Group terms under subheadings** when natural clusters emerge. If all terms belong to a single cohesive area, a flat list is fine.
|
|
31
|
+
|
|
32
|
+
## Single vs multi-context repos
|
|
33
|
+
|
|
34
|
+
**Single context (most repos):** One `CONTEXT.md` at the repo root.
|
|
35
|
+
|
|
36
|
+
**Multiple contexts:** A `CONTEXT-MAP.md` at the repo root lists the contexts, where they live, and how they relate to each other:
|
|
37
|
+
|
|
38
|
+
```md
|
|
39
|
+
# Context Map
|
|
40
|
+
|
|
41
|
+
## Contexts
|
|
42
|
+
|
|
43
|
+
- [Ordering](./src/ordering/CONTEXT.md): receives and tracks customer orders
|
|
44
|
+
- [Billing](./src/billing/CONTEXT.md): generates invoices and processes payments
|
|
45
|
+
- [Fulfillment](./src/fulfillment/CONTEXT.md): manages warehouse picking and shipping
|
|
46
|
+
|
|
47
|
+
## Relationships
|
|
48
|
+
|
|
49
|
+
- **Ordering → Fulfillment**: Ordering emits `OrderPlaced` events; Fulfillment consumes them to start picking
|
|
50
|
+
- **Fulfillment → Billing**: Fulfillment emits `ShipmentDispatched` events; Billing consumes them to generate invoices
|
|
51
|
+
- **Ordering ↔ Billing**: Shared types for `CustomerId` and `Money`
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
The skill infers which structure applies:
|
|
55
|
+
|
|
56
|
+
Resolve the root from project instructions before these checks; the current working directory may be a subproject. Use the project documentation hierarchy for ownership; the context map does not create separate record categories. Paths shown in the map are Markdown links relative to the map file.
|
|
57
|
+
|
|
58
|
+
- If `CONTEXT-MAP.md` exists, read it to find contexts
|
|
59
|
+
- If only a root `CONTEXT.md` exists, single context
|
|
60
|
+
- If neither exists, create a root `CONTEXT.md` lazily when the first term is resolved
|
|
61
|
+
|
|
62
|
+
When multiple contexts exist, infer which one the current topic relates to. If unclear, ask.
|
|
63
|
+
|
|
64
|
+
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# GLOSSARY.md Format
|
|
2
|
+
|
|
3
|
+
## Structure
|
|
4
|
+
|
|
5
|
+
```md
|
|
6
|
+
# {Context Name}
|
|
7
|
+
|
|
8
|
+
{One or two sentence description of what this context is and why it exists.}
|
|
9
|
+
|
|
10
|
+
## Language
|
|
11
|
+
|
|
12
|
+
**Order**:
|
|
13
|
+
{A one or two sentence description of the term}
|
|
14
|
+
_Avoid_: Purchase, transaction
|
|
15
|
+
|
|
16
|
+
**Invoice**:
|
|
17
|
+
A request for payment sent to a customer after delivery.
|
|
18
|
+
_Avoid_: Bill, payment request
|
|
19
|
+
|
|
20
|
+
**Customer**:
|
|
21
|
+
A person or organization that places orders.
|
|
22
|
+
_Avoid_: Client, buyer, account
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Rules
|
|
26
|
+
|
|
27
|
+
- **Be opinionated.** When multiple words exist for the same concept, pick the best one and list the others under `_Avoid_`.
|
|
28
|
+
- **Keep definitions tight.** One or two sentences max. Define what it IS, not what it does.
|
|
29
|
+
- **Only include terms specific to this project's context.** General programming concepts (timeouts, error types, utility patterns) don't belong even if the project uses them extensively. Before adding a term, ask: is this a concept unique to this context, or a general programming concept? Only the former belongs.
|
|
30
|
+
- **Group terms under subheadings** when natural clusters emerge. If all terms belong to a single cohesive area, a flat list is fine.
|
|
31
|
+
|
|
32
|
+
## Single vs multi-context repos
|
|
33
|
+
|
|
34
|
+
**Single context (most repos):** One `GLOSSARY.md` at the repo root.
|
|
35
|
+
|
|
36
|
+
**Multiple contexts:** A `GLOSSARY-MAP.md` at the repo root lists the contexts, where they live, and how they relate to each other:
|
|
37
|
+
|
|
38
|
+
```md
|
|
39
|
+
# Glossary Map
|
|
40
|
+
|
|
41
|
+
## Contexts
|
|
42
|
+
|
|
43
|
+
- [Ordering](./src/ordering/GLOSSARY.md): receives and tracks customer orders
|
|
44
|
+
- [Billing](./src/billing/GLOSSARY.md): generates invoices and processes payments
|
|
45
|
+
- [Fulfillment](./src/fulfillment/GLOSSARY.md): manages warehouse picking and shipping
|
|
46
|
+
|
|
47
|
+
## Relationships
|
|
48
|
+
|
|
49
|
+
- **Ordering → Fulfillment**: Ordering emits `OrderPlaced` events; Fulfillment consumes them to start picking
|
|
50
|
+
- **Fulfillment → Billing**: Fulfillment emits `ShipmentDispatched` events; Billing consumes them to generate invoices
|
|
51
|
+
- **Ordering ↔ Billing**: Shared types for `CustomerId` and `Money`
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
The skill infers which structure applies:
|
|
55
|
+
|
|
56
|
+
Resolve the root from project instructions before these checks; the current working directory may be a subproject. Use the project documentation hierarchy for ownership; the context map does not create separate record categories. Paths shown in the map are Markdown links relative to the map file.
|
|
57
|
+
|
|
58
|
+
- If `GLOSSARY-MAP.md` exists, read it to find contexts
|
|
59
|
+
- If only a root `GLOSSARY.md` exists, single context
|
|
60
|
+
- If neither exists, create a root `GLOSSARY.md` lazily when the first term is resolved
|
|
61
|
+
|
|
62
|
+
When multiple contexts exist, infer which one the current topic relates to. If unclear, ask.
|
|
63
|
+
|
|
64
|
+
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: gate-domain-modeling
|
|
3
|
+
description: Build and sharpen a project's domain model. Use when discussing codebase terminology, writing or editing a GLOSSARY.md, or recording a durable decision in its selected owner.
|
|
4
|
+
user-invocable: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Domain Modeling
|
|
8
|
+
|
|
9
|
+
Actively build and sharpen the project's domain model as you design. This is the *active* discipline: challenging terms, inventing edge-case scenarios, and writing the glossary and decisions down the moment they crystallise. (Merely *reading* `GLOSSARY.md` for vocabulary is not this skill: that's a one-line habit any skill can do. This skill is for when you're changing the model, not just consuming it.)
|
|
10
|
+
|
|
11
|
+
## File structure
|
|
12
|
+
|
|
13
|
+
Follow the document ownership entry referenced by project instructions for glossary paths and decisions applicable to the model being discussed. If a required input's owner or scope is unclear, report the configuration gap.
|
|
14
|
+
|
|
15
|
+
Resolve the repository management root from project instructions, using the Git top-level only as a fallback. Working inside a subproject does not change it. A root `GLOSSARY-MAP.md` selects domain documents when the repository has multiple contexts. Do not create a separate record system per context or derive record categories automatically from contexts.
|
|
16
|
+
|
|
17
|
+
A single-context project may use a root `GLOSSARY.md`. A root `GLOSSARY-MAP.md`, when present, points to the selected contexts' glossaries; context paths need not be under `src/`. Resolve decision paths separately from the document ownership entry and, for Agent Notes, its configured record roots. Create a glossary or decision record only when there is content for its selected owner. Use the `adr` skill when a separate architecture decision record is warranted.
|
|
18
|
+
|
|
19
|
+
## During the session
|
|
20
|
+
|
|
21
|
+
### Challenge against the glossary
|
|
22
|
+
|
|
23
|
+
When the user uses a term that conflicts with the existing language in `GLOSSARY.md`, call it out immediately. "Your glossary defines 'cancellation' as X, but you seem to mean Y. Which is it?"
|
|
24
|
+
|
|
25
|
+
### Sharpen fuzzy language
|
|
26
|
+
|
|
27
|
+
When the user uses vague or overloaded terms, propose a precise canonical term. "You're saying 'account': do you mean the Customer or the User? Those are different things."
|
|
28
|
+
|
|
29
|
+
### Discuss concrete scenarios
|
|
30
|
+
|
|
31
|
+
When domain relationships are being discussed, stress-test them with specific scenarios. Invent scenarios that probe edge cases and force the user to be precise about the boundaries between concepts.
|
|
32
|
+
|
|
33
|
+
### Cross-reference with code
|
|
34
|
+
|
|
35
|
+
When the user states how something works, check whether the code agrees. If you find a contradiction, surface it: "Your code cancels entire Orders, but you just said partial cancellation is possible. Which is right?"
|
|
36
|
+
|
|
37
|
+
### Update GLOSSARY.md inline
|
|
38
|
+
|
|
39
|
+
When a term is resolved, update `GLOSSARY.md` right there. Don't batch these up: capture them as they happen. Use the format in [GLOSSARY-FORMAT.md](./GLOSSARY-FORMAT.md).
|
|
40
|
+
|
|
41
|
+
`GLOSSARY.md` should be totally devoid of implementation details. Do not treat `GLOSSARY.md` as a spec, a scratch pad, or a repository for implementation decisions. It is a glossary and nothing else.
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: gate-fix-bug
|
|
3
|
+
description: "Fix a user-requested post-delivery implementation defect against its authoritative contract, using available diagnosis, focused correction, review, and regression verification."
|
|
4
|
+
user-invocable: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Fix Bug
|
|
8
|
+
|
|
9
|
+
Fix a post-delivery **Implementation Bug** that the user has explicitly asked to correct.
|
|
10
|
+
|
|
11
|
+
This skill changes code. It does not redesign product behavior or architecture.
|
|
12
|
+
|
|
13
|
+
## Gate worker assets
|
|
14
|
+
|
|
15
|
+
主 agent 使用本技能的 `assets/worker-briefs/gate-fix-bug.md` 派 fix worker;独立 review 使用 `assets/worker-briefs/fix-bug-review.md`。
|
|
16
|
+
|
|
17
|
+
## Preconditions
|
|
18
|
+
|
|
19
|
+
Before fixing, establish:
|
|
20
|
+
|
|
21
|
+
- observed failure
|
|
22
|
+
- expected behavior
|
|
23
|
+
- authoritative contract establishing the expected behavior
|
|
24
|
+
- available diagnosis and supporting evidence
|
|
25
|
+
- enough evidence to treat this as an implementation defect
|
|
26
|
+
|
|
27
|
+
Reuse an existing acceptance report or diagnosis when available, identifying the selected failure items and checking that its evidence still applies to the current delivery. A diagnosis explains the cause; it does not replace the contract. A prior report is not required for a direct user bug report.
|
|
28
|
+
|
|
29
|
+
The user requests the correction; determine its technical classification from evidence rather than requiring the user to confirm the root cause. When the cause is uncertain, investigate using `gate-diagnosing-bugs` before changing code. If evidence identifies a test, contract, design, or environment problem instead, report its ownership and required next action rather than treating it as an implementation bug.
|
|
30
|
+
|
|
31
|
+
Establish the selected repair scope and execution authorization under the project's workflow rules. Reuse authorization throughout in-scope correction, review, and re-verification.
|
|
32
|
+
|
|
33
|
+
Inspect the applicable product contract, design and decisions identified by project configuration and the work item, together with code and tests. Report missing or conflicting required inputs and the affected behavior before choosing its expected result. A defect spanning layers is not itself a reason to stop. Pause affected work only if fixing it requires an unresolved change to product behavior, an approved contract, acceptance, compatibility, migration strategy or authorized scope; surface that decision and continue independent authorized work. Do not guess a new contract in code.
|
|
34
|
+
|
|
35
|
+
## Process
|
|
36
|
+
|
|
37
|
+
1. Reproduce the reported failure.
|
|
38
|
+
2. Identify the smallest stable seam that captures the real bug.
|
|
39
|
+
3. Add or confirm regression coverage when practical; it should fail before the fix.
|
|
40
|
+
4. Locate the root implementation cause.
|
|
41
|
+
5. Apply the smallest coherent correction.
|
|
42
|
+
6. If unexpected technical failures arise during the fix, use `gate-diagnosing-bugs`.
|
|
43
|
+
7. Re-run the regression check and original reproduction.
|
|
44
|
+
8. Run directly related tests, then broader relevant tests when necessary.
|
|
45
|
+
9. Run typechecking/build checks where applicable.
|
|
46
|
+
10. The main agent uses `gate-code-review` to dispatch an independent review worker with the repair baseline, selected failures, contract references, and the complete repair diff, including new files.
|
|
47
|
+
11. Resolve material in-scope review findings by ownership. Return unresolved contract decisions to Discuss and obtain the required planning or implementation authorization under project gates; keep unrelated findings outside the repair scope.
|
|
48
|
+
12. Re-verify behavior affected by review corrections, including the original reproduction, affected acceptance criteria, and relevant regressions. Continue the correction and review loop until the completion conditions hold or further progress requires an unavailable dependency, a user-owned decision, or additional authorization.
|
|
49
|
+
|
|
50
|
+
Verify the original observable failure at an appropriate stable boundary. A passing lower-level regression test alone does not demonstrate that the original acceptance condition is restored. Complete this repair's verification within this skill; a separate user invocation of `gate-user-verify` is not a completion prerequisite.
|
|
51
|
+
|
|
52
|
+
## Scope Rules
|
|
53
|
+
|
|
54
|
+
Do not use a bug fix to introduce unrelated:
|
|
55
|
+
|
|
56
|
+
- refactoring
|
|
57
|
+
- architecture changes
|
|
58
|
+
- API redesign
|
|
59
|
+
- dependencies
|
|
60
|
+
- optimization
|
|
61
|
+
- cleanup
|
|
62
|
+
- product behavior
|
|
63
|
+
|
|
64
|
+
Small refactoring is allowed only when required to implement the correct fix safely.
|
|
65
|
+
|
|
66
|
+
Do not weaken or delete a valid test merely to make the suite pass.
|
|
67
|
+
|
|
68
|
+
## Completion
|
|
69
|
+
|
|
70
|
+
A fix is complete when:
|
|
71
|
+
|
|
72
|
+
- the original problem no longer reproduces
|
|
73
|
+
- expected behavior is restored
|
|
74
|
+
- the selected failed acceptance criteria have evidence of passing on the repaired delivery
|
|
75
|
+
- regression coverage passes when practical
|
|
76
|
+
- relevant tests/build checks pass
|
|
77
|
+
- no established contract was silently changed
|
|
78
|
+
- material in-scope review findings are resolved and affected behavior has been re-verified
|
|
79
|
+
- no blocker to this repair's completion remains
|
|
80
|
+
|
|
81
|
+
## Report
|
|
82
|
+
|
|
83
|
+
Lead with whether the selected repair is complete and verified or remains incomplete. Report:
|
|
84
|
+
|
|
85
|
+
- selected failure items and their latest results
|
|
86
|
+
- root implementation cause
|
|
87
|
+
- correction made
|
|
88
|
+
- regression coverage
|
|
89
|
+
- original reproduction and acceptance re-verification evidence
|
|
90
|
+
- review outcome and relevant regression results
|
|
91
|
+
- remaining failures, blockers, verification gaps, and required next actions, if any
|
|
92
|
+
|
|
93
|
+
Limit the conclusion to the selected repair. Unselected failures or blockers in the original acceptance report remain outside this completion claim. If the original behavior cannot be reliably verified, report the repair as incomplete rather than inferring success from code changes or passing checks alone.
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|