@mindfoldhq/trellis 0.5.7 → 0.5.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.
@@ -0,0 +1,9 @@
1
+ {
2
+ "version": "0.5.8",
3
+ "description": "Bug fixes for Codex sub-agent behavior. AI no longer gets stuck waiting on sub-agents that don't exist; `trellis-research` on Codex no longer silently exits without producing files. Pure prompt-layer trim.",
4
+ "breaking": false,
5
+ "recommendMigrate": false,
6
+ "changelog": "**Bug Fixes:**\n- **Removing the sub-agent guidance in `AGENTS.md` stops Codex from calling / waiting on research agents.** Deleted the `## Subagents` section (36 lines, including the \"ALWAYS wait for every spawned subagent\" rule).\n- **Sub-agent mode fix: `trellis-research` on Codex no longer exits prematurely / produces no research files due to missing task context** (the main agent now includes the `Active task:` line when dispatching to research agents too).\n\n**Added:**\n- `CoreRule` block prepended to the `trellis-brainstorm` skill (adapted from https://github.com/mattpocock/skills/blob/main/skills/productivity/grill-me/SKILL.md ).\n\nNon-Codex platforms (Claude Code, Cursor, OpenCode, Kiro, CodeBuddy, Droid) unchanged.",
7
+ "migrations": [],
8
+ "notes": "Pure prompt-layer trim. No Python or TypeScript edits. `trellis update` refreshes AGENTS.md / workflow.md / brainstorm skill content."
9
+ }
@@ -5,6 +5,14 @@ description: "Collaborative requirements discovery session optimized for AI codi
5
5
 
6
6
  # Brainstorm - Requirements Discovery (AI Coding Enhanced)
7
7
 
8
+ **CoreRule**: Interview me relentlessly about every aspect of this plan until we reach a shared understanding. Walk down each branch of the design tree, resolving dependencies between decisions one-by-one. For each question, provide your recommended answer.
9
+
10
+ Ask the questions one at a time.
11
+
12
+ If a question can be answered by exploring the codebase, explore the codebase instead.
13
+
14
+ ---
15
+
8
16
  Guide AI through collaborative requirements discovery **before implementation**, optimized for AI coding workflows:
9
17
 
10
18
  * **Task-first** (capture ideas immediately)
@@ -1,5 +1,13 @@
1
1
  # Brainstorm - Requirements Discovery (AI Coding Enhanced)
2
2
 
3
+ **CoreRule**: Interview me relentlessly about every aspect of this plan until we reach a shared understanding. Walk down each branch of the design tree, resolving dependencies between decisions one-by-one. For each question, provide your recommended answer.
4
+
5
+ Ask the questions one at a time.
6
+
7
+ If a question can be answered by exploring the codebase, explore the codebase instead.
8
+
9
+ ---
10
+
3
11
  Guide AI through collaborative requirements discovery **before implementation**, optimized for AI coding workflows:
4
12
 
5
13
  * **Task-first** (capture ideas immediately)
@@ -197,6 +205,8 @@ Why:
197
205
  - It returns only `{file path, one-line summary}` to the main agent
198
206
  - Independent topics can be **parallelized** — spawn multiple sub-agents in one tool call
199
207
 
208
+ > **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.
209
+
200
210
  Agent type: `trellis-research`
201
211
  Task description template: "Research <specific question>; persist findings to `{TASK_DIR}/research/<topic-slug>.md`."
202
212
 
@@ -4,12 +4,20 @@ description: "Trellis Copilot prompt: Brainstorm - Requirements Discovery (AI Co
4
4
 
5
5
  # Brainstorm - Requirements Discovery (AI Coding Enhanced)
6
6
 
7
+ **CoreRule**: Interview me relentlessly about every aspect of this plan until we reach a shared understanding. Walk down each branch of the design tree, resolving dependencies between decisions one-by-one. For each question, provide your recommended answer.
8
+
9
+ Ask the questions one at a time.
10
+
11
+ If a question can be answered by exploring the codebase, explore the codebase instead.
12
+
13
+ ---
14
+
7
15
  Guide AI through collaborative requirements discovery **before implementation**, optimized for AI coding workflows:
8
16
 
9
17
  * **Task-first** (capture ideas immediately)
10
18
  * **Action-before-asking** (reduce low-value questions)
11
19
  * **Research-first** for technical choices (avoid asking users to invent options)
12
- * **Diverge �?Converge** (expand thinking, then lock MVP)
20
+ * **Diverge �?Converge** (expand thinking, then lock MVP)
13
21
 
14
22
  ---
15
23
 
@@ -30,19 +38,19 @@ Triggered from `/` when the user describes a development task, especially when:
30
38
  Always ensure a task exists at the start so the user's ideas are recorded immediately.
31
39
 
32
40
  2. **Action before asking**
33
- If you can derive the answer from repo code, docs, configs, conventions, or quick research �?do that first.
41
+ If you can derive the answer from repo code, docs, configs, conventions, or quick research �?do that first.
34
42
 
35
43
  3. **One question per message**
36
44
  Never overwhelm the user with a list of questions. Ask one, update PRD, repeat.
37
45
 
38
46
  4. **Prefer concrete options**
39
- For preference/decision questions, present 2�? feasible, specific approaches with trade-offs.
47
+ For preference/decision questions, present 2�? feasible, specific approaches with trade-offs.
40
48
 
41
49
  5. **Research-first for technical choices**
42
50
  If the decision depends on industry conventions / similar tools / established patterns, do research first, then propose options.
43
51
 
44
- 6. **Diverge �?Converge**
45
- After initial understanding, proactively consider future evolution, related scenarios, and failure/edge cases �?then converge to an MVP with explicit out-of-scope.
52
+ 6. **Diverge �?Converge**
53
+ After initial understanding, proactively consider future evolution, related scenarios, and failure/edge cases �?then converge to an MVP with explicit out-of-scope.
46
54
 
47
55
  7. **No meta questions**
48
56
  Do not ask "should I search?" or "can you paste the code so I can continue?"
@@ -55,7 +63,7 @@ Triggered from `/` when the user describes a development task, especially when:
55
63
  Before any Q&A, ensure a task exists. If none exists, create one immediately.
56
64
 
57
65
  * Use a **temporary working title** derived from the user's message.
58
- * It's OK if the title is imperfect �?refine later in PRD.
66
+ * It's OK if the title is imperfect �?refine later in PRD.
59
67
 
60
68
  ```bash
61
69
  TASK_DIR=$(python3 ./.trellis/scripts/task.py create "brainstorm: <short goal>" --slug <auto>)
@@ -138,8 +146,8 @@ Write findings into PRD:
138
146
  | Complexity | Criteria | Action |
139
147
  | ------------ | ------------------------------------------------------ | ------------------------------------------- |
140
148
  | **Trivial** | Single-line fix, typo, obvious change | Skip brainstorm, implement directly |
141
- | **Simple** | Clear goal, 1�? files, scope well-defined | Ask 1 confirm question, then implement |
142
- | **Moderate** | Multiple files, some ambiguity | Light brainstorm (2�? high-value questions) |
149
+ | **Simple** | Clear goal, 1�? files, scope well-defined | Ask 1 confirm question, then implement |
150
+ | **Moderate** | Multiple files, some ambiguity | Light brainstorm (2�? high-value questions) |
143
151
  | **Complex** | Vague goal, architectural choices, multiple approaches | Full brainstorm |
144
152
 
145
153
  > Note: Task already exists from Step 0. Classification only affects depth of brainstorming.
@@ -150,7 +158,7 @@ Write findings into PRD:
150
158
 
151
159
  Before asking ANY question, run the following gate:
152
160
 
153
- ### Gate A �?Can I derive this without the user?
161
+ ### Gate A �?Can I derive this without the user?
154
162
 
155
163
  If answer is available via:
156
164
 
@@ -158,9 +166,9 @@ If answer is available via:
158
166
  * docs/specs/conventions
159
167
  * quick market/OSS research
160
168
 
161
- �?**Do not ask.** Fetch it, summarize, update PRD.
169
+ �?**Do not ask.** Fetch it, summarize, update PRD.
162
170
 
163
- ### Gate B �?Is this a meta/lazy question?
171
+ ### Gate B �?Is this a meta/lazy question?
164
172
 
165
173
  Examples:
166
174
 
@@ -168,21 +176,21 @@ Examples:
168
176
  * "Can you paste the code so I can proceed?"
169
177
  * "What does the code look like?" (when repo is available)
170
178
 
171
- �?**Do not ask.** Take action.
179
+ �?**Do not ask.** Take action.
172
180
 
173
- ### Gate C �?What type of question is it?
181
+ ### Gate C �?What type of question is it?
174
182
 
175
183
  * **Blocking**: cannot proceed without user input
176
184
  * **Preference**: multiple valid choices, depends on product/UX/risk preference
177
185
  * **Derivable**: should be answered by inspection/research
178
186
 
179
- �?Only ask **Blocking** or **Preference**.
187
+ �?Only ask **Blocking** or **Preference**.
180
188
 
181
189
  ---
182
190
 
183
191
  ## Step 4: Research-first Mode (Mandatory for technical choices)
184
192
 
185
- ### Trigger conditions (any �?research-first)
193
+ ### Trigger conditions (any �?research-first)
186
194
 
187
195
  * The task involves selecting an approach, library, protocol, framework, template system, plugin mechanism, or CLI UX convention
188
196
  * The user asks for "best practice", "how others do it", "recommendation"
@@ -190,10 +198,10 @@ Examples:
190
198
 
191
199
  ### Research steps
192
200
 
193
- 1. Identify 2�? comparable tools/patterns
201
+ 1. Identify 2�? comparable tools/patterns
194
202
  2. Summarize common conventions and why they exist
195
203
  3. Map conventions onto our repo constraints
196
- 4. Produce **2�? feasible approaches** for our project
204
+ 4. Produce **2�? feasible approaches** for our project
197
205
 
198
206
  ### Research output format (PRD)
199
207
 
@@ -236,15 +244,15 @@ Then ask **one** preference question:
236
244
 
237
245
  ---
238
246
 
239
- ## Step 5: Expansion Sweep (DIVERGE) �?Required after initial understanding
247
+ ## Step 5: Expansion Sweep (DIVERGE) �?Required after initial understanding
240
248
 
241
249
  After you can summarize the goal, proactively broaden thinking before converging.
242
250
 
243
- ### Expansion categories (keep to 1�? bullets each)
251
+ ### Expansion categories (keep to 1�? bullets each)
244
252
 
245
253
  1. **Future evolution**
246
254
 
247
- * What might this feature become in 1�? months?
255
+ * What might this feature become in 1�? months?
248
256
  * What extension points are worth preserving now?
249
257
 
250
258
  2. **Related scenarios**
@@ -264,9 +272,9 @@ I understand you want to implement: <current goal>.
264
272
 
265
273
  Before diving into design, let me quickly diverge to consider three categories (to avoid rework later):
266
274
 
267
- 1. Future evolution: <1�? bullets>
268
- 2. Related scenarios: <1�? bullets>
269
- 3. Failure/edge cases: <1�? bullets>
275
+ 1. Future evolution: <1�? bullets>
276
+ 2. Related scenarios: <1�? bullets>
277
+ 3. Failure/edge cases: <1�? bullets>
270
278
 
271
279
  For this MVP, which would you like to include (or none)?
272
280
 
@@ -278,8 +286,8 @@ For this MVP, which would you like to include (or none)?
278
286
 
279
287
  Then update PRD:
280
288
 
281
- * What's in MVP �?`Requirements`
282
- * What's excluded �?`Out of Scope`
289
+ * What's in MVP �?`Requirements`
290
+ * What's excluded �?`Out of Scope`
283
291
 
284
292
  ---
285
293
 
@@ -292,7 +300,7 @@ Then update PRD:
292
300
  * After each user answer:
293
301
 
294
302
  * Update PRD immediately
295
- * Move answered items from `Open Questions` �?`Requirements`
303
+ * Move answered items from `Open Questions` �?`Requirements`
296
304
  * Update `Acceptance Criteria` with testable checkboxes
297
305
  * Clarify `Out of Scope`
298
306
 
@@ -308,20 +316,20 @@ Then update PRD:
308
316
  ```markdown
309
317
  For <topic>, which approach do you prefer?
310
318
 
311
- 1. **Option A** �?<what it means + trade-off>
312
- 2. **Option B** �?<what it means + trade-off>
313
- 3. **Option C** �?<what it means + trade-off>
314
- 4. **Other** �?describe your preference
319
+ 1. **Option A** �?<what it means + trade-off>
320
+ 2. **Option B** �?<what it means + trade-off>
321
+ 3. **Option C** �?<what it means + trade-off>
322
+ 4. **Other** �?describe your preference
315
323
  ```
316
324
 
317
325
  ---
318
326
 
319
327
  ## Step 7: Propose Approaches + Record Decisions (Complex tasks)
320
328
 
321
- After requirements are clear enough, propose 2�? approaches (if not already done via research-first):
329
+ After requirements are clear enough, propose 2�? approaches (if not already done via research-first):
322
330
 
323
331
  ```markdown
324
- Based on current information, here are 2�? feasible approaches:
332
+ Based on current information, here are 2�? feasible approaches:
325
333
 
326
334
  **Approach A: <name>** (Recommended)
327
335
 
@@ -465,17 +473,17 @@ After brainstorm completes (Step 8 confirmation approved), the flow continues to
465
473
  ```text
466
474
  Brainstorm
467
475
  Step 0: Create task directory + seed PRD
468
- Step 1�?: Discover requirements, research, converge
469
- Step 8: Final confirmation �?user approves
470
- �?
476
+ Step 1�?: Discover requirements, research, converge
477
+ Step 8: Final confirmation �?user approves
478
+ �?
471
479
  Task Workflow Phase 2 (Prepare for Implementation)
472
480
  Code-Spec Depth Check (if applicable)
473
- �?Research codebase (based on confirmed PRD)
474
- �?Configure code-spec context (jsonl files)
475
- �?Activate task
476
- �?
481
+ �?Research codebase (based on confirmed PRD)
482
+ �?Configure code-spec context (jsonl files)
483
+ �?Activate task
484
+ �?
477
485
  Task Workflow Phase 3 (Execute)
478
- Implement �?Check �?Complete
486
+ Implement �?Check �?Complete
479
487
  ```
480
488
 
481
489
  The task directory and PRD already exist from brainstorm, so Phase 1 of the Task Workflow is skipped entirely.
@@ -16,42 +16,6 @@ If you're using Codex or another agent-capable tool, additional project-scoped h
16
16
  - `.agents/skills/` — reusable Trellis skills
17
17
  - `.codex/agents/` — optional custom subagents
18
18
 
19
- ## Subagents
20
-
21
- - ALWAYS wait for every spawned subagent to reach a terminal status before yielding, acting on partial results, or spawning followups.
22
- - On Codex, this means calling the `wait` tool with the subagent's thread id (requires `multi_agent_v2`). Do NOT infer completion from elapsed time.
23
- - On Claude Code / OpenCode, this means awaiting the Task/agent tool result before continuing.
24
- - NEVER cancel or re-spawn a subagent that hasn't finished. If a subagent appears stuck, raise the wait timeout (Codex default 30s, max 1h) before judging it broken.
25
- - Spawn subagents automatically when:
26
- - Parallelizable work (e.g., install + verify, npm test + typecheck, multiple tasks from plan)
27
- - Long-running or blocking tasks where a worker can run independently
28
- - Isolation for risky changes or checks
29
-
30
- ### Codex-only — `spawn_agent` parameters
31
-
32
- When calling `spawn_agent`, ALWAYS pass `fork_turns="none"`. Without it the child inherits the parent transcript and sees your prior `spawn_agent(...)` records, then applies the "wait for spawned subagents" rule to itself — causing `wait_agent` self-deadlock.
33
-
34
- ```text
35
- spawn_agent(agent_type="trellis-implement", message="...", fork_turns="none")
36
- ```
37
-
38
- ### Codex-only — multi-subagent close-loop
39
-
40
- When `wait` returns a `completed` notification, treat it as an event signal — not as "all done". Run this loop:
41
-
42
- 1. Maintain an `expected_agents` set of dispatched sub-agent thread IDs.
43
- 2. After each `wait` update:
44
- 1. Call `list_agents` to inspect ALL live agents' status.
45
- 2. For each agent now in a terminal state:
46
- - Verify its promised deliverable exists (e.g. `{task_dir}/research/*.md`).
47
- - Read or summarize as needed.
48
- - `close_agent` to release the slot.
49
- - Remove from `expected_agents`.
50
- 3. If `expected_agents` still contains running agents → keep waiting.
51
- 4. If `expected_agents` is empty → continue main flow.
52
- 3. Never `wait` on an agent that has already reported `completed`.
53
- 4. If a `completed` agent is missing its deliverable, treat it as failed — surface that in your report instead of re-waiting.
54
-
55
19
  Managed by Trellis. Edits outside this block are preserved; edits inside may be overwritten by a future `trellis update`.
56
20
 
57
21
  <!-- TRELLIS:END -->
@@ -151,7 +151,7 @@ Phase 3: Finish → distill lessons + wrap-up
151
151
 
152
152
  [workflow-state:no_task]
153
153
  No active task. **A Direct answer** — pure Q&A / explanation / lookup / chat; no file writes + one-line answer + repo reads ≤ 2 files → AI judges, no override needed.
154
- **B Create a task** — any implementation / code change / build / refactor work. Entry sequence: (1) `python3 ./.trellis/scripts/task.py create "<title>"` to create the task (status=planning, breadcrumb switches to [workflow-state:planning] for brainstorm + jsonl phase guidance) → (2) load `trellis-brainstorm` skill to discuss requirements with the user and iterate on prd.md → (3) once prd is done and jsonl is curated, run `task.py start <task-dir>` to enter [workflow-state:in_progress] for the implementation skeleton. For research-heavy work, dispatch `trellis-research` sub-agents — main agent must NOT do 3+ inline WebFetch / WebSearch / `gh api` calls. **"It looks small" is NOT grounds for downgrading B to A or C**.
154
+ **B Create a task** — any implementation / code change / build / refactor work. Entry sequence: (1) `python3 ./.trellis/scripts/task.py create "<title>"` to create the task (status=planning, breadcrumb switches to [workflow-state:planning] for brainstorm + jsonl phase guidance) → (2) load `trellis-brainstorm` skill to discuss requirements with the user and iterate on prd.md → (3) once prd is done and jsonl is curated, run `task.py start <task-dir>` to enter [workflow-state:in_progress] for the implementation skeleton. **"It looks small" is NOT grounds for downgrading B to A or C**.
155
155
  **C Inline change** (per-turn only, escape hatch for B) — the user's CURRENT message MUST contain one of: "skip trellis" / "no task" / "just do it" / "don't create a task" / "跳过 trellis" / "别走流程" / "小修一下" / "直接改" / "先别建任务" → briefly acknowledge ("ok, skipping trellis flow this turn"), then inline. **Without seeing one of these phrases you must NOT inline on your own**; do not invent an override the user never said.
156
156
  [/workflow-state:no_task]
157
157
 
@@ -169,7 +169,6 @@ No active task. **A Direct answer** — pure Q&A / explanation / lookup / chat;
169
169
  Load the `trellis-brainstorm` skill and iterate on prd.md with the user.
170
170
  Phase 1.3 (required, once): before `task.py start`, you MUST curate `implement.jsonl` and `check.jsonl` — list the spec / research files sub-agents need so they get the right context injected. You may skip only if the jsonl already has agent-curated entries (the seed `_example` row alone doesn't count).
171
171
  Then run `task.py start <task-dir>` to flip status to in_progress.
172
- Research output **must** land in `{task_dir}/research/*.md`, written by `trellis-research` sub-agents. The main agent should not inline WebFetch / WebSearch — the PRD only links to research files.
173
172
  [/workflow-state:planning]
174
173
 
175
174
  <!-- Per-turn breadcrumb: shown throughout Phase 1 when codex.dispatch_mode=inline.
@@ -182,7 +181,6 @@ Research output **must** land in `{task_dir}/research/*.md`, written by `trellis
182
181
  Load the `trellis-brainstorm` skill and iterate on prd.md with the user.
183
182
  Phase 1.3 jsonl curation is **skipped** in inline dispatch mode — the main session loads `trellis-before-dev` directly in Phase 2 and reads spec context itself, so there is no sub-agent to inject jsonl into.
184
183
  Then run `task.py start <task-dir>` to flip status to in_progress.
185
- Research output **must** land in `{task_dir}/research/*.md`. In inline mode the main session may do research itself or dispatch `trellis-research` sub-agents.
186
184
  [/workflow-state:planning-inline]
187
185
 
188
186
  ### Phase 2: Execute
@@ -200,7 +198,7 @@ Research output **must** land in `{task_dir}/research/*.md`. In inline mode the
200
198
  **Flow**: trellis-implement → trellis-check → trellis-update-spec → commit (Phase 3.4) → `/trellis:finish-work`.
201
199
  **Main-session default (no override)**: dispatch the `trellis-implement` / `trellis-check` sub-agents — the main agent does NOT edit code by default. Phase 3.4 commit (required, once): after trellis-update-spec, or whenever implementation is verifiably complete, the main agent **drives the commit** — state the commit plan in user-facing text, then run `git commit` — BEFORE suggesting `/trellis:finish-work`. `/finish-work` refuses to run on a dirty working tree (paths outside `.trellis/workspace/` and `.trellis/tasks/`).
202
200
  **Sub-agent self-exemption**: if you are already running as `trellis-implement`, implement directly from the loaded task context and do NOT spawn another `trellis-implement`; if you are already running as `trellis-check`, review/fix directly and do NOT spawn another `trellis-check`. The default dispatch rule applies to the main session only.
203
- **Sub-agent dispatch protocol (all platforms, all sub-agents EXCEPT trellis-research)**: When you spawn `trellis-implement` / `trellis-check`, your dispatch prompt **MUST** start with one line: `Active task: <task path from \`task.py current\`>`. No exceptions. On class-2 platforms (codex / copilot / gemini / qoder) the sub-agent depends on this line because there is no hook to inject task context. On class-1 platforms (claude / cursor / opencode / kiro / codebuddy / droid) the line is normally redundant — the hook injects context directly — but it serves as a critical fallback when the hook fails (Windows + Claude Code PreToolUse silent skip, `--continue` resume, fork distribution, hooks disabled, etc.). `trellis-research` does not need this line because it operates without a task binding.
201
+ **Sub-agent dispatch protocol (all platforms, all sub-agents)**: When you spawn `trellis-implement` / `trellis-check` / `trellis-research`, your dispatch prompt **MUST** start with one line: `Active task: <task path from \`task.py current\`>`. No exceptions. On class-2 platforms (codex / copilot / gemini / qoder) the sub-agent depends on this line because there is no hook to inject task context. On class-1 platforms (claude / cursor / opencode / kiro / codebuddy / droid) the line is normally redundant — the hook injects context directly — but it serves as a critical fallback when the hook fails (Windows + Claude Code PreToolUse silent skip, `--continue` resume, fork distribution, hooks disabled, etc.). For `trellis-research`, the line tells the sub-agent which `{task_dir}/research/` to write into.
204
202
  **Inline override** (per-turn only, escape hatch for sub-agent dispatch): the user's CURRENT message MUST explicitly contain one of: "do it inline" / "no sub-agent" / "你直接改" / "别派 sub-agent" / "main session 写就行" / "不用 sub-agent". **Without seeing one of these phrases you must NOT inline on your own**; do not invent an override the user never said.
205
203
  [/workflow-state:in_progress]
206
204
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mindfoldhq/trellis",
3
- "version": "0.5.7",
3
+ "version": "0.5.8",
4
4
  "description": "AI capabilities grow like ivy — Trellis provides the structure to guide them along a disciplined path",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",