trellis-hgl 0.6.0-beta.19 → 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.
@@ -3,6 +3,7 @@ name: trellis-check
3
3
  description: |
4
4
  Code quality check expert. Reviews code changes against specs and self-fixes issues.
5
5
  tools: Read, Write, Edit, Bash, Glob, Grep, mcp__exa__web_search_exa, mcp__exa__get_code_context_exa
6
+ model: opus
6
7
  ---
7
8
  # Check Agent
8
9
 
@@ -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
- Use this skill when the user explicitly asks for architecture improvement, when a refactor is structurally risky, or when the workflow identifies a task as architecture-sensitive.
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
- ## Purpose
132
+ ### 报告格式
6
133
 
7
- Reduce structural drift, prevent AI-generated spaghetti code, and converge on a simpler long-term shape before or during refactoring.
134
+ ```markdown
135
+ ## 深度架构审查报告
8
136
 
9
- ## Core Responsibilities
137
+ **结论:通过 / 失败**
10
138
 
11
- 1. Identify the architectural problem being solved.
12
- 2. Distinguish real structural issues from cosmetic cleanup.
13
- 3. Reduce unnecessary abstraction, indirection, and speculative flexibility.
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
- ## Review Lens
143
+ ### 发现的问题
144
+ 1. `<file>:<line>` - [问题描述]
145
+ - 违反了:[spec 条目 / 架构指导段落]
146
+ - 建议:[修改方向]
18
147
 
19
- Challenge changes that introduce:
20
- - wrappers with no clear ownership value
21
- - abstractions created for hypothetical future reuse
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
- Prefer:
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
- ## Output Standard
154
+ ### 禁止操作
33
155
 
34
- When this skill is used, it should produce:
35
- - the architectural concern in plain language
36
- - the smallest acceptable direction to fix it
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.19",
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",
@@ -34,7 +34,7 @@
34
34
  "inquirer": "^9.3.7",
35
35
  "undici": "^6.21.0",
36
36
  "zod": "^4.4.2",
37
- "trellis-hgl-core": "0.6.0-beta.19"
37
+ "trellis-hgl-core": "0.6.0-beta.20"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@eslint/js": "^9.18.0",