@mindfoldhq/trellis 0.5.3 → 0.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/configurators/codex.d.ts.map +1 -1
- package/dist/configurators/codex.js +14 -1
- package/dist/configurators/codex.js.map +1 -1
- package/dist/migrations/manifests/0.5.4.json +9 -0
- package/dist/migrations/manifests/0.5.5.json +9 -0
- package/dist/templates/claude/agents/trellis-check.md +8 -0
- package/dist/templates/claude/agents/trellis-implement.md +8 -0
- package/dist/templates/codebuddy/agents/trellis-check.md +8 -0
- package/dist/templates/codebuddy/agents/trellis-implement.md +8 -0
- package/dist/templates/codex/agents/trellis-check.toml +2 -2
- package/dist/templates/codex/agents/trellis-implement.toml +2 -2
- package/dist/templates/codex/hooks/session-start.py +19 -0
- package/dist/templates/codex/hooks.json +0 -12
- package/dist/templates/cursor/agents/trellis-check.md +8 -0
- package/dist/templates/cursor/agents/trellis-implement.md +8 -0
- package/dist/templates/gemini/agents/trellis-check.md +8 -0
- package/dist/templates/gemini/agents/trellis-implement.md +8 -0
- package/dist/templates/kiro/agents/trellis-check.json +8 -2
- package/dist/templates/kiro/agents/trellis-implement.json +8 -2
- package/dist/templates/opencode/agents/trellis-check.md +8 -0
- package/dist/templates/opencode/agents/trellis-implement.md +8 -0
- package/dist/templates/pi/agents/trellis-check.md +8 -0
- package/dist/templates/pi/agents/trellis-implement.md +8 -0
- package/dist/templates/qoder/agents/trellis-check.md +8 -0
- package/dist/templates/qoder/agents/trellis-implement.md +8 -0
- package/dist/templates/shared-hooks/inject-workflow-state.py +50 -1
- package/dist/templates/trellis/workflow.md +6 -1
- package/dist/utils/compare-versions.d.ts.map +1 -1
- package/dist/utils/compare-versions.js +13 -3
- package/dist/utils/compare-versions.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codex.d.ts","sourceRoot":"","sources":["../../src/configurators/codex.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"codex.d.ts","sourceRoot":"","sources":["../../src/configurators/codex.ts"],"names":[],"mappings":"AAuBA;;;;;GAKG;AACH,wBAAsB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAyG/D"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { AI_TOOLS } from "../types/ai-tools.js";
|
|
3
3
|
import { getAllAgents, getAllCodexSkills, getAllHooks, getConfigTemplate, getHooksConfig, } from "../templates/codex/index.js";
|
|
4
|
+
import { getCommandTemplates } from "../templates/common/index.js";
|
|
4
5
|
import { ensureDir, writeFile } from "../utils/file-writer.js";
|
|
5
|
-
import { resolvePlaceholders, resolveAllAsSkillsNeutral, resolveBundledSkills, applyPullBasedPreludeToml, writeSkills, writeSharedHooks, replacePythonCommandLiterals, } from "./shared.js";
|
|
6
|
+
import { resolvePlaceholders, resolvePlaceholdersNeutral, resolveAllAsSkillsNeutral, resolveBundledSkills, applyPullBasedPreludeToml, wrapWithSkillFrontmatter, writeSkills, writeSharedHooks, replacePythonCommandLiterals, } from "./shared.js";
|
|
6
7
|
/**
|
|
7
8
|
* Configure Codex by writing:
|
|
8
9
|
* - .agents/skills/ — shared skills from common source
|
|
@@ -18,6 +19,18 @@ export async function configureCodex(cwd) {
|
|
|
18
19
|
// safe when both writers produce identical output).
|
|
19
20
|
const sharedSkillsRoot = path.join(cwd, ".agents", "skills");
|
|
20
21
|
await writeSkills(sharedSkillsRoot, resolveAllAsSkillsNeutral(AI_TOOLS.codex.templateContext), resolveBundledSkills(AI_TOOLS.codex.templateContext));
|
|
22
|
+
// Additionally write `trellis-start` to .agents/skills/ — Codex-specific.
|
|
23
|
+
// The SessionStart hook was removed (de-recursion fix); inject-workflow-state.py
|
|
24
|
+
// injects a `<trellis-bootstrap>` block on no_task turns instructing the AI to
|
|
25
|
+
// invoke `$trellis-start` to load workflow context. Without this skill, that
|
|
26
|
+
// invocation has nothing to resolve. Other agent-capable platforms keep their
|
|
27
|
+
// working SessionStart hooks and don't need this.
|
|
28
|
+
const startTemplate = getCommandTemplates().find((t) => t.name === "start");
|
|
29
|
+
if (startTemplate) {
|
|
30
|
+
const trellisStartDir = path.join(sharedSkillsRoot, "trellis-start");
|
|
31
|
+
ensureDir(trellisStartDir);
|
|
32
|
+
await writeFile(path.join(trellisStartDir, "SKILL.md"), wrapWithSkillFrontmatter("trellis-start", resolvePlaceholdersNeutral(startTemplate.content, AI_TOOLS.codex.templateContext)));
|
|
33
|
+
}
|
|
21
34
|
const codexRoot = path.join(cwd, ".codex");
|
|
22
35
|
// Codex-specific skills (platform-specific) → .codex/skills/
|
|
23
36
|
const codexSkillsRoot = path.join(codexRoot, "skills");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codex.js","sourceRoot":"","sources":["../../src/configurators/codex.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,WAAW,EACX,iBAAiB,EACjB,cAAc,GACf,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EACL,mBAAmB,EACnB,yBAAyB,EACzB,oBAAoB,EACpB,yBAAyB,EACzB,WAAW,EACX,gBAAgB,EAChB,4BAA4B,GAC7B,MAAM,aAAa,CAAC;AAErB;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,GAAW;IAC9C,qDAAqD;IACrD,wEAAwE;IACxE,yEAAyE;IACzE,yEAAyE;IACzE,uEAAuE;IACvE,oDAAoD;IACpD,MAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;IAC7D,MAAM,WAAW,CACf,gBAAg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B,CAAC,IAAI,CAAC,OAAO,CAAC,CAC3C,CAAC;IACJ,CAAC;IAED,sEAAsE;IACtE,qEAAqE;IACrE,MAAM,gBAAgB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAE1C,mCAAmC;IACnC,MAAM,SAAS,CACb,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,YAAY,CAAC,EAClC,mBAAmB,CAAC,cAAc,EAAE,CAAC,CACtC,CAAC;IAEF,wEAAwE;IACxE,wEAAwE;IACxE,4EAA4E;IAC5E,+CAA+C;IAC/C,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC;QACtD,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,gEAAgE;YAC9D,mEAAmE;YACnE,6CAA6C,CAChD,CAAC;IACJ,CAAC;IAED,8BAA8B;IAC9B,MAAM,MAAM,GAAG,iBAAiB,EAAE,CAAC;IACnC,MAAM,SAAS,CACb,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,UAAU,CAAC,EACvC,4BAA4B,CAAC,MAAM,CAAC,OAAO,CAAC,CAC7C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "0.5.4",
|
|
3
|
+
"description": "Patch: guard sub-agent recursion (#237) + fix compareVersions on hyphenated prereleases (#230).",
|
|
4
|
+
"breaking": false,
|
|
5
|
+
"recommendMigrate": false,
|
|
6
|
+
"changelog": "**Bug Fixes:**\n- fix(workflow): guard sub-agent recursion (#237). On Codex, `[workflow-state:in_progress]` reaches the sub-agent's turn too, and the sub-agent followed its own dispatch instruction — spawning another `trellis-implement` instead of doing the work. Scoped the dispatch rule to the main session and added a self-exemption to all platform `trellis-implement` / `trellis-check` agent definitions.\n- fix(compare-versions): preserve hyphens inside prerelease identifiers (#230 by @voidborne-d). `String.split(\"-\", 2)` truncates the tail in JavaScript (unlike Python `maxsplit`), so `compareVersions(\"1.0.0-alpha-1\", \"1.0.0-alpha-2\")` returned `0` — the two versions sorted as equal. Fixed. Adds 20 test cases in `packages/cli/test/utils/compare-versions.test.ts`.",
|
|
7
|
+
"migrations": [],
|
|
8
|
+
"notes": "Patch on top of 0.5.3. Run `trellis update` (no `--migrate` needed). Affects every platform whose per-turn workflow-state breadcrumb can reach sub-agent turns (Codex confirmed; risk applies more broadly)."
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "0.5.5",
|
|
3
|
+
"description": "Patch: structural fix for Codex sub-agent recursion (#240, #242) — drop SessionStart hook, bootstrap via trellis-start skill.",
|
|
4
|
+
"breaking": false,
|
|
5
|
+
"recommendMigrate": false,
|
|
6
|
+
"changelog": "**Bug Fixes:**\n- fix(codex): drop SessionStart hook, bootstrap via `trellis-start` skill (#240, #242). Codex fires SessionStart for every spawn, and its hook input exposes no `agent_id` / `agent_type` field (`openai/codex#16226`) — so the dispatch directive in `codex/hooks/session-start.py` kept reaching sub-agent sessions, the sub-agent mistook itself for the main session and re-dispatched its own sub-agent (recursive turtles). The 0.5.4 patch (`#237`) added a self-exemption clause but it sat alongside the dispatch directive in the same prompt block; LLMs kept picking the command-style instruction. Structural fix: removed the `SessionStart` entry from `codex/hooks.json`. `inject-workflow-state.py` (UserPromptSubmit hook) now injects a `<trellis-bootstrap>` block on `no_task` turns telling the AI to invoke `$trellis-start` once to load workflow context. Codex configurator additionally writes the new skill to `.agents/skills/trellis-start/SKILL.md` (other agent-capable platforms keep their working SessionStart hooks). Sub-agent sessions only see the existing `<sub-agent-notice>` — no command-style \"must dispatch\" text exists anywhere in the new injection, so the recursion vector is gone at source.",
|
|
7
|
+
"migrations": [],
|
|
8
|
+
"notes": "Patch on top of 0.5.4. Run `trellis update` (no `--migrate` needed). Codex users get a new `.agents/skills/trellis-start/SKILL.md` and a `hooks.json` without `SessionStart` wiring; other platforms unchanged."
|
|
9
|
+
}
|
|
@@ -8,6 +8,14 @@ tools: Read, Write, Edit, Bash, Glob, Grep, mcp__exa__web_search_exa, mcp__exa__
|
|
|
8
8
|
|
|
9
9
|
You are the Check Agent in the Trellis workflow.
|
|
10
10
|
|
|
11
|
+
## Recursion Guard
|
|
12
|
+
|
|
13
|
+
You are already the `trellis-check` sub-agent that the main session dispatched. Do the review and fixes directly.
|
|
14
|
+
|
|
15
|
+
- Do NOT spawn another `trellis-check` or `trellis-implement` sub-agent.
|
|
16
|
+
- 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.
|
|
17
|
+
- Only the main session may dispatch Trellis implement/check agents. If more implementation work is needed, report that recommendation instead of spawning.
|
|
18
|
+
|
|
11
19
|
## Trellis Context Loading Protocol
|
|
12
20
|
|
|
13
21
|
Look for the `<!-- trellis-hook-injected -->` marker in your input above.
|
|
@@ -8,6 +8,14 @@ tools: Read, Write, Edit, Bash, Glob, Grep, mcp__exa__web_search_exa, mcp__exa__
|
|
|
8
8
|
|
|
9
9
|
You are the Implement Agent in the Trellis workflow.
|
|
10
10
|
|
|
11
|
+
## Recursion Guard
|
|
12
|
+
|
|
13
|
+
You are already the `trellis-implement` sub-agent that the main session dispatched. Do the implementation work directly.
|
|
14
|
+
|
|
15
|
+
- Do NOT spawn another `trellis-implement` or `trellis-check` sub-agent.
|
|
16
|
+
- 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.
|
|
17
|
+
- Only the main session may dispatch Trellis implement/check agents. If more parallel work is needed, report that recommendation instead of spawning.
|
|
18
|
+
|
|
11
19
|
## Trellis Context Loading Protocol
|
|
12
20
|
|
|
13
21
|
Look for the `<!-- trellis-hook-injected -->` marker in your input above.
|
|
@@ -8,6 +8,14 @@ tools: Read, Write, Edit, Bash, Glob, Grep, mcp__exa__web_search_exa, mcp__exa__
|
|
|
8
8
|
|
|
9
9
|
You are the Check Agent in the Trellis workflow.
|
|
10
10
|
|
|
11
|
+
## Recursion Guard
|
|
12
|
+
|
|
13
|
+
You are already the `trellis-check` sub-agent that the main session dispatched. Do the review and fixes directly.
|
|
14
|
+
|
|
15
|
+
- Do NOT spawn another `trellis-check` or `trellis-implement` sub-agent.
|
|
16
|
+
- 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.
|
|
17
|
+
- Only the main session may dispatch Trellis implement/check agents. If more implementation work is needed, report that recommendation instead of spawning.
|
|
18
|
+
|
|
11
19
|
## Trellis Context Loading Protocol
|
|
12
20
|
|
|
13
21
|
Look for the `<!-- trellis-hook-injected -->` marker in your input above.
|
|
@@ -8,6 +8,14 @@ tools: Read, Write, Edit, Bash, Glob, Grep, mcp__exa__web_search_exa, mcp__exa__
|
|
|
8
8
|
|
|
9
9
|
You are the Implement Agent in the Trellis workflow.
|
|
10
10
|
|
|
11
|
+
## Recursion Guard
|
|
12
|
+
|
|
13
|
+
You are already the `trellis-implement` sub-agent that the main session dispatched. Do the implementation work directly.
|
|
14
|
+
|
|
15
|
+
- Do NOT spawn another `trellis-implement` or `trellis-check` sub-agent.
|
|
16
|
+
- 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.
|
|
17
|
+
- Only the main session may dispatch Trellis implement/check agents. If more parallel work is needed, report that recommendation instead of spawning.
|
|
18
|
+
|
|
11
19
|
## Trellis Context Loading Protocol
|
|
12
20
|
|
|
13
21
|
Look for the `<!-- trellis-hook-injected -->` marker in your input above.
|
|
@@ -7,8 +7,8 @@ You are running as the `trellis-check` sub-agent. The main session has dispatche
|
|
|
7
7
|
|
|
8
8
|
CRITICAL — Recursion guard (read first):
|
|
9
9
|
- You MUST NOT spawn another `trellis-check` or `trellis-implement` sub-agent. Do the review and fixes directly in this turn.
|
|
10
|
-
- Any guidance you read in injected SessionStart context, `<guidelines>` blocks,
|
|
11
|
-
- Only the main session is allowed to dispatch `trellis-implement` / `trellis-check`. If
|
|
10
|
+
- Any guidance you read in injected SessionStart context, `<guidelines>` blocks, workflow-state breadcrumbs, or workflow.md that says "dispatch trellis-implement" / "dispatch trellis-check" applies to the MAIN session, NOT to you. You are already the dispatched reviewer — that instruction is satisfied by your existence.
|
|
11
|
+
- Only the main session is allowed to dispatch `trellis-implement` / `trellis-check`. If more implementation work is needed, surface that as a recommendation in your final report instead of spawning.
|
|
12
12
|
|
|
13
13
|
You are the Trellis reviewer agent.
|
|
14
14
|
|
|
@@ -7,8 +7,8 @@ You are running as the `trellis-implement` sub-agent. The main session has dispa
|
|
|
7
7
|
|
|
8
8
|
CRITICAL — Recursion guard (read first):
|
|
9
9
|
- You MUST NOT spawn another `trellis-implement` or `trellis-check` sub-agent. Do the implementation work directly in this turn.
|
|
10
|
-
- Any guidance you read in injected SessionStart context, `<guidelines>` blocks,
|
|
11
|
-
- Only the main session is allowed to dispatch `trellis-implement` / `trellis-check`. If
|
|
10
|
+
- Any guidance you read in injected SessionStart context, `<guidelines>` blocks, workflow-state breadcrumbs, or workflow.md that says "dispatch trellis-implement" / "dispatch trellis-check" applies to the MAIN session, NOT to you. You are already the dispatched implementer — that instruction is satisfied by your existence.
|
|
11
|
+
- Only the main session is allowed to dispatch `trellis-implement` / `trellis-check`. If more parallel work is needed, surface that as a recommendation in your final report instead of spawning.
|
|
12
12
|
|
|
13
13
|
You are the Trellis implementer agent.
|
|
14
14
|
|
|
@@ -75,6 +75,22 @@ Trellis SessionStart 已注入:workflow、当前任务状态、开发者身份
|
|
|
75
75
|
Then continue directly with the user's request. This notice is one-shot: do not repeat it after the first assistant reply in the same session.
|
|
76
76
|
</first-reply-notice>"""
|
|
77
77
|
|
|
78
|
+
SUB_AGENT_NOTICE = """<sub-agent-notice>
|
|
79
|
+
SUB-AGENT NOTICE - READ FIRST IF SPAWNED VIA spawn_agent
|
|
80
|
+
|
|
81
|
+
If your parent session spawned you via spawn_agent with an explicit task
|
|
82
|
+
message above this hook output, that message is your only job.
|
|
83
|
+
- Execute the parent message exactly as written, then return.
|
|
84
|
+
- Ignore all Trellis workflow guidance below this notice.
|
|
85
|
+
- Do NOT call task.py start, task.py add-context, or task.py archive.
|
|
86
|
+
- Do NOT call wait_agent or spawn_agent.
|
|
87
|
+
- Do NOT modify .trellis/tasks/* or any other file unless the parent message
|
|
88
|
+
explicitly asks for that.
|
|
89
|
+
|
|
90
|
+
If you are the main interactive Codex session and the user is typing at the
|
|
91
|
+
terminal with no parent agent, use the workflow guidance below normally.
|
|
92
|
+
</sub-agent-notice>"""
|
|
93
|
+
|
|
78
94
|
|
|
79
95
|
def should_skip_injection() -> bool:
|
|
80
96
|
if os.environ.get("TRELLIS_HOOKS") == "0":
|
|
@@ -336,6 +352,9 @@ def main() -> None:
|
|
|
336
352
|
|
|
337
353
|
output = StringIO()
|
|
338
354
|
|
|
355
|
+
output.write(SUB_AGENT_NOTICE)
|
|
356
|
+
output.write("\n\n")
|
|
357
|
+
|
|
339
358
|
output.write("""<session-context>
|
|
340
359
|
You are starting a new session in a Trellis-managed project.
|
|
341
360
|
Read and follow all instructions below carefully.
|
|
@@ -1,17 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"hooks": {
|
|
3
|
-
"SessionStart": [
|
|
4
|
-
{
|
|
5
|
-
"hooks": [
|
|
6
|
-
{
|
|
7
|
-
"type": "command",
|
|
8
|
-
"command": "{{PYTHON_CMD}} .codex/hooks/session-start.py",
|
|
9
|
-
"timeout": 15,
|
|
10
|
-
"statusMessage": "Loading Trellis context..."
|
|
11
|
-
}
|
|
12
|
-
]
|
|
13
|
-
}
|
|
14
|
-
],
|
|
15
3
|
"UserPromptSubmit": [
|
|
16
4
|
{
|
|
17
5
|
"hooks": [
|
|
@@ -7,6 +7,14 @@ tools: Read, Write, Edit, Bash, Glob, Grep, mcp__exa__web_search_exa, mcp__exa__
|
|
|
7
7
|
|
|
8
8
|
You are the Check Agent in the Trellis workflow.
|
|
9
9
|
|
|
10
|
+
## Recursion Guard
|
|
11
|
+
|
|
12
|
+
You are already the `trellis-check` sub-agent that the main session dispatched. Do the review and fixes directly.
|
|
13
|
+
|
|
14
|
+
- Do NOT spawn another `trellis-check` or `trellis-implement` sub-agent.
|
|
15
|
+
- 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.
|
|
16
|
+
- Only the main session may dispatch Trellis implement/check agents. If more implementation work is needed, report that recommendation instead of spawning.
|
|
17
|
+
|
|
10
18
|
## Trellis Context Loading Protocol
|
|
11
19
|
|
|
12
20
|
Look for the `<!-- trellis-hook-injected -->` marker in your input above.
|
|
@@ -7,6 +7,14 @@ tools: Read, Write, Edit, Bash, Glob, Grep, mcp__exa__web_search_exa, mcp__exa__
|
|
|
7
7
|
|
|
8
8
|
You are the Implement Agent in the Trellis workflow.
|
|
9
9
|
|
|
10
|
+
## Recursion Guard
|
|
11
|
+
|
|
12
|
+
You are already the `trellis-implement` sub-agent that the main session dispatched. Do the implementation work directly.
|
|
13
|
+
|
|
14
|
+
- Do NOT spawn another `trellis-implement` or `trellis-check` sub-agent.
|
|
15
|
+
- 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.
|
|
16
|
+
- Only the main session may dispatch Trellis implement/check agents. If more parallel work is needed, report that recommendation instead of spawning.
|
|
17
|
+
|
|
10
18
|
## Trellis Context Loading Protocol
|
|
11
19
|
|
|
12
20
|
Look for the `<!-- trellis-hook-injected -->` marker in your input above.
|
|
@@ -7,6 +7,14 @@ description: |
|
|
|
7
7
|
|
|
8
8
|
You are the Check Agent in the Trellis workflow.
|
|
9
9
|
|
|
10
|
+
## Recursion Guard
|
|
11
|
+
|
|
12
|
+
You are already the `trellis-check` sub-agent that the main session dispatched. Do the review and fixes directly.
|
|
13
|
+
|
|
14
|
+
- Do NOT spawn another `trellis-check` or `trellis-implement` sub-agent.
|
|
15
|
+
- 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.
|
|
16
|
+
- Only the main session may dispatch Trellis implement/check agents. If more implementation work is needed, report that recommendation instead of spawning.
|
|
17
|
+
|
|
10
18
|
## Context
|
|
11
19
|
|
|
12
20
|
Before checking, read:
|
|
@@ -7,6 +7,14 @@ description: |
|
|
|
7
7
|
|
|
8
8
|
You are the Implement Agent in the Trellis workflow.
|
|
9
9
|
|
|
10
|
+
## Recursion Guard
|
|
11
|
+
|
|
12
|
+
You are already the `trellis-implement` sub-agent that the main session dispatched. Do the implementation work directly.
|
|
13
|
+
|
|
14
|
+
- Do NOT spawn another `trellis-implement` or `trellis-check` sub-agent.
|
|
15
|
+
- 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.
|
|
16
|
+
- Only the main session may dispatch Trellis implement/check agents. If more parallel work is needed, report that recommendation instead of spawning.
|
|
17
|
+
|
|
10
18
|
## Context
|
|
11
19
|
|
|
12
20
|
Before implementing, read:
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "trellis-check",
|
|
3
3
|
"description": "Code quality check expert. Reviews code changes against specs and self-fixes issues.",
|
|
4
|
-
"instructions": "# Check Agent\n\nYou are the Check Agent in the Trellis workflow.\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 check 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>/prd.md` and the spec files listed in `<task-path>/check.jsonl` yourself before doing the work.\n\n## Context\n\nBefore checking, read:\n- `.trellis/spec/` - Development guidelines\n- Pre-commit checklist for quality standards\n\n## Core Responsibilities\n\n1. **Get code changes** - Use git diff to get uncommitted code\n2. **Check against specs** - Verify code follows guidelines\n3. **Self-fix** - Fix issues yourself, not just report them\n4. **Run verification** - typecheck and lint\n\n## Important\n\n**Fix issues yourself**, don't just report them.\n\nYou have write and edit tools, you can modify code directly.\n\n---\n\n## Workflow\n\n### Step 1: Get Changes\n\n```bash\ngit diff --name-only # List changed files\ngit diff # View specific changes\n```\n\n### Step 2: Check Against Specs\n\nRead relevant specs in `.trellis/spec/` to check code:\n\n- Does it follow directory structure conventions\n- Does it follow naming conventions\n- Does it follow code patterns\n- Are there missing types\n- Are there potential bugs\n\n### Step 3: Self-Fix\n\nAfter finding issues:\n\n1. Fix the issue directly (use edit tool)\n2. Record what was fixed\n3. Continue checking other issues\n\n### Step 4: Run Verification\n\nRun project's lint and typecheck commands to verify changes.\n\nIf failed, fix issues and re-run.\n\n---\n\n## Report Format\n\n```markdown\n## Self-Check Complete\n\n### Files Checked\n\n- src/components/Feature.tsx\n- src/hooks/useFeature.ts\n\n### Issues Found and Fixed\n\n1. `<file>:<line>` - <what was fixed>\n2. `<file>:<line>` - <what was fixed>\n\n### Issues Not Fixed\n\n(If there are issues that cannot be self-fixed, list them here with reasons)\n\n### Verification Results\n\n- TypeCheck: Passed\n- Lint: Passed\n\n### Summary\n\nChecked X files, found Y issues, all fixed.\n```",
|
|
5
|
-
"tools": [
|
|
4
|
+
"instructions": "# Check Agent\n\nYou are the Check Agent in the Trellis workflow.\n\n## Recursion Guard\n\nYou are already the `trellis-check` sub-agent that the main session dispatched. Do the review and fixes directly.\n\n- Do NOT spawn another `trellis-check` or `trellis-implement` 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 implementation 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 check 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>/prd.md` and the spec files listed in `<task-path>/check.jsonl` yourself before doing the work.\n\n## Context\n\nBefore checking, read:\n- `.trellis/spec/` - Development guidelines\n- Pre-commit checklist for quality standards\n\n## Core Responsibilities\n\n1. **Get code changes** - Use git diff to get uncommitted code\n2. **Check against specs** - Verify code follows guidelines\n3. **Self-fix** - Fix issues yourself, not just report them\n4. **Run verification** - typecheck and lint\n\n## Important\n\n**Fix issues yourself**, don't just report them.\n\nYou have write and edit tools, you can modify code directly.\n\n---\n\n## Workflow\n\n### Step 1: Get Changes\n\n```bash\ngit diff --name-only # List changed files\ngit diff # View specific changes\n```\n\n### Step 2: Check Against Specs\n\nRead relevant specs in `.trellis/spec/` to check code:\n\n- Does it follow directory structure conventions\n- Does it follow naming conventions\n- Does it follow code patterns\n- Are there missing types\n- Are there potential bugs\n\n### Step 3: Self-Fix\n\nAfter finding issues:\n\n1. Fix the issue directly (use edit tool)\n2. Record what was fixed\n3. Continue checking other issues\n\n### Step 4: Run Verification\n\nRun project's lint and typecheck commands to verify changes.\n\nIf failed, fix issues and re-run.\n\n---\n\n## Report Format\n\n```markdown\n## Self-Check Complete\n\n### Files Checked\n\n- src/components/Feature.tsx\n- src/hooks/useFeature.ts\n\n### Issues Found and Fixed\n\n1. `<file>:<line>` - <what was fixed>\n2. `<file>:<line>` - <what was fixed>\n\n### Issues Not Fixed\n\n(If there are issues that cannot be self-fixed, list them here with reasons)\n\n### Verification Results\n\n- TypeCheck: Passed\n- Lint: Passed\n\n### Summary\n\nChecked X files, found Y issues, all fixed.\n```",
|
|
5
|
+
"tools": [
|
|
6
|
+
"read",
|
|
7
|
+
"write",
|
|
8
|
+
"shell",
|
|
9
|
+
"glob",
|
|
10
|
+
"grep"
|
|
11
|
+
],
|
|
6
12
|
"hooks": [
|
|
7
13
|
{
|
|
8
14
|
"on": "agentSpawn",
|
|
@@ -1,8 +1,14 @@
|
|
|
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
|
-
"instructions": "# Implement Agent\n\nYou are the Implement Agent in the Trellis workflow.\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>/prd.md`, `<task-path>/info.md` (if it exists), and the spec files listed in `<task-path>/implement.jsonl` yourself 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 `info.md` - Technical design (if exists)\n\n## Core Responsibilities\n\n1. **Understand specs** - Read relevant spec files in `.trellis/spec/`\n2. **Understand requirements** - Read prd.md and info.md\n3. **Implement features** - Write code following specs and design\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- Spec layers: `.trellis/spec/<package>/<layer>/`\n- Shared guides: `.trellis/spec/guides/`\n\n### 2. Understand Requirements\n\nRead the task's prd.md and info.md:\n\n- What are the core requirements\n- Key points of technical design\n- Which files to modify/create\n\n### 3. Implement Features\n\n- Write code following specs and technical design\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
|
-
"tools": [
|
|
4
|
+
"instructions": "# 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>/prd.md`, `<task-path>/info.md` (if it exists), and the spec files listed in `<task-path>/implement.jsonl` yourself 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 `info.md` - Technical design (if exists)\n\n## Core Responsibilities\n\n1. **Understand specs** - Read relevant spec files in `.trellis/spec/`\n2. **Understand requirements** - Read prd.md and info.md\n3. **Implement features** - Write code following specs and design\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- Spec layers: `.trellis/spec/<package>/<layer>/`\n- Shared guides: `.trellis/spec/guides/`\n\n### 2. Understand Requirements\n\nRead the task's prd.md and info.md:\n\n- What are the core requirements\n- Key points of technical design\n- Which files to modify/create\n\n### 3. Implement Features\n\n- Write code following specs and technical design\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
|
+
"tools": [
|
|
6
|
+
"read",
|
|
7
|
+
"write",
|
|
8
|
+
"shell",
|
|
9
|
+
"glob",
|
|
10
|
+
"grep"
|
|
11
|
+
],
|
|
6
12
|
"hooks": [
|
|
7
13
|
{
|
|
8
14
|
"on": "agentSpawn",
|
|
@@ -15,6 +15,14 @@ permission:
|
|
|
15
15
|
|
|
16
16
|
You are the Check Agent in the Trellis workflow.
|
|
17
17
|
|
|
18
|
+
## Recursion Guard
|
|
19
|
+
|
|
20
|
+
You are already the `trellis-check` sub-agent that the main session dispatched. Do the review and fixes directly.
|
|
21
|
+
|
|
22
|
+
- Do NOT spawn another `trellis-check` or `trellis-implement` sub-agent.
|
|
23
|
+
- 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.
|
|
24
|
+
- Only the main session may dispatch Trellis implement/check agents. If more implementation work is needed, report that recommendation instead of spawning.
|
|
25
|
+
|
|
18
26
|
## Trellis Context Loading Protocol
|
|
19
27
|
|
|
20
28
|
Look for the `<!-- trellis-hook-injected -->` marker in your input above.
|
|
@@ -15,6 +15,14 @@ permission:
|
|
|
15
15
|
|
|
16
16
|
You are the Implement Agent in the Trellis workflow.
|
|
17
17
|
|
|
18
|
+
## Recursion Guard
|
|
19
|
+
|
|
20
|
+
You are already the `trellis-implement` sub-agent that the main session dispatched. Do the implementation work directly.
|
|
21
|
+
|
|
22
|
+
- Do NOT spawn another `trellis-implement` or `trellis-check` sub-agent.
|
|
23
|
+
- 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.
|
|
24
|
+
- Only the main session may dispatch Trellis implement/check agents. If more parallel work is needed, report that recommendation instead of spawning.
|
|
25
|
+
|
|
18
26
|
## Trellis Context Loading Protocol
|
|
19
27
|
|
|
20
28
|
Look for the `<!-- trellis-hook-injected -->` marker in your input above.
|
|
@@ -8,6 +8,14 @@ tools: Read, Write, Edit, Bash, Glob, Grep
|
|
|
8
8
|
|
|
9
9
|
You are the Check Agent in the Trellis workflow.
|
|
10
10
|
|
|
11
|
+
## Recursion Guard
|
|
12
|
+
|
|
13
|
+
You are already the `trellis-check` sub-agent that the main session dispatched. Do the review and fixes directly.
|
|
14
|
+
|
|
15
|
+
- Do NOT spawn another `trellis-check` or `trellis-implement` sub-agent.
|
|
16
|
+
- 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.
|
|
17
|
+
- Only the main session may dispatch Trellis implement/check agents. If more implementation work is needed, report that recommendation instead of spawning.
|
|
18
|
+
|
|
11
19
|
## Core Responsibilities
|
|
12
20
|
|
|
13
21
|
1. Inspect the current git diff.
|
|
@@ -8,6 +8,14 @@ tools: Read, Write, Edit, Bash, Glob, Grep
|
|
|
8
8
|
|
|
9
9
|
You are the Implement Agent in the Trellis workflow.
|
|
10
10
|
|
|
11
|
+
## Recursion Guard
|
|
12
|
+
|
|
13
|
+
You are already the `trellis-implement` sub-agent that the main session dispatched. Do the implementation work directly.
|
|
14
|
+
|
|
15
|
+
- Do NOT spawn another `trellis-implement` or `trellis-check` sub-agent.
|
|
16
|
+
- 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.
|
|
17
|
+
- Only the main session may dispatch Trellis implement/check agents. If more parallel work is needed, report that recommendation instead of spawning.
|
|
18
|
+
|
|
11
19
|
## Core Responsibilities
|
|
12
20
|
|
|
13
21
|
1. Understand the active task requirements.
|
|
@@ -8,6 +8,14 @@ tools: Read, Write, Edit, Bash, Glob, Grep, mcp__exa__web_search_exa, mcp__exa__
|
|
|
8
8
|
|
|
9
9
|
You are the Check Agent in the Trellis workflow.
|
|
10
10
|
|
|
11
|
+
## Recursion Guard
|
|
12
|
+
|
|
13
|
+
You are already the `trellis-check` sub-agent that the main session dispatched. Do the review and fixes directly.
|
|
14
|
+
|
|
15
|
+
- Do NOT spawn another `trellis-check` or `trellis-implement` sub-agent.
|
|
16
|
+
- 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.
|
|
17
|
+
- Only the main session may dispatch Trellis implement/check agents. If more implementation work is needed, report that recommendation instead of spawning.
|
|
18
|
+
|
|
11
19
|
## Context
|
|
12
20
|
|
|
13
21
|
Before checking, read:
|
|
@@ -8,6 +8,14 @@ tools: Read, Write, Edit, Bash, Glob, Grep, mcp__exa__web_search_exa, mcp__exa__
|
|
|
8
8
|
|
|
9
9
|
You are the Implement Agent in the Trellis workflow.
|
|
10
10
|
|
|
11
|
+
## Recursion Guard
|
|
12
|
+
|
|
13
|
+
You are already the `trellis-implement` sub-agent that the main session dispatched. Do the implementation work directly.
|
|
14
|
+
|
|
15
|
+
- Do NOT spawn another `trellis-implement` or `trellis-check` sub-agent.
|
|
16
|
+
- 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.
|
|
17
|
+
- Only the main session may dispatch Trellis implement/check agents. If more parallel work is needed, report that recommendation instead of spawning.
|
|
18
|
+
|
|
11
19
|
## Context
|
|
12
20
|
|
|
13
21
|
Before implementing, read:
|
|
@@ -36,6 +36,47 @@ from pathlib import Path
|
|
|
36
36
|
from typing import Optional
|
|
37
37
|
|
|
38
38
|
|
|
39
|
+
CODEX_SUB_AGENT_NOTICE = """<sub-agent-notice>
|
|
40
|
+
SUB-AGENT NOTICE - READ FIRST IF SPAWNED VIA spawn_agent
|
|
41
|
+
|
|
42
|
+
If your parent session spawned you via spawn_agent with an explicit task
|
|
43
|
+
message above this hook output, that message is your only job.
|
|
44
|
+
- Execute the parent message exactly as written, then return.
|
|
45
|
+
- Ignore all Trellis workflow guidance below this notice.
|
|
46
|
+
- Do NOT call task.py start, task.py add-context, or task.py archive.
|
|
47
|
+
- Do NOT call wait_agent or spawn_agent.
|
|
48
|
+
- Do NOT modify .trellis/tasks/* or any other file unless the parent message
|
|
49
|
+
explicitly asks for that.
|
|
50
|
+
|
|
51
|
+
If you are the main interactive Codex session and the user is typing at the
|
|
52
|
+
terminal with no parent agent, use the workflow guidance below normally.
|
|
53
|
+
</sub-agent-notice>"""
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
# Bootstrap notice for Codex while the session has no active task. Replaces the
|
|
57
|
+
# heavyweight SessionStart context injection — instead of pushing 9.5 KB of
|
|
58
|
+
# workflow text up front, we just nudge the AI to read the `trellis-start` skill once.
|
|
59
|
+
# The nudge keeps showing up while status == "no_task" (cheap text, AI won't
|
|
60
|
+
# re-read after the first time). Once a task is created the breadcrumb status
|
|
61
|
+
# flips and this notice stops appearing automatically. Sub-agents are warded
|
|
62
|
+
# off by the <sub-agent-notice> above plus the explicit exemption below.
|
|
63
|
+
CODEX_NO_TASK_BOOTSTRAP_NOTICE = """<trellis-bootstrap>
|
|
64
|
+
You are running in a Trellis-managed Codex session and there is no active task yet.
|
|
65
|
+
If you have not already loaded Trellis context this session, read the `trellis-start` skill once:
|
|
66
|
+
|
|
67
|
+
$trellis-start
|
|
68
|
+
|
|
69
|
+
(equivalent to reading `.agents/skills/trellis-start/SKILL.md` and following its Steps 1-3)
|
|
70
|
+
|
|
71
|
+
The skill walks you through workflow.md, dev profile, git status, active tasks, and spec
|
|
72
|
+
indexes. Then route the user's request per the <workflow-state> A/B/C rules below.
|
|
73
|
+
|
|
74
|
+
Sub-agent exemption: if you are a sub-agent (spawned via spawn_agent with a parent task
|
|
75
|
+
message), DO NOT read `$trellis-start`. Execute the parent message directly as instructed by the
|
|
76
|
+
<sub-agent-notice> above.
|
|
77
|
+
</trellis-bootstrap>"""
|
|
78
|
+
|
|
79
|
+
|
|
39
80
|
# ---------------------------------------------------------------------------
|
|
40
81
|
# CWD-robust Trellis root discovery (fixes hook-path-robustness for this hook)
|
|
41
82
|
# ---------------------------------------------------------------------------
|
|
@@ -219,11 +260,19 @@ def main() -> int:
|
|
|
219
260
|
task_id, status, source = task
|
|
220
261
|
breadcrumb = build_breadcrumb(task_id, status, templates, source)
|
|
221
262
|
|
|
263
|
+
platform = _detect_platform(data)
|
|
264
|
+
if platform == "codex":
|
|
265
|
+
parts: list[str] = [CODEX_SUB_AGENT_NOTICE]
|
|
266
|
+
if task is None:
|
|
267
|
+
parts.append(CODEX_NO_TASK_BOOTSTRAP_NOTICE)
|
|
268
|
+
parts.append(breadcrumb)
|
|
269
|
+
breadcrumb = "\n\n".join(parts)
|
|
270
|
+
|
|
222
271
|
# Gemini CLI 0.40.x rejects "UserPromptSubmit" — its per-turn event is
|
|
223
272
|
# named "BeforeAgent". Other platforms (Claude/Cursor/Qoder/CodeBuddy/
|
|
224
273
|
# Droid/Codex/Copilot) accept the original Claude-style name.
|
|
225
274
|
hook_event_name = (
|
|
226
|
-
"BeforeAgent" if
|
|
275
|
+
"BeforeAgent" if platform == "gemini" else "UserPromptSubmit"
|
|
227
276
|
)
|
|
228
277
|
|
|
229
278
|
output = {
|
|
@@ -185,7 +185,8 @@ Research output **must** land in `{task_dir}/research/*.md`, written by `trellis
|
|
|
185
185
|
|
|
186
186
|
[workflow-state:in_progress]
|
|
187
187
|
**Flow**: trellis-implement → trellis-check → trellis-update-spec → commit (Phase 3.4) → `/trellis:finish-work`.
|
|
188
|
-
**
|
|
188
|
+
**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/`).
|
|
189
|
+
**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.
|
|
189
190
|
**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.
|
|
190
191
|
**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.
|
|
191
192
|
[/workflow-state:in_progress]
|
|
@@ -437,6 +438,7 @@ Spawn the implement sub-agent:
|
|
|
437
438
|
|
|
438
439
|
- **Agent type**: `trellis-implement`
|
|
439
440
|
- **Task description**: Implement the requirements per prd.md, consulting materials under `{TASK_DIR}/research/`; finish by running project lint and type-check
|
|
441
|
+
- **Dispatch prompt guard**: Tell the spawned agent it is already the `trellis-implement` sub-agent and must implement directly, not spawn another `trellis-implement` / `trellis-check`.
|
|
440
442
|
|
|
441
443
|
The platform hook/plugin auto-handles:
|
|
442
444
|
- Reads `implement.jsonl` and injects the referenced spec files into the agent prompt
|
|
@@ -450,6 +452,7 @@ Spawn the implement sub-agent:
|
|
|
450
452
|
|
|
451
453
|
- **Agent type**: `trellis-implement`
|
|
452
454
|
- **Task description**: Implement the requirements per prd.md, consulting materials under `{TASK_DIR}/research/`; finish by running project lint and type-check
|
|
455
|
+
- **Dispatch prompt guard**: The prompt MUST start with `Active task: <task path>`, then explicitly say the spawned agent is already `trellis-implement` and must implement directly without spawning another `trellis-implement` / `trellis-check`.
|
|
453
456
|
|
|
454
457
|
The Codex sub-agent definition auto-handles the context load requirement:
|
|
455
458
|
- Resolves the active task with `task.py current --source`, then reads `prd.md` and `info.md` if present
|
|
@@ -463,6 +466,7 @@ Spawn the implement sub-agent:
|
|
|
463
466
|
|
|
464
467
|
- **Agent type**: `trellis-implement`
|
|
465
468
|
- **Task description**: Implement the requirements per prd.md, consulting materials under `{TASK_DIR}/research/`; finish by running project lint and type-check
|
|
469
|
+
- **Dispatch prompt guard**: Tell the spawned agent it is already the `trellis-implement` sub-agent and must implement directly, not spawn another `trellis-implement` / `trellis-check`.
|
|
466
470
|
|
|
467
471
|
The platform prelude auto-handles the context load requirement:
|
|
468
472
|
- Reads `implement.jsonl` and injects the referenced spec files into the agent prompt
|
|
@@ -488,6 +492,7 @@ Spawn the check sub-agent:
|
|
|
488
492
|
|
|
489
493
|
- **Agent type**: `trellis-check`
|
|
490
494
|
- **Task description**: Review all code changes against spec and prd; fix any findings directly; ensure lint and type-check pass
|
|
495
|
+
- **Dispatch prompt guard**: Tell the spawned agent it is already the `trellis-check` sub-agent and must review/fix directly, not spawn another `trellis-check` / `trellis-implement`.
|
|
491
496
|
|
|
492
497
|
The check agent's job:
|
|
493
498
|
- Review code changes against specs
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compare-versions.d.ts","sourceRoot":"","sources":["../../src/utils/compare-versions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"compare-versions.d.ts","sourceRoot":"","sources":["../../src/utils/compare-versions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAwE5D"}
|
|
@@ -9,9 +9,19 @@
|
|
|
9
9
|
* - 0.3.0-beta.16 < 0.3.0-rc.0 (alphabetically: "beta" < "rc")
|
|
10
10
|
*/
|
|
11
11
|
export function compareVersions(a, b) {
|
|
12
|
-
// Split into base version and prerelease parts
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
// Split into base version and prerelease parts on the FIRST hyphen.
|
|
13
|
+
// `String.split("-", 2)` cannot be used here: in JavaScript the limit
|
|
14
|
+
// truncates the result instead of joining the tail (unlike Python's
|
|
15
|
+
// `maxsplit`), so `"1.0.0-alpha-1".split("-", 2)` yields
|
|
16
|
+
// `["1.0.0", "alpha"]` and silently drops `-1`. SemVer permits hyphens
|
|
17
|
+
// inside a single prerelease identifier (e.g. `1.0.0-alpha-1`), so we
|
|
18
|
+
// must preserve everything after the first hyphen.
|
|
19
|
+
const splitOnFirstHyphen = (v) => {
|
|
20
|
+
const idx = v.indexOf("-");
|
|
21
|
+
return idx === -1 ? [v, undefined] : [v.slice(0, idx), v.slice(idx + 1)];
|
|
22
|
+
};
|
|
23
|
+
const [aBase, aPrerelease] = splitOnFirstHyphen(a);
|
|
24
|
+
const [bBase, bPrerelease] = splitOnFirstHyphen(b);
|
|
15
25
|
// Parse base version (only numeric parts before any hyphen)
|
|
16
26
|
const parseBase = (v) => v.split(".").map((n) => parseInt(n, 10) || 0);
|
|
17
27
|
const aBaseParts = parseBase(aBase);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compare-versions.js","sourceRoot":"","sources":["../../src/utils/compare-versions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,UAAU,eAAe,CAAC,CAAS,EAAE,CAAS;IAClD
|
|
1
|
+
{"version":3,"file":"compare-versions.js","sourceRoot":"","sources":["../../src/utils/compare-versions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,UAAU,eAAe,CAAC,CAAS,EAAE,CAAS;IAClD,oEAAoE;IACpE,sEAAsE;IACtE,oEAAoE;IACpE,yDAAyD;IACzD,uEAAuE;IACvE,sEAAsE;IACtE,mDAAmD;IACnD,MAAM,kBAAkB,GAAG,CAAC,CAAS,EAAgC,EAAE;QACrE,MAAM,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC3B,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;IAC3E,CAAC,CAAC;IACF,MAAM,CAAC,KAAK,EAAE,WAAW,CAAC,GAAG,kBAAkB,CAAC,CAAC,CAAC,CAAC;IACnD,MAAM,CAAC,KAAK,EAAE,WAAW,CAAC,GAAG,kBAAkB,CAAC,CAAC,CAAC,CAAC;IAEnD,4DAA4D;IAC5D,MAAM,SAAS,GAAG,CAAC,CAAS,EAAY,EAAE,CACxC,CAAC,CAAC,KA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