@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.md
CHANGED
|
@@ -1,272 +1,290 @@
|
|
|
1
|
-
# proj_doc_builder
|
|
2
|
-
|
|
3
|
-
**Turn a codebase into documentation an AI can actually read.** One command to build the outline,
|
|
4
|
-
one command to load it.
|
|
5
|
-
|
|
6
|
-
> **Language**: **English** (default) · [中文](README.zh-CN.md)
|
|
7
|
-
>
|
|
8
|
-
> `README.zh-CN.md` is a synced translation — update both together.
|
|
9
|
-
>
|
|
10
|
-
> Ships as a **DeepSeek Harness bundle** (`@walvka-code/proj-doc-builder`) **and** as a plain CLI.
|
|
11
|
-
|
|
12
|
-
```bash
|
|
13
|
-
# The skill directory: SKILL.md + tools/ live here
|
|
14
|
-
SKILL="$(pwd)/skills/proj-doc-builder"
|
|
15
|
-
|
|
16
|
-
# Sync: build/refresh the documentation index (preview first, then publish)
|
|
17
|
-
python "$SKILL/tools/sync_project_docs.py" . --dry-run --json
|
|
18
|
-
python "$SKILL/tools/sync_project_docs.py" . --apply --json
|
|
19
|
-
|
|
20
|
-
# Load: give a fresh conversation an entry point (overview → one document)
|
|
21
|
-
python "$SKILL/tools/load_docs.py" . --json
|
|
22
|
-
python "$SKILL/tools/load_docs.py" . --mode target --target src/core --json
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
What it does:
|
|
26
|
-
|
|
27
|
-
1. Keeps **one Markdown outline per source directory** (file inventory, key symbols, dependencies,
|
|
28
|
-
role in the system).
|
|
29
|
-
2. Remembers "what the tree looked like last time" via **content hashes + a manifest**, so the next
|
|
30
|
-
sync only touches directories that **actually changed**.
|
|
31
|
-
3. Publishes as a **recoverable transaction**; retiring a document is an explicit, evidence-gated
|
|
32
|
-
decision — never an automatic cleanup.
|
|
33
|
-
|
|
34
|
-
The stance, in one sentence: **"docs are in sync" must be backed by a manifest the tooling wrote,
|
|
35
|
-
not by the model that produced the prose.**
|
|
36
|
-
|
|
37
|
-
---
|
|
38
|
-
|
|
39
|
-
## Contents
|
|
40
|
-
|
|
41
|
-
- [Install](#install)
|
|
42
|
-
- [Repository layout](#repository-layout)
|
|
43
|
-
- [The two problems it solves](#the-two-problems-it-solves)
|
|
44
|
-
- [Guarantees](#guarantees)
|
|
45
|
-
- [The six-phase workflow](#the-six-phase-workflow)
|
|
46
|
-
- [Data model](#data-model)
|
|
47
|
-
- [Using the loader](#using-the-loader)
|
|
48
|
-
- [Platform support](#platform-support)
|
|
49
|
-
- [Tests](#tests)
|
|
50
|
-
- [Limitations and trade-offs](#limitations-and-trade-offs)
|
|
51
|
-
- [License](#license)
|
|
52
|
-
|
|
53
|
-
---
|
|
54
|
-
|
|
55
|
-
## Install
|
|
56
|
-
|
|
57
|
-
The repository is a **DeepSeek Harness bundle** that packages the skill, its Python tools and its
|
|
58
|
-
tests. Pick the install that fits your agent:
|
|
59
|
-
|
|
60
|
-
**Option 1 — DeepSeek Harness bundle (recommended)**
|
|
61
|
-
|
|
62
|
-
Add this market index under **Plugins → More → Custom plugin markets → Discover**, then install
|
|
63
|
-
`proj-doc-builder`:
|
|
64
|
-
|
|
65
|
-
```text
|
|
66
|
-
https://walvka-code.github.io/proj-doc-builder/index.json
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
(The same file is also served from `https://raw.githubusercontent.com/walvka-code/proj-doc-builder/main/index.json`,
|
|
70
|
-
but that host is unreachable from some networks; GitHub Pages is the primary address.)
|
|
71
|
-
|
|
72
|
-
Without the market, pin one commit (the bundle is a package directory in Git):
|
|
73
|
-
|
|
74
|
-
```bash
|
|
75
|
-
git+https://github.com/walvka-code/proj-doc-builder.git#<40-hex-commit>
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
or install a local checkout with the `plugin_manager` tool:
|
|
79
|
-
|
|
80
|
-
```json
|
|
81
|
-
{ "action": "install_bundle", "target": "C:/path/to/proj-doc-builder" }
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
The bundle mounts one bundled skill provider (rank 600): the skill is available in **every** session
|
|
85
|
-
of the profile, and a project-local `.dsh/skills/proj-doc-builder/` copy still wins when a repository
|
|
86
|
-
wants to pin its own version.
|
|
87
|
-
|
|
88
|
-
**Option 2 — as a project skill**
|
|
89
|
-
|
|
90
|
-
Copy `skills/proj-doc-builder/` to
|
|
91
|
-
`<project>/.dsh/skills/proj-doc-builder/`. `SKILL.md` resolves its tools through the skill directory
|
|
92
|
-
the host reports, so both layouts work unchanged.
|
|
93
|
-
|
|
94
|
-
**Option 3 — as a plain CLI** (no agent framework needed)
|
|
95
|
-
|
|
96
|
-
```bash
|
|
97
|
-
git clone <this-repo> proj-doc-builder
|
|
98
|
-
SKILL="$(pwd)/proj-doc-builder/skills/proj-doc-builder"
|
|
99
|
-
python "$SKILL/tools/sync_project_docs.py" /path/to/your/project --dry-run --json
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
**Python 3.12+, zero third-party runtime dependencies** (standard library only).
|
|
103
|
-
Tests need `pytest` (see `requirements-dev.txt`).
|
|
104
|
-
|
|
105
|
-
Prerequisites: your project root needs a `project_docs/` directory and a `CLAUDE.md` entry point.
|
|
106
|
-
|
|
107
|
-
---
|
|
108
|
-
|
|
109
|
-
## Repository layout
|
|
110
|
-
|
|
111
|
-
```text
|
|
112
|
-
proj-doc-builder/
|
|
113
|
-
├── package.json # name / dsh.bundle.patch / engines
|
|
114
|
-
├── cordis.patch.yml # mounts the bundled skill provider
|
|
115
|
-
├── index.js # reads SKILL.md, registers the skill
|
|
116
|
-
├── index.json # plugin market index (format 1)
|
|
117
|
-
├── icon.svg
|
|
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
|
-
|
|
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
|
-
|
|
1
|
+
# proj_doc_builder
|
|
2
|
+
|
|
3
|
+
**Turn a codebase into documentation an AI can actually read.** One command to build the outline,
|
|
4
|
+
one command to load it.
|
|
5
|
+
|
|
6
|
+
> **Language**: **English** (default) · [中文](README.zh-CN.md)
|
|
7
|
+
>
|
|
8
|
+
> `README.zh-CN.md` is a synced translation — update both together.
|
|
9
|
+
>
|
|
10
|
+
> Ships as a **DeepSeek Harness bundle** (`@walvka-code/proj-doc-builder`) **and** as a plain CLI.
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
# The skill directory: SKILL.md + tools/ live here
|
|
14
|
+
SKILL="$(pwd)/skills/proj-doc-builder"
|
|
15
|
+
|
|
16
|
+
# Sync: build/refresh the documentation index (preview first, then publish)
|
|
17
|
+
python "$SKILL/tools/pipeline/sync_project_docs.py" . --dry-run --json
|
|
18
|
+
python "$SKILL/tools/pipeline/sync_project_docs.py" . --apply --json
|
|
19
|
+
|
|
20
|
+
# Load: give a fresh conversation an entry point (overview → one document)
|
|
21
|
+
python "$SKILL/tools/reader/load_docs.py" . --json
|
|
22
|
+
python "$SKILL/tools/reader/load_docs.py" . --mode target --target src/core --json
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
What it does:
|
|
26
|
+
|
|
27
|
+
1. Keeps **one Markdown outline per source directory** (file inventory, key symbols, dependencies,
|
|
28
|
+
role in the system).
|
|
29
|
+
2. Remembers "what the tree looked like last time" via **content hashes + a manifest**, so the next
|
|
30
|
+
sync only touches directories that **actually changed**.
|
|
31
|
+
3. Publishes as a **recoverable transaction**; retiring a document is an explicit, evidence-gated
|
|
32
|
+
decision — never an automatic cleanup.
|
|
33
|
+
|
|
34
|
+
The stance, in one sentence: **"docs are in sync" must be backed by a manifest the tooling wrote,
|
|
35
|
+
not by the model that produced the prose.**
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Contents
|
|
40
|
+
|
|
41
|
+
- [Install](#install)
|
|
42
|
+
- [Repository layout](#repository-layout)
|
|
43
|
+
- [The two problems it solves](#the-two-problems-it-solves)
|
|
44
|
+
- [Guarantees](#guarantees)
|
|
45
|
+
- [The six-phase workflow](#the-six-phase-workflow)
|
|
46
|
+
- [Data model](#data-model)
|
|
47
|
+
- [Using the loader](#using-the-loader)
|
|
48
|
+
- [Platform support](#platform-support)
|
|
49
|
+
- [Tests](#tests)
|
|
50
|
+
- [Limitations and trade-offs](#limitations-and-trade-offs)
|
|
51
|
+
- [License](#license)
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## Install
|
|
56
|
+
|
|
57
|
+
The repository is a **DeepSeek Harness bundle** that packages the skill, its Python tools and its
|
|
58
|
+
tests. Pick the install that fits your agent:
|
|
59
|
+
|
|
60
|
+
**Option 1 — DeepSeek Harness bundle (recommended)**
|
|
61
|
+
|
|
62
|
+
Add this market index under **Plugins → More → Custom plugin markets → Discover**, then install
|
|
63
|
+
`proj-doc-builder`:
|
|
64
|
+
|
|
65
|
+
```text
|
|
66
|
+
https://walvka-code.github.io/proj-doc-builder/index.json
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
(The same file is also served from `https://raw.githubusercontent.com/walvka-code/proj-doc-builder/main/index.json`,
|
|
70
|
+
but that host is unreachable from some networks; GitHub Pages is the primary address.)
|
|
71
|
+
|
|
72
|
+
Without the market, pin one commit (the bundle is a package directory in Git):
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
git+https://github.com/walvka-code/proj-doc-builder.git#<40-hex-commit>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
or install a local checkout with the `plugin_manager` tool:
|
|
79
|
+
|
|
80
|
+
```json
|
|
81
|
+
{ "action": "install_bundle", "target": "C:/path/to/proj-doc-builder" }
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
The bundle mounts one bundled skill provider (rank 600): the skill is available in **every** session
|
|
85
|
+
of the profile, and a project-local `.dsh/skills/proj-doc-builder/` copy still wins when a repository
|
|
86
|
+
wants to pin its own version.
|
|
87
|
+
|
|
88
|
+
**Option 2 — as a project skill**
|
|
89
|
+
|
|
90
|
+
Copy `skills/proj-doc-builder/` to
|
|
91
|
+
`<project>/.dsh/skills/proj-doc-builder/`. `SKILL.md` resolves its tools through the skill directory
|
|
92
|
+
the host reports, so both layouts work unchanged.
|
|
93
|
+
|
|
94
|
+
**Option 3 — as a plain CLI** (no agent framework needed)
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
git clone <this-repo> proj-doc-builder
|
|
98
|
+
SKILL="$(pwd)/proj-doc-builder/skills/proj-doc-builder"
|
|
99
|
+
python "$SKILL/tools/pipeline/sync_project_docs.py" /path/to/your/project --dry-run --json
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
**Python 3.12+, zero third-party runtime dependencies** (standard library only).
|
|
103
|
+
Tests need `pytest` (see `requirements-dev.txt`).
|
|
104
|
+
|
|
105
|
+
Prerequisites: your project root needs a `project_docs/` directory and a `CLAUDE.md` entry point.
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## Repository layout
|
|
110
|
+
|
|
111
|
+
```text
|
|
112
|
+
proj-doc-builder/ # DSH bundle + plain-CLI repo
|
|
113
|
+
├── package.json # name / dsh.bundle.patch / engines
|
|
114
|
+
├── cordis.patch.yml # mounts the bundled skill provider
|
|
115
|
+
├── index.js # reads SKILL.md, registers the skill
|
|
116
|
+
├── index.json # plugin market index (format 1)
|
|
117
|
+
├── icon.svg # bundle icon source
|
|
118
|
+
├── assets/icon-180.png # rendered bundle icon
|
|
119
|
+
├── locale/{en,zh}.json # bundle display metadata
|
|
120
|
+
├── requirements-dev.txt # pytest only — runtime is stdlib
|
|
121
|
+
├── skills/proj-doc-builder/ # the skill itself
|
|
122
|
+
│ ├── SKILL.md # entry contract: phases, safety rules, CLI
|
|
123
|
+
│ ├── references/ # templates, checklist, linking, Phase 4 ...
|
|
124
|
+
│ ├── tests/ # 469 pytest cases + conftest.py
|
|
125
|
+
│ └── tools/
|
|
126
|
+
│ ├── _paths.py # sys.path bootstrap for subpackages
|
|
127
|
+
│ ├── core/ # contract, config, link math, CLAUDE index
|
|
128
|
+
│ ├── scan/ # directory scan, link check, markers
|
|
129
|
+
│ ├── validate/ # validate_doc.py (12 checks)
|
|
130
|
+
│ ├── pipeline/ # sync coordinator + scaffold generator
|
|
131
|
+
│ ├── reader/ # load_docs.py (brief / overview / target)
|
|
132
|
+
│ ├── phase4/ # Phase 4 auditor subpackage
|
|
133
|
+
│ └── phase4_exit.py # Phase 4 CLI entry
|
|
134
|
+
├── scripts/check-bundle.mjs # offline bundle checks (CI)
|
|
135
|
+
├── scripts/release.mjs # version bump + index repin
|
|
136
|
+
├── test/index.test.mjs # bundle-level node tests
|
|
137
|
+
└── .github/workflows/ci.yml
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
## The two problems it solves
|
|
143
|
+
|
|
144
|
+
| # | Problem | What this repo gives you |
|
|
145
|
+
|---|---|---|
|
|
146
|
+
| **1** | You want to map an unfamiliar codebase quickly, and keep a baseline for "what changed since" | **Outline**: `project_docs/**/*.md`, one document per source directory. **Baseline**: `_scan_state.json` (per-file SHA-256 + directory fingerprints) plus the manifest's `generation_id` (content-only hash). Together they make the next sync **incremental** instead of a full rewrite. |
|
|
147
|
+
| **2** | You want a new AI conversation to load the project shape instead of re-reading source from scratch | **The loader ships in this repo**: `tools/reader/load_docs.py` first verifies the manifest against the documents (per-file hashes + complete-set check), then serves a **brief** orientation (project abstract + one-line role per document, bounded by `--max-chars`), an **overview** (tree + metadata + section names), or a **single document / single section**. Writer and reader import the same contract, so the rules cannot drift apart. |
|
|
148
|
+
|
|
149
|
+
Why not just "have a model write a pile of `.md` files"? Because **the producer and the verifier must
|
|
150
|
+
be separate actors** — otherwise "the model says it's in sync" can never be falsified.
|
|
151
|
+
|
|
152
|
+
| Failure mode | Symptom | What this tool does |
|
|
153
|
+
|---|---|---|
|
|
154
|
+
| Drift | Source gained a file; the document's inventory is permanently one row short | Content-hash snapshot + worklist; only changed directories are rewritten |
|
|
155
|
+
| Unfalsifiable claims | "It's synced" with nothing to check | An independent manifest records size/SHA-256/title/status per document; mismatch is refused |
|
|
156
|
+
| Mass rewrite destroys history | Everything is rewritten just to pass validation | Only documents for changed directories block; unchanged history is audited, not rewritten |
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
## Guarantees
|
|
161
|
+
|
|
162
|
+
| Guarantee | Mechanism |
|
|
163
|
+
|---|---|
|
|
164
|
+
| **No writes by default** | Without `--apply` everything is report-only; staging lives in the system temp dir, never in the project tree |
|
|
165
|
+
| **Single commit point** | The atomic replace of `project_docs/_manifest.json` is the only documentation-generation commit point |
|
|
166
|
+
| **Never clobbers concurrent writes** | Publication uses no-replace rename (Windows `os.rename`, Linux `renameat2(RENAME_NOREPLACE)`); a mismatched preimage aborts |
|
|
167
|
+
| **Failures are classified** | Only `NOT_INSTALLED` / `INSTALLED` / `UNKNOWN` / `PARTIALLY_INSTALLED` — never a fabricated "committed" |
|
|
168
|
+
| **Working copy stays clean** | Locks, transaction journals and CAS artifacts live in the temp dir; your VCS never sees them |
|
|
169
|
+
| **Deletion is a burden of proof** | A document is only quarantined when its source directory is proven gone, it has zero inbound links, carries the exact marker and is registered — and even then it is report-only by default |
|
|
170
|
+
| **Idempotent** | A zero-change run reports `planned_writes == []` and does not refresh `last_synced` |
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## The six-phase workflow
|
|
175
|
+
|
|
176
|
+
| Phase | Action | Key output |
|
|
177
|
+
|---|---|---|
|
|
178
|
+
| 0 | Preflight: project root, `project_docs/`, `CLAUDE.md`, no pending recovery | — |
|
|
179
|
+
| 1 | `--dry-run` yields change classes and a worklist | `scan.worklist.scaffold` (profile + precomputed relative links) |
|
|
180
|
+
| 2 | The **producer** writes prose per worklist entry and `--strict` validates each one | `project_docs/*.md` |
|
|
181
|
+
| 3 | Whole-tree dry-run (links, blockers, manifest coverage) | `validation.blocking_failures == []` |
|
|
182
|
+
| 4 | Retirement report: documents whose source is gone and unreferenced | `phase4.candidates` (report-only by default) |
|
|
183
|
+
| 5 | `--apply` publishes | manifest / CLAUDE tree / scan state |
|
|
184
|
+
| 6 | Terminal verification + read-only VCS scope check | `planned_writes == []` |
|
|
185
|
+
|
|
186
|
+
The coordinator **never generates natural language**: it validates and publishes; the prose is
|
|
187
|
+
written by the producer (a human or a model).
|
|
188
|
+
|
|
189
|
+
Exit codes: `0` all gates passed / `1` a gate failed (including "a transaction needs recovery") /
|
|
190
|
+
`2` input or runtime error / `3` publish failed (**not the same as "not published"** — read
|
|
191
|
+
`publish.disposition`).
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
## Data model
|
|
196
|
+
|
|
197
|
+
| File | Purpose |
|
|
198
|
+
|---|---|
|
|
199
|
+
| `project_docs/_manifest.json` | Schema v2; per document `path/depth/title/status/bytes/sha256/synced_at`, plus `generation_id` (content-only, timestamps excluded) and `depth_counts` |
|
|
200
|
+
| `project_docs/_scan_state.json` | Source-tree snapshot (per-file SHA-256 + directory fingerprints): **this is the change-tracking baseline** that produces the next worklist |
|
|
201
|
+
| Six marker groups in `CLAUDE.md` | `doc-tree-instruction` / `project-overview` / `common-commands` / `architecture` / `test-structure` / `dependencies`. The tool **replaces only the first group**; the rest are only checked for unique, paired, non-overlapping markers |
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
## Using the loader
|
|
206
|
+
|
|
207
|
+
```bash
|
|
208
|
+
# Overview: tree + per-document title/status/bytes/section names
|
|
209
|
+
# (defaults: 80 documents, 6 section names each)
|
|
210
|
+
python tools/reader/load_docs.py . --json
|
|
211
|
+
python tools/reader/load_docs.py . --mode brief --json # fast orientation: abstract + one-line per doc
|
|
212
|
+
python tools/reader/load_docs.py . --limit 0 --sections 0 --json # every document, metadata only
|
|
213
|
+
|
|
214
|
+
# Target: a source directory, a document path, or a project-relative path
|
|
215
|
+
python tools/reader/load_docs.py . --mode target --target src/core --json
|
|
216
|
+
python tools/reader/load_docs.py . --mode target --target project_docs/src/core.md --json
|
|
217
|
+
|
|
218
|
+
# One section only
|
|
219
|
+
python tools/reader/load_docs.py . --mode target --target src/core --section Dependencies --json
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
**Verify, then serve.** If the manifest disagrees with the documents (edited files, or an
|
|
223
|
+
unregistered document), the loader exits `1` with `manifest-stale` — it will not serve a stale index.
|
|
224
|
+
|
|
225
|
+
Exit codes: `0` verified and served / `1` stale index or unregistered target / `2` usage or
|
|
226
|
+
path-safety error (including `../` traversal).
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
## Platform support
|
|
231
|
+
|
|
232
|
+
| Platform | Status | Notes |
|
|
233
|
+
|---|---|---|
|
|
234
|
+
| **Windows** | ✅ Verified | Reparse-point/junction detection, handle-bound deletion (reclaims tombstones), `msvcrt` locks |
|
|
235
|
+
| **Linux** | ✅ Verified | `fcntl` locks, `dir_fd` + `O_NOFOLLOW` path walking, `renameat2(RENAME_NOREPLACE)`, directory `fsync` |
|
|
236
|
+
| **macOS** | ⚠️ Untested | A `renamex_np` branch exists but CI does not cover it; APFS case-insensitivity and `fsync` semantics are unverified |
|
|
237
|
+
|
|
238
|
+
Three things to know on Linux:
|
|
239
|
+
|
|
240
|
+
1. **`renameat2(RENAME_NOREPLACE)` is a hard requirement.** When unsupported, the tool raises
|
|
241
|
+
`NoReplaceRenameUnsupported` and **refuses** to fall back to a replacing rename — a silent
|
|
242
|
+
fallback would quietly break crash consistency.
|
|
243
|
+
2. **Directory `fsync` degrades instead of aborting.** Filesystems that reject it are recorded and
|
|
244
|
+
surfaced (`warnings.warn` plus a `durability-degraded` warning in the report); real I/O errors
|
|
245
|
+
still propagate.
|
|
246
|
+
3. **On POSIX, tombstones are archived, not deleted.** Retired transaction directories are renamed to
|
|
247
|
+
`.phase4-archive-*` and kept forever (there is no handle-bound `unlink`), so they accumulate and
|
|
248
|
+
need manual cleanup. Windows reclaims them.
|
|
249
|
+
|
|
250
|
+
---
|
|
251
|
+
|
|
252
|
+
## Tests
|
|
253
|
+
|
|
254
|
+
```bash
|
|
255
|
+
python -m pytest skills/proj-doc-builder/tests -q # the Python tools (469 cases)
|
|
256
|
+
npm test # the bundled provider + frontmatter reader
|
|
257
|
+
npm run check # manifest, patch, packaged files, market index
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
**469 tests** (Windows: 461 passed / 8 skipped; on Linux the six Windows-handle-semantics tests
|
|
261
|
+
flip to skipped and the two POSIX file-permission tests run instead). Everything runs in `tmp_path` — your real `project_docs/` is never touched. They
|
|
262
|
+
pin **crash consistency**, not features:
|
|
263
|
+
|
|
264
|
+
- a failure before the manifest commit must roll back completely; after it, only
|
|
265
|
+
`installed/partial/unknown` may be reported and rollback is forbidden
|
|
266
|
+
- `KeyboardInterrupt` injected before and after every rename
|
|
267
|
+
- forged journal slots, ABA races, documents modified concurrently during staging
|
|
268
|
+
- unavailable `renameat2` → typed failure; rejected directory `fsync` → visible degradation
|
|
269
|
+
(CI runs a dedicated container/overlayfs job for both)
|
|
270
|
+
|
|
271
|
+
---
|
|
272
|
+
|
|
273
|
+
## Limitations and trade-offs
|
|
274
|
+
|
|
275
|
+
- Journal and CAS artifact directories must live on **the same filesystem** as the project root
|
|
276
|
+
(cross-volume setups make `--apply` refuse).
|
|
277
|
+
- Path whitelist: relative POSIX, lowercase `.md` only; absolute paths, drive letters, backslashes,
|
|
278
|
+
`..`, ADS, reserved device names and case-only conflicts are rejected.
|
|
279
|
+
- **Symlinks, junctions and reparse points are never followed**; when path identity cannot be proven,
|
|
280
|
+
the tool fails closed.
|
|
281
|
+
- `--full` is only the scanner's `force_full` switch — it is **not** "reconcile every document's file
|
|
282
|
+
inventory"; that remains a producer step.
|
|
283
|
+
- Document retirement is a **burden-of-proof flow**, not a cleanup utility: report-only by default,
|
|
284
|
+
`--apply` requires explicit authorization.
|
|
285
|
+
|
|
286
|
+
---
|
|
287
|
+
|
|
288
|
+
## License
|
|
289
|
+
|
|
290
|
+
[MIT](LICENSE)
|