@mindfoldhq/trellis 0.6.0-beta.7 → 0.6.0-beta.8

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 (58) hide show
  1. package/dist/configurators/codex.d.ts.map +1 -1
  2. package/dist/configurators/codex.js +5 -3
  3. package/dist/configurators/codex.js.map +1 -1
  4. package/dist/configurators/shared.js +4 -4
  5. package/dist/configurators/shared.js.map +1 -1
  6. package/dist/migrations/manifests/0.6.0-beta.8.json +9 -0
  7. package/dist/templates/claude/agents/trellis-check.md +2 -2
  8. package/dist/templates/claude/agents/trellis-implement.md +8 -7
  9. package/dist/templates/codebuddy/agents/trellis-check.md +2 -2
  10. package/dist/templates/codebuddy/agents/trellis-implement.md +8 -7
  11. package/dist/templates/codex/agents/trellis-check.toml +4 -4
  12. package/dist/templates/codex/agents/trellis-implement.toml +4 -4
  13. package/dist/templates/codex/hooks/session-start.py +183 -119
  14. package/dist/templates/codex/skills/before-dev/SKILL.md +12 -6
  15. package/dist/templates/codex/skills/brainstorm/SKILL.md +113 -51
  16. package/dist/templates/codex/skills/check/SKILL.md +86 -18
  17. package/dist/templates/codex/skills/start/SKILL.md +33 -323
  18. package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-context-loading.md +7 -4
  19. package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-spec-structure.md +1 -1
  20. package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-workflow.md +3 -2
  21. package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/context-injection.md +5 -5
  22. package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/spec-system.md +1 -1
  23. package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/task-system.md +8 -6
  24. package/dist/templates/common/bundled-skills/trellis-meta/references/platform-files/agents.md +5 -4
  25. package/dist/templates/common/commands/continue.md +6 -5
  26. package/dist/templates/common/commands/start.md +7 -6
  27. package/dist/templates/common/skills/before-dev.md +12 -6
  28. package/dist/templates/common/skills/brainstorm.md +56 -42
  29. package/dist/templates/common/skills/check.md +7 -1
  30. package/dist/templates/copilot/hooks/session-start.py +183 -90
  31. package/dist/templates/copilot/prompts/before-dev.prompt.md +12 -6
  32. package/dist/templates/copilot/prompts/brainstorm.prompt.md +146 -84
  33. package/dist/templates/copilot/prompts/check.prompt.md +86 -18
  34. package/dist/templates/copilot/prompts/parallel.prompt.md +16 -8
  35. package/dist/templates/copilot/prompts/start.prompt.md +33 -367
  36. package/dist/templates/cursor/agents/trellis-check.md +2 -2
  37. package/dist/templates/cursor/agents/trellis-implement.md +8 -7
  38. package/dist/templates/droid/droids/trellis-check.md +2 -2
  39. package/dist/templates/droid/droids/trellis-implement.md +8 -7
  40. package/dist/templates/gemini/agents/trellis-implement.md +7 -6
  41. package/dist/templates/kiro/agents/trellis-check.json +1 -1
  42. package/dist/templates/kiro/agents/trellis-implement.json +1 -1
  43. package/dist/templates/opencode/agents/trellis-check.md +2 -2
  44. package/dist/templates/opencode/agents/trellis-implement.md +9 -8
  45. package/dist/templates/opencode/lib/session-utils.js +212 -123
  46. package/dist/templates/opencode/plugins/inject-subagent-context.js +23 -7
  47. package/dist/templates/opencode/plugins/inject-workflow-state.js +1 -4
  48. package/dist/templates/pi/extensions/trellis/index.ts.txt +7 -5
  49. package/dist/templates/qoder/agents/trellis-implement.md +7 -6
  50. package/dist/templates/shared-hooks/inject-subagent-context.py +36 -14
  51. package/dist/templates/shared-hooks/inject-workflow-state.py +18 -42
  52. package/dist/templates/shared-hooks/session-start.py +197 -163
  53. package/dist/templates/trellis/scripts/common/task_context.py +3 -3
  54. package/dist/templates/trellis/scripts/common/task_store.py +39 -7
  55. package/dist/templates/trellis/scripts/common/workflow_phase.py +7 -10
  56. package/dist/templates/trellis/scripts/task.py +3 -3
  57. package/dist/templates/trellis/workflow.md +98 -98
  58. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: brainstorm
3
- description: "Collaborative requirements discovery session optimized for AI coding workflows. Creates task directories, seeds PRDs, runs codebase research, proposes concrete implementation approaches with trade-offs, and converges on MVP scope through structured Q&A. Use when requirements are unclear, multiple implementation paths exist, trade-offs need evaluation, or a complex feature needs scoping before development."
3
+ description: "Collaborative requirements discovery session optimized for AI coding workflows. Creates task directories, updates PRDs, runs codebase research, separates technical design and implementation planning, and converges on MVP scope through structured Q&A. Use when requirements are unclear, multiple implementation paths exist, trade-offs need evaluation, or a complex feature needs scoping before development."
4
4
  ---
5
5
 
6
6
  # Brainstorm - Requirements Discovery (AI Coding Enhanced)
@@ -24,7 +24,7 @@ Guide AI through collaborative requirements discovery **before implementation**,
24
24
 
25
25
  ## When to Use
26
26
 
27
- Triggered from `$start` when the user describes a development task, especially when:
27
+ Triggered from {{CMD_REF:start}} when the user describes a development task, especially when:
28
28
 
29
29
  * requirements are unclear or evolving
30
30
  * there are multiple valid implementation paths
@@ -70,7 +70,10 @@ Before any Q&A, ensure a task exists. If none exists, create one immediately.
70
70
  TASK_DIR=$(python3 ./.trellis/scripts/task.py create "brainstorm: <short goal>" --slug <auto>)
71
71
  ```
72
72
 
73
- Create/seed `prd.md` immediately with what you know:
73
+ Use a slug without a date prefix. `task.py create` adds the `MM-DD-`
74
+ directory prefix automatically.
75
+
76
+ `task.py create` already created a default `prd.md`. Immediately update it with what you know:
74
77
 
75
78
  ```markdown
76
79
  # brainstorm: <short goal>
@@ -79,7 +82,7 @@ Create/seed `prd.md` immediately with what you know:
79
82
 
80
83
  <one paragraph: what + why>
81
84
 
82
- ## What I already know
85
+ ## Background / Known Context
83
86
 
84
87
  * <facts from user message>
85
88
  * <facts discovered from repo/docs>
@@ -92,11 +95,11 @@ Create/seed `prd.md` immediately with what you know:
92
95
 
93
96
  * <ONLY Blocking / Preference questions; keep list short>
94
97
 
95
- ## Requirements (evolving)
98
+ ## Requirements
96
99
 
97
100
  * <start with what is known>
98
101
 
99
- ## Acceptance Criteria (evolving)
102
+ ## Acceptance Criteria
100
103
 
101
104
  * [ ] <testable criterion>
102
105
 
@@ -111,10 +114,39 @@ Create/seed `prd.md` immediately with what you know:
111
114
 
112
115
  * <what we will not do in this task>
113
116
 
114
- ## Technical Notes
117
+ ## Research References
118
+
119
+ * <links to research/*.md or external references>
120
+ ```
121
+
122
+ For complex tasks, also create/update:
115
123
 
116
- * <files inspected, constraints, links, references>
117
- * <research notes summary if applicable>
124
+ ```markdown
125
+ # design.md
126
+
127
+ ## Technical Design
128
+
129
+ <boundaries, contracts, data flow, compatibility, tradeoffs>
130
+
131
+ ## Rollout / Rollback
132
+
133
+ <operational notes if relevant>
134
+ ```
135
+
136
+ ```markdown
137
+ # implement.md
138
+
139
+ ## Implementation Checklist
140
+
141
+ - [ ] <ordered implementation step>
142
+
143
+ ## Validation
144
+
145
+ - <lint/typecheck/test command>
146
+
147
+ ## Review Gates
148
+
149
+ - <human or technical checkpoint before start/finish>
118
150
  ```
119
151
 
120
152
  ---
@@ -137,8 +169,8 @@ Before asking questions like "what does the code look like?", gather context you
137
169
 
138
170
  Write findings into PRD:
139
171
 
140
- * Add to `What I already know`
141
- * Add constraints/links to `Technical Notes`
172
+ * Add user-visible facts to `Background / Known Context`
173
+ * Write technical findings to `research/*.md`, `design.md`, or `implement.md` as appropriate
142
174
 
143
175
  ---
144
176
 
@@ -197,18 +229,63 @@ Examples:
197
229
  * The user asks for "best practice", "how others do it", "recommendation"
198
230
  * The user can't reasonably enumerate options
199
231
 
200
- ### Research steps
232
+ ### Delegate to `trellis-research` sub-agent (don't research inline)
233
+
234
+ For each research topic, **spawn a `trellis-research` sub-agent via the Task tool** — don't do WebFetch / WebSearch / `gh api` inline in the main conversation.
235
+
236
+ Why:
237
+ - The sub-agent has its own context window → doesn't pollute brainstorm context with raw tool output
238
+ - It persists findings to `{TASK_DIR}/research/<topic>.md` (the contract — see `workflow.md` Phase 1.2)
239
+ - It returns only `{file path, one-line summary}` to the main agent
240
+ - Independent topics can be **parallelized** — spawn multiple sub-agents in one tool call
241
+
242
+ > **Codex exception**: on Codex CLI, do NOT dispatch `trellis-research` for research-first mode — do the research inline (WebFetch / WebSearch in the main session) and write findings to `{TASK_DIR}/research/<topic>.md` yourself. Reason: Codex `spawn_agent` runs sub-agents with `fork_turns="none"` (isolated context, no parent session inheritance), so the research sub-agent cannot resolve the active task path via `task.py current` and silently aborts without producing files. Inline research on Codex avoids this failure mode. The 3+ inline research calls limit (B rule in `workflow.md`) is relaxed for Codex specifically.
201
243
 
202
- 1. Identify 2–4 comparable tools/patterns
244
+ Agent type: `trellis-research`
245
+ Task description template: "Research <specific question>; persist findings to `{TASK_DIR}/research/<topic-slug>.md`."
246
+
247
+ ❌ Bad (what you must NOT do):
248
+ ```
249
+ Main agent: WebFetch(url-A) → WebFetch(url-B) → Bash(gh api ...)
250
+ → WebSearch(q1) → WebSearch(q2) → ... (10+ inline calls)
251
+ → Write(research/topic.md)
252
+ ```
253
+ → Pollutes main context with raw HTML/JSON, burns tokens.
254
+
255
+ ✅ Good:
256
+ ```
257
+ Main agent: Task(subagent_type="trellis-research",
258
+ prompt="Research topic A; persist to research/topic-a.md")
259
+ + Task(subagent_type="trellis-research",
260
+ prompt="Research topic B; persist to research/topic-b.md")
261
+ + Task(subagent_type="trellis-research",
262
+ prompt="Research topic C; persist to research/topic-c.md")
263
+ → Reads research/topic-{a,b,c}.md after they finish.
264
+ ```
265
+
266
+ ### Research steps (to pass into each sub-agent prompt)
267
+
268
+ Each `trellis-research` sub-agent should:
269
+
270
+ 1. Identify 2–4 comparable tools/patterns for its topic
203
271
  2. Summarize common conventions and why they exist
204
272
  3. Map conventions onto our repo constraints
205
- 4. Produce **2–3 feasible approaches** for our project
273
+ 4. Write findings to `{TASK_DIR}/research/<topic>.md`
274
+
275
+ Main agent then reads the persisted files and produces **2–3 feasible approaches** in PRD.
206
276
 
207
277
  ### Research output format (PRD)
208
278
 
209
- Add a section in PRD (either within Technical Notes or as its own):
279
+ The PRD itself should only reference the persisted research files, not duplicate their content. Add a `## Research References` section pointing at `research/*.md`.
280
+
281
+ Optionally, add a convergence section with feasible approaches derived from the research:
210
282
 
211
283
  ```markdown
284
+ ## Research References
285
+
286
+ * [`research/<topic-a>.md`](research/<topic-a>.md) — <one-line takeaway>
287
+ * [`research/<topic-b>.md`](research/<topic-b>.md) — <one-line takeaway>
288
+
212
289
  ## Research Notes
213
290
 
214
291
  ### What similar tools do
@@ -359,7 +436,7 @@ Record the outcome in PRD as an ADR-lite section:
359
436
 
360
437
  ---
361
438
 
362
- ## Step 8: Final Confirmation + Implementation Plan
439
+ ## Step 8: Final Confirmation + Planning Artifacts
363
440
 
364
441
  When open questions are resolved, confirm complete requirements with a structured summary:
365
442
 
@@ -388,16 +465,13 @@ Here's my understanding of the complete requirements:
388
465
 
389
466
  * ...
390
467
 
391
- **Technical Approach**:
392
- <brief summary + key decisions>
393
-
394
- **Implementation Plan (small PRs)**:
468
+ **Artifact status**:
395
469
 
396
- * PR1: <scaffolding + tests + minimal plumbing>
397
- * PR2: <core behavior>
398
- * PR3: <edge cases + docs + cleanup>
470
+ * prd.md: <ready / needs update>
471
+ * design.md: <not needed for lightweight / ready / missing>
472
+ * implement.md: <not needed for lightweight / ready / missing>
399
473
 
400
- Does this look correct? If yes, I'll proceed with implementation.
474
+ Does this look correct? If yes, the next step is planning review before `task.py start`.
401
475
  ```
402
476
 
403
477
  ### Subtask Decomposition (Complex Tasks)
@@ -434,25 +508,13 @@ python3 ./.trellis/scripts/task.py add-subtask "$TASK_DIR" "$CHILD_DIR"
434
508
 
435
509
  * [ ] ...
436
510
 
437
- ## Definition of Done
438
-
439
- * ...
440
-
441
- ## Technical Approach
442
-
443
- <key design + decisions>
444
-
445
- ## Decision (ADR-lite)
446
-
447
- Context / Decision / Consequences
448
-
449
511
  ## Out of Scope
450
512
 
451
513
  * ...
452
514
 
453
- ## Technical Notes
515
+ ## Research References
454
516
 
455
- <constraints, references, files, research notes>
517
+ * <links to research/*.md or external references>
456
518
  ```
457
519
 
458
520
  ---
@@ -469,25 +531,25 @@ Context / Decision / Consequences
469
531
 
470
532
  ## Integration with Start Workflow
471
533
 
472
- After brainstorm completes (Step 8 confirmation approved), the flow continues to the Task Workflow's **Phase 2: Prepare for Implementation**:
534
+ After brainstorm completes (Step 8 confirmation approved), the flow continues to the Task Workflow planning review gate:
473
535
 
474
536
  ```text
475
537
  Brainstorm
476
- Step 0: Create task directory + seed PRD
538
+ Step 0: Create task directory + update PRD
477
539
  Step 1–7: Discover requirements, research, converge
478
- Step 8: Final confirmation → user approves
540
+ Step 8: Final confirmation → user approves planning artifacts
479
541
 
480
- Task Workflow Phase 2 (Prepare for Implementation)
481
- Code-Spec Depth Check (if applicable)
482
- Research codebase (based on confirmed PRD)
483
- Configure code-spec context (jsonl files)
484
- Activate task
542
+ Task Workflow Phase 1 (Plan)
543
+ Lightweight task → PRD-only may be enough
544
+ Complex task design.md + implement.md required
545
+ Sub-agent platforms curate implement.jsonl / check.jsonl manifests
546
+ Review gate → task.py start
485
547
 
486
- Task Workflow Phase 3 (Execute)
548
+ Task Workflow Phase 2 (Execute)
487
549
  Implement → Check → Complete
488
550
  ```
489
551
 
490
- The task directory and PRD already exist from brainstorm, so Phase 1 of the Task Workflow is skipped entirely.
552
+ The task directory and PRD already exist from brainstorm, but Phase 1 is not skipped; it owns artifact review and the `task.py start` gate.
491
553
 
492
554
  ---
493
555
 
@@ -495,6 +557,6 @@ The task directory and PRD already exist from brainstorm, so Phase 1 of the Task
495
557
 
496
558
  | Command | When to Use |
497
559
  |---------|-------------|
498
- | `$start` | Entry point that triggers brainstorm |
499
- | `$finish-work` | After implementation is complete |
500
- | `$update-spec` | If new patterns emerge during work |
560
+ | `{{CMD_REF:start}}` | Entry point that triggers brainstorm |
561
+ | `{{CMD_REF:finish-work}}` | After implementation is complete |
562
+ | `{{CMD_REF:update-spec}}` | If new patterns emerge during work |
@@ -3,28 +3,96 @@ name: check
3
3
  description: "Validates recently written code against project-specific development guidelines from .trellis/spec/. Identifies changed files via git diff, discovers applicable spec modules, runs lint and typecheck, and reports guideline violations. Use when code is written and needs quality verification, to catch context drift during long sessions, or before committing changes."
4
4
  ---
5
5
 
6
- Check if the code you just wrote follows the development guidelines.
6
+ # Code Quality Check
7
7
 
8
- Execute these steps:
8
+ Comprehensive quality verification for recently written code. Combines spec compliance, cross-layer safety, and pre-commit checks.
9
9
 
10
- 1. **Identify changed files**:
11
- ```bash
12
- git diff --name-only HEAD
13
- ```
10
+ ---
11
+
12
+ ## Step 1: Identify What Changed
13
+
14
+ ```bash
15
+ git diff --name-only HEAD
16
+ git status
17
+ ```
18
+
19
+ ## Step 2: Read Task Artifacts and Applicable Specs
20
+
21
+ Read the current task artifacts in order:
22
+
23
+ - `prd.md`
24
+ - `design.md` if present
25
+ - `implement.md` if present
26
+
27
+ ```bash
28
+ python3 ./.trellis/scripts/get_context.py --mode packages
29
+ ```
30
+
31
+ For each changed package/layer, read the spec index and follow its **Quality Check** section:
32
+
33
+ ```bash
34
+ cat .trellis/spec/<package>/<layer>/index.md
35
+ ```
36
+
37
+ Read the specific guideline files referenced — the index is a pointer, not the goal.
38
+
39
+ ## Step 3: Run Project Checks
40
+
41
+ Run the project's lint, type-check, and test commands. Fix any failures before proceeding.
42
+
43
+ ## Step 4: Review Against Checklist
44
+
45
+ ### Code Quality
46
+
47
+ - [ ] Linter passes?
48
+ - [ ] Type checker passes (if applicable)?
49
+ - [ ] Tests pass?
50
+ - [ ] No debug logging left in?
51
+ - [ ] No suppressed warnings or type-safety bypasses?
14
52
 
15
- 2. **Determine which spec modules apply** based on the changed file paths:
16
- ```bash
17
- python3 ./.trellis/scripts/get_context.py --mode packages
18
- ```
53
+ ### Test Coverage
19
54
 
20
- 3. **Read the spec index** for each relevant module:
21
- ```bash
22
- cat .trellis/spec/<package>/<layer>/index.md
23
- ```
24
- Follow the **"Quality Check"** section in the index.
55
+ - [ ] New function unit test added?
56
+ - [ ] Bug fix → regression test added?
57
+ - [ ] Changed behavior → existing tests updated?
25
58
 
26
- 4. **Read the specific guideline files** referenced in the Quality Check section (e.g., `quality-guidelines.md`, `conventions.md`). The index is NOT the goal — it points you to the actual guideline files. Read those files and review your code against them.
59
+ ### Spec Sync
60
+
61
+ - [ ] Does `.trellis/spec/` need updates? (new patterns, conventions, lessons learned)
62
+
63
+ > "If I fixed a bug or discovered something non-obvious, should I document it so future me won't hit the same issue?" → If YES, update the relevant spec doc.
64
+
65
+ ## Step 5: Cross-Layer Dimensions (if applicable)
66
+
67
+ Skip this step if your change is confined to a single layer.
68
+
69
+ ### A. Data Flow (changes touch 3+ layers)
70
+
71
+ - [ ] Read flow traces correctly: Storage → Service → API → UI
72
+ - [ ] Write flow traces correctly: UI → API → Service → Storage
73
+ - [ ] Types/schemas correctly passed between layers?
74
+ - [ ] Errors properly propagated to caller?
75
+
76
+ ### B. Code Reuse (modifying constants, creating utilities)
77
+
78
+ - [ ] Searched for existing similar code before creating new?
79
+ ```bash
80
+ grep -r "pattern" src/
81
+ ```
82
+ - [ ] If 2+ places define same value → extracted to shared constant?
83
+ - [ ] After batch modification, all occurrences updated?
84
+
85
+ ### C. Import/Dependency (creating new files)
86
+
87
+ - [ ] Correct import paths (relative vs absolute)?
88
+ - [ ] No circular dependencies?
89
+
90
+ ### D. Same-Layer Consistency
91
+
92
+ - [ ] Other places using the same concept are consistent?
93
+
94
+ ---
27
95
 
28
- 5. **Run lint and typecheck** for the affected package.
96
+ ## Step 6: Report and Fix
29
97
 
30
- 6. **Report any violations** and fix them if found.
98
+ Report violations found and fix them directly. Re-run project checks after fixes.