@mindfoldhq/trellis 0.4.0-beta.7 → 0.4.0-beta.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/commands/init.js +1 -1
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/update.js +33 -2
- package/dist/commands/update.js.map +1 -1
- package/dist/configurators/codex.d.ts +7 -4
- package/dist/configurators/codex.d.ts.map +1 -1
- package/dist/configurators/codex.js +39 -10
- package/dist/configurators/codex.js.map +1 -1
- package/dist/configurators/index.d.ts +11 -1
- package/dist/configurators/index.d.ts.map +1 -1
- package/dist/configurators/index.js +28 -4
- package/dist/configurators/index.js.map +1 -1
- package/dist/migrations/manifests/0.4.0-beta.8.json +34 -0
- package/dist/templates/claude/commands/trellis/record-session.md +2 -1
- package/dist/templates/codex/agents/check.toml +23 -0
- package/dist/templates/codex/agents/implement.toml +19 -0
- package/dist/templates/codex/agents/research.toml +26 -0
- package/dist/templates/codex/codex-skills/parallel/SKILL.md +194 -0
- package/dist/templates/codex/config.toml +5 -0
- package/dist/templates/codex/hooks/session-start.py +204 -0
- package/dist/templates/codex/hooks.json +16 -0
- package/dist/templates/codex/index.d.ts +27 -5
- package/dist/templates/codex/index.d.ts.map +1 -1
- package/dist/templates/codex/index.js +60 -8
- package/dist/templates/codex/index.js.map +1 -1
- package/dist/templates/codex/skills/improve-ut/SKILL.md +69 -0
- package/dist/templates/codex/skills/record-session/SKILL.md +2 -1
- package/dist/templates/cursor/commands/trellis-record-session.md +2 -1
- package/dist/templates/extract.d.ts +11 -0
- package/dist/templates/extract.d.ts.map +1 -1
- package/dist/templates/extract.js +19 -0
- package/dist/templates/extract.js.map +1 -1
- package/dist/templates/gemini/commands/trellis/record-session.toml +2 -1
- package/dist/templates/iflow/commands/trellis/record-session.md +2 -1
- package/dist/templates/kilo/workflows/record-session.md +2 -1
- package/dist/templates/kiro/skills/record-session/SKILL.md +2 -1
- package/dist/templates/markdown/agents.md +4 -0
- package/dist/templates/markdown/workspace-index.md +2 -0
- package/dist/templates/opencode/commands/trellis/record-session.md +2 -1
- package/dist/templates/qoder/skills/record-session/SKILL.md +2 -1
- package/dist/templates/trellis/scripts/add_session.py +63 -15
- package/dist/templates/trellis/scripts/common/cli_adapter.py +23 -9
- package/dist/templates/trellis/scripts/common/developer.py +2 -2
- package/dist/templates/trellis/scripts/multi_agent/plan.py +7 -6
- package/dist/templates/trellis/scripts/multi_agent/start.py +7 -6
- package/dist/types/ai-tools.d.ts +10 -0
- package/dist/types/ai-tools.d.ts.map +1 -1
- package/dist/types/ai-tools.js +13 -1
- package/dist/types/ai-tools.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
name = "check"
|
|
2
|
+
description = "Read-only Trellis reviewer focused on correctness, missing tests, and spec drift."
|
|
3
|
+
sandbox_mode = "read-only"
|
|
4
|
+
|
|
5
|
+
developer_instructions = """
|
|
6
|
+
You are the Trellis reviewer agent.
|
|
7
|
+
|
|
8
|
+
Review checklist:
|
|
9
|
+
- Verify behavior against the actual code paths, not assumptions.
|
|
10
|
+
- Look for missing template/update/detection touch points when platform config changes.
|
|
11
|
+
- Check whether tests should be added or updated.
|
|
12
|
+
- Check whether `.trellis/spec/` docs need sync after implementation.
|
|
13
|
+
- Prefer concrete findings over speculative warnings.
|
|
14
|
+
|
|
15
|
+
Output format:
|
|
16
|
+
## Findings
|
|
17
|
+
- Severity: <high|medium|low>
|
|
18
|
+
- File: <path>
|
|
19
|
+
- Issue: <what is wrong>
|
|
20
|
+
- Recommendation: <specific fix>
|
|
21
|
+
|
|
22
|
+
If no issues are found, say so explicitly.
|
|
23
|
+
"""
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
name = "implement"
|
|
2
|
+
description = "Workspace-write Trellis implementer that follows specs and keeps generated templates in sync."
|
|
3
|
+
sandbox_mode = "workspace-write"
|
|
4
|
+
|
|
5
|
+
developer_instructions = """
|
|
6
|
+
You are the Trellis implementer agent.
|
|
7
|
+
|
|
8
|
+
Rules:
|
|
9
|
+
- Read before write. Follow `.trellis/spec/` guidance relevant to the task.
|
|
10
|
+
- Keep changes focused on the requested scope.
|
|
11
|
+
- When touching platform registries or template lists, search first so you do not miss mirrored update paths.
|
|
12
|
+
- If you modify `.trellis/scripts/`, keep `packages/cli/src/templates/trellis/scripts/` in sync.
|
|
13
|
+
- Do not make destructive git changes unless explicitly asked.
|
|
14
|
+
|
|
15
|
+
Before finishing, summarize:
|
|
16
|
+
- Files changed
|
|
17
|
+
- Tests/checks run
|
|
18
|
+
- Remaining risks or follow-ups
|
|
19
|
+
"""
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
name = "research"
|
|
2
|
+
description = "Read-only Trellis researcher for specs, code patterns, and affected files."
|
|
3
|
+
sandbox_mode = "read-only"
|
|
4
|
+
|
|
5
|
+
developer_instructions = """
|
|
6
|
+
You are the Trellis researcher agent.
|
|
7
|
+
|
|
8
|
+
Responsibilities:
|
|
9
|
+
- Read `.trellis/workflow.md`, relevant `.trellis/spec/` files, and target code before proposing changes.
|
|
10
|
+
- Identify the smallest set of relevant specs, code patterns, and files to modify.
|
|
11
|
+
- Call out cross-layer or cross-platform risks when they are real.
|
|
12
|
+
- Do not edit files.
|
|
13
|
+
|
|
14
|
+
Output format:
|
|
15
|
+
## Relevant Specs
|
|
16
|
+
- <path>: <why>
|
|
17
|
+
|
|
18
|
+
## Code Patterns Found
|
|
19
|
+
- <pattern>: <file>
|
|
20
|
+
|
|
21
|
+
## Files to Modify
|
|
22
|
+
- <path>: <change>
|
|
23
|
+
|
|
24
|
+
## Risks / Follow-ups
|
|
25
|
+
- <none or concrete note>
|
|
26
|
+
"""
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: parallel
|
|
3
|
+
description: "Multi-agent pipeline orchestrator that plans and dispatches parallel development tasks to worktree agents. Reads project context, configures task directories with PRDs and jsonl context files, and launches isolated coding agents. Use when multiple independent features need parallel development, orchestrating worktree agents, or managing multi-agent coding pipelines."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Multi-Agent Pipeline Orchestrator
|
|
7
|
+
|
|
8
|
+
You are the Multi-Agent Pipeline Orchestrator Agent, running in the main repository, responsible for collaborating with users to manage parallel development tasks.
|
|
9
|
+
|
|
10
|
+
## Role Definition
|
|
11
|
+
|
|
12
|
+
- **You are in the main repository**, not in a worktree
|
|
13
|
+
- **You don't write code directly** - code work is done by agents in worktrees
|
|
14
|
+
- **You are responsible for planning and dispatching**: discuss requirements, create plans, configure context, start worktree agents
|
|
15
|
+
- **Delegate complex analysis to research**: find specs, inspect code structure, and reduce ambiguity before dispatch
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Operation Types
|
|
20
|
+
|
|
21
|
+
Operations in this document are categorized as:
|
|
22
|
+
|
|
23
|
+
| Marker | Meaning | Executor |
|
|
24
|
+
|--------|---------|----------|
|
|
25
|
+
| `[AI]` | Bash scripts or tool calls executed by AI | You (AI) |
|
|
26
|
+
| `[USER]` | Skills executed by user | User |
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Startup Flow
|
|
31
|
+
|
|
32
|
+
### Step 1: Understand Trellis Workflow `[AI]`
|
|
33
|
+
|
|
34
|
+
First, read the workflow guide to understand the development process:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
cat .trellis/workflow.md # Development process, conventions, and quick start guide
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Step 2: Get Current Status `[AI]`
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
python3 ./.trellis/scripts/get_context.py
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Step 3: Read Project Guidelines `[AI]`
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
python3 ./.trellis/scripts/get_context.py --mode packages # Discover available spec layers
|
|
50
|
+
cat .trellis/spec/guides/index.md # Thinking guides
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Step 4: Ask User for Requirements
|
|
54
|
+
|
|
55
|
+
Ask the user:
|
|
56
|
+
|
|
57
|
+
1. What feature to develop?
|
|
58
|
+
2. Which modules are involved?
|
|
59
|
+
3. Development type? (backend / frontend / fullstack)
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## Planning: Choose Your Approach
|
|
64
|
+
|
|
65
|
+
Based on requirement complexity, choose one of these approaches:
|
|
66
|
+
|
|
67
|
+
### Option A: Plan Agent (Recommended for complex features) `[AI]`
|
|
68
|
+
|
|
69
|
+
Use when:
|
|
70
|
+
- Requirements need analysis and validation
|
|
71
|
+
- Multiple modules or cross-layer changes
|
|
72
|
+
- Unclear scope that needs research
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
python3 ./.trellis/scripts/multi_agent/plan.py \
|
|
76
|
+
--name "<feature-name>" \
|
|
77
|
+
--type "<backend|frontend|fullstack>" \
|
|
78
|
+
--requirement "<user requirement description>" \
|
|
79
|
+
--platform codex
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Plan Agent will:
|
|
83
|
+
1. Evaluate requirement validity (may reject if unclear/too large)
|
|
84
|
+
2. Analyze the codebase and specs
|
|
85
|
+
3. Create and configure task directory
|
|
86
|
+
4. Write `prd.md` with acceptance criteria
|
|
87
|
+
5. Output a ready-to-use task directory
|
|
88
|
+
|
|
89
|
+
After `plan.py` completes, start the worktree agent:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
python3 ./.trellis/scripts/multi_agent/start.py "$TASK_DIR" --platform codex
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Option B: Manual Configuration (For simple or already-clear features) `[AI]`
|
|
96
|
+
|
|
97
|
+
Use when:
|
|
98
|
+
- Requirements are already clear and specific
|
|
99
|
+
- You know exactly which files are involved
|
|
100
|
+
- Simple, well-scoped changes
|
|
101
|
+
|
|
102
|
+
#### Step 1: Create Task Directory
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
TASK_DIR=$(python3 ./.trellis/scripts/task.py create "<title>" --slug <task-name>)
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
#### Step 2: Configure Task
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
python3 ./.trellis/scripts/task.py init-context "$TASK_DIR" <dev_type>
|
|
112
|
+
python3 ./.trellis/scripts/task.py set-branch "$TASK_DIR" feature/<name>
|
|
113
|
+
python3 ./.trellis/scripts/task.py set-scope "$TASK_DIR" <scope>
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
#### Step 3: Add Context
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
python3 ./.trellis/scripts/task.py add-context "$TASK_DIR" implement "<path>" "<reason>"
|
|
120
|
+
python3 ./.trellis/scripts/task.py add-context "$TASK_DIR" check "<path>" "<reason>"
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
#### Step 4: Create `prd.md`
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
cat > "$TASK_DIR/prd.md" << 'END_PRD'
|
|
127
|
+
# Feature: <name>
|
|
128
|
+
|
|
129
|
+
## Requirements
|
|
130
|
+
- ...
|
|
131
|
+
|
|
132
|
+
## Acceptance Criteria
|
|
133
|
+
- ...
|
|
134
|
+
END_PRD
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
#### Step 5: Validate and Start
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
python3 ./.trellis/scripts/task.py validate "$TASK_DIR"
|
|
141
|
+
python3 ./.trellis/scripts/multi_agent/start.py "$TASK_DIR" --platform codex
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## After Starting: Report Status
|
|
147
|
+
|
|
148
|
+
Tell the user the agent has started and provide monitoring commands.
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## User Available Skills `[USER]`
|
|
153
|
+
|
|
154
|
+
The following skills are for users (not AI):
|
|
155
|
+
|
|
156
|
+
| Skill | Description |
|
|
157
|
+
|-------|-------------|
|
|
158
|
+
| `$parallel` | Start Multi-Agent Pipeline (this skill) |
|
|
159
|
+
| `$start` | Start normal development mode (single process) |
|
|
160
|
+
| `$record-session` | Record session progress |
|
|
161
|
+
| `$finish-work` | Pre-completion checklist |
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## Monitoring Commands (for user reference)
|
|
166
|
+
|
|
167
|
+
Tell the user they can use these commands to monitor:
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
python3 ./.trellis/scripts/multi_agent/status.py # Overview
|
|
171
|
+
python3 ./.trellis/scripts/multi_agent/status.py --log <name> # View log
|
|
172
|
+
python3 ./.trellis/scripts/multi_agent/status.py --watch <name> # Real-time monitoring
|
|
173
|
+
python3 ./.trellis/scripts/multi_agent/cleanup.py <branch> # Cleanup worktree
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## Pipeline Phases
|
|
179
|
+
|
|
180
|
+
The dispatch agent in the worktree will automatically execute:
|
|
181
|
+
|
|
182
|
+
1. implement → Implement feature
|
|
183
|
+
2. check → Check code quality
|
|
184
|
+
3. finish → Final verification
|
|
185
|
+
4. create-pr → Create PR
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
## Core Rules
|
|
190
|
+
|
|
191
|
+
- **Don't write code directly** - delegate to agents in worktrees
|
|
192
|
+
- **Don't execute git commit** - the flow handles it in the worktree pipeline
|
|
193
|
+
- **Delegate complex analysis before dispatch** - find specs, inspect code structure, and reduce ambiguity
|
|
194
|
+
- **Prefer focused tasks** - parallelism works best when each worktree has a narrow scope
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
"""
|
|
4
|
+
Codex Session Start Hook - Inject Trellis context into Codex sessions.
|
|
5
|
+
|
|
6
|
+
Output format follows Codex hook protocol:
|
|
7
|
+
stdout JSON → { hookSpecificOutput: { hookEventName: "SessionStart", additionalContext: "..." } }
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
import json
|
|
13
|
+
import os
|
|
14
|
+
import subprocess
|
|
15
|
+
import sys
|
|
16
|
+
import warnings
|
|
17
|
+
from io import StringIO
|
|
18
|
+
from pathlib import Path
|
|
19
|
+
|
|
20
|
+
warnings.filterwarnings("ignore")
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def should_skip_injection() -> bool:
|
|
24
|
+
return os.environ.get("CODEX_NON_INTERACTIVE") == "1"
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def read_file(path: Path, fallback: str = "") -> str:
|
|
28
|
+
try:
|
|
29
|
+
return path.read_text(encoding="utf-8")
|
|
30
|
+
except (FileNotFoundError, PermissionError):
|
|
31
|
+
return fallback
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def run_script(script_path: Path) -> str:
|
|
35
|
+
try:
|
|
36
|
+
env = os.environ.copy()
|
|
37
|
+
env["PYTHONIOENCODING"] = "utf-8"
|
|
38
|
+
cmd = [sys.executable, "-W", "ignore", str(script_path)]
|
|
39
|
+
result = subprocess.run(
|
|
40
|
+
cmd,
|
|
41
|
+
capture_output=True,
|
|
42
|
+
text=True,
|
|
43
|
+
encoding="utf-8",
|
|
44
|
+
errors="replace",
|
|
45
|
+
timeout=5,
|
|
46
|
+
cwd=str(script_path.parent.parent.parent),
|
|
47
|
+
env=env,
|
|
48
|
+
)
|
|
49
|
+
return result.stdout if result.returncode == 0 else "No context available"
|
|
50
|
+
except (subprocess.TimeoutExpired, FileNotFoundError, PermissionError):
|
|
51
|
+
return "No context available"
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def _get_task_status(trellis_dir: Path) -> str:
|
|
55
|
+
current_task_file = trellis_dir / ".current-task"
|
|
56
|
+
if not current_task_file.is_file():
|
|
57
|
+
return "Status: NO ACTIVE TASK\nNext: Describe what you want to work on"
|
|
58
|
+
|
|
59
|
+
task_ref = current_task_file.read_text(encoding="utf-8").strip()
|
|
60
|
+
if not task_ref:
|
|
61
|
+
return "Status: NO ACTIVE TASK\nNext: Describe what you want to work on"
|
|
62
|
+
|
|
63
|
+
if Path(task_ref).is_absolute():
|
|
64
|
+
task_dir = Path(task_ref)
|
|
65
|
+
elif task_ref.startswith(".trellis/"):
|
|
66
|
+
task_dir = trellis_dir.parent / task_ref
|
|
67
|
+
else:
|
|
68
|
+
task_dir = trellis_dir / "tasks" / task_ref
|
|
69
|
+
if not task_dir.is_dir():
|
|
70
|
+
return f"Status: STALE POINTER\nTask: {task_ref}\nNext: Task directory not found. Run: python3 ./.trellis/scripts/task.py finish"
|
|
71
|
+
|
|
72
|
+
task_json_path = task_dir / "task.json"
|
|
73
|
+
task_data: dict = {}
|
|
74
|
+
if task_json_path.is_file():
|
|
75
|
+
try:
|
|
76
|
+
task_data = json.loads(task_json_path.read_text(encoding="utf-8"))
|
|
77
|
+
except (json.JSONDecodeError, PermissionError):
|
|
78
|
+
pass
|
|
79
|
+
|
|
80
|
+
task_title = task_data.get("title", task_ref)
|
|
81
|
+
task_status = task_data.get("status", "unknown")
|
|
82
|
+
|
|
83
|
+
if task_status == "completed":
|
|
84
|
+
return f"Status: COMPLETED\nTask: {task_title}\nNext: Archive with `python3 ./.trellis/scripts/task.py archive {task_dir.name}` or start a new task"
|
|
85
|
+
|
|
86
|
+
has_context = False
|
|
87
|
+
for jsonl_name in ("implement.jsonl", "check.jsonl", "spec.jsonl"):
|
|
88
|
+
jsonl_path = task_dir / jsonl_name
|
|
89
|
+
if jsonl_path.is_file() and jsonl_path.stat().st_size > 0:
|
|
90
|
+
has_context = True
|
|
91
|
+
break
|
|
92
|
+
|
|
93
|
+
has_prd = (task_dir / "prd.md").is_file()
|
|
94
|
+
|
|
95
|
+
if not has_prd:
|
|
96
|
+
return f"Status: NOT READY\nTask: {task_title}\nMissing: prd.md not created\nNext: Write PRD, then research → init-context → start"
|
|
97
|
+
|
|
98
|
+
if not has_context:
|
|
99
|
+
return f"Status: NOT READY\nTask: {task_title}\nMissing: Context not configured (no jsonl files)\nNext: Complete Phase 2 (research → init-context → start) before implementing"
|
|
100
|
+
|
|
101
|
+
return f"Status: READY\nTask: {task_title}\nNext: Continue with implement or check"
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def main() -> None:
|
|
105
|
+
if should_skip_injection():
|
|
106
|
+
sys.exit(0)
|
|
107
|
+
|
|
108
|
+
# Read hook input from stdin
|
|
109
|
+
try:
|
|
110
|
+
hook_input = json.loads(sys.stdin.read())
|
|
111
|
+
project_dir = Path(hook_input.get("cwd", ".")).resolve()
|
|
112
|
+
except (json.JSONDecodeError, KeyError):
|
|
113
|
+
project_dir = Path(".").resolve()
|
|
114
|
+
|
|
115
|
+
trellis_dir = project_dir / ".trellis"
|
|
116
|
+
codex_dir = project_dir / ".codex"
|
|
117
|
+
|
|
118
|
+
output = StringIO()
|
|
119
|
+
|
|
120
|
+
output.write("""<session-context>
|
|
121
|
+
You are starting a new session in a Trellis-managed project.
|
|
122
|
+
Read and follow all instructions below carefully.
|
|
123
|
+
</session-context>
|
|
124
|
+
|
|
125
|
+
""")
|
|
126
|
+
|
|
127
|
+
output.write("<current-state>\n")
|
|
128
|
+
context_script = trellis_dir / "scripts" / "get_context.py"
|
|
129
|
+
output.write(run_script(context_script))
|
|
130
|
+
output.write("\n</current-state>\n\n")
|
|
131
|
+
|
|
132
|
+
output.write("<workflow>\n")
|
|
133
|
+
workflow_content = read_file(trellis_dir / "workflow.md", "No workflow.md found")
|
|
134
|
+
output.write(workflow_content)
|
|
135
|
+
output.write("\n</workflow>\n\n")
|
|
136
|
+
|
|
137
|
+
output.write("<guidelines>\n")
|
|
138
|
+
output.write("**Note**: The guidelines below are index files — they list available guideline documents and their locations.\n")
|
|
139
|
+
output.write("During actual development, you MUST read the specific guideline files listed in each index's Pre-Development Checklist.\n\n")
|
|
140
|
+
|
|
141
|
+
spec_dir = trellis_dir / "spec"
|
|
142
|
+
if spec_dir.is_dir():
|
|
143
|
+
for sub in sorted(spec_dir.iterdir()):
|
|
144
|
+
if not sub.is_dir() or sub.name.startswith("."):
|
|
145
|
+
continue
|
|
146
|
+
|
|
147
|
+
if sub.name == "guides":
|
|
148
|
+
index_file = sub / "index.md"
|
|
149
|
+
if index_file.is_file():
|
|
150
|
+
output.write(f"## {sub.name}\n")
|
|
151
|
+
output.write(read_file(index_file))
|
|
152
|
+
output.write("\n\n")
|
|
153
|
+
continue
|
|
154
|
+
|
|
155
|
+
index_file = sub / "index.md"
|
|
156
|
+
if index_file.is_file():
|
|
157
|
+
output.write(f"## {sub.name}\n")
|
|
158
|
+
output.write(read_file(index_file))
|
|
159
|
+
output.write("\n\n")
|
|
160
|
+
else:
|
|
161
|
+
for nested in sorted(sub.iterdir()):
|
|
162
|
+
if not nested.is_dir():
|
|
163
|
+
continue
|
|
164
|
+
nested_index = nested / "index.md"
|
|
165
|
+
if nested_index.is_file():
|
|
166
|
+
output.write(f"## {sub.name}/{nested.name}\n")
|
|
167
|
+
output.write(read_file(nested_index))
|
|
168
|
+
output.write("\n\n")
|
|
169
|
+
|
|
170
|
+
output.write("</guidelines>\n\n")
|
|
171
|
+
|
|
172
|
+
# Inject start skill as instructions (Codex uses skills, not slash commands)
|
|
173
|
+
start_skill = codex_dir / "skills" / "start" / "SKILL.md"
|
|
174
|
+
if not start_skill.is_file():
|
|
175
|
+
start_skill = project_dir / ".agents" / "skills" / "start" / "SKILL.md"
|
|
176
|
+
if start_skill.is_file():
|
|
177
|
+
output.write("<instructions>\n")
|
|
178
|
+
output.write(read_file(start_skill))
|
|
179
|
+
output.write("\n</instructions>\n\n")
|
|
180
|
+
|
|
181
|
+
task_status = _get_task_status(trellis_dir)
|
|
182
|
+
output.write(f"<task-status>\n{task_status}\n</task-status>\n\n")
|
|
183
|
+
|
|
184
|
+
output.write("""<ready>
|
|
185
|
+
Context loaded. Steps 1-3 (workflow, context, guidelines) are already injected above — do NOT re-read them.
|
|
186
|
+
Start from Step 4. Wait for user's first message, then follow <instructions> to handle their request.
|
|
187
|
+
If there is an active task, ask whether to continue it.
|
|
188
|
+
</ready>""")
|
|
189
|
+
|
|
190
|
+
context = output.getvalue()
|
|
191
|
+
result = {
|
|
192
|
+
"suppressOutput": True,
|
|
193
|
+
"systemMessage": f"Trellis context injected ({len(context)} chars)",
|
|
194
|
+
"hookSpecificOutput": {
|
|
195
|
+
"hookEventName": "SessionStart",
|
|
196
|
+
"additionalContext": context,
|
|
197
|
+
},
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
print(json.dumps(result, ensure_ascii=False), flush=True)
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
if __name__ == "__main__":
|
|
204
|
+
main()
|
|
@@ -1,18 +1,40 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Codex
|
|
2
|
+
* Codex templates
|
|
3
3
|
*
|
|
4
4
|
* These are GENERIC templates for user projects.
|
|
5
|
-
* Do NOT use Trellis project's own .agents/skills
|
|
5
|
+
* Do NOT use Trellis project's own .agents/skills or .codex directories
|
|
6
|
+
* (which may be customized).
|
|
6
7
|
*
|
|
7
8
|
* Directory structure:
|
|
8
9
|
* codex/
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
10
|
+
* ├── agents/ # Project-scoped Codex custom agents (.toml)
|
|
11
|
+
* ├── codex-skills/ # Codex-specific skills → .codex/skills/
|
|
12
|
+
* ├── skills/ # Shared skills → .agents/skills/
|
|
13
|
+
* └── config.toml # Project-scoped Codex config
|
|
12
14
|
*/
|
|
13
15
|
export interface SkillTemplate {
|
|
14
16
|
name: string;
|
|
15
17
|
content: string;
|
|
16
18
|
}
|
|
19
|
+
export interface AgentTemplate {
|
|
20
|
+
name: string;
|
|
21
|
+
content: string;
|
|
22
|
+
}
|
|
23
|
+
export interface ConfigTemplate {
|
|
24
|
+
targetPath: string;
|
|
25
|
+
content: string;
|
|
26
|
+
}
|
|
17
27
|
export declare function getAllSkills(): SkillTemplate[];
|
|
28
|
+
export declare function getAllAgents(): AgentTemplate[];
|
|
29
|
+
/**
|
|
30
|
+
* Get Codex-specific skills (installed to .codex/skills/, not shared .agents/skills/).
|
|
31
|
+
*/
|
|
32
|
+
export declare function getAllCodexSkills(): SkillTemplate[];
|
|
33
|
+
export interface HookTemplate {
|
|
34
|
+
name: string;
|
|
35
|
+
content: string;
|
|
36
|
+
}
|
|
37
|
+
export declare function getAllHooks(): HookTemplate[];
|
|
38
|
+
export declare function getHooksConfig(): string;
|
|
39
|
+
export declare function getConfigTemplate(): ConfigTemplate;
|
|
18
40
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/templates/codex/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/templates/codex/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAgCH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,YAAY,IAAI,aAAa,EAAE,CAS9C;AAED,wBAAgB,YAAY,IAAI,aAAa,EAAE,CAc9C;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,aAAa,EAAE,CASnD;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,WAAW,IAAI,YAAY,EAAE,CAW5C;AAED,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,wBAAgB,iBAAiB,IAAI,cAAc,CAKlD"}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Codex
|
|
2
|
+
* Codex templates
|
|
3
3
|
*
|
|
4
4
|
* These are GENERIC templates for user projects.
|
|
5
|
-
* Do NOT use Trellis project's own .agents/skills
|
|
5
|
+
* Do NOT use Trellis project's own .agents/skills or .codex directories
|
|
6
|
+
* (which may be customized).
|
|
6
7
|
*
|
|
7
8
|
* Directory structure:
|
|
8
9
|
* codex/
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
10
|
+
* ├── agents/ # Project-scoped Codex custom agents (.toml)
|
|
11
|
+
* ├── codex-skills/ # Codex-specific skills → .codex/skills/
|
|
12
|
+
* ├── skills/ # Shared skills → .agents/skills/
|
|
13
|
+
* └── config.toml # Project-scoped Codex config
|
|
12
14
|
*/
|
|
13
15
|
import { readdirSync, readFileSync } from "node:fs";
|
|
14
16
|
import { dirname, join } from "node:path";
|
|
@@ -18,9 +20,9 @@ const __dirname = dirname(__filename);
|
|
|
18
20
|
function readTemplate(relativePath) {
|
|
19
21
|
return readFileSync(join(__dirname, relativePath), "utf-8");
|
|
20
22
|
}
|
|
21
|
-
function
|
|
23
|
+
function listDirectories(dir) {
|
|
22
24
|
try {
|
|
23
|
-
return readdirSync(join(__dirname,
|
|
25
|
+
return readdirSync(join(__dirname, dir), { withFileTypes: true })
|
|
24
26
|
.filter((entry) => entry.isDirectory())
|
|
25
27
|
.map((entry) => entry.name)
|
|
26
28
|
.sort();
|
|
@@ -29,12 +31,62 @@ function listSkillNames() {
|
|
|
29
31
|
return [];
|
|
30
32
|
}
|
|
31
33
|
}
|
|
34
|
+
function listFiles(dir) {
|
|
35
|
+
try {
|
|
36
|
+
return readdirSync(join(__dirname, dir)).sort();
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return [];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
32
42
|
export function getAllSkills() {
|
|
33
43
|
const skills = [];
|
|
34
|
-
for (const name of
|
|
44
|
+
for (const name of listDirectories("skills")) {
|
|
35
45
|
const content = readTemplate(`skills/${name}/SKILL.md`);
|
|
36
46
|
skills.push({ name, content });
|
|
37
47
|
}
|
|
38
48
|
return skills;
|
|
39
49
|
}
|
|
50
|
+
export function getAllAgents() {
|
|
51
|
+
const agents = [];
|
|
52
|
+
for (const file of listFiles("agents")) {
|
|
53
|
+
if (!file.endsWith(".toml")) {
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
const name = file.replace(".toml", "");
|
|
57
|
+
const content = readTemplate(`agents/${file}`);
|
|
58
|
+
agents.push({ name, content });
|
|
59
|
+
}
|
|
60
|
+
return agents;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Get Codex-specific skills (installed to .codex/skills/, not shared .agents/skills/).
|
|
64
|
+
*/
|
|
65
|
+
export function getAllCodexSkills() {
|
|
66
|
+
const skills = [];
|
|
67
|
+
for (const name of listDirectories("codex-skills")) {
|
|
68
|
+
const content = readTemplate(`codex-skills/${name}/SKILL.md`);
|
|
69
|
+
skills.push({ name, content });
|
|
70
|
+
}
|
|
71
|
+
return skills;
|
|
72
|
+
}
|
|
73
|
+
export function getAllHooks() {
|
|
74
|
+
const hooks = [];
|
|
75
|
+
for (const file of listFiles("hooks")) {
|
|
76
|
+
if (!file.endsWith(".py")) {
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
hooks.push({ name: file, content: readTemplate(`hooks/${file}`) });
|
|
80
|
+
}
|
|
81
|
+
return hooks;
|
|
82
|
+
}
|
|
83
|
+
export function getHooksConfig() {
|
|
84
|
+
return readTemplate("hooks.json");
|
|
85
|
+
}
|
|
86
|
+
export function getConfigTemplate() {
|
|
87
|
+
return {
|
|
88
|
+
targetPath: "config.toml",
|
|
89
|
+
content: readTemplate("config.toml"),
|
|
90
|
+
};
|
|
91
|
+
}
|
|
40
92
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/templates/codex/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/templates/codex/index.ts"],"names":[],"mappings":"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"}
|