@blxzer/cursor-trellis 0.3.4 → 0.3.6

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 (210) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/README.md +13 -13
  3. package/README.zh-CN.md +1 -1
  4. package/bin/cstl.js +1 -1
  5. package/bin/smart-search.js +1 -1
  6. package/dist/cli/index.d.ts.map +1 -1
  7. package/dist/cli/index.js +17 -2
  8. package/dist/cli/index.js.map +1 -1
  9. package/dist/commands/campaign/canvas-render.d.ts +68 -0
  10. package/dist/commands/campaign/canvas-render.d.ts.map +1 -0
  11. package/dist/commands/campaign/canvas-render.js +414 -0
  12. package/dist/commands/campaign/canvas-render.js.map +1 -0
  13. package/dist/commands/campaign/compose.d.ts +15 -0
  14. package/dist/commands/campaign/compose.d.ts.map +1 -0
  15. package/dist/commands/campaign/compose.js +110 -0
  16. package/dist/commands/campaign/compose.js.map +1 -0
  17. package/dist/commands/campaign/index.d.ts +13 -0
  18. package/dist/commands/campaign/index.d.ts.map +1 -0
  19. package/dist/commands/campaign/index.js +134 -0
  20. package/dist/commands/campaign/index.js.map +1 -0
  21. package/dist/commands/campaign/kind-map.d.ts +6 -0
  22. package/dist/commands/campaign/kind-map.d.ts.map +1 -0
  23. package/dist/commands/campaign/kind-map.js +21 -0
  24. package/dist/commands/campaign/kind-map.js.map +1 -0
  25. package/dist/commands/campaign/mcp-server.d.ts +6 -0
  26. package/dist/commands/campaign/mcp-server.d.ts.map +1 -0
  27. package/dist/commands/campaign/mcp-server.js +167 -0
  28. package/dist/commands/campaign/mcp-server.js.map +1 -0
  29. package/dist/commands/campaign/render.d.ts +5 -0
  30. package/dist/commands/campaign/render.d.ts.map +1 -0
  31. package/dist/commands/campaign/render.js +103 -0
  32. package/dist/commands/campaign/render.js.map +1 -0
  33. package/dist/commands/campaign/trellis-load.d.ts +13 -0
  34. package/dist/commands/campaign/trellis-load.d.ts.map +1 -0
  35. package/dist/commands/campaign/trellis-load.js +122 -0
  36. package/dist/commands/campaign/trellis-load.js.map +1 -0
  37. package/dist/commands/campaign/types.d.ts +61 -0
  38. package/dist/commands/campaign/types.d.ts.map +1 -0
  39. package/dist/commands/campaign/types.js +3 -0
  40. package/dist/commands/campaign/types.js.map +1 -0
  41. package/dist/commands/goal/index.d.ts +3 -0
  42. package/dist/commands/goal/index.d.ts.map +1 -0
  43. package/dist/commands/goal/index.js +159 -0
  44. package/dist/commands/goal/index.js.map +1 -0
  45. package/dist/commands/goal/review.d.ts +6 -0
  46. package/dist/commands/goal/review.d.ts.map +1 -0
  47. package/dist/commands/goal/review.js +28 -0
  48. package/dist/commands/goal/review.js.map +1 -0
  49. package/dist/commands/init.d.ts.map +1 -1
  50. package/dist/commands/init.js +11 -1
  51. package/dist/commands/init.js.map +1 -1
  52. package/dist/commands/rpc/client.d.ts +51 -0
  53. package/dist/commands/rpc/client.d.ts.map +1 -0
  54. package/dist/commands/rpc/client.js +147 -0
  55. package/dist/commands/rpc/client.js.map +1 -0
  56. package/dist/commands/rpc/index.d.ts +10 -0
  57. package/dist/commands/rpc/index.d.ts.map +1 -0
  58. package/dist/commands/rpc/index.js +157 -0
  59. package/dist/commands/rpc/index.js.map +1 -0
  60. package/dist/commands/rpc/serve.d.ts +23 -0
  61. package/dist/commands/rpc/serve.d.ts.map +1 -0
  62. package/dist/commands/rpc/serve.js +60 -0
  63. package/dist/commands/rpc/serve.js.map +1 -0
  64. package/dist/commands/rpc/smoke.d.ts +16 -0
  65. package/dist/commands/rpc/smoke.d.ts.map +1 -0
  66. package/dist/commands/rpc/smoke.js +92 -0
  67. package/dist/commands/rpc/smoke.js.map +1 -0
  68. package/dist/commands/sdk/index.d.ts +9 -0
  69. package/dist/commands/sdk/index.d.ts.map +1 -0
  70. package/dist/commands/sdk/index.js +58 -0
  71. package/dist/commands/sdk/index.js.map +1 -0
  72. package/dist/commands/sdk/run.d.ts +42 -0
  73. package/dist/commands/sdk/run.d.ts.map +1 -0
  74. package/dist/commands/sdk/run.js +220 -0
  75. package/dist/commands/sdk/run.js.map +1 -0
  76. package/dist/commands/sdk/status.d.ts +14 -0
  77. package/dist/commands/sdk/status.d.ts.map +1 -0
  78. package/dist/commands/sdk/status.js +69 -0
  79. package/dist/commands/sdk/status.js.map +1 -0
  80. package/dist/configurators/workflow.d.ts.map +1 -1
  81. package/dist/configurators/workflow.js +13 -1
  82. package/dist/configurators/workflow.js.map +1 -1
  83. package/dist/goal/action-packet.d.ts +89 -0
  84. package/dist/goal/action-packet.d.ts.map +1 -0
  85. package/dist/goal/action-packet.js +113 -0
  86. package/dist/goal/action-packet.js.map +1 -0
  87. package/dist/goal/audit.d.ts +14 -0
  88. package/dist/goal/audit.d.ts.map +1 -0
  89. package/dist/goal/audit.js +12 -0
  90. package/dist/goal/audit.js.map +1 -0
  91. package/dist/goal/constants.d.ts +26 -0
  92. package/dist/goal/constants.d.ts.map +1 -0
  93. package/dist/goal/constants.js +24 -0
  94. package/dist/goal/constants.js.map +1 -0
  95. package/dist/goal/paths.d.ts +8 -0
  96. package/dist/goal/paths.d.ts.map +1 -0
  97. package/dist/goal/paths.js +36 -0
  98. package/dist/goal/paths.js.map +1 -0
  99. package/dist/goal/preflight.d.ts +21 -0
  100. package/dist/goal/preflight.d.ts.map +1 -0
  101. package/dist/goal/preflight.js +97 -0
  102. package/dist/goal/preflight.js.map +1 -0
  103. package/dist/goal/review-seam.d.ts +44 -0
  104. package/dist/goal/review-seam.d.ts.map +1 -0
  105. package/dist/goal/review-seam.js +153 -0
  106. package/dist/goal/review-seam.js.map +1 -0
  107. package/dist/goal/reviewer-rules.d.ts +13 -0
  108. package/dist/goal/reviewer-rules.d.ts.map +1 -0
  109. package/dist/goal/reviewer-rules.js +153 -0
  110. package/dist/goal/reviewer-rules.js.map +1 -0
  111. package/dist/goal/reviewer.d.ts +9 -0
  112. package/dist/goal/reviewer.d.ts.map +1 -0
  113. package/dist/goal/reviewer.js +54 -0
  114. package/dist/goal/reviewer.js.map +1 -0
  115. package/dist/goal/runtime.d.ts +32 -0
  116. package/dist/goal/runtime.d.ts.map +1 -0
  117. package/dist/goal/runtime.js +242 -0
  118. package/dist/goal/runtime.js.map +1 -0
  119. package/dist/goal/sdk-client.d.ts +10 -0
  120. package/dist/goal/sdk-client.d.ts.map +1 -0
  121. package/dist/goal/sdk-client.js +34 -0
  122. package/dist/goal/sdk-client.js.map +1 -0
  123. package/dist/goal/state.d.ts +40 -0
  124. package/dist/goal/state.d.ts.map +1 -0
  125. package/dist/goal/state.js +37 -0
  126. package/dist/goal/state.js.map +1 -0
  127. package/dist/goal/task-triggers.d.ts +15 -0
  128. package/dist/goal/task-triggers.d.ts.map +1 -0
  129. package/dist/goal/task-triggers.js +23 -0
  130. package/dist/goal/task-triggers.js.map +1 -0
  131. package/dist/goal/walls.d.ts +12 -0
  132. package/dist/goal/walls.d.ts.map +1 -0
  133. package/dist/goal/walls.js +65 -0
  134. package/dist/goal/walls.js.map +1 -0
  135. package/dist/goal/worker-prompt.d.ts +13 -0
  136. package/dist/goal/worker-prompt.d.ts.map +1 -0
  137. package/dist/goal/worker-prompt.js +41 -0
  138. package/dist/goal/worker-prompt.js.map +1 -0
  139. package/dist/goal/worker.d.ts +42 -0
  140. package/dist/goal/worker.d.ts.map +1 -0
  141. package/dist/goal/worker.js +180 -0
  142. package/dist/goal/worker.js.map +1 -0
  143. package/dist/migrations/manifests/0.3.5.json +9 -0
  144. package/dist/migrations/manifests/0.3.6.json +9 -0
  145. package/dist/templates/common/bundled-skills/smart-search-cli/SKILL.md +35 -29
  146. package/dist/templates/common/bundled-skills/smart-search-cli/references/cli-contract.md +11 -25
  147. package/dist/templates/common/commands/continue.md +15 -3
  148. package/dist/templates/common/skills/check.md +7 -4
  149. package/dist/templates/cursor/agents/cstl-check.md +1 -0
  150. package/dist/templates/cursor/fixtures/expected-rules.d.ts.map +1 -1
  151. package/dist/templates/cursor/fixtures/expected-rules.js +6 -1
  152. package/dist/templates/cursor/fixtures/expected-rules.js.map +1 -1
  153. package/dist/templates/cursor/rules/cstl-cursor-modes.mdc +32 -0
  154. package/dist/templates/cursor/rules/cstl-triage.mdc +2 -4
  155. package/dist/templates/cursor/rules/retrieval-routing.mdc +26 -7
  156. package/dist/templates/markdown/agents.md +2 -0
  157. package/dist/templates/markdown/index.d.ts +3 -0
  158. package/dist/templates/markdown/index.d.ts.map +1 -1
  159. package/dist/templates/markdown/index.js +3 -0
  160. package/dist/templates/markdown/index.js.map +1 -1
  161. package/dist/templates/markdown/spec/guides/cursor-context-injection-guide.md.txt +38 -21
  162. package/dist/templates/markdown/spec/guides/cursor-native-modes-guide.md.txt +125 -0
  163. package/dist/templates/markdown/spec/guides/index.md.txt +107 -104
  164. package/dist/templates/markdown/spec/guides/injection-budget-guide.md.txt +111 -0
  165. package/dist/templates/markdown/spec/guides/retrieval-daily-guide.md.txt +38 -6
  166. package/dist/templates/markdown/spec/guides/verification-strength-guide.md.txt +184 -0
  167. package/dist/templates/shared-hooks/session-start.py +10 -0
  168. package/dist/templates/trellis/config.yaml +18 -0
  169. package/dist/templates/trellis/index.d.ts +5 -0
  170. package/dist/templates/trellis/index.d.ts.map +1 -1
  171. package/dist/templates/trellis/index.js +14 -0
  172. package/dist/templates/trellis/index.js.map +1 -1
  173. package/dist/templates/trellis/scripts/common/artifact_locale.py +278 -0
  174. package/dist/templates/trellis/scripts/common/codebase_retrieval_router.py +51 -2
  175. package/dist/templates/trellis/scripts/common/config.py +39 -0
  176. package/dist/templates/trellis/scripts/common/injection_budget.py +317 -0
  177. package/dist/templates/trellis/scripts/common/parent_orchestration.py +500 -5
  178. package/dist/templates/trellis/scripts/common/retrieval_agent_instructions.py +9 -3
  179. package/dist/templates/trellis/scripts/common/session_context.py +32 -4
  180. package/dist/templates/trellis/scripts/common/session_memory.py +26 -0
  181. package/dist/templates/trellis/scripts/common/subagent_dispatch.py +74 -9
  182. package/dist/templates/trellis/scripts/common/task_context.py +18 -0
  183. package/dist/templates/trellis/scripts/common/task_dashboard.py +16 -1
  184. package/dist/templates/trellis/scripts/common/task_map.py +670 -614
  185. package/dist/templates/trellis/scripts/common/task_store.py +191 -40
  186. package/dist/templates/trellis/scripts/common/test_observable_defaults.py +135 -0
  187. package/dist/templates/trellis/scripts/cursor_retrieval_probe_prompt.md +14 -12
  188. package/dist/templates/trellis/scripts/generate_dispatch_prompt.py +182 -0
  189. package/dist/templates/trellis/scripts/injection_budget_probe.py +69 -0
  190. package/dist/templates/trellis/scripts/retrieval_probe_matrix_template.json +3 -3
  191. package/dist/templates/trellis/scripts/spec_health_outcomes.py +160 -0
  192. package/dist/templates/trellis/scripts/task.py +51 -0
  193. package/dist/templates/trellis/tasks/locale/en/default-prd.md +19 -0
  194. package/dist/templates/trellis/tasks/locale/zh/default-prd.md +19 -0
  195. package/dist/templates/trellis/workflow.md +23 -3
  196. package/dist/utils/codebase-retrieval-router.d.ts.map +1 -1
  197. package/dist/utils/codebase-retrieval-router.js +14 -0
  198. package/dist/utils/codebase-retrieval-router.js.map +1 -1
  199. package/dist/utils/cursor-sdk-gate.d.ts +10 -0
  200. package/dist/utils/cursor-sdk-gate.d.ts.map +1 -0
  201. package/dist/utils/cursor-sdk-gate.js +32 -0
  202. package/dist/utils/cursor-sdk-gate.js.map +1 -0
  203. package/dist/utils/project-capabilities.d.ts +30 -3
  204. package/dist/utils/project-capabilities.d.ts.map +1 -1
  205. package/dist/utils/project-capabilities.js +182 -11
  206. package/dist/utils/project-capabilities.js.map +1 -1
  207. package/dist/utils/readiness.d.ts.map +1 -1
  208. package/dist/utils/readiness.js +26 -0
  209. package/dist/utils/readiness.js.map +1 -1
  210. package/package.json +4 -3
@@ -4,29 +4,29 @@
4
4
 
5
5
  ---
6
6
 
7
- ## The channel matrix (verified 2026-06-19)
7
+ ## The channel matrix (verified 2026-08-05, Cursor Native 3.8.x)
8
8
 
9
- Cursor has **four** channels that can put text in front of the model. They are **not** equally reliable:
9
+ Cursor has **several** channels that can put text in front of the model. They are **not** equally reliable:
10
10
 
11
11
  | Channel | How it loads | Reliable on Cursor? | Trellis content here |
12
12
  |---|---|---|---|
13
- | `.cursor/rules/*.mdc` (`alwaysApply: true`) | Prepended before **every** prompt, independent path | ✅ **Yes** | `cstl-triage.mdc` (Request Triage hard gate) |
14
- | `beforeSubmitPrompt` hook `additional_context` | Per user message; router emits `## 代码库检索计划` | ⚠️ **Verify on your Cursor build** (docs list field; forum reports vary) | `inject-retrieval-plan.py` + `retrieval-routing.mdc` enforcement |
15
- | `AGENTS.md` (repo root + nested) | Read automatically, treated as an always-on rule | ✅ **Yes** | smart-search-first rule, command surface, remote policy (the `<!-- TRELLIS:START -->` block) |
16
- | `sessionStart` hook → `additional_context` | Hook fires, JSON parsed... **but content never reaches the model's system context** | ❌ **No (confirmed bug)** | workflow.md Phase Index + Task Dashboard + first-reply notice |
13
+ | `.cursor/rules/*.mdc` (`alwaysApply: true`) | Prepended before **every** prompt, independent path | ✅ **Yes** | `cstl-triage.mdc` (Request Triage hard gate), `retrieval-routing.mdc`, `cstl-cursor-modes.mdc` (Prefer native modes) |
14
+ | `AGENTS.md` (repo root + nested) | Read automatically, treated as an always-on rule | **Yes** | smart-search-first rule, command surface (the `<!-- CSTL:START -->` block) |
15
+ | `sessionStart` hook `additional_context` | Once per session; delivered via `hooks_context` | ✅ **Yes** (fixed — verified 2026-08-05; was #158452) | Task Dashboard, workflow Phase Index summary, first-reply notice |
16
+ | `beforeSubmitPrompt` hook → `additional_context` | Per user message; router would emit `## 代码库检索计划` | ❌ **No (telemetry-only since 2026-06-24)** | `inject-retrieval-plan.py` logs to `.cstl/.runtime/retrieval-plan-events.log`; **no injection** |
17
17
  | `.cstl/workflow.md` (read on demand) | Only if the agent explicitly runs `get_context.py` or reads the file | ⚠️ Depends on agent taking action | Full Request Triage section, Task Ladder, workflow-state breadcrumbs |
18
- | **`task.py generate-dispatch-prompt` → Task `prompt`** (CLI Layer 2) | Main session runs Trellis script before `Task(...)` | ✅ **Yes (primary for subagent task context on Cursor)** | Full embed: marker, `Selected task:`, prd/jsonl/spec bodies |
18
+ | **`task.py generate-dispatch-prompt` → Task `prompt`** (CLI Layer 2) | Main session runs Trellis script before `Task(...)` | ✅ **Yes (primary for subagent task context on Cursor)** | Full embed: marker, `Selected task:`, prd/jsonl/spec bodies (budgeted — see [injection-budget-guide](./injection-budget-guide.md)) |
19
19
 
20
- **Key takeaway**: anything that must reach the model **every turn without the agent choosing to load it** must live in `.cursor/rules` or `AGENTS.md`. Subagent task context on Cursor uses **CLI Layer 2** before Task dispatch; `preToolUse` hook injection is best-effort only (see forum reports + 2026-06-22 spike). Anything in `workflow.md` that depends on `sessionStart` injection is **invisible to Cursor agents** until the bug is fixed.
20
+ **Key takeaway**: anything that must reach the model **every turn** must live in `.cursor/rules` or `AGENTS.md`. `sessionStart` is reliable for **session-level** orientation (dashboard, workflow summary) but fires only once. Retrieval plans: use **Rules default tool order** or run `route_codebase_retrieval.py --instructions` on demand — do **not** rely on `beforeSubmitPrompt` injection. Subagent task context uses **CLI Layer 2** before Task dispatch.
21
21
 
22
22
  ---
23
23
 
24
- ## The sessionStart bug (why this guide exists)
24
+ ## The sessionStart bug (#158452) history and current status
25
25
 
26
- - **Bug**: Cursor forum #158452 — `sessionStart` hook `additional_context` is executed and JSON-parsed correctly, but the value is **never added to the agent's initial system context**.
27
- - **Status**: Confirmed by Cursor team (deanrie), internal bug filed, **no ETA** as of 2026-06-19.
28
- - **Scope**: Affects `sessionStart` and `postToolUse` `additional_context` on Cursor IDE. The `env` field of the same hook **does** work (separate storage path).
29
- - **Symptom**: hook runs (verifiable via side-channel log), valid JSON emitted, but the agent has zero awareness of the injected text (e.g. won't say a first-reply notice phrase).
26
+ - **Bug**: Cursor forum #158452 — `sessionStart` hook `additional_context` was executed and JSON-parsed correctly, but the value was **not added to the agent's initial system context** (through ~2026-06).
27
+ - **Status (2026-08-05)**: **Fixed** on Cursor Native 3.8.x first-reply-notice probe passes; `hooks_context` contains full SessionStart payload. Re-verify after major Cursor upgrades.
28
+ - **Historical scope**: Also affected `postToolUse` `additional_context` on some builds. The `env` field of the same hook uses a separate storage path.
29
+ - **Routing implication**: Even with sessionStart working, **per-turn hard gates** (Triage, retrieval policy) stay in `.cursor/rules` sessionStart fires only once per session.
30
30
 
31
31
  ### How to diagnose "is sessionStart injection actually reaching the model?"
32
32
 
@@ -38,23 +38,39 @@ Cursor has **four** channels that can put text in front of the model. They are *
38
38
 
39
39
  ## Trellis routing rules on Cursor
40
40
 
41
- Because of the bug, Trellis routes content by reliability on Cursor:
41
+ Trellis routes content by reliability on Cursor:
42
42
 
43
43
  | Trellis content | Where it lives | Why |
44
44
  |---|---|---|
45
- | **Request Triage hard gate** (classify every turn, emit `[Triage: <Mode>]`) | `.cursor/rules/cstl-triage.mdc` (`alwaysApply: true`) | Must be visible every turn; sessionStart path is broken |
46
- | **smart-search-first web routing** | `AGENTS.md` (TRELLIS:START block) | AGENTS.md is a reliable always-on channel |
47
- | **Command surface** (what's user-invocable vs internal skill) | `AGENTS.md` (TRELLIS:START block) | Same |
48
- | **Workflow phases, Task Ladder, workflow-state breadcrumbs** | `.cstl/workflow.md` | Loaded on demand via `get_context.py` / `cstl-start` / `cstl-continue`; NOT auto-injected on Cursor |
45
+ | **Request Triage hard gate** (classify every turn, emit `[Triage: <Mode>]`) | `.cursor/rules/cstl-triage.mdc` (`alwaysApply: true`) | Must be visible **every turn**; sessionStart is once-per-session |
46
+ | **Codebase retrieval policy** | `.cursor/rules/retrieval-routing.mdc` + `route_codebase_retrieval.py` | `beforeSubmitPrompt` injection is telemetry-only; Rules + router CLI |
47
+ | **Prefer Cursor native modes** (Plan/Ask/Debug/Agent/Multitask × Trellis) | `.cursor/rules/cstl-cursor-modes.mdc` + `cursor-native-modes-guide.md` | P1 orchestration; full table on demand in guide |
48
+ | **smart-search-first web routing** | `AGENTS.md` (CSTL block) | AGENTS.md is a reliable always-on channel |
49
+ | **Command surface** (what's user-invocable vs internal skill) | `AGENTS.md` (CSTL block) | Same |
50
+ | **Session orientation** (dashboard, workflow summary, first-reply notice) | `sessionStart` hook → `additional_context` | Reliable on Cursor 3.8.x+; session-level only |
51
+ | **Workflow phases, Task Ladder, workflow-state breadcrumbs** | `.cstl/workflow.md` + sessionStart summary | Full detail on demand via `get_context.py` / `cstl-continue` |
49
52
 
50
- **If a new "must-always-be-visible" rule is added to Trellis**: ship it as a `.cursor/rules/*.mdc` (Cursor) — do **not** rely on adding it to `workflow.md` and expecting sessionStart to deliver it.
53
+ **If a new "must-always-be-visible" rule is added to Trellis**: ship it as a `.cursor/rules/*.mdc` (Cursor) — do **not** rely on `workflow.md` or sessionStart alone for per-turn enforcement. Run `injection_budget_probe.py` after adding rules (see [injection-budget-guide](./injection-budget-guide.md)).
54
+
55
+ ---
56
+
57
+ ## Injection budget (P0)
58
+
59
+ Per-channel caps and jsonl/Layer 2 limits are defined in **[injection-budget-guide](./injection-budget-guide.md)**. Summary from channel matrix (2026-08-06):
60
+
61
+ - **Per-turn:** C01 Rules + C02 AGENTS only (not C04).
62
+ - **Session once:** C03 sessionStart dashboard/workflow.
63
+ - **Subagent:** C06 Layer 2 with role `max_chars` + jsonl entry/file/total caps.
64
+ - **Retrieval:** C16 Rules + router CLI on demand.
65
+
66
+ Probe: `python ./.cstl/scripts/injection_budget_probe.py --repo-root .`
51
67
 
52
68
  ---
53
69
 
54
70
  ## When to update this guide
55
71
 
56
- - Cursor ships a fix for forum #158452 mark the sessionStart row as "✅ Yes (fixed in version X)" and re-evaluate whether workflow.md content can move back to sessionStart-only.
57
- - A new Cursor injection channel appears (e.g. a working per-turn `beforeSubmitPrompt.additional_context`) add a row to the matrix.
72
+ - Cursor major upgradere-run sessionStart first-reply-notice probe and update the matrix date.
73
+ - `beforeSubmitPrompt.additional_context` becomes reliable on a future build re-enable injection in `inject-retrieval-plan.py` and update this guide.
58
74
  - Trellis adds a new `.cursor/rules/*.mdc` → add a row to the routing table.
59
75
 
60
76
  ---
@@ -62,6 +78,7 @@ Because of the bug, Trellis routes content by reliability on Cursor:
62
78
  ## Related
63
79
 
64
80
  - `cursor-subagent-policy.md` — Task tool scenes, model routing (this guide is about **context injection**, that one is about **subagent dispatch**).
81
+ - `cursor-native-modes-guide.md` — Prefer Plan/Ask/Debug/Agent/Multitask; pairs with `cstl-cursor-modes.mdc`.
65
82
  - `.cstl/workflow.md` → `### Request Triage` — the full Triage decision tree (the rule in `.cursor/rules/cstl-triage.mdc` is the slim always-apply version pointing here).
66
83
  - Task `06-19-cursor-rules-triage` (archive) — the investigation that produced this guide.
67
84
  - Cursor forum thread: https://forum.cursor.com/t/sessionstart-hook-additional-context-is-never-injected-into-agents-initial-system-context/158452
@@ -0,0 +1,125 @@
1
+ # Cursor native modes — Prefer & orchestrate (don't replace)
2
+
3
+ > **Purpose**: Task-drive Cursor **Plan / Ask / Debug / Agent / Multitask** into Trellis phases and artifacts. Prefer native when callable; **quietly** fall back to the cstl spine when not. Do **not** reimplement modes or publish an “unsupported mode” list.
4
+ >
5
+ > **Product anchor**: `.cstl/workspace/cursor-trellis-product-positioning.md` (P1).
6
+ >
7
+ > **Design lock**: Parent `research/task-driven-modes-design-lock-2026-08-06.md`.
8
+ >
9
+ > **Evidence**: `{TASK}/research/cursor-modes-external.md`, `{TASK}/research/modes-callability-matrix.md`.
10
+ >
11
+ > **Rollback**: [Rollback](#rollback).
12
+
13
+ ---
14
+
15
+ ## Principle
16
+
17
+ | Layer | Duty |
18
+ | --- | --- |
19
+ | **Cursor native** | Plan / Ask / Debug / Agent / Multitask — **try task-driven use first** |
20
+ | **cstl spine** | Triage / Phase / gates / artifacts / Parent integration — **quiet fallback** when native cannot be driven well |
21
+
22
+ **Prefer native. Invent less.** Failures drop to existing cstl paths with little commentary — never a user-facing “本版本不适配某 mode” section.
23
+
24
+ ---
25
+
26
+ ## Prefer / Adapt table (mode × Trellis × artifacts)
27
+
28
+ | Cursor mode | Prefer when | Task-driven Prefer | Quiet cstl fallback | Durable artifacts |
29
+ | --- | --- | --- | --- | --- |
30
+ | **Ask** | Explain / lookup; **no** durable change | Prefer Ask UI / side chat when the user is already there; Agent cannot `SwitchMode`→Ask | In-session **No Task** behavior (read-only, no `task.py create` without consent) | None |
31
+ | **Plan** | Scope / design / tradeoffs before code | **Try `SwitchMode(plan)`**; after review, `SwitchMode(agent)` or Build; **Save to workspace** → map into task files | Keep writing `prd.md` / `design.md` / `implement.md` + `cstl-brainstorm` in Agent | Phase 1 files |
32
+ | **Agent** | Approved build / verify | Default; `SwitchMode(agent)` when returning from Plan | — | Diff, `verify.md`, gates |
33
+ | **Debug** | Repro / runtime / regressions | Prefer real Cursor Debug when the user/session can reach it | Evidence → `verify.md`; `cstl-break-loop` if looped | Notes / logs in `verify.md` |
34
+ | **Multitask** | Independent Parent children post-approval | Prefer `/multitask` / Build in Parallel / Agent `Task` background workers **when useful** | Explicit `.cstl/tasks/<dir>` prompts + Parent `integrate-child` | Child `verify`/`handoff`; Parent `task-map` |
35
+
36
+ ### Phase quick map
37
+
38
+ ```
39
+ Triage (No Task / Micro-Grill) → Ask surface if present; else No Task in Agent
40
+ Phase 1 → SwitchMode(plan) when useful; else write artifacts in Agent
41
+ Phase 2–3 → Agent (+ workers when contracted)
42
+ Stuck / repeat failure → Debug when reachable; else verify.md + break-loop
43
+ Parent parallel children → Multitask / Task parallel when useful; Parent integrates
44
+ ```
45
+
46
+ ---
47
+
48
+ ## Mode-specific contracts
49
+
50
+ ### Ask ↔ No Task
51
+
52
+ - Official Ask does not edit files. Agent tools cannot switch into Ask.
53
+ - Classify **No Task** for pure Q&A; no task creation without consent.
54
+ - Side chats (3.11) complement Ask during Agent runs — still not Trellis artifacts.
55
+
56
+ ### Plan ↔ Phase 1
57
+
58
+ - Prefer **`SwitchMode(plan)`** for design-heavy Phase 1; care about switch-back quality.
59
+ - Default plan save = **home directory** — **Save to workspace**, then map to `{TASK}/prd.md`, `design.md`, `implement.md`.
60
+ - Does **not** skip `start-execution --check` / execution approval.
61
+ - If Plan switch or save flow is poor: **quietly** author the same files in Agent.
62
+
63
+ ### Debug ↔ evidence
64
+
65
+ - Prefer Cursor Debug instrumentation when reachable.
66
+ - Always land proof in **`verify.md`**. Contract change → Return-to-Planning.
67
+
68
+ ### Multitask ↔ Parent/Child
69
+
70
+ 1. Trellis remains source of truth for status, gates, integration.
71
+ 2. Prefer native parallel surfaces to support independent Children when they help isolation/throughput.
72
+ 3. Every worker prompt includes **explicit `.cstl/tasks/<dir>`** — never rely on `selected_task`.
73
+ 4. Parent alone `integrate-child`; no collision guarantee without worktrees + review.
74
+
75
+ ---
76
+
77
+ ## Callability (Agent tool table)
78
+
79
+ | Surface | Plan | Agent | Ask | Debug | Parallel Children |
80
+ | --- | --- | --- | --- | --- | --- |
81
+ | Agent `SwitchMode` | Yes → `plan` | Yes → `agent` | — | — | — |
82
+ | Agent `Task` / Multitask | — | workers | — | — | Prefer when useful |
83
+ | User / CLI modes | Plan UI / `/plan` | default | Ask UI / `/ask` | Debug UI | `/multitask`, Build in Parallel |
84
+
85
+ Details: `research/modes-callability-matrix.md`.
86
+
87
+ ---
88
+
89
+ ## What cstl must not claim
90
+
91
+ - Plans auto-save into `.cstl/tasks/`.
92
+ - Multitask inherits `selected_task` or exposes a stable programmatic mode API.
93
+ - Parallel agents cannot conflict without Trellis/worktree discipline.
94
+ - `SwitchMode` can open Ask or Debug.
95
+ - Shipping a parallel fake Plan/Ask/Debug product, or documenting gaps as “本版本不适配”.
96
+
97
+ ---
98
+
99
+ ## Dogfood / probes
100
+
101
+ | Mode | Minimum probe | Pass when |
102
+ | --- | --- | --- |
103
+ | **Plan** | Schema or live `SwitchMode(plan)` note in verify | Prefer path documented; quiet Agent fallback if unused |
104
+ | **Ask / Debug** | Callability matrix | Quiet spine behavior; no “不适配” section |
105
+ | **Multitask** | Task parallel or doc contract | Explicit child paths; Parent integrates |
106
+ | **Agent** | Session implements under contract | Artifacts on disk |
107
+
108
+ ---
109
+
110
+ ## Rollback
111
+
112
+ Docs + rules only:
113
+
114
+ 1. Delete `.cursor/rules/cstl-cursor-modes.mdc` and `.cstl/spec/guides/cursor-native-modes-guide.md`.
115
+ 2. Drop related `guides/index.md` / `workflow.md` rows, or `cstl update` from pre-P1 templates.
116
+ 3. **cursor-trellis**: revert this Child’s tip or delete mirrored template paths.
117
+
118
+ ---
119
+
120
+ ## Related
121
+
122
+ - `{TASK}/research/modes-callability-matrix.md`
123
+ - `{TASK}/research/cursor-modes-external.md`
124
+ - `.cursor/rules/cstl-cursor-modes.mdc`
125
+ - `.cstl/spec/guides/cursor-subagent-policy.md`
@@ -1,104 +1,107 @@
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 testMentally 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
+ | [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 |
27
+ | [Code Reuse Thinking Guide](./code-reuse-thinking-guide.md) | Identify patterns and reduce duplication | When you notice repeated patterns |
28
+ | [Cross-Layer Thinking Guide](./cross-layer-thinking-guide.md) | Think through data flow across layers | Features spanning multiple layers |
29
+ | [Retrieval daily guide](./retrieval-daily-guide.md) | rg / codegraph / fast-context / smart-search / pack / router | Planning, research, finish verification |
30
+ | [Cursor semantic compliance](./cursor-semantic-compliance.md) | Native planned vs executed semantic (`SemanticSearch`, classify_tool_calls) | Retrieval eval, OC-15 compliance runs, telemetry interpretation |
31
+ | [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 |
32
+ | [Execution strategy](./execution-strategy.md) | `suggest-execution-strategy`, rules JSON, inline vs worker vs child-task | Writing `implement.md` contract, Phase 2 dispatch |
33
+ | [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 |
34
+ | [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 |
35
+ | [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 |
36
+
37
+ ---
38
+
39
+ ## Quick Reference: Thinking Triggers
40
+
41
+ ### When to Think About Cross-Layer Issues
42
+
43
+ - [ ] Feature touches 3+ layers (API, Service, Component, Database)
44
+ - [ ] Data format changes between layers
45
+ - [ ] Multiple consumers need the same data
46
+ - [ ] You're not sure where to put some logic
47
+ - [ ] You are adding an event kind, JSONL record, RPC payload, or config field
48
+ - [ ] UI / command code starts casting raw payload fields directly
49
+
50
+ → Read [Cross-Layer Thinking Guide](./cross-layer-thinking-guide.md)
51
+
52
+ ### When to Think About Code Reuse
53
+
54
+ - [ ] You're writing similar code to something that exists
55
+ - [ ] You see the same pattern repeated 3+ times
56
+ - [ ] You're adding a new field to multiple places
57
+ - [ ] **You're modifying any constant or config**
58
+ - [ ] **You're creating a new utility/helper function** ← Search first!
59
+ - [ ] Two files read the same untyped payload field with local casts
60
+ - [ ] Multiple branches update the same derived state from `kind` / `action`
61
+
62
+ → Read [Code Reuse Thinking Guide](./code-reuse-thinking-guide.md)
63
+
64
+ ### When Verifying AI Cross-Review Results
65
+
66
+ - [ ] Reviewer claims "user input can be malicious" Check the actual data source (internal manifest? user config? external API?)
67
+ - [ ] Reviewer flags "missing validation" → Is the data from a trusted internal source?
68
+ - [ ] Reviewer says "behavior change" → Read the code comments — is it intentional design?
69
+ - [ ] Reviewer identifies a "bug" in test Mentally delete the feature being tested — does the test still pass? If yes → tautological test
70
+
71
+ **Common AI reviewer false-positive patterns**:
72
+ 1. **Trust boundary confusion**: Treating internal data (bundled JSON manifests) as untrusted external input
73
+ 2. **Ignoring design comments**: Flagging intentional behavior documented in code comments as bugs
74
+ 3. **Variable misreading**: Not tracing a variable to its actual definition (e.g., Map keyed by path vs name)
75
+
76
+ **Verification rule**: Every CRITICAL/WARNING finding must be verified against the actual code before prioritizing. Budget ~35% false-positive rate for AI reviews.
77
+
78
+ ---
79
+
80
+ ## Pre-Modification Rule (CRITICAL)
81
+
82
+ > **Before changing ANY value, ALWAYS search first!**
83
+
84
+ ```bash
85
+ # Search for the value you're about to change
86
+ grep -r "value_to_change" .
87
+ ```
88
+
89
+ This single habit prevents most "forgot to update X" bugs.
90
+
91
+ ---
92
+
93
+ ## How to Use This Directory
94
+
95
+ 1. **Before coding**: Skim the relevant thinking guide
96
+ 2. **During coding**: If something feels repetitive or complex, check the guides
97
+ 3. **After bugs**: Add new insights to the relevant guide (learn from mistakes)
98
+
99
+ ---
100
+
101
+ ## Contributing
102
+
103
+ Found a new "didn't think of that" moment? Add it to the relevant guide.
104
+
105
+ ---
106
+
107
+ **Core Principle**: 30 minutes of thinking saves 3 hours of debugging.
@@ -0,0 +1,111 @@
1
+ # Injection Budget Guide
2
+
3
+ > **Purpose**: Allocate context injection across **reliable Cursor channels** with measurable caps —「完整 = 证据密度」, not unbounded prose.
4
+
5
+ **Matrix input:** `08-06-cstl-p0-channel-baseline-matrix` → `research/channel-matrix.md` (C01–C04, C16).
6
+
7
+ ---
8
+
9
+ ## 1. Non-goals
10
+
11
+ - **No `beforeSubmitPrompt` injection** — C04 stays telemetry-only until Cursor changelog proves otherwise.
12
+ - **No black-box silent injection** — Layer 2 and jsonl loads emit stderr manifest lines.
13
+ - **No weakening gates** — Triage (`cstl-triage.mdc`), execution approval, and retrieval policy remain always-on.
14
+ - **No Auto-Trigger Skill as retrieval primary** — C16 stays Rules + `route_codebase_retrieval.py --instructions`.
15
+
16
+ ---
17
+
18
+ ## 2. Channel budget tiers
19
+
20
+ | Tier | Channels | When | Budget |
21
+ | --- | --- | --- | --- |
22
+ | **Per-turn hard** | C01 Rules, C02 AGENTS | Every agent turn | Rules total warn 20 KiB / fail 32 KiB; AGENTS CSTL block warn 4 KiB |
23
+ | **Session once** | C03 sessionStart | New session | Keep dashboard/workflow summary compact; not a substitute for per-turn rules |
24
+ | **Zero** | C04 beforeSubmit | Every message | **0** — log only |
25
+ | **Subagent only** | C06 Layer 2 | `generate_dispatch_prompt` → Task | Role default `max_chars` + jsonl caps (§3) |
26
+ | **On demand** | C16 retrieval | When agent needs a plan | Rules default order or router CLI; no per-message plan block |
27
+
28
+ ---
29
+
30
+ ## 3. JSONL manifest budgets (implement / check)
31
+
32
+ Curate **spec/research only** — never pre-register code paths you will edit.
33
+
34
+ | Limit | Value | Enforcement |
35
+ | --- | --- | --- |
36
+ | Max entries | 8 | Skip excess at Layer 2 load; `task.py validate` WARN |
37
+ | Max single expansion | 12,000 chars | Skip file/directory block |
38
+ | Max total jsonl body | 48,000 chars | Skip when cumulative would exceed |
39
+
40
+ **Curator rules:**
41
+
42
+ 1. Prefer **index + one layer spec** over whole package trees.
43
+ 2. Use `task.py add-context` with a one-line **reason** (replayable intent).
44
+ 3. Delete the seed `_example` row when adding real entries.
45
+ 4. Full task artifacts (`prd.md`, `design.md`, `implement.md`) are **always** embedded separately — do not duplicate them in jsonl.
46
+
47
+ **Dispatch manifest (stderr):**
48
+
49
+ ```text
50
+ [subagent-dispatch] injection-budget: .cstl/tasks/.../implement.jsonl loaded 2 entries (8421 chars): ...
51
+ [subagent-dispatch] injection-budget: skipped path: total cap (...)
52
+ ```
53
+
54
+ ---
55
+
56
+ ## 4. Layer 2 role defaults
57
+
58
+ When `--max-chars` is omitted, `generate_dispatch_prompt.py` uses:
59
+
60
+ | Role | Default `max_chars` |
61
+ | --- | --- |
62
+ | implement | 96,000 |
63
+ | check | 64,000 |
64
+ | research | 48,000 |
65
+
66
+ Override per dispatch when a task truly needs more — document the override in `implement.md` DSC and `verify.md`.
67
+
68
+ Truncation order after jsonl budget: whole context string tail-truncated with `...[truncated]...` warning.
69
+
70
+ ---
71
+
72
+ ## 5. alwaysApply rule hygiene
73
+
74
+ Before adding a new `.cursor/rules/*.mdc` with `alwaysApply: true`:
75
+
76
+ 1. Confirm the content **must** be visible **every turn** (see `cursor-context-injection-guide.md`).
77
+ 2. Run `python ./.cstl/scripts/injection_budget_probe.py --repo-root .`.
78
+ 3. If total alwaysApply exceeds **20 KiB**, trim or move detail to on-demand spec / `get_context.py`.
79
+
80
+ **Rollback:** remove or scope the new rule; re-run probe.
81
+
82
+ ---
83
+
84
+ ## 6. Observability probe
85
+
86
+ ```powershell
87
+ # Workspace surfaces
88
+ python ./.cstl/scripts/injection_budget_probe.py --repo-root .
89
+
90
+ # Task jsonl + dispatch size
91
+ python ./.cstl/scripts/injection_budget_probe.py --repo-root . --task .cstl/tasks/<task-dir> --dispatch-role implement
92
+
93
+ # CI / gate style (fail on WARN or rules >32KiB)
94
+ python ./.cstl/scripts/injection_budget_probe.py --repo-root . --strict
95
+ ```
96
+
97
+ Constants live in `.cstl/scripts/common/injection_budget.py` (single source).
98
+
99
+ ---
100
+
101
+ ## 7. Related
102
+
103
+ - [Cursor context injection guide](./cursor-context-injection-guide.md) — channel reliability matrix
104
+ - [Cursor subagent policy](./cursor-subagent-policy.md) — Layer 2 dispatch contract
105
+ - [Verification strength guide](./verification-strength-guide.md) — evidence density for closeout (orthogonal axis)
106
+
107
+ ---
108
+
109
+ ## 8. Rollback
110
+
111
+ Revert `injection_budget.py`, probe script, `subagent_dispatch` budget branch, validate WARNs, and this guide. Layer 2 returns to unbounded jsonl expansion; C04 remains telemetry-only.