@walvka-code/proj-doc-builder 0.0.0-stage → 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/LICENSE +21 -0
- package/README.md +290 -3
- package/README.zh-CN.md +258 -0
- package/cordis.patch.yml +8 -0
- package/icon.svg +11 -0
- package/index.js +164 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +59 -4
- package/skills/proj-doc-builder/SKILL.md +412 -0
- package/skills/proj-doc-builder/references/audit_script.md +103 -0
- package/skills/proj-doc-builder/references/batch-generation.md +55 -0
- package/skills/proj-doc-builder/references/checklist.md +90 -0
- package/skills/proj-doc-builder/references/exclusions.md +79 -0
- package/skills/proj-doc-builder/references/linking.md +83 -0
- package/skills/proj-doc-builder/references/migration.md +32 -0
- package/skills/proj-doc-builder/references/phase4.md +200 -0
- package/skills/proj-doc-builder/references/templates.md +212 -0
- package/skills/proj-doc-builder/tests/claims.json +76 -0
- package/skills/proj-doc-builder/tests/conftest.py +23 -0
- package/skills/proj-doc-builder/tests/test_claims_registry.py +81 -0
- package/skills/proj-doc-builder/tests/test_claude_doc_index.py +157 -0
- package/skills/proj-doc-builder/tests/test_e2e_fresh_project.py +156 -0
- package/skills/proj-doc-builder/tests/test_link_tools.py +279 -0
- package/skills/proj-doc-builder/tests/test_load_docs.py +353 -0
- package/skills/proj-doc-builder/tests/test_normalize_markers.py +120 -0
- package/skills/proj-doc-builder/tests/test_phase4_exit.py +3895 -0
- package/skills/proj-doc-builder/tests/test_project_docs_contract.py +812 -0
- package/skills/proj-doc-builder/tests/test_scan_dirs.py +1159 -0
- 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 -0
- 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 +712 -0
- package/skills/proj-doc-builder/tools/_paths.py +39 -0
- package/skills/proj-doc-builder/tools/core/claude_doc_index.py +504 -0
- package/skills/proj-doc-builder/tools/core/compute_link.py +239 -0
- package/skills/proj-doc-builder/tools/core/proj_doc_config.py +460 -0
- package/skills/proj-doc-builder/tools/core/project_docs_contract.py +2725 -0
- package/skills/proj-doc-builder/tools/phase4/__init__.py +82 -0
- package/skills/proj-doc-builder/tools/phase4/cas_storage.py +25 -0
- package/skills/proj-doc-builder/tools/phase4/engine.py +35 -0
- package/skills/proj-doc-builder/tools/phase4/journal.py +29 -0
- package/skills/proj-doc-builder/tools/phase4/platform_handles.py +27 -0
- package/skills/proj-doc-builder/tools/phase4_exit.py +8565 -0
- package/skills/proj-doc-builder/tools/pipeline/gen_docs_from_scaffold.py +789 -0
- package/skills/proj-doc-builder/tools/pipeline/sync_project_docs.py +5531 -0
- package/skills/proj-doc-builder/tools/reader/load_docs.py +654 -0
- package/skills/proj-doc-builder/tools/scan/link_check.py +203 -0
- package/skills/proj-doc-builder/tools/scan/normalize_markers.py +211 -0
- package/skills/proj-doc-builder/tools/scan/scan_dirs.py +2735 -0
- package/skills/proj-doc-builder/tools/validate/validate_doc.py +1911 -0
package/index.js
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bundled `proj-doc-builder` skill provider for DeepSeek Harness.
|
|
3
|
+
*
|
|
4
|
+
* This package ships the skill (SKILL.md, tools/, references/, tests/) inside
|
|
5
|
+
* `skills/proj-doc-builder/`. The provider reads the Markdown body at load time
|
|
6
|
+
* and reports the skill directory as its resource base, so every relative path
|
|
7
|
+
* in the instructions resolves beside the installed package instead of a
|
|
8
|
+
* project-local `.dsh/skills/proj-doc-builder/` checkout.
|
|
9
|
+
*
|
|
10
|
+
* Rank 600 is the bundled rank: a project-local or user-level copy of the same
|
|
11
|
+
* skill still wins, which is what lets a repository pin its own version.
|
|
12
|
+
*
|
|
13
|
+
* @module @walvka-code/proj-doc-builder
|
|
14
|
+
*/
|
|
15
|
+
import { readFile } from "node:fs/promises";
|
|
16
|
+
import { dirname, join } from "node:path";
|
|
17
|
+
import { fileURLToPath } from "node:url";
|
|
18
|
+
|
|
19
|
+
/** Cordis plugin name. */
|
|
20
|
+
export const name = "proj-doc-builder";
|
|
21
|
+
|
|
22
|
+
/** Service required by this bundled provider. */
|
|
23
|
+
export const inject = ["skills"];
|
|
24
|
+
|
|
25
|
+
/** Registry provider name; unique across mounted skill providers. */
|
|
26
|
+
const PROVIDER_NAME = "proj-doc-builder";
|
|
27
|
+
|
|
28
|
+
/** Standard precedence rank for packaged skill providers and local bundled roots. */
|
|
29
|
+
const BUNDLED_SKILL_RANK = 600;
|
|
30
|
+
|
|
31
|
+
const SKILL_DIR = join(dirname(fileURLToPath(import.meta.url)), "skills", "proj-doc-builder");
|
|
32
|
+
const SKILL_FILE = join(SKILL_DIR, "SKILL.md");
|
|
33
|
+
|
|
34
|
+
/** Used only when SKILL.md frontmatter cannot be read, so the catalog never loses the skill. */
|
|
35
|
+
const DESCRIPTION_FALLBACK =
|
|
36
|
+
"Safely scan, validate, and synchronize AI-readable project documentation, the manifest and the CLAUDE document tree.";
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Strip one pair of matching quotes from a scalar.
|
|
40
|
+
* @param {string} value - raw frontmatter scalar.
|
|
41
|
+
* @returns {string} unquoted scalar.
|
|
42
|
+
*/
|
|
43
|
+
function unquote(value) {
|
|
44
|
+
const match = /^(['"])([\s\S]*)\1$/.exec(value);
|
|
45
|
+
return match ? match[2] : value;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Parse the flat YAML frontmatter this skill declares.
|
|
50
|
+
*
|
|
51
|
+
* Only top-level `key: value` pairs and folded (`>`) or literal (`|`) block
|
|
52
|
+
* scalars are modelled; nested mappings are ignored, which is enough for the
|
|
53
|
+
* `name`, `description` and invocation keys the skill registry consumes.
|
|
54
|
+
*
|
|
55
|
+
* @param {string} text - complete SKILL.md source.
|
|
56
|
+
* @returns {{ meta: Record<string, string>, body: string }} parsed metadata and the Markdown body.
|
|
57
|
+
*/
|
|
58
|
+
export function parseFrontMatter(text) {
|
|
59
|
+
const source = text.replace(/^\uFEFF/, "");
|
|
60
|
+
const match = /^---\r?\n([\s\S]*?)\r?\n---[ \t]*\r?\n?/.exec(source);
|
|
61
|
+
if (!match) return { meta: {}, body: source };
|
|
62
|
+
|
|
63
|
+
/** @type {Record<string, string>} */
|
|
64
|
+
const meta = {};
|
|
65
|
+
let blockKey = null;
|
|
66
|
+
for (const line of match[1].split(/\r?\n/)) {
|
|
67
|
+
if (!line.trim()) continue;
|
|
68
|
+
const pair = /^([A-Za-z0-9_-]+):(.*)$/.exec(line);
|
|
69
|
+
if (pair) {
|
|
70
|
+
const [, key, rest] = pair;
|
|
71
|
+
const value = rest.trim();
|
|
72
|
+
if (value === ">" || value === "|" || value === ">-" || value === "|-") {
|
|
73
|
+
blockKey = key;
|
|
74
|
+
meta[key] = "";
|
|
75
|
+
} else if (value === "") {
|
|
76
|
+
blockKey = null;
|
|
77
|
+
meta[key] = "";
|
|
78
|
+
} else {
|
|
79
|
+
blockKey = null;
|
|
80
|
+
meta[key] = unquote(value);
|
|
81
|
+
}
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
if (blockKey && /^\s+\S/.test(line)) {
|
|
85
|
+
const piece = line.trim();
|
|
86
|
+
meta[blockKey] = meta[blockKey] ? `${meta[blockKey]} ${piece}` : piece;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
for (const key of Object.keys(meta)) meta[key] = meta[key].replace(/\s+/g, " ").trim();
|
|
90
|
+
return { meta, body: source.slice(match[0].length) };
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Resolve invocation controls from frontmatter flags.
|
|
95
|
+
* @param {Record<string, string>} meta - parsed frontmatter.
|
|
96
|
+
* @returns {{ modelInvocable: boolean, userInvocable: boolean }} invocation policy.
|
|
97
|
+
*/
|
|
98
|
+
function invocationOf(meta) {
|
|
99
|
+
const flag = (key, fallback) => {
|
|
100
|
+
const value = meta[key];
|
|
101
|
+
if (value === undefined || value === "") return fallback;
|
|
102
|
+
return value === "true";
|
|
103
|
+
};
|
|
104
|
+
return {
|
|
105
|
+
modelInvocable: !flag("disable-model-invocation", false),
|
|
106
|
+
userInvocable: flag("user-invocable", true),
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** @type {{ meta: Record<string, string>, body: string } | undefined} */
|
|
111
|
+
let cachedSkill;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Read and cache SKILL.md.
|
|
115
|
+
* @param {{ signal?: AbortSignal }} [options] - lookup options.
|
|
116
|
+
* @returns {Promise<{ meta: Record<string, string>, body: string }>} parsed skill.
|
|
117
|
+
*/
|
|
118
|
+
async function loadSkill(options) {
|
|
119
|
+
options?.signal?.throwIfAborted?.();
|
|
120
|
+
if (!cachedSkill) {
|
|
121
|
+
cachedSkill = parseFrontMatter(await readFile(SKILL_FILE, "utf8"));
|
|
122
|
+
}
|
|
123
|
+
return cachedSkill;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Build the registry-facing summary of one parsed skill.
|
|
128
|
+
* @param {Record<string, string>} meta - parsed frontmatter.
|
|
129
|
+
* @returns {object} skill candidate without `rank`/`locator`.
|
|
130
|
+
*/
|
|
131
|
+
function summaryOf(meta) {
|
|
132
|
+
return {
|
|
133
|
+
name: meta.name || PROVIDER_NAME,
|
|
134
|
+
description: meta.description || DESCRIPTION_FALLBACK,
|
|
135
|
+
invocation: invocationOf(meta),
|
|
136
|
+
source: "bundled",
|
|
137
|
+
provider: PROVIDER_NAME,
|
|
138
|
+
resourceBase: { kind: "directory", path: SKILL_DIR },
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** @type {import('@deepseek-ai/dsh-skill').SkillProvider} */
|
|
143
|
+
const provider = {
|
|
144
|
+
name: PROVIDER_NAME,
|
|
145
|
+
async list(options = {}) {
|
|
146
|
+
if (options.signal?.aborted) return [];
|
|
147
|
+
const { meta } = await loadSkill(options);
|
|
148
|
+
return [{ ...summaryOf(meta), rank: BUNDLED_SKILL_RANK, locator: SKILL_FILE }];
|
|
149
|
+
},
|
|
150
|
+
async get(_candidate, options = {}) {
|
|
151
|
+
if (options.signal?.aborted) return undefined;
|
|
152
|
+
const { meta, body } = await loadSkill(options);
|
|
153
|
+
return { ...summaryOf(meta), content: body };
|
|
154
|
+
},
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Register the bundled provider on `ctx.skills`.
|
|
159
|
+
* @param {import('@deepseek-ai/cordis').Context} ctx - owning context.
|
|
160
|
+
* @returns {void}
|
|
161
|
+
*/
|
|
162
|
+
export function apply(ctx) {
|
|
163
|
+
ctx.skills.registerProvider(() => provider);
|
|
164
|
+
}
|
package/locale/en.json
ADDED
package/locale/zh.json
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,61 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@walvka-code/proj-doc-builder",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "4.5.2",
|
|
4
|
+
"description": "DeepSeek Harness bundle for the proj-doc-builder skill: scan, validate and publish AI-readable project documentation with committed scan state.",
|
|
5
|
+
"icon": "./icon.svg",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "index.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": "./index.js",
|
|
10
|
+
"./cordis.patch.yml": "./cordis.patch.yml",
|
|
11
|
+
"./locale/*.json": "./locale/*.json",
|
|
12
|
+
"./skills/*": "./skills/*",
|
|
13
|
+
"./package.json": "./package.json"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"index.js",
|
|
17
|
+
"cordis.patch.yml",
|
|
18
|
+
"icon.svg",
|
|
19
|
+
"locale/*.json",
|
|
20
|
+
"README.md",
|
|
21
|
+
"skills/**/*",
|
|
22
|
+
"!skills/**/__pycache__",
|
|
23
|
+
"!skills/**/__pycache__/**",
|
|
24
|
+
"!skills/**/*.pyc"
|
|
25
|
+
],
|
|
26
|
+
"keywords": [
|
|
27
|
+
"dsh-bundle",
|
|
28
|
+
"dsh-skill",
|
|
29
|
+
"project-docs",
|
|
30
|
+
"documentation",
|
|
31
|
+
"sync"
|
|
32
|
+
],
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"author": "walvka-code",
|
|
35
|
+
"homepage": "https://github.com/walvka-code/proj-doc-builder#readme",
|
|
36
|
+
"repository": {
|
|
37
|
+
"type": "git",
|
|
38
|
+
"url": "git+https://github.com/walvka-code/proj-doc-builder.git"
|
|
39
|
+
},
|
|
40
|
+
"bugs": {
|
|
41
|
+
"url": "https://github.com/walvka-code/proj-doc-builder/issues"
|
|
42
|
+
},
|
|
43
|
+
"publishConfig": {
|
|
44
|
+
"access": "public"
|
|
45
|
+
},
|
|
46
|
+
"engines": {
|
|
47
|
+
"node": ">=20",
|
|
48
|
+
"dsh": ">=0.2.1-rc.5"
|
|
49
|
+
},
|
|
50
|
+
"dsh": {
|
|
51
|
+
"bundle": {
|
|
52
|
+
"patch": "./cordis.patch.yml"
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"scripts": {
|
|
56
|
+
"check": "node scripts/check-bundle.mjs",
|
|
57
|
+
"check:counts": "node scripts/sync-test-counts.mjs",
|
|
58
|
+
"test": "node --test",
|
|
59
|
+
"release": "node scripts/release.mjs"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,412 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: proj-doc-builder
|
|
3
|
+
description: >
|
|
4
|
+
Safely scan, validate, and synchronize AI-readable project documentation,
|
|
5
|
+
manifest v2, the CLAUDE document-tree index, and committed scan state. Use
|
|
6
|
+
when the user asks to sync, refresh, generate, or validate project docs.
|
|
7
|
+
也是「文档同步手册」:`project_docs/` 的定位(索引而非权威)、权威顺序、
|
|
8
|
+
以及「发现漂移要登记而不是粉饰」的纪律。
|
|
9
|
+
Triggers: "同步文档", "project_docs", "文档树", "CLAUDE.md", "generate docs",
|
|
10
|
+
"sync docs", "validate docs", "文档漂移", "权威顺序", "索引不是权威"
|
|
11
|
+
version: "4.5.2"
|
|
12
|
+
disable-model-invocation: false
|
|
13
|
+
user-invocable: true
|
|
14
|
+
allowed-tools:
|
|
15
|
+
- Bash
|
|
16
|
+
- Read
|
|
17
|
+
- Write
|
|
18
|
+
- Glob
|
|
19
|
+
- Grep
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
# proj_doc_builder v4.5 — 分阶段生成与确定性发布
|
|
23
|
+
|
|
24
|
+
> **路径约定(必读)**:下文 `<skill-dir>` 指本 `SKILL.md` 所在目录的**绝对路径**——
|
|
25
|
+
> 技能加载结果里的 `Base directory for this skill` 就是它。所有命令都在**项目根**执行,
|
|
26
|
+
> 因此脚本一律写成 `<skill-dir>/tools/<子包>/<脚本>.py`(v4.5 起按职责分 `core/` `scan/` `validate/` `pipeline/` `reader/`;`phase4_exit.py` 仍在 `tools/` 根);
|
|
27
|
+
> 路径含空格时必须保留示例中的双引号。
|
|
28
|
+
> 技能以 DSH bundle 安装时 `<skill-dir>` 在 profile 的包目录内,以项目技能安装时它是
|
|
29
|
+
> `<项目根>/.dsh/skills/` 下的同名目录——两种布局下本文命令都成立。
|
|
30
|
+
|
|
31
|
+
> **工具目录分层**:`tools/` 按职责分为 `core/`(契约、配置、链接计算、CLAUDE 索引)、
|
|
32
|
+
> `scan/`(目录扫描、链接检查、marker 归一)、`validate/`(文档质量校验)、`pipeline/`
|
|
33
|
+
> (同步协调器与脚手架生成器)、`reader/`(加载器)和 `phase4/`(阶段四审计实现,
|
|
34
|
+
> CLI 入口仍在 `tools/phase4_exit.py`)。各子包保持平级 `import`,由 `tools/_paths.py`
|
|
35
|
+
> 在脚本启动时把子包目录加入 `sys.path`;新增脚本须照抄同样的引导块。
|
|
36
|
+
|
|
37
|
+
本 skill 分为两类工作:
|
|
38
|
+
|
|
39
|
+
1. **模型生成/更新文档正文**:只处理 scanner 选出的新增或变化源码目录。
|
|
40
|
+
2. **工具确定性收尾**:`sync_project_docs.py` 负责 staging、严格校验、manifest v2、CLAUDE 文档树、Phase 4 报告和 scan state 发布。
|
|
41
|
+
|
|
42
|
+
协调器不生成自然语言正文。不得跳过文档更新而直接提交 scan baseline。
|
|
43
|
+
|
|
44
|
+
## 强制安全约束
|
|
45
|
+
|
|
46
|
+
- 默认先 dry-run;只有所有闸门通过后才运行 coordinator `--apply`。
|
|
47
|
+
- Phase 4 默认只报告。不得自动删除文档,不得自动添加 archive 标注,不得把旧 `--auto-approve` 当作授权。
|
|
48
|
+
- quarantine 是独立的显式动作;一次普通 `/proj-doc-builder` 不自动执行它。
|
|
49
|
+
- pending Phase 4 journal 必须先通过显式 `--recover` 处理;report、apply、restore 和 coordinator 都不得绕过恢复闸门。
|
|
50
|
+
- 活动 Markdown 集合只排除根级 `project_docs/.quarantine(运行时生成,可能不存在)/`;`.lingma/` 和嵌套同名目录仍属于活动树。
|
|
51
|
+
- 所有文本严格 UTF-8;Python 文件首行必须是 `# -*- coding: utf-8 -*-`。
|
|
52
|
+
- manifest path 仅允许相对 POSIX 小写 `.md` 路径;禁止绝对路径、反斜杠、`..`、ADS、保留设备名和大小写冲突。
|
|
53
|
+
- 不跟随 symlink、junction 或 reparse point;路径身份不能证明时 fail closed。
|
|
54
|
+
- 不自动批量重写未变化历史文档的自然语言内容。
|
|
55
|
+
- 根 `CLAUDE.md` 只更新 `doc-tree-instruction` 自动区块;其余架构、命令、测试等复杂区块只校验 marker,不自动改写。
|
|
56
|
+
- 不执行版本控制提交(`svn commit` / `git commit`),也不创建版本控制元数据目录(如 `.git`)。
|
|
57
|
+
|
|
58
|
+
## 工具职责
|
|
59
|
+
|
|
60
|
+
| 工具 | 职责 |
|
|
61
|
+
|---|---|
|
|
62
|
+
| `<skill-dir>/tools/core/proj_doc_config.py` | 统一加载项目根目录可选 `.projdoc.toml`(扫描排除规则、CLAUDE 索引预算/折叠、发布历史保留上限、校验词表与已知失败白名单、`strict_config`) |
|
|
63
|
+
| `<skill-dir>/tools/core/project_docs_contract.py` | 路径、UTF-8、严格 JSON、链接、manifest(含 `doc_contract_version` / `--migrate-manifest`)、锁和原子写的唯一契约 |
|
|
64
|
+
| `<skill-dir>/tools/scan/scan_dirs.py` | 内容哈希目录快照;生成 candidate,不提前推进 committed baseline |
|
|
65
|
+
| `<skill-dir>/tools/core/compute_link.py` | 计算或验证单个/批量相对文档链接 |
|
|
66
|
+
| `<skill-dir>/tools/validate/validate_doc.py` | standard / placeholder profile 文档质量检查与全量并行文件清单审计(`--audit-inventory`),只报告不修改 |
|
|
67
|
+
| `<skill-dir>/tools/scan/link_check.py` | 全库只读链接检查;**不生成 manifest** |
|
|
68
|
+
| `<skill-dir>/tools/scan/normalize_markers.py` | 仅规范化可精确识别的历史损坏 marker |
|
|
69
|
+
| `<skill-dir>/tools/core/claude_doc_index.py` | 只从候选 manifest 生成 `doc-tree-instruction` |
|
|
70
|
+
| `<skill-dir>/tools/phase4_exit.py` | fail-closed 报告、显式 quarantine、receipt restore 和持久 journal recovery;不删除活动文档 |
|
|
71
|
+
| `<skill-dir>/tools/pipeline/sync_project_docs.py` | staging、闸门、统一根锁、发布、自动备份回滚(`--restore`)、单文档重生成(`--regenerate`)与排除建议(`--suggest-excludes`)的唯一协调器 |
|
|
72
|
+
| `<skill-dir>/tools/pipeline/gen_docs_from_scaffold.py` | 消费 `--scaffold-dump` JSON 的内置参考批量生成器,打通 `init → scaffold-dump → gen → apply` 四步流程 |
|
|
73
|
+
| `<skill-dir>/tools/reader/load_docs.py` | 加载器(只读):先校验 manifest 与文档完全一致,再输出工程速览(`--mode brief`,摘要+每份文档一句话角色)、工程概览或单份文档/单节——给新对话一个入口 |
|
|
74
|
+
|
|
75
|
+
详细规则见 `references/`。
|
|
76
|
+
|
|
77
|
+
## Phase 0:环境与输入预检
|
|
78
|
+
|
|
79
|
+
在项目根执行 Python 工具,并先强制 UTF-8:
|
|
80
|
+
|
|
81
|
+
```powershell
|
|
82
|
+
$env:PYTHONIOENCODING='utf-8'
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
若项目尚未初始化(缺少 `project_docs/` 或 `.projdoc.toml`),可先运行一键初始化:
|
|
86
|
+
|
|
87
|
+
```powershell
|
|
88
|
+
python "<skill-dir>/tools/pipeline/sync_project_docs.py" . --init
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
`--init` 会自动创建 `project_docs/`(若不存在),基于启发式规则(产物/报告目录名、单目录 >100 文件、高占比数据文件且无源码)生成带注释建议的 `.projdoc.toml` 骨架,并生成根 `CLAUDE.md` 六大区块骨架(仅当文件不存在;已有文件原样保留)。执行完 `--init` 即可直接进入 Phase 1 dry-run。
|
|
92
|
+
|
|
93
|
+
确认:
|
|
94
|
+
|
|
95
|
+
- `project_docs/` 是项目根下的真实目录;
|
|
96
|
+
- 根 `CLAUDE.md` 是真实普通文件,且含 `doc-tree-instruction`、`project-overview`、`common-commands`、`architecture`、`test-structure`、`dependencies` 六对 `<!-- AUTO-GENERATED v3.0: <section> START/END -->` marker(`--init` 生成的骨架已满足该契约,只自动改写 `doc-tree-instruction` 一节);
|
|
97
|
+
- 没有正在进行的其他 sync/quarantine/restore,也没有待恢复的固定 `prepared`/`ready` Phase 4 journal、legacy journal、publication temp、detached artifact 或 coordinator publish journal;
|
|
98
|
+
- 不读取或执行项目自有的计划/反馈目录(若存在);文档读取方在运行时严格只读,不回写业务文件。
|
|
99
|
+
|
|
100
|
+
## Phase 1:首次 coordinator dry-run
|
|
101
|
+
|
|
102
|
+
```powershell
|
|
103
|
+
# 紧凑概览视图(适合首次大仓库快速判断排除项与校验分布)
|
|
104
|
+
python "<skill-dir>/tools/pipeline/sync_project_docs.py" . --dry-run --summary
|
|
105
|
+
# 完整 JSON(需要完整 worklist/scaffold 时;也可配合 --scaffold-dump <file.json> 导出)
|
|
106
|
+
python "<skill-dir>/tools/pipeline/sync_project_docs.py" . --dry-run --json
|
|
107
|
+
# 预览计划变更的 unified diff 摘要
|
|
108
|
+
python "<skill-dir>/tools/pipeline/sync_project_docs.py" . --dry-run --diff --summary
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
退出码:
|
|
112
|
+
|
|
113
|
+
| 退出码 | 含义 |
|
|
114
|
+
|---:|---|
|
|
115
|
+
| 0 | 所有闸门通过,可发布或已无变化 |
|
|
116
|
+
| 1 | 文档质量、链接或 Phase 4 闸门失败 |
|
|
117
|
+
| 2 | 输入、schema、路径、UTF-8、锁或运行错误 |
|
|
118
|
+
| 3 | 发布失败;查看 `publish` 的 commit/rollback 状态 |
|
|
119
|
+
|
|
120
|
+
从 JSON 读取:
|
|
121
|
+
|
|
122
|
+
- `first_run` / `first_run_notice`:首轮(`baseline.schema_version != 2`)无 strict 阻断,需配合 `--full` 与 `validate_doc.py --audit-inventory . --json` 自行确保全量质量;
|
|
123
|
+
- `scan.changes`:`new/modified/deleted/unchanged/unknown`(若 `scan.scanner_version_changed == true`,旧基线升级不触发全量 strict 重写,改为 `needs_audit` 轻量核验);
|
|
124
|
+
- `scan.worklist.directories`:本轮需生成或复核的源码目录;
|
|
125
|
+
- `scan.worklist.scaffold`:包含校验器同口径的 `recommended_profile`、`profile_basis`、`inventory_files`、`inventory_subdirs`、`is_boundary` 与 `precomputed_links`(大仓库批量生成见 `references/batch-generation.md`);
|
|
126
|
+
- 配合 `--scaffold-dump` 时每条 `direct_files[]` 还带 `facts`(`kind` / `lines` / `symbols` / `keys` / `headings` / `first_line`),生成器据此写"关键内容"而不必猜文件名;普通 dry-run 报告里不含 `facts`,避免撑大输出;
|
|
127
|
+
- `scan.candidate_generation_id`:candidate 绑定;
|
|
128
|
+
- `validation.by_check`:按检查项 1–12 聚合的失败计数(10/11/12 为 v4.5 新增的 advisory 检查);
|
|
129
|
+
- `validation.blocking_failures`:变化文档的阻断错误;
|
|
130
|
+
- `validation.audit_failures`:未变化历史文档的非阻断审计;
|
|
131
|
+
- `validation.known_issues`:命中 `.projdoc.toml` 中 `[[validation.expected_failures]]` 的已知例外;
|
|
132
|
+
- `links.broken`;
|
|
133
|
+
- `phase4` 分类;
|
|
134
|
+
- `planned_writes`。
|
|
135
|
+
|
|
136
|
+
scanner 使用直接普通文件 SHA-256;相同 size/mtime 的内容变化也会进入 `modified`。boundary 后代和其他 unknown scope 不得被当成删除依据。
|
|
137
|
+
|
|
138
|
+
**指纹与增量语义(v4.3)**:
|
|
139
|
+
|
|
140
|
+
- 目录指纹只覆盖**内容**(文件名 + 大小 + SHA-256 + 子目录名 + 边界标志 + 跳过项),**不含 mtime/path**。仅触碰时间戳(`touch`、编辑器重存、`svn update` 改时间)不会产生 `modified`。
|
|
141
|
+
- `scan.changes` 旁边提供 `change_attribution`:逐目录给出 `added` / `removed` / `modified` 的**具体文件名**,可直接回答"这个目录到底改了什么",无需再逐文件比对。
|
|
142
|
+
- 扫描需要连续两遍结果一致;不稳定时错误消息附带 `drifting: <目录级 diff>`,直接指出是哪几个目录在两遍之间变化(活跃开发时常见)。
|
|
143
|
+
- 大仓库可开 `[scan] use_mtime_cache = true`:复用上次 committed state 里同一 `(size, mtime)` 的 SHA-256,638 目录扫描 17s → 5s。**代价**:无法侦测「大小与 mtime 完全相同、仅内容被替换」的修改(默认关闭,因为它牺牲的正是这条保证)。
|
|
144
|
+
|
|
145
|
+
**校验范围(v4.3)**:
|
|
146
|
+
|
|
147
|
+
- `--apply` 成功发布后会在 `project_docs/.quarantine/backup-<generation>/` 留一份自动备份,按 `[publish] max_history_entries`(默认 10)自动清理最旧的;`--restore [GENERATION_ID]` 可整体回退。
|
|
148
|
+
- 增量运行默认只重新校验**本轮变更目录**对应的文档(`validation.scope = "changed-directories"`,`unchecked_count` 给出跳过数):未变目录的文档在上次变更时已校验过。
|
|
149
|
+
- `--full` 强制校验全部文档(`scope = "all-documents"`),并要求全量文件清单审计,是发布前的终审档位。
|
|
150
|
+
已提交基线存在时,`--full` 对**全部**文档启用 critical 严格阻断(advisory 检查 10/11/12 与概述句数仍只告警);
|
|
151
|
+
这是终审与增量 dry-run 的唯一区别——增量只对变更目录 strict,未变更文档仅做 advisory 审计。
|
|
152
|
+
- 环境在两次运行之间被其他进程改写(并行开发、CI)时,用 `--full`,不要依赖增量结论。
|
|
153
|
+
- 克隆、移动或重命名项目目录后,已提交的 `project_docs/_scan_state.json` 仍绑定旧绝对路径根,
|
|
154
|
+
dry-run 会报 `committed scan state belongs to a different project root`;
|
|
155
|
+
用 `--full --apply` 重新绑定到新根(本条不丢历史,只重建基线),或删除该文件按首轮处理。
|
|
156
|
+
|
|
157
|
+
**锁域留存与 `--prune-locks`(v4.4)**:
|
|
158
|
+
|
|
159
|
+
- 锁目录 `%TEMP%/proj-doc-builder-locks/` 在大项目长期使用后会堆积数千个 `<digest>.lock`、`.publish-history-*`、`.publish-transaction.json`,使列目录变慢、浪费 temp 空间。
|
|
160
|
+
- `--prune-locks` 清理它:`.lock` 文件先探测是否被进程持有(持有则保留并计入 `in_use`),未持有且超过 `stale_lock_hours`(默认 1h)才删;`.publish-history-*` 按 digest 分组只保留最新 `history_keep` 个(默认 20);`journal` 与 `artifacts` 超过 `max_age_hours`(默认 168h)才删,给 `--recover` 留窗口。
|
|
161
|
+
- `--apply` 成功后会自动跑一次清理(仅 housekeeping,失败只加 `warning`,绝不阻断发布)。也可单独运行 `--prune-locks --dry-run` 预览。
|
|
162
|
+
|
|
163
|
+
## Phase 2:生成或更新变化文档
|
|
164
|
+
|
|
165
|
+
只处理 `scan.worklist.directories` 中的 `new` / `modified` 目录。优先参考 `scan.worklist.scaffold` 中预计算的 `recommended_profile` 与 `precomputed_links`(包含 parent/children/tests 的相对链接),降低多轮外部工具调用。目录到文档的映射为:
|
|
166
|
+
|
|
167
|
+
```text
|
|
168
|
+
源码目录: <root>/a/b/
|
|
169
|
+
文档路径: <root>/project_docs/a/b.md
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### 2.1 读取与分析
|
|
173
|
+
|
|
174
|
+
- 读取真实直接文件和直接子目录;
|
|
175
|
+
- 提取实际类、函数、常量和依赖;
|
|
176
|
+
- boundary 目录只写本层概要,不递归其后代;
|
|
177
|
+
- 二进制文件只记录文件名、类型和用途,不伪造符号。
|
|
178
|
+
|
|
179
|
+
### 2.2 选择 profile
|
|
180
|
+
|
|
181
|
+
- **standard**:有实质源码、标准材料或有效子模块;概述 **8–10 个实质句子**(v4.5 起,低于 8 句判 advisory 失败),文件/子目录清单必须与磁盘一致,并包含 `## 数据与状态`、`## 性能与资源特征`、`## 变更与迁移注意` 三节(v4.5 新增;确无内容时写 `本节不适用:<≥6 字理由>`)。
|
|
182
|
+
- **placeholder**:空目录或只有无实质内容的初始化文件;允许 1–2 句概述,不要求虚构符号、依赖或长篇系统角色,三节新内容也不要求。
|
|
183
|
+
|
|
184
|
+
概述要覆盖六个角度:定位、输入、核心处理、输出、边界、失败模式,并至少点名 4 个具体实体(文件、符号、配置键或上下游模块)。模板见 `references/templates.md`,校验规则见 `references/checklist.md`。
|
|
185
|
+
|
|
186
|
+
### 2.3 链接
|
|
187
|
+
|
|
188
|
+
不得手工计算 `../`:
|
|
189
|
+
|
|
190
|
+
```powershell
|
|
191
|
+
python "<skill-dir>/tools/core/compute_link.py" `
|
|
192
|
+
--project-docs project_docs `
|
|
193
|
+
--from <当前文档相对路径> `
|
|
194
|
+
--to <目标文档相对路径>
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
共享 resolver 支持 inline、reference-style、HTML anchor、fragment、query、extensionless `.md` 和严格 URL decode。详情见 `references/linking.md`。
|
|
198
|
+
|
|
199
|
+
### 2.4 单文档校验
|
|
200
|
+
|
|
201
|
+
```powershell
|
|
202
|
+
python "<skill-dir>/tools/validate/validate_doc.py" `
|
|
203
|
+
<doc.md> --source-dir <source_dir> --strict --json
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
本轮变化文档的任何 FAIL 必须修复。未变化历史文档只审计和报告,不为通过校验而机械改写。
|
|
207
|
+
|
|
208
|
+
### 2.5 删除和 unknown
|
|
209
|
+
|
|
210
|
+
- `deleted` 只进入 Phase 4 分析;不得直接删除对应文档。
|
|
211
|
+
- `unknown`、boundary 后代和不可信路径不得生成"源码已消失"结论。
|
|
212
|
+
- 未注册文档、manifest 缺失项或大小写漂移必须由 coordinator/contract 精确报告。
|
|
213
|
+
|
|
214
|
+
### 2.6 全量文件清单审计(`--full` 模式强制步骤)
|
|
215
|
+
|
|
216
|
+
> **教训**:扫描器标记 `unchanged` 只意味着目录指纹(文件集合哈希)未变,**不代表文档内容与磁盘一致**。源码在两次同步之间新增文件后,基线指纹已包含新文件,增量扫描判 unchanged → 文档永远不会被触发重写 → 文件清单永久漏失。
|
|
217
|
+
|
|
218
|
+
在 `--full` 模式下,**不论扫描器分类如何**,必须对全部已有文档运行内置的并行文件清单审计:
|
|
219
|
+
|
|
220
|
+
```powershell
|
|
221
|
+
python "<skill-dir>/tools/validate/validate_doc.py" --audit-inventory . --json
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
审计覆盖全部活动 `project_docs/*.md`(自动排除 `_*`、`index.md`、`.quarantine/` 及 `.projdoc.toml` 排除目录):
|
|
225
|
+
|
|
226
|
+
1. 对比文档 `## 文件清单` 表格与对应源码目录的磁盘直接文件集合:
|
|
227
|
+
- 磁盘有但文档缺 = **漏文件** (`missing`)
|
|
228
|
+
- 文档有但磁盘无 = **幽灵条目** (`extra`)
|
|
229
|
+
2. 漏文件:按 2.1-2.4 流程提取关键信息并补入表格
|
|
230
|
+
3. 幽灵条目:从表格删除该行;如果源码目录已空且文档之前是 standard,降级为 placeholder
|
|
231
|
+
4. 同时检查概述中的文件计数是否与实际一致
|
|
232
|
+
|
|
233
|
+
实现细节见 `references/audit_script.md`。
|
|
234
|
+
|
|
235
|
+
## Phase 3:全局 dry-run 闭环
|
|
236
|
+
|
|
237
|
+
更新正文后反复运行:
|
|
238
|
+
|
|
239
|
+
```powershell
|
|
240
|
+
python "<skill-dir>/tools/pipeline/sync_project_docs.py" . --dry-run --json
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
必须同时满足:
|
|
244
|
+
|
|
245
|
+
- `ok == true`;
|
|
246
|
+
- 变化文档 strict 校验 0 阻断;
|
|
247
|
+
- `links.broken_count == 0`;
|
|
248
|
+
- manifest v2 candidate 覆盖完整活动 Markdown 集合;
|
|
249
|
+
- CLAUDE 六组 marker 唯一、成对、不交叠;
|
|
250
|
+
- Phase 4 无安全错误;存在 quarantine candidate 时发布照常进行但 scan baseline 冻结(见 Phase 4);
|
|
251
|
+
- source snapshot 在 staging 与发布前复核中保持一致;
|
|
252
|
+
- **`--full` 模式额外要求**:全部活动文档的文件清单与磁盘逐项核对一致(Phase 2.6 `validate_doc.py --audit-inventory . --json` 审计结果为 0 漏文件 / 0 幽灵条目)。
|
|
253
|
+
|
|
254
|
+
`link_check.py` 仅做只读链接校验:
|
|
255
|
+
|
|
256
|
+
```powershell
|
|
257
|
+
python "<skill-dir>/tools/scan/link_check.py" --project-docs project_docs --json
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
不得把它描述为 manifest 生成器。
|
|
261
|
+
|
|
262
|
+
## Phase 4:report-first 退出机制
|
|
263
|
+
|
|
264
|
+
普通同步只读取 coordinator 内嵌的 Phase 4 report。也可独立运行:
|
|
265
|
+
|
|
266
|
+
```powershell
|
|
267
|
+
python "<skill-dir>/tools/phase4_exit.py" . --json
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
只有同时满足以下条件才可成为 quarantine candidate:
|
|
271
|
+
|
|
272
|
+
- 已在受验证 manifest 注册;
|
|
273
|
+
- 含精确 AUTO marker;
|
|
274
|
+
- 对应源码目录确认不存在;
|
|
275
|
+
- 使用共享 resolver 统计为零入站引用;
|
|
276
|
+
- 不位于 boundary/unknown scope;
|
|
277
|
+
- 路径、UTF-8、hash 和 generation 均可信。
|
|
278
|
+
|
|
279
|
+
“概述短”“内容为空”或“占位”不是处置理由。有引用的历史文档仅报告,工具不自动 archive。
|
|
280
|
+
|
|
281
|
+
若 report 存在 candidate,普通 sync 可继续发布文档、marker 修复、CLAUDE 文档树和 manifest,但不推进 scan baseline(警告 `scan-baseline-frozen`)。这一设计使解除入站引用的文档编辑得以发布,避免 coordinator 闸门与 Phase 4 manifest 一致性校验相互死锁。只有用户另行明确要求 quarantine 时才运行:
|
|
282
|
+
|
|
283
|
+
```powershell
|
|
284
|
+
python "<skill-dir>/tools/phase4_exit.py" . --apply --json
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
恢复 receipt:
|
|
288
|
+
|
|
289
|
+
```powershell
|
|
290
|
+
python "<skill-dir>/tools/phase4_exit.py" . --restore <RECEIPT_ID> --json
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
quarantine/restore 在第一次内容变更前排他发布不可变的 `.phase4-transaction.json` prepared journal;后镜像准备完成后再以 no-replace 方式发布不可变的 `.phase4-transaction-ready.json` companion,绝不原地覆盖 prepared。manifest 通过 before/after anchor 执行 no-replace CAS,是唯一 commit point。restore 使用独立 transaction anchor 发布目标,原 quarantine payload 不与目标共享 inode。若进程被强制终止,或 journal/artifact 清理失败,所有普通动作和 coordinator 都会返回 `phase4-recovery-required`。此时必须先运行:
|
|
294
|
+
|
|
295
|
+
```powershell
|
|
296
|
+
python "<skill-dir>/tools/phase4_exit.py" . --recover --json
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
恢复只接受 journal 记录的精确 before/after 状态:manifest、活动文档、target/source、receipt、payload 或 CLAUDE 出现人工/并发变化时保留现场并 fail closed。无 pending journal 的 `--recover` 是成功 no-op。
|
|
300
|
+
|
|
301
|
+
详情见 `references/phase4.md`。
|
|
302
|
+
|
|
303
|
+
## Phase 5:确定性发布
|
|
304
|
+
|
|
305
|
+
所有闸门通过后:
|
|
306
|
+
|
|
307
|
+
```powershell
|
|
308
|
+
python "<skill-dir>/tools/pipeline/sync_project_docs.py" . --apply --json
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
固定事务语义:
|
|
312
|
+
|
|
313
|
+
1. coordinator 在 staging 前、staging 后和发布锁内检查 pending Phase 4 journal;存在或无法验证时不推进任何基线。
|
|
314
|
+
2. 所有候选先在系统临时目录中完成校验;dry-run 不在项目树创建 staging、缓存或其他路径。
|
|
315
|
+
3. 发布时获取项目统一根锁并重新核对文档、CLAUDE、manifest、scan state 和源码 snapshot。
|
|
316
|
+
4. 在系统临时目录的项目锁域旁排他发布持久 coordinator publish journal;该 journal 不污染版本控制工作副本。
|
|
317
|
+
5. 先发布精确 marker 修复和 CLAUDE 文档树。
|
|
318
|
+
6. manifest 最后作为文档代际 commit point。
|
|
319
|
+
7. scan state 最后提交;失败时依据 manifest/scan/artifact 的实际安装状态报告 `NOT_INSTALLED`、`UNKNOWN` 或 `PARTIALLY_INSTALLED`,不虚构已提交状态。
|
|
320
|
+
8. manifest 前失败只回滚本事务仍拥有的候选内容;检测到并发修改时不覆盖并报告 rollback conflict。
|
|
321
|
+
|
|
322
|
+
若返回 `coordinator-recovery-required`,必须运行协调器自己的恢复入口:
|
|
323
|
+
|
|
324
|
+
```powershell
|
|
325
|
+
python "<skill-dir>/tools/pipeline/sync_project_docs.py" . --recover --json
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
它与 `phase4_exit.py --recover` 是两个独立状态机:前者恢复普通 sync 发布,后者恢复 quarantine/restore。无 pending coordinator journal 时,`--recover` 是成功 no-op。
|
|
329
|
+
|
|
330
|
+
manifest schema v2 包含 `generation_id`、producer、docs root、total、depth counts、last synced,以及每份文档的 path/depth/title/status/bytes/SHA-256/synced_at(及可选 `doc_contract_version`/`generator`)。v1 仅内存兼容;未知 schema 直接拒绝。跨版本升级时可用只读命令检查契约版本落后文档或原地迁移 manifest 元数据:
|
|
331
|
+
|
|
332
|
+
```powershell
|
|
333
|
+
python "<skill-dir>/tools/pipeline/sync_project_docs.py" . --upgrade-plan --json
|
|
334
|
+
python "<skill-dir>/tools/pipeline/sync_project_docs.py" . --migrate-manifest --json
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
## Phase 6:终验与幂等
|
|
338
|
+
|
|
339
|
+
发布后再次运行同一 dry-run:
|
|
340
|
+
|
|
341
|
+
```powershell
|
|
342
|
+
python "<skill-dir>/tools/pipeline/sync_project_docs.py" . --dry-run --json
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
预期:
|
|
346
|
+
|
|
347
|
+
- `planned_writes == []`;
|
|
348
|
+
- manifest `changed == false`;
|
|
349
|
+
- scan `commit_needed == false`;
|
|
350
|
+
- 0 断链;
|
|
351
|
+
- 无未解释的缺失、未注册、候选或 unknown 错误;
|
|
352
|
+
- **`--full` 模式额外要求**:重新运行 `python "<skill-dir>/tools/validate/validate_doc.py" --audit-inventory . --json`,确认全部活动文档与磁盘一致。
|
|
353
|
+
|
|
354
|
+
零变化运行不得刷新 `last_synced`、manifest、CLAUDE 或 scan state。
|
|
355
|
+
|
|
356
|
+
最后只读执行版本控制范围检查;不提交(Git 与 SVN 各有等价命令):
|
|
357
|
+
|
|
358
|
+
```powershell
|
|
359
|
+
git status
|
|
360
|
+
git diff
|
|
361
|
+
# SVN 仓库:svn status / svn diff
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
确认没有个人绝对路径、版本控制元数据文件、非预期自然语言重写或 quarantine 动作。
|
|
365
|
+
|
|
366
|
+
## 完成报告
|
|
367
|
+
|
|
368
|
+
报告至少包含:
|
|
369
|
+
|
|
370
|
+
- scanner 分类和处理目录数;
|
|
371
|
+
- 新建/更新文档路径;
|
|
372
|
+
- **文件清单审计结果**:审计的文档总数、漏文件修复数、幽灵条目清除数、空目录文档降级数;
|
|
373
|
+
- strict 与历史审计结果;
|
|
374
|
+
- marker 精确修复数;
|
|
375
|
+
- manifest schema/generation/total/depth counts;
|
|
376
|
+
- CLAUDE 文档树是否变化;
|
|
377
|
+
- 链接数量与断链数;
|
|
378
|
+
- Phase 4 candidates/blocked/missing/unregistered,以及 pending/recovered journal 状态;
|
|
379
|
+
- publish commit point、scan state 和 rollback/partial 状态;
|
|
380
|
+
- 第二次 dry-run 是否完全无变化;
|
|
381
|
+
- 版本控制 status/diff 范围;
|
|
382
|
+
- 明确说明未执行版本控制提交、未自动删除或 quarantine 文档。
|
|
383
|
+
|
|
384
|
+
## 文档定位与漂移纪律
|
|
385
|
+
|
|
386
|
+
## 定位
|
|
387
|
+
`project_docs/` 是**自动生成的目录镜像索引**,由本技能生成与校验
|
|
388
|
+
(工具在本技能自带的 `tools/` 子目录里,**不在项目根的 `tools/`**)。
|
|
389
|
+
|
|
390
|
+
## 权威顺序(冲突时按此采信)
|
|
391
|
+
1. **实测运行输出**(报告 / 日志 / 器件回读)
|
|
392
|
+
2. **标准原文**(你的标准与规范文档目录)
|
|
393
|
+
3. **源码**(被测代码本体)
|
|
394
|
+
4. **配置数据**(运行时配置、环境参数、设备描述)
|
|
395
|
+
5. `project_docs/`(索引)
|
|
396
|
+
6. `CLAUDE.md`(总览,可能滞后)
|
|
397
|
+
7. 技能文档(方法论,不替代 1–4)
|
|
398
|
+
|
|
399
|
+
## 漂移纪律
|
|
400
|
+
* 发现文档与实测不符:**先取证,再改文档,并在台账留痕**
|
|
401
|
+
* 不要"顺手改文档让它看起来对";不要把历史计划文档改写成事后正确
|
|
402
|
+
* 已知漂移应显式列出(例如:标称值 vs 实测标定值、目录迁移后的旧路径)
|
|
403
|
+
|
|
404
|
+
## 何时不要动文档
|
|
405
|
+
* 正在跑测试批次(改动会污染归档)
|
|
406
|
+
* 结论尚无法复现(先补证据)
|
|
407
|
+
|
|
408
|
+
## 收尾自检
|
|
409
|
+
```bash
|
|
410
|
+
python -m pytest "<skill-dir>/tests" -q # 本技能自带的用例(Windows 上部分用例按平台跳过)
|
|
411
|
+
```
|
|
412
|
+
若自检出现单个测试失败,先排查是否为重构后测试用例的 monkeypatch 替身签名陈旧(例如 `_file_snapshot` 参数变更),并在本版本周期内同步修复。
|