@mindfoldhq/trellis 0.6.0-rc.0 → 0.6.0

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,276 @@
1
+ # Workers And Agent Cards
2
+
3
+ Use workers when a peer agent should execute independently and report back
4
+ through the channel event log. A worker is a registered child process (claude
5
+ or codex) attached to a channel; the supervisor forwards inbox messages to it
6
+ and translates its output back into channel events.
7
+
8
+ ## Spawn
9
+
10
+ ```bash
11
+ trellis channel create impl-task --by dispatcher --cwd /path/to/repo
12
+ trellis channel spawn impl-task --provider codex --as codex-impl --timeout 30m
13
+
14
+ echo "Implement the schema for table X per .trellis/.../prd.md" \
15
+ | trellis channel send impl-task --as dispatcher --to codex-impl --stdin
16
+
17
+ trellis channel wait impl-task --as dispatcher --from codex-impl --kind done --timeout 30m
18
+ ```
19
+
20
+ `spawn` forks a `channel __supervisor` worker that emits `spawned`, streams
21
+ `progress`, and should end with `done`, `error`, or `killed`. Workers stay
22
+ inbox-idle until a `send --to <worker>` (or a broadcast when
23
+ `--inbox-policy broadcastAndExplicit` is set) wakes them.
24
+
25
+ Key `spawn` flags:
26
+
27
+ - `--agent <name>` — load `.trellis/agents/<name>.md` (provider/model/as/system prompt defaults).
28
+ - `--provider <claude|codex>` — overrides the agent card; validated against the adapter registry.
29
+ - `--as <name>` — channel worker handle; defaults to the agent name.
30
+ - `--cwd <path>` — worker working directory (also the jail root for `--file`/`--jsonl`).
31
+ - `--model <id>` — model override.
32
+ - `--resume <id>` — resume an existing claude session / codex thread.
33
+ - `--timeout <duration>` — auto-kill after `30s` / `2m` / `1h`.
34
+ - `--warn-before <duration>` — supervisor_warning lead time (default `5m`; `0ms` disables).
35
+ - `--file <path>` (repeatable, glob-supported) — inject file content into the system prompt.
36
+ - `--jsonl <path>` (repeatable) — Trellis jsonl manifest (`{file, reason}` per line).
37
+ - `--by <agent>` — author of the `spawned` event (defaults to `$TRELLIS_CHANNEL_AS` or `main`).
38
+ - `--inbox-policy <explicitOnly|broadcastAndExplicit>` — default `explicitOnly`.
39
+ - `--idle-timeout <duration>` — OOM guard idle TTL (default `5m`; `0` disables).
40
+ - `--max-live-workers <n>` — spawn-time live-worker budget (default `6`; `0` disables).
41
+
42
+ The success event `spawned` records `pid`, `provider`, `agent`, the injected
43
+ `files`, and the resolved `manifests` so later spectators can audit context.
44
+
45
+ ## Agent Cards
46
+
47
+ `--agent <name>` resolves to `.trellis/agents/<name>.md`. The card name must
48
+ match `[A-Za-z0-9._-]+`. The default Trellis install ships two cards:
49
+
50
+ - `.trellis/agents/check.md` — code-quality reviewer.
51
+ - `.trellis/agents/implement.md` — coding worker for implementation runs.
52
+
53
+ ```yaml
54
+ ---
55
+ name: check
56
+ description: Code quality check expert.
57
+ provider: claude
58
+ ---
59
+ ```
60
+
61
+ Frontmatter fields populate `spawn` defaults (provider, model, `as`); the
62
+ markdown body becomes the worker's system-prompt role. Cards do **not**
63
+ auto-attach task files — context must be injected explicitly per spawn (see
64
+ below).
65
+
66
+ Always inspect project cards before spawning a named agent:
67
+
68
+ ```bash
69
+ ls .trellis/agents
70
+ sed -n '1,100p' .trellis/agents/check.md
71
+ ```
72
+
73
+ ## Context Injection
74
+
75
+ Two flags inject content into the worker's system prompt under a
76
+ `# CONTEXT FILES` block, assembled by `context-loader`:
77
+
78
+ - `--file <path>` — repeatable, glob-supported (`*`, `**`). Each match is
79
+ read and concatenated.
80
+ - `--jsonl <path>` — repeatable Trellis manifest where every line is
81
+ `{"file":"<path>","reason":"<why>"}`. The reason is preserved as a header
82
+ comment above each file's content.
83
+
84
+ Limits enforced by the loader:
85
+
86
+ - 1 MB hard cap per file (oversize → error).
87
+ - 200 KB per-file warning to stderr.
88
+ - 500 KB total assembled-context warning to stderr.
89
+ - Path-traversal jail: all resolved paths must stay under `--cwd`.
90
+
91
+ Example spawning a check agent against a task directory:
92
+
93
+ ```bash
94
+ TASK=.trellis/tasks/05-13-example
95
+ trellis channel spawn cr-example --agent check --provider codex --as check-cx \
96
+ --file "$TASK/prd.md" \
97
+ --file "$TASK/design.md" \
98
+ --file "$TASK/implement.md" \
99
+ --jsonl "$TASK/check.jsonl" \
100
+ --cwd "$PWD" --timeout 30m
101
+ ```
102
+
103
+ The `spawned` event records both the literal `files` array and any `manifests`
104
+ expanded from `--jsonl`, so the audit trail captures whatever the worker was
105
+ actually shown.
106
+
107
+ ## Names And Routing
108
+
109
+ `--as` has two meanings:
110
+
111
+ - `send` / `wait` / `interrupt`: speaker identity (author of the resulting event).
112
+ - `spawn`: the worker handle that other agents address with `--to`.
113
+
114
+ Use explicit names when multiple workers or providers participate in one
115
+ channel:
116
+
117
+ ```bash
118
+ trellis channel spawn cr-feature --agent check --as check-claude
119
+ trellis channel spawn cr-feature --agent check --provider codex --as check-cx
120
+
121
+ trellis channel wait cr-feature --as main \
122
+ --from check-claude,check-cx --kind done --all --timeout 15m
123
+ ```
124
+
125
+ `--all` requires `--from` and blocks until every listed worker has produced a
126
+ matching event; timeout exits with code **124** and prints
127
+ `timeout: still waiting on ...` to stderr.
128
+
129
+ ## Soft Interrupt — `interrupt`
130
+
131
+ `channel interrupt` is the cooperative redirect: it appends an `interrupt`
132
+ event (reason `"user"`) and, where the adapter supports it, issues a
133
+ provider-level turn interrupt with a replacement instruction. Use it when the
134
+ worker should drop its current turn and act on new input immediately, without
135
+ losing its session.
136
+
137
+ ```bash
138
+ echo "Stop refactoring the parser — switch to fixing the failing test in src/foo.ts" \
139
+ | trellis channel interrupt impl-task --as dispatcher --to codex-impl --stdin
140
+ ```
141
+
142
+ Flags:
143
+
144
+ - `--as <agent>` **(required)** — caller identity.
145
+ - `--to <agent>` **(required)** — target worker.
146
+ - `--scope <project|global>` — channel scope.
147
+ - `--stdin` / `--text-file <path>` / `[text]` — replacement instruction body.
148
+
149
+ The appended event has `kind: "interrupt"` — downstream `wait` / `messages`
150
+ filters can subscribe with `--kind interrupt` to react to redirections (e.g.
151
+ to log the rerouting, or to gate other workers behind a coordinator's
152
+ correction).
153
+
154
+ For low-priority hints that should wait for the worker's next turn, send a
155
+ plain tagged message instead:
156
+
157
+ ```bash
158
+ echo "Check this when you reach the next turn." \
159
+ | trellis channel send impl-task --as dispatcher --to codex-impl \
160
+ --stdin --tag question
161
+ ```
162
+
163
+ ## Hard Interrupt — `kill` + `--resume`
164
+
165
+ Use `kill` when the worker must stop **now** (e.g. runaway loop, bad
166
+ instructions already in flight, or `interrupt` is not honored by the
167
+ adapter). The supervisor escalates SIGTERM → 8 s grace → SIGKILL; the CLI
168
+ writes a `killed` event when SIGKILL is needed so the event log stays
169
+ truthful.
170
+
171
+ ```bash
172
+ trellis channel kill impl-task --as codex-impl
173
+ trellis channel spawn impl-task --as codex-impl --provider codex \
174
+ --resume "$(cat ~/.trellis/channels/<bucket>/impl-task/worker.session-id)"
175
+
176
+ echo "STOP — new instructions: ..." \
177
+ | trellis channel send impl-task --as dispatcher --to codex-impl --stdin
178
+ ```
179
+
180
+ `kill` flags:
181
+
182
+ - `--as <agent>` **(required)** — names the worker (positional `<name>` is the channel).
183
+ - `--scope <project|global>`.
184
+ - `--force` — SIGKILL immediately (also kills the inner worker pid).
185
+
186
+ Side effects: cleans `pid`, `worker-pid`, `config`, `spawnlock` sidecar
187
+ files; keeps `log`, `session-id`, `thread-id` for forensics and resume.
188
+
189
+ When `interrupt` will not converge, kill + `--resume` is the guaranteed
190
+ redirection path.
191
+
192
+ ## Worker OOM Guard
193
+
194
+ The OOM guard prevents orphaned/idle workers from accumulating and exhausting
195
+ host resources. It runs at every `spawn` and enforces two policies per
196
+ project bucket:
197
+
198
+ - **Idle TTL** — sweep workers whose last activity is older than the
199
+ configured threshold (default `5m`; `0` disables).
200
+ - **Live-worker budget** — refuse the new spawn if more than N workers are
201
+ already alive in the same project bucket (default `6`; `0` disables).
202
+
203
+ Precedence (highest first):
204
+
205
+ 1. CLI flags: `--idle-timeout`, `--max-live-workers` on `spawn`.
206
+ 2. Environment variables: `TRELLIS_CHANNEL_WORKER_IDLE_TIMEOUT`,
207
+ `TRELLIS_CHANNEL_MAX_LIVE_WORKERS`.
208
+ 3. `.trellis/config.yaml` under `channel.worker_guard`.
209
+ 4. Built-in defaults (`5m`, `6`).
210
+
211
+ Cleanup notices are written to stderr at spawn time so operators can see which
212
+ idle workers were swept and why a new spawn was rejected. The guard does not
213
+ touch ephemeral / `channel run` workers any differently — they are subject to
214
+ the same idle TTL and budget.
215
+
216
+ To audit current state, list workers via `channel list` (the `WORKERS`
217
+ column) and inspect per-channel `pid` / `worker-pid` sidecar files under
218
+ `~/.trellis/channels/<bucket>/<channel>/`.
219
+
220
+ ## Worker Inbox APIs
221
+
222
+ The inbox is the channel surface workers wake on. Routing is controlled by
223
+ two knobs:
224
+
225
+ - **Inbox policy** (`spawn --inbox-policy`):
226
+ - `explicitOnly` (default) — worker only wakes on `send --to <worker>` or
227
+ `interrupt --to <worker>`.
228
+ - `broadcastAndExplicit` — also wakes on broadcasts (`send` with no `--to`).
229
+ - **Delivery mode** (`send --delivery-mode`):
230
+ - `appendOnly` — append the event regardless of worker state.
231
+ - `requireKnownWorker` — fail if no worker named in `--to` was ever spawned.
232
+ - `requireRunningWorker` — fail if the named worker is not currently alive.
233
+
234
+ Stricter delivery modes prevent silent message loss when callers expect a
235
+ running peer.
236
+
237
+ Inbox-relevant subcommands:
238
+
239
+ - `send <channel> [text]` — append a `message` event.
240
+ - `--as <agent>` **(required)** — author.
241
+ - `--to <agents>` — CSV; one → string, many → array; broadcast if omitted.
242
+ - `--stdin` / `--text-file <path>` / `[text]` — body source.
243
+ - `--delivery-mode <appendOnly|requireKnownWorker|requireRunningWorker>`.
244
+ - `interrupt <channel> [text]` — soft-interrupt redirect (see above).
245
+ - `wait <channel>` — block until matching events arrive.
246
+ - `--as <agent>` **(required)** — `self` for filter context.
247
+ - `--from <agents>` — CSV authors.
248
+ - `--kind <kind[,kind...]>` — CSV (OR semantics); supports `interrupt`,
249
+ `done`, `progress`, etc.
250
+ - `--to <target>` — defaults to own agent (broadcast + explicit-to-me).
251
+ - `--include-progress` — also wake on progress events.
252
+ - `--all` — require every `--from` agent to match (timeout → exit **124**).
253
+ - `--timeout <duration>` — `30s` / `2m` / `1h` / `1000ms`.
254
+ - `messages <channel>` — view / filter / follow the event stream.
255
+ - `--follow` to tail, `--kind` / `--from` / `--to` to filter, `--raw` for
256
+ JSON-per-line, `--no-progress` to hide progress noise.
257
+
258
+ A typical dispatcher loop:
259
+
260
+ ```bash
261
+ # 1. Wake the worker.
262
+ echo "Run the failing test and report." \
263
+ | trellis channel send impl-task --as dispatcher --to codex-impl --stdin \
264
+ --delivery-mode requireRunningWorker
265
+
266
+ # 2. Block until it finishes.
267
+ trellis channel wait impl-task --as dispatcher \
268
+ --from codex-impl --kind done,error --timeout 30m
269
+
270
+ # 3. Read the final answer.
271
+ trellis channel messages impl-task --from codex-impl --last 1 --raw
272
+ ```
273
+
274
+ All event-emitting subcommands (`send`, `interrupt`, `post`, `context add` /
275
+ `delete`, `title set` / `clear`, `thread rename`) print the appended event as
276
+ a single JSON line on stdout, making the inbox layer easy to script against.
@@ -0,0 +1,128 @@
1
+ # Workflows
2
+
3
+ Use these patterns by intent. Prefer durable channels for multi-round work and
4
+ `channel run` for one-shot questions.
5
+
6
+ ## Pattern A: Multi-round Brainstorm
7
+
8
+ Use when the user says "和 codex/claude 讨论一下", "brainstorm", or "拉一个 agent
9
+ 进来一起看".
10
+
11
+ ```bash
12
+ trellis channel create brainstorm-storage-layer --by main \
13
+ --task .trellis/tasks/05-XX-storage-adapter
14
+
15
+ trellis channel spawn brainstorm-storage-layer \
16
+ --agent architect --provider codex \
17
+ --file .trellis/tasks/05-XX-storage-adapter/prd.md \
18
+ --file .trellis/tasks/05-XX-storage-adapter/design.md \
19
+ --as cx-arch --timeout 30m
20
+
21
+ trellis channel send brainstorm-storage-layer \
22
+ --as main --to cx-arch --text-file /tmp/brainstorm-r1.md
23
+
24
+ trellis channel wait brainstorm-storage-layer \
25
+ --as main --kind done --from cx-arch --timeout 10m
26
+ ```
27
+
28
+ Do not stop after one answer. Read the answer, identify vague areas, send a
29
+ new probe, and repeat until the result is executable.
30
+
31
+ Minimum round structure:
32
+
33
+ 1. Direction split: should this live in an existing mechanism or a new one?
34
+ 2. MVP boundary: v1, v2, and what would force v2 back into v1.
35
+ 3. Data contract: events, schema, metadata, state source of truth, compatibility.
36
+ 4. CLI / UX contract: command names, flags, errors, defaults, ambiguity.
37
+ 5. Cross-layer risk and tests: shared helpers, drift points, release-blocking tests.
38
+
39
+ Optional rounds:
40
+
41
+ - Operations: logs, debugging, stuck workers, kill/restart, recovery.
42
+ - Migration/release: breaking status, manifest, changelog, docs-site.
43
+ - Opposition review: ask the peer agent to argue against the current plan.
44
+
45
+ Every probe should request concrete file paths, commands, schema, rejected
46
+ alternatives, and release-blocking issues. Reject hedging when a decision is
47
+ needed.
48
+
49
+ ## Pattern B: Implement / Check Agent
50
+
51
+ Use when the user asks to dispatch implementation or review work.
52
+
53
+ ```bash
54
+ TASK=.trellis/tasks/05-12-foo
55
+ trellis channel create cr-foo --task "$TASK" --by main
56
+
57
+ trellis channel spawn cr-foo \
58
+ --agent check \
59
+ --jsonl "$TASK/check.jsonl" \
60
+ --file "$TASK/prd.md" \
61
+ --file "$TASK/design.md" \
62
+ --file "$TASK/implement.md" \
63
+ --cwd "$PWD" --timeout 15m
64
+
65
+ trellis channel send cr-foo --as main --to check --text-file /tmp/cr-brief.md
66
+ trellis channel wait cr-foo --as main --kind done --from check --timeout 15m
67
+ trellis channel messages cr-foo --kind message --from check --tag final_answer
68
+ ```
69
+
70
+ For implement work, use `--agent implement` and send an implementation brief.
71
+ For check work, include the exact diff scope, relevant specs, and validation
72
+ already run.
73
+
74
+ ## Pattern C: Parallel Reviewers
75
+
76
+ Use one channel and distinct worker names.
77
+
78
+ ```bash
79
+ trellis channel create cr-feature --by main --ephemeral
80
+
81
+ trellis channel spawn cr-feature --agent check \
82
+ --jsonl "$TASK/check.jsonl" --file "$TASK/prd.md" --file "$TASK/design.md" \
83
+ --timeout 15m
84
+
85
+ trellis channel spawn cr-feature --agent check --provider codex --as check-cx \
86
+ --jsonl "$TASK/check.jsonl" --file "$TASK/prd.md" --file "$TASK/design.md" \
87
+ --timeout 15m
88
+
89
+ trellis channel send cr-feature --as main --to check --text-file /tmp/cr-brief.md
90
+ trellis channel send cr-feature --as main --to check-cx --text-file /tmp/cr-brief.md
91
+ trellis channel wait cr-feature --as main --kind done --from check,check-cx --all --timeout 15m
92
+ ```
93
+
94
+ `--all` means every listed worker must emit a matching event.
95
+
96
+ ## Pattern D: One-shot Worker
97
+
98
+ ```bash
99
+ trellis channel run --provider codex --message "say hi in 3 words" --timeout 1m
100
+ trellis channel run --agent plan --message-file /tmp/plan-question.md --timeout 10m
101
+ ```
102
+
103
+ On success, `run` removes the ephemeral channel. On error/timeout/killed, it
104
+ keeps the channel and prints the path for inspection.
105
+
106
+ ## Pattern E: Forum Channel
107
+
108
+ Use for issue forums, topic-style feedback, release todos, agent findings, and
109
+ internal changelogs. Read `forum.md` for the full model.
110
+
111
+ ## Pattern F: Take Over Existing Thread
112
+
113
+ If the user gives a forum/thread name, restore context yourself:
114
+
115
+ ```bash
116
+ trellis channel forum <board> --scope global
117
+ trellis channel thread <board> <thread> --scope global --raw
118
+ trellis channel context list <board> --scope global --thread <thread>
119
+ trellis channel messages <board> --scope global --raw --thread <thread>
120
+ ```
121
+
122
+ Output a constraint summary, not a transcript dump:
123
+
124
+ - user-level problem
125
+ - context files that affect this repo
126
+ - current-version versus future-version requirements
127
+ - whether current code/design satisfies it
128
+ - next action or comment to append
@@ -1,73 +1,85 @@
1
1
  ---
2
2
  name: trellis-meta
3
- description: "Understand and customize the local Trellis architecture inside a user project. Use when modifying .trellis plus platform hooks, settings, agents, skills, commands, prompts, or workflows generated by trellis init."
3
+ description: "Understand and customize the local Trellis architecture inside a user project. Use when modifying .trellis plus platform hooks, settings, agents, skills, commands, prompts, workflows, the channel runtime (trellis channel), bundled runtime agents under .trellis/agents/, selectable workflow templates, registry-backed spec refresh, cross-session memory (trellis mem) generated by trellis init, or AI-facing bundled skills (trellis-channel, trellis-session-insight, trellis-spec-bootstrap) and bundled-skill auto-dispatch flow."
4
4
  ---
5
5
 
6
6
  # Trellis Meta
7
7
 
8
8
  This skill is for local Trellis users who have already run `trellis init` in a project. After reading it, an AI should understand the Trellis architecture, operating model, and customization entry points inside that user project, then modify the generated `.trellis/` and platform directory files according to the user's request.
9
9
 
10
+ Trellis v0.6 adds three architectural surfaces on top of the pre-v0.6 workflow / persistence / platform model. First, a multi-agent collaboration runtime: `trellis channel` coordinates multiple AI worker processes through project-scoped JSONL event logs at `~/.trellis/channels/<project>/<channel>/events.jsonl`, with worker OOM guard, forum/thread channels, durable idempotency keys, and bundled `.trellis/agents/{check,implement}.md` runtime definitions. Second, cross-session memory: `trellis mem list | search | context | extract | projects` reads raw Claude Code and Codex JSONL already on disk, slices by `--phase brainstorm|implement|all`, and never uploads anything. Third, a dual-package npm release: `@mindfoldhq/trellis` (CLI) and `@mindfoldhq/trellis-core` (SDK with `/channel`, `/task`, `/mem`, `/testing` subpaths) ship in lockstep on one version. Treat these as first-class customization surfaces alongside the per-platform integration files.
11
+
10
12
  The default operating scope is local files in the user project:
11
13
 
12
- - `.trellis/`: workflow, config, tasks, spec, workspace, scripts, and runtime state.
13
- - Platform directories: `.claude/`, `.codex/`, `.cursor/`, `.opencode/`, `.kiro/`, `.gemini/`, `.qoder/`, `.codebuddy/`, `.github/`, `.factory/`, `.pi/`, `.kilocode/`, `.agent/`, `.windsurf/`, and similar directories.
14
+ - `.trellis/`: workflow, config, tasks, spec, workspace, scripts, bundled runtime agents, and runtime state.
15
+ - Platform directories: `.claude/`, `.codex/`, `.cursor/`, `.opencode/`, `.kiro/`, `.gemini/`, `.qoder/`, `.codebuddy/`, `.github/`, `.factory/`, `.pi/`, `.reasonix/`, `.kilocode/`, `.agent/`, `.windsurf/`, and similar directories. Pi additionally exposes a native `trellis_subagent` tool with `single` / `parallel` / `chain` dispatch modes, throttled progress cards, and `isTrellisAgent()` validation on top of the file layout. Reasonix stores both workflow skills and subagent skills as `.reasonix/skills/<name>/SKILL.md`; subagent skills carry `runAs: subagent` frontmatter.
14
16
  - Shared skill layer: `.agents/skills/`.
17
+ - User-owned channel store outside the project tree: `~/.trellis/channels/<project>/<channel>/events.jsonl`.
18
+ - Raw platform conversation logs queryable via `trellis mem`: `~/.claude/projects/` and `~/.codex/sessions/` (OpenCode adapter degraded for the v0.6 line).
15
19
 
16
- Do not assume the user has the Trellis source repository. Do not default to modifying the global npm install directory or `node_modules`.
20
+ Do not assume the user has the Trellis source repository. Do not default to modifying the global npm install directory or `node_modules` — both `@mindfoldhq/trellis` and `@mindfoldhq/trellis-core` ship as published packages sharing one version and one git tag per release.
17
21
 
18
22
  ## How To Use
19
23
 
20
24
  1. Read `references/local-architecture/overview.md` first to establish the local Trellis system model.
21
25
  2. If the request involves a specific AI tool, read `references/platform-files/platform-map.md` and the relevant platform file notes.
22
- 3. If the user wants to change behavior, read `references/customize-local/overview.md`, then open the specific customization topic.
23
- 4. Before editing, read the actual files in the user project and treat local content as authoritative.
26
+ 3. If the request involves multi-agent dispatch or channel workers, read `references/local-architecture/multi-agent-channel.md` and the bundled `.trellis/agents/` files.
27
+ 4. If the user wants to change behavior, read `references/customize-local/overview.md`, then open the specific customization topic.
28
+ 5. Before editing, read the actual files in the user project and treat local content as authoritative.
24
29
 
25
30
  ## References
26
31
 
27
32
  ### Local Architecture
28
33
 
29
- - `references/local-architecture/overview.md`: The three-layer local Trellis architecture and customization principles.
30
- - `references/local-architecture/generated-files.md`: Files generated by `trellis init` and their customization boundaries.
31
- - `references/local-architecture/workflow.md`: Phases, routing, and workflow-state blocks in `.trellis/workflow.md`.
32
- - `references/local-architecture/task-system.md`: Task directories, active tasks, JSONL context, and task runtime.
33
- - `references/local-architecture/spec-system.md`: How `.trellis/spec/` is organized and injected.
34
- - `references/local-architecture/workspace-memory.md`: `.trellis/workspace/`, journals, and cross-session memory.
35
- - `references/local-architecture/context-injection.md`: Hooks, sub-agent preludes, and context injection paths.
34
+ - `references/local-architecture/overview.md`: The layered local Trellis architecture (workflow / persistence / platform / channel runtime) and customization principles.
35
+ - `references/local-architecture/generated-files.md`: Files generated by `trellis init` and their customization boundaries, including `.trellis/agents/`.
36
+ - `references/local-architecture/workflow.md`: Phases, routing, workflow-state blocks, and selectable workflow templates (`native`, `tdd`, `channel-driven-subagent-dispatch`, marketplace) in `.trellis/workflow.md`.
37
+ - `references/local-architecture/task-system.md`: Task directories, active task, JSONL context, parent/child task trees, and task runtime.
38
+ - `references/local-architecture/spec-system.md`: How `.trellis/spec/` is organized, injected, and refreshed from a `registry.spec` source.
39
+ - `references/local-architecture/workspace-memory.md`: `.trellis/workspace/` journals plus `trellis mem` cross-session recall and the `@mindfoldhq/trellis-core/mem` SDK.
40
+ - `references/local-architecture/context-injection.md`: Hooks, sub-agent preludes, and channel-runtime worker inbox routing.
41
+ - `references/local-architecture/multi-agent-channel.md`: `trellis channel` subcommands, project-scoped event store, forum/thread channels, worker OOM guard, durable idempotency, and bundled `.trellis/agents/` runtime agents.
42
+ - `references/local-architecture/bundled-skills.md`: Auto-dispatched bundled skills (`trellis-meta`, `trellis-spec-bootstrap`, `trellis-session-insight`) and how `getBundledSkillTemplates()` ships them to every platform skill root.
36
43
 
37
44
  ### Platform Files
38
45
 
39
- - `references/platform-files/overview.md`: How shared `.trellis/` files relate to platform directories.
40
- - `references/platform-files/platform-map.md`: Platform directories and paths for skills, agents, hooks, and extensions.
41
- - `references/platform-files/hooks-and-settings.md`: How settings/config files, hooks, plugins, and extensions connect to Trellis.
42
- - `references/platform-files/agents.md`: Local file responsibilities for `trellis-research`, `trellis-implement`, and `trellis-check`.
46
+ - `references/platform-files/overview.md`: How shared `.trellis/` files relate to platform directories and the four platform integration modes (hook-driven, agent prelude, main-session workflow, channel runtime).
47
+ - `references/platform-files/platform-map.md`: Platform directories and paths for skills, agents, hooks, and extensions across all 15 supported platforms including Reasonix and Pi's native `trellis_subagent` extension.
48
+ - `references/platform-files/hooks-and-settings.md`: How settings/config files, hooks, plugins, and extensions connect to Trellis; covers `channel.worker_guard.*` and `codex.dispatch_mode`.
49
+ - `references/platform-files/agents.md`: Per-platform `trellis-research` / `trellis-implement` / `trellis-check` sub-agent files plus bundled `.trellis/agents/{check,implement}.md` for the channel runtime.
43
50
  - `references/platform-files/skills-and-commands.md`: Differences between skills, commands, prompts, and workflows, plus how to change them.
44
51
 
45
52
  ### Local Customization
46
53
 
47
54
  - `references/customize-local/overview.md`: Choose the right local customization entry point for the user's request.
48
- - `references/customize-local/change-workflow.md`: Change phases, routing, next actions, and workflow-state.
49
- - `references/customize-local/change-task-lifecycle.md`: Change task creation, status, archive behavior, and hooks.
50
- - `references/customize-local/change-context-loading.md`: Change how tasks, specs, journals, and hook context are loaded.
51
- - `references/customize-local/change-hooks.md`: Change platform hooks, settings, and shell session bridges.
52
- - `references/customize-local/change-agents.md`: Change research, implement, and check agent behavior.
53
- - `references/customize-local/change-skills-or-commands.md`: Add or modify local skills, commands, prompts, and workflows.
54
- - `references/customize-local/change-spec-structure.md`: Adjust the project spec structure under `.trellis/spec/`.
55
+ - `references/customize-local/change-workflow.md`: Change phases, routing, next actions, workflow-state, and the selected workflow template.
56
+ - `references/customize-local/change-task-lifecycle.md`: Change task creation, status, archive behavior, parent/child links, archive slug collision handling, and lifecycle hooks.
57
+ - `references/customize-local/change-context-loading.md`: Change how tasks, specs, journals, hook context, channel inbox messages, and `trellis mem` recall are loaded.
58
+ - `references/customize-local/change-hooks.md`: Change platform hooks, settings, task lifecycle hooks (`hooks.after_*`), and shell session bridges.
59
+ - `references/customize-local/change-agents.md`: Change research, implement, and check agent behavior across platform sub-agents, bundled channel runtime agents, and the Codex `dispatch_mode` toggle.
60
+ - `references/customize-local/change-skills-or-commands.md`: Add or modify local skills, commands, prompts, and workflows; covers upstream bundled-skill auto-dispatch.
61
+ - `references/customize-local/change-spec-structure.md`: Adjust the project spec structure under `.trellis/spec/`, including registry-backed sources.
55
62
  - `references/customize-local/add-project-local-conventions.md`: Put team rules into project-local specs or local skills.
56
63
 
57
64
  ## Current Rules
58
65
 
59
- - `.trellis/workflow.md` is the local workflow source of truth.
60
- - `.trellis/config.yaml` is the project-level Trellis configuration and task hook configuration entry point.
61
- - `.trellis/spec/` stores the user's project-specific coding conventions and design constraints.
62
- - `.trellis/tasks/` stores task PRDs, technical notes, research files, and JSONL context.
63
- - `.trellis/workspace/` stores developer journals and cross-session memory.
64
- - Platform settings/config files decide which hooks, agents, skills, commands, prompts, and workflows actually run.
66
+ - `.trellis/workflow.md` is the local workflow source of truth; its initial content was selected from a workflow template (built-in `native`, `tdd`, `channel-driven-subagent-dispatch`, or a marketplace template) at `trellis init` time and can be re-selected via `trellis workflow --template <id>`. Missing `.trellis/agents/<name>.md` files referenced by the active template trigger a non-blocking stderr warning pointing at `trellis update`.
67
+ - `.trellis/config.yaml` is the project-level Trellis configuration entry point. It hosts task lifecycle hooks (`hooks.after_create` / `after_start` / `after_finish` / `after_archive`), journal shape (`session_commit_message` / `max_journal_lines` / `session_auto_commit`), channel worker guard (`channel.worker_guard.idle_timeout` / `max_live_workers`), Codex dispatch mode (`codex.dispatch_mode: inline | sub-agent`), and the spec registry block (`registry.spec.source` + `registry.spec.template`).
68
+ - `.trellis/spec/` stores the user's project-specific coding conventions and design constraints. When `registry.spec` is set, files are refreshed by `trellis update`; local edits surface as "modified by user" conflicts in `.trellis/.template-hashes.json`.
69
+ - `.trellis/tasks/` stores task PRDs, design notes, implement plans, research files, and JSONL context. Tasks form parent/child trees: `task.py create --parent <slug>`, `task.py add-subtask <parent> <child>`, `task.py remove-subtask <parent> <child>`, and `task.py list-context <task>`. `task.py create` rejects a slug already present in `.trellis/tasks/archive/**`.
70
+ - `.trellis/workspace/` stores **deliberately written** developer journals. Raw cross-session dialogue is **not** stored here — it lives on disk under `~/.claude/projects/` and `~/.codex/sessions/` and is recovered via `trellis mem search|extract|context`. The bundled `trellis-session-insight` skill teaches when to reach for `mem`.
71
+ - `.trellis/agents/{check,implement}.md` are bundled, platform-agnostic channel runtime agent definitions loaded by `trellis channel spawn --agent <name>`. Editable; `trellis update` backfills missing ones. Editing the per-platform `trellis-implement.md` / `trellis-check.md` does **not** change channel-runtime worker behavior.
72
+ - `~/.trellis/channels/<project>/<channel>/events.jsonl` is the channel runtime event log per project per channel. User-owned, file-locked sequence numbering, durable `idempotencyKey` support; never under `.trellis/`.
73
+ - Bundled multi-file skills (`trellis-meta`, `trellis-spec-bootstrap`, `trellis-session-insight`, `trellis-channel`) are auto-dispatched to every platform skill root by `getBundledSkillTemplates()` in `packages/cli/src/templates/common/index.ts`. Dropping a new directory under `packages/cli/src/templates/common/bundled-skills/` (upstream) ships it to every platform on the next `trellis update`.
74
+ - Platform settings/config files decide which hooks, agents, skills, commands, prompts, and workflows actually run. Reasonix has no settings file — behavior is encoded inside skill frontmatter.
65
75
  - `.trellis/.template-hashes.json` and `.trellis/.runtime/` are management/runtime state files. Confirm necessity before editing them.
66
76
 
67
77
  ## Do Not
68
78
 
69
79
  - Do not treat Trellis upstream source code as the default target for local customization.
70
- - Do not modify the global npm install directory or `node_modules/@mindfoldhq/trellis` to implement project needs.
71
- - Do not overwrite user-modified local files with default templates.
72
- - Do not put team-private project rules into the public `trellis-meta`; put project rules in `.trellis/spec/` or a project-local skill.
73
- - Do not describe removed historical mechanisms as current Trellis behavior.
80
+ - Do not modify the global npm install directory or `node_modules/@mindfoldhq/trellis` or `node_modules/@mindfoldhq/trellis-core` to implement project needs; both packages ship in lockstep.
81
+ - Do not overwrite user-modified local files with default templates; check `.trellis/.template-hashes.json` first and prefer `.new` sidecar files over destructive overwrites.
82
+ - Do not put team-private project rules into any public bundled skill (`trellis-meta`, `trellis-spec-bootstrap`, `trellis-session-insight`, `trellis-channel`); put project rules in `.trellis/spec/`, a project-local skill, the current task, or the workspace journal — `trellis update` will overwrite anything inside a bundled skill directory.
83
+ - Do not hand-edit `~/.trellis/channels/<project>/<channel>/events.jsonl`; sequence numbers are assigned under a file lock and replay-safe writes go through the `trellis channel` CLI or the `@mindfoldhq/trellis-core/channel` SDK.
84
+ - Do not edit `.claude/agents/trellis-implement.md` (or any other per-platform sub-agent file) when the goal is to change channel runtime worker behavior — edit `.trellis/agents/<name>.md` instead.
85
+ - Do not describe removed or never-shipped mechanisms as current Trellis behavior; cross-check against the local `.trellis/config.yaml` and the installed CLI's `trellis --help` before claiming a knob exists.
@@ -2,12 +2,20 @@
2
2
 
3
3
  When the user wants to change AI entry points, auto-trigger rules, or explicit command behavior, edit skills, commands, prompts, or workflows in local platform directories.
4
4
 
5
+ Before editing, classify the skill you are about to touch:
6
+
7
+ - **Bundled upstream skill** — `trellis-meta`, `trellis-spec-bootstrap`, `trellis-session-insight`, `trellis-channel`. Source of truth lives in the Trellis CLI repo under `packages/cli/src/templates/common/bundled-skills/<name>/`; auto-dispatched to every platform's skill root by `getBundledSkillTemplates()` on `trellis init` / `trellis update`. Local edits here are tracked by `.trellis/.template-hashes.json` and will be flagged on the next update.
8
+ - **Project-local skill** — anything else under `.{platform}/skills/`. Owned by the user; not refreshed by `trellis update`.
9
+
10
+ The remainder of this file uses "skill" for the local file; the override and conflict rules differ between the two cases.
11
+
5
12
  ## Read These Files First
6
13
 
7
14
  1. `.trellis/workflow.md`
8
15
  2. Target platform skill/command/prompt/workflow directory
9
16
  3. Related agent or hook files
10
17
  4. Whether project rules already exist in `.trellis/spec/`
18
+ 5. `.trellis/.template-hashes.json` — confirms whether the skill you are about to edit is upstream-owned (entry present) or project-local (entry absent)
11
19
 
12
20
  ## Which Entry Type To Choose
13
21
 
@@ -15,7 +23,9 @@ When the user wants to change AI entry points, auto-trigger rules, or explicit c
15
23
  | --- | --- |
16
24
  | AI should automatically know a capability | Add or modify a skill. |
17
25
  | User wants to trigger manually with a command | Add or modify a command/prompt/workflow. |
18
- | Team project conventions | Prefer `.trellis/spec/` or a project-local skill. |
26
+ | Team project conventions | Prefer `.trellis/spec/` or a project-local skill — never a bundled skill directory. |
27
+ | Tweak a bundled skill (`trellis-meta` et al.) for the user's own project | Create a project-local sibling skill (different name) that overrides intent, or edit `.trellis/spec/`. Edits inside the bundled skill directory survive only until the next `trellis update` and will need a "keep" choice each time. |
28
+ | Contribute the change back upstream | Edit `packages/cli/src/templates/common/bundled-skills/<name>/` in the Trellis CLI repo, not the deployed copy. |
19
29
  | Change Trellis flow semantics | Synchronize `.trellis/workflow.md`. |
20
30
 
21
31
  ## Modify A Skill
@@ -38,6 +48,20 @@ description: "Use when customizing this project's deployment workflow and releas
38
48
 
39
49
  Do not write vague descriptions such as "helpful project skill"; they can trigger incorrectly.
40
50
 
51
+ ### Bundled vs. Project-Local
52
+
53
+ The same directory shape is used by two very different ownership models:
54
+
55
+ | Aspect | Bundled (`trellis-meta`, `trellis-spec-bootstrap`, `trellis-session-insight`, `trellis-channel`) | Project-local |
56
+ | --- | --- | --- |
57
+ | Source of truth | `packages/cli/src/templates/common/bundled-skills/<name>/` in Trellis CLI repo | Inside the user project itself |
58
+ | Dispatch | Auto-dispatched to every platform skill root by `getBundledSkillTemplates()` (`packages/cli/src/templates/common/index.ts`) on `trellis init` / `trellis update` | Created by the user (or another skill) and never moved |
59
+ | Hash tracking | Every file recorded in `.trellis/.template-hashes.json`; conflict prompt on update | Not tracked |
60
+ | Editing locally | Allowed but will be marked "modified by user" on next update | Free editing |
61
+ | The right way to customize | Add a *new* project-local skill with a *different* name that supplements (or supersedes) the bundled one | Edit the file directly |
62
+
63
+ If the goal is "make my project's AI behave differently when discussing release notes," the answer is almost always a project-local skill, not surgery on `trellis-meta/`.
64
+
41
65
  ## Modify A Command/Prompt/Workflow
42
66
 
43
67
  Explicit entry points should state:
@@ -57,22 +81,42 @@ If a command only repeats workflow rules, prefer making it reference/read `.trel
57
81
  | Cursor | `.cursor/skills/`, `.cursor/commands/` |
58
82
  | OpenCode | `.opencode/skills/`, `.opencode/commands/` |
59
83
  | Codex | `.agents/skills/`, `.codex/skills/` |
84
+ | Gemini CLI | `.agents/skills/`, `.gemini/commands/` |
85
+ | Kiro | `.kiro/skills/` |
86
+ | Qoder | `.qoder/skills/`, `.qoder/commands/` |
87
+ | CodeBuddy | `.codebuddy/skills/`, `.codebuddy/commands/` |
60
88
  | GitHub Copilot | `.github/skills/`, `.github/prompts/` |
89
+ | Factory Droid | `.factory/skills/`, `.factory/commands/` |
90
+ | Pi Agent | `.pi/skills/` |
91
+ | Reasonix | `.reasonix/skills/` (no separate commands dir; slash commands built into the platform) |
61
92
  | Kilo / Antigravity / Windsurf | workflows + skills |
62
93
 
94
+ Every directory above is a deploy target for the four bundled skills. Each platform receives a full copy on `trellis init` and refresh on `trellis update`; nothing has to be wired by hand.
95
+
63
96
  ## Add A Project-Local Skill
64
97
 
65
- If the user wants to document team-private customizations, create a project-local skill, for example:
98
+ If the user wants to document team-private customizations, create a project-local skill — never put project-private content into a bundled skill directory, since `trellis update` will overwrite it.
66
99
 
67
100
  ```text
68
101
  .claude/skills/project-trellis-local/
69
102
  └── SKILL.md
70
103
  ```
71
104
 
72
- For multi-platform projects, add equivalent versions in each platform skill directory, or use `.agents/skills/` on platforms that support the shared layer.
105
+ For multi-platform projects, add equivalent versions in each platform skill directory, or use `.agents/skills/` on platforms that support the shared layer (Codex, Gemini CLI).
106
+
107
+ Pick a name that does **not** collide with the bundled set:
108
+
109
+ - `trellis-meta`
110
+ - `trellis-spec-bootstrap`
111
+ - `trellis-session-insight`
112
+ - `trellis-channel`
113
+
114
+ A reused name causes `getBundledSkillTemplates()` to overwrite the project-local copy on the next update. A common convention is to prefix the project name: `acme-trellis-deploy`, `acme-trellis-onboarding`.
73
115
 
74
116
  ## Notes
75
117
 
76
118
  - Do not mix every platform's syntax into one file.
77
119
  - Do not change only one platform entry point while claiming all platforms are supported.
78
120
  - Do not hide long-term engineering conventions inside a command; write them to `.trellis/spec/`.
121
+ - Do not hand-edit files inside `trellis-meta/`, `trellis-spec-bootstrap/`, `trellis-session-insight/`, or `trellis-channel/` under any `.{platform}/skills/` directory expecting the change to persist — they are bundled and refreshed by `trellis update`. Either contribute upstream or add a project-local skill that complements them.
122
+ - After `trellis update` reports a "modified by you" conflict on a bundled skill file, choose **keep** only if you accept maintaining the divergence by hand; otherwise accept the overwrite and re-apply the intent as a project-local skill.