@haaaiawd/anws 2.2.2 → 2.2.4
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 +180 -180
- package/lib/manifest.js +212 -212
- package/package.json +1 -1
- package/templates/.agents/skills/anws-system/SKILL.md +108 -108
- package/templates/.agents/skills/code-reviewer/SKILL.md +101 -101
- package/templates/.agents/skills/concept-modeler/SKILL.md +179 -178
- package/templates/.agents/skills/craft-authoring/SKILL.md +6 -6
- package/templates/.agents/skills/design-reviewer/SKILL.md +190 -176
- package/templates/.agents/skills/e2e-testing-guide/SKILL.md +113 -36
- package/templates/.agents/skills/nexus-mapper/SKILL.md +321 -306
- package/templates/.agents/skills/report-template/SKILL.md +92 -85
- package/templates/.agents/skills/runtime-inspector/SKILL.md +12 -12
- package/templates/.agents/skills/sequential-thinking/SKILL.md +225 -216
- package/templates/.agents/skills/spec-writer/SKILL.md +9 -9
- package/templates/.agents/skills/spec-writer/references/prd_template.md +6 -6
- package/templates/.agents/skills/system-architect/SKILL.md +678 -620
- package/templates/.agents/skills/system-designer/SKILL.md +601 -534
- package/templates/.agents/skills/system-designer/references/system-design-detail-template.md +5 -5
- package/templates/.agents/skills/system-designer/references/system-design-template.md +28 -28
- package/templates/.agents/skills/task-planner/SKILL.md +699 -629
- package/templates/.agents/skills/task-planner/references/TASK_TEMPLATE.md +15 -15
- package/templates/.agents/skills/task-reviewer/SKILL.md +388 -363
- package/templates/.agents/skills/tech-evaluator/SKILL.md +144 -135
- package/templates/.agents/skills/tech-evaluator/references/ADR_TEMPLATE.md +80 -78
- package/templates/.agents/workflows/blueprint.md +391 -391
- package/templates/.agents/workflows/challenge.md +52 -52
- package/templates/.agents/workflows/change.md +346 -346
- package/templates/.agents/workflows/craft.md +11 -11
- package/templates/.agents/workflows/design-system.md +631 -631
- package/templates/.agents/workflows/explore.md +399 -399
- package/templates/.agents/workflows/forge.md +145 -132
- package/templates/.agents/workflows/genesis.md +353 -353
- package/templates/.agents/workflows/probe.md +243 -243
- package/templates/.agents/workflows/quickstart.md +123 -123
- package/templates/.agents/workflows/upgrade.md +10 -10
- package/templates/AGENTS.md +149 -149
|
@@ -1,306 +1,321 @@
|
|
|
1
|
-
---
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
# nexus-mapper — AI 项目探测协议
|
|
7
|
-
|
|
8
|
-
本 Skill 指导 AI Agent 使用 **PROBE 五阶段协议**,对任意本地 Git 仓库执行系统性探测,产出 `.nexus-map/` 分层知识库。
|
|
9
|
-
|
|
10
|
-
---
|
|
11
|
-
|
|
12
|
-
## 何时调用 / 何时不调用
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
|
16
|
-
|
|
|
17
|
-
|
|
|
18
|
-
|
|
|
19
|
-
|
|
|
20
|
-
|
|
|
21
|
-
|
|
|
22
|
-
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
|
34
|
-
|
|
|
35
|
-
|
|
|
36
|
-
|
|
37
|
-
`
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
├──
|
|
68
|
-
|
|
69
|
-
│
|
|
70
|
-
├──
|
|
71
|
-
│ └──
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
[
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
-
|
|
170
|
-
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
-
|
|
197
|
-
|
|
198
|
-
-
|
|
199
|
-
|
|
200
|
-
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
---
|
|
216
|
-
|
|
217
|
-
### 守则
|
|
218
|
-
|
|
219
|
-
> [!IMPORTANT]
|
|
220
|
-
>
|
|
221
|
-
|
|
222
|
-
-
|
|
223
|
-
- `
|
|
224
|
-
-
|
|
225
|
-
|
|
226
|
-
---
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
- `
|
|
234
|
-
- `
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
1
|
+
---
|
|
2
|
+
|
|
3
|
+
## name: nexus-mapper
|
|
4
|
+
description: "Generate a persistent .nexus-map/ knowledge base that lets any AI session instantly understand a codebase's architecture, systems, dependencies, and change hotspots. Use when starting work on an unfamiliar repository, onboarding with AI-assisted context, preparing for a major refactoring initiative, or enabling reliable cold-start AI sessions across a team. Produces INDEX.md, systems.md, concept_model.json, git_forensics.md and more. Requires shell execution and Python 3.10+. For ad-hoc file queries or instant impact analysis during active development, use nexus-query instead."
|
|
5
|
+
|
|
6
|
+
# nexus-mapper — AI 项目探测协议
|
|
7
|
+
|
|
8
|
+
本 Skill 指导 AI Agent 使用 **PROBE 五阶段协议**,对任意本地 Git 仓库执行系统性探测,产出 `.nexus-map/` 分层知识库。
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## 何时调用 / 何时不调用
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
| 场景 | 调用 |
|
|
16
|
+
| ------------------------------------------------- | --- |
|
|
17
|
+
| 用户提供本地 repo 路径,希望 AI 理解其架构 | 是 |
|
|
18
|
+
| 需要生成 `.nexus-map/INDEX.md` 供后续 AI 会话冷启动 | 是 |
|
|
19
|
+
| 用户说「帮我分析项目」「建立项目知识库」「让 AI 了解这个仓库」 | 是 |
|
|
20
|
+
| 运行环境无 shell 执行能力(纯 API 调用模式,无 `run_command` 工具) | 否 |
|
|
21
|
+
| 宿主机无本地 Python 3.10+ | 否 |
|
|
22
|
+
| 目标仓库无任何已知语言源文件(`.py/.ts/.java/.go/.rs/.cpp` 等均无) | 否 |
|
|
23
|
+
| 用户只想查询某个特定文件/函数 → 直接用 `view_file` / `grep_search` | 否 |
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## 前提检查
|
|
29
|
+
|
|
30
|
+
缺失项要显式告知用户;需要降级等时及时提醒用户,经过同意才能继续。
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
| 前提 | 检查方式 |
|
|
34
|
+
| ------------ | ------------------------------------ |
|
|
35
|
+
| 目标路径存在 | `$repo_path` 可访问 |
|
|
36
|
+
| Python 3.10+ | `python --version` >= 3.10 |
|
|
37
|
+
| 脚本依赖已安装 | `python -c "import tree_sitter"` 无报错 |
|
|
38
|
+
| 有 shell 执行能力 | Agent 环境支持 `run_command` 工具调用 |
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
`git` 历史是加分项,不是硬阻塞项。没有 `.git` 或历史过少时,跳过热点分析,并在输出中明确记录这是一次降级探测。
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## 输入契约
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
repo_path: 目标仓库的本地绝对路径(必填)
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
**语言支持**:自动按文件扩展名 dispatch,语言配置(扩展名映射 + Tree-sitter 查询)存储在 `scripts/languages.json`。当前已接入 Python/JavaScript/TypeScript/TSX/Bash/Java/Go/Rust/C#/C/C++/Kotlin/Ruby/Swift/Scala/PHP/Lua/Elixir/GDScript/Dart/Haskell/Clojure/SQL/Proto/Solidity/Vue/Svelte/R/Perl 等 30+ 语言。
|
|
52
|
+
|
|
53
|
+
**非标准语言**:若仓库含有内置未支持的语言,通过命令行参数动态补充(详见 `references/05-language-customization.md`):
|
|
54
|
+
|
|
55
|
+
- `--add-extension .templ=templ` 添加新文件扩展名映射
|
|
56
|
+
- `--add-query templ struct "(component_declaration ...)"` 添加结构查询
|
|
57
|
+
- `--language-config <JSON_FILE>` 复杂配置时使用 JSON 文件
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## 输出格式
|
|
62
|
+
|
|
63
|
+
执行完成后,目标仓库根目录下将产出:
|
|
64
|
+
|
|
65
|
+
```text
|
|
66
|
+
.nexus-map/
|
|
67
|
+
├── INDEX.md ← AI 冷启动主入口(< 2000 tokens)
|
|
68
|
+
├── arch/
|
|
69
|
+
│ ├── systems.md ← 系统边界 + 代码位置
|
|
70
|
+
│ ├── dependencies.md ← Mermaid 依赖图 + 时序图
|
|
71
|
+
│ └── test_coverage.md ← 静态测试面:测试文件、覆盖到的核心模块、证据缺口
|
|
72
|
+
├── concepts/
|
|
73
|
+
│ ├── concept_model.json ← Schema V1 机器可读图谱
|
|
74
|
+
│ └── domains.md ← 核心领域概念说明
|
|
75
|
+
├── hotspots/
|
|
76
|
+
│ └── git_forensics.md ← Git 热点 + 耦合对分析
|
|
77
|
+
└── raw/
|
|
78
|
+
├── ast_nodes.json ← Tree-sitter 解析原始数据
|
|
79
|
+
├── git_stats.json ← Git 热点与耦合数据
|
|
80
|
+
└── file_tree.txt ← 过滤后的文件树
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
所有生成的 Markdown 文件必须带一个简短头部,至少包含:`generated_by`、`verified_at`、`provenance`。
|
|
84
|
+
|
|
85
|
+
`concept_model.json` 的人类可读名称字段统一使用 `label`,不要添加 `title`。
|
|
86
|
+
|
|
87
|
+
如果 PROFILE 阶段发现语言覆盖降级或人工推断,`provenance` 必须明确标注。
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## PROBE 阶段门控
|
|
92
|
+
|
|
93
|
+
> [!IMPORTANT]
|
|
94
|
+
> **进入每个阶段前必须先读对应 reference,不得跳过。**
|
|
95
|
+
> 各阶段详细步骤、完成检查清单与边界场景处理均在 reference 中定义。
|
|
96
|
+
|
|
97
|
+
```
|
|
98
|
+
[Skill 激活时] → read references/probe-protocol.md (阶段步骤蓝图,含边界场景与三维度质疑框架)
|
|
99
|
+
[EMIT 前] → read references/output-schema.md (Schema 校验规范)
|
|
100
|
+
[非标准语言时] → read references/language-customization.md(按需,非门控)
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## 执行守则
|
|
106
|
+
|
|
107
|
+
### 守则1: OBJECT 拒绝形式主义
|
|
108
|
+
|
|
109
|
+
OBJECT 的存在意义是打破 REASON 的幸存者偏差。大量工程事实隐藏在目录命名和 git 热点背后,第一直觉几乎总是错的。
|
|
110
|
+
|
|
111
|
+
不合格质疑(禁止提交):
|
|
112
|
+
|
|
113
|
+
```
|
|
114
|
+
Q1: 我对系统结构的把握还不够扎实
|
|
115
|
+
Q2: xxx 目录的职责暂时没有直接证据
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
问题不在措辞,而在于没有证据线索,也无法在 BENCHMARK 阶段验证。
|
|
119
|
+
|
|
120
|
+
合格质疑格式:
|
|
121
|
+
|
|
122
|
+
```
|
|
123
|
+
Q1: git_stats 显示 tasks/analysis_tasks.py 变更 21 次(high risk),
|
|
124
|
+
但 HYPOTHESIS 认为编排入口是 evolution/detective_loop.py。
|
|
125
|
+
矛盾:若 detective_loop 是入口,为何 analysis_tasks 热度更高?
|
|
126
|
+
证据线索: git_stats.json hotspots[0].path
|
|
127
|
+
验证计划: view tasks/analysis_tasks.py 的 class 定义 + import 树
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
### 守则2: implemented 节点必须有真实 code_path
|
|
133
|
+
|
|
134
|
+
> [!IMPORTANT]
|
|
135
|
+
> 写入 `concept_model.json` 前,必须先区分节点是 `implemented`、`planned` 还是 `inferred`。
|
|
136
|
+
> 只有 `implemented` 节点允许写入 `code_path`,且必须亲手验证存在。
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
# BENCHMARK 阶段验证方式
|
|
140
|
+
ls $repo_path/src/nexus/application/weaving/ # 目录存在 → 节点有效
|
|
141
|
+
ls $repo_path/src/nexus/application/nonexist/ # [!ERROR] → 修正或删除此节点
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
对于 `planned` 或 `inferred` 节点,使用:
|
|
145
|
+
|
|
146
|
+
```json
|
|
147
|
+
{
|
|
148
|
+
"implementation_status": "planned",
|
|
149
|
+
"code_path": null,
|
|
150
|
+
"evidence_path": "docs/architecture.md",
|
|
151
|
+
"evidence_gap": "仓库中未发现 src/agents/monarch/,仅在设计文档中出现"
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
禁止:用勉强相关的文件冒充 `code_path`、把状态塞进路径字段(如 `code_path: "PLANNED"`)。
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
### 守则3: EMIT 原子性
|
|
160
|
+
|
|
161
|
+
先全部写入 `.nexus-map/.tmp/`,全部成功后整体移动到正式目录,删除 `.tmp/`。
|
|
162
|
+
目的:中途失败不留半成品。下次执行检测到 `.tmp/` 存在 → 清理后重新生成。
|
|
163
|
+
|
|
164
|
+
幂等性规则:
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
| 状态 | 处理方式 |
|
|
168
|
+
| ------------------------------- | --------------------- |
|
|
169
|
+
| `.nexus-map/` 不存在 | 直接继续 |
|
|
170
|
+
| `.nexus-map/` 存在且 `INDEX.md` 有效 | 询问用户:「是否覆盖?[y/n]」 |
|
|
171
|
+
| `.nexus-map/` 存在但文件不完整 | 「检测到未完成分析,将重新生成」,直接继续 |
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
### 守则4: INDEX.md 的角色——冷启动路由器,而非静态字典
|
|
177
|
+
|
|
178
|
+
`INDEX.md` 的读者是**从未见过这个仓库的 AI**。两个硬约束:
|
|
179
|
+
|
|
180
|
+
- **< 2000 tokens** — 超过就重写,不是截断
|
|
181
|
+
- **结论必须具体** — 证据不足时明确写出 `evidence gap` 或 `unknown`,并说明缺了什么证据
|
|
182
|
+
|
|
183
|
+
写完后执行 token 估算:行数 × 平均 30 tokens/行 = 粗估值。
|
|
184
|
+
|
|
185
|
+
**INDEX.md 必须包含的强制路由块(Hard-Trigger Block)**——生成时把这段结构写入文件末尾:
|
|
186
|
+
|
|
187
|
+
```markdown
|
|
188
|
+
## [操作指南] 强制执行步骤
|
|
189
|
+
|
|
190
|
+
> 本节是对所有读取本文件的 AI 发出的硬性操作指令,不是建议。
|
|
191
|
+
|
|
192
|
+
### 步骤1 — 必须先读完以下所有文件(顺序不限)
|
|
193
|
+
|
|
194
|
+
读完本文件后,在执行任何任务之前,必须依次 read 以下文件完整内容:
|
|
195
|
+
|
|
196
|
+
- `.nexus-map/arch/systems.md` — 系统边界与代码位置
|
|
197
|
+
- `.nexus-map/arch/dependencies.md` — 系统间依赖关系与 Mermaid 图
|
|
198
|
+
- `.nexus-map/arch/test_coverage.md` — 测试面与证据缺口
|
|
199
|
+
- `.nexus-map/hotspots/git_forensics.md` — Git 热点与耦合风险
|
|
200
|
+
- `.nexus-map/concepts/domains.md` — 核心领域概念
|
|
201
|
+
|
|
202
|
+
> 这些文件均为高密度摘要,总量通常 < 5000 tokens,是必要的上下文成本。
|
|
203
|
+
> 不得以"任务简单"或"只改一个文件"为由跳过。
|
|
204
|
+
|
|
205
|
+
### 步骤2 — 按任务类型追加操作(步骤1 完成后执行)
|
|
206
|
+
|
|
207
|
+
- 若任务涉及**接口修改、新增跨模块调用、删除/重命名公共函数**:
|
|
208
|
+
→ 必须运行 `query_graph.py --impact <目标文件>` 确认影响半径后再写代码。
|
|
209
|
+
- 若任务需要**判断某文件被谁引用**:
|
|
210
|
+
→ 运行 `query_graph.py --who-imports <模块名>`。
|
|
211
|
+
- 若仓库结构已发生重大变化(新增系统、重构模块边界):
|
|
212
|
+
→ 任务完成后评估是否需要重新运行 nexus-mapper 更新知识库。
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
---
|
|
216
|
+
|
|
217
|
+
### 守则5: 最小执行面与敏感信息保护
|
|
218
|
+
|
|
219
|
+
> [!IMPORTANT]
|
|
220
|
+
> 默认只运行本 Skill 自带脚本和必要的只读检查。不要因为"想更懂仓库"就执行目标仓库里的构建脚本、测试脚本或自定义命令。
|
|
221
|
+
|
|
222
|
+
- 默认允许:`extract_ast.py`、`git_detective.py`、目录遍历、文本搜索、只读文件查看
|
|
223
|
+
- 默认禁止:执行目标仓库的 `npm install`、`pnpm dev`、`python main.py`、`docker compose up` 等,除非用户明确要求
|
|
224
|
+
- 遇到 `.env`、密钥文件、凭据配置时:只记录其存在和用途,不抄出具体值
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
### 守则6: 降级与人工推断必须显式可见
|
|
229
|
+
|
|
230
|
+
> [!IMPORTANT]
|
|
231
|
+
> 如果 AST 覆盖不完整,或者某部分来自人工阅读而非脚本产出,必须在最终文件中显式标注 provenance。
|
|
232
|
+
|
|
233
|
+
- `dependencies.md` 中凡是非 AST 直接支持的依赖关系,必须标注 `inferred from file tree/manual inspection`
|
|
234
|
+
- `domains.md`、`systems.md`、`INDEX.md` 如果涉及未支持语言区域,必须说明 `unsupported language downgrade`
|
|
235
|
+
- 若写入进度快照、Sprint 状态,必须附 `verified_at`,避免过期信息伪装成当前事实
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
## 不确定性表达规范
|
|
240
|
+
|
|
241
|
+
避免只写:待确认 · 可能是 · 疑似 · 也许 · 待定 · 暂不清楚 · pending · maybe · possibly · TBD
|
|
242
|
+
|
|
243
|
+
如果证据不足,按以下格式写:
|
|
244
|
+
|
|
245
|
+
- `unknown: 未发现直接证据表明 api/ 是主入口,当前仅能确认 cli.py 被 README 引用`
|
|
246
|
+
- `evidence gap: 仓库没有 git 历史,因此 hotspots 部分跳过`
|
|
247
|
+
|
|
248
|
+
允许诚实地写不确定,但必须解释不确定来自哪一条缺失证据。
|
|
249
|
+
|
|
250
|
+
---
|
|
251
|
+
|
|
252
|
+
## 脚本工具链
|
|
253
|
+
|
|
254
|
+
```bash
|
|
255
|
+
# 设置 SKILL_DIR(根据实际安装路径)
|
|
256
|
+
# 场景 A: 作为 .agent/skills 安装
|
|
257
|
+
SKILL_DIR=".agent/skills/nexus-mapper"
|
|
258
|
+
# 场景 B: 独立 repo(开发/调试时)
|
|
259
|
+
SKILL_DIR="/path/to/nexus-mapper"
|
|
260
|
+
|
|
261
|
+
# PROFILE 阶段 — 基础用法
|
|
262
|
+
python $SKILL_DIR/scripts/extract_ast.py <repo_path> [--max-nodes 500] \
|
|
263
|
+
--file-tree-out <repo_path>/.nexus-map/raw/file_tree.txt \
|
|
264
|
+
> <repo_path>/.nexus-map/raw/ast_nodes.json
|
|
265
|
+
|
|
266
|
+
# 补充非标准语言支持
|
|
267
|
+
python $SKILL_DIR/scripts/extract_ast.py <repo_path> [--max-nodes 500] \
|
|
268
|
+
--add-extension .templ=templ \
|
|
269
|
+
--add-query templ struct "(component_declaration name: (identifier) @class.name) @class.def" \
|
|
270
|
+
> <repo_path>/.nexus-map/raw/ast_nodes.json
|
|
271
|
+
|
|
272
|
+
# 复杂配置:使用 JSON 配置文件
|
|
273
|
+
python $SKILL_DIR/scripts/extract_ast.py <repo_path> [--max-nodes 500] \
|
|
274
|
+
--language-config /custom/path/to/language-config.json \
|
|
275
|
+
> <repo_path>/.nexus-map/raw/ast_nodes.json
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
**依赖安装(首次使用)**:
|
|
279
|
+
|
|
280
|
+
```bash
|
|
281
|
+
pip install -r $SKILL_DIR/scripts/requirements.txt
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
---
|
|
285
|
+
|
|
286
|
+
## 持久化记忆规则(写入宿主 AGENTS.md)
|
|
287
|
+
|
|
288
|
+
建议把以下规则写入仓库的 `AGENTS.md`、`CLAUDE.md` 或同类持久记忆文件,使知识库在长期对话中保持活跃:
|
|
289
|
+
|
|
290
|
+
```md
|
|
291
|
+
如果仓库中存在 .nexus-map/INDEX.md,先阅读它,然后在执行任务前读完其路由块中列出的所有文件。
|
|
292
|
+
|
|
293
|
+
如果 .nexus-map/ 不存在,且当前任务涉及跨模块修改或接口变更,先向用户提议运行 nexus-mapper;若用户需立即开始,至少先运行 query_graph.py --summary 建立结构感知。
|
|
294
|
+
|
|
295
|
+
当任务改变了项目的结构认知(系统边界、入口、依赖关系),在交付前评估是否需要更新 .nexus-map。
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
---
|
|
299
|
+
|
|
300
|
+
## 按需查询工具(PROBE 辅助)
|
|
301
|
+
|
|
302
|
+
`scripts/query_graph.py` 读取 `raw/ast_nodes.json`,零额外依赖(纯 Python 标准库)。
|
|
303
|
+
|
|
304
|
+
```bash
|
|
305
|
+
python $SKILL_DIR/scripts/query_graph.py <ast_nodes.json> --file <path> # 文件骨架
|
|
306
|
+
python $SKILL_DIR/scripts/query_graph.py <ast_nodes.json> --who-imports <mod> # 反向依赖
|
|
307
|
+
python $SKILL_DIR/scripts/query_graph.py <ast_nodes.json> --impact <path> # 影响半径
|
|
308
|
+
python $SKILL_DIR/scripts/query_graph.py <ast_nodes.json> --impact <path> --git-stats <git_stats.json>
|
|
309
|
+
python $SKILL_DIR/scripts/query_graph.py <ast_nodes.json> --hub-analysis # 核心节点
|
|
310
|
+
python $SKILL_DIR/scripts/query_graph.py <ast_nodes.json> --summary # 目录聚合
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
| 阶段 | 推荐查询 | 用途 |
|
|
315
|
+
| ------ | ---------------------- | ------------------------------------- |
|
|
316
|
+
| REASON | `--hub-analysis` | 数据验证核心系统假说,不靠目录名猜测 |
|
|
317
|
+
| OBJECT | `--impact --git-stats` | 验证边界假设,查看真实上下游依赖 |
|
|
318
|
+
| EMIT | `--summary`, `--file` | 生成 systems.md / dependencies.md 的数据支撑 |
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
各查询模式的核心价值:`--hub-analysis` 用于 REASON 期验证架构假说;`--impact --git-stats` 用于 OBJECT 期量化边界风险;`--summary` 与 `--file` 用于 EMIT 期生成精确数据支撑。
|