@walvka-code/proj-doc-builder 4.0.0 → 4.5.2
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 +290 -272
- package/README.zh-CN.md +258 -240
- package/package.json +6 -2
- package/skills/proj-doc-builder/SKILL.md +97 -35
- package/skills/proj-doc-builder/references/audit_script.md +103 -96
- package/skills/proj-doc-builder/references/batch-generation.md +55 -0
- package/skills/proj-doc-builder/references/checklist.md +20 -10
- package/skills/proj-doc-builder/references/exclusions.md +1 -1
- package/skills/proj-doc-builder/references/linking.md +83 -83
- package/skills/proj-doc-builder/references/templates.md +57 -17
- package/skills/proj-doc-builder/tests/claims.json +76 -0
- package/skills/proj-doc-builder/tests/conftest.py +17 -5
- package/skills/proj-doc-builder/tests/test_claims_registry.py +81 -0
- package/skills/proj-doc-builder/tests/test_e2e_fresh_project.py +156 -0
- package/skills/proj-doc-builder/tests/test_load_docs.py +353 -248
- package/skills/proj-doc-builder/tests/test_project_docs_contract.py +32 -1
- package/skills/proj-doc-builder/tests/test_scan_dirs.py +1 -1
- package/skills/proj-doc-builder/tests/test_stage1_stage2_upgrades.py +395 -0
- package/skills/proj-doc-builder/tests/test_sync_project_docs.py +2169 -2169
- package/skills/proj-doc-builder/tests/test_v41_upgrades.py +614 -0
- package/skills/proj-doc-builder/tests/test_v42_upgrades.py +422 -0
- package/skills/proj-doc-builder/tests/test_v43_upgrades.py +198 -0
- package/skills/proj-doc-builder/tests/test_v44_upgrades.py +361 -0
- package/skills/proj-doc-builder/tests/test_v45_upgrades.py +212 -0
- package/skills/proj-doc-builder/tests/test_validate_doc.py +172 -15
- package/skills/proj-doc-builder/tools/_paths.py +39 -0
- package/skills/proj-doc-builder/tools/{claude_doc_index.py → core/claude_doc_index.py} +504 -298
- package/skills/proj-doc-builder/tools/{compute_link.py → core/compute_link.py} +239 -233
- package/skills/proj-doc-builder/tools/core/proj_doc_config.py +460 -0
- package/skills/proj-doc-builder/tools/{project_docs_contract.py → core/project_docs_contract.py} +460 -53
- package/skills/proj-doc-builder/tools/phase4/__init__.py +31 -6
- package/skills/proj-doc-builder/tools/phase4/cas_storage.py +11 -4
- package/skills/proj-doc-builder/tools/phase4/engine.py +17 -2
- package/skills/proj-doc-builder/tools/phase4/journal.py +15 -8
- package/skills/proj-doc-builder/tools/phase4/platform_handles.py +12 -5
- package/skills/proj-doc-builder/tools/phase4_exit.py +153 -47
- package/skills/proj-doc-builder/tools/pipeline/gen_docs_from_scaffold.py +789 -0
- package/skills/proj-doc-builder/tools/{sync_project_docs.py → pipeline/sync_project_docs.py} +5531 -3639
- package/skills/proj-doc-builder/tools/{load_docs.py → reader/load_docs.py} +654 -380
- package/skills/proj-doc-builder/tools/{link_check.py → scan/link_check.py} +203 -152
- package/skills/proj-doc-builder/tools/{normalize_markers.py → scan/normalize_markers.py} +211 -205
- package/skills/proj-doc-builder/tools/{scan_dirs.py → scan/scan_dirs.py} +2735 -2405
- package/skills/proj-doc-builder/tools/{validate_doc.py → validate/validate_doc.py} +1911 -1299
- package/skills/proj-doc-builder/tests/__pycache__/conftest.cpython-314-pytest-9.0.3.pyc +0 -0
- package/skills/proj-doc-builder/tests/__pycache__/test_claude_doc_index.cpython-314-pytest-9.0.3.pyc +0 -0
- package/skills/proj-doc-builder/tests/__pycache__/test_link_tools.cpython-314-pytest-9.0.3.pyc +0 -0
- package/skills/proj-doc-builder/tests/__pycache__/test_load_docs.cpython-314-pytest-9.0.3.pyc +0 -0
- package/skills/proj-doc-builder/tests/__pycache__/test_normalize_markers.cpython-314-pytest-9.0.3.pyc +0 -0
- package/skills/proj-doc-builder/tests/__pycache__/test_phase4_exit.cpython-314-pytest-9.0.3.pyc +0 -0
- package/skills/proj-doc-builder/tests/__pycache__/test_project_docs_contract.cpython-314-pytest-9.0.3.pyc +0 -0
- package/skills/proj-doc-builder/tests/__pycache__/test_scan_dirs.cpython-314-pytest-9.0.3.pyc +0 -0
- package/skills/proj-doc-builder/tests/__pycache__/test_sync_project_docs.cpython-314-pytest-9.0.3.pyc +0 -0
- package/skills/proj-doc-builder/tools/__pycache__/claude_doc_index.cpython-314.pyc +0 -0
- package/skills/proj-doc-builder/tools/__pycache__/compute_link.cpython-314.pyc +0 -0
- package/skills/proj-doc-builder/tools/__pycache__/link_check.cpython-314.pyc +0 -0
- package/skills/proj-doc-builder/tools/__pycache__/load_docs.cpython-314.pyc +0 -0
- package/skills/proj-doc-builder/tools/__pycache__/normalize_markers.cpython-314.pyc +0 -0
- package/skills/proj-doc-builder/tools/__pycache__/phase4_exit.cpython-314.pyc +0 -0
- package/skills/proj-doc-builder/tools/__pycache__/project_docs_contract.cpython-314.pyc +0 -0
- package/skills/proj-doc-builder/tools/__pycache__/scan_dirs.cpython-314.pyc +0 -0
- package/skills/proj-doc-builder/tools/__pycache__/sync_project_docs.cpython-314.pyc +0 -0
package/README.zh-CN.md
CHANGED
|
@@ -1,240 +1,258 @@
|
|
|
1
|
-
# proj_doc_builder
|
|
2
|
-
|
|
3
|
-
**把工程变成 AI 读得懂的文档索引。** 一条命令生成大纲,一条命令加载概况。
|
|
4
|
-
|
|
5
|
-
> **语言**:[English](README.md)(默认)· **中文**
|
|
6
|
-
>
|
|
7
|
-
> 英文是默认版本;本文件为同步翻译,改内容时两版一起改。
|
|
8
|
-
>
|
|
9
|
-
> 同时提供 **DeepSeek Harness bundle**(`@walvka-code/proj-doc-builder`)与普通 CLI 两种用法。
|
|
10
|
-
|
|
11
|
-
```bash
|
|
12
|
-
# 技能目录:SKILL.md 与 tools/ 都在这里
|
|
13
|
-
SKILL="$(pwd)/skills/proj-doc-builder"
|
|
14
|
-
|
|
15
|
-
# 同步:生成/更新文档索引(先看,不写盘 → 确认后发布)
|
|
16
|
-
python "$SKILL/tools/sync_project_docs.py" . --dry-run --json
|
|
17
|
-
python "$SKILL/tools/sync_project_docs.py" . --apply --json
|
|
18
|
-
|
|
19
|
-
# 加载:给新对话一个入口(概览 → 定位到某一份)
|
|
20
|
-
python "$SKILL/tools/load_docs.py" . --json
|
|
21
|
-
python "$SKILL/tools/load_docs.py" . --mode target --target src/core --json
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
它做的三件事:
|
|
25
|
-
|
|
26
|
-
1. 为**每个源码目录**维护一份 Markdown 大纲(文件清单 / 关键符号 / 依赖关系 / 系统角色)。
|
|
27
|
-
2. 用**内容哈希 + manifest** 记住"上次同步时的样子",所以下一次只处理**真正变化**的目录。
|
|
28
|
-
3. 发布是**可回滚事务**;退役文档需要单独举证,不会自动删除。
|
|
29
|
-
|
|
30
|
-
一句话立场:**文档"已同步"必须由工具写下的 manifest 背书,而不是由生成它的模型自述。**
|
|
31
|
-
|
|
32
|
-
---
|
|
33
|
-
|
|
34
|
-
## 目录
|
|
35
|
-
|
|
36
|
-
- [安装](#安装)
|
|
37
|
-
- [仓库布局](#仓库布局)
|
|
38
|
-
- [它解决的两个问题](#它解决的两个问题)
|
|
39
|
-
- [核心保证](#核心保证)
|
|
40
|
-
- [工作流六阶段](#工作流六阶段)
|
|
41
|
-
- [数据模型](#数据模型)
|
|
42
|
-
- [加载器用法](#加载器用法)
|
|
43
|
-
- [平台支持](#平台支持)
|
|
44
|
-
- [测试](#测试)
|
|
45
|
-
- [限制与取舍](#限制与取舍)
|
|
46
|
-
- [License](#license)
|
|
47
|
-
|
|
48
|
-
---
|
|
49
|
-
|
|
50
|
-
## 安装
|
|
51
|
-
|
|
52
|
-
本仓本身是一个 **DeepSeek Harness bundle**,把技能、Python 工具和测试一起打包。按你的 agent 选一种:
|
|
53
|
-
|
|
54
|
-
**方式一:DSH bundle(推荐)**
|
|
55
|
-
|
|
56
|
-
在 **Plugins → More → 开启 Custom plugin markets → Discover** 里加入本仓的索引地址,然后安装
|
|
57
|
-
`proj-doc-builder`:
|
|
58
|
-
|
|
59
|
-
```text
|
|
60
|
-
https://walvka-code.github.io/proj-doc-builder/index.json
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
(同一份索引也发布在 `https://raw.githubusercontent.com/walvka-code/proj-doc-builder/main/index.json`,
|
|
64
|
-
但部分网络无法直连该域名;以 GitHub Pages 地址为准。)
|
|
65
|
-
|
|
66
|
-
不用市场时,可直接钉住某个 commit(bundle 是仓库里的一个包目录):
|
|
67
|
-
|
|
68
|
-
```bash
|
|
69
|
-
git+https://github.com/walvka-code/proj-doc-builder.git#<40 位 commit>
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
或用 `plugin_manager` 装本地检出:
|
|
73
|
-
|
|
74
|
-
```json
|
|
75
|
-
{ "action": "install_bundle", "target": "C:/path/to/proj-doc-builder" }
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
bundle 挂载一个 bundled 技能提供方(rank 600):技能在 profile 的**所有会话**里可用;若某个项目自带
|
|
79
|
-
`.dsh/skills/proj-doc-builder/`,项目副本优先(用于钉住版本)。
|
|
80
|
-
|
|
81
|
-
**方式二:作为项目技能**
|
|
82
|
-
|
|
83
|
-
把 `skills/proj-doc-builder/` 复制到
|
|
84
|
-
`<project>/.dsh/skills/proj-doc-builder/`。`SKILL.md` 用宿主报告的技能目录解析工具路径,
|
|
85
|
-
两种布局都成立。
|
|
86
|
-
|
|
87
|
-
**方式三:当普通 CLI 用**(不需要任何 agent 框架)
|
|
88
|
-
|
|
89
|
-
```bash
|
|
90
|
-
git clone <this-repo> proj-doc-builder
|
|
91
|
-
SKILL="$(pwd)/proj-doc-builder/skills/proj-doc-builder"
|
|
92
|
-
python "$SKILL/tools/sync_project_docs.py" /path/to/your/project --dry-run --json
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
**Python 3.12+,运行时零第三方依赖**(仅标准库)。测试需要 `pytest`(见 `requirements-dev.txt`)。
|
|
96
|
-
|
|
97
|
-
前置条件:你的项目根要有 `project_docs/` 与 `CLAUDE.md` 两个入口。
|
|
98
|
-
|
|
99
|
-
---
|
|
100
|
-
|
|
101
|
-
## 仓库布局
|
|
102
|
-
|
|
103
|
-
```text
|
|
104
|
-
proj-doc-builder/
|
|
105
|
-
├── package.json #
|
|
106
|
-
├── cordis.patch.yml # 挂载 bundled 技能提供方
|
|
107
|
-
├── index.js # 读取 SKILL.md 并注册技能
|
|
108
|
-
├── index.json # 插件市场索引(format 1)
|
|
109
|
-
├── icon.svg
|
|
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
|
-
**
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
1
|
+
# proj_doc_builder
|
|
2
|
+
|
|
3
|
+
**把工程变成 AI 读得懂的文档索引。** 一条命令生成大纲,一条命令加载概况。
|
|
4
|
+
|
|
5
|
+
> **语言**:[English](README.md)(默认)· **中文**
|
|
6
|
+
>
|
|
7
|
+
> 英文是默认版本;本文件为同步翻译,改内容时两版一起改。
|
|
8
|
+
>
|
|
9
|
+
> 同时提供 **DeepSeek Harness bundle**(`@walvka-code/proj-doc-builder`)与普通 CLI 两种用法。
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
# 技能目录:SKILL.md 与 tools/ 都在这里
|
|
13
|
+
SKILL="$(pwd)/skills/proj-doc-builder"
|
|
14
|
+
|
|
15
|
+
# 同步:生成/更新文档索引(先看,不写盘 → 确认后发布)
|
|
16
|
+
python "$SKILL/tools/pipeline/sync_project_docs.py" . --dry-run --json
|
|
17
|
+
python "$SKILL/tools/pipeline/sync_project_docs.py" . --apply --json
|
|
18
|
+
|
|
19
|
+
# 加载:给新对话一个入口(概览 → 定位到某一份)
|
|
20
|
+
python "$SKILL/tools/reader/load_docs.py" . --json
|
|
21
|
+
python "$SKILL/tools/reader/load_docs.py" . --mode target --target src/core --json
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
它做的三件事:
|
|
25
|
+
|
|
26
|
+
1. 为**每个源码目录**维护一份 Markdown 大纲(文件清单 / 关键符号 / 依赖关系 / 系统角色)。
|
|
27
|
+
2. 用**内容哈希 + manifest** 记住"上次同步时的样子",所以下一次只处理**真正变化**的目录。
|
|
28
|
+
3. 发布是**可回滚事务**;退役文档需要单独举证,不会自动删除。
|
|
29
|
+
|
|
30
|
+
一句话立场:**文档"已同步"必须由工具写下的 manifest 背书,而不是由生成它的模型自述。**
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## 目录
|
|
35
|
+
|
|
36
|
+
- [安装](#安装)
|
|
37
|
+
- [仓库布局](#仓库布局)
|
|
38
|
+
- [它解决的两个问题](#它解决的两个问题)
|
|
39
|
+
- [核心保证](#核心保证)
|
|
40
|
+
- [工作流六阶段](#工作流六阶段)
|
|
41
|
+
- [数据模型](#数据模型)
|
|
42
|
+
- [加载器用法](#加载器用法)
|
|
43
|
+
- [平台支持](#平台支持)
|
|
44
|
+
- [测试](#测试)
|
|
45
|
+
- [限制与取舍](#限制与取舍)
|
|
46
|
+
- [License](#license)
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## 安装
|
|
51
|
+
|
|
52
|
+
本仓本身是一个 **DeepSeek Harness bundle**,把技能、Python 工具和测试一起打包。按你的 agent 选一种:
|
|
53
|
+
|
|
54
|
+
**方式一:DSH bundle(推荐)**
|
|
55
|
+
|
|
56
|
+
在 **Plugins → More → 开启 Custom plugin markets → Discover** 里加入本仓的索引地址,然后安装
|
|
57
|
+
`proj-doc-builder`:
|
|
58
|
+
|
|
59
|
+
```text
|
|
60
|
+
https://walvka-code.github.io/proj-doc-builder/index.json
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
(同一份索引也发布在 `https://raw.githubusercontent.com/walvka-code/proj-doc-builder/main/index.json`,
|
|
64
|
+
但部分网络无法直连该域名;以 GitHub Pages 地址为准。)
|
|
65
|
+
|
|
66
|
+
不用市场时,可直接钉住某个 commit(bundle 是仓库里的一个包目录):
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
git+https://github.com/walvka-code/proj-doc-builder.git#<40 位 commit>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
或用 `plugin_manager` 装本地检出:
|
|
73
|
+
|
|
74
|
+
```json
|
|
75
|
+
{ "action": "install_bundle", "target": "C:/path/to/proj-doc-builder" }
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
bundle 挂载一个 bundled 技能提供方(rank 600):技能在 profile 的**所有会话**里可用;若某个项目自带
|
|
79
|
+
`.dsh/skills/proj-doc-builder/`,项目副本优先(用于钉住版本)。
|
|
80
|
+
|
|
81
|
+
**方式二:作为项目技能**
|
|
82
|
+
|
|
83
|
+
把 `skills/proj-doc-builder/` 复制到
|
|
84
|
+
`<project>/.dsh/skills/proj-doc-builder/`。`SKILL.md` 用宿主报告的技能目录解析工具路径,
|
|
85
|
+
两种布局都成立。
|
|
86
|
+
|
|
87
|
+
**方式三:当普通 CLI 用**(不需要任何 agent 框架)
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
git clone <this-repo> proj-doc-builder
|
|
91
|
+
SKILL="$(pwd)/proj-doc-builder/skills/proj-doc-builder"
|
|
92
|
+
python "$SKILL/tools/pipeline/sync_project_docs.py" /path/to/your/project --dry-run --json
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
**Python 3.12+,运行时零第三方依赖**(仅标准库)。测试需要 `pytest`(见 `requirements-dev.txt`)。
|
|
96
|
+
|
|
97
|
+
前置条件:你的项目根要有 `project_docs/` 与 `CLAUDE.md` 两个入口。
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## 仓库布局
|
|
102
|
+
|
|
103
|
+
```text
|
|
104
|
+
proj-doc-builder/ # DSH bundle + 纯 CLI 仓库
|
|
105
|
+
├── package.json # 名称 / dsh.bundle.patch / engines
|
|
106
|
+
├── cordis.patch.yml # 挂载 bundled 技能提供方
|
|
107
|
+
├── index.js # 读取 SKILL.md 并注册技能
|
|
108
|
+
├── index.json # 插件市场索引(format 1)
|
|
109
|
+
├── icon.svg # bundle 图标源文件
|
|
110
|
+
├── assets/icon-180.png # 渲染后的 bundle 图标
|
|
111
|
+
├── locale/{en,zh}.json # bundle 展示元数据
|
|
112
|
+
├── requirements-dev.txt # 仅 pytest — 运行时只用标准库
|
|
113
|
+
├── skills/proj-doc-builder/ # 技能本体
|
|
114
|
+
│ ├── SKILL.md # 入口契约:阶段、安全规则、CLI
|
|
115
|
+
│ ├── references/ # 模板、审计表、链接、Phase 4 等
|
|
116
|
+
│ ├── tests/ # 469 条 pytest 用例 + conftest.py
|
|
117
|
+
│ └── tools/
|
|
118
|
+
│ ├── _paths.py # 子包 sys.path 引导
|
|
119
|
+
│ ├── core/ # 契约、配置、链接计算、CLAUDE 索引
|
|
120
|
+
│ ├── scan/ # 目录扫描、链接检查、标记归一
|
|
121
|
+
│ ├── validate/ # validate_doc.py(12 项检查)
|
|
122
|
+
│ ├── pipeline/ # 同步协调器 + 脚手架生成器
|
|
123
|
+
│ ├── reader/ # load_docs.py(brief / overview / target)
|
|
124
|
+
│ ├── phase4/ # Phase 4 审计子包
|
|
125
|
+
│ └── phase4_exit.py # Phase 4 CLI 入口
|
|
126
|
+
├── scripts/check-bundle.mjs # 离线 bundle 自检(CI)
|
|
127
|
+
├── scripts/release.mjs # 版本号对齐 + 索引重钉
|
|
128
|
+
├── test/index.test.mjs # bundle 层 node 测试
|
|
129
|
+
└── .github/workflows/ci.yml
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## 它解决的两个问题
|
|
135
|
+
|
|
136
|
+
| # | 问题 | 本仓给出的答案 |
|
|
137
|
+
|---|---|---|
|
|
138
|
+
| **1** | 想快速梳理一个陌生工程,并留下"后续改了什么"的跟踪基线 | **大纲**:`project_docs/**/*.md`,每个源码目录一份。**基线**:`_scan_state.json`(逐文件 SHA-256 + 目录 fingerprint)与 `_manifest.json` 的 `generation_id`(只哈希内容)。两者合起来让下一次同步**只处理真正变化的目录**,而不是全量重写。 |
|
|
139
|
+
| **2** | 想让新开的 AI 对话快速加载工程概况,而不是每次从零读源码 | **加载器就在本仓**:`tools/reader/load_docs.py` 先校验 manifest 与文档完全一致(逐份 hash + 集合完整),再输出**速览**(工程摘要 + 每份文档一句话角色,受 `--max-chars` 约束)、**概览**(目录树 + 元数据 + 小节名)或**单份文档 / 单节**。写侧与读侧共用同一契约,不会各写一套解析而漂移。 |
|
|
140
|
+
|
|
141
|
+
为什么不是"让模型写一堆 md":**生成者和校验者必须是两个执行体**,否则"模型说已同步"永远无法被证伪。
|
|
142
|
+
|
|
143
|
+
| 崩点 | 表现 | 本工具的应对 |
|
|
144
|
+
|---|---|---|
|
|
145
|
+
| 漂移 | 源码加了文件,文档"文件清单"永远少一行 | 内容哈希快照 + 变更工作清单,只重写变化的目录 |
|
|
146
|
+
| 自证不可信 | 模型说"已同步",你无法复核 | 独立 manifest 记录每份文档的 size/SHA-256/title/status,不一致即拒绝 |
|
|
147
|
+
| 批量翻新毁历史 | 为过校验把所有历史文档重写一遍 | 只有"本轮变化"的文档是阻断项;历史文档只审计、不改写 |
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
## 核心保证
|
|
152
|
+
|
|
153
|
+
| 保证 | 机制 |
|
|
154
|
+
|---|---|
|
|
155
|
+
| **默认零写入** | 不带 `--apply` 一律只报告;staging 在系统临时目录,不在项目树建路径 |
|
|
156
|
+
| **单一提交点** | `project_docs/_manifest.json` 的那一次原子替换是文档代际的唯一 commit point |
|
|
157
|
+
| **不覆盖并发写入** | 发布用 no-replace rename(Windows `os.rename` / Linux `renameat2(RENAME_NOREPLACE)`),前置镜像不符即拒绝 |
|
|
158
|
+
| **失败必须分类** | 只报 `NOT_INSTALLED` / `INSTALLED` / `UNKNOWN` / `PARTIALLY_INSTALLED`,绝不虚构"已提交" |
|
|
159
|
+
| **不污染工作副本** | 锁、事务 journal、CAS 产物全在系统临时目录,版本控制里看不到 |
|
|
160
|
+
| **删除是举证而非清理** | 只在"源码目录确认消失 + 零入站引用 + 精确 marker + 已注册"时生成隔离候选,且默认只报告 |
|
|
161
|
+
| **幂等** | 零变化运行时 `planned_writes == []`,不刷新 `last_synced` |
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## 工作流六阶段
|
|
166
|
+
|
|
167
|
+
| Phase | 动作 | 关键产物 |
|
|
168
|
+
|---|---|---|
|
|
169
|
+
| 0 | 预检:项目根、`project_docs/`、`CLAUDE.md`、无待恢复事务 | — |
|
|
170
|
+
| 1 | `--dry-run` 得到变化分类与工作清单 | `scan.worklist.scaffold`(推荐 profile + 预计算相对链接) |
|
|
171
|
+
| 2 | **生成方**按工作清单写正文并逐份 `--strict` 校验 | `project_docs/*.md` |
|
|
172
|
+
| 3 | 全局 dry-run 闭环(断链、阻断、manifest 覆盖面) | `validation.blocking_failures == []` |
|
|
173
|
+
| 4 | 退役报告:哪些文档的源码已消失且零引用 | `phase4.candidates`(默认只报告) |
|
|
174
|
+
| 5 | `--apply` 发布 | manifest / CLAUDE 文档树 / scan state |
|
|
175
|
+
| 6 | 终验 + 版本控制只读范围检查 | `planned_writes == []` |
|
|
176
|
+
|
|
177
|
+
**协调器不生成任何自然语言**:它只做校验与事务发布,正文由生成方(人或模型)写入。
|
|
178
|
+
|
|
179
|
+
退出码:`0` 全过 / `1` 闸门失败(含"存在待恢复事务")/ `2` 输入或运行错误 / `3` 发布失败(**不等于未发布**,以 `publish.disposition` 为准)。
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
## 数据模型
|
|
184
|
+
|
|
185
|
+
| 文件 | 作用 |
|
|
186
|
+
|---|---|
|
|
187
|
+
| `project_docs/_manifest.json` | schema v2,每份文档记录 `path/depth/title/status/bytes/sha256/synced_at`,并给出 `generation_id`(只哈希内容,不含时间戳)与 `depth_counts` |
|
|
188
|
+
| `project_docs/_scan_state.json` | 源码目录快照(逐文件 SHA-256 + 目录 fingerprint):**这是"改动跟踪基线"**,决定下一轮 worklist |
|
|
189
|
+
| `CLAUDE.md` 六组 marker | `doc-tree-instruction` / `project-overview` / `common-commands` / `architecture` / `test-structure` / `dependencies`。工具**只替换第一组**,其余仅校验 marker 唯一、成对、不交叠 |
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
## 加载器用法
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
# 概览:树 + 每份文档的 title/status/字节数/小节名(默认 80 份、每份 6 个小节名)
|
|
197
|
+
python "$SKILL/tools/reader/load_docs.py" . --json
|
|
198
|
+
python "$SKILL/tools/reader/load_docs.py" . --mode brief --json # 速览:摘要 + 每份文档一句话
|
|
199
|
+
python "$SKILL/tools/reader/load_docs.py" . --limit 0 --sections 0 --json # 全部文档、只要元数据
|
|
200
|
+
|
|
201
|
+
# 定位:源码目录 / 文档路径 / 工程相对路径都可以
|
|
202
|
+
python "$SKILL/tools/reader/load_docs.py" . --mode target --target src/core --json
|
|
203
|
+
python "$SKILL/tools/reader/load_docs.py" . --mode target --target project_docs/src/core.md --json
|
|
204
|
+
|
|
205
|
+
# 只要某一节
|
|
206
|
+
python "$SKILL/tools/reader/load_docs.py" . --mode target --target src/core --section 依赖关系 --json
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
**先校验再加载**:manifest 与磁盘文档不一致(被改过、或多出未注册文档)时退出 `1` 并报 `manifest-stale`,绝不在陈旧索引上服务。
|
|
210
|
+
|
|
211
|
+
退出码:`0` 已校验可服务 / `1` 索引陈旧或目标未注册 / `2` 用法或路径安全问题(含 `../` 越界)。
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
## 平台支持
|
|
216
|
+
|
|
217
|
+
| 平台 | 状态 | 说明 |
|
|
218
|
+
|---|---|---|
|
|
219
|
+
| **Windows** | ✅ 已验证 | 重解析点/junction 识别、句柄级删除(可回收墓碑)、`msvcrt` 锁 |
|
|
220
|
+
| **Linux** | ✅ 已验证 | `fcntl` 锁、`dir_fd` 逐级 `O_NOFOLLOW` 走查、`renameat2(RENAME_NOREPLACE)`、目录 `fsync` |
|
|
221
|
+
| **macOS** | ⚠️ 未验证 | 有 `renamex_np` 分支但无 CI;APFS 大小写不敏感与 `fsync` 语义差异未取证 |
|
|
222
|
+
|
|
223
|
+
Linux 上必须知道的三条:
|
|
224
|
+
|
|
225
|
+
1. **`renameat2(RENAME_NOREPLACE)` 是硬依赖。** 不支持时抛 `NoReplaceRenameUnsupported` 并**明确拒绝**回退到会覆盖的 `rename`——覆盖会静默破坏崩溃一致性。
|
|
226
|
+
2. **目录 `fsync` 被拒时降级不中断。** 跳过并显式暴露(`warnings.warn` + 报告 `durability-degraded`);真实 I/O 错误仍上抛。
|
|
227
|
+
3. **POSIX 下墓碑只归档不删除。** 退役事务目录改名为 `.phase4-archive-*` 永久保留(无句柄绑定 unlink),需人工清理;Windows 可回收。
|
|
228
|
+
|
|
229
|
+
---
|
|
230
|
+
|
|
231
|
+
## 测试
|
|
232
|
+
|
|
233
|
+
```bash
|
|
234
|
+
python -m pytest skills/proj-doc-builder/tests -q
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
**469 个用例**(Windows:461 passed / 8 skipped;Linux 上 6 条"Windows 句柄语义"用例反向跳过、2 条 POSIX 文件权限用例改为执行),全部使用 `tmp_path`,不触碰真实 `project_docs/`。锁定的不是"功能"而是**崩溃一致性**:
|
|
238
|
+
|
|
239
|
+
- manifest 之前失败必须完整回滚;之后失败只准报 `installed/partial/unknown`,禁止回滚
|
|
240
|
+
- `KeyboardInterrupt` 落在每一个 rename 前后的落点
|
|
241
|
+
- 伪造 journal 槽位、ABA 竞态、staging 期间文档被并发修改
|
|
242
|
+
- `renameat2` 不可用 → 类型化失败;目录 `fsync` 被拒 → 降级且可见(CI 有专门的容器/overlayfs 作业)
|
|
243
|
+
|
|
244
|
+
---
|
|
245
|
+
|
|
246
|
+
## 限制与取舍
|
|
247
|
+
|
|
248
|
+
- 事务 journal 与 CAS 产物目录必须与项目根**同一文件系统**(跨盘会让 `--apply` 直接拒绝)。
|
|
249
|
+
- 路径白名单:只接受相对 POSIX、小写 `.md`;拒绝绝对路径、盘符、反斜杠、`..`、ADS、保留设备名与大小写冲突。
|
|
250
|
+
- **不跟随** symlink / junction / reparse point;路径身份无法证明时一律拒绝。
|
|
251
|
+
- `--full` 只是扫描器的 `force_full` 开关,**不等于**"逐份文档盘点文件清单"。
|
|
252
|
+
- 文档退役是**举证流程**,不是清理工具:默认只报告,`--apply` 需另行明确授权。
|
|
253
|
+
|
|
254
|
+
---
|
|
255
|
+
|
|
256
|
+
## License
|
|
257
|
+
|
|
258
|
+
[MIT](LICENSE)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@walvka-code/proj-doc-builder",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.2",
|
|
4
4
|
"description": "DeepSeek Harness bundle for the proj-doc-builder skill: scan, validate and publish AI-readable project documentation with committed scan state.",
|
|
5
5
|
"icon": "./icon.svg",
|
|
6
6
|
"type": "module",
|
|
@@ -18,7 +18,10 @@
|
|
|
18
18
|
"icon.svg",
|
|
19
19
|
"locale/*.json",
|
|
20
20
|
"README.md",
|
|
21
|
-
"skills/**/*"
|
|
21
|
+
"skills/**/*",
|
|
22
|
+
"!skills/**/__pycache__",
|
|
23
|
+
"!skills/**/__pycache__/**",
|
|
24
|
+
"!skills/**/*.pyc"
|
|
22
25
|
],
|
|
23
26
|
"keywords": [
|
|
24
27
|
"dsh-bundle",
|
|
@@ -51,6 +54,7 @@
|
|
|
51
54
|
},
|
|
52
55
|
"scripts": {
|
|
53
56
|
"check": "node scripts/check-bundle.mjs",
|
|
57
|
+
"check:counts": "node scripts/sync-test-counts.mjs",
|
|
54
58
|
"test": "node --test",
|
|
55
59
|
"release": "node scripts/release.mjs"
|
|
56
60
|
}
|