@mindfoldhq/trellis 0.3.0-rc.3 → 0.3.0-rc.5

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 (24) hide show
  1. package/dist/migrations/manifests/0.3.0-rc.4.json +9 -0
  2. package/dist/migrations/manifests/0.3.0-rc.5.json +9 -0
  3. package/dist/templates/claude/agents/dispatch.md +2 -2
  4. package/dist/templates/claude/commands/trellis/brainstorm.md +476 -0
  5. package/dist/templates/claude/commands/trellis/finish-work.md +2 -1
  6. package/dist/templates/claude/hooks/inject-subagent-context.py +22 -6
  7. package/dist/templates/codex/skills/brainstorm/SKILL.md +481 -0
  8. package/dist/templates/codex/skills/finish-work/SKILL.md +3 -3
  9. package/dist/templates/codex/skills/start/SKILL.md +53 -59
  10. package/dist/templates/codex/skills/update-spec/SKILL.md +4 -28
  11. package/dist/templates/cursor/commands/trellis-brainstorm.md +476 -0
  12. package/dist/templates/cursor/commands/trellis-finish-work.md +1 -1
  13. package/dist/templates/cursor/commands/trellis-start.md +4 -1
  14. package/dist/templates/iflow/agents/dispatch.md +2 -2
  15. package/dist/templates/iflow/commands/trellis/brainstorm.md +476 -0
  16. package/dist/templates/iflow/commands/trellis/finish-work.md +2 -1
  17. package/dist/templates/iflow/commands/trellis/start.md +22 -3
  18. package/dist/templates/iflow/hooks/inject-subagent-context.py +22 -6
  19. package/dist/templates/opencode/agents/dispatch.md +3 -1
  20. package/dist/templates/opencode/commands/trellis/brainstorm.md +476 -0
  21. package/dist/templates/opencode/commands/trellis/finish-work.md +2 -1
  22. package/dist/templates/opencode/commands/trellis/start.md +22 -3
  23. package/dist/templates/opencode/plugin/inject-subagent-context.js +23 -5
  24. package/package.json +1 -1
@@ -0,0 +1,9 @@
1
+ {
2
+ "version": "0.3.0-rc.4",
3
+ "description": "Active spec sync in finish agent and codex skill template fixes",
4
+ "breaking": false,
5
+ "recommendMigrate": false,
6
+ "changelog": "**Enhancements:**\n- feat(templates): finish agent now actively syncs spec docs during pipeline runs — injects `update-spec.md` into finish context across all pipeline platforms (claude/iflow/opencode), rewrites finish workflow from passive verification to active spec sync that detects new patterns/contracts and updates spec files before confirming PR readiness\n\n**Documentation:**\n- docs(templates): update dispatch.md across claude/iflow/opencode to document the new finish-phase spec injection (update-spec.md + finish-work.md + prd.md)\n- docs(templates): update finish-work.md block rule — pipeline platforms note automatic spec sync by finish agent, non-pipeline platforms (cursor/codex) retain manual-first wording\n- docs(codex): restore code-spec enforcement sections (Section 2.5 Hard Block) in codex skill templates that were missing from initial codex integration",
7
+ "migrations": [],
8
+ "notes": "No migration required. Template-level changes only — run `trellis update` to sync."
9
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "version": "0.3.0-rc.5",
3
+ "description": "Brainstorm templates for all platforms",
4
+ "breaking": false,
5
+ "recommendMigrate": false,
6
+ "changelog": "**Enhancements:**\n- feat(templates): add brainstorm command to all 5 platform templates (claude/iflow/opencode/cursor/codex) with platform-specific command syntax — previously only existed in deployed dirs, never generated by `trellis init/update`\n\n**Documentation:**\n- docs(templates): add brainstorm references to start commands across iflow/opencode/cursor/codex — adds Complex Task classification, brainstorm-first workflow section, and command table entry (matching existing Claude start.md)",
7
+ "migrations": [],
8
+ "notes": "No migration required. Template-level changes only — run `trellis update` to sync."
9
+ }
@@ -131,11 +131,11 @@ Task(
131
131
  ```
132
132
 
133
133
  **Important**: The `[finish]` marker in prompt triggers different context injection:
134
- - Lighter context focused on final verification
135
134
  - finish-work.md checklist
135
+ - update-spec.md (spec update process and templates)
136
136
  - prd.md for verifying requirements are met
137
137
 
138
- This is different from regular "check" which has full specs for self-fix loop.
138
+ The finish agent actively updates spec docs when it detects new patterns or contracts in the changes. This is different from regular "check" which has full specs for self-fix loop.
139
139
 
140
140
  ### action: "create-pr"
141
141
 
@@ -0,0 +1,476 @@
1
+ # Brainstorm - Requirements Discovery (AI Coding Enhanced)
2
+
3
+ Guide AI through collaborative requirements discovery **before implementation**, optimized for AI coding workflows:
4
+
5
+ * **Task-first** (capture ideas immediately)
6
+ * **Action-before-asking** (reduce low-value questions)
7
+ * **Research-first** for technical choices (avoid asking users to invent options)
8
+ * **Diverge → Converge** (expand thinking, then lock MVP)
9
+
10
+ ---
11
+
12
+ ## When to Use
13
+
14
+ Triggered from `/trellis:start` when the user describes a development task, especially when:
15
+
16
+ * requirements are unclear or evolving
17
+ * there are multiple valid implementation paths
18
+ * trade-offs matter (UX, reliability, maintainability, cost, performance)
19
+ * the user might not know the best options up front
20
+
21
+ ---
22
+
23
+ ## Core Principles (Non-negotiable)
24
+
25
+ 1. **Task-first (capture early)**
26
+ Always ensure a task exists at the start so the user's ideas are recorded immediately.
27
+
28
+ 2. **Action before asking**
29
+ If you can derive the answer from repo code, docs, configs, conventions, or quick research — do that first.
30
+
31
+ 3. **One question per message**
32
+ Never overwhelm the user with a list of questions. Ask one, update PRD, repeat.
33
+
34
+ 4. **Prefer concrete options**
35
+ For preference/decision questions, present 2–3 feasible, specific approaches with trade-offs.
36
+
37
+ 5. **Research-first for technical choices**
38
+ If the decision depends on industry conventions / similar tools / established patterns, do research first, then propose options.
39
+
40
+ 6. **Diverge → Converge**
41
+ After initial understanding, proactively consider future evolution, related scenarios, and failure/edge cases — then converge to an MVP with explicit out-of-scope.
42
+
43
+ 7. **No meta questions**
44
+ Do not ask "should I search?" or "can you paste the code so I can continue?"
45
+ If you need information: search/inspect. If blocked: ask the minimal blocking question.
46
+
47
+ ---
48
+
49
+ ## Step 0: Ensure Task Exists (ALWAYS)
50
+
51
+ Before any Q&A, ensure a task exists. If none exists, create one immediately.
52
+
53
+ * Use a **temporary working title** derived from the user's message.
54
+ * It's OK if the title is imperfect — refine later in PRD.
55
+
56
+ ```bash
57
+ TASK_DIR=$(python3 ./.trellis/scripts/task.py create "brainstorm: <short goal>" --slug <auto>)
58
+ ```
59
+
60
+ Create/seed `prd.md` immediately with what you know:
61
+
62
+ ```markdown
63
+ # brainstorm: <short goal>
64
+
65
+ ## Goal
66
+
67
+ <one paragraph: what + why>
68
+
69
+ ## What I already know
70
+
71
+ * <facts from user message>
72
+ * <facts discovered from repo/docs>
73
+
74
+ ## Assumptions (temporary)
75
+
76
+ * <assumptions to validate>
77
+
78
+ ## Open Questions
79
+
80
+ * <ONLY Blocking / Preference questions; keep list short>
81
+
82
+ ## Requirements (evolving)
83
+
84
+ * <start with what is known>
85
+
86
+ ## Acceptance Criteria (evolving)
87
+
88
+ * [ ] <testable criterion>
89
+
90
+ ## Definition of Done (team quality bar)
91
+
92
+ * Tests added/updated (unit/integration where appropriate)
93
+ * Lint / typecheck / CI green
94
+ * Docs/notes updated if behavior changes
95
+ * Rollout/rollback considered if risky
96
+
97
+ ## Out of Scope (explicit)
98
+
99
+ * <what we will not do in this task>
100
+
101
+ ## Technical Notes
102
+
103
+ * <files inspected, constraints, links, references>
104
+ * <research notes summary if applicable>
105
+ ```
106
+
107
+ ---
108
+
109
+ ## Step 1: Auto-Context (DO THIS BEFORE ASKING QUESTIONS)
110
+
111
+ Before asking questions like "what does the code look like?", gather context yourself:
112
+
113
+ ### Repo inspection checklist
114
+
115
+ * Identify likely modules/files impacted
116
+ * Locate existing patterns (similar features, conventions, error handling style)
117
+ * Check configs, scripts, existing command definitions
118
+ * Note any constraints (runtime, dependency policy, build tooling)
119
+
120
+ ### Documentation checklist
121
+
122
+ * Look for existing PRDs/specs/templates
123
+ * Look for command usage examples, README, ADRs if any
124
+
125
+ Write findings into PRD:
126
+
127
+ * Add to `What I already know`
128
+ * Add constraints/links to `Technical Notes`
129
+
130
+ ---
131
+
132
+ ## Step 2: Classify Complexity (still useful, not gating task creation)
133
+
134
+ | Complexity | Criteria | Action |
135
+ | ------------ | ------------------------------------------------------ | ------------------------------------------- |
136
+ | **Trivial** | Single-line fix, typo, obvious change | Skip brainstorm, implement directly |
137
+ | **Simple** | Clear goal, 1–2 files, scope well-defined | Ask 1 confirm question, then implement |
138
+ | **Moderate** | Multiple files, some ambiguity | Light brainstorm (2–3 high-value questions) |
139
+ | **Complex** | Vague goal, architectural choices, multiple approaches | Full brainstorm |
140
+
141
+ > Note: Task already exists from Step 0. Classification only affects depth of brainstorming.
142
+
143
+ ---
144
+
145
+ ## Step 3: Question Gate (Ask ONLY high-value questions)
146
+
147
+ Before asking ANY question, run the following gate:
148
+
149
+ ### Gate A — Can I derive this without the user?
150
+
151
+ If answer is available via:
152
+
153
+ * repo inspection (code/config)
154
+ * docs/specs/conventions
155
+ * quick market/OSS research
156
+
157
+ → **Do not ask.** Fetch it, summarize, update PRD.
158
+
159
+ ### Gate B — Is this a meta/lazy question?
160
+
161
+ Examples:
162
+
163
+ * "Should I search?"
164
+ * "Can you paste the code so I can proceed?"
165
+ * "What does the code look like?" (when repo is available)
166
+
167
+ → **Do not ask.** Take action.
168
+
169
+ ### Gate C — What type of question is it?
170
+
171
+ * **Blocking**: cannot proceed without user input
172
+ * **Preference**: multiple valid choices, depends on product/UX/risk preference
173
+ * **Derivable**: should be answered by inspection/research
174
+
175
+ → Only ask **Blocking** or **Preference**.
176
+
177
+ ---
178
+
179
+ ## Step 4: Research-first Mode (Mandatory for technical choices)
180
+
181
+ ### Trigger conditions (any → research-first)
182
+
183
+ * The task involves selecting an approach, library, protocol, framework, template system, plugin mechanism, or CLI UX convention
184
+ * The user asks for "best practice", "how others do it", "recommendation"
185
+ * The user can't reasonably enumerate options
186
+
187
+ ### Research steps
188
+
189
+ 1. Identify 2–4 comparable tools/patterns
190
+ 2. Summarize common conventions and why they exist
191
+ 3. Map conventions onto our repo constraints
192
+ 4. Produce **2–3 feasible approaches** for our project
193
+
194
+ ### Research output format (PRD)
195
+
196
+ Add a section in PRD (either within Technical Notes or as its own):
197
+
198
+ ```markdown
199
+ ## Research Notes
200
+
201
+ ### What similar tools do
202
+
203
+ * ...
204
+ * ...
205
+
206
+ ### Constraints from our repo/project
207
+
208
+ * ...
209
+
210
+ ### Feasible approaches here
211
+
212
+ **Approach A: <name>** (Recommended)
213
+
214
+ * How it works:
215
+ * Pros:
216
+ * Cons:
217
+
218
+ **Approach B: <name>**
219
+
220
+ * How it works:
221
+ * Pros:
222
+ * Cons:
223
+
224
+ **Approach C: <name>** (optional)
225
+
226
+ * ...
227
+ ```
228
+
229
+ Then ask **one** preference question:
230
+
231
+ * "Which approach do you prefer: A / B / C (or other)?"
232
+
233
+ ---
234
+
235
+ ## Step 5: Expansion Sweep (DIVERGE) — Required after initial understanding
236
+
237
+ After you can summarize the goal, proactively broaden thinking before converging.
238
+
239
+ ### Expansion categories (keep to 1–2 bullets each)
240
+
241
+ 1. **Future evolution**
242
+
243
+ * What might this feature become in 1–3 months?
244
+ * What extension points are worth preserving now?
245
+
246
+ 2. **Related scenarios**
247
+
248
+ * What adjacent commands/flows should remain consistent with this?
249
+ * Are there parity expectations (create vs update, import vs export, etc.)?
250
+
251
+ 3. **Failure & edge cases**
252
+
253
+ * Conflicts, offline/network failure, retries, idempotency, compatibility, rollback
254
+ * Input validation, security boundaries, permission checks
255
+
256
+ ### Expansion message template (to user)
257
+
258
+ ```markdown
259
+ I understand you want to implement: <current goal>.
260
+
261
+ Before diving into design, let me quickly diverge to consider three categories (to avoid rework later):
262
+
263
+ 1. Future evolution: <1–2 bullets>
264
+ 2. Related scenarios: <1–2 bullets>
265
+ 3. Failure/edge cases: <1–2 bullets>
266
+
267
+ For this MVP, which would you like to include (or none)?
268
+
269
+ 1. Current requirement only (minimal viable)
270
+ 2. Add <X> (reserve for future extension)
271
+ 3. Add <Y> (improve robustness/consistency)
272
+ 4. Other: describe your preference
273
+ ```
274
+
275
+ Then update PRD:
276
+
277
+ * What's in MVP → `Requirements`
278
+ * What's excluded → `Out of Scope`
279
+
280
+ ---
281
+
282
+ ## Step 6: Q&A Loop (CONVERGE)
283
+
284
+ ### Rules
285
+
286
+ * One question per message
287
+ * Prefer multiple-choice when possible
288
+ * After each user answer:
289
+
290
+ * Update PRD immediately
291
+ * Move answered items from `Open Questions` → `Requirements`
292
+ * Update `Acceptance Criteria` with testable checkboxes
293
+ * Clarify `Out of Scope`
294
+
295
+ ### Question priority (recommended)
296
+
297
+ 1. **MVP scope boundary** (what is included/excluded)
298
+ 2. **Preference decisions** (after presenting concrete options)
299
+ 3. **Failure/edge behavior** (only for MVP-critical paths)
300
+ 4. **Success metrics & Acceptance Criteria** (what proves it works)
301
+
302
+ ### Preferred question format (multiple choice)
303
+
304
+ ```markdown
305
+ For <topic>, which approach do you prefer?
306
+
307
+ 1. **Option A** — <what it means + trade-off>
308
+ 2. **Option B** — <what it means + trade-off>
309
+ 3. **Option C** — <what it means + trade-off>
310
+ 4. **Other** — describe your preference
311
+ ```
312
+
313
+ ---
314
+
315
+ ## Step 7: Propose Approaches + Record Decisions (Complex tasks)
316
+
317
+ After requirements are clear enough, propose 2–3 approaches (if not already done via research-first):
318
+
319
+ ```markdown
320
+ Based on current information, here are 2–3 feasible approaches:
321
+
322
+ **Approach A: <name>** (Recommended)
323
+
324
+ * How:
325
+ * Pros:
326
+ * Cons:
327
+
328
+ **Approach B: <name>**
329
+
330
+ * How:
331
+ * Pros:
332
+ * Cons:
333
+
334
+ Which direction do you prefer?
335
+ ```
336
+
337
+ Record the outcome in PRD as an ADR-lite section:
338
+
339
+ ```markdown
340
+ ## Decision (ADR-lite)
341
+
342
+ **Context**: Why this decision was needed
343
+ **Decision**: Which approach was chosen
344
+ **Consequences**: Trade-offs, risks, potential future improvements
345
+ ```
346
+
347
+ ---
348
+
349
+ ## Step 8: Final Confirmation + Implementation Plan
350
+
351
+ When open questions are resolved, confirm complete requirements with a structured summary:
352
+
353
+ ### Final confirmation format
354
+
355
+ ```markdown
356
+ Here's my understanding of the complete requirements:
357
+
358
+ **Goal**: <one sentence>
359
+
360
+ **Requirements**:
361
+
362
+ * ...
363
+ * ...
364
+
365
+ **Acceptance Criteria**:
366
+
367
+ * [ ] ...
368
+ * [ ] ...
369
+
370
+ **Definition of Done**:
371
+
372
+ * ...
373
+
374
+ **Out of Scope**:
375
+
376
+ * ...
377
+
378
+ **Technical Approach**:
379
+ <brief summary + key decisions>
380
+
381
+ **Implementation Plan (small PRs)**:
382
+
383
+ * PR1: <scaffolding + tests + minimal plumbing>
384
+ * PR2: <core behavior>
385
+ * PR3: <edge cases + docs + cleanup>
386
+
387
+ Does this look correct? If yes, I'll proceed with implementation.
388
+ ```
389
+
390
+ ---
391
+
392
+ ## PRD Target Structure (final)
393
+
394
+ `prd.md` should converge to:
395
+
396
+ ```markdown
397
+ # <Task Title>
398
+
399
+ ## Goal
400
+
401
+ <why + what>
402
+
403
+ ## Requirements
404
+
405
+ * ...
406
+
407
+ ## Acceptance Criteria
408
+
409
+ * [ ] ...
410
+
411
+ ## Definition of Done
412
+
413
+ * ...
414
+
415
+ ## Technical Approach
416
+
417
+ <key design + decisions>
418
+
419
+ ## Decision (ADR-lite)
420
+
421
+ Context / Decision / Consequences
422
+
423
+ ## Out of Scope
424
+
425
+ * ...
426
+
427
+ ## Technical Notes
428
+
429
+ <constraints, references, files, research notes>
430
+ ```
431
+
432
+ ---
433
+
434
+ ## Anti-Patterns (Hard Avoid)
435
+
436
+ * Asking user for code/context that can be derived from repo
437
+ * Asking user to choose an approach before presenting concrete options
438
+ * Meta questions about whether to research
439
+ * Staying narrowly on the initial request without considering evolution/edges
440
+ * Letting brainstorming drift without updating PRD
441
+
442
+ ---
443
+
444
+ ## Integration with Start Workflow
445
+
446
+ High-level flow:
447
+
448
+ ```text
449
+ User describes task
450
+
451
+ Step 0: Ensure task exists (create if missing)
452
+
453
+ Step 1: Auto-context (inspect repo/docs, research if needed)
454
+
455
+ Step 2: Classify complexity
456
+
457
+ Step 4 (if triggered): Research-first → propose options
458
+
459
+ Step 5: Expansion sweep (diverge)
460
+
461
+ Step 6: Q&A loop (converge; update PRD each turn)
462
+
463
+ Step 8: Final confirmation + small-PR plan
464
+
465
+ Implement
466
+ ```
467
+
468
+ ---
469
+
470
+ ## Related Commands
471
+
472
+ | Command | When to Use |
473
+ |---------|-------------|
474
+ | `/trellis:start` | Entry point that triggers brainstorm |
475
+ | `/trellis:finish-work` | After implementation is complete |
476
+ | `/trellis:update-spec` | If new patterns emerge during work |
@@ -59,7 +59,8 @@ If this change touches infra or cross-layer contracts, this is a blocking checkl
59
59
  - [ ] Includes required tests and assertion points
60
60
 
61
61
  **Block Rule**:
62
- If infra/cross-layer changed but the related spec is still abstract, do NOT finish. Complete `/trellis:update-spec` first.
62
+ In pipeline mode, the finish agent will automatically detect and execute spec updates when gaps are found.
63
+ If running this checklist manually, ensure spec sync is complete before committing — run `/trellis:update-spec` if needed.
63
64
 
64
65
  ### 3. API Changes
65
66
 
@@ -369,7 +369,8 @@ def get_finish_context(repo_root: str, task_dir: str) -> str:
369
369
  Read order:
370
370
  1. All files in finish.jsonl (if exists)
371
371
  2. Fallback to finish-work.md only (lightweight final check)
372
- 3. prd.md (for verifying requirements are met)
372
+ 3. update-spec.md (for active spec sync)
373
+ 4. prd.md (for verifying requirements are met)
373
374
  """
374
375
  context_parts = []
375
376
 
@@ -389,7 +390,16 @@ def get_finish_context(repo_root: str, task_dir: str) -> str:
389
390
  f"=== .claude/commands/trellis/finish-work.md (Finish checklist) ===\n{finish_work}"
390
391
  )
391
392
 
392
- # 2. Requirements document (for verifying requirements are met)
393
+ # 2. Spec update process (for active spec sync)
394
+ update_spec = read_file_content(
395
+ repo_root, ".claude/commands/trellis/update-spec.md"
396
+ )
397
+ if update_spec:
398
+ context_parts.append(
399
+ f"=== .claude/commands/trellis/update-spec.md (Spec update process) ===\n{update_spec}"
400
+ )
401
+
402
+ # 3. Requirements document (for verifying requirements are met)
393
403
  prd_content = read_file_content(repo_root, f"{task_dir}/prd.md")
394
404
  if prd_content:
395
405
  context_parts.append(
@@ -533,13 +543,19 @@ Finish checklist and requirements:
533
543
 
534
544
  1. **Review changes** - Run `git diff --name-only` to see all changed files
535
545
  2. **Verify requirements** - Check each requirement in prd.md is implemented
536
- 3. **Run final checks** - Execute finish-work.md checklist
537
- 4. **Confirm ready** - Ensure code is ready for PR
546
+ 3. **Spec sync** - Analyze whether changes introduce new patterns, contracts, or conventions
547
+ - If new pattern/convention found: read target spec file → update it → update index.md if needed
548
+ - If infra/cross-layer change: follow the 7-section mandatory template from update-spec.md
549
+ - If pure code fix with no new patterns: skip this step
550
+ 4. **Run final checks** - Execute lint and typecheck
551
+ 5. **Confirm ready** - Ensure code is ready for PR
538
552
 
539
553
  ## Important Constraints
540
554
 
541
- - This is a final verification, not a fix phase
542
- - If critical issues found, report them clearly
555
+ - You MAY update spec files when gaps are detected (use update-spec.md as guide)
556
+ - MUST read the target spec file BEFORE editing (avoid duplicating existing content)
557
+ - Do NOT update specs for trivial changes (typos, formatting, obvious fixes)
558
+ - If critical CODE issues found, report them clearly (fix specs, not code)
543
559
  - Verify all acceptance criteria in prd.md are met"""
544
560
 
545
561