trellis-hgl 0.6.0-beta.18 → 0.6.0-beta.20
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/bin/trellis.js +0 -0
- package/dist/templates/claude/agents/trellis-check.md +1 -0
- package/dist/templates/claude/agents/trellis-research.md +1 -0
- package/dist/templates/common/skills/brainstorm.md +1 -1
- package/dist/templates/common/skills/improve-codebase-architecture.md +147 -27
- package/dist/templates/trellis/workflow.md +2 -1
- package/package.json +28 -29
package/bin/trellis.js
CHANGED
|
File without changes
|
|
@@ -3,6 +3,7 @@ name: trellis-research
|
|
|
3
3
|
description: |
|
|
4
4
|
Code and tech search expert. Finds files, patterns, and tech solutions, and PERSISTS every finding to the current task's research/ directory. No code modifications outside that directory.
|
|
5
5
|
tools: Read, Write, Glob, Grep, Bash, mcp__exa__web_search_exa, mcp__exa__get_code_context_exa, Skill, mcp__chrome-devtools__*
|
|
6
|
+
model: opus
|
|
6
7
|
---
|
|
7
8
|
# Research Agent
|
|
8
9
|
|
|
@@ -49,7 +49,7 @@ Use a concise title from the user's request. Use a slug without a date prefix. `
|
|
|
49
49
|
6. After each user answer, update `prd.md` before continuing.
|
|
50
50
|
7. Once repository-answerable questions are exhausted, tighten the remaining requirement gaps with `trellis-grill-me`: one question at a time, each with a recommendation, while still updating `prd.md` after each answer.
|
|
51
51
|
8. Do not switch into development strategy decisions until the requirement-clarification pass has converged in `prd.md`.
|
|
52
|
-
9. Before implementation starts on the Claude Code path, record the development strategy decisions in the task documents: development mode, branch vs worktree, default flow vs TDD. Lightweight tasks may keep that record in `prd.md`; complex tasks should keep it in `implement.md` together with the review-gate plan: `trellis-spec-review` → `trellis-code-review` → `trellis-code-architecture-review`. If the strategy is `subagent + worktree`, pin `./.claude/worktree`. If the strategy is TDD, record `trellis-tdd` as the reference flow.
|
|
52
|
+
9. Before implementation starts on the Claude Code path, record the development strategy decisions in the task documents: development mode, branch vs worktree, default flow vs TDD. Lightweight tasks may keep that record in `prd.md`; complex tasks should keep it in `implement.md` together with the review-gate plan: `trellis-spec-review` → `trellis-code-review` → `trellis-code-architecture-review`. If the strategy is `subagent + worktree`, pin `./.claude/worktree`. If the strategy is TDD, record `trellis-tdd` as the reference flow. Also ask: "是否需要在开发前进行架构指导?" — if yes, dispatch `trellis-improve-codebase-architecture` with `架构审查模式: guidance` before `task.py start`, append its output to `design.md`, and add `架构审查:enabled` plus `trellis-improve-codebase-architecture(深度)` to the review-gate order in `implement.md`.
|
|
53
53
|
10. For complex tasks, create or update `design.md` and `implement.md` before implementation starts.
|
|
54
54
|
|
|
55
55
|
Do not invent a project-specific product/spec hierarchy. If the repository already has product, domain, or spec docs, use them. If it does not, proceed with the evidence that exists.
|
|
@@ -1,38 +1,158 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: trellis-improve-codebase-architecture
|
|
3
|
+
description: "Active codebase architecture analysis and review. Three modes: (A) Active Analysis — explore codebase, build spec, generate refactor candidates; (B) Pre-dev Guidance — provide architecture guidance before implementation; (C) Deep Review — audit changed code against spec after code-architecture-review passes."
|
|
4
|
+
---
|
|
5
|
+
|
|
1
6
|
# Trellis Improve Codebase Architecture
|
|
2
7
|
|
|
3
|
-
|
|
8
|
+
This skill operates in three modes depending on context. Read the dispatch prompt to determine which mode applies.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Mode A: Active Analysis(主动分析)
|
|
13
|
+
|
|
14
|
+
**触发条件**:用户直接调用,dispatch prompt 中不含 `架构审查模式:`
|
|
15
|
+
|
|
16
|
+
### 流程
|
|
17
|
+
|
|
18
|
+
**第一步:检查活跃任务**
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
{{PYTHON_CMD}} ./.trellis/scripts/task.py current
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
- 有活跃任务 → 询问用户:"当前有活跃任务 `[任务名]`,是否切换到架构分析任务?"
|
|
25
|
+
- 用户拒绝 → 终止,不做任何操作
|
|
26
|
+
- 用户同意 → 执行 `{{PYTHON_CMD}} ./.trellis/scripts/task.py finish` 结束当前会话,再继续
|
|
27
|
+
- 无活跃任务 → 直接继续
|
|
28
|
+
|
|
29
|
+
**第二步:询问分析范围**
|
|
30
|
+
|
|
31
|
+
让用户指定要分析的目录、模块,或整个代码库。根据项目结构给出建议范围。
|
|
32
|
+
|
|
33
|
+
**第三步:创建架构分析任务**
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
{{PYTHON_CMD}} ./.trellis/scripts/task.py create "架构分析: <scope>" --slug arch-analysis-<MMDD>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
**第四步:通过 trellis-research 探索代码库**
|
|
40
|
+
|
|
41
|
+
dispatch `trellis-research` 子代理,探索指定范围,识别:
|
|
42
|
+
|
|
43
|
+
- 模块边界和依赖关系
|
|
44
|
+
- 现有的架构模式和开发风格
|
|
45
|
+
- 接口复杂度 vs 实现复杂度(shallow module 信号)
|
|
46
|
+
- 耦合点和测试困难区域
|
|
47
|
+
|
|
48
|
+
研究结果自动持久化到 `{TASK_DIR}/research/`,供后续步骤引用。
|
|
49
|
+
|
|
50
|
+
**第五步:Spec 驱动分析**
|
|
51
|
+
|
|
52
|
+
检查 `.trellis/spec/` 是否有相关规范:
|
|
53
|
+
|
|
54
|
+
**如果存在 spec**:
|
|
55
|
+
- 读取相关 spec 文档
|
|
56
|
+
- 以 spec 为评判标准分析代码
|
|
57
|
+
- 识别不符合 spec 的架构问题
|
|
58
|
+
- 生成编号的重构候选清单
|
|
59
|
+
|
|
60
|
+
**如果 spec 不存在或不完整**:
|
|
61
|
+
- 基于 `research/` 里的探索结果,识别现有模式和开发风格
|
|
62
|
+
- 与用户进行对话式讨论,每次只确认一个规范点
|
|
63
|
+
- 每确认一个规范点后,立即写入 `.trellis/spec/`(遵循现有 spec 格式,同步更新对应 `index.md`)
|
|
64
|
+
- 基于新建的 spec 给出候选清单
|
|
65
|
+
|
|
66
|
+
**第六步:输出候选清单**
|
|
67
|
+
|
|
68
|
+
将候选清单记录到任务 PRD 中:
|
|
69
|
+
|
|
70
|
+
```markdown
|
|
71
|
+
## 架构分析候选清单
|
|
72
|
+
|
|
73
|
+
1. **[模块名]** - 问题描述
|
|
74
|
+
- 涉及文件:`path/to/file.ts`
|
|
75
|
+
- 问题:[具体问题,如接口比实现复杂]
|
|
76
|
+
- 建议:[改进方向]
|
|
77
|
+
- 预期收益:[可维护性、可测试性等收益]
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
候选清单不是实现指令,需要用户选择后再创建具体实现任务。
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## Mode B: Pre-dev Guidance(前置架构指导)
|
|
85
|
+
|
|
86
|
+
**触发条件**:dispatch prompt 中包含 `架构审查模式: guidance`
|
|
87
|
+
|
|
88
|
+
### 流程
|
|
89
|
+
|
|
90
|
+
1. 读取活跃任务的 `prd.md` 和 `design.md`
|
|
91
|
+
2. 读取 `.trellis/spec/` 中的相关规范
|
|
92
|
+
3. 基于 PRD 和 design 的内容,输出架构指导
|
|
93
|
+
4. 将指导内容追加到活跃任务的 `design.md`:
|
|
94
|
+
|
|
95
|
+
```markdown
|
|
96
|
+
## 架构指导(Pre-development)
|
|
97
|
+
|
|
98
|
+
### 模块边界建议
|
|
99
|
+
[基于 PRD 范围的建议]
|
|
100
|
+
|
|
101
|
+
### 关键抽象设计
|
|
102
|
+
[需要明确的接口和契约]
|
|
103
|
+
|
|
104
|
+
### 潜在架构风险
|
|
105
|
+
[可能导致结构漂移的设计决策]
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### 禁止操作
|
|
109
|
+
|
|
110
|
+
- 不创建新的 Trellis 任务
|
|
111
|
+
- 不调用 `task.py create` 或 `task.py start`
|
|
112
|
+
- 不修改实现代码
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## Mode C: Deep Review(深度审查)
|
|
117
|
+
|
|
118
|
+
**触发条件**:dispatch prompt 中包含 `架构审查模式: deep-review`
|
|
119
|
+
|
|
120
|
+
### 流程
|
|
121
|
+
|
|
122
|
+
1. 从 dispatch prompt 读取改动文件列表
|
|
123
|
+
2. 读取活跃任务的 `prd.md` 和 `design.md`(含 `## 架构指导` 段落,如有)
|
|
124
|
+
3. 读取 `.trellis/spec/` 中的相关规范
|
|
125
|
+
4. 审查改动代码,检查:
|
|
126
|
+
- 是否遵循了 `design.md` 中的架构指导
|
|
127
|
+
- 是否引入了不必要的抽象或中间层
|
|
128
|
+
- 模块边界是否清晰
|
|
129
|
+
- 是否产生了架构漂移(偏离 spec 或架构指导)
|
|
130
|
+
5. 输出审查报告
|
|
4
131
|
|
|
5
|
-
|
|
132
|
+
### 报告格式
|
|
6
133
|
|
|
7
|
-
|
|
134
|
+
```markdown
|
|
135
|
+
## 深度架构审查报告
|
|
8
136
|
|
|
9
|
-
|
|
137
|
+
**结论:通过 / 失败**
|
|
10
138
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
4. Propose the smallest structural change that improves maintainability.
|
|
15
|
-
5. Preserve task alignment — do not widen scope without a concrete reason.
|
|
139
|
+
### 审查范围
|
|
140
|
+
- 改动文件:[列表]
|
|
141
|
+
- 对照标准:[spec 文件列表]
|
|
16
142
|
|
|
17
|
-
|
|
143
|
+
### 发现的问题
|
|
144
|
+
1. `<file>:<line>` - [问题描述]
|
|
145
|
+
- 违反了:[spec 条目 / 架构指导段落]
|
|
146
|
+
- 建议:[修改方向]
|
|
18
147
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
- configuration or strategy layers without current need
|
|
23
|
-
- defensive branching for impossible internal states
|
|
24
|
-
- refactors that move code around without improving boundaries
|
|
148
|
+
### 阻断性问题
|
|
149
|
+
[必须修复才能通过的问题,如无则写"无"]
|
|
150
|
+
```
|
|
25
151
|
|
|
26
|
-
|
|
27
|
-
- direct control flow
|
|
28
|
-
- explicit boundaries
|
|
29
|
-
- behavior-centered module seams
|
|
30
|
-
- changes justified by current requirements or proven maintenance pain
|
|
152
|
+
**审查失败时**:报告阻断性问题,主 session 将把代码打回 `trellis-implement` 修改,并重新进入完整的 review 循环。
|
|
31
153
|
|
|
32
|
-
|
|
154
|
+
### 禁止操作
|
|
33
155
|
|
|
34
|
-
|
|
35
|
-
-
|
|
36
|
-
-
|
|
37
|
-
- what not to add
|
|
38
|
-
- what must stay aligned with current task scope
|
|
156
|
+
- 不创建新的 Trellis 任务
|
|
157
|
+
- 不调用 `task.py`
|
|
158
|
+
- 不直接修改实现代码
|
|
@@ -187,7 +187,7 @@ Sub-agent mode: curate `implement.jsonl` and `check.jsonl` as spec/research mani
|
|
|
187
187
|
|
|
188
188
|
Planning order for this Claude Code path: `task.py create` → `trellis-brainstorm` → `trellis-grill-me` → development strategy decision.
|
|
189
189
|
Do not enter development strategy decisions until `prd.md` has been tightened through repository-first clarification and one-question-at-a-time follow-up.
|
|
190
|
-
Before `task.py start`, record the development strategy decisions in the task documents. Complex tasks should store them in `implement.md`: development mode (current session / subagent), branch vs worktree, default flow vs TDD, plus the planned review-gate order: `trellis-spec-review` → `trellis-code-review` → `trellis-code-architecture-review`. If the strategy is `subagent + worktree`, pin the shared path to `./.claude/worktree` and require every code-development subagent to use it. If the strategy is TDD, record `trellis-tdd` as the reference flow.
|
|
190
|
+
Before `task.py start`, record the development strategy decisions in the task documents. Complex tasks should store them in `implement.md`: development mode (current session / subagent), branch vs worktree, default flow vs TDD, plus the planned review-gate order: `trellis-spec-review` → `trellis-code-review` → `trellis-code-architecture-review`. If the strategy is `subagent + worktree`, pin the shared path to `./.claude/worktree` and require every code-development subagent to use it. If the strategy is TDD, record `trellis-tdd` as the reference flow. If the task has `架构审查:enabled` in `implement.md`, dispatch `trellis-improve-codebase-architecture` with `架构审查模式: guidance` before `task.py start`, then append its output to `design.md`.
|
|
191
191
|
[/workflow-state:planning]
|
|
192
192
|
|
|
193
193
|
<!-- Per-turn breadcrumb: shown throughout Phase 1 when codex.dispatch_mode=inline.
|
|
@@ -226,6 +226,7 @@ Dispatch prompt starts with `Active task: <task path from task.py current>`. Rea
|
|
|
226
226
|
If the chosen strategy is `subagent + worktree`, all code-development subagents must use the same `./.claude/worktree` path.
|
|
227
227
|
If the chosen strategy is TDD, align implementation and review expectations to `trellis-tdd`.
|
|
228
228
|
If the task is architecture-sensitive or enters structural refactoring, route the architecture pass through `trellis-improve-codebase-architecture` before widening the change.
|
|
229
|
+
If `implement.md` records `架构审查:enabled`, after `trellis-code-architecture-review` passes dispatch `trellis-improve-codebase-architecture` with `架构审查模式: deep-review` plus the changed file list from `git diff --name-only <base_branch>...HEAD`. On failure, report blocking issues and return to `trellis-implement`; re-run the full review loop until deep-review passes.
|
|
229
230
|
If the user asks to archive the current task, do not block on commit; archive is allowed even when code is not committed.
|
|
230
231
|
[/workflow-state:in_progress]
|
|
231
232
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "trellis-hgl",
|
|
3
|
-
"version": "0.6.0-beta.
|
|
3
|
+
"version": "0.6.0-beta.20",
|
|
4
4
|
"description": "AI capabilities grow like ivy — Trellis provides the structure to guide them along a disciplined path",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -12,31 +12,6 @@
|
|
|
12
12
|
"publishConfig": {
|
|
13
13
|
"access": "public"
|
|
14
14
|
},
|
|
15
|
-
"scripts": {
|
|
16
|
-
"build": "pnpm run clean && tsc && pnpm run copy-templates",
|
|
17
|
-
"clean": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\"",
|
|
18
|
-
"copy-templates": "node scripts/copy-templates.js",
|
|
19
|
-
"dev": "tsc --watch",
|
|
20
|
-
"start": "node ./dist/cli/index.js",
|
|
21
|
-
"test": "vitest run",
|
|
22
|
-
"test:watch": "vitest",
|
|
23
|
-
"test:coverage": "vitest run --coverage",
|
|
24
|
-
"lint": "eslint src/ test/",
|
|
25
|
-
"lint:fix": "eslint src/ test/ --fix",
|
|
26
|
-
"format": "prettier --write src/",
|
|
27
|
-
"format:check": "prettier --check src/",
|
|
28
|
-
"typecheck": "tsc --noEmit",
|
|
29
|
-
"lint:py": "basedpyright",
|
|
30
|
-
"lint:all": "pnpm lint && pnpm lint:py",
|
|
31
|
-
"prepublishOnly": "pnpm run build && node -e \"const fs=require('node:fs'); fs.copyFileSync('../../README.md','README.md'); fs.copyFileSync('../../LICENSE','LICENSE');\"",
|
|
32
|
-
"release": "node scripts/release.js patch",
|
|
33
|
-
"release:minor": "node scripts/release.js minor",
|
|
34
|
-
"release:major": "node scripts/release.js major",
|
|
35
|
-
"release:beta": "node scripts/release.js beta",
|
|
36
|
-
"release:rc": "node scripts/release.js rc",
|
|
37
|
-
"release:promote": "node scripts/release.js promote",
|
|
38
|
-
"manifest": "node scripts/create-manifest.js"
|
|
39
|
-
},
|
|
40
15
|
"keywords": [
|
|
41
16
|
"ai",
|
|
42
17
|
"workflow",
|
|
@@ -52,14 +27,14 @@
|
|
|
52
27
|
"author": "Mindfold LLC",
|
|
53
28
|
"license": "AGPL-3.0-only",
|
|
54
29
|
"dependencies": {
|
|
55
|
-
"trellis-hgl-core": "workspace:*",
|
|
56
30
|
"chalk": "^5.3.0",
|
|
57
31
|
"commander": "^12.1.0",
|
|
58
32
|
"figlet": "^1.9.4",
|
|
59
33
|
"giget": "^3.1.1",
|
|
60
34
|
"inquirer": "^9.3.7",
|
|
61
35
|
"undici": "^6.21.0",
|
|
62
|
-
"zod": "^4.4.2"
|
|
36
|
+
"zod": "^4.4.2",
|
|
37
|
+
"trellis-hgl-core": "0.6.0-beta.20"
|
|
63
38
|
},
|
|
64
39
|
"devDependencies": {
|
|
65
40
|
"@eslint/js": "^9.18.0",
|
|
@@ -86,5 +61,29 @@
|
|
|
86
61
|
"repository": {
|
|
87
62
|
"type": "git",
|
|
88
63
|
"url": "https://github.com/mindfold-ai/trellis.git"
|
|
64
|
+
},
|
|
65
|
+
"scripts": {
|
|
66
|
+
"build": "pnpm run clean && tsc && pnpm run copy-templates",
|
|
67
|
+
"clean": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\"",
|
|
68
|
+
"copy-templates": "node scripts/copy-templates.js",
|
|
69
|
+
"dev": "tsc --watch",
|
|
70
|
+
"start": "node ./dist/cli/index.js",
|
|
71
|
+
"test": "vitest run",
|
|
72
|
+
"test:watch": "vitest",
|
|
73
|
+
"test:coverage": "vitest run --coverage",
|
|
74
|
+
"lint": "eslint src/ test/",
|
|
75
|
+
"lint:fix": "eslint src/ test/ --fix",
|
|
76
|
+
"format": "prettier --write src/",
|
|
77
|
+
"format:check": "prettier --check src/",
|
|
78
|
+
"typecheck": "tsc --noEmit",
|
|
79
|
+
"lint:py": "basedpyright",
|
|
80
|
+
"lint:all": "pnpm lint && pnpm lint:py",
|
|
81
|
+
"release": "node scripts/release.js patch",
|
|
82
|
+
"release:minor": "node scripts/release.js minor",
|
|
83
|
+
"release:major": "node scripts/release.js major",
|
|
84
|
+
"release:beta": "node scripts/release.js beta",
|
|
85
|
+
"release:rc": "node scripts/release.js rc",
|
|
86
|
+
"release:promote": "node scripts/release.js promote",
|
|
87
|
+
"manifest": "node scripts/create-manifest.js"
|
|
89
88
|
}
|
|
90
|
-
}
|
|
89
|
+
}
|