@huajiwuyan/hello 3.0.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/README.md +68 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +448 -0
- package/package.json +38 -0
- package/templates/claude/commands/hello.md +760 -0
- package/templates/claude/skills/SKILL.md +90 -0
- package/templates/claude/skills/SKILL.toml +7 -0
- package/templates/claude/skills/assets/icon-large.svg +12 -0
- package/templates/claude/skills/assets/icon-small-400px.svg +12 -0
- package/templates/claude/skills/assets/templates/CHANGELOG.md +24 -0
- package/templates/claude/skills/assets/templates/CHANGELOG_{YYYY}.md +25 -0
- package/templates/claude/skills/assets/templates/INDEX.md +36 -0
- package/templates/claude/skills/assets/templates/archive/_index.md +22 -0
- package/templates/claude/skills/assets/templates/context.md +82 -0
- package/templates/claude/skills/assets/templates/modules/_index.md +22 -0
- package/templates/claude/skills/assets/templates/modules/module.md +35 -0
- package/templates/claude/skills/assets/templates/plan/proposal.md +104 -0
- package/templates/claude/skills/assets/templates/plan/tasks.md +49 -0
- package/templates/claude/skills/references/functions/auto.md +217 -0
- package/templates/claude/skills/references/functions/clean.md +167 -0
- package/templates/claude/skills/references/functions/commit.md +374 -0
- package/templates/claude/skills/references/functions/exec.md +178 -0
- package/templates/claude/skills/references/functions/help.md +105 -0
- package/templates/claude/skills/references/functions/init.md +228 -0
- package/templates/claude/skills/references/functions/plan.md +219 -0
- package/templates/claude/skills/references/functions/review.md +146 -0
- package/templates/claude/skills/references/functions/rollback.md +208 -0
- package/templates/claude/skills/references/functions/test.md +153 -0
- package/templates/claude/skills/references/functions/upgrade.md +371 -0
- package/templates/claude/skills/references/functions/validate.md +147 -0
- package/templates/claude/skills/references/rules/package.md +212 -0
- package/templates/claude/skills/references/rules/scaling.md +150 -0
- package/templates/claude/skills/references/rules/state.md +318 -0
- package/templates/claude/skills/references/rules/tools.md +371 -0
- package/templates/claude/skills/references/services/knowledge.md +408 -0
- package/templates/claude/skills/references/services/templates.md +344 -0
- package/templates/claude/skills/references/stages/analyze.md +201 -0
- package/templates/claude/skills/references/stages/design.md +379 -0
- package/templates/claude/skills/references/stages/develop.md +497 -0
- package/templates/claude/skills/references/stages/evaluate.md +286 -0
- package/templates/claude/skills/references/stages/tweak.md +244 -0
- package/templates/claude/skills/scripts/create_package.py +260 -0
- package/templates/claude/skills/scripts/list_packages.py +145 -0
- package/templates/claude/skills/scripts/migrate_package.py +399 -0
- package/templates/claude/skills/scripts/project_stats.py +438 -0
- package/templates/claude/skills/scripts/upgradewiki.py +321 -0
- package/templates/claude/skills/scripts/utils.py +596 -0
- package/templates/claude/skills/scripts/validate_package.py +309 -0
- package/templates/codex/prompts/hello.md +757 -0
- package/templates/codex/skills/SKILL.md +74 -0
- package/templates/codex/skills/SKILL.toml +7 -0
- package/templates/codex/skills/assets/icon-large.svg +12 -0
- package/templates/codex/skills/assets/icon-small-400px.svg +12 -0
- package/templates/codex/skills/assets/templates/CHANGELOG.md +24 -0
- package/templates/codex/skills/assets/templates/CHANGELOG_{YYYY}.md +25 -0
- package/templates/codex/skills/assets/templates/INDEX.md +36 -0
- package/templates/codex/skills/assets/templates/archive/_index.md +22 -0
- package/templates/codex/skills/assets/templates/context.md +82 -0
- package/templates/codex/skills/assets/templates/modules/_index.md +22 -0
- package/templates/codex/skills/assets/templates/modules/module.md +35 -0
- package/templates/codex/skills/assets/templates/plan/proposal.md +104 -0
- package/templates/codex/skills/assets/templates/plan/tasks.md +29 -0
- package/templates/codex/skills/references/functions/auto.md +181 -0
- package/templates/codex/skills/references/functions/brain.md +275 -0
- package/templates/codex/skills/references/functions/clean.md +154 -0
- package/templates/codex/skills/references/functions/commit.md +265 -0
- package/templates/codex/skills/references/functions/debug/condition-based-waiting.md +151 -0
- package/templates/codex/skills/references/functions/debug/defense-in-depth.md +147 -0
- package/templates/codex/skills/references/functions/debug/root-cause-tracing.md +168 -0
- package/templates/codex/skills/references/functions/debug.md +389 -0
- package/templates/codex/skills/references/functions/exec.md +153 -0
- package/templates/codex/skills/references/functions/help.md +101 -0
- package/templates/codex/skills/references/functions/init.md +221 -0
- package/templates/codex/skills/references/functions/plan.md +178 -0
- package/templates/codex/skills/references/functions/review.md +135 -0
- package/templates/codex/skills/references/functions/rlm.md +864 -0
- package/templates/codex/skills/references/functions/rollback.md +190 -0
- package/templates/codex/skills/references/functions/test.md +140 -0
- package/templates/codex/skills/references/functions/upgrade.md +363 -0
- package/templates/codex/skills/references/functions/validate.md +135 -0
- package/templates/codex/skills/references/rules/cache.md +136 -0
- package/templates/codex/skills/references/rules/scaling.md +124 -0
- package/templates/codex/skills/references/rules/state.md +201 -0
- package/templates/codex/skills/references/rules/tools.md +301 -0
- package/templates/codex/skills/references/services/attention.md +53 -0
- package/templates/codex/skills/references/services/knowledge.md +559 -0
- package/templates/codex/skills/references/services/package.md +383 -0
- package/templates/codex/skills/references/services/templates.md +390 -0
- package/templates/codex/skills/references/stages/analyze.md +191 -0
- package/templates/codex/skills/references/stages/design.md +355 -0
- package/templates/codex/skills/references/stages/develop.md +520 -0
- package/templates/codex/skills/references/stages/tweak.md +239 -0
- package/templates/codex/skills/rlm/__init__.py +39 -0
- package/templates/codex/skills/rlm/agent_orchestrator.py +422 -0
- package/templates/codex/skills/rlm/context_manager.py +366 -0
- package/templates/codex/skills/rlm/engine.py +915 -0
- package/templates/codex/skills/rlm/folding.py +391 -0
- package/templates/codex/skills/rlm/repl.py +452 -0
- package/templates/codex/skills/rlm/roles/analyzer.md +66 -0
- package/templates/codex/skills/rlm/roles/designer.md +94 -0
- package/templates/codex/skills/rlm/roles/explorer.md +43 -0
- package/templates/codex/skills/rlm/roles/implementer.md +62 -0
- package/templates/codex/skills/rlm/roles/kb_keeper.md +138 -0
- package/templates/codex/skills/rlm/roles/pkg_keeper.md +163 -0
- package/templates/codex/skills/rlm/roles/reviewer.md +74 -0
- package/templates/codex/skills/rlm/roles/synthesizer.md +90 -0
- package/templates/codex/skills/rlm/roles/tester.md +83 -0
- package/templates/codex/skills/rlm/schemas/agent_result.json +174 -0
- package/templates/codex/skills/rlm/session.py +376 -0
- package/templates/codex/skills/rlm/shared_tasks.py +370 -0
- package/templates/codex/skills/scripts/create_package.py +260 -0
- package/templates/codex/skills/scripts/list_packages.py +145 -0
- package/templates/codex/skills/scripts/migrate_package.py +399 -0
- package/templates/codex/skills/scripts/project_stats.py +438 -0
- package/templates/codex/skills/scripts/upgradewiki.py +321 -0
- package/templates/codex/skills/scripts/utils.py +596 -0
- package/templates/codex/skills/scripts/validate_package.py +309 -0
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
# 知识库与方案包模板服务
|
|
2
|
+
|
|
3
|
+
本模块定义模板使用规则,模板文件位于 `{TEMPLATE_DIR}` 目录。
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 服务概述
|
|
8
|
+
|
|
9
|
+
> 📌 规则引用: 路径基准变量定义见 references/rules/tools.md
|
|
10
|
+
|
|
11
|
+
```yaml
|
|
12
|
+
服务名称: 模板服务
|
|
13
|
+
适用范围: 所有涉及知识库创建和方案包创建的场景
|
|
14
|
+
核心职责:
|
|
15
|
+
- 模板存在性检查和降级处理
|
|
16
|
+
- 知识库模板管理
|
|
17
|
+
- 方案包模板管理
|
|
18
|
+
- 模板使用规则定义
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
<template_validation>
|
|
24
|
+
## 模板存在性检查
|
|
25
|
+
|
|
26
|
+
**检查时机:** 使用模板前必须验证
|
|
27
|
+
|
|
28
|
+
**检查流程:**
|
|
29
|
+
|
|
30
|
+
```yaml
|
|
31
|
+
步骤1 - 构建模板完整路径:
|
|
32
|
+
路径: {TEMPLATE_DIR}/{模板相对路径}
|
|
33
|
+
|
|
34
|
+
步骤2 - 验证模板存在:
|
|
35
|
+
存在: 读取模板内容,继续流程
|
|
36
|
+
不存在: 进入降级处理
|
|
37
|
+
|
|
38
|
+
降级处理:
|
|
39
|
+
知识库模板不存在:
|
|
40
|
+
- 暂停流程,提示用户检查模板目录
|
|
41
|
+
- 在输出中标注: "❌ 模板文件不存在"
|
|
42
|
+
- 等待用户决策或修复
|
|
43
|
+
|
|
44
|
+
方案包模板不存在:
|
|
45
|
+
- 暂停流程,提示用户检查模板目录
|
|
46
|
+
- proposal.md/tasks.md 为必需文件,缺失时无法继续
|
|
47
|
+
- 在输出中标注: "❌ 模板文件不存在"
|
|
48
|
+
- 等待用户决策或修复
|
|
49
|
+
```
|
|
50
|
+
</template_validation>
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
<script_degradation_integration>
|
|
55
|
+
## 脚本降级对接
|
|
56
|
+
|
|
57
|
+
> 📌 规则引用: 脚本执行报告机制详见 references/rules/tools.md
|
|
58
|
+
|
|
59
|
+
**场景:** 脚本因模板不存在而部分完成时,AI 接手继续。
|
|
60
|
+
|
|
61
|
+
### AI 接手时的文件创建指南
|
|
62
|
+
|
|
63
|
+
当脚本返回 `success=false` 且 pending 中包含文件创建任务时,AI 应按以下结构创建文件:
|
|
64
|
+
|
|
65
|
+
```yaml
|
|
66
|
+
proposal.md 必需章节:
|
|
67
|
+
- 元信息(方案包名称、创建日期、类型)
|
|
68
|
+
- 1. 需求(背景、目标、约束条件、验收标准)
|
|
69
|
+
- 2. 方案(技术方案、影响范围、风险评估)
|
|
70
|
+
|
|
71
|
+
tasks.md 必需章节:
|
|
72
|
+
- 元数据头部(feature, created, status, mode)
|
|
73
|
+
- 进度概览(完成/失败/跳过/总数)
|
|
74
|
+
- 任务列表(按阶段/模块分组)
|
|
75
|
+
- 执行日志(最近的状态变更记录)
|
|
76
|
+
- 执行备注
|
|
77
|
+
|
|
78
|
+
_index.md 必需结构:
|
|
79
|
+
- 快速索引表格(时间戳、名称、类型、涉及模块、决策、结果)
|
|
80
|
+
- 结果状态说明
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### 质量检查要点
|
|
84
|
+
|
|
85
|
+
AI 在接手前应验证脚本已创建的文件:
|
|
86
|
+
|
|
87
|
+
```yaml
|
|
88
|
+
proposal.md:
|
|
89
|
+
- 文件存在性
|
|
90
|
+
- 包含元信息章节
|
|
91
|
+
- 包含需求章节
|
|
92
|
+
- 包含方案章节
|
|
93
|
+
|
|
94
|
+
tasks.md:
|
|
95
|
+
- 文件存在性
|
|
96
|
+
- 包含元数据头部(@feature, @created, @status, @mode)
|
|
97
|
+
- 包含进度概览章节
|
|
98
|
+
- 包含任务列表章节
|
|
99
|
+
- 包含执行日志章节
|
|
100
|
+
- 任务使用正确的状态符号([ ] [√] [X] [-] [?])
|
|
101
|
+
|
|
102
|
+
目录结构:
|
|
103
|
+
- plan/YYYYMMDDHHMM_feature/ 目录存在
|
|
104
|
+
- 目录名格式正确(12位时间戳_功能名)
|
|
105
|
+
```
|
|
106
|
+
</script_degradation_integration>
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## 模板文件索引
|
|
111
|
+
|
|
112
|
+
### 知识库模板 ({TEMPLATE_DIR})
|
|
113
|
+
|
|
114
|
+
| 模板路径 | 生成路径 | 用途 |
|
|
115
|
+
|---------|---------|------|
|
|
116
|
+
| INDEX.md | helloagents/INDEX.md | 知识库入口 |
|
|
117
|
+
| context.md | helloagents/context.md | 项目上下文 |
|
|
118
|
+
| CHANGELOG.md | helloagents/CHANGELOG.md | 变更日志 |
|
|
119
|
+
| CHANGELOG_{YYYY}.md | helloagents/CHANGELOG_{YYYY}.md | 年度变更日志(大型项目分片) |
|
|
120
|
+
| modules/_index.md | helloagents/modules/_index.md | 模块索引 |
|
|
121
|
+
| modules/module.md | helloagents/modules/{模块名}.md | 模块文档 |
|
|
122
|
+
| archive/_index.md | helloagents/archive/_index.md | 归档索引 |
|
|
123
|
+
|
|
124
|
+
### 方案包模板 ({TEMPLATE_DIR}/plan/)
|
|
125
|
+
|
|
126
|
+
| 模板路径 | 生成路径 | 用途 |
|
|
127
|
+
|---------|---------|------|
|
|
128
|
+
| plan/proposal.md | helloagents/plan/{YYYYMMDDHHMM}_{feature}/proposal.md | 变更提案 |
|
|
129
|
+
| plan/tasks.md | helloagents/plan/{YYYYMMDDHHMM}_{feature}/tasks.md | 任务清单 |
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## 模板章节结构
|
|
134
|
+
|
|
135
|
+
> 标注"必须"的章节在填充时必须包含,标注"可选"的章节按需填充
|
|
136
|
+
|
|
137
|
+
```yaml
|
|
138
|
+
proposal.md:
|
|
139
|
+
- 元信息(必须)
|
|
140
|
+
- 1. 需求(必须): 背景、目标、约束条件、验收标准
|
|
141
|
+
- 2. 方案(必须): 技术方案、影响范围、风险评估
|
|
142
|
+
- 3. 技术设计(可选): 架构设计、API设计、数据模型
|
|
143
|
+
- 4. 核心场景(可选): 场景描述(执行后同步到模块文档)
|
|
144
|
+
- 5. 技术决策(可选): 决策记录
|
|
145
|
+
|
|
146
|
+
tasks.md:
|
|
147
|
+
- 元数据头部(必须): @feature, @created, @status, @mode
|
|
148
|
+
- 进度概览(必须): 完成/失败/跳过/总数 统计
|
|
149
|
+
- 任务列表(必须): 按阶段/模块分组的任务项
|
|
150
|
+
- 执行日志(必须): 最近 5 条状态变更记录
|
|
151
|
+
- 执行备注(必须): 特殊情况说明
|
|
152
|
+
|
|
153
|
+
module.md:
|
|
154
|
+
- 职责(必须)
|
|
155
|
+
- 接口定义(可选): 公共API、数据结构
|
|
156
|
+
- 行为规范(必须): 场景描述
|
|
157
|
+
- 依赖关系(必须)
|
|
158
|
+
|
|
159
|
+
context.md:
|
|
160
|
+
- 1. 基本信息(必须)
|
|
161
|
+
- 2. 技术上下文(必须)
|
|
162
|
+
- 3. 项目概述(必须)
|
|
163
|
+
- 4. 开发约定(必须)
|
|
164
|
+
- 5. 当前约束(必须)
|
|
165
|
+
- 6. 已知技术债务(可选)
|
|
166
|
+
|
|
167
|
+
archive/_index.md:
|
|
168
|
+
- 快速索引(必须)
|
|
169
|
+
- 按月归档(必须)
|
|
170
|
+
- 结果状态说明(必须)
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
## tasks.md 增强格式示例
|
|
176
|
+
|
|
177
|
+
> 此格式支持进度快照机制(见 attention.md),便于状态跟踪和近因效应利用
|
|
178
|
+
|
|
179
|
+
```markdown
|
|
180
|
+
<!--
|
|
181
|
+
@feature: {功能名称}
|
|
182
|
+
@created: {YYYY-MM-DD HH:MM}
|
|
183
|
+
@status: pending | in_progress | completed | failed
|
|
184
|
+
@mode: standard | lightweight
|
|
185
|
+
-->
|
|
186
|
+
|
|
187
|
+
# 任务清单: {功能名称}
|
|
188
|
+
|
|
189
|
+
## 进度概览
|
|
190
|
+
|
|
191
|
+
| 状态 | 数量 |
|
|
192
|
+
|------|------|
|
|
193
|
+
| [√] 完成 | 0 |
|
|
194
|
+
| [X] 失败 | 0 |
|
|
195
|
+
| [-] 跳过 | 0 |
|
|
196
|
+
| [ ] 待执行 | N |
|
|
197
|
+
| **总计** | N |
|
|
198
|
+
|
|
199
|
+
## 任务列表
|
|
200
|
+
|
|
201
|
+
### 阶段1: {阶段名称}
|
|
202
|
+
|
|
203
|
+
- [ ] 任务1: 描述
|
|
204
|
+
- [ ] 任务2: 描述
|
|
205
|
+
|
|
206
|
+
### 阶段2: {阶段名称}
|
|
207
|
+
|
|
208
|
+
- [ ] 任务3: 描述
|
|
209
|
+
- [ ] 任务4: 描述
|
|
210
|
+
|
|
211
|
+
## 执行日志
|
|
212
|
+
|
|
213
|
+
> 最近 5 条状态变更(新记录在上)
|
|
214
|
+
|
|
215
|
+
| 时间 | 任务 | 状态 | 备注 |
|
|
216
|
+
|------|------|------|------|
|
|
217
|
+
| - | - | - | - |
|
|
218
|
+
|
|
219
|
+
## 执行备注
|
|
220
|
+
|
|
221
|
+
(执行过程中的特殊情况说明)
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
**格式说明:**
|
|
225
|
+
|
|
226
|
+
```yaml
|
|
227
|
+
元数据头部:
|
|
228
|
+
@feature: 功能名称,与目录名对应
|
|
229
|
+
@created: 创建时间
|
|
230
|
+
@status: 方案包整体状态
|
|
231
|
+
- pending: 待执行
|
|
232
|
+
- in_progress: 执行中
|
|
233
|
+
- completed: 已完成
|
|
234
|
+
- failed: 执行失败
|
|
235
|
+
@mode: 执行模式(standard 标准开发 / lightweight 轻量迭代)
|
|
236
|
+
|
|
237
|
+
进度概览:
|
|
238
|
+
- 实时统计各状态任务数量
|
|
239
|
+
- 每次任务状态变更后更新
|
|
240
|
+
|
|
241
|
+
执行日志:
|
|
242
|
+
- 保留最近 5 条状态变更记录
|
|
243
|
+
- 格式: 时间 | 任务名 | 新状态 | 备注
|
|
244
|
+
- 失败任务必须记录错误原因
|
|
245
|
+
- 便于 AI 避免重复错误
|
|
246
|
+
|
|
247
|
+
更新时机:
|
|
248
|
+
- 任务状态变更时更新 tasks.md
|
|
249
|
+
- 响应末尾输出进度快照(见 attention.md)
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
## 使用规则
|
|
255
|
+
|
|
256
|
+
### 创建知识库
|
|
257
|
+
|
|
258
|
+
```yaml
|
|
259
|
+
步骤:
|
|
260
|
+
1. 读取 {TEMPLATE_DIR} 下的模板文件
|
|
261
|
+
2. 根据项目实际情况填充占位符内容
|
|
262
|
+
3. 写入用户项目的 helloagents/ 目录
|
|
263
|
+
|
|
264
|
+
目标结构: 见 G1 "知识库完整结构(SSOT)"
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
### 创建方案包
|
|
268
|
+
|
|
269
|
+
```yaml
|
|
270
|
+
步骤:
|
|
271
|
+
1. 读取 {TEMPLATE_DIR}/plan/ 下的模板文件
|
|
272
|
+
2. 根据需求实际情况填充占位符内容
|
|
273
|
+
3. 写入 helloagents/plan/{YYYYMMDDHHMM}_{feature}/ 目录
|
|
274
|
+
|
|
275
|
+
目标结构:
|
|
276
|
+
helloagents/plan/{YYYYMMDDHHMM}_{feature}/
|
|
277
|
+
├── proposal.md
|
|
278
|
+
└── tasks.md
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
---
|
|
282
|
+
|
|
283
|
+
## 方案包相关规则
|
|
284
|
+
|
|
285
|
+
> 以下规则与方案包模板的使用密切相关,故置于此处统一管理。
|
|
286
|
+
|
|
287
|
+
### 轻量迭代的方案包创建
|
|
288
|
+
|
|
289
|
+
```yaml
|
|
290
|
+
方案包创建:
|
|
291
|
+
- 必须创建 proposal.md(完整版,与标准开发相同)
|
|
292
|
+
- 必须创建 tasks.md
|
|
293
|
+
|
|
294
|
+
目录创建规则: 按 G1 "目录/文件自动创建规则" 执行(目录不存在时自动创建)
|
|
295
|
+
升级处理: 见 G5 "轻量迭代 - 升级条件"
|
|
296
|
+
迁移规则: 迁移至 archive/ 时标注"轻量迭代"
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
### 技术决策章节(何时需要写)
|
|
300
|
+
|
|
301
|
+
```yaml
|
|
302
|
+
需要写:
|
|
303
|
+
- 涉及架构变更
|
|
304
|
+
- 涉及技术选型(新库/框架/工具)
|
|
305
|
+
- 存在多种实现路径需权衡
|
|
306
|
+
- 有长期影响的技术约束
|
|
307
|
+
|
|
308
|
+
不需要写:
|
|
309
|
+
- 简单bug修复
|
|
310
|
+
- 样式/文案调整
|
|
311
|
+
- 明确无歧义的实现
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
### 决策ID格式
|
|
315
|
+
|
|
316
|
+
```yaml
|
|
317
|
+
格式: {feature}#D{NNN}
|
|
318
|
+
示例: add-login#D001, add-login#D002
|
|
319
|
+
简写: 同一方案包内可省略前缀,跨方案引用必须带前缀
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
### 概述类型方案包(overview)
|
|
323
|
+
|
|
324
|
+
> 📌 规则引用: 详细规则见 G6 "方案包类型"
|
|
325
|
+
|
|
326
|
+
---
|
|
327
|
+
|
|
328
|
+
## 异常处理
|
|
329
|
+
|
|
330
|
+
```yaml
|
|
331
|
+
模板文件不存在:
|
|
332
|
+
- 使用内置默认结构
|
|
333
|
+
- 输出标注"ℹ️ 使用默认模板"
|
|
334
|
+
- 继续流程
|
|
335
|
+
|
|
336
|
+
模板读取失败:
|
|
337
|
+
- 检查文件权限
|
|
338
|
+
- 降级为内置默认结构
|
|
339
|
+
- 输出警告信息
|
|
340
|
+
|
|
341
|
+
占位符填充失败:
|
|
342
|
+
- 保留未填充的占位符
|
|
343
|
+
- 输出警告,提示手动补充
|
|
344
|
+
- 继续流程
|
|
345
|
+
|
|
346
|
+
写入目标失败:
|
|
347
|
+
- 按 G1 "目录/文件自动创建规则" 创建目录
|
|
348
|
+
- 重试写入
|
|
349
|
+
- 仍失败则暂停,输出错误详情
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
---
|
|
353
|
+
|
|
354
|
+
## 规则引用索引
|
|
355
|
+
|
|
356
|
+
| 规则 | 定义位置 |
|
|
357
|
+
|------|---------|
|
|
358
|
+
| 路径基准变量 | references/rules/tools.md |
|
|
359
|
+
| 微调模式记录 | references/services/knowledge.md |
|
|
360
|
+
| 任务状态符号 | G6 |
|
|
361
|
+
| CHANGELOG格式 | references/services/knowledge.md |
|
|
362
|
+
| 大型项目分片 | references/rules/scaling.md |
|
|
363
|
+
| 知识库完整结构 | G1 |
|
|
364
|
+
| 目录/文件自动创建规则 | G1 |
|
|
365
|
+
| 方案包类型 | G6 |
|
|
366
|
+
| 轻量迭代升级条件 | G5 |
|
|
367
|
+
|
|
368
|
+
---
|
|
369
|
+
|
|
370
|
+
## 服务引用关系
|
|
371
|
+
|
|
372
|
+
```yaml
|
|
373
|
+
被引用:
|
|
374
|
+
- ~init 命令(知识库模板使用)
|
|
375
|
+
- 方案设计阶段(方案包模板使用)
|
|
376
|
+
- ~exec 命令(方案包验证)
|
|
377
|
+
- scripts/create_package.py(模板加载)
|
|
378
|
+
- scripts/migrate_package.py(_index.md 模板)
|
|
379
|
+
- scripts/validate_package.py(章节验证)
|
|
380
|
+
|
|
381
|
+
引用:
|
|
382
|
+
- G1 知识库完整结构
|
|
383
|
+
- G1 目录/文件自动创建规则
|
|
384
|
+
- G5 轻量迭代升级条件
|
|
385
|
+
- G6 方案包类型
|
|
386
|
+
- G6 任务状态符号
|
|
387
|
+
- references/rules/tools.md(脚本执行报告机制)
|
|
388
|
+
- references/rules/scaling.md(大型项目分片)
|
|
389
|
+
- references/services/knowledge.md(CHANGELOG格式)
|
|
390
|
+
```
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
# 项目分析模块
|
|
2
|
+
|
|
3
|
+
本模块定义项目分析阶段的详细规则,在轻量迭代或标准开发模式下执行。
|
|
4
|
+
|
|
5
|
+
**核心职责:** 纯信息收集,不做设计决策。为后续 DESIGN 阶段提供完整、准确的项目上下文。
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 模块入口
|
|
10
|
+
|
|
11
|
+
### 触发条件
|
|
12
|
+
|
|
13
|
+
```yaml
|
|
14
|
+
前置条件: 需求评估阶段复杂度判定为轻量迭代或标准开发模式
|
|
15
|
+
加载时机: 用户确认执行后加载
|
|
16
|
+
特点: 扫描目录,获取项目上下文,纯信息收集
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### 状态设置
|
|
20
|
+
|
|
21
|
+
```yaml
|
|
22
|
+
设置时机: 本模块被加载时
|
|
23
|
+
设置内容:
|
|
24
|
+
- CURRENT_STAGE = ANALYZE
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## 执行模式适配
|
|
30
|
+
|
|
31
|
+
<mode_adaptation>
|
|
32
|
+
|
|
33
|
+
### 模式行为
|
|
34
|
+
|
|
35
|
+
```yaml
|
|
36
|
+
读取状态变量: WORKFLOW_MODE
|
|
37
|
+
|
|
38
|
+
"交互模式"(INTERACTIVE,默认):
|
|
39
|
+
执行下方"执行流程"步骤1-6
|
|
40
|
+
遇到需要确认的场景: 按G3场景内容规则(确认场景)输出,等待用户选择
|
|
41
|
+
完成后: 自动流转到方案设计阶段(不输出阶段完成状态)
|
|
42
|
+
|
|
43
|
+
"全授权模式"(AUTO_FULL,~auto命令):
|
|
44
|
+
静默执行下方"执行流程"步骤1-6(不输出中间状态)
|
|
45
|
+
遇到需要确认的场景: 自动选择默认选项(如跳过初始化、继续大型项目分析)
|
|
46
|
+
完成后: 自动流转到方案设计阶段
|
|
47
|
+
|
|
48
|
+
"规划模式"(AUTO_PLAN,~plan命令):
|
|
49
|
+
静默执行下方"执行流程"步骤1-6(不输出中间状态)
|
|
50
|
+
完成后: 自动流转到方案设计阶段
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### 阶段流转
|
|
54
|
+
|
|
55
|
+
```yaml
|
|
56
|
+
项目分析完成后:
|
|
57
|
+
设置: CURRENT_STAGE = DESIGN
|
|
58
|
+
读取并执行: references/stages/design.md
|
|
59
|
+
传递: 项目上下文信息供方案设计使用
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
</mode_adaptation>
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## 执行流程
|
|
67
|
+
|
|
68
|
+
### 步骤1: 知识库开关检查
|
|
69
|
+
|
|
70
|
+
按 G1 "KB开关检查规则" 和 "KB_SKIPPED 变量生命周期" 执行。
|
|
71
|
+
|
|
72
|
+
```yaml
|
|
73
|
+
设置规则:
|
|
74
|
+
KB_CREATE_MODE = 0: 设置 KB_SKIPPED = true
|
|
75
|
+
KB_CREATE_MODE = 1/2/3: 设置 KB_SKIPPED = false
|
|
76
|
+
|
|
77
|
+
传递: 后续阶段(design, develop)直接使用此值(按 G1 "KB_SKIPPED 变量生命周期")
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### 步骤2: 检查知识库状态
|
|
81
|
+
|
|
82
|
+
```yaml
|
|
83
|
+
前置条件: KB_SKIPPED = false(仅开关=1/2/3时执行)
|
|
84
|
+
判定条件: 工作目录存在代码文件 且 需求不是"新建项目"
|
|
85
|
+
|
|
86
|
+
处理规则: 按 G1 "KB开关检查规则" 中的 KB_CREATE_MODE 值执行对应操作
|
|
87
|
+
|
|
88
|
+
知识库状态显示:
|
|
89
|
+
KB_CREATE_MODE = 0: "⚠️ 已跳过(开关关闭)"
|
|
90
|
+
KB_CREATE_MODE = 1/2/3 且存在: "✅ 已加载"
|
|
91
|
+
KB_CREATE_MODE = 1 且不存在: "⚠️ 不存在(建议执行 ~init)"
|
|
92
|
+
KB_CREATE_MODE = 2 且不存在: 编程任务 → "🔄 已自动创建",非编程 → 同1
|
|
93
|
+
KB_CREATE_MODE = 3 且不存在: "🔄 已自动创建"
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### 步骤3: 获取项目上下文
|
|
97
|
+
|
|
98
|
+
> 📌 规则引用: 子代理调用按 G9 "子代理编排 - ANALYZE" + G10 "跨CLI兼容规则" 执行
|
|
99
|
+
|
|
100
|
+
```yaml
|
|
101
|
+
执行内容:
|
|
102
|
+
KB_SKIPPED = true: 直接扫描代码库
|
|
103
|
+
KB_SKIPPED = false: 先检查知识库 → 不足则扫描代码库
|
|
104
|
+
|
|
105
|
+
目的: 为方案设计提供完整项目上下文
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### 步骤4: 提取关键目标与成功标准
|
|
109
|
+
|
|
110
|
+
```yaml
|
|
111
|
+
执行内容:
|
|
112
|
+
- 提取关键目标: 从完整需求中提炼核心目标
|
|
113
|
+
- 定义成功标准: 明确可验证的成功标准
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### 步骤5: 技术分析与准备
|
|
117
|
+
|
|
118
|
+
```yaml
|
|
119
|
+
执行内容:
|
|
120
|
+
- 定位相关模块
|
|
121
|
+
- 质量检查: 标记过时信息,扫描安全风险和代码异味
|
|
122
|
+
- 问题诊断: 分析日志或错误信息(如有)
|
|
123
|
+
- 技术信息收集(如需要): 使用联网搜索或MCP工具获取最新文档和最佳实践
|
|
124
|
+
|
|
125
|
+
外部工具调用(如需要):
|
|
126
|
+
触发条件: 需要获取最新技术文档、API参考、最佳实践等信息
|
|
127
|
+
调用规则: 按 G4 外部工具规则执行
|
|
128
|
+
状态保存: 调用前保存 SUSPENDED_STAGE = ANALYZE
|
|
129
|
+
状态恢复: 工具完成后恢复阶段状态,继续分析
|
|
130
|
+
输出格式: 按 G3 外部工具输出格式处理
|
|
131
|
+
|
|
132
|
+
输出物: 项目上下文信息(技术栈、模块结构、质量问题、技术约束)供方案设计使用
|
|
133
|
+
|
|
134
|
+
⚠️ 禁止行为:
|
|
135
|
+
- 不做技术选型决策(留给 DESIGN 阶段)
|
|
136
|
+
- 不设计实现方案(留给 DESIGN 阶段)
|
|
137
|
+
- 不进行代码修改(留给 DEVELOP 阶段)
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### 步骤6: 大型项目检测
|
|
141
|
+
|
|
142
|
+
> 脚本路径、存在性检查、错误恢复规则见 references/rules/tools.md
|
|
143
|
+
|
|
144
|
+
**脚本调用(可选):** `project_stats.py`(用于获取精确的项目统计数据)
|
|
145
|
+
|
|
146
|
+
```yaml
|
|
147
|
+
检测规则: 按 G9 "大型项目判定" 条件执行
|
|
148
|
+
|
|
149
|
+
检测到大型项目:
|
|
150
|
+
"交互模式": 按G3场景内容规则(确认场景)输出,等待用户选择
|
|
151
|
+
"全授权模式"/"规划模式": 自动继续,在分析结果中标注"大型项目,已启用分批处理"
|
|
152
|
+
|
|
153
|
+
未检测到大型项目: 继续阶段流转
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## 用户选择处理
|
|
159
|
+
|
|
160
|
+
> 本章节定义项目分析阶段需要用户确认的场景,供 G3 输出格式统一提取。
|
|
161
|
+
|
|
162
|
+
### 场景: 知识库状态确认(知识库不存在且需用户确认)
|
|
163
|
+
|
|
164
|
+
```yaml
|
|
165
|
+
触发条件:
|
|
166
|
+
- KB_CREATE_MODE = 1 且知识库不存在
|
|
167
|
+
- KB_CREATE_MODE = 2 且非编程任务且知识库不存在
|
|
168
|
+
|
|
169
|
+
内容要素:
|
|
170
|
+
- 检测结果: 知识库不存在
|
|
171
|
+
- 建议操作: 执行 ~init 初始化知识库
|
|
172
|
+
|
|
173
|
+
选项:
|
|
174
|
+
执行初始化: 转发到 ~init 命令
|
|
175
|
+
跳过: 设置 KB_SKIPPED = true,继续项目分析
|
|
176
|
+
取消: 按 G6 状态重置协议执行
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### 场景: 大型项目确认
|
|
180
|
+
|
|
181
|
+
```yaml
|
|
182
|
+
触发条件: 检测到大型项目(按 G9 "大型项目判定" 条件)
|
|
183
|
+
|
|
184
|
+
内容要素:
|
|
185
|
+
- 检测结果: 项目规模统计(源文件数/代码行数/模块数)
|
|
186
|
+
- 处理说明: 将启用分批处理策略
|
|
187
|
+
|
|
188
|
+
选项:
|
|
189
|
+
继续: 按大型项目策略继续分析
|
|
190
|
+
取消: 按 G6 状态重置协议执行
|
|
191
|
+
```
|