@blxzer/cursor-trellis 0.3.5 → 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 (130) hide show
  1. package/CHANGELOG.md +46 -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/configurators/workflow.d.ts.map +1 -1
  18. package/dist/configurators/workflow.js +13 -1
  19. package/dist/configurators/workflow.js.map +1 -1
  20. package/dist/goal/action-packet.d.ts +89 -0
  21. package/dist/goal/action-packet.d.ts.map +1 -0
  22. package/dist/goal/action-packet.js +113 -0
  23. package/dist/goal/action-packet.js.map +1 -0
  24. package/dist/goal/audit.d.ts +14 -0
  25. package/dist/goal/audit.d.ts.map +1 -0
  26. package/dist/goal/audit.js +12 -0
  27. package/dist/goal/audit.js.map +1 -0
  28. package/dist/goal/constants.d.ts +26 -0
  29. package/dist/goal/constants.d.ts.map +1 -0
  30. package/dist/goal/constants.js +24 -0
  31. package/dist/goal/constants.js.map +1 -0
  32. package/dist/goal/paths.d.ts +8 -0
  33. package/dist/goal/paths.d.ts.map +1 -0
  34. package/dist/goal/paths.js +36 -0
  35. package/dist/goal/paths.js.map +1 -0
  36. package/dist/goal/preflight.d.ts +21 -0
  37. package/dist/goal/preflight.d.ts.map +1 -0
  38. package/dist/goal/preflight.js +97 -0
  39. package/dist/goal/preflight.js.map +1 -0
  40. package/dist/goal/review-seam.d.ts +44 -0
  41. package/dist/goal/review-seam.d.ts.map +1 -0
  42. package/dist/goal/review-seam.js +153 -0
  43. package/dist/goal/review-seam.js.map +1 -0
  44. package/dist/goal/reviewer-rules.d.ts +13 -0
  45. package/dist/goal/reviewer-rules.d.ts.map +1 -0
  46. package/dist/goal/reviewer-rules.js +153 -0
  47. package/dist/goal/reviewer-rules.js.map +1 -0
  48. package/dist/goal/reviewer.d.ts +9 -0
  49. package/dist/goal/reviewer.d.ts.map +1 -0
  50. package/dist/goal/reviewer.js +54 -0
  51. package/dist/goal/reviewer.js.map +1 -0
  52. package/dist/goal/runtime.d.ts +32 -0
  53. package/dist/goal/runtime.d.ts.map +1 -0
  54. package/dist/goal/runtime.js +242 -0
  55. package/dist/goal/runtime.js.map +1 -0
  56. package/dist/goal/sdk-client.d.ts +10 -0
  57. package/dist/goal/sdk-client.d.ts.map +1 -0
  58. package/dist/goal/sdk-client.js +34 -0
  59. package/dist/goal/sdk-client.js.map +1 -0
  60. package/dist/goal/state.d.ts +40 -0
  61. package/dist/goal/state.d.ts.map +1 -0
  62. package/dist/goal/state.js +37 -0
  63. package/dist/goal/state.js.map +1 -0
  64. package/dist/goal/task-triggers.d.ts +15 -0
  65. package/dist/goal/task-triggers.d.ts.map +1 -0
  66. package/dist/goal/task-triggers.js +23 -0
  67. package/dist/goal/task-triggers.js.map +1 -0
  68. package/dist/goal/walls.d.ts +12 -0
  69. package/dist/goal/walls.d.ts.map +1 -0
  70. package/dist/goal/walls.js +65 -0
  71. package/dist/goal/walls.js.map +1 -0
  72. package/dist/goal/worker-prompt.d.ts +13 -0
  73. package/dist/goal/worker-prompt.d.ts.map +1 -0
  74. package/dist/goal/worker-prompt.js +41 -0
  75. package/dist/goal/worker-prompt.js.map +1 -0
  76. package/dist/goal/worker.d.ts +42 -0
  77. package/dist/goal/worker.d.ts.map +1 -0
  78. package/dist/goal/worker.js +180 -0
  79. package/dist/goal/worker.js.map +1 -0
  80. package/dist/migrations/manifests/0.3.5.json +9 -0
  81. package/dist/migrations/manifests/0.3.6.json +9 -0
  82. package/dist/templates/common/commands/continue.md +15 -3
  83. package/dist/templates/common/skills/check.md +7 -4
  84. package/dist/templates/cursor/agents/cstl-check.md +1 -0
  85. package/dist/templates/cursor/fixtures/expected-rules.d.ts.map +1 -1
  86. package/dist/templates/cursor/fixtures/expected-rules.js +6 -1
  87. package/dist/templates/cursor/fixtures/expected-rules.js.map +1 -1
  88. package/dist/templates/cursor/rules/cstl-cursor-modes.mdc +32 -0
  89. package/dist/templates/cursor/rules/cstl-triage.mdc +2 -4
  90. package/dist/templates/cursor/rules/retrieval-routing.mdc +26 -7
  91. package/dist/templates/markdown/index.d.ts +3 -0
  92. package/dist/templates/markdown/index.d.ts.map +1 -1
  93. package/dist/templates/markdown/index.js +3 -0
  94. package/dist/templates/markdown/index.js.map +1 -1
  95. package/dist/templates/markdown/spec/guides/cursor-context-injection-guide.md.txt +38 -21
  96. package/dist/templates/markdown/spec/guides/cursor-native-modes-guide.md.txt +125 -0
  97. package/dist/templates/markdown/spec/guides/index.md.txt +107 -104
  98. package/dist/templates/markdown/spec/guides/injection-budget-guide.md.txt +111 -0
  99. package/dist/templates/markdown/spec/guides/retrieval-daily-guide.md.txt +24 -6
  100. package/dist/templates/markdown/spec/guides/verification-strength-guide.md.txt +184 -0
  101. package/dist/templates/shared-hooks/session-start.py +10 -0
  102. package/dist/templates/trellis/config.yaml +18 -0
  103. package/dist/templates/trellis/index.d.ts +5 -0
  104. package/dist/templates/trellis/index.d.ts.map +1 -1
  105. package/dist/templates/trellis/index.js +14 -0
  106. package/dist/templates/trellis/index.js.map +1 -1
  107. package/dist/templates/trellis/scripts/common/artifact_locale.py +278 -0
  108. package/dist/templates/trellis/scripts/common/codebase_retrieval_router.py +37 -2
  109. package/dist/templates/trellis/scripts/common/config.py +39 -0
  110. package/dist/templates/trellis/scripts/common/injection_budget.py +317 -0
  111. package/dist/templates/trellis/scripts/common/parent_orchestration.py +161 -5
  112. package/dist/templates/trellis/scripts/common/retrieval_agent_instructions.py +9 -3
  113. package/dist/templates/trellis/scripts/common/session_context.py +32 -4
  114. package/dist/templates/trellis/scripts/common/session_memory.py +26 -0
  115. package/dist/templates/trellis/scripts/common/subagent_dispatch.py +74 -9
  116. package/dist/templates/trellis/scripts/common/task_context.py +18 -0
  117. package/dist/templates/trellis/scripts/common/task_dashboard.py +16 -1
  118. package/dist/templates/trellis/scripts/common/task_map.py +40 -8
  119. package/dist/templates/trellis/scripts/common/task_store.py +144 -39
  120. package/dist/templates/trellis/scripts/common/test_observable_defaults.py +135 -0
  121. package/dist/templates/trellis/scripts/cursor_retrieval_probe_prompt.md +14 -12
  122. package/dist/templates/trellis/scripts/generate_dispatch_prompt.py +182 -0
  123. package/dist/templates/trellis/scripts/injection_budget_probe.py +69 -0
  124. package/dist/templates/trellis/scripts/retrieval_probe_matrix_template.json +3 -3
  125. package/dist/templates/trellis/scripts/spec_health_outcomes.py +160 -0
  126. package/dist/templates/trellis/scripts/task.py +19 -0
  127. package/dist/templates/trellis/tasks/locale/en/default-prd.md +19 -0
  128. package/dist/templates/trellis/tasks/locale/zh/default-prd.md +19 -0
  129. package/dist/templates/trellis/workflow.md +23 -3
  130. package/package.json +2 -2
@@ -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.
@@ -20,18 +20,36 @@ Ask: *If this answer were wrong because the world or a third-party API moved, wo
20
20
  **NO examples:** symbol location / call chains; in-repo Trellis contracts; behavior of the code you are editing; pure rename/lint inside known files.
21
21
  After search: persist under `{TASK}/research/` with a **provider label**; treat hits as candidates until corroborated (repo, test, or second source).
22
22
 
23
+ ## Prefer / Adapt / Own (code intelligence)
24
+
25
+ | Need | **Prefer** (Cursor native) | **Adapt** | **Own** (codegraph / MCP) |
26
+ | --- | --- | --- | --- |
27
+ | Exact literal / path | **Grep** (`rg`) | — | — |
28
+ | Named-symbol definition | **Grep → Read** | Path hints from semantic when file unknown | codegraph when trap/overload/blast context |
29
+ | IDE diagnostics | **ReadLints** | — | — |
30
+ | Conceptual discovery | **@codebase** / built-in semantic (Native) | **fast_context_search** (BYOK) | — |
31
+ | Caller chain / blast radius | Grep gap-fill | — | **codegraph** MCP |
32
+ | Cross-package trap / extension | Grep scoped | — | **codegraph** MCP |
33
+ | Raw LSP / GO_TO_DEFINITION | **Not in Agent tool table** — re-probe before claiming Prefer | — | codegraph product fallback |
34
+
35
+ **Rollback:** restore pre-P1 codegraph-first definition rows in this guide + `.cursor/rules/retrieval-routing.mdc`; keep codegraph MCP enabled.
36
+
37
+ **Evidence (2026-08-05):** `research/cursor-code-intel-external.md` — official Agent tools = search/read/edit (no LSP); semantic (@codebase) ≠ LSP; Agents Window LSP gap staff-confirmed on forum.
38
+
23
39
  ## Quick matrix
24
40
 
25
41
  | Need | Tool | Notes |
26
42
  | --- | --- | --- |
27
43
  | Exact string / path / log line | **rg** (Grep) | Fast literal match in repo |
28
- | Symbol, callers, edit blast radius | **codegraph** MCP | Structure-first for caller/trap/extension intents |
44
+ | Named-symbol definition | **Grep Read** (Prefer); **codegraph** when trap/blast | Native first; structure when ambiguous |
45
+ | IDE diagnostics | **ReadLints** | Cursor-native linter/diagnostic surface |
46
+ | Symbol, callers, edit blast radius | **codegraph** MCP | Own layer: structure-first for caller/trap/extension intents |
29
47
  | Unknown keywords, semantic discovery | **@codebase** (Cursor Native) / **fast-context** (Cursor++ BYOK) | Native: built-in semantic; BYOK: `fast_context_search` MCP (see `cursorEnv` in plans) |
30
48
  | External / current facts | **smart-search-cli** | **Mandatory first** — built-in web tools are downgrade-only (see rule above) |
31
49
  | Trellis durable docs | **artifact-search** | `search_artifacts.py` |
32
50
  | Past sessions | **session-memory** | Historical; verify against tasks/spec |
33
51
  | Intent hint for code questions | **router** | `route_codebase_retrieval.py` — plan JSON + `agentInstructions`; `--instructions` for steps only |
34
- | Agent follows plan on Cursor | **`beforeSubmitPrompt` → `inject-retrieval-plan.py`** + **`.cursor/rules/retrieval-routing.mdc`** | Per-turn plan block from router `--instructions`; Rules enforce execution; not `sessionStart` (#158452) |
52
+ | Agent follows retrieval policy on Cursor | **`.cursor/rules/retrieval-routing.mdc`** + **`route_codebase_retrieval.py`** | Rules enforce default tool order; `beforeSubmitPrompt` hook is telemetry-only (no plan injection); sessionStart is session-level orientation |
35
53
  | Score collected evidence | **retrieval-pack** | `get_context.py --mode retrieval-pack` — does **not** search |
36
54
 
37
55
  ## Semantic routing (Cursor)
@@ -41,7 +59,7 @@ The planner emits **`platform-semantic`** with backend chosen by **`cursorEnv`**
41
59
  - **native:** built-in `@codebase` / agent semantic search — **do not** use fast-context as Primary.
42
60
  - **byok:** **fast-context MCP** (`fast_context_search`) — built-in semantic is not in the agent tool list.
43
61
 
44
- Definition / reference jumps: **codegraph** (not GO_TO_DEFINITION; Agent LSP unavailable).
62
+ Definition / reference jumps (Agent): **Prefer Grep → Read** for named symbols; **codegraph** when trap/blast/ambiguity. **Not** raw LSP: `GO_TO_DEFINITION` absent from [Agent tool overview](https://cursor.com/docs/agent/overview.md) (2026-08-05). Semantic / `@codebase` is a separate Prefer path for concepts (embedding index), not LSP. IDE Editor F12 ≠ Agent tool routing.
45
63
 
46
64
  ## Token economy signals
47
65
 
@@ -92,7 +110,7 @@ When `smart-search doctor` is not ok or `run_smart_search.py` status is `not_con
92
110
 
93
111
  **CLI discovery (Cursor):** `TRELLIS_SMART_SEARCH_COMMAND` / `smart_search.command` → PATH `smart-search` → project `node_modules/.bin/smart-search` (when installed as a dependency). Agent entrypoint is always `./.cstl/scripts/run_smart_search.py`.
94
112
 
95
- **Research flags (smart-search ≥ 0.1.15):** pass through `run_smart_search.py` for `--intent deep-research`:
113
+ **Research flags (smart-search ≥ 0.2.0; flags also on 0.1.15+):** pass through `run_smart_search.py` for `--intent deep-research`:
96
114
 
97
115
  | Flag | Values | Use |
98
116
  | --- | --- | --- |
@@ -108,7 +126,7 @@ Research JSON may include `output_schema_version: 1` and structured `citations`
108
126
 
109
127
  `route_codebase_retrieval.py` returns **intent + route suggestions** and **`agentInstructions`** (numbered steps with Cursor-native tool names). **codebase-evidence** is **candidate** until confirmed by Read/Git/tests.
110
128
 
111
- On **Cursor**, per-query plans come from **`beforeSubmitPrompt` → `inject-retrieval-plan.py`**; durable execution policy lives in **`.cursor/rules/retrieval-routing.mdc`** (`alwaysApply`). Do **not** rely on `sessionStart` hook injection (#158452) or end-of-turn **retrieval-pack** for plans — retrieval-pack **scores** collected evidence; it does not search.
129
+ On **Cursor**, retrieval policy lives in **`.cursor/rules/retrieval-routing.mdc`** (`alwaysApply`) plus on-demand **`route_codebase_retrieval.py`**. The **`beforeSubmitPrompt`** hook is **telemetry-only** (no plan injection). `sessionStart` delivers session-level orientation (dashboard, workflow summary). Do **not** rely on end-of-turn **retrieval-pack** for plans — retrieval-pack **scores** collected evidence; it does not search.
112
130
 
113
131
  ### Result-layer ranking (B / E / D — REC-05)
114
132
 
@@ -120,7 +138,7 @@ After Grep/codegraph/semantic produce **path candidates**, reorder before choosi
120
138
  | `trap-package-disambiguation` | Demote snapshot/registry/`src/agents/` trap paths unless Read confirms the asked layer. |
121
139
  | `env-config-literal` | Prefer `scripts/`, `e2e/`, `bench/`, `test/` over generic `src/auth` / `src/paths`. |
122
140
 
123
- - **Agent plans**: `render_agent_instructions` / `inject-retrieval-plan.py` append a **结果层排序** block when these intents appear.
141
+ - **Agent plans**: `render_agent_instructions` / `route_codebase_retrieval.py --instructions` append a **结果层排序** block when these intents appear.
124
142
  - **Offline reorder**: `python ./.cstl/scripts/rank_retrieval_candidates.py --candidates fixtures.json --intents caller-chain --top-k 5 --pretty`
125
143
  - **Library**: `common/retrieval_result_ranking.py` (Python mirror used by router and rank script).
126
144
 
@@ -0,0 +1,184 @@
1
+ # Verification Strength Guide
2
+
3
+ > **Purpose**: Define **how deeply** cstl tasks must be verified before closeout — graded by task risk (Lite / Full / Parent), **not** TDD ceremony.
4
+
5
+ ---
6
+
7
+ ## 1. Non-goals
8
+
9
+ - **No TDD productization** — cstl does not require red-green-refactor loops, "write tests first" gates, or per-function unit test mandates.
10
+ - **No per-task full-suite burden** — Lite tasks must not be forced through architecture review or whole-repo CI.
11
+ - **No replacement for project test frameworks** — cstl validation checks **task evidence** in `verify.md` and configured quality gates; it does not run or replace your project's test runner.
12
+
13
+ ---
14
+
15
+ ## 2. Two-axis model (verification strength, not TDD)
16
+
17
+ ### Axis A — Task Ladder closeout profile
18
+
19
+ Inferred by `task.py` from artifact presence and `task.json` meta. Determines **minimum evidence** before archive or child integration.
20
+
21
+ | Closeout profile | Trigger (existing logic) | Minimum verification depth |
22
+ | --- | --- | --- |
23
+ | **lite** | No `design.md`+`implement.md`; or meta marks lite | PRD AC mapping + focused validation + acceptance + durable-learning decision |
24
+ | **full** | Has `design.md` + `implement.md` | Lite depth + DSC validation + **check evidence** + **reviewed change-set** + configured reviewer gates |
25
+ | **parent** | `task.json.children` non-empty | Each child integrated/cancelled + parent integration evidence + integration-review gate |
26
+
27
+ **High-risk upgrade (normative):** scope touching framework semantics, cross-file workflow, `verification_profile`, or capabilities should **Lite → Full** per `workflow.md` Task Ladder rules.
28
+
29
+ ### Axis B — `verification_profile` (reviewer gate strictness)
30
+
31
+ Declared in `implement.md` Development Strategy Contract. Guide narrative: **验证强度** — never "TDD tier".
32
+
33
+ | Profile | Default enabled gates | Strength meaning |
34
+ | --- | --- | --- |
35
+ | **standard** | requirements-review, code-review | Default Full/Child: planning artifacts + change review + validation/check evidence |
36
+ | **strict** | same as standard (reserved for stricter archive signals) | High-risk Full default this wave |
37
+ | **architecture** | + architecture-review | Cross-layer / contract / template / runtime changes |
38
+
39
+ Details: `task_gates.py` → `PROFILE_DEFAULT_GATES`.
40
+
41
+ ---
42
+
43
+ ## 3. Minimum validation checklist by closeout profile
44
+
45
+ ### Lite
46
+
47
+ - [ ] Focused validation on **touched behavior** (command + result in `verify.md`)
48
+ - [ ] `python ./.cstl/scripts/task.py validate <task>`
49
+ - [ ] Final acceptance mapped to PRD AC
50
+ - [ ] Durable-learning decision line (see [Durable Learning Decision Guide](./durable-learning-decision-guide.md))
51
+
52
+ **Example `verify.md` lines:**
53
+
54
+ ```markdown
55
+ Validation: `python -m py_compile src/foo.py` — exit 0
56
+ Acceptance: prd AC 1–3 satisfied; typo fix verified in editor
57
+ Durable learning decision: no durable learning — one-off content fix
58
+ ```
59
+
60
+ ### Full
61
+
62
+ All Lite items, plus:
63
+
64
+ - [ ] Validation commands from `implement.md` executed; results recorded
65
+ - [ ] `Check evidence:` or `cstl-check evidence:` — inline skill or agent review completed
66
+ - [ ] `Reviewed change-set:` or `Git diff ref:` — identity of reviewed diff
67
+ - [ ] Required gates recorded via `task.py record-gate` when contract enables them
68
+
69
+ **Example:**
70
+
71
+ ```markdown
72
+ Validation: probe matrix 4/4 PASS (see research/probe-results.md)
73
+ Check evidence: cstl-check skill — spec compliance + py_compile
74
+ Reviewed change-set: git diff main..HEAD — 8 files in .cstl/spec + scripts
75
+ Acceptance: prd AC 1–5 mapped below
76
+ Durable learning decision: no durable learning
77
+ ```
78
+
79
+ ### Parent
80
+
81
+ All structural children `integrated` or `cancelled`, plus:
82
+
83
+ - [ ] `Integration evidence:` in parent `verify.md`
84
+ - [ ] `integration-review` gate when parent contract requires it
85
+
86
+ ---
87
+
88
+ ## 4. Choosing `verification_profile`
89
+
90
+ | Situation | Suggested profile |
91
+ | --- | --- |
92
+ | Single-file / local fix, Lite ladder | N/A (lite closeout; gates minimal) |
93
+ | Full task, normal feature | `standard` |
94
+ | High-risk Full (hooks, gates, templates, runtime) | `strict` or `architecture` |
95
+ | Cross-layer contract / framework semantics | `architecture` |
96
+
97
+ Set in `implement.md`:
98
+
99
+ ```yaml
100
+ verification_profile: standard
101
+ quality_gates:
102
+ mode: explicit
103
+ enabled: [requirements-review, code-review]
104
+ ```
105
+
106
+ ---
107
+
108
+ ## 5. `verify.md` signal line format (CLI-aligned)
109
+
110
+ The CLI uses regex to detect **substantive** evidence. Placeholder values (`TBD`, `N/A`, `待定`, `-`, `...`) are rejected.
111
+
112
+ | Signal | Example lines (any one match) |
113
+ | --- | --- |
114
+ | Validation | `Validation:`, `Validation commands:`, `Validation results:` |
115
+ | Check evidence | `Check evidence:`, `cstl-check evidence:` |
116
+ | Acceptance | `Acceptance:`, `Final acceptance:`, `Accepted by user:` |
117
+ | Durable learning | `Durable learning decision:`, `no durable learning`, `Spec update evidence:` |
118
+ | Integration | `Integration evidence:`, `Final integration:` |
119
+ | Reviewed change-set | `Reviewed change-set:`, `Git diff ref:`, `Changeset:` |
120
+
121
+ **Not sufficient alone:**
122
+
123
+ - `python ./.cstl/scripts/task.py validate` passing JSONL schema — **does not** prove task acceptance
124
+ - Long log dumps without structured signal lines
125
+ - Checkbox ticks in PRD without `verify.md` validation mapping
126
+
127
+ ---
128
+
129
+ ## 6. False-green detection
130
+
131
+ ### Existing CLI guards
132
+
133
+ | Failure mode | Mechanism |
134
+ | --- | --- |
135
+ | Placeholder validation | `PLACEHOLDER_VALUES_RE` in `task_gates.py` |
136
+ | Missing archive signals | `verify_evidence_status()` at archive / `record-gate` |
137
+ | PRD AC all placeholder | `_prd_requirements_review_errors` at start-execution |
138
+ | Gate PASS without evidence | `record-gate` rejects substantive-missing verify |
139
+
140
+ ### Repeatable probe
141
+
142
+ Run fixture matrix against shared logic (no second rule set):
143
+
144
+ ```powershell
145
+ python ./.cstl/scripts/verify_evidence_probe.py --fixture <path> --profile lite|full|parent --expect pass|fail
146
+ ```
147
+
148
+ Fixtures: `.cstl/tasks/08-06-cstl-p0-verify-capability/research/verification-probes/`
149
+
150
+ | Fixture | Intent | lite | full |
151
+ | --- | --- | --- | --- |
152
+ | `shallow-placeholder.md` | Placeholder-only verify | FAIL | FAIL |
153
+ | `lite-sufficient.md` | Minimal valid Lite | PASS | FAIL (missing check + changeset) |
154
+ | `full-sufficient.md` | Valid Full closeout | PASS | PASS |
155
+ | `overkill-noise.md` | Verbose logs, no signals | FAIL | FAIL |
156
+
157
+ ---
158
+
159
+ ## 7. Shallow vs overkill (quick reference)
160
+
161
+ | Scenario | Too shallow (should block) | Overkill (non-goal) |
162
+ | --- | --- | --- |
163
+ | Lite typo fix | "Looks good" with no `Validation:` line | architecture-review + full-repo test suite |
164
+ | Full hook change | `py_compile` only, no `Reviewed change-set:` | Mandate new unit test per function (TDD) |
165
+ | Parent integrate child | Child verify still placeholder | Full E2E per child |
166
+
167
+ ---
168
+
169
+ ## 8. Integration with cstl-check / record-gate / archive
170
+
171
+ ```text
172
+ Phase 2 Execute → cstl-check (skill/agent) → verify.md evidence
173
+ Phase 3.1 Verify → record-gate (non-baseline) → archive --check
174
+ ```
175
+
176
+ - **cstl-check**: review against spec + task artifacts; fix in-contract defects; write human-readable evidence **before** `record-gate`.
177
+ - **record-gate**: machine state only; requires substantive `verify.md` for PASS/SKIPPED.
178
+ - **archive**: `verify_evidence_status()` must pass for profile; Full also needs gate readiness.
179
+
180
+ Workflow cross-ref: Phase 3.1 Quality verification in `workflow.md`.
181
+
182
+ ---
183
+
184
+ **Core principle:** Match verification **strength** to task **risk** — enough to catch false greens, never enough to become TDD theater.
@@ -656,6 +656,16 @@ def _build_compact_current_state(
656
656
  if spec_index_paths:
657
657
  lines.append(f"Spec indexes: {len(spec_index_paths)} available.")
658
658
 
659
+ try:
660
+ from common.artifact_locale import artifact_locale_summary # type: ignore[import-not-found]
661
+
662
+ task_dir = None
663
+ if active.task_path:
664
+ task_dir = _resolve_task_dir(trellis_dir, active.task_path)
665
+ lines.append(artifact_locale_summary(repo_root, task_dir))
666
+ except Exception:
667
+ pass
668
+
659
669
  return "\n".join(lines)
660
670
 
661
671
 
@@ -32,6 +32,15 @@ max_journal_lines: 2000
32
32
  #
33
33
  # session_auto_commit: true
34
34
 
35
+ #-------------------------------------------------------------------------------
36
+ # Context injection (opt-in)
37
+ #-------------------------------------------------------------------------------
38
+
39
+ # Optional get_context enrichment. Default off — JOURNAL FILE stays metadata-only.
40
+ #
41
+ # context_injection:
42
+ # journal_snippet: false # opt-in; inject ≤150 token recent journal summary in get_context
43
+
35
44
  #-------------------------------------------------------------------------------
36
45
  # Task Lifecycle Hooks
37
46
  #-------------------------------------------------------------------------------
@@ -76,6 +85,15 @@ max_journal_lines: 2000
76
85
  # Default package used when --package is not specified.
77
86
  # default_package: frontend
78
87
 
88
+ #-------------------------------------------------------------------------------
89
+ # Human-reviewed artifact locale (zh | en)
90
+ #-------------------------------------------------------------------------------
91
+
92
+ # Language for prd/design/implement/verify/handoff and task create seeds.
93
+ # Does NOT translate CLI UI or existing archived tasks.
94
+ #
95
+ # artifact_locale: zh
96
+
79
97
  #-------------------------------------------------------------------------------
80
98
  # Smart Search CLI (optional per-machine override)
81
99
  #-------------------------------------------------------------------------------