@mindfoldhq/trellis 0.5.7 → 0.5.9

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.
@@ -9,7 +9,7 @@
9
9
  {
10
10
  "file": ".trellis/config.yaml",
11
11
  "sentinel": "codex:",
12
- "sectionHeading": "Codex (sub-agent dispatch behavior)"
12
+ "sectionHeading": "Codex (dispatch behavior)"
13
13
  }
14
14
  ],
15
15
  "notes": "Patch on top of 0.5.6. Run `trellis update` (no `--migrate` needed). Codex users get the new `dispatch_mode` knob (default unchanged), hardened sub-agent role files, plus the previously-init-only `trellis-start` skill on the update path. Kiro users get an agent JSON that Kiro CLI no longer rejects. Codex 0.129+ users should run `/hooks` once after upgrading Codex to approve the Trellis `UserPromptSubmit` hook."
@@ -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
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "version": "0.5.9",
3
+ "description": "Patch: codex dispatch defaults to inline + workflow.md namespaced into codex-inline / codex-sub-agent.",
4
+ "breaking": false,
5
+ "recommendMigrate": false,
6
+ "changelog": "**Bug Fixes:**\n- fix(codex): default `codex.dispatch_mode` flipped from `sub-agent` to `inline`. Codex sub-agents run with `fork_turns=\"none\"` isolation and can't inherit the parent session's task context, so they exit silently or recursively dispatch. Inline keeps the main Codex agent in charge so context isn't lost. Set `codex.dispatch_mode: sub-agent` in `.trellis/config.yaml` to opt back into the legacy dispatch flow. Invalid values fall back to inline.\n- fix(workflow): namespace `--platform codex` into virtual platforms `codex-inline` / `codex-sub-agent` so `workflow.md` `[Platform A, B, ...]` blocks render the correct guidance per mode. `inject-workflow-state.py` emits a `<codex-mode>` banner in the per-turn UserPromptSubmit prompt so Codex knows which mode it is in, and `[workflow-state:STATUS-inline]` blocks now drive the breadcrumb path for inline mode.\n\n**Internal:**\n- chore(manifests): restore `0.6.0-beta.0.json` on main. The version was published from `feat/v0.6.0-beta` but its manifest never landed on main, breaking adjacent-version update chains for users who hop between stable and beta lines.",
7
+ "migrations": [],
8
+ "notes": "Patch on top of 0.5.8. Run `trellis update` (no `--migrate` needed). Existing Codex projects keep working: if you previously uncommented `dispatch_mode: sub-agent`, that opt-in still routes to the legacy dispatch flow; if the line is commented (the default), behavior switches to inline."
9
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "version": "0.6.0-beta.0",
3
+ "description": "First 0.6 beta. Adds `trellis mem`: search past Claude Code / Codex / OpenCode sessions by keyword, read the turns around each match, and dump full conversations.",
4
+ "breaking": false,
5
+ "recommendMigrate": false,
6
+ "changelog": "**New feature: `trellis mem`**\n- `trellis mem` searches past Claude Code / Codex / OpenCode sessions by keyword and reads the turns around each match. Five subcommands wired through commander as a passthrough group: `projects`, `list`, `search`, `context`, `extract`. Strips hook injections, AGENTS.md preambles, and tool-call noise so search hits reflect real dialogue. Handles compaction (Claude `isCompactSummary` + Codex `compacted` events). Adds zod ^4 as a runtime dep.\n- 84 unit tests added on top of the integrated POC source: 11 pure helpers (Tier 1, 44 cases), 3 platform parsers with inline fixtures (Tier 2, 24 cases), 5 subcommand integration smoke (Tier 3, 16 cases). mem.ts statement coverage 81.89% / function 89.04% / line 87.93%.",
7
+ "migrations": [],
8
+ "configSectionsAdded": [
9
+ {
10
+ "file": ".trellis/config.yaml",
11
+ "sentinel": "codex:",
12
+ "sectionHeading": "Codex (sub-agent dispatch behavior)"
13
+ }
14
+ ],
15
+ "notes": "First public 0.6 beta. Install: `npm install -g @mindfoldhq/trellis@beta`. The `trellis mem` command is opt-in (only fires when invoked). Codex 0.129+ users should run `/hooks` once to approve the Trellis `UserPromptSubmit` hook."
16
+ }
@@ -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 -->
@@ -227,20 +227,49 @@ def _read_trellis_config(root: Path) -> dict:
227
227
  return {}
228
228
 
229
229
 
230
+ def _codex_mode_banner(config: dict) -> str:
231
+ """Emit a `<codex-mode>` banner for the additionalContext payload.
232
+
233
+ Reads `codex.dispatch_mode` from .trellis/config.yaml; defaults to
234
+ `inline` when missing or invalid because Codex sub-agents run with
235
+ `fork_turns="none"` isolation and can't inherit the parent session's
236
+ task context. The banner makes the active mode explicit to Codex AI
237
+ per turn, complementing the workflow-state body which is per-status.
238
+ Mode tells AI which dispatch protocol to follow; workflow-state tells
239
+ AI what step it's at.
240
+ """
241
+ mode = "inline"
242
+ if isinstance(config, dict):
243
+ codex_cfg = config.get("codex")
244
+ if isinstance(codex_cfg, dict):
245
+ cfg_mode = codex_cfg.get("dispatch_mode")
246
+ if cfg_mode in ("inline", "sub-agent"):
247
+ mode = cfg_mode
248
+ return f"<codex-mode>{mode}</codex-mode>"
249
+
250
+
230
251
  def resolve_breadcrumb_key(
231
252
  status: str, platform: str | None, config: dict
232
253
  ) -> str:
233
254
  """Pick the breadcrumb tag key based on Codex dispatch_mode.
234
255
 
235
- Codex users may opt into ``codex.dispatch_mode: inline`` to have the main
236
- agent edit code directly. When the opt-in is set, route to the parallel
237
- ``<status>-inline`` tag block so the breadcrumb body matches the inline
238
- workflow. Other platforms / modes return the plain status unchanged.
256
+ Codex defaults to ``inline`` because sub-agents run with ``fork_turns="none"``
257
+ isolation and can't inherit the parent session's task context. Users can
258
+ opt into ``codex.dispatch_mode: sub-agent`` in ``.trellis/config.yaml``
259
+ to use the parallel ``<status>-inline`` tag ``<status>`` flip. Invalid
260
+ or missing values fall back to inline.
261
+
262
+ Non-codex platforms return the plain status unchanged.
239
263
  """
240
- if platform == "codex" and isinstance(config, dict):
241
- codex_cfg = config.get("codex")
242
- if isinstance(codex_cfg, dict) and codex_cfg.get("dispatch_mode") == "inline":
243
- return f"{status}-inline"
264
+ if platform == "codex":
265
+ mode = "inline"
266
+ if isinstance(config, dict):
267
+ codex_cfg = config.get("codex")
268
+ if isinstance(codex_cfg, dict):
269
+ cfg_mode = codex_cfg.get("dispatch_mode")
270
+ if cfg_mode in ("inline", "sub-agent"):
271
+ mode = cfg_mode
272
+ return f"{status}-inline" if mode == "inline" else status
244
273
  return status
245
274
 
246
275
 
@@ -311,6 +340,7 @@ def main() -> int:
311
340
  parts: list[str] = [CODEX_SUB_AGENT_NOTICE]
312
341
  if task is None:
313
342
  parts.append(CODEX_NO_TASK_BOOTSTRAP_NOTICE)
343
+ parts.append(_codex_mode_banner(config))
314
344
  parts.append(breadcrumb)
315
345
  breadcrumb = "\n\n".join(parts)
316
346
 
@@ -59,12 +59,14 @@ max_journal_lines: 2000
59
59
  # default_package: frontend
60
60
 
61
61
  #-------------------------------------------------------------------------------
62
- # Codex (sub-agent dispatch behavior)
62
+ # Codex (dispatch behavior)
63
63
  #-------------------------------------------------------------------------------
64
- # Opt out of "main session must dispatch trellis-implement / trellis-check
65
- # sub-agents" and let the main agent edit code inline. Codex-only knob;
66
- # other platforms ignore it. Default ("sub-agent") preserves existing
67
- # behavior, so nothing changes unless you uncomment the block below.
64
+ # Codex-only knob; other platforms ignore it. Default ("inline") makes the
65
+ # main Codex agent edit code directly because Codex sub-agents run with
66
+ # `fork_turns="none"` isolation and can't inherit the parent session's
67
+ # task context. Set to "sub-agent" to opt into the legacy dispatch model
68
+ # (main agent spawns trellis-implement / trellis-check / trellis-research
69
+ # sub-agents).
68
70
  #
69
71
  # codex:
70
- # dispatch_mode: sub-agent # or "inline" to let the main agent edit code directly
72
+ # dispatch_mode: inline # or "sub-agent" to dispatch trellis-* sub-agents
@@ -145,17 +145,29 @@ def _platform_matches(platform: str, block_names: list[str]) -> bool:
145
145
 
146
146
 
147
147
  def resolve_effective_platform(platform: str, config: dict) -> str:
148
- """Map platform name through codex inline-mode opt-in.
148
+ """Map ``codex`` to a dispatch-mode-namespaced virtual platform name.
149
149
 
150
- When ``codex.dispatch_mode`` is set to ``"inline"`` in .trellis/config.yaml
151
- and the caller is running with ``--platform codex``, swap the name to
152
- ``"kilo"`` so ``filter_platform`` surfaces the inline workflow content
153
- that already lives in the ``[Kilo, Antigravity, Windsurf]`` blocks.
150
+ When ``--platform codex`` is passed, return ``"codex-inline"`` (default)
151
+ or ``"codex-sub-agent"`` based on ``.trellis/config.yaml`` ``codex.dispatch_mode``.
152
+ ``filter_platform`` then surfaces blocks whose marker lists include the
153
+ namespaced name (e.g. ``[codex-sub-agent, ...]`` or ``[codex-inline, Kilo,
154
+ Antigravity, Windsurf]``).
155
+
156
+ Default is ``inline`` because Codex sub-agents run with ``fork_turns="none"``
157
+ isolation and can't inherit the parent session's task context — inline
158
+ keeps the main agent in charge so context isn't lost. Invalid / missing
159
+ values also fall back to inline.
160
+
161
+ Other platforms are returned unchanged.
154
162
  """
155
163
  if platform == "codex":
164
+ mode = "inline"
156
165
  codex_cfg = config.get("codex") if isinstance(config, dict) else None
157
- if isinstance(codex_cfg, dict) and codex_cfg.get("dispatch_mode") == "inline":
158
- return "kilo"
166
+ if isinstance(codex_cfg, dict):
167
+ cfg_mode = codex_cfg.get("dispatch_mode")
168
+ if cfg_mode in ("inline", "sub-agent"):
169
+ mode = cfg_mode
170
+ return f"codex-{mode}"
159
171
  return platform
160
172
 
161
173
 
@@ -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
 
@@ -247,7 +245,7 @@ If you reach this state with uncommitted code, return to Phase 3.4 first — `/f
247
245
 
248
246
  When a user request matches one of these intents, load the corresponding skill (or dispatch the corresponding sub-agent) first — do not skip skills.
249
247
 
250
- [Claude Code, Cursor, OpenCode, Codex, Kiro, Gemini, Qoder, CodeBuddy, Copilot, Droid, Pi]
248
+ [Claude Code, Cursor, OpenCode, codex-sub-agent, Kiro, Gemini, Qoder, CodeBuddy, Copilot, Droid, Pi]
251
249
 
252
250
  | User intent | Route |
253
251
  |---|---|
@@ -259,9 +257,9 @@ When a user request matches one of these intents, load the corresponding skill (
259
257
 
260
258
  **Why `trellis-before-dev` is NOT in this table:** you are not the one writing code — the `trellis-implement` sub-agent is. Sub-agent platforms get spec context via `implement.jsonl` injection / prelude, not via the main thread loading `trellis-before-dev`.
261
259
 
262
- [/Claude Code, Cursor, OpenCode, Codex, Kiro, Gemini, Qoder, CodeBuddy, Copilot, Droid, Pi]
260
+ [/Claude Code, Cursor, OpenCode, codex-sub-agent, Kiro, Gemini, Qoder, CodeBuddy, Copilot, Droid, Pi]
263
261
 
264
- [Kilo, Antigravity, Windsurf]
262
+ [codex-inline, Kilo, Antigravity, Windsurf]
265
263
 
266
264
  | User intent | Skill |
267
265
  |---|---|
@@ -271,11 +269,11 @@ When a user request matches one of these intents, load the corresponding skill (
271
269
  | Stuck / fixed same bug several times | `trellis-break-loop` |
272
270
  | Spec needs update | `trellis-update-spec` |
273
271
 
274
- [/Kilo, Antigravity, Windsurf]
272
+ [/codex-inline, Kilo, Antigravity, Windsurf]
275
273
 
276
274
  ### DO NOT skip skills
277
275
 
278
- [Claude Code, Cursor, OpenCode, Codex, Kiro, Gemini, Qoder, CodeBuddy, Copilot, Droid, Pi]
276
+ [Claude Code, Cursor, OpenCode, codex-sub-agent, Kiro, Gemini, Qoder, CodeBuddy, Copilot, Droid, Pi]
279
277
 
280
278
  | What you're thinking | Why it's wrong |
281
279
  |---|---|
@@ -284,9 +282,9 @@ When a user request matches one of these intents, load the corresponding skill (
284
282
  | "I already know the spec" | The spec may have been updated since you last read it; the sub-agent gets the fresh copy, you may not |
285
283
  | "Code first, check later" | `trellis-check` surfaces issues you won't notice yourself; earlier is cheaper |
286
284
 
287
- [/Claude Code, Cursor, OpenCode, Codex, Kiro, Gemini, Qoder, CodeBuddy, Copilot, Droid, Pi]
285
+ [/Claude Code, Cursor, OpenCode, codex-sub-agent, Kiro, Gemini, Qoder, CodeBuddy, Copilot, Droid, Pi]
288
286
 
289
- [Kilo, Antigravity, Windsurf]
287
+ [codex-inline, Kilo, Antigravity, Windsurf]
290
288
 
291
289
  | What you're thinking | Why it's wrong |
292
290
  |---|---|
@@ -295,7 +293,7 @@ When a user request matches one of these intents, load the corresponding skill (
295
293
  | "I already know the spec" | The spec may have been updated since you last read it; read again |
296
294
  | "Code first, check later" | `trellis-check` surfaces issues you won't notice yourself; earlier is cheaper |
297
295
 
298
- [/Kilo, Antigravity, Windsurf]
296
+ [/codex-inline, Kilo, Antigravity, Windsurf]
299
297
 
300
298
  ### Loading Step Detail
301
299
 
@@ -344,7 +342,7 @@ Return to this step whenever requirements change and revise `prd.md`.
344
342
 
345
343
  Research can happen at any time during requirement exploration. It isn't limited to local code — you can use any available tool (MCP servers, skills, web search, etc.) to look up external information, including third-party library docs, industry practices, API references, etc.
346
344
 
347
- [Claude Code, Cursor, OpenCode, Codex, Kiro, Gemini, Qoder, CodeBuddy, Copilot, Droid, Pi]
345
+ [Claude Code, Cursor, OpenCode, codex-sub-agent, Kiro, Gemini, Qoder, CodeBuddy, Copilot, Droid, Pi]
348
346
 
349
347
  Spawn the research sub-agent:
350
348
 
@@ -352,13 +350,13 @@ Spawn the research sub-agent:
352
350
  - **Task description**: Research <specific question>
353
351
  - **Key requirement**: Research output MUST be persisted to `{TASK_DIR}/research/`
354
352
 
355
- [/Claude Code, Cursor, OpenCode, Codex, Kiro, Gemini, Qoder, CodeBuddy, Copilot, Droid, Pi]
353
+ [/Claude Code, Cursor, OpenCode, codex-sub-agent, Kiro, Gemini, Qoder, CodeBuddy, Copilot, Droid, Pi]
356
354
 
357
- [Kilo, Antigravity, Windsurf]
355
+ [codex-inline, Kilo, Antigravity, Windsurf]
358
356
 
359
- Do the research in the main session directly and write findings into `{TASK_DIR}/research/`.
357
+ Do the research in the main session directly and write findings into `{TASK_DIR}/research/`. (For `codex-inline` this avoids the `fork_turns="none"` isolation that prevents `trellis-research` sub-agents from resolving the active task path.)
360
358
 
361
- [/Kilo, Antigravity, Windsurf]
359
+ [/codex-inline, Kilo, Antigravity, Windsurf]
362
360
 
363
361
  **Research artifact conventions**:
364
362
  - One file per research topic (e.g. `research/auth-library-comparison.md`)
@@ -371,7 +369,7 @@ Brainstorm and research can interleave freely — pause to research a technical
371
369
 
372
370
  #### 1.3 Configure context `[required · once]`
373
371
 
374
- [Claude Code, Cursor, OpenCode, Codex, Kiro, Gemini, Qoder, CodeBuddy, Copilot, Droid, Pi]
372
+ [Claude Code, Cursor, OpenCode, codex-sub-agent, Kiro, Gemini, Qoder, CodeBuddy, Copilot, Droid, Pi]
375
373
 
376
374
  Curate `implement.jsonl` and `check.jsonl` so the Phase 2 sub-agents get the right spec context. These files were seeded on `task create` with a single self-describing `_example` line; your job here is to fill in real entries.
377
375
 
@@ -412,13 +410,13 @@ Delete the seed `_example` line once real entries exist (optional — it's skipp
412
410
 
413
411
  Skip when: `implement.jsonl` has agent-curated entries (the seed row alone doesn't count).
414
412
 
415
- [/Claude Code, Cursor, OpenCode, Codex, Kiro, Gemini, Qoder, CodeBuddy, Copilot, Droid, Pi]
413
+ [/Claude Code, Cursor, OpenCode, codex-sub-agent, Kiro, Gemini, Qoder, CodeBuddy, Copilot, Droid, Pi]
416
414
 
417
- [Kilo, Antigravity, Windsurf]
415
+ [codex-inline, Kilo, Antigravity, Windsurf]
418
416
 
419
417
  Skip this step. Context is loaded directly by the `trellis-before-dev` skill in Phase 2.
420
418
 
421
- [/Kilo, Antigravity, Windsurf]
419
+ [/codex-inline, Kilo, Antigravity, Windsurf]
422
420
 
423
421
  #### 1.4 Activate task `[required · once]`
424
422
 
@@ -442,11 +440,11 @@ If `task.py start` errors with a session-identity message (no context key from h
442
440
  | `research/` has artifacts (complex tasks) | recommended |
443
441
  | `info.md` technical design (complex tasks) | optional |
444
442
 
445
- [Claude Code, Cursor, OpenCode, Codex, Kiro, Gemini, Qoder, CodeBuddy, Copilot, Droid, Pi]
443
+ [Claude Code, Cursor, OpenCode, codex-sub-agent, Kiro, Gemini, Qoder, CodeBuddy, Copilot, Droid, Pi]
446
444
 
447
445
  | `implement.jsonl` has agent-curated entries (not just the seed row) | ✅ |
448
446
 
449
- [/Claude Code, Cursor, OpenCode, Codex, Kiro, Gemini, Qoder, CodeBuddy, Copilot, Droid, Pi]
447
+ [/Claude Code, Cursor, OpenCode, codex-sub-agent, Kiro, Gemini, Qoder, CodeBuddy, Copilot, Droid, Pi]
450
448
 
451
449
  ---
452
450
 
@@ -470,7 +468,7 @@ The platform hook/plugin auto-handles:
470
468
 
471
469
  [/Claude Code, Cursor, OpenCode, Gemini, Qoder, CodeBuddy, Copilot, Droid, Pi]
472
470
 
473
- [Codex]
471
+ [codex-sub-agent]
474
472
 
475
473
  Spawn the implement sub-agent:
476
474
 
@@ -482,7 +480,7 @@ The Codex sub-agent definition auto-handles the context load requirement:
482
480
  - Resolves the active task with `task.py current --source`, then reads `prd.md` and `info.md` if present
483
481
  - Reads `implement.jsonl` and requires the agent to load each referenced spec file before coding
484
482
 
485
- [/Codex]
483
+ [/codex-sub-agent]
486
484
 
487
485
  [Kiro]
488
486
 
@@ -498,7 +496,7 @@ The platform prelude auto-handles the context load requirement:
498
496
 
499
497
  [/Kiro]
500
498
 
501
- [Kilo, Antigravity, Windsurf]
499
+ [codex-inline, Kilo, Antigravity, Windsurf]
502
500
 
503
501
  1. Load the `trellis-before-dev` skill to read project guidelines
504
502
  2. Read `{TASK_DIR}/prd.md` for requirements
@@ -506,11 +504,11 @@ The platform prelude auto-handles the context load requirement:
506
504
  4. Implement the code per requirements
507
505
  5. Run project lint and type-check
508
506
 
509
- [/Kilo, Antigravity, Windsurf]
507
+ [/codex-inline, Kilo, Antigravity, Windsurf]
510
508
 
511
509
  #### 2.2 Quality check `[required · repeatable]`
512
510
 
513
- [Claude Code, Cursor, OpenCode, Codex, Kiro, Gemini, Qoder, CodeBuddy, Copilot, Droid, Pi]
511
+ [Claude Code, Cursor, OpenCode, codex-sub-agent, Kiro, Gemini, Qoder, CodeBuddy, Copilot, Droid, Pi]
514
512
 
515
513
  Spawn the check sub-agent:
516
514
 
@@ -523,9 +521,9 @@ The check agent's job:
523
521
  - Auto-fix issues it finds
524
522
  - Run lint and typecheck to verify
525
523
 
526
- [/Claude Code, Cursor, OpenCode, Codex, Kiro, Gemini, Qoder, CodeBuddy, Copilot, Droid, Pi]
524
+ [/Claude Code, Cursor, OpenCode, codex-sub-agent, Kiro, Gemini, Qoder, CodeBuddy, Copilot, Droid, Pi]
527
525
 
528
- [Kilo, Antigravity, Windsurf]
526
+ [codex-inline, Kilo, Antigravity, Windsurf]
529
527
 
530
528
  Load the `trellis-check` skill and verify the code per its guidance:
531
529
  - Spec compliance
@@ -534,7 +532,7 @@ Load the `trellis-check` skill and verify the code per its guidance:
534
532
 
535
533
  If issues are found → fix → re-check, until green.
536
534
 
537
- [/Kilo, Antigravity, Windsurf]
535
+ [/codex-inline, Kilo, Antigravity, Windsurf]
538
536
 
539
537
  #### 2.3 Rollback `[on demand]`
540
538
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mindfoldhq/trellis",
3
- "version": "0.5.7",
3
+ "version": "0.5.9",
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",