@pennixrv/trellis 0.7.2-beta.10 → 0.7.2-beta.12
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.
- package/README.md +14 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +94 -96
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/teamwork/batch-reservation.d.ts.map +1 -1
- package/dist/commands/teamwork/batch-reservation.js +16 -8
- package/dist/commands/teamwork/batch-reservation.js.map +1 -1
- package/dist/commands/teamwork/batch.d.ts +1 -0
- package/dist/commands/teamwork/batch.d.ts.map +1 -1
- package/dist/commands/teamwork/batch.js +112 -1
- package/dist/commands/teamwork/batch.js.map +1 -1
- package/dist/commands/teamwork/coordinator.d.ts +3 -0
- package/dist/commands/teamwork/coordinator.d.ts.map +1 -1
- package/dist/commands/teamwork/coordinator.js +21 -3
- package/dist/commands/teamwork/coordinator.js.map +1 -1
- package/dist/commands/teamwork/foreground-wait.d.ts +4 -1
- package/dist/commands/teamwork/foreground-wait.d.ts.map +1 -1
- package/dist/commands/teamwork/foreground-wait.js +8 -1
- package/dist/commands/teamwork/foreground-wait.js.map +1 -1
- package/dist/commands/teamwork/index.d.ts.map +1 -1
- package/dist/commands/teamwork/index.js +1 -0
- package/dist/commands/teamwork/index.js.map +1 -1
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/update.js +34 -44
- package/dist/commands/update.js.map +1 -1
- package/dist/configurators/workflow.d.ts.map +1 -1
- package/dist/configurators/workflow.js +15 -52
- package/dist/configurators/workflow.js.map +1 -1
- package/dist/migrations/manifests/0.7.2-beta.11.json +9 -0
- package/dist/migrations/manifests/0.7.2-beta.12.json +9 -0
- package/dist/templates/claude/agents/trellis-implement.md +1 -1
- package/dist/templates/codebuddy/agents/trellis-implement.md +1 -1
- package/dist/templates/codex/hooks/session-start.py +10 -29
- package/dist/templates/common/bundled-skills/trellis-spec-bootstrap/references/spec-writing.md +6 -0
- package/dist/templates/common/bundled-skills/trellis-teamwork/SKILL.md +1 -1
- package/dist/templates/common/bundled-skills/trellis-teamwork/references/teammate-processes.md +21 -1
- package/dist/templates/common/bundled-skills/trellis-teamwork/references/teamwork-plan-construction.md +13 -2
- package/dist/templates/common/commands/continue.md +6 -0
- package/dist/templates/common/skills/before-dev.md +3 -1
- package/dist/templates/common/skills/check.md +3 -1
- package/dist/templates/copilot/hooks/session-start.py +10 -29
- package/dist/templates/cursor/agents/trellis-implement.md +1 -1
- package/dist/templates/droid/droids/trellis-implement.md +1 -1
- package/dist/templates/dsh/agents/trellis-implement.md +1 -1
- package/dist/templates/gemini/agents/trellis-implement.md +1 -1
- package/dist/templates/grok/agents/trellis-implement.md +1 -1
- package/dist/templates/kimi/agents/trellis-implement.md +1 -1
- package/dist/templates/kiro/agents/trellis-implement.json +1 -1
- package/dist/templates/markdown/agents.md +9 -0
- package/dist/templates/markdown/index.d.ts +1 -0
- package/dist/templates/markdown/index.d.ts.map +1 -1
- package/dist/templates/markdown/index.js +1 -0
- package/dist/templates/markdown/index.js.map +1 -1
- package/dist/templates/markdown/spec/index.md.txt +19 -0
- package/dist/templates/opencode/agents/trellis-implement.md +1 -1
- package/dist/templates/opencode/lib/session-utils.js +17 -5
- package/dist/templates/qoder/agents/trellis-implement.md +1 -1
- package/dist/templates/shared-hooks/guard-teamwork-wait.py +110 -12
- package/dist/templates/shared-hooks/session-start.py +7 -5
- package/dist/templates/snow/agents/trellis-implement.md +1 -1
- package/dist/templates/trae/agents/trellis-implement.md +1 -1
- package/dist/templates/trellis/scripts/common/packages_context.py +29 -1
- package/dist/templates/zcode/agents/trellis-implement.md +1 -1
- package/dist/utils/asset-backup.d.ts.map +1 -1
- package/dist/utils/asset-backup.js +22 -20
- package/dist/utils/asset-backup.js.map +1 -1
- package/dist/utils/file-writer.d.ts +2 -0
- package/dist/utils/file-writer.d.ts.map +1 -1
- package/dist/utils/file-writer.js +1 -1
- package/dist/utils/file-writer.js.map +1 -1
- package/dist/utils/managed-markdown.d.ts +5 -0
- package/dist/utils/managed-markdown.d.ts.map +1 -0
- package/dist/utils/managed-markdown.js +64 -0
- package/dist/utils/managed-markdown.js.map +1 -0
- package/dist/utils/managed-removal.d.ts +2 -0
- package/dist/utils/managed-removal.d.ts.map +1 -1
- package/dist/utils/managed-removal.js +26 -2
- package/dist/utils/managed-removal.js.map +1 -1
- package/dist/utils/manifest-prune.d.ts.map +1 -1
- package/dist/utils/manifest-prune.js +5 -12
- package/dist/utils/manifest-prune.js.map +1 -1
- package/dist/utils/uninstall-scrubbers.d.ts.map +1 -1
- package/dist/utils/uninstall-scrubbers.js +5 -11
- package/dist/utils/uninstall-scrubbers.js.map +1 -1
- package/package.json +2 -2
|
@@ -61,7 +61,7 @@ trellis teamwork context list <session> --scope global --thread <thread>
|
|
|
61
61
|
- Trellis teammates do not ask the user directly or require a user-question tool. Return missing input, limitations, unresolved choices or contract-valid blocked reports to the main agent; the main agent first resolves evidence and allocation before deciding whether a user choice is needed.
|
|
62
62
|
- `general`, `advisor`, and `committee` are coordination modes, independent from profiles, providers, `run`, batch execution, and forum sessions. Read project defaults with `teamwork config`; construct a frozen plan with `teamwork plan` and execute it with `teamwork batch --task <task-dir>`.
|
|
63
63
|
- For a managed batch, invoke one foreground `teamwork batch --json` command and wait for its receipt. The CLI owns FIFO admission, capacity, provider waits, retries, cancellation, report validation, and settlement; the main agent must not schedule per-assignment waits or retries.
|
|
64
|
-
- If the host yields that call, silently continue its original handle. Do not emit repetitive progress, query status, start unrelated work, or create another batch.
|
|
64
|
+
- If the host yields that call, silently continue its original handle. Do not emit repetitive progress, query unrelated status, start unrelated work, or create another batch. If the handle is unavailable, use `teamwork reconcile <original-plan> --task <task-dir> --wait 30` to observe that same batch read-only. A pending snapshot permits another bounded observation; a yielded observation continues its own handle. Neither path redispatches, extends the original deadline, releases capacity, or accepts reports. Codex's native projection and supported PreToolUse guard provide the recovery locator; they do not prevent model wake-ups or ordinary messages. After coordinator loss, use explicit native reconciliation and retain reservations until provider exit is proven.
|
|
65
65
|
- Agent/program callers must use `run --json`, `batch --json`, or `wait --json --from <worker>` for final results. Default run text and default wait events are compatibility/operator views. Read `execution`, every `reports[].validation` and content status, then perform semantic review; `done`, exit zero, `complete`, and `ALL_ACCEPTED` alone do not accept a task result. `semanticValidation: not_run` explicitly leaves that decision to the main agent.
|
|
66
66
|
- Tool permissions are automatically allowed; the default Codex launch has no sandbox. Source/Git, memory, and delegation boundaries are prompt obligations. Do not add tool/path permission gates or describe the role as technical isolation.
|
|
67
67
|
- Initialization carries common/professional rules and the mode-specific result contract. Task messages carry task data, acceptance and exact identity/path references. Context manifests may choose inline, required full reading, or on-demand references; reference text never becomes system instructions. ACP has user content only and cannot claim system priority.
|
package/dist/templates/common/bundled-skills/trellis-teamwork/references/teammate-processes.md
CHANGED
|
@@ -125,12 +125,32 @@ with `--confirm <preview-digest>` deletes those files; a changed preview or an
|
|
|
125
125
|
unresolved reservation is rejected. Read and accept needed evidence before
|
|
126
126
|
cleanup. Session removal alone does not delete task-owned attempt evidence.
|
|
127
127
|
|
|
128
|
+
For a managed batch whose original host handle is unavailable, use
|
|
129
|
+
`teamwork reconcile <original-plan> --task <task-dir> --wait 30`. The observation
|
|
130
|
+
budget is an integer from 1 to 60 seconds, not an extension of the batch deadline.
|
|
131
|
+
The JSON `mode: observe` result binds the original identity and deadline.
|
|
132
|
+
`outcome: pending` permits another bounded observation; `settled` contains the
|
|
133
|
+
durable receipt and the ordinary batch `result`, including report artifacts and
|
|
134
|
+
pending semantic review. A terminal transition without its receipt stays pending.
|
|
135
|
+
`reconciliation_required` directs explicit recovery; `blocked` describes missing
|
|
136
|
+
proof. Observation never launches a provider, acquires execution capacity, writes
|
|
137
|
+
coordination events, cancels the batch or accepts a report. Interrupting the
|
|
138
|
+
observer only ends observation. Resume its own continuation if the host yields;
|
|
139
|
+
if that handle is also lost, repeat the read-only observation. Do not search
|
|
140
|
+
private host histories, disable hooks, replay batch or manually edit projections
|
|
141
|
+
as the default recovery path. Old projections without locators still require the
|
|
142
|
+
original plan/task; unknown identities cannot be reconstructed automatically.
|
|
143
|
+
|
|
128
144
|
Use `teamwork reconcile <original-plan> --task <task-dir>` to preview recovery
|
|
129
145
|
after coordinator loss. `--execute --reason <disposition>` only settles when
|
|
130
146
|
native process-exit facts or process birth identity prove termination. A missing
|
|
131
147
|
PID, absent report, or dead coordinator alone is insufficient. This command
|
|
132
148
|
preserves accepted assignments and releases only the original batch's leases.
|
|
133
|
-
It does not restart providers or accept task results.
|
|
149
|
+
It does not restart providers or accept task results. When the original
|
|
150
|
+
reservation proves the coordinator has exited, preview can describe recovery
|
|
151
|
+
from RUNNING without writing a transition; explicit execute reuses the existing
|
|
152
|
+
reconciliation bridge. A live or unverifiable owner cannot be taken over.
|
|
153
|
+
`--wait` cannot be combined with execute, reason or unknown-exit confirmation.
|
|
134
154
|
|
|
135
155
|
After a durable failed settlement and explicit bounded retry approval, construct
|
|
136
156
|
`teamwork retry <original-plan> --task <task-dir> --output <new-plan> --batch <new-id>
|
|
@@ -96,6 +96,13 @@ closes admission, marks undispatched FIFO work `FINAL_FAILED`, then cancels and
|
|
|
96
96
|
drains active attempts. Confirmed outcomes settle as `SETTLED_WITH_FAILURE`;
|
|
97
97
|
unconfirmed process exit requires reconciliation.
|
|
98
98
|
|
|
99
|
+
If the host handle becomes unavailable, observe only that original frozen plan
|
|
100
|
+
with `trellis teamwork reconcile <plan> --task <task-dir> --wait 30`. This is
|
|
101
|
+
bounded read-only recovery, not another batch or a new execution deadline.
|
|
102
|
+
Only a verified durable receipt exposes a settled result; reports still need
|
|
103
|
+
main-agent review. Coordinator loss follows explicit reconciliation and never
|
|
104
|
+
proves provider termination by itself.
|
|
105
|
+
|
|
99
106
|
A valid `blocked` report with evidence ends only that assignment as
|
|
100
107
|
`FINAL_FAILED`; the CLI continues with the remaining FIFO work and preserves
|
|
101
108
|
the blocker report. Missing reports may use the assignment's declared retry
|
|
@@ -197,8 +204,12 @@ answer. Retention may remove failed-attempt artifacts. Main-agent semantic
|
|
|
197
204
|
review checks the answer and evidence against the acceptance criteria; shape
|
|
198
205
|
validation does not perform that review or change native task acceptance.
|
|
199
206
|
|
|
200
|
-
The coordinator returns `ALL_ACCEPTED`, `SETTLED_WITH_FAILURE`, or
|
|
201
|
-
`RECONCILIATION_REQUIRED`. For `
|
|
207
|
+
The coordinator returns `AWAITING_REVIEW`, `ALL_ACCEPTED`, `SETTLED_WITH_FAILURE`, or
|
|
208
|
+
`RECONCILIATION_REQUIRED`. For `AWAITING_REVIEW`, read every report and its
|
|
209
|
+
evidence, limitations and unresolved items, then use `trellis teamwork review`
|
|
210
|
+
with the exact task, batch and assignment identity (see `review --help`).
|
|
211
|
+
Accept or request rework through that native interface; do not edit receipts.
|
|
212
|
+
For `ALL_ACCEPTED`, review every accepted report
|
|
202
213
|
against the phase contract, record the evidence in the task-owned artifact, and
|
|
203
214
|
use the native task acceptance gate before advancing. For
|
|
204
215
|
`SETTLED_WITH_FAILURE`, review the failure reports and blockers, do not accept
|
|
@@ -12,6 +12,12 @@ Resume from the active Trellis task and its current phase. The task record and p
|
|
|
12
12
|
|
|
13
13
|
Follow the active phase breadcrumb to the matching bundled phase Skill and its workflow.md. Use the task CLI to inspect or change phase state. A resume does not itself accept an artifact, grant authorization, or move the task.
|
|
14
14
|
|
|
15
|
+
Without hook context, use `{{PYTHON_CMD}} ./.trellis/scripts/task.py phase show <task>`
|
|
16
|
+
and explicitly read the applicable spec indexes and guidelines. If the route is
|
|
17
|
+
missing, inspect recorded requirements and authorization, choose the ordered
|
|
18
|
+
phases with evidence for omissions, then initialize through the native CLI.
|
|
19
|
+
Reuse existing confirmations; resume only the known unfinished action.
|
|
20
|
+
|
|
15
21
|
Task lifecycle status and business phase are separate. A planning task may remain in Goal Exploration and Requirements Confirmation Phase, Decision Space Construction and Consolidation Phase, or Solution Design and Convergence Phase. `in_progress` marks authorized Task Implementation and Test Verification Phase; `completed` and `cancelled` are terminal lifecycle states. Delivery Review and On-Site Closeout Phase remains explicit.
|
|
16
22
|
|
|
17
23
|
## Phase operations
|
|
@@ -14,7 +14,9 @@ Execute these steps:
|
|
|
14
14
|
- What type of work (backend, frontend, unit-test, docs, etc.)
|
|
15
15
|
- Any spec/research paths referenced by the task artifacts
|
|
16
16
|
|
|
17
|
-
4. **Read the spec index
|
|
17
|
+
4. **Read the available spec indexes**: `.trellis/spec/index.md`, then
|
|
18
|
+
`.trellis/spec/<package>/index.md` for the affected configured packages,
|
|
19
|
+
and existing layer indexes where applicable. Older projects need no migration:
|
|
18
20
|
```bash
|
|
19
21
|
cat .trellis/spec/<package>/<layer>/index.md
|
|
20
22
|
```
|
|
@@ -19,7 +19,9 @@ Read the current native phase, accepted contract and its actual artifact referen
|
|
|
19
19
|
python3 ./.trellis/scripts/get_context.py --mode packages
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
Read the available `.trellis/spec/index.md`, affected configured package
|
|
23
|
+
indexes (`.trellis/spec/<package>/index.md`), and existing layer indexes.
|
|
24
|
+
Follow their **Quality Check** sections; older projects need no migration:
|
|
23
25
|
|
|
24
26
|
```bash
|
|
25
27
|
cat .trellis/spec/<package>/<layer>/index.md
|
|
@@ -267,9 +267,9 @@ def _get_task_status(trellis_dir: Path, hook_input: dict) -> str:
|
|
|
267
267
|
if task_status == "planning":
|
|
268
268
|
next_action = (
|
|
269
269
|
"Follow the current per-turn workflow-state. Task lifecycle status and artifact presence "
|
|
270
|
-
"do not identify the business phase. If no phase route is initialized,
|
|
271
|
-
"
|
|
272
|
-
"
|
|
270
|
+
"do not identify the business phase. If no phase route is initialized, inspect recorded "
|
|
271
|
+
"requirements and authorization, choose applicable ordered phases with evidence for omissions, "
|
|
272
|
+
"then initialize through Trellis CLI and load the current phase Skill. Reuse valid confirmations."
|
|
273
273
|
)
|
|
274
274
|
if any(
|
|
275
275
|
path.is_file() and not _has_curated_jsonl_entry(path)
|
|
@@ -324,31 +324,12 @@ def _repo_relative(repo_root: Path, path: Path) -> str:
|
|
|
324
324
|
return str(path)
|
|
325
325
|
|
|
326
326
|
|
|
327
|
-
def _collect_spec_index_paths(trellis_dir: Path) -> list[str]:
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
spec_dir = trellis_dir / "spec"
|
|
334
|
-
if not spec_dir.is_dir():
|
|
335
|
-
return paths
|
|
336
|
-
|
|
337
|
-
for sub in sorted(spec_dir.iterdir()):
|
|
338
|
-
if not sub.is_dir() or sub.name.startswith(".") or sub.name == "guides":
|
|
339
|
-
continue
|
|
340
|
-
index_file = sub / "index.md"
|
|
341
|
-
if index_file.is_file():
|
|
342
|
-
paths.append(f".trellis/spec/{sub.name}/index.md")
|
|
343
|
-
continue
|
|
344
|
-
for nested in sorted(sub.iterdir()):
|
|
345
|
-
if not nested.is_dir():
|
|
346
|
-
continue
|
|
347
|
-
nested_index = nested / "index.md"
|
|
348
|
-
if nested_index.is_file():
|
|
349
|
-
paths.append(f".trellis/spec/{sub.name}/{nested.name}/index.md")
|
|
350
|
-
|
|
351
|
-
return paths
|
|
327
|
+
def _collect_spec_index_paths(trellis_dir: Path, input_data: dict | None = None) -> list[str]:
|
|
328
|
+
scripts = str(trellis_dir / "scripts")
|
|
329
|
+
if scripts not in sys.path:
|
|
330
|
+
sys.path.insert(0, scripts)
|
|
331
|
+
from common.packages_context import collect_spec_index_paths # type: ignore[import-not-found]
|
|
332
|
+
return collect_spec_index_paths(trellis_dir.parent, input_data, platform="copilot")
|
|
352
333
|
|
|
353
334
|
|
|
354
335
|
def _build_compact_current_state(
|
|
@@ -514,7 +495,7 @@ def main() -> None:
|
|
|
514
495
|
configure_project_encoding(project_dir)
|
|
515
496
|
|
|
516
497
|
trellis_dir = project_dir / ".trellis"
|
|
517
|
-
spec_index_paths = _collect_spec_index_paths(trellis_dir)
|
|
498
|
+
spec_index_paths = _collect_spec_index_paths(trellis_dir, hook_input)
|
|
518
499
|
|
|
519
500
|
output = StringIO()
|
|
520
501
|
|
|
@@ -55,7 +55,7 @@ Before implementing, read:
|
|
|
55
55
|
|
|
56
56
|
Read relevant specs based on task type:
|
|
57
57
|
|
|
58
|
-
-
|
|
58
|
+
- Read available spec indexes: `.trellis/spec/index.md`, `.trellis/spec/<package>/index.md`, and existing `.trellis/spec/<package>/<layer>/index.md` (legacy single-repo layers remain valid).
|
|
59
59
|
- Shared guides: `.trellis/spec/guides/`
|
|
60
60
|
|
|
61
61
|
### 2. Understand Requirements
|
|
@@ -48,7 +48,7 @@ Before implementing, read:
|
|
|
48
48
|
|
|
49
49
|
Read relevant specs based on task type:
|
|
50
50
|
|
|
51
|
-
-
|
|
51
|
+
- Read available spec indexes: `.trellis/spec/index.md`, `.trellis/spec/<package>/index.md`, and existing `.trellis/spec/<package>/<layer>/index.md` (legacy single-repo layers remain valid).
|
|
52
52
|
- Shared guides: `.trellis/spec/guides/`
|
|
53
53
|
|
|
54
54
|
### 2. Understand Requirements
|
|
@@ -52,7 +52,7 @@ Before implementing, read:
|
|
|
52
52
|
|
|
53
53
|
Read relevant specs based on task type:
|
|
54
54
|
|
|
55
|
-
-
|
|
55
|
+
- Read available spec indexes: `.trellis/spec/index.md`, `.trellis/spec/<package>/index.md`, and existing `.trellis/spec/<package>/<layer>/index.md` (legacy single-repo layers remain valid).
|
|
56
56
|
- Shared guides: `.trellis/spec/guides/`
|
|
57
57
|
|
|
58
58
|
### 2. Understand Requirements
|
|
@@ -48,7 +48,7 @@ Before implementing, read:
|
|
|
48
48
|
|
|
49
49
|
Read relevant specs based on task type:
|
|
50
50
|
|
|
51
|
-
-
|
|
51
|
+
- Read available spec indexes: `.trellis/spec/index.md`, `.trellis/spec/<package>/index.md`, and existing `.trellis/spec/<package>/<layer>/index.md` (legacy single-repo layers remain valid).
|
|
52
52
|
- Shared guides: `.trellis/spec/guides/`
|
|
53
53
|
|
|
54
54
|
### 2. Understand Requirements
|
|
@@ -62,7 +62,7 @@ Before implementing, read:
|
|
|
62
62
|
|
|
63
63
|
Read relevant specs based on task type:
|
|
64
64
|
|
|
65
|
-
-
|
|
65
|
+
- Read available spec indexes: `.trellis/spec/index.md`, `.trellis/spec/<package>/index.md`, and existing `.trellis/spec/<package>/<layer>/index.md` (legacy single-repo layers remain valid).
|
|
66
66
|
- Shared guides: `.trellis/spec/guides/`
|
|
67
67
|
|
|
68
68
|
### 2. Understand Requirements
|
|
@@ -61,7 +61,7 @@ Before implementing, read:
|
|
|
61
61
|
|
|
62
62
|
Read relevant specs based on task type:
|
|
63
63
|
|
|
64
|
-
-
|
|
64
|
+
- Read available spec indexes: `.trellis/spec/index.md`, `.trellis/spec/<package>/index.md`, and existing `.trellis/spec/<package>/<layer>/index.md` (legacy single-repo layers remain valid).
|
|
65
65
|
- Shared guides: `.trellis/spec/guides/`
|
|
66
66
|
|
|
67
67
|
### 2. Understand Requirements
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "trellis-implement",
|
|
3
3
|
"description": "Code implementation expert. Understands specs and requirements, then implements features. No git commit allowed.",
|
|
4
|
-
"prompt": "# Implement Agent\n\nYou are the Implement Agent in the Trellis workflow.\n\n## Recursion Guard\n\nYou are already the `trellis-implement` sub-agent that the main session dispatched. Do the implementation work directly.\n\n- Do NOT spawn another `trellis-implement` or `trellis-check` sub-agent.\n- If SessionStart context, workflow-state breadcrumbs, or workflow.md say to dispatch `trellis-implement` / `trellis-check`, treat that as a main-session instruction that is already satisfied by your current role.\n- Only the main session may dispatch Trellis implement/check agents. If more parallel work is needed, report that recommendation instead of spawning.\n\n## Trellis Context Loading Protocol\n\nLook for the `<!-- trellis-hook-injected -->` marker in your input above.\n\n- **If the marker is present**: prd / spec / research files have already been auto-loaded for you above. Proceed with the implementation work directly.\n- **If the marker is absent**: hook injection didn't fire (Windows + Claude Code, `--continue` resume, fork distribution, hooks disabled, etc.). Find the active task path from your dispatch prompt's first line `Active task: <path>`, then Read `<task-path>/implement.jsonl`, each listed file, `<task-path>/prd.md`, `<task-path>/design.md` if present, and `<task-path>/implement.md` if present before doing the work.\n\n## Context\n\nBefore implementing, read:\n- `.trellis/workflow.md` - Project workflow\n- `.trellis/spec/` - Development guidelines\n- Task `prd.md` - Requirements document\n- Task `design.md` - Technical design (if exists)\n- Task `implement.md` - Execution plan (if exists)\n\n## Core Responsibilities\n\n1. **Understand specs** - Read relevant spec files in `.trellis/spec/`\n2. **Understand task artifacts** - Read prd.md, design.md if present, and implement.md if present\n3. **Implement features** - Write code following specs and task artifacts\n4. **Self-check** - Ensure code quality\n5. **Report results** - Report completion status\n\n## Forbidden Operations\n\n**Do NOT execute these git commands:**\n\n- `git commit`\n- `git push`\n- `git merge`\n\n---\n\n## Workflow\n\n### 1. Understand Specs\n\nRead relevant specs based on task type:\n\n-
|
|
4
|
+
"prompt": "# Implement Agent\n\nYou are the Implement Agent in the Trellis workflow.\n\n## Recursion Guard\n\nYou are already the `trellis-implement` sub-agent that the main session dispatched. Do the implementation work directly.\n\n- Do NOT spawn another `trellis-implement` or `trellis-check` sub-agent.\n- If SessionStart context, workflow-state breadcrumbs, or workflow.md say to dispatch `trellis-implement` / `trellis-check`, treat that as a main-session instruction that is already satisfied by your current role.\n- Only the main session may dispatch Trellis implement/check agents. If more parallel work is needed, report that recommendation instead of spawning.\n\n## Trellis Context Loading Protocol\n\nLook for the `<!-- trellis-hook-injected -->` marker in your input above.\n\n- **If the marker is present**: prd / spec / research files have already been auto-loaded for you above. Proceed with the implementation work directly.\n- **If the marker is absent**: hook injection didn't fire (Windows + Claude Code, `--continue` resume, fork distribution, hooks disabled, etc.). Find the active task path from your dispatch prompt's first line `Active task: <path>`, then Read `<task-path>/implement.jsonl`, each listed file, `<task-path>/prd.md`, `<task-path>/design.md` if present, and `<task-path>/implement.md` if present before doing the work.\n\n## Context\n\nBefore implementing, read:\n- `.trellis/workflow.md` - Project workflow\n- `.trellis/spec/` - Development guidelines\n- Task `prd.md` - Requirements document\n- Task `design.md` - Technical design (if exists)\n- Task `implement.md` - Execution plan (if exists)\n\n## Core Responsibilities\n\n1. **Understand specs** - Read relevant spec files in `.trellis/spec/`\n2. **Understand task artifacts** - Read prd.md, design.md if present, and implement.md if present\n3. **Implement features** - Write code following specs and task artifacts\n4. **Self-check** - Ensure code quality\n5. **Report results** - Report completion status\n\n## Forbidden Operations\n\n**Do NOT execute these git commands:**\n\n- `git commit`\n- `git push`\n- `git merge`\n\n---\n\n## Workflow\n\n### 1. Understand Specs\n\nRead relevant specs based on task type:\n\n- Read available spec indexes: `.trellis/spec/index.md`, `.trellis/spec/<package>/index.md`, and existing `.trellis/spec/<package>/<layer>/index.md` (legacy single-repo layers remain valid).\n- Shared guides: `.trellis/spec/guides/`\n\n### 2. Understand Requirements\n\nRead the task's prd.md, design.md if present, and implement.md if present:\n\n- What are the core requirements\n- Key points of technical design\n- Implementation order, validation commands, and rollback points\n\n### 3. Implement Features\n\n- Write code following specs and task artifacts\n- Follow existing code patterns\n- Only do what's required, no over-engineering\n\n### 4. Verify\n\nRun project's lint and typecheck commands to verify changes.\n\n---\n\n## Report Format\n\n```markdown\n## Implementation Complete\n\n### Files Modified\n\n- `src/components/Feature.tsx` - New component\n- `src/hooks/useFeature.ts` - New hook\n\n### Implementation Summary\n\n1. Created Feature component...\n2. Added useFeature hook...\n\n### Verification Results\n\n- Lint: Passed\n- TypeCheck: Passed\n```\n\n---\n\n## Code Standards\n\n- Follow existing code patterns\n- Don't add unnecessary abstractions\n- Only do what's required, no over-engineering\n- Keep code readable",
|
|
5
5
|
"tools": [
|
|
6
6
|
"read",
|
|
7
7
|
"write",
|
|
@@ -3,6 +3,15 @@
|
|
|
3
3
|
|
|
4
4
|
These instructions are for AI assistants working in this project.
|
|
5
5
|
|
|
6
|
+
For a new session use `trellis-start`; for existing work use `trellis-continue`
|
|
7
|
+
and resume the known unfinished action. Read `.trellis/workflow.md` for the
|
|
8
|
+
native route and ownership rules. Task CLI owns task and phase state; specs
|
|
9
|
+
describe engineering conventions, not implementation authorization.
|
|
10
|
+
|
|
11
|
+
Without hook context, run `python3 ./.trellis/scripts/get_context.py --mode phase`
|
|
12
|
+
and `python3 ./.trellis/scripts/task.py phase show <task>`, then explicitly read
|
|
13
|
+
the applicable spec indexes and their referenced guidelines.
|
|
14
|
+
|
|
6
15
|
This project is managed by Trellis. The working knowledge you need lives under `.trellis/`:
|
|
7
16
|
|
|
8
17
|
- `.trellis/workflow.md` — development phases, when to create tasks, skill routing
|
|
@@ -8,6 +8,7 @@ export declare const agentsMdContent: string;
|
|
|
8
8
|
export declare const workspaceIndexContent: string;
|
|
9
9
|
export declare const agentProgressIndexContent: string;
|
|
10
10
|
export declare const workflowGitignoreContent: string;
|
|
11
|
+
export declare const specIndexContent: string;
|
|
11
12
|
export declare const backendIndexContent: string;
|
|
12
13
|
export declare const backendDirectoryStructureContent: string;
|
|
13
14
|
export declare const backendDatabaseGuidelinesContent: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/templates/markdown/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAqBH,eAAO,MAAM,eAAe,EAAE,MAAuC,CAAC;AAGtE,eAAO,MAAM,qBAAqB,EAAE,MACK,CAAC;AAG1C,eAAO,MAAM,yBAAyB,QAAwB,CAAC;AAG/D,eAAO,MAAM,wBAAwB,EAAE,MACH,CAAC;AAQrC,eAAO,MAAM,mBAAmB,EAAE,MAEjC,CAAC;AACF,eAAO,MAAM,gCAAgC,EAAE,MAE9C,CAAC;AACF,eAAO,MAAM,gCAAgC,EAAE,MAE9C,CAAC;AACF,eAAO,MAAM,+BAA+B,EAAE,MAE7C,CAAC;AACF,eAAO,MAAM,+BAA+B,EAAE,MAE7C,CAAC;AACF,eAAO,MAAM,2BAA2B,EAAE,MAEzC,CAAC;AAGF,eAAO,MAAM,oBAAoB,EAAE,MAElC,CAAC;AACF,eAAO,MAAM,iCAAiC,EAAE,MAE/C,CAAC;AACF,eAAO,MAAM,yBAAyB,EAAE,MAEvC,CAAC;AAC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kBAAkB,EAAE,MAEhC,CAAC;AACF,eAAO,MAAM,oCAAoC,EAAE,MAElD,CAAC;AACF,eAAO,MAAM,mCAAmC,EAAE,MAEjD,CAAC"}
|
|
@@ -31,6 +31,7 @@ export const workflowGitignoreContent = readLocalTemplate("gitignore.txt");
|
|
|
31
31
|
// These are NOT dogfooded - they are generic templates for new projects
|
|
32
32
|
// =============================================================================
|
|
33
33
|
// Backend structure (multi-doc format)
|
|
34
|
+
export const specIndexContent = readLocalTemplate("spec/index.md.txt");
|
|
34
35
|
export const backendIndexContent = readLocalTemplate("spec/backend/index.md.txt");
|
|
35
36
|
export const backendDirectoryStructureContent = readLocalTemplate("spec/backend/directory-structure.md.txt");
|
|
36
37
|
export const backendDatabaseGuidelinesContent = readLocalTemplate("spec/backend/database-guidelines.md.txt");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/templates/markdown/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAEtC;;GAEG;AACH,SAAS,iBAAiB,CAAC,QAAgB;IACzC,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAC3C,OAAO,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AACzC,CAAC;AAED,gFAAgF;AAChF,8BAA8B;AAC9B,gFAAgF;AAEhF,MAAM,CAAC,MAAM,eAAe,GAAW,iBAAiB,CAAC,WAAW,CAAC,CAAC;AAEtE,oDAAoD;AACpD,MA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,CAChD,CAAC;AACF,MAAM,CAAC,MAAM,mCAAmC,GAAW,iBAAiB,CAC1E,8CAA8C,CAC/C,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Project Development Guidelines
|
|
2
|
+
|
|
3
|
+
This index navigates the project's verified engineering conventions. Use
|
|
4
|
+
`trellis-spec-bootstrap` to establish relevant topics from source, tests and
|
|
5
|
+
existing project rules. No domain or layer is required by default.
|
|
6
|
+
|
|
7
|
+
## Pre-Development Checklist
|
|
8
|
+
|
|
9
|
+
Read this index, the applicable package index (when configured), and the topic
|
|
10
|
+
guidelines for the code you will change. Read the shared `guides/index.md` at
|
|
11
|
+
the spec root. Follow existing layer indexes in projects that use them.
|
|
12
|
+
|
|
13
|
+
## Quality Check
|
|
14
|
+
|
|
15
|
+
Review the change against the applicable guidelines and run the checks they
|
|
16
|
+
require. Record actual results and any unavailable verification.
|
|
17
|
+
|
|
18
|
+
Add links to real topic guidelines here as the project establishes them. For
|
|
19
|
+
an empty project, leave conventions pending until implementation supplies evidence.
|
|
@@ -63,7 +63,7 @@ Before implementing, read:
|
|
|
63
63
|
|
|
64
64
|
Read relevant specs based on task type:
|
|
65
65
|
|
|
66
|
-
-
|
|
66
|
+
- Read available spec indexes: `.trellis/spec/index.md`, `.trellis/spec/<package>/index.md`, and existing `.trellis/spec/<package>/<layer>/index.md` (legacy single-repo layers remain valid).
|
|
67
67
|
- Shared guides: `.trellis/spec/guides/`
|
|
68
68
|
- Guides: `.trellis/spec/guides/`
|
|
69
69
|
|
|
@@ -100,7 +100,7 @@ function getTaskStatus(ctx, platformInput = null) {
|
|
|
100
100
|
if (taskStatus === "planning") {
|
|
101
101
|
const nextBits = [
|
|
102
102
|
"Follow the current per-turn workflow-state; task lifecycle status and artifact presence do not identify the business phase",
|
|
103
|
-
"If no phase route is initialized,
|
|
103
|
+
"If no phase route is initialized, inspect recorded requirements and authorization, choose applicable ordered phases with evidence for omissions, then initialize through Trellis CLI and load the current phase Skill; reuse valid confirmations",
|
|
104
104
|
];
|
|
105
105
|
if (!jsonlReady) {
|
|
106
106
|
nextBits.push(
|
|
@@ -248,7 +248,7 @@ function resolveSpecScope(config) {
|
|
|
248
248
|
return null;
|
|
249
249
|
}
|
|
250
250
|
|
|
251
|
-
function collectSpecIndexPaths(directory, allowedPkgs) {
|
|
251
|
+
function collectSpecIndexPaths(directory, allowedPkgs, packageNames) {
|
|
252
252
|
const specDir = join(directory, ".trellis", "spec");
|
|
253
253
|
const paths = [];
|
|
254
254
|
|
|
@@ -258,6 +258,8 @@ function collectSpecIndexPaths(directory, allowedPkgs) {
|
|
|
258
258
|
}
|
|
259
259
|
|
|
260
260
|
if (!existsSync(specDir)) return paths;
|
|
261
|
+
if (existsSync(join(specDir, "index.md")))
|
|
262
|
+
paths.unshift(".trellis/spec/index.md");
|
|
261
263
|
|
|
262
264
|
try {
|
|
263
265
|
const subs = readdirSync(specDir)
|
|
@@ -272,11 +274,17 @@ function collectSpecIndexPaths(directory, allowedPkgs) {
|
|
|
272
274
|
.sort();
|
|
273
275
|
|
|
274
276
|
for (const sub of subs) {
|
|
277
|
+
if (
|
|
278
|
+
packageNames.has(sub) &&
|
|
279
|
+
allowedPkgs !== null &&
|
|
280
|
+
!allowedPkgs.has(sub)
|
|
281
|
+
)
|
|
282
|
+
continue;
|
|
275
283
|
const indexFile = join(specDir, sub, "index.md");
|
|
276
284
|
if (existsSync(indexFile)) {
|
|
277
285
|
paths.push(`.trellis/spec/${sub}/index.md`);
|
|
278
|
-
}
|
|
279
|
-
|
|
286
|
+
}
|
|
287
|
+
{
|
|
280
288
|
try {
|
|
281
289
|
const nested = readdirSync(join(specDir, sub))
|
|
282
290
|
.filter((name) => {
|
|
@@ -433,7 +441,11 @@ export function buildSessionContext(ctx, platformInput = null) {
|
|
|
433
441
|
|
|
434
442
|
const config = loadTrellisConfig(directory, contextKey);
|
|
435
443
|
const allowedPkgs = resolveSpecScope(config);
|
|
436
|
-
const paths = collectSpecIndexPaths(
|
|
444
|
+
const paths = collectSpecIndexPaths(
|
|
445
|
+
directory,
|
|
446
|
+
allowedPkgs,
|
|
447
|
+
new Set(Object.keys(config.packages)),
|
|
448
|
+
);
|
|
437
449
|
|
|
438
450
|
const parts = [];
|
|
439
451
|
|
|
@@ -49,7 +49,7 @@ Before implementing, read:
|
|
|
49
49
|
|
|
50
50
|
Read relevant specs based on task type:
|
|
51
51
|
|
|
52
|
-
-
|
|
52
|
+
- Read available spec indexes: `.trellis/spec/index.md`, `.trellis/spec/<package>/index.md`, and existing `.trellis/spec/<package>/<layer>/index.md` (legacy single-repo layers remain valid).
|
|
53
53
|
- Shared guides: `.trellis/spec/guides/`
|
|
54
54
|
|
|
55
55
|
### 2. Understand Requirements
|
|
@@ -7,13 +7,73 @@ that the host does not expose to PreToolUse remain Skill obligations.
|
|
|
7
7
|
from __future__ import annotations
|
|
8
8
|
|
|
9
9
|
import hashlib
|
|
10
|
+
import itertools
|
|
10
11
|
import json
|
|
11
12
|
import os
|
|
12
13
|
import shlex
|
|
14
|
+
import stat
|
|
13
15
|
import sys
|
|
14
16
|
from pathlib import Path
|
|
15
17
|
|
|
16
18
|
|
|
19
|
+
def safe_path(value: str, root: Path) -> Path:
|
|
20
|
+
candidate = Path(os.path.abspath(root / value))
|
|
21
|
+
parts = candidate.relative_to(root).parts
|
|
22
|
+
current = root
|
|
23
|
+
for part in parts:
|
|
24
|
+
current = current / part
|
|
25
|
+
if current.is_symlink():
|
|
26
|
+
raise ValueError("symlink in recovery path")
|
|
27
|
+
return candidate
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def read_record(file: Path, limit: int) -> dict:
|
|
31
|
+
info = file.lstat()
|
|
32
|
+
if not stat.S_ISREG(info.st_mode) or info.st_size > limit:
|
|
33
|
+
raise ValueError("invalid recovery file")
|
|
34
|
+
value = json.loads(file.read_text(encoding="utf-8"))
|
|
35
|
+
if not isinstance(value, dict):
|
|
36
|
+
raise ValueError("invalid recovery object")
|
|
37
|
+
return value
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def recovery_arguments(command: str) -> tuple[str, str] | None:
|
|
41
|
+
if any(character in command for character in "$`;\n\r&|<>"):
|
|
42
|
+
return None
|
|
43
|
+
argv = shlex.split(command)
|
|
44
|
+
if argv[:3] != ["trellis", "teamwork", "reconcile"] or len(argv) < 6:
|
|
45
|
+
return None
|
|
46
|
+
plan = argv[3]
|
|
47
|
+
options: dict[str, str | bool] = {}
|
|
48
|
+
index = 4
|
|
49
|
+
while index < len(argv):
|
|
50
|
+
name = argv[index]
|
|
51
|
+
if name in options:
|
|
52
|
+
return None
|
|
53
|
+
if name in {"--execute", "--confirm-unknown-process-exit"}:
|
|
54
|
+
options[name] = True
|
|
55
|
+
elif name in {"--task", "--wait", "--reason"} and index + 1 < len(argv):
|
|
56
|
+
index += 1
|
|
57
|
+
options[name] = argv[index]
|
|
58
|
+
else:
|
|
59
|
+
return None
|
|
60
|
+
index += 1
|
|
61
|
+
task = options.get("--task")
|
|
62
|
+
if not isinstance(task, str):
|
|
63
|
+
return None
|
|
64
|
+
if "--wait" in options:
|
|
65
|
+
seconds = options["--wait"]
|
|
66
|
+
if not isinstance(seconds, str) or len(seconds) > 2 or not seconds.isascii() or not seconds.isdecimal() or str(int(seconds)) != seconds or not 1 <= int(seconds) <= 60:
|
|
67
|
+
return None
|
|
68
|
+
if any(name in options for name in {"--execute", "--reason", "--confirm-unknown-process-exit"}):
|
|
69
|
+
return None
|
|
70
|
+
if "--confirm-unknown-process-exit" in options and "--execute" not in options:
|
|
71
|
+
return None
|
|
72
|
+
if "--execute" in options and not str(options.get("--reason", "")).strip():
|
|
73
|
+
return None
|
|
74
|
+
return plan, task
|
|
75
|
+
|
|
76
|
+
|
|
17
77
|
def decision(payload: dict) -> dict | None:
|
|
18
78
|
if not isinstance(payload, dict):
|
|
19
79
|
return None
|
|
@@ -26,14 +86,41 @@ def decision(payload: dict) -> dict | None:
|
|
|
26
86
|
while not (root / ".trellis").is_dir() and root != root.parent:
|
|
27
87
|
root = root.parent
|
|
28
88
|
directory = root / ".trellis/.runtime/teamwork-waits" / hashlib.sha256(session.encode()).hexdigest()
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
89
|
+
unsafe_directory = False
|
|
90
|
+
records: list[Path] = []
|
|
91
|
+
try:
|
|
92
|
+
safe_path(str(directory), root)
|
|
93
|
+
if directory.exists():
|
|
94
|
+
records = list(itertools.islice(directory.glob("*.json"), 65))
|
|
95
|
+
if len(records) > 64:
|
|
96
|
+
unsafe_directory = True
|
|
97
|
+
records = []
|
|
98
|
+
except (OSError, ValueError):
|
|
99
|
+
unsafe_directory = True
|
|
100
|
+
if not records and not unsafe_directory:
|
|
33
101
|
return None
|
|
102
|
+
states: list[dict] = []
|
|
103
|
+
hints: list[str] = []
|
|
34
104
|
for record in records:
|
|
35
105
|
try:
|
|
36
|
-
|
|
106
|
+
safe_path(str(record), root)
|
|
107
|
+
state = read_record(record, 4096)
|
|
108
|
+
if state.get("schemaVersion") != 1 or state.get("state") != "waiting":
|
|
109
|
+
raise ValueError("unsupported foreground projection")
|
|
110
|
+
session_id, batch_id, plan_hash = (state.get(key) for key in ("sessionId", "batchId", "planHash"))
|
|
111
|
+
if not all(isinstance(value, str) and value for value in (session_id, batch_id, plan_hash)):
|
|
112
|
+
raise ValueError("missing frozen identity")
|
|
113
|
+
if not isinstance(plan_hash, str) or len(plan_hash) != 64 or any(character not in "0123456789abcdef" for character in plan_hash):
|
|
114
|
+
raise ValueError("invalid frozen hash")
|
|
115
|
+
if type(state.get("ownerPid")) is not int or state["ownerPid"] <= 0:
|
|
116
|
+
raise ValueError("invalid owner pid")
|
|
117
|
+
if record.name != hashlib.sha256(f"{session_id}:{batch_id}".encode()).hexdigest() + ".json":
|
|
118
|
+
raise ValueError("projection filename identity mismatch")
|
|
119
|
+
states.append(state)
|
|
120
|
+
if isinstance(state.get("planPath"), str) and isinstance(state.get("taskRoot"), str):
|
|
121
|
+
plan_path = safe_path(state["planPath"], root)
|
|
122
|
+
task_path = safe_path(state["taskRoot"], root)
|
|
123
|
+
hints.append(f"trellis teamwork reconcile {shlex.quote(str(plan_path))} --task {shlex.quote(str(task_path))} --wait 30")
|
|
37
124
|
except (OSError, ValueError, TypeError):
|
|
38
125
|
continue
|
|
39
126
|
tool = str(payload.get("tool_name", "")).rsplit(".", 1)[-1]
|
|
@@ -42,14 +129,25 @@ def decision(payload: dict) -> dict | None:
|
|
|
42
129
|
tool_input = payload.get("tool_input")
|
|
43
130
|
tool_input = tool_input if isinstance(tool_input, dict) else {}
|
|
44
131
|
command = tool_input.get("command", tool_input.get("cmd"))
|
|
45
|
-
if isinstance(command, str)
|
|
132
|
+
if isinstance(command, str):
|
|
46
133
|
try:
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
134
|
+
arguments = recovery_arguments(command)
|
|
135
|
+
if arguments:
|
|
136
|
+
plan_path, task_path = (safe_path(value, root) for value in arguments)
|
|
137
|
+
task_path.relative_to(root / ".trellis" / "tasks")
|
|
138
|
+
plan_path.relative_to(task_path)
|
|
139
|
+
plan = read_record(plan_path, 2097152)
|
|
140
|
+
if not task_path.is_dir():
|
|
141
|
+
raise ValueError("missing owning task")
|
|
142
|
+
matches = [state for state in states if state["sessionId"] == plan.get("session_id") and state["batchId"] == plan.get("batch_id") and state["planHash"] == plan.get("plan_hash")]
|
|
143
|
+
if len(matches) == 1:
|
|
144
|
+
state = matches[0]
|
|
145
|
+
if ("planPath" not in state or safe_path(state["planPath"], root) == plan_path) and ("taskRoot" not in state or safe_path(state["taskRoot"], root) == task_path):
|
|
146
|
+
return None
|
|
147
|
+
except (OSError, ValueError, TypeError):
|
|
148
|
+
pass
|
|
149
|
+
hint = " Recovery: " + " | ".join(hints) if hints else " Recovery locator missing or invalid; supply the original frozen plan and task to native reconcile."
|
|
150
|
+
return {"hookSpecificOutput": {"hookEventName": "PreToolUse", "permissionDecision": "deny", "permissionDecisionReason": "Trellis owns an outstanding foreground batch. Continue or interrupt the original host wait handle. If unavailable, observe that same batch with native reconcile --wait; do not redispatch or take over FIFO. Dead coordinators require explicit reconciliation and verified provider exit." + hint}}
|
|
53
151
|
|
|
54
152
|
|
|
55
153
|
if __name__ == "__main__":
|
|
@@ -472,7 +472,7 @@ def _get_task_status(trellis_dir: Path, input_data: dict) -> str:
|
|
|
472
472
|
if task_status == "planning":
|
|
473
473
|
next_bits = [
|
|
474
474
|
"Follow the current per-turn workflow-state; task lifecycle status and artifact presence do not identify the business phase",
|
|
475
|
-
"If no phase route is initialized,
|
|
475
|
+
"If no phase route is initialized, inspect recorded requirements and existing authorization, choose applicable ordered phases with evidence for omissions, then initialize through Trellis CLI and load the current phase Skill; do not repeat valid confirmations",
|
|
476
476
|
]
|
|
477
477
|
if not jsonl_ready:
|
|
478
478
|
next_bits.append("curate task context manifests only when a dispatched agent needs them")
|
|
@@ -639,7 +639,7 @@ def _resolve_spec_scope(
|
|
|
639
639
|
return None # Unknown scope type: full scan
|
|
640
640
|
|
|
641
641
|
|
|
642
|
-
def _collect_spec_index_paths(trellis_dir: Path, allowed_pkgs: set | None) -> list[str]:
|
|
642
|
+
def _collect_spec_index_paths(trellis_dir: Path, allowed_pkgs: set | None, package_names: set | None = None) -> list[str]:
|
|
643
643
|
paths: list[str] = []
|
|
644
644
|
guides_index = trellis_dir / "spec" / "guides" / "index.md"
|
|
645
645
|
if guides_index.is_file():
|
|
@@ -648,16 +648,18 @@ def _collect_spec_index_paths(trellis_dir: Path, allowed_pkgs: set | None) -> li
|
|
|
648
648
|
spec_dir = trellis_dir / "spec"
|
|
649
649
|
if not spec_dir.is_dir():
|
|
650
650
|
return paths
|
|
651
|
+
if (spec_dir / "index.md").is_file():
|
|
652
|
+
paths.insert(0, ".trellis/spec/index.md")
|
|
651
653
|
|
|
652
654
|
for sub in sorted(spec_dir.iterdir()):
|
|
653
655
|
if not sub.is_dir() or sub.name.startswith(".") or sub.name == "guides":
|
|
654
656
|
continue
|
|
655
657
|
|
|
658
|
+
if package_names and sub.name in package_names and allowed_pkgs is not None and sub.name not in allowed_pkgs:
|
|
659
|
+
continue
|
|
656
660
|
index_file = sub / "index.md"
|
|
657
661
|
if index_file.is_file():
|
|
658
662
|
paths.append(f".trellis/spec/{sub.name}/index.md")
|
|
659
|
-
continue
|
|
660
|
-
|
|
661
663
|
if allowed_pkgs is not None and sub.name not in allowed_pkgs:
|
|
662
664
|
continue
|
|
663
665
|
for nested in sorted(sub.iterdir()):
|
|
@@ -878,7 +880,7 @@ def main():
|
|
|
878
880
|
|
|
879
881
|
output = StringIO()
|
|
880
882
|
|
|
881
|
-
spec_index_paths = _collect_spec_index_paths(trellis_dir, allowed_pkgs)
|
|
883
|
+
spec_index_paths = _collect_spec_index_paths(trellis_dir, allowed_pkgs, set(packages))
|
|
882
884
|
|
|
883
885
|
output.write("""<session-context>
|
|
884
886
|
Trellis compact SessionStart context. Use it to orient the session; load details on demand.
|