@mindfoldhq/trellis 0.1.1 → 0.1.2
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/{templates/agents/bodies → .claude/agents}/check.md +7 -0
- package/dist/{templates/agents/bodies → .claude/agents}/debug.md +7 -0
- package/dist/{templates/agents/bodies → .claude/agents}/dispatch.md +11 -8
- package/dist/{templates/agents/bodies → .claude/agents}/implement.md +7 -0
- package/dist/.claude/agents/plan.md +396 -0
- package/dist/{templates/agents/bodies → .claude/agents}/research.md +7 -0
- package/dist/{templates/commands/common/check-cross-layer.txt → .claude/commands/check-cross-layer.md} +29 -29
- package/dist/{templates → .claude}/hooks/inject-subagent-context.py +63 -0
- package/dist/.cursor/commands/before-backend-dev.md +13 -0
- package/dist/.cursor/commands/before-frontend-dev.md +13 -0
- package/dist/.cursor/commands/break-loop.md +107 -0
- package/dist/.cursor/commands/check-backend.md +13 -0
- package/dist/.cursor/commands/check-cross-layer.md +153 -0
- package/dist/.cursor/commands/check-frontend.md +13 -0
- package/dist/.cursor/commands/create-command.md +154 -0
- package/dist/.cursor/commands/finish-work.md +129 -0
- package/dist/.cursor/commands/integrate-skill.md +219 -0
- package/dist/.cursor/commands/onboard-developer.md +355 -0
- package/dist/.cursor/commands/record-agent-flow.md +62 -0
- package/dist/.trellis/scripts/common/phase.sh +150 -0
- package/dist/{templates/scripts/feature.sh.txt → .trellis/scripts/feature.sh} +8 -3
- package/dist/{templates/scripts/multi-agent/cleanup.sh.txt → .trellis/scripts/multi-agent/cleanup.sh} +107 -18
- package/dist/.trellis/scripts/multi-agent/create-pr.sh +241 -0
- package/dist/.trellis/scripts/multi-agent/plan.sh +232 -0
- package/dist/{templates/scripts/multi-agent/start.sh.txt → .trellis/scripts/multi-agent/start.sh} +21 -0
- package/dist/{templates/scripts/multi-agent/status.sh.txt → .trellis/scripts/multi-agent/status.sh} +282 -10
- package/dist/.trellis/structure/backend/database-guidelines.md +51 -0
- package/dist/.trellis/structure/backend/directory-structure.md +209 -0
- package/dist/.trellis/structure/backend/error-handling.md +278 -0
- package/dist/.trellis/structure/backend/index.md +38 -0
- package/dist/.trellis/structure/backend/logging-guidelines.md +266 -0
- package/dist/.trellis/structure/backend/quality-guidelines.md +313 -0
- package/dist/.trellis/structure/frontend/component-guidelines.md +59 -0
- package/dist/.trellis/structure/frontend/directory-structure.md +54 -0
- package/dist/.trellis/structure/frontend/hook-guidelines.md +51 -0
- package/dist/.trellis/structure/frontend/index.md +39 -0
- package/dist/.trellis/structure/frontend/quality-guidelines.md +51 -0
- package/dist/.trellis/structure/frontend/state-management.md +51 -0
- package/dist/.trellis/structure/frontend/type-safety.md +51 -0
- package/dist/.trellis/structure/guides/code-reuse-thinking-guide.md +92 -0
- package/dist/.trellis/structure/guides/cross-layer-thinking-guide.md +94 -0
- package/dist/.trellis/structure/guides/index.md +79 -0
- package/dist/{templates/scripts/worktree.yaml.txt → .trellis/worktree.yaml} +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +5 -16
- package/dist/commands/init.js.map +1 -1
- package/dist/configurators/claude.d.ts +17 -17
- package/dist/configurators/claude.d.ts.map +1 -1
- package/dist/configurators/claude.js +29 -59
- package/dist/configurators/claude.js.map +1 -1
- package/dist/configurators/cursor.d.ts +3 -3
- package/dist/configurators/cursor.d.ts.map +1 -1
- package/dist/configurators/cursor.js +11 -15
- package/dist/configurators/cursor.js.map +1 -1
- package/dist/configurators/opencode.d.ts +11 -10
- package/dist/configurators/opencode.d.ts.map +1 -1
- package/dist/configurators/opencode.js +14 -33
- package/dist/configurators/opencode.js.map +1 -1
- package/dist/configurators/workflow.d.ts +7 -0
- package/dist/configurators/workflow.d.ts.map +1 -1
- package/dist/configurators/workflow.js +30 -99
- package/dist/configurators/workflow.js.map +1 -1
- package/dist/templates/extract.d.ts +73 -8
- package/dist/templates/extract.d.ts.map +1 -1
- package/dist/templates/extract.js +149 -10
- package/dist/templates/extract.js.map +1 -1
- package/dist/templates/markdown/index.d.ts +5 -1
- package/dist/templates/markdown/index.d.ts.map +1 -1
- package/dist/templates/markdown/index.js +54 -26
- package/dist/templates/markdown/index.js.map +1 -1
- package/dist/templates/markdown/structure/backend/directory-structure.md.txt +6 -6
- package/dist/templates/markdown/structure/backend/error-handling.md.txt +8 -8
- package/dist/templates/markdown/structure/backend/index.md.txt +5 -5
- package/dist/templates/markdown/structure/backend/logging-guidelines.md.txt +8 -8
- package/dist/templates/markdown/structure/frontend/index.md.txt +6 -6
- package/dist/templates/markdown/structure/guides/cross-layer-thinking-guide.md.txt +5 -5
- package/dist/templates/markdown/structure/guides/index.md.txt +7 -7
- package/dist/templates/markdown/worktree.yaml.txt +58 -0
- package/package.json +1 -1
- package/dist/configurators/templates.d.ts +0 -40
- package/dist/configurators/templates.d.ts.map +0 -1
- package/dist/configurators/templates.js +0 -67
- package/dist/configurators/templates.js.map +0 -1
- package/dist/templates/agents/index.d.ts +0 -42
- package/dist/templates/agents/index.d.ts.map +0 -1
- package/dist/templates/agents/index.js +0 -148
- package/dist/templates/agents/index.js.map +0 -1
- package/dist/templates/agents/metadata.d.ts +0 -48
- package/dist/templates/agents/metadata.d.ts.map +0 -1
- package/dist/templates/agents/metadata.js +0 -101
- package/dist/templates/agents/metadata.js.map +0 -1
- package/dist/templates/commands/index.d.ts +0 -48
- package/dist/templates/commands/index.d.ts.map +0 -1
- package/dist/templates/commands/index.js +0 -167
- package/dist/templates/commands/index.js.map +0 -1
- package/dist/templates/commands/opencode/start.md.txt +0 -127
- package/dist/templates/hooks/index.d.ts +0 -33
- package/dist/templates/hooks/index.d.ts.map +0 -1
- package/dist/templates/hooks/index.js +0 -53
- package/dist/templates/hooks/index.js.map +0 -1
- package/dist/templates/markdown/gitignore.txt +0 -3
- package/dist/templates/scripts/index.d.ts +0 -36
- package/dist/templates/scripts/index.d.ts.map +0 -1
- package/dist/templates/scripts/index.js +0 -41
- package/dist/templates/scripts/index.js.map +0 -1
- /package/dist/{templates/commands/common/before-backend-dev.txt → .claude/commands/before-backend-dev.md} +0 -0
- /package/dist/{templates/commands/common/before-frontend-dev.txt → .claude/commands/before-frontend-dev.md} +0 -0
- /package/dist/{templates/commands/common/break-loop.txt → .claude/commands/break-loop.md} +0 -0
- /package/dist/{templates/commands/common/check-backend.txt → .claude/commands/check-backend.md} +0 -0
- /package/dist/{templates/commands/common/check-frontend.txt → .claude/commands/check-frontend.md} +0 -0
- /package/dist/{templates/commands/common/create-command.txt → .claude/commands/create-command.md} +0 -0
- /package/dist/{templates/commands/common/finish-work.txt → .claude/commands/finish-work.md} +0 -0
- /package/dist/{templates/commands/common/integrate-skill.txt → .claude/commands/integrate-skill.md} +0 -0
- /package/dist/{templates/commands/common/onboard-developer.txt → .claude/commands/onboard-developer.md} +0 -0
- /package/dist/{templates/commands/claude/parallel.md.txt → .claude/commands/parallel.md} +0 -0
- /package/dist/{templates/commands/common/record-agent-flow.txt → .claude/commands/record-agent-flow.md} +0 -0
- /package/dist/{templates/commands/claude/start.md.txt → .claude/commands/start.md} +0 -0
- /package/dist/{templates/hooks → .claude}/settings.json +0 -0
- /package/dist/{templates/commands/cursor/start.md.txt → .cursor/commands/start.md} +0 -0
- /package/dist/{templates/markdown/agent-traces-index.md.txt → .trellis/agent-traces/index.md} +0 -0
- /package/dist/{templates/scripts/add-session.sh.txt → .trellis/scripts/add-session.sh} +0 -0
- /package/dist/{templates/scripts/common/developer.sh.txt → .trellis/scripts/common/developer.sh} +0 -0
- /package/dist/{templates/scripts/common/git-context.sh.txt → .trellis/scripts/common/git-context.sh} +0 -0
- /package/dist/{templates/scripts/common/paths.sh.txt → .trellis/scripts/common/paths.sh} +0 -0
- /package/dist/{templates/scripts/common/worktree.sh.txt → .trellis/scripts/common/worktree.sh} +0 -0
- /package/dist/{templates/scripts/create-bootstrap.sh.txt → .trellis/scripts/create-bootstrap.sh} +0 -0
- /package/dist/{templates/scripts/get-context.sh.txt → .trellis/scripts/get-context.sh} +0 -0
- /package/dist/{templates/scripts/get-developer.sh.txt → .trellis/scripts/get-developer.sh} +0 -0
- /package/dist/{templates/scripts/init-developer.sh.txt → .trellis/scripts/init-developer.sh} +0 -0
- /package/dist/{templates/markdown/workflow.md.txt → .trellis/workflow.md} +0 -0
- /package/dist/templates/markdown/{agents.md.txt → agents.md} +0 -0
- /package/dist/templates/markdown/{init-agent.md.txt → init-agent.md} +0 -0
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: check
|
|
3
|
+
description: |
|
|
4
|
+
Code quality check expert. Reviews code changes against specs and self-fixes issues.
|
|
5
|
+
tools: Read, Write, Edit, Bash, Glob, Grep, mcp__exa__web_search_exa, mcp__exa__get_code_context_exa
|
|
6
|
+
model: opus
|
|
7
|
+
---
|
|
1
8
|
# Check Agent
|
|
2
9
|
|
|
3
10
|
You are the Check Agent in the Trellis workflow.
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: debug
|
|
3
|
+
description: |
|
|
4
|
+
Issue fixing expert. Understands issues, fixes against specs, and verifies fixes. Precise fixes only.
|
|
5
|
+
tools: Read, Write, Edit, Bash, Glob, Grep, mcp__exa__web_search_exa, mcp__exa__get_code_context_exa
|
|
6
|
+
model: sonnet
|
|
7
|
+
---
|
|
1
8
|
# Debug Agent
|
|
2
9
|
|
|
3
10
|
You are the Debug Agent in the Trellis workflow.
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: dispatch
|
|
3
|
+
description: |
|
|
4
|
+
Multi-Agent Pipeline main dispatcher. Pure dispatcher. Only responsible for calling subagents and scripts in phase order.
|
|
5
|
+
tools: Read, Bash, mcp__exa__web_search_exa, mcp__exa__get_code_context_exa
|
|
6
|
+
model: sonnet
|
|
7
|
+
---
|
|
1
8
|
# Dispatch Agent
|
|
2
9
|
|
|
3
10
|
You are the Dispatch Agent in the Multi-Agent Pipeline (pure dispatcher).
|
|
@@ -49,11 +56,7 @@ Get the `next_action` array, which defines the list of phases to execute.
|
|
|
49
56
|
|
|
50
57
|
Execute each step in `phase` order.
|
|
51
58
|
|
|
52
|
-
**
|
|
53
|
-
|
|
54
|
-
```bash
|
|
55
|
-
jq '.current_phase = {N}' ${FEATURE_DIR}/feature.json > ${FEATURE_DIR}/feature.json.tmp && mv ${FEATURE_DIR}/feature.json.tmp ${FEATURE_DIR}/feature.json
|
|
56
|
-
```
|
|
59
|
+
> **Note**: You do NOT need to manually update `current_phase`. The Hook automatically updates it when you call Task with a subagent.
|
|
57
60
|
|
|
58
61
|
---
|
|
59
62
|
|
|
@@ -134,14 +137,14 @@ Hook will auto-inject complete finish-work.md content.
|
|
|
134
137
|
This action creates a Pull Request from the feature branch. Run it via Bash:
|
|
135
138
|
|
|
136
139
|
```bash
|
|
137
|
-
./.trellis/scripts/
|
|
140
|
+
./.trellis/scripts/multi-agent/create-pr.sh
|
|
138
141
|
```
|
|
139
142
|
|
|
140
143
|
This will:
|
|
141
144
|
1. Stage and commit all changes (excluding agent-traces)
|
|
142
145
|
2. Push to origin
|
|
143
146
|
3. Create a Draft PR using `gh pr create`
|
|
144
|
-
4. Update feature.json with status="review" and
|
|
147
|
+
4. Update feature.json with status="review", pr_url, and current_phase
|
|
145
148
|
|
|
146
149
|
**Note**: This is the only action that performs git commit, as it's the final step after all implementation and checks are complete.
|
|
147
150
|
|
|
@@ -201,6 +204,6 @@ If a subagent reports failure, read the output and decide:
|
|
|
201
204
|
## Key Constraints
|
|
202
205
|
|
|
203
206
|
1. **Do not read spec/requirement files directly** - Let Hook inject to subagents
|
|
204
|
-
2. **Only commit via create-pr action** - Use `
|
|
207
|
+
2. **Only commit via create-pr action** - Use `multi-agent/create-pr.sh` at the end of pipeline
|
|
205
208
|
3. **All subagents should use opus model for complex tasks**
|
|
206
209
|
4. **Keep dispatch logic simple** - Complex logic belongs in subagents
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: implement
|
|
3
|
+
description: |
|
|
4
|
+
Code implementation expert. Understands specs and requirements, then implements features. No git commit allowed.
|
|
5
|
+
tools: Read, Write, Edit, Bash, Glob, Grep, mcp__exa__web_search_exa, mcp__exa__get_code_context_exa
|
|
6
|
+
model: opus
|
|
7
|
+
---
|
|
1
8
|
# Implement Agent
|
|
2
9
|
|
|
3
10
|
You are the Implement Agent in the Trellis workflow.
|
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: plan
|
|
3
|
+
description: |
|
|
4
|
+
Multi-Agent Pipeline planner. Analyzes requirements and produces a fully configured feature directory ready for dispatch.
|
|
5
|
+
tools: Read, Bash, Glob, Grep, Task
|
|
6
|
+
model: opus
|
|
7
|
+
---
|
|
8
|
+
# Plan Agent
|
|
9
|
+
|
|
10
|
+
You are the Plan Agent in the Multi-Agent Pipeline.
|
|
11
|
+
|
|
12
|
+
**Your job**: Evaluate requirements and, if valid, transform them into a fully configured feature directory.
|
|
13
|
+
|
|
14
|
+
**You have the power to reject** - If a requirement is unclear, incomplete, unreasonable, or potentially harmful, you MUST refuse to proceed and clean up.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Step 0: Evaluate Requirement (CRITICAL)
|
|
19
|
+
|
|
20
|
+
Before doing ANY work, evaluate the requirement:
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
PLAN_REQUIREMENT = <the requirement from environment>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Reject If:
|
|
27
|
+
|
|
28
|
+
1. **Unclear or Vague**
|
|
29
|
+
- "Make it better" / "Fix the bugs" / "Improve performance"
|
|
30
|
+
- No specific outcome defined
|
|
31
|
+
- Cannot determine what "done" looks like
|
|
32
|
+
|
|
33
|
+
2. **Incomplete Information**
|
|
34
|
+
- Missing critical details to implement
|
|
35
|
+
- References unknown systems or files
|
|
36
|
+
- Depends on decisions not yet made
|
|
37
|
+
|
|
38
|
+
3. **Out of Scope for This Project**
|
|
39
|
+
- Requirement doesn't match the project's purpose
|
|
40
|
+
- Requires changes to external systems
|
|
41
|
+
- Not technically feasible with current architecture
|
|
42
|
+
|
|
43
|
+
4. **Potentially Harmful**
|
|
44
|
+
- Security vulnerabilities (intentional backdoors, data exfiltration)
|
|
45
|
+
- Destructive operations without clear justification
|
|
46
|
+
- Circumventing access controls
|
|
47
|
+
|
|
48
|
+
5. **Too Large / Should Be Split**
|
|
49
|
+
- Multiple unrelated features bundled together
|
|
50
|
+
- Would require touching too many systems
|
|
51
|
+
- Cannot be completed in a reasonable scope
|
|
52
|
+
|
|
53
|
+
### If Rejecting:
|
|
54
|
+
|
|
55
|
+
1. **Update feature.json status to "rejected"**:
|
|
56
|
+
```bash
|
|
57
|
+
jq '.status = "rejected"' "$PLAN_FEATURE_DIR/feature.json" > "$PLAN_FEATURE_DIR/feature.json.tmp" \
|
|
58
|
+
&& mv "$PLAN_FEATURE_DIR/feature.json.tmp" "$PLAN_FEATURE_DIR/feature.json"
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
2. **Write rejection reason to a file** (so user can see it):
|
|
62
|
+
```bash
|
|
63
|
+
cat > "$PLAN_FEATURE_DIR/REJECTED.md" << 'EOF'
|
|
64
|
+
# Plan Rejected
|
|
65
|
+
|
|
66
|
+
## Reason
|
|
67
|
+
<category from above>
|
|
68
|
+
|
|
69
|
+
## Details
|
|
70
|
+
<specific explanation of why this requirement cannot proceed>
|
|
71
|
+
|
|
72
|
+
## Suggestions
|
|
73
|
+
- <what the user should clarify or change>
|
|
74
|
+
- <how to make the requirement actionable>
|
|
75
|
+
|
|
76
|
+
## To Retry
|
|
77
|
+
|
|
78
|
+
1. Delete this directory:
|
|
79
|
+
rm -rf $PLAN_FEATURE_DIR
|
|
80
|
+
|
|
81
|
+
2. Run with revised requirement:
|
|
82
|
+
./.trellis/scripts/multi-agent/plan.sh --name "<name>" --type "<type>" --requirement "<revised requirement>"
|
|
83
|
+
EOF
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
3. **Print summary to stdout** (will be captured in .plan-log):
|
|
87
|
+
```
|
|
88
|
+
=== PLAN REJECTED ===
|
|
89
|
+
|
|
90
|
+
Reason: <category>
|
|
91
|
+
Details: <brief explanation>
|
|
92
|
+
|
|
93
|
+
See: $PLAN_FEATURE_DIR/REJECTED.md
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
4. **Exit immediately** - Do not proceed to Step 1.
|
|
97
|
+
|
|
98
|
+
**The feature directory is kept** with:
|
|
99
|
+
- `feature.json` (status: "rejected")
|
|
100
|
+
- `REJECTED.md` (full explanation)
|
|
101
|
+
- `.plan-log` (execution log)
|
|
102
|
+
|
|
103
|
+
This allows the user to review why it was rejected.
|
|
104
|
+
|
|
105
|
+
### If Accepting:
|
|
106
|
+
|
|
107
|
+
Continue to Step 1. The requirement is:
|
|
108
|
+
- Clear and specific
|
|
109
|
+
- Has a defined outcome
|
|
110
|
+
- Is technically feasible
|
|
111
|
+
- Is appropriately scoped
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## Input
|
|
116
|
+
|
|
117
|
+
You receive input via environment variables (set by plan.sh):
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
PLAN_FEATURE_NAME # Feature name (e.g., "user-auth")
|
|
121
|
+
PLAN_DEV_TYPE # Development type: backend | frontend | fullstack
|
|
122
|
+
PLAN_REQUIREMENT # Requirement description from user
|
|
123
|
+
PLAN_FEATURE_DIR # Pre-created feature directory path
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Read them at startup:
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
echo "Feature: $PLAN_FEATURE_NAME"
|
|
130
|
+
echo "Type: $PLAN_DEV_TYPE"
|
|
131
|
+
echo "Requirement: $PLAN_REQUIREMENT"
|
|
132
|
+
echo "Directory: $PLAN_FEATURE_DIR"
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Output (if accepted)
|
|
136
|
+
|
|
137
|
+
A complete feature directory containing:
|
|
138
|
+
|
|
139
|
+
```
|
|
140
|
+
${PLAN_FEATURE_DIR}/
|
|
141
|
+
├── feature.json # Updated with branch, scope, dev_type
|
|
142
|
+
├── prd.md # Requirements document
|
|
143
|
+
├── implement.jsonl # Implement phase context
|
|
144
|
+
├── check.jsonl # Check phase context
|
|
145
|
+
└── debug.jsonl # Debug phase context
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
## Workflow (After Acceptance)
|
|
151
|
+
|
|
152
|
+
### Step 1: Initialize Context Files
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
./.trellis/scripts/feature.sh init-context "$PLAN_FEATURE_DIR" "$PLAN_DEV_TYPE"
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
This creates base jsonl files with standard specs for the dev type.
|
|
159
|
+
|
|
160
|
+
### Step 2: Analyze Codebase with Research Agent
|
|
161
|
+
|
|
162
|
+
Call research agent to find relevant specs and code patterns:
|
|
163
|
+
|
|
164
|
+
```
|
|
165
|
+
Task(
|
|
166
|
+
subagent_type: "research",
|
|
167
|
+
prompt: "Analyze what specs and code patterns are needed for this task.
|
|
168
|
+
|
|
169
|
+
Task: ${PLAN_REQUIREMENT}
|
|
170
|
+
Dev Type: ${PLAN_DEV_TYPE}
|
|
171
|
+
|
|
172
|
+
Instructions:
|
|
173
|
+
1. Search .trellis/structure/ for relevant spec files
|
|
174
|
+
2. Search the codebase for related modules and patterns
|
|
175
|
+
3. Identify files that should be added to jsonl context
|
|
176
|
+
|
|
177
|
+
Output format (use exactly this format):
|
|
178
|
+
|
|
179
|
+
## implement.jsonl
|
|
180
|
+
- path: <relative file path>, reason: <why needed>
|
|
181
|
+
- path: <relative file path>, reason: <why needed>
|
|
182
|
+
|
|
183
|
+
## check.jsonl
|
|
184
|
+
- path: <relative file path>, reason: <why needed>
|
|
185
|
+
|
|
186
|
+
## debug.jsonl
|
|
187
|
+
- path: <relative file path>, reason: <why needed>
|
|
188
|
+
|
|
189
|
+
## Suggested Scope
|
|
190
|
+
<single word for commit scope, e.g., auth, api, ui>
|
|
191
|
+
|
|
192
|
+
## Technical Notes
|
|
193
|
+
<any important technical considerations for prd.md>",
|
|
194
|
+
model: "opus"
|
|
195
|
+
)
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### Step 3: Add Context Entries
|
|
199
|
+
|
|
200
|
+
Parse research agent output and add entries to jsonl files:
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
# For each entry in implement.jsonl section:
|
|
204
|
+
./.trellis/scripts/feature.sh add-context "$PLAN_FEATURE_DIR" implement "<path>" "<reason>"
|
|
205
|
+
|
|
206
|
+
# For each entry in check.jsonl section:
|
|
207
|
+
./.trellis/scripts/feature.sh add-context "$PLAN_FEATURE_DIR" check "<path>" "<reason>"
|
|
208
|
+
|
|
209
|
+
# For each entry in debug.jsonl section:
|
|
210
|
+
./.trellis/scripts/feature.sh add-context "$PLAN_FEATURE_DIR" debug "<path>" "<reason>"
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### Step 4: Write prd.md
|
|
214
|
+
|
|
215
|
+
Create the requirements document:
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
cat > "$PLAN_FEATURE_DIR/prd.md" << 'EOF'
|
|
219
|
+
# Feature: ${PLAN_FEATURE_NAME}
|
|
220
|
+
|
|
221
|
+
## Overview
|
|
222
|
+
[Brief description of what this feature does]
|
|
223
|
+
|
|
224
|
+
## Requirements
|
|
225
|
+
- [Requirement 1]
|
|
226
|
+
- [Requirement 2]
|
|
227
|
+
- ...
|
|
228
|
+
|
|
229
|
+
## Acceptance Criteria
|
|
230
|
+
- [ ] [Criterion 1]
|
|
231
|
+
- [ ] [Criterion 2]
|
|
232
|
+
- ...
|
|
233
|
+
|
|
234
|
+
## Technical Notes
|
|
235
|
+
[Any technical considerations from research agent]
|
|
236
|
+
|
|
237
|
+
## Out of Scope
|
|
238
|
+
- [What this feature does NOT include]
|
|
239
|
+
EOF
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
**Guidelines for prd.md**:
|
|
243
|
+
- Be specific and actionable
|
|
244
|
+
- Include acceptance criteria that can be verified
|
|
245
|
+
- Add technical notes from research agent
|
|
246
|
+
- Define what's out of scope to prevent scope creep
|
|
247
|
+
|
|
248
|
+
### Step 5: Configure Feature Metadata
|
|
249
|
+
|
|
250
|
+
```bash
|
|
251
|
+
# Set branch name
|
|
252
|
+
./.trellis/scripts/feature.sh set-branch "$PLAN_FEATURE_DIR" "feature/${PLAN_FEATURE_NAME}"
|
|
253
|
+
|
|
254
|
+
# Set scope (from research agent suggestion)
|
|
255
|
+
./.trellis/scripts/feature.sh set-scope "$PLAN_FEATURE_DIR" "<scope>"
|
|
256
|
+
|
|
257
|
+
# Update dev_type in feature.json
|
|
258
|
+
jq --arg type "$PLAN_DEV_TYPE" '.dev_type = $type' \
|
|
259
|
+
"$PLAN_FEATURE_DIR/feature.json" > "$PLAN_FEATURE_DIR/feature.json.tmp" \
|
|
260
|
+
&& mv "$PLAN_FEATURE_DIR/feature.json.tmp" "$PLAN_FEATURE_DIR/feature.json"
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
### Step 6: Validate Configuration
|
|
264
|
+
|
|
265
|
+
```bash
|
|
266
|
+
./.trellis/scripts/feature.sh validate "$PLAN_FEATURE_DIR"
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
If validation fails, fix the invalid paths and re-validate.
|
|
270
|
+
|
|
271
|
+
### Step 7: Output Summary
|
|
272
|
+
|
|
273
|
+
Print a summary for the caller:
|
|
274
|
+
|
|
275
|
+
```bash
|
|
276
|
+
echo "=== Plan Complete ==="
|
|
277
|
+
echo "Feature Directory: $PLAN_FEATURE_DIR"
|
|
278
|
+
echo ""
|
|
279
|
+
echo "Files created:"
|
|
280
|
+
ls -la "$PLAN_FEATURE_DIR"
|
|
281
|
+
echo ""
|
|
282
|
+
echo "Context summary:"
|
|
283
|
+
./.trellis/scripts/feature.sh list-context "$PLAN_FEATURE_DIR"
|
|
284
|
+
echo ""
|
|
285
|
+
echo "Ready for: ./.trellis/scripts/multi-agent/start.sh $PLAN_FEATURE_DIR"
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
---
|
|
289
|
+
|
|
290
|
+
## Key Principles
|
|
291
|
+
|
|
292
|
+
1. **Reject early, reject clearly** - Don't waste time on bad requirements
|
|
293
|
+
2. **Research before configure** - Always call research agent to understand the codebase
|
|
294
|
+
3. **Validate all paths** - Every file in jsonl must exist
|
|
295
|
+
4. **Be specific in prd.md** - Vague requirements lead to wrong implementations
|
|
296
|
+
5. **Include acceptance criteria** - Check agent needs to verify something concrete
|
|
297
|
+
6. **Set appropriate scope** - This affects commit message format
|
|
298
|
+
|
|
299
|
+
---
|
|
300
|
+
|
|
301
|
+
## Error Handling
|
|
302
|
+
|
|
303
|
+
### Research Agent Returns No Results
|
|
304
|
+
|
|
305
|
+
If research agent finds no relevant specs:
|
|
306
|
+
- Use only the base specs from init-context
|
|
307
|
+
- Add a note in prd.md that this is a new area without existing patterns
|
|
308
|
+
|
|
309
|
+
### Path Not Found
|
|
310
|
+
|
|
311
|
+
If add-context fails because path doesn't exist:
|
|
312
|
+
- Skip that entry
|
|
313
|
+
- Log a warning
|
|
314
|
+
- Continue with other entries
|
|
315
|
+
|
|
316
|
+
### Validation Fails
|
|
317
|
+
|
|
318
|
+
If final validation fails:
|
|
319
|
+
- Read the error output
|
|
320
|
+
- Remove invalid entries from jsonl files
|
|
321
|
+
- Re-validate
|
|
322
|
+
|
|
323
|
+
---
|
|
324
|
+
|
|
325
|
+
## Examples
|
|
326
|
+
|
|
327
|
+
### Example: Accepted Requirement
|
|
328
|
+
|
|
329
|
+
```
|
|
330
|
+
Input:
|
|
331
|
+
PLAN_FEATURE_NAME = "add-rate-limiting"
|
|
332
|
+
PLAN_DEV_TYPE = "backend"
|
|
333
|
+
PLAN_REQUIREMENT = "Add rate limiting to API endpoints using a sliding window algorithm. Limit to 100 requests per minute per IP. Return 429 status when exceeded."
|
|
334
|
+
|
|
335
|
+
Result: ACCEPTED - Clear, specific, has defined behavior
|
|
336
|
+
|
|
337
|
+
Output:
|
|
338
|
+
.trellis/agent-traces/xxx/features/17-add-rate-limiting/
|
|
339
|
+
├── feature.json # branch: feature/add-rate-limiting, scope: api
|
|
340
|
+
├── prd.md # Detailed requirements with acceptance criteria
|
|
341
|
+
├── implement.jsonl # Backend specs + existing middleware patterns
|
|
342
|
+
├── check.jsonl # Quality guidelines + API testing specs
|
|
343
|
+
└── debug.jsonl # Error handling specs
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
### Example: Rejected - Vague Requirement
|
|
347
|
+
|
|
348
|
+
```
|
|
349
|
+
Input:
|
|
350
|
+
PLAN_REQUIREMENT = "Make the API faster"
|
|
351
|
+
|
|
352
|
+
Result: REJECTED
|
|
353
|
+
|
|
354
|
+
=== PLAN REJECTED ===
|
|
355
|
+
|
|
356
|
+
Reason: Unclear or Vague
|
|
357
|
+
|
|
358
|
+
Details:
|
|
359
|
+
"Make the API faster" does not specify:
|
|
360
|
+
- Which endpoints need optimization
|
|
361
|
+
- Current performance baseline
|
|
362
|
+
- Target performance metrics
|
|
363
|
+
- Acceptable trade-offs (memory, complexity)
|
|
364
|
+
|
|
365
|
+
Suggestions:
|
|
366
|
+
- Identify specific slow endpoints with response times
|
|
367
|
+
- Define target latency (e.g., "GET /users should respond in <100ms")
|
|
368
|
+
- Specify if caching, query optimization, or architecture changes are acceptable
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
### Example: Rejected - Too Large
|
|
372
|
+
|
|
373
|
+
```
|
|
374
|
+
Input:
|
|
375
|
+
PLAN_REQUIREMENT = "Add user authentication, authorization, password reset, 2FA, OAuth integration, and audit logging"
|
|
376
|
+
|
|
377
|
+
Result: REJECTED
|
|
378
|
+
|
|
379
|
+
=== PLAN REJECTED ===
|
|
380
|
+
|
|
381
|
+
Reason: Too Large / Should Be Split
|
|
382
|
+
|
|
383
|
+
Details:
|
|
384
|
+
This requirement bundles 6 distinct features that should be implemented separately:
|
|
385
|
+
1. User authentication (login/logout)
|
|
386
|
+
2. Authorization (roles/permissions)
|
|
387
|
+
3. Password reset flow
|
|
388
|
+
4. Two-factor authentication
|
|
389
|
+
5. OAuth integration
|
|
390
|
+
6. Audit logging
|
|
391
|
+
|
|
392
|
+
Suggestions:
|
|
393
|
+
- Start with basic authentication first
|
|
394
|
+
- Create separate features for each capability
|
|
395
|
+
- Consider dependencies (auth before authz, etc.)
|
|
396
|
+
```
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: research
|
|
3
|
+
description: |
|
|
4
|
+
Code and tech search expert. Pure research, no code modifications. Finds files, patterns, and tech solutions.
|
|
5
|
+
tools: Read, Glob, Grep, mcp__exa__web_search_exa, mcp__exa__get_code_context_exa
|
|
6
|
+
model: haiku
|
|
7
|
+
---
|
|
1
8
|
# Research Agent
|
|
2
9
|
|
|
3
10
|
You are the Research Agent in the Trellis workflow.
|
|
@@ -35,21 +35,20 @@ Based on your change type, execute relevant checks below:
|
|
|
35
35
|
|
|
36
36
|
**Trigger**: Changes involve 3 or more layers
|
|
37
37
|
|
|
38
|
-
| Layer |
|
|
39
|
-
|
|
40
|
-
| API
|
|
41
|
-
| Service | `services/`, `lib/` |
|
|
42
|
-
| Database | `db/`, `
|
|
43
|
-
|
|
|
44
|
-
|
|
|
45
|
-
| Utility | `utils/`, `lib/` |
|
|
38
|
+
| Layer | Common Locations |
|
|
39
|
+
|-------|------------------|
|
|
40
|
+
| API/Routes | `routes/`, `api/`, `handlers/`, `controllers/` |
|
|
41
|
+
| Service/Business Logic | `services/`, `lib/`, `core/`, `domain/` |
|
|
42
|
+
| Database/Storage | `db/`, `models/`, `repositories/`, `schema/` |
|
|
43
|
+
| UI/Presentation | `components/`, `views/`, `templates/`, `pages/` |
|
|
44
|
+
| Utility | `utils/`, `helpers/`, `common/` |
|
|
46
45
|
|
|
47
46
|
**Checklist**:
|
|
48
|
-
- [ ] Read flow: Database -> Service -> API ->
|
|
49
|
-
- [ ] Write flow:
|
|
50
|
-
- [ ] Types correctly passed between layers?
|
|
51
|
-
- [ ] Errors properly propagated to
|
|
52
|
-
- [ ] Loading states handled at each layer?
|
|
47
|
+
- [ ] Read flow: Database -> Service -> API -> UI
|
|
48
|
+
- [ ] Write flow: UI -> API -> Service -> Database
|
|
49
|
+
- [ ] Types/schemas correctly passed between layers?
|
|
50
|
+
- [ ] Errors properly propagated to caller?
|
|
51
|
+
- [ ] Loading/pending states handled at each layer?
|
|
53
52
|
|
|
54
53
|
**Detailed Guide**: `.trellis/structure/guides/cross-layer-thinking-guide.md`
|
|
55
54
|
|
|
@@ -67,7 +66,8 @@ Based on your change type, execute relevant checks below:
|
|
|
67
66
|
**Checklist**:
|
|
68
67
|
- [ ] Search first: How many places define this value?
|
|
69
68
|
```bash
|
|
70
|
-
|
|
69
|
+
# Search in source files (adjust extensions for your project)
|
|
70
|
+
grep -r "value-to-change" src/
|
|
71
71
|
```
|
|
72
72
|
- [ ] If 2+ places define same value -> Should extract to shared constant
|
|
73
73
|
- [ ] After modification, all usage sites updated?
|
|
@@ -84,7 +84,7 @@ Based on your change type, execute relevant checks below:
|
|
|
84
84
|
**Checklist**:
|
|
85
85
|
- [ ] Search for existing similar utilities first
|
|
86
86
|
```bash
|
|
87
|
-
grep -r "functionNamePattern"
|
|
87
|
+
grep -r "functionNamePattern" src/
|
|
88
88
|
```
|
|
89
89
|
- [ ] If similar exists, can you extend it instead?
|
|
90
90
|
- [ ] If creating new, is it in the right location (shared vs domain-specific)?
|
|
@@ -98,37 +98,37 @@ Based on your change type, execute relevant checks below:
|
|
|
98
98
|
**Checklist**:
|
|
99
99
|
- [ ] Did you check ALL files with similar patterns?
|
|
100
100
|
```bash
|
|
101
|
-
grep -r "patternYouChanged"
|
|
101
|
+
grep -r "patternYouChanged" src/
|
|
102
102
|
```
|
|
103
103
|
- [ ] Any files missed that should also be updated?
|
|
104
104
|
- [ ] Should this pattern be abstracted to prevent future duplication?
|
|
105
105
|
|
|
106
106
|
---
|
|
107
107
|
|
|
108
|
-
## Dimension C: Import Paths (Required when creating new files)
|
|
108
|
+
## Dimension C: Import/Dependency Paths (Required when creating new files)
|
|
109
109
|
|
|
110
|
-
**Trigger**: Creating new
|
|
110
|
+
**Trigger**: Creating new source files
|
|
111
111
|
|
|
112
112
|
**Checklist**:
|
|
113
|
-
- [ ] Using correct
|
|
114
|
-
- [ ] No circular
|
|
115
|
-
- [ ]
|
|
113
|
+
- [ ] Using correct import paths (relative vs absolute)?
|
|
114
|
+
- [ ] No circular dependencies?
|
|
115
|
+
- [ ] Consistent with project's module organization?
|
|
116
116
|
|
|
117
117
|
---
|
|
118
118
|
|
|
119
119
|
## Dimension D: Same-Layer Consistency
|
|
120
120
|
|
|
121
121
|
**Trigger**:
|
|
122
|
-
- Modifying display logic
|
|
123
|
-
- Same domain concept used in multiple
|
|
122
|
+
- Modifying display logic or formatting
|
|
123
|
+
- Same domain concept used in multiple places
|
|
124
124
|
|
|
125
125
|
**Checklist**:
|
|
126
|
-
- [ ] Search for other
|
|
126
|
+
- [ ] Search for other places using same concept
|
|
127
127
|
```bash
|
|
128
|
-
grep -r "ConceptName"
|
|
128
|
+
grep -r "ConceptName" src/
|
|
129
129
|
```
|
|
130
|
-
- [ ] Are these
|
|
131
|
-
- [ ] Should they share configuration?
|
|
130
|
+
- [ ] Are these usages consistent?
|
|
131
|
+
- [ ] Should they share configuration/constants?
|
|
132
132
|
|
|
133
133
|
---
|
|
134
134
|
|
|
@@ -138,8 +138,8 @@ Based on your change type, execute relevant checks below:
|
|
|
138
138
|
|-------|------------|------------|
|
|
139
139
|
| Changed one place, missed others | Didn't search impact scope | `grep` before changing |
|
|
140
140
|
| Data lost at some layer | Didn't check data flow | Trace data source to destination |
|
|
141
|
-
| Type mismatch | Cross-layer types inconsistent | Use shared
|
|
142
|
-
| UI inconsistent | Same concept in multiple places | Extract shared constants |
|
|
141
|
+
| Type/schema mismatch | Cross-layer types inconsistent | Use shared type definitions |
|
|
142
|
+
| UI/output inconsistent | Same concept in multiple places | Extract shared constants |
|
|
143
143
|
| Similar utility exists | Didn't search first | Search before creating |
|
|
144
144
|
| Batch fix incomplete | Didn't verify all occurrences | grep after fixing |
|
|
145
145
|
|
|
@@ -36,6 +36,9 @@ DIR_FEATURES = "features"
|
|
|
36
36
|
DIR_STRUCTURE = "structure"
|
|
37
37
|
FILE_CURRENT_FEATURE = ".current-feature"
|
|
38
38
|
|
|
39
|
+
# Agents that don't update phase (can be called at any time)
|
|
40
|
+
AGENTS_NO_PHASE_UPDATE = {"debug", "research"}
|
|
41
|
+
|
|
39
42
|
# =============================================================================
|
|
40
43
|
# Subagent Constants (change here to rename subagent types)
|
|
41
44
|
# =============================================================================
|
|
@@ -86,6 +89,63 @@ def get_current_feature(repo_root: str) -> str | None:
|
|
|
86
89
|
return None
|
|
87
90
|
|
|
88
91
|
|
|
92
|
+
def update_current_phase(repo_root: str, feature_dir: str, subagent_type: str) -> None:
|
|
93
|
+
"""
|
|
94
|
+
Update current_phase in feature.json based on subagent_type.
|
|
95
|
+
|
|
96
|
+
This ensures phase tracking is always accurate, regardless of whether
|
|
97
|
+
dispatch agent remembers to update it.
|
|
98
|
+
|
|
99
|
+
Logic:
|
|
100
|
+
- Read next_action array from feature.json
|
|
101
|
+
- Find the next phase whose action matches subagent_type
|
|
102
|
+
- Only move forward, never backward
|
|
103
|
+
- Some agents (debug, research) don't update phase
|
|
104
|
+
"""
|
|
105
|
+
if subagent_type in AGENTS_NO_PHASE_UPDATE:
|
|
106
|
+
return
|
|
107
|
+
|
|
108
|
+
feature_json_path = os.path.join(repo_root, feature_dir, "feature.json")
|
|
109
|
+
if not os.path.exists(feature_json_path):
|
|
110
|
+
return
|
|
111
|
+
|
|
112
|
+
try:
|
|
113
|
+
with open(feature_json_path, "r", encoding="utf-8") as f:
|
|
114
|
+
feature_data = json.load(f)
|
|
115
|
+
|
|
116
|
+
current_phase = feature_data.get("current_phase", 0)
|
|
117
|
+
next_actions = feature_data.get("next_action", [])
|
|
118
|
+
|
|
119
|
+
# Map action names to subagent types
|
|
120
|
+
# "implement" -> "implement", "check" -> "check", "finish" -> "check"
|
|
121
|
+
action_to_agent = {
|
|
122
|
+
"implement": "implement",
|
|
123
|
+
"check": "check",
|
|
124
|
+
"finish": "check", # finish uses check agent
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
# Find the next phase that matches this subagent_type
|
|
128
|
+
new_phase = None
|
|
129
|
+
for action in next_actions:
|
|
130
|
+
phase_num = action.get("phase", 0)
|
|
131
|
+
action_name = action.get("action", "")
|
|
132
|
+
expected_agent = action_to_agent.get(action_name)
|
|
133
|
+
|
|
134
|
+
# Only consider phases after current_phase
|
|
135
|
+
if phase_num > current_phase and expected_agent == subagent_type:
|
|
136
|
+
new_phase = phase_num
|
|
137
|
+
break
|
|
138
|
+
|
|
139
|
+
if new_phase is not None:
|
|
140
|
+
feature_data["current_phase"] = new_phase
|
|
141
|
+
|
|
142
|
+
with open(feature_json_path, "w", encoding="utf-8") as f:
|
|
143
|
+
json.dump(feature_data, f, indent=2, ensure_ascii=False)
|
|
144
|
+
except Exception:
|
|
145
|
+
# Don't fail the hook if phase update fails
|
|
146
|
+
pass
|
|
147
|
+
|
|
148
|
+
|
|
89
149
|
def read_file_content(base_path: str, file_path: str) -> str | None:
|
|
90
150
|
"""Read file content, return None if file doesn't exist"""
|
|
91
151
|
full_path = os.path.join(base_path, file_path)
|
|
@@ -580,6 +640,9 @@ def main():
|
|
|
580
640
|
if not os.path.exists(feature_dir_full):
|
|
581
641
|
sys.exit(0)
|
|
582
642
|
|
|
643
|
+
# Update current_phase in feature.json (system-level enforcement)
|
|
644
|
+
update_current_phase(repo_root, feature_dir, subagent_type)
|
|
645
|
+
|
|
583
646
|
# Get context and build prompt based on subagent type
|
|
584
647
|
if subagent_type == AGENT_IMPLEMENT:
|
|
585
648
|
assert feature_dir is not None # validated above
|