@blxzer/cursor-trellis 0.3.5 → 0.4.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.
Files changed (156) hide show
  1. package/CHANGELOG.md +69 -0
  2. package/README.md +13 -0
  3. package/dist/cli/index.d.ts.map +1 -1
  4. package/dist/cli/index.js +3 -0
  5. package/dist/cli/index.js.map +1 -1
  6. package/dist/commands/goal/index.d.ts +3 -0
  7. package/dist/commands/goal/index.d.ts.map +1 -0
  8. package/dist/commands/goal/index.js +159 -0
  9. package/dist/commands/goal/index.js.map +1 -0
  10. package/dist/commands/goal/review.d.ts +6 -0
  11. package/dist/commands/goal/review.d.ts.map +1 -0
  12. package/dist/commands/goal/review.js +28 -0
  13. package/dist/commands/goal/review.js.map +1 -0
  14. package/dist/commands/sdk/run.d.ts.map +1 -1
  15. package/dist/commands/sdk/run.js +2 -27
  16. package/dist/commands/sdk/run.js.map +1 -1
  17. package/dist/commands/update.d.ts.map +1 -1
  18. package/dist/commands/update.js +5 -1
  19. package/dist/commands/update.js.map +1 -1
  20. package/dist/configurators/workflow.d.ts.map +1 -1
  21. package/dist/configurators/workflow.js +51 -2
  22. package/dist/configurators/workflow.js.map +1 -1
  23. package/dist/constants/paths.d.ts +4 -0
  24. package/dist/constants/paths.d.ts.map +1 -1
  25. package/dist/constants/paths.js +4 -0
  26. package/dist/constants/paths.js.map +1 -1
  27. package/dist/goal/action-packet.d.ts +89 -0
  28. package/dist/goal/action-packet.d.ts.map +1 -0
  29. package/dist/goal/action-packet.js +113 -0
  30. package/dist/goal/action-packet.js.map +1 -0
  31. package/dist/goal/audit.d.ts +14 -0
  32. package/dist/goal/audit.d.ts.map +1 -0
  33. package/dist/goal/audit.js +12 -0
  34. package/dist/goal/audit.js.map +1 -0
  35. package/dist/goal/constants.d.ts +26 -0
  36. package/dist/goal/constants.d.ts.map +1 -0
  37. package/dist/goal/constants.js +24 -0
  38. package/dist/goal/constants.js.map +1 -0
  39. package/dist/goal/paths.d.ts +8 -0
  40. package/dist/goal/paths.d.ts.map +1 -0
  41. package/dist/goal/paths.js +36 -0
  42. package/dist/goal/paths.js.map +1 -0
  43. package/dist/goal/preflight.d.ts +21 -0
  44. package/dist/goal/preflight.d.ts.map +1 -0
  45. package/dist/goal/preflight.js +97 -0
  46. package/dist/goal/preflight.js.map +1 -0
  47. package/dist/goal/review-seam.d.ts +44 -0
  48. package/dist/goal/review-seam.d.ts.map +1 -0
  49. package/dist/goal/review-seam.js +153 -0
  50. package/dist/goal/review-seam.js.map +1 -0
  51. package/dist/goal/reviewer-rules.d.ts +13 -0
  52. package/dist/goal/reviewer-rules.d.ts.map +1 -0
  53. package/dist/goal/reviewer-rules.js +153 -0
  54. package/dist/goal/reviewer-rules.js.map +1 -0
  55. package/dist/goal/reviewer.d.ts +9 -0
  56. package/dist/goal/reviewer.d.ts.map +1 -0
  57. package/dist/goal/reviewer.js +54 -0
  58. package/dist/goal/reviewer.js.map +1 -0
  59. package/dist/goal/runtime.d.ts +32 -0
  60. package/dist/goal/runtime.d.ts.map +1 -0
  61. package/dist/goal/runtime.js +242 -0
  62. package/dist/goal/runtime.js.map +1 -0
  63. package/dist/goal/sdk-client.d.ts +10 -0
  64. package/dist/goal/sdk-client.d.ts.map +1 -0
  65. package/dist/goal/sdk-client.js +34 -0
  66. package/dist/goal/sdk-client.js.map +1 -0
  67. package/dist/goal/state.d.ts +40 -0
  68. package/dist/goal/state.d.ts.map +1 -0
  69. package/dist/goal/state.js +37 -0
  70. package/dist/goal/state.js.map +1 -0
  71. package/dist/goal/task-triggers.d.ts +15 -0
  72. package/dist/goal/task-triggers.d.ts.map +1 -0
  73. package/dist/goal/task-triggers.js +23 -0
  74. package/dist/goal/task-triggers.js.map +1 -0
  75. package/dist/goal/walls.d.ts +12 -0
  76. package/dist/goal/walls.d.ts.map +1 -0
  77. package/dist/goal/walls.js +65 -0
  78. package/dist/goal/walls.js.map +1 -0
  79. package/dist/goal/worker-prompt.d.ts +13 -0
  80. package/dist/goal/worker-prompt.d.ts.map +1 -0
  81. package/dist/goal/worker-prompt.js +41 -0
  82. package/dist/goal/worker-prompt.js.map +1 -0
  83. package/dist/goal/worker.d.ts +42 -0
  84. package/dist/goal/worker.d.ts.map +1 -0
  85. package/dist/goal/worker.js +180 -0
  86. package/dist/goal/worker.js.map +1 -0
  87. package/dist/migrations/manifests/0.3.5.json +9 -0
  88. package/dist/migrations/manifests/0.3.6.json +9 -0
  89. package/dist/migrations/manifests/0.4.0.json +9 -0
  90. package/dist/templates/common/commands/continue.md +15 -3
  91. package/dist/templates/common/skills/check.md +7 -4
  92. package/dist/templates/cursor/agents/cstl-check.md +1 -0
  93. package/dist/templates/cursor/fixtures/expected-rules.d.ts.map +1 -1
  94. package/dist/templates/cursor/fixtures/expected-rules.js +6 -1
  95. package/dist/templates/cursor/fixtures/expected-rules.js.map +1 -1
  96. package/dist/templates/cursor/rules/cstl-cursor-modes.mdc +32 -0
  97. package/dist/templates/cursor/rules/cstl-triage.mdc +2 -4
  98. package/dist/templates/cursor/rules/retrieval-routing.mdc +26 -7
  99. package/dist/templates/markdown/index.d.ts +9 -0
  100. package/dist/templates/markdown/index.d.ts.map +1 -1
  101. package/dist/templates/markdown/index.js +9 -0
  102. package/dist/templates/markdown/index.js.map +1 -1
  103. package/dist/templates/markdown/spec/guides/artifact-locale-guide.md.txt +93 -0
  104. package/dist/templates/markdown/spec/guides/cross-platform-thinking-guide.md.txt +7 -7
  105. package/dist/templates/markdown/spec/guides/cursor-context-injection-guide.md.txt +38 -21
  106. package/dist/templates/markdown/spec/guides/cursor-native-modes-guide.md.txt +125 -0
  107. package/dist/templates/markdown/spec/guides/cursor-subagent-policy.md.txt +10 -8
  108. package/dist/templates/markdown/spec/guides/debug-loop-guide.md.txt +227 -0
  109. package/dist/templates/markdown/spec/guides/goal-release-regression-runbook.md.txt +132 -0
  110. package/dist/templates/markdown/spec/guides/index.md.txt +144 -104
  111. package/dist/templates/markdown/spec/guides/injection-budget-guide.md.txt +111 -0
  112. package/dist/templates/markdown/spec/guides/prototype-guide.md.txt +139 -0
  113. package/dist/templates/markdown/spec/guides/retrieval-daily-guide.md.txt +28 -6
  114. package/dist/templates/markdown/spec/guides/test-discipline-guide.md.txt +138 -0
  115. package/dist/templates/markdown/spec/guides/verification-strength-guide.md.txt +185 -0
  116. package/dist/templates/shared-hooks/session-start.py +10 -0
  117. package/dist/templates/trellis/config.yaml +18 -0
  118. package/dist/templates/trellis/index.d.ts +17 -0
  119. package/dist/templates/trellis/index.d.ts.map +1 -1
  120. package/dist/templates/trellis/index.js +40 -0
  121. package/dist/templates/trellis/index.js.map +1 -1
  122. package/dist/templates/trellis/pool/README.md +103 -0
  123. package/dist/templates/trellis/pool/items/.gitkeep +0 -0
  124. package/dist/templates/trellis/pool/plan.md +26 -0
  125. package/dist/templates/trellis/scripts/common/artifact_locale.py +278 -0
  126. package/dist/templates/trellis/scripts/common/codebase_retrieval_router.py +37 -2
  127. package/dist/templates/trellis/scripts/common/config.py +39 -0
  128. package/dist/templates/trellis/scripts/common/injection_budget.py +317 -0
  129. package/dist/templates/trellis/scripts/common/parent_orchestration.py +161 -5
  130. package/dist/templates/trellis/scripts/common/pool_store.py +702 -0
  131. package/dist/templates/trellis/scripts/common/retrieval_agent_instructions.py +9 -3
  132. package/dist/templates/trellis/scripts/common/session_context.py +32 -4
  133. package/dist/templates/trellis/scripts/common/session_memory.py +26 -0
  134. package/dist/templates/trellis/scripts/common/subagent_dispatch.py +74 -9
  135. package/dist/templates/trellis/scripts/common/task_context.py +18 -0
  136. package/dist/templates/trellis/scripts/common/task_dashboard.py +24 -1
  137. package/dist/templates/trellis/scripts/common/task_dependencies.py +673 -0
  138. package/dist/templates/trellis/scripts/common/task_gates.py +58 -5
  139. package/dist/templates/trellis/scripts/common/task_map.py +40 -8
  140. package/dist/templates/trellis/scripts/common/task_store.py +400 -39
  141. package/dist/templates/trellis/scripts/common/test_depends_mode_block.py +489 -0
  142. package/dist/templates/trellis/scripts/common/test_observable_defaults.py +135 -0
  143. package/dist/templates/trellis/scripts/common/test_pool_store.py +428 -0
  144. package/dist/templates/trellis/scripts/common/test_task_dependencies.py +345 -0
  145. package/dist/templates/trellis/scripts/cursor_retrieval_probe_prompt.md +14 -12
  146. package/dist/templates/trellis/scripts/generate_dispatch_prompt.py +182 -0
  147. package/dist/templates/trellis/scripts/injection_budget_probe.py +69 -0
  148. package/dist/templates/trellis/scripts/pool.py +192 -0
  149. package/dist/templates/trellis/scripts/retrieval_probe_matrix_template.json +3 -3
  150. package/dist/templates/trellis/scripts/spec_health_outcomes.py +160 -0
  151. package/dist/templates/trellis/scripts/task.py +85 -1
  152. package/dist/templates/trellis/scripts/verify_evidence_probe.py +138 -0
  153. package/dist/templates/trellis/tasks/locale/en/default-prd.md +19 -0
  154. package/dist/templates/trellis/tasks/locale/zh/default-prd.md +19 -0
  155. package/dist/templates/trellis/workflow.md +55 -5
  156. package/package.json +2 -2
@@ -0,0 +1,227 @@
1
+ # Debug Loop Guide
2
+
3
+ > **Purpose**: 调试纪律 —— 先建 tight、red-capable 反馈环,再假设、再修,一次到位找到并修对;与 `cstl-break-loop` 划界(诊断进行中 vs 修完后防再发),互不替代。
4
+
5
+ ---
6
+
7
+ ## 1. Purpose / Non-goals
8
+
9
+ **Purpose.** Hard bugs and performance regressions are not solved by reading code — they are solved by building a **tight, red-capable feedback loop** first, then letting hypotheses consume it. This guide defines the discipline: build the loop → reproduce → hypothesise → probe one variable at a time → freeze the loop as a regression → clean up and hand off to prevention.
10
+
11
+ **Non-goals**
12
+
13
+ - **Not a mandate for every bug.** A lightweight bug (obvious at a glance, provable in a single step) may skip the full loop — but you must state **one sentence** explaining why the full cycle was skipped.
14
+ - **Not a replacement for `cstl-break-loop`.** This guide owns *diagnosis in progress*; break-loop owns *post-fix root cause classification / prevention / knowledge capture* (see §2).
15
+ - **No production instrumentation** unless the user explicitly permits it. If you cannot build a loop without instrumenting production, stop and ask (see Phase 1 "genuinely cannot build a loop").
16
+ - **Not TDD ceremony.** Phase 5 freezes the loop as a test *or* a repeatable command — whichever is the correct seam.
17
+
18
+ ## 2. Boundary with cstl-break-loop
19
+
20
+ | | **debug-loop-guide** (this guide) | **cstl-break-loop** |
21
+ | --- | --- | --- |
22
+ | 时机 | 诊断与修复**进行中**(建环 → 修) | 修复**完成后**(深分析) |
23
+ | 目标 | 一次到位找到并修对(red 环、假设表、修复、清理) | 根因分类(A–E)、为何修失败、防再发机制、入 spec |
24
+ | 输出 | 红环、3–5 假设排名、修复、回归、清理 | 5 维分析、prevention、knowledge capture 到 guides |
25
+ | 触发 | 用户报 bug / 性能回归,进入诊断 | `/cstl:break-loop` 或修完后的任务收尾 |
26
+
27
+ **二者不互相替代**:debug-loop-guide 结束时若只修完没做根因分类,同类 bug 会再发;cstl-break-loop 不帮你找到原因(它在修完之后才启动)。Phase 6 的 post-mortem 钩子负责把两者接起来。
28
+
29
+ ## 3. Hard rule: no red-capable loop → no hypotheses
30
+
31
+ > **硬纪律:无 red-capable 反馈环,不得进入假设阶段;禁止先读代码猜原因。**
32
+
33
+ A **red-capable** loop is **one command** that you have **already run at least once** (show the invocation and its redacted output), and that simultaneously:
34
+
35
+ - **Drives the path of the user's symptom** — it exercises the actual bug code path, not "it didn't crash".
36
+ - **Can go red and green** — it goes red on *this* bug and turns green once fixed.
37
+ - **Is as deterministic, fast, and agent-runnable as possible** — seconds, unattended; a human in the loop only via the PowerShell HITL template (§12).
38
+
39
+ If you catch yourself reading code to build a theory before this command exists — **stop**. Jumping straight to a hypothesis is the exact failure this discipline prevents. No red-capable command, no Phase 2.
40
+
41
+ **If you genuinely cannot build a loop**: stop and say so explicitly. List what you tried. Ask the user for (a) access to the environment that reproduces it, (b) a redacted captured artifact (HAR file, log dump, core dump, screen recording with timestamps), or (c) **explicit permission** to add temporary production instrumentation. Do **not** proceed to hypothesise without a loop.
42
+
43
+ ## 4. Lightweight escape hatch
44
+
45
+ A lightweight bug — one visible at a glance, provable in a single step (typo, obvious off-by-one, missing export) — may skip the full cycle. The only requirement: **one sentence explaining why the full loop was skipped** (e.g. "single-line typo, provable by one compile run; full loop skipped"). Hard bugs and performance regressions **default to the full loop**.
46
+
47
+ ## 5. Redact
48
+
49
+ This guide makes you show commands, outputs and captured artifacts. **Redact every secret first** — write `<REDACTED>` in its place.
50
+
51
+ - Build loops against **env vars** so credentials stay in the environment, never in what you show.
52
+ - Captured artifacts carry auth headers: **quote only the lines that carry the signal**, not the whole blob.
53
+ - If the redacted output is not enough to diagnose the bug, say so and ask the user — do not leak secrets to move faster.
54
+
55
+ ## 6. Phase 1 — Build a tight feedback loop
56
+
57
+ **This is the phase.** 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 just consume it. If you don't have one, no amount of staring at code will save you. Spend disproportionate effort here. **Be aggressive. Be creative. Refuse to give up.**
58
+
59
+ ### Ways to construct one — try them in roughly this order
60
+
61
+ 1. **Failing test** at whatever seam reaches the bug — unit, integration, e2e.
62
+ 2. **Curl / HTTP script** against a running dev server.
63
+ 3. **CLI invocation** with a fixture input, diffing stdout against a known-good snapshot.
64
+ 4. **Headless browser script** (Playwright / Puppeteer) — drives the UI, asserts on DOM/console/network.
65
+ 5. **Replay a captured trace.** Save a real network request / payload / event log to disk; replay it through the code path in isolation.
66
+ 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.
67
+ 7. **Property / fuzz loop.** If the bug is "sometimes wrong output", run 1000 random inputs and look for the failure mode.
68
+ 8. **Bisection harness.** If the bug appeared between two known states (commit, dataset, version), automate "boot at state X, check, repeat" so you can bisect it.
69
+ 9. **Differential loop.** Run the same input through old-version vs new-version (or two configs) and diff outputs.
70
+ 10. **HITL PowerShell script** (§12). Last resort. If a human must click, drive *them* with a structured loop so it is still a loop. Captured output feeds back to you.
71
+
72
+ ### Tighten the loop
73
+
74
+ Treat the loop as a product. Once you have *a* loop, **tighten** it:
75
+
76
+ - Can I make it **faster**? (Cache setup, skip unrelated init, narrow the test scope.)
77
+ - Can I make the **signal sharper**? (Assert on the specific symptom, not "didn't crash".)
78
+ - Can I make it **more deterministic**? (Pin time, seed RNG, isolate filesystem, freeze network.)
79
+
80
+ A 30-second flaky loop is barely better than no loop; a 2-second deterministic one is a debugging superpower.
81
+
82
+ ### Non-deterministic bugs
83
+
84
+ 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 — keep raising the rate until it is debuggable.
85
+
86
+ ### Completion criterion — a tight loop that goes red
87
+
88
+ 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:
89
+
90
+ - [ ] **Red-capable** — 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".
91
+ - [ ] **Deterministic** — same verdict every run (flaky bugs: a pinned, high reproduction rate, per above).
92
+ - [ ] **Fast** — seconds, not minutes.
93
+ - [ ] **Agent-runnable** — unattended; a human in the loop only via the HITL template (§12).
94
+
95
+ No red-capable command, no Phase 2.
96
+
97
+ ## 7. Phase 2 — Reproduce + minimise
98
+
99
+ Run the loop. Watch it go red — the bug appears.
100
+
101
+ Confirm:
102
+
103
+ - [ ] The loop produces the failure mode the **user** described — not a different failure that happens to be nearby. Wrong bug = wrong fix.
104
+ - [ ] The failure is reproducible across multiple runs (or, for non-deterministic bugs, reproducible at a high enough rate to debug against).
105
+ - [ ] You have captured the exact symptom (error message, wrong output, slow timing) so later phases can verify the fix actually addresses it.
106
+
107
+ ### Minimise
108
+
109
+ Once it is 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 — keep only what is load-bearing for the failure. A minimal repro shrinks the Phase 3 hypothesis space (fewer moving parts to suspect) and becomes the clean Phase 5 regression. Done when **every remaining element is load-bearing** — removing any one of them makes the loop go green.
110
+
111
+ Do not proceed until you have reproduced **and** minimised.
112
+
113
+ ## 8. Phase 3 — Ranked falsifiable hypotheses (show user)
114
+
115
+ Generate **3–5 ranked hypotheses** before testing any of them. Single-hypothesis generation anchors on the first plausible idea.
116
+
117
+ Each hypothesis must be **falsifiable**: state the prediction it makes.
118
+
119
+ > Format: "If `<X>` is the cause, then `<changing Y>` will make the bug disappear / `<changing Z>` will make it worse."
120
+
121
+ If you cannot state the prediction, the hypothesis is a vibe — discard or sharpen it.
122
+
123
+ **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 have already ruled out. Cheap checkpoint, big time saver. Don't block on it — proceed with your ranking if the user is AFK.
124
+
125
+ ## 9. Phase 4 — One-variable probes / instrumentation
126
+
127
+ Each probe must map to a specific prediction from Phase 3. **Change one variable at a time.**
128
+
129
+ Tool preference:
130
+
131
+ 1. **Debugger / REPL inspection** if the environment supports it. One breakpoint beats ten logs.
132
+ 2. **Targeted logs** at the boundaries that distinguish hypotheses.
133
+ 3. Never "log everything and grep".
134
+
135
+ **Tag every debug log with a unique prefix**, e.g. `[DEBUG-a4f2]` (or any equivalent uniform prefix). Cleanup at the end becomes a **single grep**: `grep -rn "\[DEBUG-" .` / `rg "\[DEBUG-"` — every tagged line dies, untagged lines survive.
136
+
137
+ **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.
138
+
139
+ ## 10. Phase 5 — Regression (freeze the loop)
140
+
141
+ Freeze the loop as a test **or** a repeatable command — whichever has a **correct seam**.
142
+
143
+ A correct seam is one where the test/command 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 cannot replicate the chain that triggered the bug), a regression there gives false confidence.
144
+
145
+ **If no correct seam exists, that itself is the finding.** Note it — the architecture is preventing the bug from being locked down. Flag it for Phase 6 / break-loop.
146
+
147
+ If a correct seam exists:
148
+
149
+ 1. Turn the minimised repro into a failing test (or a repeatable command) at that seam.
150
+ 2. Watch it fail.
151
+ 3. Apply the fix.
152
+ 4. Watch it pass.
153
+ 5. Re-run the Phase 1 feedback loop against the original (un-minimised) scenario.
154
+
155
+ This phase hands off to the test-discipline scope (P08) without being absorbed by it: the loop here is bug-driven; test-discipline owns the general testing strategy.
156
+
157
+ ## 11. Phase 6 — Cleanup + post-mortem hook
158
+
159
+ Required before declaring done:
160
+
161
+ - [ ] Original repro no longer reproduces (re-run the Phase 1 loop)
162
+ - [ ] Regression passes (or absence of seam is documented)
163
+ - [ ] All `[DEBUG-...]` instrumentation removed — one grep, zero hits
164
+ - [ ] Throwaway prototypes deleted (or moved to a clearly-marked debug location)
165
+ - [ ] The hypothesis that turned out correct is stated in the commit / PR message — so the next debugger learns
166
+
167
+ **Post-mortem hook:** then ask *what would have prevented this bug?* If the answer involves architectural change (no good test seam, tangled callers, hidden coupling), or the bug is worth classifying, run **`cstl-break-loop`** (root cause category A–E, why fixes failed, prevention mechanisms) and/or update the relevant spec/guide via **`cstl-update-spec`**. Make the recommendation **after** the fix is in, not before — you have more information now than when you started.
168
+
169
+ ## 12. PowerShell HITL template
170
+
171
+ PowerShell 7 (user environment). Copy this file, edit the steps below, and run it. The agent runs the script; the user follows prompts in their terminal. Two helpers:
172
+
173
+ - `Step "instruction"` → show instruction, wait for Enter
174
+ - `$var = Capture "question"` → show question, read response; the returned value is echoed back, where the agent reads it — so capture observations, and leave signing in to the user as a `Step`
175
+
176
+ At the end, captured values are printed as `KEY=VALUE` for the agent to parse.
177
+
178
+ ```powershell
179
+ # Human-in-the-loop reproduction loop (PowerShell 7).
180
+ # Usage: ./hitl-loop.ps1
181
+ # Edit the "--- edit below ---" section per bug, then run it.
182
+
183
+ $ErrorActionPreference = 'Stop'
184
+
185
+ function Step {
186
+ param([Parameter(Mandatory)][string]$Instruction)
187
+ Write-Host ''
188
+ Write-Host ">>> $Instruction" -ForegroundColor Cyan
189
+ [void](Read-Host " [Enter when done] ")
190
+ }
191
+
192
+ function Capture {
193
+ param([Parameter(Mandatory)][string]$Question)
194
+ Write-Host ''
195
+ Write-Host ">>> $Question" -ForegroundColor Cyan
196
+ $answer = Read-Host " > "
197
+ Write-Host " (captured: $answer)"
198
+ return $answer
199
+ }
200
+
201
+ # --- edit below ---------------------------------------------------------
202
+
203
+ Step "Open the app at http://localhost:3000 and sign in."
204
+
205
+ $ERRORED = Capture "Click the 'Export' button. Did it throw an error? (y/n)"
206
+
207
+ $ERROR_MSG = Capture "Paste the error message (or 'none'):"
208
+
209
+ # --- edit above ---------------------------------------------------------
210
+
211
+ Write-Host ''
212
+ Write-Host '--- Captured ---' -ForegroundColor Green
213
+ Write-Host "ERRORED=$ERRORED"
214
+ Write-Host "ERROR_MSG=$ERROR_MSG"
215
+ ```
216
+
217
+ Adaptation notes for the agent: keep the loop **agent-runnable** where possible (headless/HTTP/CLI first); HITL only when a human must click or sign in. Never ask the user to paste secrets into the loop output — capture observations, leave signing in to the user as a `Step`.
218
+
219
+ ## 13. Completion checklist
220
+
221
+ - [ ] Phase 1 loop exists, ran at least once, red-capable, deterministic, fast, agent-runnable (or escape hatch justified in one sentence)
222
+ - [ ] Phase 2: reproduced the user's exact symptom; repro minimised until every element is load-bearing
223
+ - [ ] Phase 3: 3–5 ranked falsifiable hypotheses, each with a stated prediction; shown to user
224
+ - [ ] Phase 4: one variable per probe; debug logs tagged `[DEBUG-...]`
225
+ - [ ] Phase 5: loop frozen as test or repeatable command at a correct seam (or absence of seam documented)
226
+ - [ ] Phase 6: original repro green, instrumentation removed (one grep, zero hits), post-mortem hook to `cstl-break-loop` / `cstl-update-spec` decided
227
+ - [ ] Everything shown to the user redacted (`<REDACTED>`, credentials via env)
@@ -0,0 +1,132 @@
1
+ # Goal 发布回归 Runbook
2
+
3
+ > **受众**:Root npm 闸、Parent 集成前自检、维护者。
4
+ > **范围**:`cstl goal` 回归 checklist — **不扩展 Goal 功能**,仅钉死 hardening 命令。
5
+ > **基线**:`cursor-trellis` `main`(A1/A2 合并后 tip);harness 侧 `.cstl/spec/Trellis/framework/cstl-goal-*.md`。
6
+
7
+ ---
8
+
9
+ ## 1. 发布门语义
10
+
11
+ | 项 | 说明 |
12
+ | --- | --- |
13
+ | **用途** | npm 发布前 Goal 回归闸;Parent `verify.md` 可链接本页 |
14
+ | **非目标** | 不新增 runner/worker 能力;不替代 [cursor-trellis release runbook](./cursor-trellis-release-coexistence-guide.md) |
15
+ | **通过标准** | Mock 路径全绿(§2);Live 路径(§3)为可选加分项 |
16
+ | **零功能 diff** | 本闸仅文档与命令;**不得**附带 `cursor-trellis/packages/cli/src/goal/*` 语义变更 |
17
+
18
+ ---
19
+
20
+ ## 2. Mock 路径(必须 — 无需 `CURSOR_API_KEY`)
21
+
22
+ 在 harness 根目录执行。CI / 新人 onboarding 至少跑完本节。
23
+
24
+ ### 2.1 全量 Goal 测试
25
+
26
+ ```powershell
27
+ cd cursor-trellis/packages/cli
28
+ pnpm test goal/
29
+ ```
30
+
31
+ **期望:** 7 个 test files、32 tests 全部 PASS。
32
+
33
+ ### 2.2 Golden + 墙单元测试
34
+
35
+ ```powershell
36
+ cd cursor-trellis/packages/cli
37
+ pnpm exec vitest run test/goal/reviewer-golden.test.ts test/goal/walls.test.ts
38
+ ```
39
+
40
+ **期望:**
41
+
42
+ - `mis-allow gate is zero on hard-deny bucket` 通过
43
+ - `walls.test.ts` 墙钟逻辑通过
44
+
45
+ ### 2.3 墙 smoke 脚本语法
46
+
47
+ ```powershell
48
+ python -m py_compile .cstl/scripts/goal_wall_smoke.py
49
+ ```
50
+
51
+ ### 2.4 可选 — 墙钟 crash 可复现 smoke
52
+
53
+ 需已有 goal run 目录(`goal_id` 来自历史 hardening 或本地狗粮):
54
+
55
+ ```powershell
56
+ python ./.cstl/scripts/goal_wall_smoke.py <goal_id> --mode window --json
57
+ ```
58
+
59
+ **期望:** JSON 中 `ok: true`;`audit.log` 含 `wall-clock reached`。
60
+
61
+ ---
62
+
63
+ ## 3. Live 路径(可选 — 需要 `CURSOR_API_KEY`)
64
+
65
+ 仅当维护者显式同意 live SDK 狗粮时执行。Cursor Agent shell **默认不继承** User 级环境变量,须先加载:
66
+
67
+ ```powershell
68
+ $env:CURSOR_API_KEY = [Environment]::GetEnvironmentVariable('CURSOR_API_KEY','User')
69
+ ```
70
+
71
+ ### 3.1 Preflight → Accept → Run
72
+
73
+ ```powershell
74
+ cstl goal preflight --goal "..." --json
75
+ cstl goal accept <goal_id>
76
+ cstl goal run <goal_id> --max-steps 1 --json
77
+ ```
78
+
79
+ CI 风格可用 mock worker(无需 live SDK):
80
+
81
+ ```powershell
82
+ cstl goal run <goal_id> --mock-worker --max-steps 1 --json
83
+ ```
84
+
85
+ 若全局 `cstl` 未 link 最新 dist,改用本地 CLI:
86
+
87
+ ```powershell
88
+ node cursor-trellis/packages/cli/dist/cli/index.js goal preflight --goal "..." --json
89
+ ```
90
+
91
+ ---
92
+
93
+ ## 4. 契约引用
94
+
95
+ 回归失败时对照合同,勿在发布闸中改语义:
96
+
97
+ | 文档 | 路径 |
98
+ | --- | --- |
99
+ | cstl-goal 验收合同 | [`.cstl/spec/Trellis/framework/cstl-goal-contract.md`](../Trellis/framework/cstl-goal-contract.md) |
100
+ | Action Packet | [`.cstl/spec/Trellis/framework/cstl-goal-action-packet.md`](../Trellis/framework/cstl-goal-action-packet.md) |
101
+ | Golden 用例 | `cursor-trellis/packages/cli/test/fixtures/goal-reviewer-golden/cases.json` |
102
+
103
+ ---
104
+
105
+ ## 5. SDK 残余风险(须诚实记录)
106
+
107
+ | 来源 | 结论 |
108
+ | --- | --- |
109
+ | `@cursor/sdk` `Agent.prompt` | `sdk-client.ts` 包装为**单次** `Promise`,**无** mid-run cancel / abort 参数 |
110
+ | Goal SDK worker | `worker.ts` 仅外层 `withTimeout(..., ctx.timeoutMs)` |
111
+ | smart-search docs 探针(2026-08-07) | 未发现官方 mid-run cancel API — **按 timeout-only 风险处理** |
112
+
113
+ **实践建议:**
114
+
115
+ - Live 回归控制 `--max-steps` 与 wall 配置
116
+ - 长步无法保证 turn 中途取消;超时后进程可能仍占用资源直至 Promise settle
117
+ - 无 key 环境一律用 `--mock-worker` 或 §2 Mock 路径
118
+
119
+ ---
120
+
121
+ ## 6. 快速 Checklist
122
+
123
+ - [ ] `pnpm test goal/` — 32 PASS
124
+ - [ ] `reviewer-golden.test.ts` + `walls.test.ts` — PASS
125
+ - [ ] `python -m py_compile .cstl/scripts/goal_wall_smoke.py` — OK
126
+ - [ ] (可选)`goal_wall_smoke.py <goal_id> --mode window --json` — `ok: true`
127
+ - [ ] (可选 live)`cstl goal preflight` / `accept` / `run --max-steps 1`
128
+ - [ ] **无** `cursor-trellis/packages/cli/src/goal/*` 功能 diff
129
+
130
+ ---
131
+
132
+ **来源:** `08-06-cstl-p2-goal-hardening/verify.md` · Parent `08-07-cstl-parent-orch-visibility` §5.2
@@ -1,104 +1,144 @@
1
- # Thinking Guides
2
-
3
- > **Purpose**: Expand your thinking to catch things you might not have considered.
4
-
5
- ---
6
-
7
- ## Why Thinking Guides?
8
-
9
- **Most bugs and tech debt come from "didn't think of that"**, not from lack of skill:
10
-
11
- - Didn't think about what happens at layer boundaries → cross-layer bugs
12
- - Didn't think about code patterns repeating → duplicated code everywhere
13
- - Didn't think about edge cases → runtime errors
14
- - Didn't think about future maintainers → unreadable code
15
-
16
- These guides help you **ask the right questions before coding**.
17
-
18
- ---
19
-
20
- ## Available Guides
21
-
22
- | Guide | Purpose | When to Use |
23
- |-------|---------|-------------|
24
- | [Durable Learning Decision Guide](./durable-learning-decision-guide.md) | Choose no-learning vs spec update vs learning artifact before archive | Finishing a task, parent review, or after `/cstl:break-loop` |
25
- | [Code Reuse Thinking Guide](./code-reuse-thinking-guide.md) | Identify patterns and reduce duplication | When you notice repeated patterns |
26
- | [Cross-Layer Thinking Guide](./cross-layer-thinking-guide.md) | Think through data flow across layers | Features spanning multiple layers |
27
- | [Retrieval daily guide](./retrieval-daily-guide.md) | rg / codegraph / fast-context / smart-search / pack / router | Planning, research, finish verification |
28
- | [Cursor semantic compliance](./cursor-semantic-compliance.md) | Native planned vs executed semantic (`SemanticSearch`, classify_tool_calls) | Retrieval eval, OC-15 compliance runs, telemetry interpretation |
29
- | [Cursor subagent policy](./cursor-subagent-policy.md) | Task tool scenes, Agent mode, `model_policy: cursor-configured`, Cursor++ | Parent/Child dispatch, research/implement/check, parallel execution |
30
- | [Execution strategy](./execution-strategy.md) | `suggest-execution-strategy`, rules JSON, inline vs worker vs child-task | Writing `implement.md` contract, Phase 2 dispatch |
31
- | [Cursor context injection guide](./cursor-context-injection-guide.md) | Which Cursor channels reach the model (sessionStart bug, .cursor/rules, AGENTS.md) | "Agent ignored instructions" on Cursor, adding always-visible rules |
32
- | [cursor-trellis release & coexistence](./cursor-trellis-release-coexistence-guide.md) | npm publish runbook, `cstl-v*` tags, upstream Trellis coexistence | Releasing cstl, scenario 2 init, migrate gate, uninstall AGENTS strip |
33
-
34
- ---
35
-
36
- ## Quick Reference: Thinking Triggers
37
-
38
- ### When to Think About Cross-Layer Issues
39
-
40
- - [ ] Feature touches 3+ layers (API, Service, Component, Database)
41
- - [ ] Data format changes between layers
42
- - [ ] Multiple consumers need the same data
43
- - [ ] You're not sure where to put some logic
44
- - [ ] You are adding an event kind, JSONL record, RPC payload, or config field
45
- - [ ] UI / command code starts casting raw payload fields directly
46
-
47
- → Read [Cross-Layer Thinking Guide](./cross-layer-thinking-guide.md)
48
-
49
- ### When to Think About Code Reuse
50
-
51
- - [ ] You're writing similar code to something that exists
52
- - [ ] You see the same pattern repeated 3+ times
53
- - [ ] You're adding a new field to multiple places
54
- - [ ] **You're modifying any constant or config**
55
- - [ ] **You're creating a new utility/helper function** ← Search first!
56
- - [ ] Two files read the same untyped payload field with local casts
57
- - [ ] Multiple branches update the same derived state from `kind` / `action`
58
-
59
- Read [Code Reuse Thinking Guide](./code-reuse-thinking-guide.md)
60
-
61
- ### When Verifying AI Cross-Review Results
62
-
63
- - [ ] Reviewer claims "user input can be malicious" → Check the actual data source (internal manifest? user config? external API?)
64
- - [ ] Reviewer flags "missing validation" → Is the data from a trusted internal source?
65
- - [ ] Reviewer says "behavior change" → Read the code comments is it intentional design?
66
- - [ ] Reviewer identifies a "bug" in test → Mentally delete the feature being tested does the test still pass? If yes → tautological test
67
-
68
- **Common AI reviewer false-positive patterns**:
69
- 1. **Trust boundary confusion**: Treating internal data (bundled JSON manifests) as untrusted external input
70
- 2. **Ignoring design comments**: Flagging intentional behavior documented in code comments as bugs
71
- 3. **Variable misreading**: Not tracing a variable to its actual definition (e.g., Map keyed by path vs name)
72
-
73
- **Verification rule**: Every CRITICAL/WARNING finding must be verified against the actual code before prioritizing. Budget ~35% false-positive rate for AI reviews.
74
-
75
- ---
76
-
77
- ## Pre-Modification Rule (CRITICAL)
78
-
79
- > **Before changing ANY value, ALWAYS search first!**
80
-
81
- ```bash
82
- # Search for the value you're about to change
83
- grep -r "value_to_change" .
84
- ```
85
-
86
- This single habit prevents most "forgot to update X" bugs.
87
-
88
- ---
89
-
90
- ## How to Use This Directory
91
-
92
- 1. **Before coding**: Skim the relevant thinking guide
93
- 2. **During coding**: If something feels repetitive or complex, check the guides
94
- 3. **After bugs**: Add new insights to the relevant guide (learn from mistakes)
95
-
96
- ---
97
-
98
- ## Contributing
99
-
100
- Found a new "didn't think of that" moment? Add it to the relevant guide.
101
-
102
- ---
103
-
104
- **Core Principle**: 30 minutes of thinking saves 3 hours of debugging.
1
+ # Thinking Guides
2
+
3
+ > **Purpose**: Expand your thinking to catch things you might not have considered.
4
+
5
+ ---
6
+
7
+ ## Why Thinking Guides?
8
+
9
+ **Most bugs and tech debt come from "didn't think of that"**, not from lack of skill:
10
+
11
+ - Didn't think about what happens at layer boundaries → cross-layer bugs
12
+ - Didn't think about code patterns repeating → duplicated code everywhere
13
+ - Didn't think about edge cases → runtime errors
14
+ - Didn't think about future maintainers → unreadable code
15
+
16
+ These guides help you **ask the right questions before coding**.
17
+
18
+ ---
19
+
20
+ ## Available Guides
21
+
22
+ | Guide | Purpose | When to Use |
23
+ |-------|---------|-------------|
24
+ | [Durable Learning Decision Guide](./durable-learning-decision-guide.md) | Choose no-learning vs spec update vs learning artifact before archive | Finishing a task, parent review, or after `/cstl:break-loop` |
25
+ | [Verification Strength Guide](./verification-strength-guide.md) | Graded verify depth (Lite/Full/Parent × verification_profile); false-green probes; **not** TDD | Phase 3.1, writing `verify.md`, choosing check depth, archive prep |
26
+ | [Debug Loop Guide](./debug-loop-guide.md) | Debug discipline: tight red-capable feedback loop before hypotheses; six phases; `[DEBUG-xxx]` tags; Redact; PS7 HITL | User reports a hard bug / performance regression; diagnosis in progress (before `cstl-break-loop`) |
27
+ | [Test Discipline Guide](./test-discipline-guide.md) | 测试写作纪律:pre-agreed seams、垂直切片、三反模式、mock 边界;**不是 TDD 要求** | Writing or reviewing tests; planning what to test; choosing mock boundaries |
28
+ | [Prototype Guide](./prototype-guide.md) | 原型纪律:一次性代码回答设计问题;问题决定形态;LOGIC/Python 默认、UI 不适用;折叠重写不 mv、留证 + 清理 | A design question needs a runnable throwaway answer (mechanism / state model / algorithm); folding a verdict into design or real code |
29
+ | [Injection Budget Guide](./injection-budget-guide.md) | Per-channel caps, jsonl manifest limits, Layer 2 defaults; matrix-aligned | Adding alwaysApply rules, curating jsonl, subagent dispatch |
30
+ | [Code Reuse Thinking Guide](./code-reuse-thinking-guide.md) | Identify patterns and reduce duplication | When you notice repeated patterns |
31
+ | [Cross-Layer Thinking Guide](./cross-layer-thinking-guide.md) | Think through data flow across layers | Features spanning multiple layers |
32
+ | [Retrieval daily guide](./retrieval-daily-guide.md) | rg / codegraph / fast-context / smart-search / pack / router | Planning, research, finish verification |
33
+ | [Cursor semantic compliance](./cursor-semantic-compliance.md) | Native planned vs executed semantic (`SemanticSearch`, classify_tool_calls) | Retrieval eval, OC-15 compliance runs, telemetry interpretation |
34
+ | [Cursor subagent policy](./cursor-subagent-policy.md) | Task tool scenes, Agent mode, `model_policy: cursor-configured`, Cursor++ | Parent/Child dispatch, research/implement/check, parallel execution |
35
+ | [Execution strategy](./execution-strategy.md) | `suggest-execution-strategy`, rules JSON, inline vs worker vs child-task | Writing `implement.md` contract, Phase 2 dispatch |
36
+ | [Cursor context injection guide](./cursor-context-injection-guide.md) | Which Cursor channels reach the model (sessionStart bug, .cursor/rules, AGENTS.md) | "Agent ignored instructions" on Cursor, adding always-visible rules |
37
+ | [Cursor native modes guide](./cursor-native-modes-guide.md) | Prefer Plan / Ask / Debug / Agent / Multitask × Trellis phases & artifacts | P1 mode routing, Parent/Multitask, Ask↔No Task, Plan↔Phase 1, Debug evidence |
38
+ | [Artifact locale guide](./artifact-locale-guide.md) | Human-reviewed PRD/design/implement/verify/handoff language (zh \| en) | `task.py create`, planning skills, session context; not full CLI i18n |
39
+ | [cursor-trellis release & coexistence](./cursor-trellis-release-coexistence-guide.md) | npm publish runbook, `cstl-v*` tags, upstream Trellis coexistence | Releasing cstl, scenario 2 init, migrate gate, uninstall AGENTS strip |
40
+ | [Goal release regression runbook](./goal-release-regression-runbook.md) | Goal npm 发布前回归闸:mock/live 命令、契约路径、SDK timeout 残余风险 | Root npm 闸、Parent integrate 前 Goal 自检、hardening 后发布 |
41
+
42
+ ### When using `/cstl-goal` (optional long-horizon mode)
43
+
44
+ - [ ] User explicitly invoked `/cstl-goal` default cstl spine unchanged otherwise
45
+ - [ ] Read [cstl-goal Contract](../Trellis/framework/cstl-goal-contract.md) §1 preflight + §3 hard deny before G1 self-drive
46
+ - [ ] High-risk actions: pack per [Action Packet](../Trellis/framework/cstl-goal-action-packet.md) → reviewer seam; no bare execute
47
+
48
+ ---
49
+
50
+ ## Quick Reference: Thinking Triggers
51
+
52
+ ### When to Think About Cross-Layer Issues
53
+
54
+ - [ ] Feature touches 3+ layers (API, Service, Component, Database)
55
+ - [ ] Data format changes between layers
56
+ - [ ] Multiple consumers need the same data
57
+ - [ ] You're not sure where to put some logic
58
+ - [ ] You are adding an event kind, JSONL record, RPC payload, or config field
59
+ - [ ] UI / command code starts casting raw payload fields directly
60
+
61
+ Read [Cross-Layer Thinking Guide](./cross-layer-thinking-guide.md)
62
+
63
+ ### When to Think About Code Reuse
64
+
65
+ - [ ] You're writing similar code to something that exists
66
+ - [ ] You see the same pattern repeated 3+ times
67
+ - [ ] You're adding a new field to multiple places
68
+ - [ ] **You're modifying any constant or config**
69
+ - [ ] **You're creating a new utility/helper function** Search first!
70
+ - [ ] Two files read the same untyped payload field with local casts
71
+ - [ ] Multiple branches update the same derived state from `kind` / `action`
72
+
73
+ Read [Code Reuse Thinking Guide](./code-reuse-thinking-guide.md)
74
+
75
+ ### When Verifying AI Cross-Review Results
76
+
77
+ - [ ] Reviewer claims "user input can be malicious" → Check the actual data source (internal manifest? user config? external API?)
78
+ - [ ] Reviewer flags "missing validation" → Is the data from a trusted internal source?
79
+ - [ ] Reviewer says "behavior change" → Read the code comments — is it intentional design?
80
+ - [ ] Reviewer identifies a "bug" in test → Mentally delete the feature being tested — does the test still pass? If yes → tautological test
81
+
82
+ **Common AI reviewer false-positive patterns**:
83
+ 1. **Trust boundary confusion**: Treating internal data (bundled JSON manifests) as untrusted external input
84
+ 2. **Ignoring design comments**: Flagging intentional behavior documented in code comments as bugs
85
+ 3. **Variable misreading**: Not tracing a variable to its actual definition (e.g., Map keyed by path vs name)
86
+
87
+ **Verification rule**: Every CRITICAL/WARNING finding must be verified against the actual code before prioritizing. Budget ~35% false-positive rate for AI reviews.
88
+
89
+ ### When Debugging Hard Bugs or Performance Regressions
90
+
91
+ - [ ] User reports something broken / throwing / failing / slow, and it is not obvious at a glance
92
+ - [ ] You find yourself about to read code to form a theory before you have a runnable repro command
93
+ - [ ] A fix attempt failed and you have no regression to prove the fix
94
+ - [ ] You need a human-in-the-loop repro script (PowerShell 7)
95
+
96
+ → Read [Debug Loop Guide](./debug-loop-guide.md) (diagnosis in progress; run `cstl-break-loop` after the fix)
97
+
98
+ ### When Writing or Reviewing Tests
99
+
100
+ - [ ] You're about to write tests for new or existing behavior
101
+ - [ ] You're reviewing a test that breaks on refactor without a behavior change
102
+ - [ ] You need to decide what to mock and where the seam is
103
+ - [ ] Test expectations seem to restate the implementation
104
+
105
+ → Read [Test Discipline Guide](./test-discipline-guide.md)
106
+
107
+ ### When a Design Question Needs a Runnable Throwaway
108
+
109
+ - [ ] 你在验证一个机制 / 状态模型 / 算法「感不感觉对」——不是 bug 调试,是设计验证
110
+ - [ ] 结论要写回 design / prd / 真实代码,但想先跑起来看证据
111
+ - [ ] 准备写一次性脚本回答「如果……会怎样」
112
+
113
+ → Read [Prototype Guide](./prototype-guide.md) (LOGIC/Python default; UI N/A; fold+evidence+cleanup)
114
+
115
+ ---
116
+
117
+ ## Pre-Modification Rule (CRITICAL)
118
+
119
+ > **Before changing ANY value, ALWAYS search first!**
120
+
121
+ ```bash
122
+ # Search for the value you're about to change
123
+ grep -r "value_to_change" .
124
+ ```
125
+
126
+ This single habit prevents most "forgot to update X" bugs.
127
+
128
+ ---
129
+
130
+ ## How to Use This Directory
131
+
132
+ 1. **Before coding**: Skim the relevant thinking guide
133
+ 2. **During coding**: If something feels repetitive or complex, check the guides
134
+ 3. **After bugs**: Add new insights to the relevant guide (learn from mistakes)
135
+
136
+ ---
137
+
138
+ ## Contributing
139
+
140
+ Found a new "didn't think of that" moment? Add it to the relevant guide.
141
+
142
+ ---
143
+
144
+ **Core Principle**: 30 minutes of thinking saves 3 hours of debugging.