@haaaiawd/anws 1.2.4 → 2.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.
Files changed (71) hide show
  1. package/README.md +208 -173
  2. package/bin/cli.js +22 -9
  3. package/lib/adapters/index.js +157 -0
  4. package/lib/agents.js +185 -0
  5. package/lib/changelog.js +187 -0
  6. package/lib/copy.js +72 -1
  7. package/lib/diff.js +270 -0
  8. package/lib/init.js +238 -174
  9. package/lib/install-state.js +195 -0
  10. package/lib/manifest.js +184 -42
  11. package/lib/output.js +185 -13
  12. package/lib/prompt.js +284 -0
  13. package/lib/resources/index.js +27 -0
  14. package/lib/update.js +355 -149
  15. package/package.json +10 -6
  16. package/templates/.agents/skills/concept-modeler/SKILL.md +176 -0
  17. package/templates/{.agent → .agents}/skills/design-reviewer/SKILL.md +6 -6
  18. package/templates/.agents/skills/nexus-mapper/SKILL.md +306 -0
  19. package/templates/.agents/skills/nexus-mapper/references/language-customization.md +164 -0
  20. package/templates/.agents/skills/nexus-mapper/references/output-schema.md +298 -0
  21. package/templates/.agents/skills/nexus-mapper/references/probe-protocol.md +246 -0
  22. package/templates/.agents/skills/nexus-mapper/scripts/extract_ast.py +706 -0
  23. package/templates/.agents/skills/nexus-mapper/scripts/git_detective.py +194 -0
  24. package/templates/.agents/skills/nexus-mapper/scripts/languages.json +127 -0
  25. package/templates/.agents/skills/nexus-mapper/scripts/query_graph.py +556 -0
  26. package/templates/.agents/skills/nexus-mapper/scripts/requirements.txt +6 -0
  27. package/templates/{.agent → .agents}/skills/report-template/SKILL.md +11 -14
  28. package/templates/.agents/skills/report-template/references/REPORT_TEMPLATE.md +100 -0
  29. package/templates/{.agent → .agents}/skills/runtime-inspector/SKILL.md +1 -1
  30. package/templates/.agents/skills/sequential-thinking/SKILL.md +166 -0
  31. package/templates/.agents/skills/spec-writer/SKILL.md +108 -0
  32. package/templates/{.agent → .agents}/skills/spec-writer/references/prd_template.md +1 -1
  33. package/templates/{.agent → .agents}/skills/system-architect/SKILL.md +3 -3
  34. package/templates/.agents/skills/system-architect/references/rfc_template.md +59 -0
  35. package/templates/{.agent → .agents}/skills/system-designer/SKILL.md +6 -6
  36. package/templates/{.agent → .agents}/skills/system-designer/references/system-design-template.md +75 -25
  37. package/templates/{.agent → .agents}/skills/task-planner/SKILL.md +1 -1
  38. package/templates/.agents/skills/task-planner/references/TASK_TEMPLATE.md +144 -0
  39. package/templates/{.agent → .agents}/skills/task-reviewer/SKILL.md +4 -3
  40. package/templates/{.agent → .agents}/skills/tech-evaluator/SKILL.md +2 -2
  41. package/templates/{.agent → .agents}/skills/tech-evaluator/references/ADR_TEMPLATE.md +10 -0
  42. package/templates/{.agent → .agents}/workflows/blueprint.md +38 -33
  43. package/templates/{.agent → .agents}/workflows/challenge.md +21 -15
  44. package/templates/{.agent → .agents}/workflows/change.md +24 -15
  45. package/templates/{.agent → .agents}/workflows/craft.md +9 -20
  46. package/templates/{.agent → .agents}/workflows/design-system.md +83 -56
  47. package/templates/{.agent → .agents}/workflows/explore.md +6 -19
  48. package/templates/{.agent → .agents}/workflows/forge.md +36 -38
  49. package/templates/{.agent → .agents}/workflows/genesis.md +76 -64
  50. package/templates/.agents/workflows/probe.md +168 -0
  51. package/templates/{.agent → .agents}/workflows/quickstart.md +7 -12
  52. package/templates/.agents/workflows/upgrade.md +192 -0
  53. package/templates/AGENTS.md +134 -113
  54. package/templates/.agent/skills/build-inspector/SKILL.md +0 -83
  55. package/templates/.agent/skills/complexity-guard/SKILL.md +0 -71
  56. package/templates/.agent/skills/complexity-guard/references/anti_patterns.md +0 -21
  57. package/templates/.agent/skills/concept-modeler/SKILL.md +0 -112
  58. package/templates/.agent/skills/concept-modeler/prompts/GLOSSARY_PROMPT.md +0 -40
  59. package/templates/.agent/skills/concept-modeler/references/ENTITY_EXTRACTION_PROMPT.md +0 -299
  60. package/templates/.agent/skills/concept-modeler/scripts/glossary_gen.py +0 -66
  61. package/templates/.agent/skills/git-forensics/SKILL.md +0 -74
  62. package/templates/.agent/skills/git-forensics/references/ANALYSIS_METHODOLOGY.md +0 -193
  63. package/templates/.agent/skills/git-forensics/scripts/__pycache__/git_forensics.cpython-313.pyc +0 -0
  64. package/templates/.agent/skills/git-forensics/scripts/git_forensics.py +0 -615
  65. package/templates/.agent/skills/git-forensics/scripts/git_hotspots.py +0 -118
  66. package/templates/.agent/skills/report-template/references/REPORT_TEMPLATE.md +0 -100
  67. package/templates/.agent/skills/spec-writer/SKILL.md +0 -108
  68. package/templates/.agent/skills/system-architect/references/rfc_template.md +0 -59
  69. package/templates/.agent/skills/task-planner/references/TASK_TEMPLATE.md +0 -144
  70. package/templates/.agent/workflows/scout.md +0 -139
  71. /package/templates/{.agent → .agents}/skills/system-designer/references/system-design-detail-template.md +0 -0
@@ -1,112 +0,0 @@
1
- ---
2
- name: concept-modeler
3
- description: 从模糊的用户需求中提取领域概念——实体、流程和"暗物质"(用户没说的)。基于 DDD(领域驱动设计)方法论。
4
- ---
5
-
6
- # 建模师手册 (The Modeler's Field Guide)
7
-
8
- > "如果你描述不清楚,你就造不出来。" —— Eric Evans
9
-
10
- 本技能将用户的"感觉词"转化为**实体 (Entities)**、**数据流 (Flows)** 和**暗物质 (Missing Components)**。
11
-
12
- ---
13
-
14
- ## ⚠️ 强制深度思考
15
-
16
- > [!IMPORTANT]
17
- > 在执行任何分析之前,你**必须**调用 `sequential thinking` 工具,视情况进行 **3—5 步**推理。
18
- > 思考内容例如:
19
- > 1. "用户说的'同步'是单向还是双向?实时还是批量?"
20
- > 2. "这个'列表'在代码里对应什么?`Wishlist` 还是 `ShoppingCart`?"
21
- > 3. "用户只描述了 Happy Path——如果 X 失败了怎么办?"
22
- > 4. "这个功能需要新的数据库表吗?需要新的 API 端点吗?"
23
- > 5. "有没有隐藏的安全/性能/可靠性问题用户没提?"
24
-
25
- ---
26
-
27
- ## ⚡ 任务目标
28
-
29
- 从用户的自然语言需求中提取:
30
- 1. **实体 (Entities)** - 系统中的"名词"
31
- 2. **数据流 (Flows)** - "名词"之间的"动词"
32
- 3. **暗物质 (Missing)** - 用户没说但必须存在的组件
33
-
34
- ---
35
-
36
- ## 🧭 探索流程 (The Extraction)
37
-
38
- ### 第一步:名词捕捉 (Noun Hunting)
39
- * **输入**: "我想让用户能够*同步*他们的*列表*。"
40
- * **建模师追问**: "列表"是什么?`Wishlist`?`ShoppingCart`?`TodoList`?
41
- * **老师傅箴言**: 永远不要假设你理解了用户的词汇。**Ubiquitous Language 是 DDD 的核心**。
42
- * **输出**: 定义清晰的 **Entity** 列表。
43
-
44
- ### 第二步:动词分析 (Verb Analysis)
45
- * **输入**: "同步。"
46
- * **建模师追问**:
47
- * 是**单向**还是**双向**?
48
- * 是**实时**还是**批量**?
49
- * **失败策略**是什么?重试?回滚?告警?
50
- * **老师傅箴言**: 动词决定了系统的复杂度。一个"同步"可能藏着 10 个边界情况。
51
- * **输出**: 定义 **Data Flow** 和 **Consistency Model**。
52
-
53
- ### 第三步:暗物质探测 (Dark Matter Detection)
54
- * **老师傅核心定律**: 用户只描述 Happy Path。**你的工作是找到他们没说的一切**。
55
- * **检查清单**:
56
- | 类别 | 追问 |
57
- | :--- | :--- |
58
- | **错误处理** | 如果 X 失败了怎么办? |
59
- | **持久化** | 数据存哪里?需要备份吗? |
60
- | **认证授权** | 谁能访问?如何验证身份? |
61
- | **日志监控** | 如何知道系统状态?如何调试? |
62
- | **配置管理** | 硬编码还是外部配置? |
63
- | **限流熔断** | 高并发时如何保护系统? |
64
- * **输出**: 标记 **Missing Components** 及其优先级。
65
-
66
- ---
67
-
68
- ## 🛡️ 老师傅守则
69
-
70
- 1. **不要编造**: 如果信息不足,把问题列出来让用户澄清。
71
- 2. **保守估计**: 宁可多识别缺失组件,也不要遗漏。
72
- 3. **解释推理**: 对每个判断提供理由。
73
- 4. **关联构建信息**: 将识别出的 Entities 与 `build-inspector` 发现的构建根关联起来。
74
-
75
- ---
76
-
77
- ## 📤 输出格式
78
-
79
- 你**必须**使用 `write_to_file` 保存到 `genesis/v{N}/concept_model.json`,格式如下:
80
-
81
- ```json
82
- {
83
- "entities": [
84
- { "name": "Wishlist", "type": "数据", "necessity": "必须", "description": "用户的愿望清单" }
85
- ],
86
- "flows": [
87
- { "from": "User", "action": "添加", "to": "Wishlist", "data": "Product ID" }
88
- ],
89
- "missing_components": [
90
- { "component": "错误重试", "category": "错误处理", "priority": "高", "reason": "API 可能超时" }
91
- ],
92
- "questions_for_user": [
93
- "同步是实时的还是批量的?"
94
- ]
95
- }
96
- ```
97
-
98
- ---
99
-
100
- ## 🧰 工具箱
101
-
102
- * `scripts/glossary_gen.py --path src/`: 从代码中提取候选领域词汇。
103
- * `prompts/GLOSSARY_PROMPT.md`: 领域词汇对齐提示词。
104
- * `references/ENTITY_EXTRACTION_PROMPT.md`: 完整的实体提取提示词模板(含 Few-Shot 示例)。
105
-
106
- ---
107
-
108
- ## Collaboration
109
-
110
- * **Before**: `build-inspector` 和 `runtime-inspector` 揭示了*系统是什么*。
111
- * **After**: `spec-writer` 定义*系统将变成什么*。
112
- * **Synergy**: 你的领域模型将帮助 Scout 的功能冲突分析更精准。
@@ -1,40 +0,0 @@
1
- # Ubiquitous Language Extraction Prompt
2
-
3
- ## Role
4
- You are a **Domain Linguist** and **DDD Practitioner**. Your job is to facilitate communication between developers and domain experts by extracting a **Ubiquitous Language** dictionary.
5
-
6
- ## Goal
7
- Analyze the provided code and documentation to extract the core vocabulary of the domain. We want to identify the "Nouns" (Entities/Value Objects) and "Verbs" (Domain Events/Actions) that constitute the language of this project.
8
-
9
- ## Input Context
10
- - **Code Identifiers**: Class names, Struct names, Public Function names.
11
- - **Documentation text**: User stories, comments.
12
-
13
- ## Output Format
14
- Generate a Markdown Glossary table.
15
-
16
- ### Format Template
17
- ```markdown
18
- # Domain Glossary (Ubiquitous Language)
19
-
20
- ## Entities (Nouns)
21
- | Term | Definition | Code Mappings |
22
- |---|---|---|
23
- | User | A registered person who uses the system. | `src/models/User.rs`, `database.users` |
24
- | Prompt | A text template used for AI generation. | `src/models/Prompt.ts` |
25
-
26
- ## Actions (Verbs)
27
- | Term | Definition | Code Mappings |
28
- |---|---|---|
29
- | Generate | The process of creating content using AI. | `service/Generator.run()` |
30
- | Inject | Inserting the generated text into an active window. | `service/Injector.inject()` |
31
-
32
- ## Inconsistencies Detected
33
- > [!WARNING]
34
- > - **Client vs User**: Code uses `Client`, docs use `User`. Recommended: Unify to `User`.
35
- ```
36
-
37
- ## Constraints
38
- - **Ignore** technical terms (e.g., "Integer", "HTTP Request"). Focus on DOMAIN terms.
39
- - **Merge** synonyms if they clearly refer to the same thing, but note the inconsistency.
40
- - Definitions should be **business-centric**, not code-centric.
@@ -1,299 +0,0 @@
1
- # 实体提取 Prompt 模板 - 完整版
2
-
3
- ## 概述
4
-
5
- 此 Prompt 用于从用户的自然语言描述中提取系统的逻辑模型。基于 2024 年 LLM Prompt 工程最佳实践设计。
6
-
7
- ## 设计原则
8
-
9
- 基于调研的最佳实践:
10
-
11
- 1. **明确指令**:清晰陈述任务和期望的实体类型
12
- 2. **Few-shot 示例**:提供示例帮助模型理解格式
13
- 3. **Chain-of-Thought**:引导模型逐步推理
14
- 4. **Role Prompting**:赋予模型专家身份
15
- 5. **JSON 输出**:明确指定结构化输出格式
16
- 6. **"Give LLM an Out"**:允许模型表示不确定性
17
-
18
- ---
19
-
20
- ## 主 Prompt 模板
21
-
22
- ```markdown
23
- # 角色定义
24
-
25
- 你是一名拥有 15 年经验的资深系统架构师。你的专长是:
26
- - 从模糊需求中提取精确的系统模型
27
- - 识别用户遗漏的关键组件
28
- - 预判潜在的架构风险和耦合问题
29
- - 设计可扩展、可维护的系统架构
30
-
31
- # 任务
32
-
33
- 用户想要构建以下系统/功能:
34
-
35
- ---
36
- {{USER_INPUT}}
37
- ---
38
-
39
- 请执行以下 **结构化分析**,按步骤推理:
40
-
41
- ## 第 1 步:实体提取 (Entity Extraction)
42
-
43
- 列出这个系统中必须存在的所有核心"名词"。
44
-
45
- 思考方向:
46
- - 用户/角色类:谁会使用这个系统?
47
- - 数据/资源类:系统处理什么数据?
48
- - 服务/组件类:需要哪些独立的服务模块?
49
- - 外部依赖类:需要对接哪些外部 API 或服务?
50
- - 基础设施类:需要什么存储、缓存、队列?
51
-
52
- 对于每个实体,评估其 **必要性**:
53
- - [必须] = 没有这个系统无法运行
54
- - [应该] = 没有这个会严重影响体验
55
- - [可选] = 增强功能,可后续添加
56
-
57
- ## 第 2 步:数据流分析 (Data Flow Analysis)
58
-
59
- 描述数据如何在这些实体之间流转。
60
-
61
- 使用格式:
62
- ```
63
- [源实体] --[动作/数据]--> [目标实体]
64
- ```
65
-
66
- 重点考虑:
67
- - 主流程(Happy Path)是什么?
68
- - 数据在哪些点会被转换或处理?
69
- - 哪些是同步操作,哪些应该异步?
70
-
71
- ## 第 3 步:缺失检测 (Missing Component Detection)
72
-
73
- **这是最关键的一步**。根据你的经验,主动识别用户描述中 **遗漏** 的关键组件:
74
-
75
- 检查清单:
76
- - [ ] **错误处理**:如果 X 失败了怎么办?重试?回滚?
77
- - [ ] **数据持久化**:数据存在哪里?需要备份吗?
78
- - [ ] **认证授权**:谁能访问什么?如何验证身份?
79
- - [ ] **日志监控**:如何知道系统状态?如何调试问题?
80
- - [ ] **队列/缓存**:是否需要异步处理?是否需要缓存热点数据?
81
- - [ ] **配置管理**:hardcode 还是外部配置?环境差异如何处理?
82
- - [ ] **限流/熔断**:高并发时如何保护系统?
83
- - [ ] **幂等性**:重复请求会怎样?
84
-
85
- 对于每个缺失项,解释 **为什么需要** 以及 **如果没有会怎样**。
86
-
87
- ## 第 4 步:风险识别 (Risk Identification)
88
-
89
- 预判潜在的问题(即使用户没问):
90
-
91
- 风险类型:
92
- - **耦合风险**:哪些组件之间可能产生不健康的依赖?
93
- - **性能风险**:哪里可能成为瓶颈?
94
- - **可靠性风险**:哪里可能导致级联故障?
95
- - **安全风险**:哪里可能有安全漏洞?
96
- - **扩展性风险**:当规模增长 10 倍时,哪里会先出问题?
97
-
98
- ## 第 5 步:边界定义 (Boundary Definition)
99
-
100
- 建议如何划分模块边界以降低耦合:
101
-
102
- - 哪些组件应该放在一起(高内聚)?
103
- - 哪些组件应该分离(低耦合)?
104
- - 接口应该如何设计?
105
-
106
- ---
107
-
108
- # 输出格式
109
-
110
- 严格按照以下 JSON 格式输出:
111
-
112
- ```json
113
- {
114
- "entities": [
115
- {
116
- "name": "实体名称",
117
- "type": "用户|数据|服务|外部|基础设施",
118
- "necessity": "必须|应该|可选",
119
- "description": "简要描述"
120
- }
121
- ],
122
- "data_flows": [
123
- {
124
- "from": "源实体",
125
- "action": "动作描述",
126
- "to": "目标实体",
127
- "data": "传递的数据",
128
- "sync": true
129
- }
130
- ],
131
- "missing_components": [
132
- {
133
- "component": "缺失组件名称",
134
- "category": "错误处理|持久化|安全|监控|性能|配置",
135
- "reason": "为什么需要",
136
- "impact_if_missing": "如果没有会怎样",
137
- "priority": "高|中|低"
138
- }
139
- ],
140
- "potential_risks": [
141
- {
142
- "risk_type": "耦合|性能|可靠性|安全|扩展性",
143
- "description": "风险描述",
144
- "affected_entities": ["相关实体"],
145
- "mitigation": "建议的缓解措施"
146
- }
147
- ],
148
- "boundary_recommendations": [
149
- {
150
- "module_name": "模块名称",
151
- "contains": ["包含的实体"],
152
- "rationale": "为什么这样划分"
153
- }
154
- ],
155
- "questions_for_user": [
156
- "如果有不确定的地方,列出需要用户澄清的问题"
157
- ]
158
- }
159
- ```
160
-
161
- # 重要提示
162
-
163
- 1. **不要编造**:如果信息不足,在 `questions_for_user` 中列出问题
164
- 2. **保守估计**:宁可多识别缺失组件,也不要遗漏
165
- 3. **解释推理**:对每个判断提供理由
166
- 4. **实际经验**:基于真实系统设计经验,而不是理论
167
- ```
168
-
169
- ---
170
-
171
- ## Few-Shot 示例
172
-
173
- ### 示例输入
174
-
175
- ```
176
- 我想做一个"视频摘要生成器":用户上传视频,系统用 Whisper 转文字,
177
- 然后用 GPT 生成摘要,最后返回给用户。
178
- ```
179
-
180
- ### 示例输出
181
-
182
- ```json
183
- {
184
- "entities": [
185
- {"name": "User", "type": "用户", "necessity": "必须", "description": "上传视频并获取摘要的用户"},
186
- {"name": "VideoFile", "type": "数据", "necessity": "必须", "description": "用户上传的视频文件"},
187
- {"name": "VideoUploader", "type": "服务", "necessity": "必须", "description": "处理视频上传的服务"},
188
- {"name": "TranscriptionService", "type": "服务", "necessity": "必须", "description": "调用 Whisper API 转文字"},
189
- {"name": "SummaryService", "type": "服务", "necessity": "必须", "description": "调用 GPT 生成摘要"},
190
- {"name": "WhisperAPI", "type": "外部", "necessity": "必须", "description": "OpenAI Whisper 语音识别"},
191
- {"name": "GPT_API", "type": "外部", "necessity": "必须", "description": "OpenAI GPT 文本生成"},
192
- {"name": "FileStorage", "type": "基础设施", "necessity": "必须", "description": "存储上传的视频和生成的摘要"},
193
- {"name": "TaskQueue", "type": "基础设施", "necessity": "应该", "description": "异步处理视频任务"}
194
- ],
195
- "data_flows": [
196
- {"from": "User", "action": "上传", "to": "VideoUploader", "data": "视频文件", "sync": true},
197
- {"from": "VideoUploader", "action": "存储", "to": "FileStorage", "data": "视频文件", "sync": true},
198
- {"from": "VideoUploader", "action": "创建任务", "to": "TaskQueue", "data": "任务ID", "sync": true},
199
- {"from": "TaskQueue", "action": "触发", "to": "TranscriptionService", "data": "视频路径", "sync": false},
200
- {"from": "TranscriptionService", "action": "调用", "to": "WhisperAPI", "data": "音频数据", "sync": true},
201
- {"from": "TranscriptionService", "action": "传递", "to": "SummaryService", "data": "文字内容", "sync": true},
202
- {"from": "SummaryService", "action": "调用", "to": "GPT_API", "data": "文字内容", "sync": true},
203
- {"from": "SummaryService", "action": "存储", "to": "FileStorage", "data": "摘要结果", "sync": true}
204
- ],
205
- "missing_components": [
206
- {
207
- "component": "任务状态追踪",
208
- "category": "监控",
209
- "reason": "用户上传后需要知道处理进度",
210
- "impact_if_missing": "用户无法知道视频是否处理完成,体验极差",
211
- "priority": "高"
212
- },
213
- {
214
- "component": "API 调用重试机制",
215
- "category": "错误处理",
216
- "reason": "Whisper/GPT API 可能超时或失败",
217
- "impact_if_missing": "单次失败导致整个任务失败,浪费用户时间",
218
- "priority": "高"
219
- },
220
- {
221
- "component": "视频大小/时长限制",
222
- "category": "性能",
223
- "reason": "大视频会导致处理时间过长和成本过高",
224
- "impact_if_missing": "用户可能上传几GB的视频导致系统崩溃",
225
- "priority": "高"
226
- },
227
- {
228
- "component": "费用追踪/计费",
229
- "category": "配置",
230
- "reason": "API 调用有成本,需要追踪",
231
- "impact_if_missing": "无法控制成本,可能产生意外账单",
232
- "priority": "中"
233
- }
234
- ],
235
- "potential_risks": [
236
- {
237
- "risk_type": "性能",
238
- "description": "视频处理是 CPU/内存密集型,大视频可能导致 OOM",
239
- "affected_entities": ["TranscriptionService"],
240
- "mitigation": "限制视频大小,使用流式处理"
241
- },
242
- {
243
- "risk_type": "可靠性",
244
- "description": "如果 TaskQueue 宕机,所有待处理任务丢失",
245
- "affected_entities": ["TaskQueue"],
246
- "mitigation": "使用持久化队列(如 Redis + 持久化)"
247
- },
248
- {
249
- "risk_type": "耦合",
250
- "description": "TranscriptionService 和 SummaryService 如果同步调用,一个慢会拖慢整个流程",
251
- "affected_entities": ["TranscriptionService", "SummaryService"],
252
- "mitigation": "考虑将两个服务通过队列解耦"
253
- }
254
- ],
255
- "boundary_recommendations": [
256
- {
257
- "module_name": "上传模块",
258
- "contains": ["VideoUploader", "FileStorage"],
259
- "rationale": "上传和存储紧密相关,应该放在一起"
260
- },
261
- {
262
- "module_name": "处理模块",
263
- "contains": ["TranscriptionService", "SummaryService", "TaskQueue"],
264
- "rationale": "视频处理流程,通过队列异步执行"
265
- },
266
- {
267
- "module_name": "外部集成层",
268
- "contains": ["WhisperAPI", "GPT_API"],
269
- "rationale": "所有外部 API 调用应该通过统一的适配层,方便切换供应商"
270
- }
271
- ],
272
- "questions_for_user": [
273
- "视频支持的最大时长/大小是多少?",
274
- "用户是否需要实时查看处理进度?",
275
- "摘要结果需要保留多久?"
276
- ]
277
- }
278
- ```
279
-
280
- ---
281
-
282
- ## 追问策略
283
-
284
- 如果初始分析不够深入,使用以下追问:
285
-
286
- 1. **边界追问**:"如果 [实体A] 出错了,[实体B] 会怎样?"
287
- 2. **规模追问**:"如果有 10000 个用户同时使用,哪里会先崩?"
288
- 3. **演化追问**:"6 个月后如果要加 [新功能],需要改动哪些组件?"
289
- 4. **成本追问**:"这个架构的运维成本主要在哪里?"
290
- 5. **安全追问**:"如果有恶意用户尝试攻击,最薄弱的环节是哪里?"
291
-
292
- ---
293
-
294
- ## 与其他 Skills 的配合
295
-
296
- - 对于 **Brownfield** 模式:先用 `build-inspector` 分析构建边界,用 `runtime-inspector` 分析 IPC,再用此 Prompt 分析新功能
297
- - 分析结果应传递给 Scout 的功能冲突分析(Step 6)和最终报告生成
298
- - 识别的缺失组件应在后续 Blueprint 阶段详细设计
299
-
@@ -1,66 +0,0 @@
1
- import os
2
- import argparse
3
- import json
4
- import re
5
-
6
- # Simple regex for finding potential domain terms (Classes, Structs)
7
- # This is a heuristic. For better results, use the tree-sitter slice we built earlier.
8
- # But for "Concept Modeling" of a whole repo, a fast scan is often enough to start.
9
-
10
- PATTERNS = {
11
- 'python': [r'class\s+([A-Z][a-zA-Z0-9_]*)'],
12
- 'rust': [r'struct\s+([A-Z][a-zA-Z0-9_]*)', r'enum\s+([A-Z][a-zA-Z0-9_]*)'],
13
- 'javascript': [r'class\s+([A-Z][a-zA-Z0-9_]*)', r'interface\s+([A-Z][a-zA-Z0-9_]*)'],
14
- 'typescript': [r'class\s+([A-Z][a-zA-Z0-9_]*)', r'interface\s+([A-Z][a-zA-Z0-9_]*)', r'type\s+([A-Z][a-zA-Z0-9_]*)']
15
- }
16
-
17
- def scan_identifiers(root_dir: str):
18
- terms = set()
19
-
20
- for root, _, files in os.walk(root_dir):
21
- for file in files:
22
- ext = os.path.splitext(file)[1]
23
- lang = None
24
- if ext == '.py': lang = 'python'
25
- elif ext == '.rs': lang = 'rust'
26
- elif ext in ['.js', '.jsx']: lang = 'javascript'
27
- elif ext in ['.ts', '.tsx']: lang = 'typescript'
28
-
29
- if lang:
30
- try:
31
- with open(os.path.join(root, file), 'r', encoding='utf-8') as f:
32
- content = f.read()
33
-
34
- for pat in PATTERNS[lang]:
35
- matches = re.finditer(pat, content)
36
- for m in matches:
37
- terms.add(m.group(1))
38
- except Exception:
39
- pass
40
-
41
- return sorted(list(terms))
42
-
43
- def main():
44
- parser = argparse.ArgumentParser(description="Generate Glossary Context")
45
- parser.add_argument("--path", required=True, help="Repo path")
46
- parser.add_argument("--output", "-o", help="Output JSON file for LLM")
47
-
48
- args = parser.parse_args()
49
-
50
- print(f"Scanning for domain terms in {args.path}...")
51
- terms = scan_identifiers(args.path)
52
-
53
- result = {
54
- "candidate_terms": terms,
55
- "instruction": "The above terms were extracted from the codebase. Please filter out technical terms (like 'Config', 'Factory') and keep only Domain Terms."
56
- }
57
-
58
- if args.output:
59
- with open(args.output, 'w') as f:
60
- json.dump(result, f, indent=2)
61
- print(f"Context saved to {args.output}")
62
- else:
63
- print(json.dumps(result, indent=2))
64
-
65
- if __name__ == "__main__":
66
- main()
@@ -1,74 +0,0 @@
1
- ---
2
- name: git-forensics
3
- description: 分析 Git 历史,发现"逻辑耦合"(总一起改的文件)和"热点"(高频修改的复杂模块)。基于 Adam Tornhill 的《Your Code as a Crime Scene》方法论。
4
- ---
5
-
6
- # 考古学家手册 (The Archaeologist's Field Notes)
7
-
8
- > "历史不会重复,但会押韵。静态分析告诉你结构,Git 取证告诉你痛苦的真相。" —— Adam Tornhill
9
-
10
- 本技能基于 **Adam Tornhill 的《Your Code as a Crime Scene》** 方法论。
11
- 核心思想:代码的**演化历史**比代码本身更能揭示设计问题。
12
-
13
- ---
14
-
15
- ## ⚠️ 强制深度思考
16
-
17
- > [!IMPORTANT]
18
- > 在执行任何分析之前,你**必须**调用 `sequential thinking` 工具,视情况进行 **2—3 步**推理。
19
- > 思考内容例如:
20
- > 1. "这个项目的 Git 历史有多深?是否需要 `git fetch --unshallow`?"
21
- > 2. "我应该关注哪个时间范围?(最近 3 个月?1 年?)"
22
- > 3. "有没有明显的'噪音文件'(如 `package-lock.json`)需要排除?"
23
-
24
- ---
25
-
26
- ## ⚡ 快速启动
27
- 1. **耦合分析**: `python scripts/git_forensics.py --repo . --threshold 0.3`
28
- 2. **热点探测**: `python scripts/git_hotspots.py --repo . --days 180`
29
-
30
- ---
31
-
32
- ## 🧭 探索流程 (The Dig)
33
-
34
- ### 第一步:感知时间流 (The Tornhill Method)
35
- * **老师傅箴言**: "代码的价值不是它是什么,而是它是如何变成这样的。"
36
- * 运行 `git log --oneline -n 100`,快速感知项目近期活跃度。
37
- * **关键推断**: 如果最近 50 次提交都只涉及一两个目录,那就是"震中"——最可能藏有风险的地方。
38
-
39
- ### 第二步:发现隐性耦合 (Temporal Coupling / Change Coupling)
40
- * **核心问题**: "有没有两个文件,它们在代码里**没有** `import`/`use` 关系,但 **70%** 的提交都一起出现?"
41
- * **老师傅警报 (来自 Adam Tornhill)**:
42
- * ⚠️ **逻辑耦合但物理分离** -> 这是"架构腐烂 (Architectural Decay)"的强信号!
43
- * ⚠️ **跨构建根的耦合** -> 如果 `service/ipc.rs` 总和 `gui/api.ts` 一起改,但它们属于不同构建根,这是**版本漂移**的温床!
44
- * **处方**: 要么合并它们到同一模块,要么抽象出共享的 Schema/契约层。
45
-
46
- ### 第三步:定位热点 (Hotspot Analysis - CodeScene Methodology)
47
- * **公式**: 热点 = 高变更频率 (Churn) × 高复杂度 (Complexity)
48
- * **老师傅策略矩阵 (来自 CodeScene)**:
49
-
50
- | | 低复杂度 | 高复杂度 |
51
- | :---: | :---: | :---: |
52
- | **高 Churn** | 配置/生成代码,可忽略 | 🔴 **优先重构!Bug 温床,ROI 最高** |
53
- | **低 Churn** | 稳定模块,别动 | 🟡 遗留雷区,小心翼翼 |
54
-
55
- * **老师傅建议**: 重构资源有限时,**只攻高 Churn + 高 Complexity 的象限**。这是投资回报率最高的地方。
56
-
57
- ---
58
-
59
- ## 🛡️ 老师傅守则
60
-
61
- 1. **先取消浅克隆**: `git fetch --unshallow`。没有历史 = 没有数据 = 你是盲人。
62
- 2. **过滤噪音**: 忽略 `package-lock.json`, `Cargo.lock`, `*.min.js`, `dist/` 等生成物。它们会污染你的分析结果。
63
- 3. **警惕大规模重命名**: 重命名 (`git mv`) 会干扰追踪。如果发现诡异的耦合数据,手动检查是否是重命名导致。
64
- 4. **关联构建信息**: 在输出耦合对时,**标注它们分别属于哪个构建根**。这是连接 Git 分析和 Build 分析的关键桥梁。
65
-
66
- ---
67
-
68
- ## 📤 输出清单
69
-
70
- 1. **Coupling Pairs (耦合对)**: Score > 0.7 的文件对。**标注它们的构建根**。
71
- 2. **Cross-Root Couplings (跨根耦合)**: 重点标记!如果两个高耦合文件属于不同构建根,这是**头号风险**。
72
- 3. **Hotspots (热点)**: 高风险模块列表 (高 Churn + 高 Complexity)。
73
- 4. **Orphans (孤儿)**: 超过 1 年无人触碰的文件(知识腐烂警告)。
74
- 5. **Refactoring Priority**: 根据 Churn/Complexity 矩阵给出建议的重构优先级。