@mindfoldhq/trellis 0.3.9 → 0.3.10-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.js +2 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/commands/init.d.ts +1 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +203 -31
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/update.js +154 -6
- package/dist/commands/update.js.map +1 -1
- package/dist/configurators/workflow.d.ts +6 -2
- package/dist/configurators/workflow.d.ts.map +1 -1
- package/dist/configurators/workflow.js +88 -58
- package/dist/configurators/workflow.js.map +1 -1
- package/dist/migrations/index.d.ts +1 -0
- package/dist/migrations/index.d.ts.map +1 -1
- package/dist/migrations/index.js +2 -0
- package/dist/migrations/index.js.map +1 -1
- package/dist/migrations/manifests/0.4.0-beta.1.json +228 -0
- package/dist/templates/claude/agents/dispatch.md +1 -2
- package/dist/templates/claude/agents/implement.md +2 -3
- package/dist/templates/claude/commands/trellis/before-dev.md +29 -0
- package/dist/templates/claude/commands/trellis/check.md +25 -0
- package/dist/templates/claude/commands/trellis/create-command.md +2 -2
- package/dist/templates/claude/commands/trellis/onboard.md +13 -13
- package/dist/templates/claude/commands/trellis/parallel.md +1 -2
- package/dist/templates/claude/commands/trellis/record-session.md +1 -1
- package/dist/templates/claude/commands/trellis/start.md +8 -4
- package/dist/templates/claude/hooks/inject-subagent-context.py +21 -13
- package/dist/templates/claude/hooks/session-start.py +170 -2
- package/dist/templates/codex/skills/before-dev/SKILL.md +34 -0
- package/dist/templates/codex/skills/check/SKILL.md +30 -0
- package/dist/templates/codex/skills/create-command/SKILL.md +2 -2
- package/dist/templates/codex/skills/onboard/SKILL.md +11 -11
- package/dist/templates/codex/skills/record-session/SKILL.md +1 -1
- package/dist/templates/codex/skills/start/SKILL.md +8 -3
- package/dist/templates/cursor/commands/trellis-before-dev.md +29 -0
- package/dist/templates/cursor/commands/trellis-check.md +25 -0
- package/dist/templates/cursor/commands/trellis-create-command.md +2 -2
- package/dist/templates/cursor/commands/trellis-onboard.md +13 -13
- package/dist/templates/cursor/commands/trellis-record-session.md +1 -1
- package/dist/templates/cursor/commands/trellis-start.md +7 -16
- package/dist/templates/gemini/commands/trellis/before-dev.toml +33 -0
- package/dist/templates/gemini/commands/trellis/check.toml +29 -0
- package/dist/templates/gemini/commands/trellis/create-command.toml +2 -2
- package/dist/templates/gemini/commands/trellis/onboard.toml +2 -2
- package/dist/templates/gemini/commands/trellis/record-session.toml +1 -1
- package/dist/templates/gemini/commands/trellis/start.toml +9 -4
- package/dist/templates/iflow/agents/dispatch.md +1 -2
- package/dist/templates/iflow/agents/implement.md +2 -3
- package/dist/templates/iflow/commands/trellis/before-dev.md +29 -0
- package/dist/templates/iflow/commands/trellis/check.md +25 -0
- package/dist/templates/iflow/commands/trellis/create-command.md +2 -2
- package/dist/templates/iflow/commands/trellis/onboard.md +13 -13
- package/dist/templates/iflow/commands/trellis/parallel.md +1 -2
- package/dist/templates/iflow/commands/trellis/record-session.md +1 -1
- package/dist/templates/iflow/commands/trellis/start.md +8 -4
- package/dist/templates/iflow/hooks/inject-subagent-context.py +21 -13
- package/dist/templates/iflow/hooks/session-start.py +156 -1
- package/dist/templates/kilo/workflows/before-dev.md +29 -0
- package/dist/templates/kilo/workflows/check.md +25 -0
- package/dist/templates/kilo/workflows/create-command.md +2 -2
- package/dist/templates/kilo/workflows/onboard.md +13 -13
- package/dist/templates/kilo/workflows/parallel.md +1 -2
- package/dist/templates/kilo/workflows/record-session.md +1 -1
- package/dist/templates/kilo/workflows/start.md +8 -3
- package/dist/templates/kiro/skills/before-dev/SKILL.md +34 -0
- package/dist/templates/kiro/skills/check/SKILL.md +30 -0
- package/dist/templates/kiro/skills/create-command/SKILL.md +2 -2
- package/dist/templates/kiro/skills/onboard/SKILL.md +11 -11
- package/dist/templates/kiro/skills/record-session/SKILL.md +1 -1
- package/dist/templates/kiro/skills/start/SKILL.md +8 -3
- package/dist/templates/markdown/spec/backend/script-conventions.md +93 -0
- package/dist/templates/opencode/agents/dispatch.md +1 -2
- package/dist/templates/opencode/agents/implement.md +2 -2
- package/dist/templates/opencode/agents/research.md +1 -2
- package/dist/templates/opencode/commands/trellis/before-dev.md +29 -0
- package/dist/templates/opencode/commands/trellis/check.md +25 -0
- package/dist/templates/opencode/commands/trellis/create-command.md +2 -2
- package/dist/templates/opencode/commands/trellis/onboard.md +13 -13
- package/dist/templates/opencode/commands/trellis/parallel.md +1 -2
- package/dist/templates/opencode/commands/trellis/record-session.md +1 -1
- package/dist/templates/opencode/commands/trellis/start.md +8 -3
- package/dist/templates/opencode/plugin/inject-subagent-context.js +45 -18
- package/dist/templates/opencode/plugin/session-start.js +149 -1
- package/dist/templates/qoder/skills/before-dev/SKILL.md +34 -0
- package/dist/templates/qoder/skills/check/SKILL.md +30 -0
- package/dist/templates/qoder/skills/create-command/SKILL.md +2 -2
- package/dist/templates/qoder/skills/onboard/SKILL.md +13 -13
- package/dist/templates/qoder/skills/record-session/SKILL.md +1 -1
- package/dist/templates/qoder/skills/start/SKILL.md +8 -3
- package/dist/templates/trellis/config.yaml +20 -0
- package/dist/templates/trellis/index.d.ts +11 -0
- package/dist/templates/trellis/index.d.ts.map +1 -1
- package/dist/templates/trellis/index.js +22 -0
- package/dist/templates/trellis/index.js.map +1 -1
- package/dist/templates/trellis/scripts/add_session.py +52 -7
- package/dist/templates/trellis/scripts/common/cli_adapter.py +33 -45
- package/dist/templates/trellis/scripts/common/config.py +152 -0
- package/dist/templates/trellis/scripts/common/git.py +31 -0
- package/dist/templates/trellis/scripts/common/git_context.py +23 -586
- package/dist/templates/trellis/scripts/common/io.py +37 -0
- package/dist/templates/trellis/scripts/common/log.py +45 -0
- package/dist/templates/trellis/scripts/common/packages_context.py +233 -0
- package/dist/templates/trellis/scripts/common/paths.py +46 -0
- package/dist/templates/trellis/scripts/common/phase.py +50 -49
- package/dist/templates/trellis/scripts/common/registry.py +41 -72
- package/dist/templates/trellis/scripts/common/session_context.py +466 -0
- package/dist/templates/trellis/scripts/common/task_context.py +384 -0
- package/dist/templates/trellis/scripts/common/task_queue.py +27 -98
- package/dist/templates/trellis/scripts/common/task_store.py +534 -0
- package/dist/templates/trellis/scripts/common/task_utils.py +96 -6
- package/dist/templates/trellis/scripts/common/tasks.py +109 -0
- package/dist/templates/trellis/scripts/common/types.py +112 -0
- package/dist/templates/trellis/scripts/create_bootstrap.py +31 -26
- package/dist/templates/trellis/scripts/hooks/linear_sync.py +243 -0
- package/dist/templates/trellis/scripts/multi_agent/_bootstrap.py +17 -0
- package/dist/templates/trellis/scripts/multi_agent/cleanup.py +43 -48
- package/dist/templates/trellis/scripts/multi_agent/create_pr.py +336 -45
- package/dist/templates/trellis/scripts/multi_agent/plan.py +2 -26
- package/dist/templates/trellis/scripts/multi_agent/start.py +126 -57
- package/dist/templates/trellis/scripts/multi_agent/status.py +12 -753
- package/dist/templates/trellis/scripts/multi_agent/status_display.py +542 -0
- package/dist/templates/trellis/scripts/multi_agent/status_monitor.py +225 -0
- package/dist/templates/trellis/scripts/task.py +50 -975
- package/dist/templates/trellis/workflow.md +21 -34
- package/dist/types/migration.d.ts +3 -1
- package/dist/types/migration.d.ts.map +1 -1
- package/dist/utils/project-detector.d.ts +23 -0
- package/dist/utils/project-detector.d.ts.map +1 -1
- package/dist/utils/project-detector.js +364 -0
- package/dist/utils/project-detector.js.map +1 -1
- package/dist/utils/template-fetcher.d.ts +2 -2
- package/dist/utils/template-fetcher.d.ts.map +1 -1
- package/dist/utils/template-fetcher.js +5 -5
- package/dist/utils/template-fetcher.js.map +1 -1
- package/package.json +1 -1
- package/dist/templates/claude/commands/trellis/before-backend-dev.md +0 -13
- package/dist/templates/claude/commands/trellis/before-frontend-dev.md +0 -13
- package/dist/templates/claude/commands/trellis/check-backend.md +0 -13
- package/dist/templates/claude/commands/trellis/check-frontend.md +0 -13
- package/dist/templates/codex/skills/before-backend-dev/SKILL.md +0 -18
- package/dist/templates/codex/skills/before-frontend-dev/SKILL.md +0 -18
- package/dist/templates/codex/skills/check-backend/SKILL.md +0 -18
- package/dist/templates/codex/skills/check-frontend/SKILL.md +0 -18
- package/dist/templates/cursor/commands/trellis-before-backend-dev.md +0 -13
- package/dist/templates/cursor/commands/trellis-before-frontend-dev.md +0 -13
- package/dist/templates/cursor/commands/trellis-check-backend.md +0 -13
- package/dist/templates/cursor/commands/trellis-check-frontend.md +0 -13
- package/dist/templates/gemini/commands/trellis/before-backend-dev.toml +0 -17
- package/dist/templates/gemini/commands/trellis/before-frontend-dev.toml +0 -17
- package/dist/templates/gemini/commands/trellis/check-backend.toml +0 -17
- package/dist/templates/gemini/commands/trellis/check-frontend.toml +0 -17
- package/dist/templates/iflow/commands/trellis/before-backend-dev.md +0 -13
- package/dist/templates/iflow/commands/trellis/before-frontend-dev.md +0 -13
- package/dist/templates/iflow/commands/trellis/check-backend.md +0 -13
- package/dist/templates/iflow/commands/trellis/check-frontend.md +0 -13
- package/dist/templates/kilo/workflows/before-backend-dev.md +0 -13
- package/dist/templates/kilo/workflows/before-frontend-dev.md +0 -13
- package/dist/templates/kilo/workflows/check-backend.md +0 -13
- package/dist/templates/kilo/workflows/check-frontend.md +0 -13
- package/dist/templates/kiro/skills/before-backend-dev/SKILL.md +0 -18
- package/dist/templates/kiro/skills/before-frontend-dev/SKILL.md +0 -18
- package/dist/templates/kiro/skills/check-backend/SKILL.md +0 -18
- package/dist/templates/kiro/skills/check-frontend/SKILL.md +0 -18
- package/dist/templates/opencode/commands/trellis/before-backend-dev.md +0 -13
- package/dist/templates/opencode/commands/trellis/before-frontend-dev.md +0 -13
- package/dist/templates/opencode/commands/trellis/check-backend.md +0 -13
- package/dist/templates/opencode/commands/trellis/check-frontend.md +0 -13
- package/dist/templates/qoder/skills/before-backend-dev/SKILL.md +0 -18
- package/dist/templates/qoder/skills/before-frontend-dev/SKILL.md +0 -18
- package/dist/templates/qoder/skills/check-backend/SKILL.md +0 -18
- package/dist/templates/qoder/skills/check-frontend/SKILL.md +0 -18
|
@@ -65,8 +65,8 @@ Before implementing, read:
|
|
|
65
65
|
|
|
66
66
|
Read relevant specs based on task type:
|
|
67
67
|
|
|
68
|
-
-
|
|
69
|
-
-
|
|
68
|
+
- Spec layers: `.trellis/spec/<package>/<layer>/`
|
|
69
|
+
- Shared guides: `.trellis/spec/guides/`
|
|
70
70
|
- Guides: `.trellis/spec/guides/`
|
|
71
71
|
|
|
72
72
|
### 2. Understand Requirements
|
|
@@ -29,8 +29,7 @@ Otherwise, if task-specific research is needed:
|
|
|
29
29
|
- If `path` is a directory → Read all `.md` files in it
|
|
30
30
|
|
|
31
31
|
Project spec locations for reference:
|
|
32
|
-
- `.trellis/spec
|
|
33
|
-
- `.trellis/spec/frontend/` - Frontend standards
|
|
32
|
+
- `.trellis/spec/<package>/<layer>/` - Package-specific standards
|
|
34
33
|
- `.trellis/spec/guides/` - Thinking guides
|
|
35
34
|
- `.trellis/big-question/` - Known issues and pitfalls
|
|
36
35
|
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
Read the relevant development guidelines before starting your task.
|
|
2
|
+
|
|
3
|
+
Execute these steps:
|
|
4
|
+
|
|
5
|
+
1. **Discover packages and their spec layers**:
|
|
6
|
+
```bash
|
|
7
|
+
python3 ./.trellis/scripts/get_context.py --mode packages
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
2. **Identify which specs apply** to your task based on:
|
|
11
|
+
- Which package you're modifying (e.g., `cli/`, `docs-site/`)
|
|
12
|
+
- What type of work (backend, frontend, unit-test, docs, etc.)
|
|
13
|
+
|
|
14
|
+
3. **Read the spec index** for each relevant module:
|
|
15
|
+
```bash
|
|
16
|
+
cat .trellis/spec/<package>/<layer>/index.md
|
|
17
|
+
```
|
|
18
|
+
Follow the **"Pre-Development Checklist"** section in the index.
|
|
19
|
+
|
|
20
|
+
4. **Read the specific guideline files** listed in the Pre-Development Checklist that are relevant to your task. The index is NOT the goal — it points you to the actual guideline files (e.g., `error-handling.md`, `conventions.md`, `mock-strategies.md`). Read those files to understand the coding standards and patterns.
|
|
21
|
+
|
|
22
|
+
5. **Always read shared guides**:
|
|
23
|
+
```bash
|
|
24
|
+
cat .trellis/spec/guides/index.md
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
6. Understand the coding standards and patterns you need to follow, then proceed with your development plan.
|
|
28
|
+
|
|
29
|
+
This step is **mandatory** before writing any code.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
Check if the code you just wrote follows the development guidelines.
|
|
2
|
+
|
|
3
|
+
Execute these steps:
|
|
4
|
+
|
|
5
|
+
1. **Identify changed files**:
|
|
6
|
+
```bash
|
|
7
|
+
git diff --name-only HEAD
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
2. **Determine which spec modules apply** based on the changed file paths:
|
|
11
|
+
```bash
|
|
12
|
+
python3 ./.trellis/scripts/get_context.py --mode packages
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
3. **Read the spec index** for each relevant module:
|
|
16
|
+
```bash
|
|
17
|
+
cat .trellis/spec/<package>/<layer>/index.md
|
|
18
|
+
```
|
|
19
|
+
Follow the **"Quality Check"** section in the index.
|
|
20
|
+
|
|
21
|
+
4. **Read the specific guideline files** referenced in the Quality Check section (e.g., `quality-guidelines.md`, `conventions.md`). The index is NOT the goal — it points you to the actual guideline files. Read those files and review your code against them.
|
|
22
|
+
|
|
23
|
+
5. **Run lint and typecheck** for the affected package.
|
|
24
|
+
|
|
25
|
+
6. **Report any violations** and fix them if found.
|
|
@@ -101,8 +101,8 @@ Description:
|
|
|
101
101
|
| Command Type | Prefix | Example |
|
|
102
102
|
|--------------|--------|---------|
|
|
103
103
|
| Session Start | `start` | `start` |
|
|
104
|
-
| Pre-development | `before-` | `before-
|
|
105
|
-
| Check | `check-` | `check
|
|
104
|
+
| Pre-development | `before-` | `before-dev` |
|
|
105
|
+
| Check | `check-` | `check` |
|
|
106
106
|
| Record | `record-` | `record-session` |
|
|
107
107
|
| Generate | `generate-` | `generate-api-doc` |
|
|
108
108
|
| Update | `update-` | `update-changelog` |
|
|
@@ -126,13 +126,13 @@ AI needs the same onboarding - but compressed into seconds at session start.
|
|
|
126
126
|
|
|
127
127
|
---
|
|
128
128
|
|
|
129
|
-
### /trellis:before-
|
|
129
|
+
### /trellis:before-dev - Inject Specialized Knowledge
|
|
130
130
|
|
|
131
131
|
**WHY IT EXISTS**:
|
|
132
132
|
AI models have "pre-trained knowledge" - general patterns from millions of codebases. But YOUR project has specific conventions that differ from generic patterns.
|
|
133
133
|
|
|
134
134
|
**WHAT IT ACTUALLY DOES**:
|
|
135
|
-
1.
|
|
135
|
+
1. Discovers spec layers via `get_context.py --mode packages` and reads relevant guidelines
|
|
136
136
|
2. Loads project-specific patterns into AI's working context:
|
|
137
137
|
- Component naming conventions
|
|
138
138
|
- State management patterns
|
|
@@ -140,12 +140,12 @@ AI models have "pre-trained knowledge" - general patterns from millions of codeb
|
|
|
140
140
|
- Error handling standards
|
|
141
141
|
|
|
142
142
|
**WHY THIS MATTERS**:
|
|
143
|
-
- Without before
|
|
144
|
-
- With before
|
|
143
|
+
- Without before-dev: AI writes generic code that doesn't match project style.
|
|
144
|
+
- With before-dev: AI writes code that looks like the rest of the codebase.
|
|
145
145
|
|
|
146
146
|
---
|
|
147
147
|
|
|
148
|
-
### /trellis:check
|
|
148
|
+
### /trellis:check - Combat Context Drift
|
|
149
149
|
|
|
150
150
|
**WHY IT EXISTS**:
|
|
151
151
|
AI context window has limited capacity. As conversation progresses, guidelines injected at session start become less influential. This causes "context drift."
|
|
@@ -211,9 +211,9 @@ All the context AI built during this session will be lost when session ends. The
|
|
|
211
211
|
|
|
212
212
|
**[1/8] /trellis:start** - AI needs project context before touching code
|
|
213
213
|
**[2/8] python3 ./.trellis/scripts/task.py create "Fix bug" --slug fix-bug** - Track work for future reference
|
|
214
|
-
**[3/8] /trellis:before-
|
|
214
|
+
**[3/8] /trellis:before-dev** - Inject project-specific development guidelines
|
|
215
215
|
**[4/8] Investigate and fix the bug** - Actual development work
|
|
216
|
-
**[5/8] /trellis:check
|
|
216
|
+
**[5/8] /trellis:check** - Re-verify code against guidelines
|
|
217
217
|
**[6/8] /trellis:finish-work** - Holistic cross-layer review
|
|
218
218
|
**[7/8] Human tests and commits** - Human validates before code enters repo
|
|
219
219
|
**[8/8] /trellis:record-session** - Persist memory for future sessions
|
|
@@ -228,9 +228,9 @@ All the context AI built during this session will be lost when session ends. The
|
|
|
228
228
|
### Example 3: Code Review Fixes
|
|
229
229
|
|
|
230
230
|
**[1/6] /trellis:start** - Resume context from previous session
|
|
231
|
-
**[2/6] /trellis:before-
|
|
231
|
+
**[2/6] /trellis:before-dev** - Re-inject guidelines before fixes
|
|
232
232
|
**[3/6] Fix each CR issue** - Address feedback with guidelines in context
|
|
233
|
-
**[4/6] /trellis:check
|
|
233
|
+
**[4/6] /trellis:check** - Verify fixes did not introduce new issues
|
|
234
234
|
**[5/6] /trellis:finish-work** - Document lessons from CR
|
|
235
235
|
**[6/6] Human commits, then /trellis:record-session** - Preserve CR lessons
|
|
236
236
|
|
|
@@ -238,16 +238,16 @@ All the context AI built during this session will be lost when session ends. The
|
|
|
238
238
|
|
|
239
239
|
**[1/5] /trellis:start** - Clear baseline before major changes
|
|
240
240
|
**[2/5] Plan phases** - Break into verifiable chunks
|
|
241
|
-
**[3/5] Execute phase by phase with /check
|
|
241
|
+
**[3/5] Execute phase by phase with /trellis:check after each** - Incremental verification
|
|
242
242
|
**[4/5] /trellis:finish-work** - Check if new patterns should be documented
|
|
243
243
|
**[5/5] Record with multiple commit hashes** - Link all commits to one feature
|
|
244
244
|
|
|
245
245
|
### Example 5: Debug Session
|
|
246
246
|
|
|
247
247
|
**[1/6] /trellis:start** - See if this bug was investigated before
|
|
248
|
-
**[2/6] /trellis:before-
|
|
248
|
+
**[2/6] /trellis:before-dev** - Guidelines might document known gotchas
|
|
249
249
|
**[3/6] Investigation** - Actual debugging work
|
|
250
|
-
**[4/6] /trellis:check
|
|
250
|
+
**[4/6] /trellis:check** - Verify debug changes do not break other things
|
|
251
251
|
**[5/6] /trellis:finish-work** - Debug findings might need documentation
|
|
252
252
|
**[6/6] Human commits, then /trellis:record-session** - Debug knowledge is valuable
|
|
253
253
|
|
|
@@ -256,7 +256,7 @@ All the context AI built during this session will be lost when session ends. The
|
|
|
256
256
|
## KEY RULES TO EMPHASIZE
|
|
257
257
|
|
|
258
258
|
1. **AI NEVER commits** - Human tests and approves. AI prepares, human validates.
|
|
259
|
-
2. **Guidelines before code** - /before
|
|
259
|
+
2. **Guidelines before code** - /before-dev command injects project knowledge.
|
|
260
260
|
3. **Check after code** - /check-* commands catch context drift.
|
|
261
261
|
4. **Record everything** - /trellis:record-session persists memory.
|
|
262
262
|
|
|
@@ -41,8 +41,7 @@ python3 ./.trellis/scripts/get_context.py
|
|
|
41
41
|
### Step 3: Read Project Guidelines `[AI]`
|
|
42
42
|
|
|
43
43
|
```bash
|
|
44
|
-
|
|
45
|
-
cat .trellis/spec/backend/index.md # Backend guidelines index
|
|
44
|
+
python3 ./.trellis/scripts/get_context.py --mode packages # Discover available spec layers
|
|
46
45
|
cat .trellis/spec/guides/index.md # Thinking guides
|
|
47
46
|
```
|
|
48
47
|
|
|
@@ -31,7 +31,7 @@ python3 ./.trellis/scripts/add_session.py \
|
|
|
31
31
|
--summary "Brief summary of what was done"
|
|
32
32
|
|
|
33
33
|
# Method 2: Pass detailed content via stdin
|
|
34
|
-
cat << 'EOF' | python3 ./.trellis/scripts/add_session.py --title "Title" --commit "hash"
|
|
34
|
+
cat << 'EOF' | python3 ./.trellis/scripts/add_session.py --stdin --title "Title" --commit "hash"
|
|
35
35
|
| Feature | Description |
|
|
36
36
|
|---------|-------------|
|
|
37
37
|
| New API | Added user authentication endpoint |
|
|
@@ -40,9 +40,14 @@ This shows: developer identity, git status, current task (if any), active tasks.
|
|
|
40
40
|
### Step 3: Read Guidelines Index
|
|
41
41
|
|
|
42
42
|
```bash
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
python3 ./.trellis/scripts/get_context.py --mode packages
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
This shows available packages and their spec layers. Read the relevant spec indexes:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
cat .trellis/spec/<package>/<layer>/index.md # Package-specific guidelines
|
|
50
|
+
cat .trellis/spec/guides/index.md # Thinking guides (always read)
|
|
46
51
|
```
|
|
47
52
|
|
|
48
53
|
> **Important**: The index files are navigation — they list the actual guideline files (e.g., `error-handling.md`, `conventions.md`, `mock-strategies.md`).
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* - Otherwise, this plugin handles injection
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
import { existsSync, writeFileSync } from "fs"
|
|
12
|
+
import { existsSync, writeFileSync, readdirSync } from "fs"
|
|
13
13
|
import { join } from "path"
|
|
14
14
|
import { TrellisContext, debugLog } from "../lib/trellis-context.js"
|
|
15
15
|
|
|
@@ -119,8 +119,7 @@ function getCheckContext(ctx, taskDir) {
|
|
|
119
119
|
const checkFiles = [
|
|
120
120
|
[".opencode/commands/trellis/finish-work.md", "Finish work checklist"],
|
|
121
121
|
[".opencode/commands/trellis/check-cross-layer.md", "Cross-layer check spec"],
|
|
122
|
-
[".opencode/commands/trellis/check
|
|
123
|
-
[".opencode/commands/trellis/check-frontend.md", "Frontend check spec"],
|
|
122
|
+
[".opencode/commands/trellis/check.md", "Check spec"],
|
|
124
123
|
]
|
|
125
124
|
for (const [f, description] of checkFiles) {
|
|
126
125
|
const content = ctx.readProjectFile(f)
|
|
@@ -202,8 +201,7 @@ function getDebugContext(ctx, taskDir) {
|
|
|
202
201
|
}
|
|
203
202
|
|
|
204
203
|
const checkFiles = [
|
|
205
|
-
[".opencode/commands/trellis/check
|
|
206
|
-
[".opencode/commands/trellis/check-frontend.md", "Frontend check spec"],
|
|
204
|
+
[".opencode/commands/trellis/check.md", "Check spec"],
|
|
207
205
|
[".opencode/commands/trellis/check-cross-layer.md", "Cross-layer check spec"],
|
|
208
206
|
]
|
|
209
207
|
for (const [f, description] of checkFiles) {
|
|
@@ -229,17 +227,46 @@ function getDebugContext(ctx, taskDir) {
|
|
|
229
227
|
function getResearchContext(ctx, taskDir) {
|
|
230
228
|
const parts = []
|
|
231
229
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
230
|
+
// Dynamic project structure (scan actual spec directory)
|
|
231
|
+
const specPath = ".trellis/spec"
|
|
232
|
+
const specFull = join(ctx.directory, specPath)
|
|
233
|
+
|
|
234
|
+
const structureLines = [`## Project Spec Directory Structure\n\n\`\`\`\n${specPath}/`]
|
|
235
|
+
if (existsSync(specFull)) {
|
|
236
|
+
try {
|
|
237
|
+
const entries = readdirSync(specFull, { withFileTypes: true })
|
|
238
|
+
.filter(d => d.isDirectory() && !d.name.startsWith("."))
|
|
239
|
+
.sort((a, b) => a.name.localeCompare(b.name))
|
|
240
|
+
|
|
241
|
+
for (const entry of entries) {
|
|
242
|
+
const entryPath = join(specFull, entry.name)
|
|
243
|
+
// Check if this is a direct spec layer (has index.md)
|
|
244
|
+
if (existsSync(join(entryPath, "index.md"))) {
|
|
245
|
+
structureLines.push(`├── ${entry.name}/`)
|
|
246
|
+
} else {
|
|
247
|
+
// Check for nested package dirs (monorepo)
|
|
248
|
+
try {
|
|
249
|
+
const nested = readdirSync(entryPath, { withFileTypes: true })
|
|
250
|
+
.filter(d => d.isDirectory() && existsSync(join(entryPath, d.name, "index.md")))
|
|
251
|
+
.sort((a, b) => a.name.localeCompare(b.name))
|
|
252
|
+
if (nested.length > 0) {
|
|
253
|
+
structureLines.push(`├── ${entry.name}/`)
|
|
254
|
+
for (const n of nested) {
|
|
255
|
+
structureLines.push(`│ ├── ${n.name}/`)
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
} catch {
|
|
259
|
+
// Ignore nested read errors
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
} catch {
|
|
264
|
+
// Ignore read errors
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
structureLines.push("```")
|
|
240
268
|
|
|
241
|
-
.
|
|
242
|
-
\`\`\`
|
|
269
|
+
parts.push(structureLines.join("\n") + `
|
|
243
270
|
|
|
244
271
|
## Search Tips
|
|
245
272
|
|
|
@@ -250,10 +277,10 @@ function getResearchContext(ctx, taskDir) {
|
|
|
250
277
|
|
|
251
278
|
if (taskDir) {
|
|
252
279
|
const jsonlPath = join(ctx.directory, taskDir, "research.jsonl")
|
|
253
|
-
const
|
|
254
|
-
if (
|
|
280
|
+
const researchEntries = ctx.readJsonlWithFiles(jsonlPath)
|
|
281
|
+
if (researchEntries.length > 0) {
|
|
255
282
|
parts.push("\n## Additional Search Context\n")
|
|
256
|
-
parts.push(ctx.buildContextFromEntries(
|
|
283
|
+
parts.push(ctx.buildContextFromEntries(researchEntries))
|
|
257
284
|
}
|
|
258
285
|
}
|
|
259
286
|
|
|
@@ -12,8 +12,12 @@
|
|
|
12
12
|
|
|
13
13
|
import { existsSync, readFileSync, readdirSync, statSync } from "fs"
|
|
14
14
|
import { join } from "path"
|
|
15
|
+
import { execFileSync } from "child_process"
|
|
16
|
+
import { platform } from "os"
|
|
15
17
|
import { TrellisContext, contextCollector, debugLog } from "../lib/trellis-context.js"
|
|
16
18
|
|
|
19
|
+
const PYTHON_CMD = platform() === "win32" ? "python" : "python3"
|
|
20
|
+
|
|
17
21
|
|
|
18
22
|
/**
|
|
19
23
|
* Check current task status and return structured status string.
|
|
@@ -101,6 +105,124 @@ function getTaskStatus(directory) {
|
|
|
101
105
|
return `Status: READY\nTask: ${taskTitle}\nNext: Continue with implement or check`
|
|
102
106
|
}
|
|
103
107
|
|
|
108
|
+
/**
|
|
109
|
+
* Load Trellis config for session-start decisions.
|
|
110
|
+
* Calls get_context.py --mode packages --json for reliable config data.
|
|
111
|
+
*/
|
|
112
|
+
function loadTrellisConfig(directory) {
|
|
113
|
+
const scriptPath = join(directory, ".trellis", "scripts", "get_context.py")
|
|
114
|
+
if (!existsSync(scriptPath)) {
|
|
115
|
+
return { isMonorepo: false, packages: {}, specScope: null, activeTaskPackage: null, defaultPackage: null }
|
|
116
|
+
}
|
|
117
|
+
try {
|
|
118
|
+
const output = execFileSync(PYTHON_CMD, [scriptPath, "--mode", "packages", "--json"], {
|
|
119
|
+
cwd: directory,
|
|
120
|
+
timeout: 5000,
|
|
121
|
+
encoding: "utf-8",
|
|
122
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
123
|
+
})
|
|
124
|
+
const data = JSON.parse(output)
|
|
125
|
+
if (data.mode !== "monorepo") {
|
|
126
|
+
return { isMonorepo: false, packages: {}, specScope: null, activeTaskPackage: null, defaultPackage: null }
|
|
127
|
+
}
|
|
128
|
+
// Convert packages array to dict keyed by name
|
|
129
|
+
const pkgDict = {}
|
|
130
|
+
for (const pkg of (data.packages || [])) {
|
|
131
|
+
pkgDict[pkg.name] = pkg
|
|
132
|
+
}
|
|
133
|
+
return {
|
|
134
|
+
isMonorepo: true,
|
|
135
|
+
packages: pkgDict,
|
|
136
|
+
specScope: data.specScope || null,
|
|
137
|
+
activeTaskPackage: data.activeTaskPackage || null,
|
|
138
|
+
defaultPackage: data.defaultPackage || null,
|
|
139
|
+
}
|
|
140
|
+
} catch (e) {
|
|
141
|
+
debugLog("session", "loadTrellisConfig error:", e.message)
|
|
142
|
+
return { isMonorepo: false, packages: {}, specScope: null, activeTaskPackage: null, defaultPackage: null }
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Check for legacy spec directory structure in monorepo.
|
|
149
|
+
*/
|
|
150
|
+
function checkLegacySpec(directory, config) {
|
|
151
|
+
if (!config.isMonorepo || Object.keys(config.packages).length === 0) {
|
|
152
|
+
return null
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const specDir = join(directory, ".trellis", "spec")
|
|
156
|
+
if (!existsSync(specDir)) return null
|
|
157
|
+
|
|
158
|
+
// Check for legacy flat spec dirs
|
|
159
|
+
let hasLegacy = false
|
|
160
|
+
for (const name of ["backend", "frontend"]) {
|
|
161
|
+
if (existsSync(join(specDir, name, "index.md"))) {
|
|
162
|
+
hasLegacy = true
|
|
163
|
+
break
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
if (!hasLegacy) return null
|
|
167
|
+
|
|
168
|
+
// Check which packages are missing spec/<pkg>/ directory
|
|
169
|
+
const pkgNames = Object.keys(config.packages).sort()
|
|
170
|
+
const missing = pkgNames.filter(name => !existsSync(join(specDir, name)))
|
|
171
|
+
|
|
172
|
+
if (missing.length === 0) return null
|
|
173
|
+
|
|
174
|
+
if (missing.length === pkgNames.length) {
|
|
175
|
+
return (
|
|
176
|
+
`[!] Legacy spec structure detected: found \`spec/backend/\` or \`spec/frontend/\` ` +
|
|
177
|
+
`but no package-scoped \`spec/<package>/\` directories.\n` +
|
|
178
|
+
`Monorepo packages: ${pkgNames.join(", ")}\n` +
|
|
179
|
+
`Please reorganize: \`spec/backend/\` -> \`spec/<package>/backend/\``
|
|
180
|
+
)
|
|
181
|
+
}
|
|
182
|
+
return (
|
|
183
|
+
`[!] Partial spec migration detected: packages ${missing.join(", ")} ` +
|
|
184
|
+
`still missing \`spec/<pkg>/\` directory.\n` +
|
|
185
|
+
`Please complete migration for all packages.`
|
|
186
|
+
)
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Resolve which packages should have their specs injected.
|
|
192
|
+
* Returns a Set of allowed package names, or null for full scan.
|
|
193
|
+
*/
|
|
194
|
+
function resolveSpecScope(config) {
|
|
195
|
+
if (!config.isMonorepo || Object.keys(config.packages).length === 0) {
|
|
196
|
+
return null
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
const { specScope, activeTaskPackage, defaultPackage, packages } = config
|
|
200
|
+
if (specScope == null) return null
|
|
201
|
+
|
|
202
|
+
if (specScope === "active_task") {
|
|
203
|
+
if (activeTaskPackage && activeTaskPackage in packages) return new Set([activeTaskPackage])
|
|
204
|
+
if (defaultPackage && defaultPackage in packages) return new Set([defaultPackage])
|
|
205
|
+
return null
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if (Array.isArray(specScope)) {
|
|
209
|
+
const valid = new Set()
|
|
210
|
+
for (const entry of specScope) {
|
|
211
|
+
if (entry in packages) {
|
|
212
|
+
valid.add(entry)
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
if (valid.size > 0) return valid
|
|
216
|
+
// All invalid: fallback
|
|
217
|
+
if (activeTaskPackage && activeTaskPackage in packages) return new Set([activeTaskPackage])
|
|
218
|
+
if (defaultPackage && defaultPackage in packages) return new Set([defaultPackage])
|
|
219
|
+
return null
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
return null
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
|
|
104
226
|
/**
|
|
105
227
|
* Build session context for injection
|
|
106
228
|
*/
|
|
@@ -110,6 +232,10 @@ function buildSessionContext(ctx) {
|
|
|
110
232
|
const claudeDir = join(directory, ".claude")
|
|
111
233
|
const opencodeDir = join(directory, ".opencode")
|
|
112
234
|
|
|
235
|
+
// Load config for scope filtering and legacy detection
|
|
236
|
+
const config = loadTrellisConfig(directory)
|
|
237
|
+
const allowedPkgs = resolveSpecScope(config)
|
|
238
|
+
|
|
113
239
|
const parts = []
|
|
114
240
|
|
|
115
241
|
// 1. Header
|
|
@@ -118,6 +244,12 @@ You are starting a new session in a Trellis-managed project.
|
|
|
118
244
|
Read and follow all instructions below carefully.
|
|
119
245
|
</trellis-context>`)
|
|
120
246
|
|
|
247
|
+
// Legacy migration warning
|
|
248
|
+
const legacyWarning = checkLegacySpec(directory, config)
|
|
249
|
+
if (legacyWarning) {
|
|
250
|
+
parts.push(`<migration-warning>\n${legacyWarning}\n</migration-warning>`)
|
|
251
|
+
}
|
|
252
|
+
|
|
121
253
|
// 2. Current Context (dynamic)
|
|
122
254
|
const contextScript = join(trellisDir, "scripts", "get_context.py")
|
|
123
255
|
if (existsSync(contextScript)) {
|
|
@@ -155,15 +287,31 @@ Read and follow all instructions below carefully.
|
|
|
155
287
|
}).sort()
|
|
156
288
|
|
|
157
289
|
for (const sub of subs) {
|
|
290
|
+
// Always include guides/ regardless of scope
|
|
291
|
+
if (sub === "guides") {
|
|
292
|
+
const indexFile = join(specDir, sub, "index.md")
|
|
293
|
+
if (existsSync(indexFile)) {
|
|
294
|
+
const content = ctx.readFile(indexFile)
|
|
295
|
+
if (content) {
|
|
296
|
+
parts.push(`## ${sub}\n${content}\n`)
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
continue
|
|
300
|
+
}
|
|
301
|
+
|
|
158
302
|
const indexFile = join(specDir, sub, "index.md")
|
|
159
303
|
if (existsSync(indexFile)) {
|
|
160
|
-
// Flat spec dir: spec/<layer>/index.md
|
|
304
|
+
// Flat spec dir: spec/<layer>/index.md (single-repo)
|
|
161
305
|
const content = ctx.readFile(indexFile)
|
|
162
306
|
if (content) {
|
|
163
307
|
parts.push(`## ${sub}\n${content}\n`)
|
|
164
308
|
}
|
|
165
309
|
} else {
|
|
166
310
|
// Nested package dirs (monorepo): spec/<pkg>/<layer>/index.md
|
|
311
|
+
// Apply scope filter
|
|
312
|
+
if (allowedPkgs !== null && !allowedPkgs.has(sub)) {
|
|
313
|
+
continue
|
|
314
|
+
}
|
|
167
315
|
try {
|
|
168
316
|
const nested = readdirSync(join(specDir, sub)).filter(name => {
|
|
169
317
|
try {
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: before-dev
|
|
3
|
+
description: "Read the relevant development guidelines before starting your task."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Read the relevant development guidelines before starting your task.
|
|
7
|
+
|
|
8
|
+
Execute these steps:
|
|
9
|
+
|
|
10
|
+
1. **Discover packages and their spec layers**:
|
|
11
|
+
```bash
|
|
12
|
+
python3 ./.trellis/scripts/get_context.py --mode packages
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
2. **Identify which specs apply** to your task based on:
|
|
16
|
+
- Which package you're modifying (e.g., `cli/`, `docs-site/`)
|
|
17
|
+
- What type of work (backend, frontend, unit-test, docs, etc.)
|
|
18
|
+
|
|
19
|
+
3. **Read the spec index** for each relevant module:
|
|
20
|
+
```bash
|
|
21
|
+
cat .trellis/spec/<package>/<layer>/index.md
|
|
22
|
+
```
|
|
23
|
+
Follow the **"Pre-Development Checklist"** section in the index.
|
|
24
|
+
|
|
25
|
+
4. **Read the specific guideline files** listed in the Pre-Development Checklist that are relevant to your task. The index is NOT the goal — it points you to the actual guideline files (e.g., `error-handling.md`, `conventions.md`, `mock-strategies.md`). Read those files to understand the coding standards and patterns.
|
|
26
|
+
|
|
27
|
+
5. **Always read shared guides**:
|
|
28
|
+
```bash
|
|
29
|
+
cat .trellis/spec/guides/index.md
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
6. Understand the coding standards and patterns you need to follow, then proceed with your development plan.
|
|
33
|
+
|
|
34
|
+
This step is **mandatory** before writing any code.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: check
|
|
3
|
+
description: "Check if the code you just wrote follows the development guidelines."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Check if the code you just wrote follows the development guidelines.
|
|
7
|
+
|
|
8
|
+
Execute these steps:
|
|
9
|
+
|
|
10
|
+
1. **Identify changed files**:
|
|
11
|
+
```bash
|
|
12
|
+
git diff --name-only HEAD
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
2. **Determine which spec modules apply** based on the changed file paths:
|
|
16
|
+
```bash
|
|
17
|
+
python3 ./.trellis/scripts/get_context.py --mode packages
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
3. **Read the spec index** for each relevant module:
|
|
21
|
+
```bash
|
|
22
|
+
cat .trellis/spec/<package>/<layer>/index.md
|
|
23
|
+
```
|
|
24
|
+
Follow the **"Quality Check"** section in the index.
|
|
25
|
+
|
|
26
|
+
4. **Read the specific guideline files** referenced in the Quality Check section (e.g., `quality-guidelines.md`, `conventions.md`). The index is NOT the goal — it points you to the actual guideline files. Read those files and review your code against them.
|
|
27
|
+
|
|
28
|
+
5. **Run lint and typecheck** for the affected package.
|
|
29
|
+
|
|
30
|
+
6. **Report any violations** and fix them if found.
|
|
@@ -93,8 +93,8 @@ Description:
|
|
|
93
93
|
| Skill Type | Prefix | Example |
|
|
94
94
|
|------------|--------|---------|
|
|
95
95
|
| Session Start | `start` | `start` |
|
|
96
|
-
| Pre-development | `before-` | `before-
|
|
97
|
-
| Check | `check-` | `check
|
|
96
|
+
| Pre-development | `before-` | `before-dev` |
|
|
97
|
+
| Check | `check-` | `check` |
|
|
98
98
|
| Record | `record-` | `record-session` |
|
|
99
99
|
| Generate | `generate-` | `generate-api-doc` |
|
|
100
100
|
| Update | `update-` | `update-changelog` |
|