repowiki-cli 0.6.0__tar.gz → 0.7.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. repowiki_cli-0.7.0/PKG-INFO +209 -0
  2. repowiki_cli-0.7.0/README.md +179 -0
  3. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/pyproject.toml +1 -1
  4. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki/coverage.py +51 -2
  5. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki/dispatch.py +4 -2
  6. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki/i18n.py +2 -0
  7. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki/skills/repowiki/SKILL.en.md +5 -3
  8. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki/skills/repowiki/SKILL.md +2 -2
  9. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki/templates/en/STYLE.md +1 -1
  10. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki/templates/en/page_task.md +1 -1
  11. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki/templates/en/update_task.md +1 -1
  12. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki/templates/zh/STYLE.md +1 -1
  13. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki/templates/zh/page_task.md +1 -1
  14. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki/templates/zh/update_task.md +1 -1
  15. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki/validate.py +78 -17
  16. repowiki_cli-0.7.0/src/repowiki_cli.egg-info/PKG-INFO +209 -0
  17. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/tests/test_coverage.py +25 -0
  18. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/tests/test_i18n.py +3 -0
  19. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/tests/test_validate.py +50 -0
  20. repowiki_cli-0.6.0/PKG-INFO +0 -354
  21. repowiki_cli-0.6.0/README.md +0 -324
  22. repowiki_cli-0.6.0/src/repowiki_cli.egg-info/PKG-INFO +0 -354
  23. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/LICENSE +0 -0
  24. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/setup.cfg +0 -0
  25. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki/__init__.py +0 -0
  26. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki/catalog.py +0 -0
  27. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki/cli.py +0 -0
  28. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki/errors.py +0 -0
  29. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki/gitutil.py +0 -0
  30. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki/knowledge.py +0 -0
  31. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki/llms.py +0 -0
  32. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki/metadata.py +0 -0
  33. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki/output.py +0 -0
  34. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki/paths.py +0 -0
  35. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki/plan.py +0 -0
  36. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki/scanner.py +0 -0
  37. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki/site.py +0 -0
  38. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki/skill_install.py +0 -0
  39. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki/state.py +0 -0
  40. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki/tasks.py +0 -0
  41. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki/templates/en/catalog_task.md +0 -0
  42. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki/templates/en/flow_template.md +6 -6
  43. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki/templates/en/knowledge_card_task.md +0 -0
  44. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki/templates/en/knowledge_card_update_task.md +0 -0
  45. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki/templates/en/knowledge_module_task.md +0 -0
  46. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki/templates/en/knowledge_module_update_task.md +0 -0
  47. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki/templates/en/knowledge_task.md +0 -0
  48. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki/templates/en/overview_task.md +0 -0
  49. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki/templates/en/overview_update_task.md +0 -0
  50. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki/templates/en/page_template.md +6 -6
  51. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki/templates/site/app.js +0 -0
  52. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki/templates/site.html +0 -0
  53. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki/templates/zh/catalog_task.md +0 -0
  54. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki/templates/zh/flow_template.md +6 -6
  55. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki/templates/zh/knowledge_card_task.md +0 -0
  56. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki/templates/zh/knowledge_card_update_task.md +0 -0
  57. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki/templates/zh/knowledge_module_task.md +0 -0
  58. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki/templates/zh/knowledge_module_update_task.md +0 -0
  59. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki/templates/zh/knowledge_task.md +0 -0
  60. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki/templates/zh/overview_task.md +0 -0
  61. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki/templates/zh/overview_update_task.md +0 -0
  62. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki/templates/zh/page_template.md +6 -6
  63. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki/templates.py +0 -0
  64. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki/updater.py +0 -0
  65. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki/vendor/marked.min.js +0 -0
  66. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki/vendor/mermaid.min.js +0 -0
  67. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki_cli.egg-info/SOURCES.txt +0 -0
  68. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki_cli.egg-info/dependency_links.txt +0 -0
  69. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki_cli.egg-info/entry_points.txt +0 -0
  70. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki_cli.egg-info/requires.txt +0 -0
  71. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/src/repowiki_cli.egg-info/top_level.txt +0 -0
  72. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/tests/test_flow.py +0 -0
  73. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/tests/test_output.py +0 -0
  74. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/tests/test_paths_catalog.py +0 -0
  75. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/tests/test_robustness.py +0 -0
  76. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/tests/test_scanner.py +0 -0
  77. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/tests/test_site.py +0 -0
  78. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/tests/test_skill_install.py +0 -0
  79. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/tests/test_stale.py +0 -0
  80. {repowiki_cli-0.6.0 → repowiki_cli-0.7.0}/tests/test_state.py +0 -0
@@ -0,0 +1,209 @@
1
+ Metadata-Version: 2.4
2
+ Name: repowiki-cli
3
+ Version: 0.7.0
4
+ Summary: Deterministic repo wiki build system, driven by any coding agent. Output language follows the repository (zh/en).
5
+ Author: luomsis
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/luomsis/repowiki
8
+ Project-URL: Repository, https://github.com/luomsis/repowiki
9
+ Project-URL: Issues, https://github.com/luomsis/repowiki/issues
10
+ Project-URL: Changelog, https://github.com/luomsis/repowiki/blob/main/CHANGELOG.md
11
+ Keywords: documentation,wiki,codebase,mermaid,llm,agent,onboarding,developer-tools
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Natural Language :: Chinese (Simplified)
16
+ Classifier: Natural Language :: English
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3 :: Only
19
+ Classifier: Topic :: Software Development :: Documentation
20
+ Classifier: Operating System :: MacOS
21
+ Classifier: Operating System :: POSIX :: Linux
22
+ Classifier: Operating System :: Microsoft :: Windows
23
+ Requires-Python: >=3.10
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Requires-Dist: pyyaml>=6
27
+ Provides-Extra: test
28
+ Requires-Dist: pytest>=8; extra == "test"
29
+ Dynamic: license-file
30
+
31
+ # repowiki
32
+
33
+ **中文** | [English](README.en.md)
34
+
35
+ [![CI](https://github.com/luomsis/repowiki/actions/workflows/ci.yml/badge.svg)](https://github.com/luomsis/repowiki/actions/workflows/ci.yml)
36
+ [![PyPI](https://img.shields.io/pypi/v/repowiki-cli)](https://pypi.org/project/repowiki-cli/)
37
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
38
+ [![Python ≥ 3.10](https://img.shields.io/badge/python-3.10%2B-blue.svg)](https://www.python.org/downloads/)
39
+ [![Platform](https://img.shields.io/badge/platform-macOS%20%7C%20Linux%20%7C%20Windows-lightgrey)](#可靠性设计)
40
+
41
+ 为任意仓库生成结构化 Wiki 的构建系统。
42
+
43
+ `repowiki` 是一个确定性的构建系统:负责任务规划、原子认领、产出校验、自动修复、元数据组装;
44
+ 智能工作(读代码、写 wiki)由驱动它的 agent(Claude Code / Codex / OpenCode 等 agent CLI,或人)完成。
45
+ 零 API Key、零网络调用、零 agent CLI 依赖——任何「能跑 shell + 读写文件」的执行者都能参与,包括并发。
46
+ Wiki 产出语言自动跟随目标仓库(中文仓库 → `zh/`,英文仓库 → `en/`;`plan --locale` 可显式指定)。
47
+
48
+ ![repowiki 系统架构图](docs/assets/repowiki-architecture.png)
49
+
50
+ *交互版架构图:[docs/repowiki-architecture.html](docs/repowiki-architecture.html)(明暗主题 · 路径高亮 · 节点搜索,下载后在浏览器打开)*
51
+
52
+ **看效果**:repowiki 为自己生成的 wiki 已发布为在线样例 → **[直接打开](https://luomsis.github.io/repowiki/zh/wiki.html)**
53
+ (每次 push main 自动重建)。
54
+
55
+ ## 为什么是 repowiki
56
+
57
+ 给仓库生成 wiki 的现成方案主要有两条路:云端 AI wiki 服务(代码要上传、按量付费、产出是黑盒),
58
+ 或者让一个 agent 直接通读仓库现写(大仓库上下文装不下、中断即前功尽弃、难以并行)。
59
+ repowiki 走第三条路:**读代码、写 wiki 的智能留给任意 agent,其余一切——任务规划、原子认领、
60
+ 产出校验、自动修复、断点续跑——做成确定性构建系统。**
61
+
62
+ | | 云端 AI wiki 服务 | 让 agent 直接读仓库 | repowiki |
63
+ |---|---|---|---|
64
+ | 智能来源 | 内置 LLM(不可换) | 你的 agent(任选) | 你的 agent(任选) |
65
+ | 代码出域 | 是 | 否 | 否 |
66
+ | API Key / 网络 | 需要 | 视 agent 而定 | repowiki 本身零依赖 |
67
+ | 大仓库 | 受服务方配额限制 | 上下文装不下 | 任务切分,逐页生成 |
68
+ | 中断 / 崩溃 | — | 从头再来 | 状态落盘,断点续跑 |
69
+ | 并行加速 | — | 难协调 | 多 worker 原子认领,天然并行 |
70
+ | 产出质量 | 黑盒 | 靠 agent 自觉 | 模板强制 + 程序化校验 + 自动修复 |
71
+
72
+ 一句话:**agent 负责聪明,repowiki 负责靠谱。**
73
+
74
+ ## 特性
75
+
76
+ - **确定性编排**:plan / claim / check / 自动修复全是确定性代码——零 API Key、零网络调用、不绑定任何 agent CLI;
77
+ - **并发安全,断点续跑**:原子任务认领 + 心跳续期 + 过期自动回收,多个 agent / 进程 / 人同时参与同一仓库;每任务状态落盘,随时中断随时继续;
78
+ - **增量更新与 CI 门禁**:`update` 基于 git diff 只重写受影响页面;`stale --fail-if-stale` 拦截「代码改了、wiki 没跟」的 PR;`coverage` 统计 wiki 从未引用的文件;
79
+ - **单文件离线站点 + agent 索引**:`site` 产出约 5 MB 自包含 HTML(导航、搜索、mermaid、源码弹层,双击即看),同时导出 `llms.txt` / `llms-full.txt`([llmstxt.org](https://llmstxt.org/) 约定),任何 agent / IDE 按索引直接读,无需 MCP;
80
+ - **强校验,自动修复**:模板强制 + 程序化校验;锚点 / 行号 / H1 / 路径分隔符自动修复,只有语义缺陷才判失败;
81
+ - **双语产出,跨平台**:语言自动跟随目标仓库(zh / en);macOS / Linux / Windows 原生支持(无需 WSL),CI 三平台 × Python 3.10-3.13 矩阵回归;
82
+ - **知识卡片与页面原型**:机制卡片 / 模块文档,类别可整表自定义(`--categories`);页面按主题选 module(结构型,默认)/ flow(流程型)两种模板。
83
+
84
+ ## 目录
85
+
86
+ - [为什么是 repowiki](#为什么是-repowiki) · [特性](#特性)
87
+ - [安装](#安装) · [查看 Wiki](#查看-wiki单文件离线站点) · [命令一览](#命令一览)
88
+ - [可靠性设计](#可靠性设计) · [设计边界](#设计边界)
89
+ - [贡献](#贡献contributing) · [社区](#社区) · [文档](#文档) · [License](#license)
90
+
91
+ ## 安装
92
+
93
+ ### 1. CLI(必需,Python ≥ 3.10,macOS / Linux / Windows)
94
+
95
+ ```bash
96
+ pip install repowiki-cli # PyPI(运行时依赖仅 pyyaml)
97
+ # 或 pipx install repowiki-cli;开发安装:克隆仓库后 pip install -e .
98
+ repowiki --version # 验证
99
+ ```
100
+
101
+ ### 2. Agent Skill(可选,让 agent 自动触发本工作流)
102
+
103
+ skill 文件随 CLI 一起分发,一条命令安装:
104
+
105
+ ```bash
106
+ repowiki skill install # 默认装入 ~/.agents/skills/repowiki/(各 agent 通用的全局 skills 目录)
107
+ repowiki skill install --agent claude # 或装入指定客户端目录(claude / codex / zcode / cursor / opencode)
108
+ repowiki skill status # 查看已装版本、是否过期
109
+ ```
110
+
111
+ 也可把本仓库作为插件安装(`.claude-plugin/` 清单自动识别),或手动拷贝
112
+ `src/repowiki/skills/repowiki/` 到客户端 skills 目录。skill 只是指引(告诉 agent 按什么流程
113
+ 调用 CLI),真正干活的是第 1 步装的 `repowiki` 命令。
114
+
115
+ ### 3. 离线安装
116
+
117
+ 运行时依赖只有 `pyyaml`:在有网机器上下载 `PyYAML` wheel 与 Release 页附带的
118
+ [`repowiki_cli-*.whl`](https://github.com/luomsis/repowiki/releases),拷到目标机后
119
+ `pip install --no-index` 两个 wheel 即可;skill 已随 whl 打包,装好后同样执行
120
+ `repowiki skill install`(纯本地拷贝)。完整步骤见 [docs/zh/USAGE.md](docs/zh/USAGE.md)。
121
+
122
+ ## 查看 Wiki(单文件离线站点)
123
+
124
+ 上方在线样例即由 `repowiki site` 生成、push main 后自动重建。
125
+
126
+ ![阅读视图:章节导航 + mermaid 渲染 + 源码引用](docs/assets/site-preview-reading.png)
127
+
128
+ ![点击 file:// 源码引用,页内弹层查看带行号的源码片段](docs/assets/site-preview-snippet.png)
129
+
130
+ `repowiki site <repo> [--open]` 把整个 wiki 打包成**一个自包含的 HTML 文件**
131
+ (`<repo>/.repowiki/<locale>/wiki.html`,约 5 MB):
132
+
133
+ - markdown + mermaid 全部渲染,引用的源码行区间直接内嵌,点击 `file://` 引用在页内
134
+ 弹层查看带行号高亮的源码——无需 IDE、无需网络,发给同事一个文件即可浏览整个 wiki;
135
+ - 侧边栏章节导航(可折叠)+ 当前页目录(scroll-spy 跟随高亮)、全文搜索(命中词高亮)、
136
+ 代码块一键复制、prev/next 翻页、阅读进度条、暗色/浅色主题(跟随系统 + 手动切换);
137
+ - 完全离线:markdown/mermaid 渲染库(marked/mermaid,MIT)已内嵌进文件本身;
138
+ - 幂等可重跑:finalize、update 或手动改了页面之后随时重新执行 `repowiki site` 重建;
139
+ - 执行过 `repowiki clean` 也能重建(此时章节顺序退化为目录序,内容不受影响)。
140
+
141
+ 页面按 **module(结构型,默认)/ flow(流程型)** 两种原型撰写,模板与文风规范由校验器
142
+ 按语言强制;每节末尾「Section sources/章节来源」、每图后「Diagram sources/图表来源」,
143
+ 引用格式 `[path:Lx-Ly](file://path#Lx-Ly)`,页间零链接(正因如此所有页面任务可完全并行)。
144
+ 完整小节结构见 [docs/zh/USAGE.md](docs/zh/USAGE.md)。
145
+
146
+ ## 命令一览
147
+
148
+ | 命令 | 作用 |
149
+ |---|---|
150
+ | `plan <repo>` | 扫描 + 生成任务清单(产出语言自动检测,`--locale` 可指定) |
151
+ | `next --claim` | 领取一个就绪任务,`--json` 含完整 instructions |
152
+ | `check --task ID` | 校验产出;锚点/行号/H1 自动修复 |
153
+ | `finalize` | 组装 metadata.json(两步:先创建 overview 任务) |
154
+ | `site` | 生成单文件离线站点 + llms.txt / llms-full.txt 索引 |
155
+ | `update` / `stale` | git diff 增量更新任务 / 只读过期报告(CI 门禁) |
156
+ | `skill install` / `status` | 安装 / 检查 agent skill |
157
+ | `status` / `clean` | 进度统计 / 清空任务状态 |
158
+
159
+ 完整 15 条命令与全部参数:`repowiki <命令> --help` 或 [docs/zh/USAGE.md](docs/zh/USAGE.md)。
160
+ 退出码:`0` 成功,`1` 校验失败或用法错误,`2` 状态冲突(任务被他人认领),`3` 进展性等待
161
+ (finalize 已创建 overview 任务,完成后再次运行即可)。
162
+
163
+ ## 可靠性设计
164
+
165
+ - 原子认领(POSIX `fcntl` / Windows `msvcrt` 文件锁)+ 过期自动回收:崩溃 worker 的认领自动回队列,无需人工释放;
166
+ - 断点续跑:每任务状态落盘;状态文件损坏时保留现场明确报错,绝不静默清空任务清单;
167
+ - `watch` 不假活:过期认领不计入「执行中」,真停滞及时报告而非干等超时;
168
+ - finalize 后自动瘦身运行时产物,保留增量更新所需状态。
169
+
170
+ 机制细节(过期窗口调参、`.stale-*` 留痕、心跳语义、瘦身清单)见 [docs/zh/USAGE.md](docs/zh/USAGE.md)。
171
+
172
+ ## 设计边界
173
+
174
+ - **设计取舍**:`metadata.json` 只含可读字段(catalogs/items/source_files/snippets/relations),运行时状态留在 `state/`;ADR 类知识卡片不生成,机制卡片/模块文档完整支持;产出语言冻结为 zh / en;CLI 交互消息当前为中文(面向驱动它的 agent),不影响 wiki 产出语言。
175
+ - **已知边界**:任务规格内嵌完整模板与文风规范(约 4-6k tokens),换取自包含与并行安全,小上下文 agent 可将规格中的模板段落替换为对 `templates/` 目录的引用;产出语言 plan 时锁定,中途更换需 `plan --replan`;`update` 依赖目标仓库本地 git CLI(`git diff` / `git rev-parse`)。
176
+ - **Non-Goals**:LLM API 后端 · 内置 agent CLI 检测/执行器 · MCP 封装(agent 读取 wiki 的需求由 `llms.txt` 静态导出满足) · 常驻预览服务器(`site` 产物是纯静态单文件,双击即看) · zh/en 之外的产出语言。
177
+
178
+ ## 贡献(Contributing)
179
+
180
+ 欢迎 issue 与 PR!本地开发:
181
+
182
+ ```bash
183
+ git clone https://github.com/luomsis/repowiki.git && cd repowiki
184
+ pip install -e '.[test]'
185
+ pytest
186
+ ```
187
+
188
+ - 行为变更请先开 issue 或去 Discussions 对齐方向,再动手。
189
+
190
+ ## 社区
191
+
192
+ - 问题、想法,或想晒一晒你生成的 wiki → [GitHub Discussions](https://github.com/luomsis/repowiki/discussions)
193
+ - bug 与功能请求 → [Issues](https://github.com/luomsis/repowiki/issues)
194
+
195
+ ## 文档
196
+
197
+ 全部文档集中于 `docs/`(`zh/` 与 `en/` 镜像目录,同名文件一一对应):
198
+
199
+ - [使用详解](docs/zh/USAGE.md)([English](docs/en/USAGE.md))——完整命令参考、Worker 循环契约、并发配方、可靠性机制细节
200
+ - [版本日志](CHANGELOG.md)([English](CHANGELOG.en.md),位于仓库根部)
201
+ - [领域词汇表](docs/zh/CONTEXT.md)(产出物 / 编排 / 执行三组术语与 Avoid 对照)
202
+ - [决策记录](docs/zh/DECISIONS.md)(规格空白处的 15 条最小合理决策)
203
+ - 架构决策记录(ADR):[Windows 原生支持的双锁后端](docs/zh/adr/0001-windows-native-support.md) ·
204
+ [单文件离线站点](docs/zh/adr/0002-single-file-offline-site.md)
205
+ - Agent Skill 指引:[中文](src/repowiki/skills/repowiki/SKILL.md) · [English](src/repowiki/skills/repowiki/SKILL.en.md)
206
+
207
+ ## License
208
+
209
+ [MIT](LICENSE) © luomsis
@@ -0,0 +1,179 @@
1
+ # repowiki
2
+
3
+ **中文** | [English](README.en.md)
4
+
5
+ [![CI](https://github.com/luomsis/repowiki/actions/workflows/ci.yml/badge.svg)](https://github.com/luomsis/repowiki/actions/workflows/ci.yml)
6
+ [![PyPI](https://img.shields.io/pypi/v/repowiki-cli)](https://pypi.org/project/repowiki-cli/)
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
8
+ [![Python ≥ 3.10](https://img.shields.io/badge/python-3.10%2B-blue.svg)](https://www.python.org/downloads/)
9
+ [![Platform](https://img.shields.io/badge/platform-macOS%20%7C%20Linux%20%7C%20Windows-lightgrey)](#可靠性设计)
10
+
11
+ 为任意仓库生成结构化 Wiki 的构建系统。
12
+
13
+ `repowiki` 是一个确定性的构建系统:负责任务规划、原子认领、产出校验、自动修复、元数据组装;
14
+ 智能工作(读代码、写 wiki)由驱动它的 agent(Claude Code / Codex / OpenCode 等 agent CLI,或人)完成。
15
+ 零 API Key、零网络调用、零 agent CLI 依赖——任何「能跑 shell + 读写文件」的执行者都能参与,包括并发。
16
+ Wiki 产出语言自动跟随目标仓库(中文仓库 → `zh/`,英文仓库 → `en/`;`plan --locale` 可显式指定)。
17
+
18
+ ![repowiki 系统架构图](docs/assets/repowiki-architecture.png)
19
+
20
+ *交互版架构图:[docs/repowiki-architecture.html](docs/repowiki-architecture.html)(明暗主题 · 路径高亮 · 节点搜索,下载后在浏览器打开)*
21
+
22
+ **看效果**:repowiki 为自己生成的 wiki 已发布为在线样例 → **[直接打开](https://luomsis.github.io/repowiki/zh/wiki.html)**
23
+ (每次 push main 自动重建)。
24
+
25
+ ## 为什么是 repowiki
26
+
27
+ 给仓库生成 wiki 的现成方案主要有两条路:云端 AI wiki 服务(代码要上传、按量付费、产出是黑盒),
28
+ 或者让一个 agent 直接通读仓库现写(大仓库上下文装不下、中断即前功尽弃、难以并行)。
29
+ repowiki 走第三条路:**读代码、写 wiki 的智能留给任意 agent,其余一切——任务规划、原子认领、
30
+ 产出校验、自动修复、断点续跑——做成确定性构建系统。**
31
+
32
+ | | 云端 AI wiki 服务 | 让 agent 直接读仓库 | repowiki |
33
+ |---|---|---|---|
34
+ | 智能来源 | 内置 LLM(不可换) | 你的 agent(任选) | 你的 agent(任选) |
35
+ | 代码出域 | 是 | 否 | 否 |
36
+ | API Key / 网络 | 需要 | 视 agent 而定 | repowiki 本身零依赖 |
37
+ | 大仓库 | 受服务方配额限制 | 上下文装不下 | 任务切分,逐页生成 |
38
+ | 中断 / 崩溃 | — | 从头再来 | 状态落盘,断点续跑 |
39
+ | 并行加速 | — | 难协调 | 多 worker 原子认领,天然并行 |
40
+ | 产出质量 | 黑盒 | 靠 agent 自觉 | 模板强制 + 程序化校验 + 自动修复 |
41
+
42
+ 一句话:**agent 负责聪明,repowiki 负责靠谱。**
43
+
44
+ ## 特性
45
+
46
+ - **确定性编排**:plan / claim / check / 自动修复全是确定性代码——零 API Key、零网络调用、不绑定任何 agent CLI;
47
+ - **并发安全,断点续跑**:原子任务认领 + 心跳续期 + 过期自动回收,多个 agent / 进程 / 人同时参与同一仓库;每任务状态落盘,随时中断随时继续;
48
+ - **增量更新与 CI 门禁**:`update` 基于 git diff 只重写受影响页面;`stale --fail-if-stale` 拦截「代码改了、wiki 没跟」的 PR;`coverage` 统计 wiki 从未引用的文件;
49
+ - **单文件离线站点 + agent 索引**:`site` 产出约 5 MB 自包含 HTML(导航、搜索、mermaid、源码弹层,双击即看),同时导出 `llms.txt` / `llms-full.txt`([llmstxt.org](https://llmstxt.org/) 约定),任何 agent / IDE 按索引直接读,无需 MCP;
50
+ - **强校验,自动修复**:模板强制 + 程序化校验;锚点 / 行号 / H1 / 路径分隔符自动修复,只有语义缺陷才判失败;
51
+ - **双语产出,跨平台**:语言自动跟随目标仓库(zh / en);macOS / Linux / Windows 原生支持(无需 WSL),CI 三平台 × Python 3.10-3.13 矩阵回归;
52
+ - **知识卡片与页面原型**:机制卡片 / 模块文档,类别可整表自定义(`--categories`);页面按主题选 module(结构型,默认)/ flow(流程型)两种模板。
53
+
54
+ ## 目录
55
+
56
+ - [为什么是 repowiki](#为什么是-repowiki) · [特性](#特性)
57
+ - [安装](#安装) · [查看 Wiki](#查看-wiki单文件离线站点) · [命令一览](#命令一览)
58
+ - [可靠性设计](#可靠性设计) · [设计边界](#设计边界)
59
+ - [贡献](#贡献contributing) · [社区](#社区) · [文档](#文档) · [License](#license)
60
+
61
+ ## 安装
62
+
63
+ ### 1. CLI(必需,Python ≥ 3.10,macOS / Linux / Windows)
64
+
65
+ ```bash
66
+ pip install repowiki-cli # PyPI(运行时依赖仅 pyyaml)
67
+ # 或 pipx install repowiki-cli;开发安装:克隆仓库后 pip install -e .
68
+ repowiki --version # 验证
69
+ ```
70
+
71
+ ### 2. Agent Skill(可选,让 agent 自动触发本工作流)
72
+
73
+ skill 文件随 CLI 一起分发,一条命令安装:
74
+
75
+ ```bash
76
+ repowiki skill install # 默认装入 ~/.agents/skills/repowiki/(各 agent 通用的全局 skills 目录)
77
+ repowiki skill install --agent claude # 或装入指定客户端目录(claude / codex / zcode / cursor / opencode)
78
+ repowiki skill status # 查看已装版本、是否过期
79
+ ```
80
+
81
+ 也可把本仓库作为插件安装(`.claude-plugin/` 清单自动识别),或手动拷贝
82
+ `src/repowiki/skills/repowiki/` 到客户端 skills 目录。skill 只是指引(告诉 agent 按什么流程
83
+ 调用 CLI),真正干活的是第 1 步装的 `repowiki` 命令。
84
+
85
+ ### 3. 离线安装
86
+
87
+ 运行时依赖只有 `pyyaml`:在有网机器上下载 `PyYAML` wheel 与 Release 页附带的
88
+ [`repowiki_cli-*.whl`](https://github.com/luomsis/repowiki/releases),拷到目标机后
89
+ `pip install --no-index` 两个 wheel 即可;skill 已随 whl 打包,装好后同样执行
90
+ `repowiki skill install`(纯本地拷贝)。完整步骤见 [docs/zh/USAGE.md](docs/zh/USAGE.md)。
91
+
92
+ ## 查看 Wiki(单文件离线站点)
93
+
94
+ 上方在线样例即由 `repowiki site` 生成、push main 后自动重建。
95
+
96
+ ![阅读视图:章节导航 + mermaid 渲染 + 源码引用](docs/assets/site-preview-reading.png)
97
+
98
+ ![点击 file:// 源码引用,页内弹层查看带行号的源码片段](docs/assets/site-preview-snippet.png)
99
+
100
+ `repowiki site <repo> [--open]` 把整个 wiki 打包成**一个自包含的 HTML 文件**
101
+ (`<repo>/.repowiki/<locale>/wiki.html`,约 5 MB):
102
+
103
+ - markdown + mermaid 全部渲染,引用的源码行区间直接内嵌,点击 `file://` 引用在页内
104
+ 弹层查看带行号高亮的源码——无需 IDE、无需网络,发给同事一个文件即可浏览整个 wiki;
105
+ - 侧边栏章节导航(可折叠)+ 当前页目录(scroll-spy 跟随高亮)、全文搜索(命中词高亮)、
106
+ 代码块一键复制、prev/next 翻页、阅读进度条、暗色/浅色主题(跟随系统 + 手动切换);
107
+ - 完全离线:markdown/mermaid 渲染库(marked/mermaid,MIT)已内嵌进文件本身;
108
+ - 幂等可重跑:finalize、update 或手动改了页面之后随时重新执行 `repowiki site` 重建;
109
+ - 执行过 `repowiki clean` 也能重建(此时章节顺序退化为目录序,内容不受影响)。
110
+
111
+ 页面按 **module(结构型,默认)/ flow(流程型)** 两种原型撰写,模板与文风规范由校验器
112
+ 按语言强制;每节末尾「Section sources/章节来源」、每图后「Diagram sources/图表来源」,
113
+ 引用格式 `[path:Lx-Ly](file://path#Lx-Ly)`,页间零链接(正因如此所有页面任务可完全并行)。
114
+ 完整小节结构见 [docs/zh/USAGE.md](docs/zh/USAGE.md)。
115
+
116
+ ## 命令一览
117
+
118
+ | 命令 | 作用 |
119
+ |---|---|
120
+ | `plan <repo>` | 扫描 + 生成任务清单(产出语言自动检测,`--locale` 可指定) |
121
+ | `next --claim` | 领取一个就绪任务,`--json` 含完整 instructions |
122
+ | `check --task ID` | 校验产出;锚点/行号/H1 自动修复 |
123
+ | `finalize` | 组装 metadata.json(两步:先创建 overview 任务) |
124
+ | `site` | 生成单文件离线站点 + llms.txt / llms-full.txt 索引 |
125
+ | `update` / `stale` | git diff 增量更新任务 / 只读过期报告(CI 门禁) |
126
+ | `skill install` / `status` | 安装 / 检查 agent skill |
127
+ | `status` / `clean` | 进度统计 / 清空任务状态 |
128
+
129
+ 完整 15 条命令与全部参数:`repowiki <命令> --help` 或 [docs/zh/USAGE.md](docs/zh/USAGE.md)。
130
+ 退出码:`0` 成功,`1` 校验失败或用法错误,`2` 状态冲突(任务被他人认领),`3` 进展性等待
131
+ (finalize 已创建 overview 任务,完成后再次运行即可)。
132
+
133
+ ## 可靠性设计
134
+
135
+ - 原子认领(POSIX `fcntl` / Windows `msvcrt` 文件锁)+ 过期自动回收:崩溃 worker 的认领自动回队列,无需人工释放;
136
+ - 断点续跑:每任务状态落盘;状态文件损坏时保留现场明确报错,绝不静默清空任务清单;
137
+ - `watch` 不假活:过期认领不计入「执行中」,真停滞及时报告而非干等超时;
138
+ - finalize 后自动瘦身运行时产物,保留增量更新所需状态。
139
+
140
+ 机制细节(过期窗口调参、`.stale-*` 留痕、心跳语义、瘦身清单)见 [docs/zh/USAGE.md](docs/zh/USAGE.md)。
141
+
142
+ ## 设计边界
143
+
144
+ - **设计取舍**:`metadata.json` 只含可读字段(catalogs/items/source_files/snippets/relations),运行时状态留在 `state/`;ADR 类知识卡片不生成,机制卡片/模块文档完整支持;产出语言冻结为 zh / en;CLI 交互消息当前为中文(面向驱动它的 agent),不影响 wiki 产出语言。
145
+ - **已知边界**:任务规格内嵌完整模板与文风规范(约 4-6k tokens),换取自包含与并行安全,小上下文 agent 可将规格中的模板段落替换为对 `templates/` 目录的引用;产出语言 plan 时锁定,中途更换需 `plan --replan`;`update` 依赖目标仓库本地 git CLI(`git diff` / `git rev-parse`)。
146
+ - **Non-Goals**:LLM API 后端 · 内置 agent CLI 检测/执行器 · MCP 封装(agent 读取 wiki 的需求由 `llms.txt` 静态导出满足) · 常驻预览服务器(`site` 产物是纯静态单文件,双击即看) · zh/en 之外的产出语言。
147
+
148
+ ## 贡献(Contributing)
149
+
150
+ 欢迎 issue 与 PR!本地开发:
151
+
152
+ ```bash
153
+ git clone https://github.com/luomsis/repowiki.git && cd repowiki
154
+ pip install -e '.[test]'
155
+ pytest
156
+ ```
157
+
158
+ - 行为变更请先开 issue 或去 Discussions 对齐方向,再动手。
159
+
160
+ ## 社区
161
+
162
+ - 问题、想法,或想晒一晒你生成的 wiki → [GitHub Discussions](https://github.com/luomsis/repowiki/discussions)
163
+ - bug 与功能请求 → [Issues](https://github.com/luomsis/repowiki/issues)
164
+
165
+ ## 文档
166
+
167
+ 全部文档集中于 `docs/`(`zh/` 与 `en/` 镜像目录,同名文件一一对应):
168
+
169
+ - [使用详解](docs/zh/USAGE.md)([English](docs/en/USAGE.md))——完整命令参考、Worker 循环契约、并发配方、可靠性机制细节
170
+ - [版本日志](CHANGELOG.md)([English](CHANGELOG.en.md),位于仓库根部)
171
+ - [领域词汇表](docs/zh/CONTEXT.md)(产出物 / 编排 / 执行三组术语与 Avoid 对照)
172
+ - [决策记录](docs/zh/DECISIONS.md)(规格空白处的 15 条最小合理决策)
173
+ - 架构决策记录(ADR):[Windows 原生支持的双锁后端](docs/zh/adr/0001-windows-native-support.md) ·
174
+ [单文件离线站点](docs/zh/adr/0002-single-file-offline-site.md)
175
+ - Agent Skill 指引:[中文](src/repowiki/skills/repowiki/SKILL.md) · [English](src/repowiki/skills/repowiki/SKILL.en.md)
176
+
177
+ ## License
178
+
179
+ [MIT](LICENSE) © luomsis
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "repowiki-cli"
7
- version = "0.6.0"
7
+ version = "0.7.0"
8
8
  description = "Deterministic repo wiki build system, driven by any coding agent. Output language follows the repository (zh/en)."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -63,12 +63,16 @@ def run_coverage(paths: WikiPaths, as_json: bool) -> int:
63
63
  uncited = sorted(known - cited)
64
64
  total = len(known)
65
65
  covered = total - len(uncited)
66
+ breakdown = _classify_uncited(uncited, cited, paths.locale)
67
+ eff_total = total - len(breakdown["vendor"]) - len(breakdown["locale_mirror"])
66
68
  result = {
67
69
  "ok": True,
68
70
  "repo_files": total,
69
71
  "cited_files": covered,
70
72
  "coverage": round(covered / total, 4) if total else 1.0,
73
+ "effective_coverage": round(covered / eff_total, 4) if eff_total else 1.0,
71
74
  "uncited_files": uncited,
75
+ "uncited_breakdown": breakdown,
72
76
  "knowledge_files": sorted(knowledge_files),
73
77
  "pages": pages,
74
78
  }
@@ -76,15 +80,60 @@ def run_coverage(paths: WikiPaths, as_json: bool) -> int:
76
80
  return 0
77
81
 
78
82
 
83
+ def _locale_mirrors(p: str, locale: str) -> set[str]:
84
+ """Candidate paths of the other-locale twin of ``p`` (deterministic)."""
85
+ out: set[str] = set()
86
+ for old, new in (
87
+ (f"/{locale}/", "/en/"), ("/en/", f"/{locale}/"),
88
+ (f".{locale}.", ".en."), (".en.", f".{locale}."), (".en.", "."),
89
+ ):
90
+ if old in p:
91
+ out.add(p.replace(old, new, 1))
92
+ return out
93
+
94
+
95
+ def _classify_uncited(uncited: list[str], cited: set[str], locale: str) -> dict[str, list[str]]:
96
+ """Bucket uncited files: vendored third-party code, other-locale mirrors
97
+ of already-cited files, and the rest (the actionable residue)."""
98
+ vendor: list[str] = []
99
+ mirror: list[str] = []
100
+ other: list[str] = []
101
+ for p in uncited:
102
+ if "/vendor/" in f"/{p}":
103
+ vendor.append(p)
104
+ elif _locale_mirrors(p, locale) & cited:
105
+ mirror.append(p)
106
+ else:
107
+ other.append(p)
108
+ return {"vendor": sorted(vendor), "locale_mirror": sorted(mirror), "other": sorted(other)}
109
+
110
+
79
111
  def _coverage_human(r: dict) -> str:
80
112
  lines = [
81
113
  f"覆盖率 {r['cited_files']}/{r['repo_files']}({r['coverage'] * 100:.1f}%)"
82
114
  "——被 wiki 页面/总览/知识卡片引用过的仓库文件占比"
83
115
  ]
116
+ if r.get("effective_coverage") != r["coverage"]:
117
+ lines.append(
118
+ f"有效覆盖率 {r['effective_coverage'] * 100:.1f}%"
119
+ "(剔除 vendor 与其他语言镜像后的口径)"
120
+ )
84
121
  uncited = r["uncited_files"]
85
122
  if uncited:
86
- lines.append(f"未被引用 {len(uncited)} 个(至多列出 {MAX_LISTING} 个,JSON 输出含全量):")
87
- lines += [f" → {p}" for p in uncited[:MAX_LISTING]]
123
+ bd = r.get("uncited_breakdown") or {}
124
+ mirror = bd.get("locale_mirror", [])
125
+ vendored = bd.get("vendor", [])
126
+ actionable = bd.get("other", uncited)
127
+ lines.append(f"未被引用 {len(uncited)} 个(JSON 输出含全量分组):")
128
+ if mirror:
129
+ lines.append(f" 其他语言镜像(无需引用): {', '.join(mirror[:5])}"
130
+ + (f" 等 {len(mirror)} 个" if len(mirror) > 5 else ""))
131
+ if vendored:
132
+ lines.append(f" vendor 第三方(无需引用): {', '.join(vendored[:5])}"
133
+ + (f" 等 {len(vendored)} 个" if len(vendored) > 5 else ""))
134
+ show = actionable[:MAX_LISTING]
135
+ lines.append(f" 值得补引用 {len(actionable)} 个(至多列出 {MAX_LISTING} 个):")
136
+ lines += [f" → {p}" for p in show]
88
137
  else:
89
138
  lines.append("仓库全部文件都被引用 ✓")
90
139
  zero = [p for p in r["pages"] if p["cited_files"] == 0]
@@ -292,7 +292,8 @@ def _check_readonly(paths: WikiPaths, task: dict, inv) -> dict:
292
292
  node_id = task["id"][:-len("-update")] if task["id"].endswith("-update") else task["id"]
293
293
  res = check_page(raw, task["title"].replace("(增量更新)", ""), paths.repo_root,
294
294
  is_update=(task["kind"] == "page_update"), locale=paths.locale,
295
- archetype=_node_archetype(paths, node_id))
295
+ archetype=_node_archetype(paths, node_id),
296
+ known_paths=inv.known_paths())
296
297
  return {**base, "ok": res.ok, "readonly": True, "errors": res.errors,
297
298
  "fixed": [], "warnings": res.warnings,
298
299
  "note": "done 为终态,此结果仅供参考,状态未改变"}
@@ -352,7 +353,8 @@ def _check_one(paths: WikiPaths, store: TaskStore, task: dict, inv) -> dict:
352
353
  node_id = tid[:-len("-update")] if tid.endswith("-update") else tid
353
354
  res = check_page(raw, task["title"].replace("(增量更新)", ""), paths.repo_root,
354
355
  is_update=(kind == "page_update"), locale=paths.locale,
355
- archetype=_node_archetype(paths, node_id))
356
+ archetype=_node_archetype(paths, node_id),
357
+ known_paths=inv.known_paths())
356
358
  if res.fixed and res.text != raw:
357
359
  out_file.write_text(res.text, encoding="utf-8")
358
360
  status = "done" if res.ok else "failed"
@@ -32,6 +32,7 @@ STRINGS: dict[str, dict] = {
32
32
  ("结论", "exact"),
33
33
  ],
34
34
  "update_extra": ("更新摘要", "exact"),
35
+ "section_sources": "章节来源",
35
36
  "flow_sections": [
36
37
  ("简介", "exact"),
37
38
  ("流程总览", "exact"),
@@ -74,6 +75,7 @@ STRINGS: dict[str, dict] = {
74
75
  ("Conclusion", "exact"),
75
76
  ],
76
77
  "update_extra": ("Update Summary", "exact"),
78
+ "section_sources": "Section sources",
77
79
  "flow_sections": [
78
80
  ("Introduction", "exact"),
79
81
  ("Flow Overview", "exact"),
@@ -131,10 +131,12 @@ code 3 (it created the overview task — normal progress).
131
131
  source code.
132
132
  - Pages follow the template and STYLE guide embedded in the spec: all required sections
133
133
  present, "Section sources" at the end of every section, "Diagram sources" after every
134
- mermaid diagram, `[path:Lx-Ly](file://path#Lx-Ly)` format, line numbers within bounds,
134
+ mermaid diagram, `[path:Lx-Ly](file://path#Lx-Ly)` format, line numbers within bounds
135
+ (a start past EOF or an inverted range is rejected; only an overhanging end is clamped),
135
136
  zero cross-page links, no emoji/tables.
136
- - Deterministic defects caught by `check` (anchors/line numbers/H1) are auto-repaired —
137
- no manual handling needed; only fix the semantic issues listed in `errors`.
137
+ - Deterministic defects caught by `check` (anchors/H1/overhanging line-range ends) are
138
+ auto-repaired — no manual handling needed; only fix the semantic issues listed in
139
+ `errors`.
138
140
  - Output lives in `<repo>/.repowiki/` (`<locale>/content` pages, `<locale>/meta`
139
141
  metadata, `knowledge/<locale>/` knowledge cards, `<locale>/wiki.html` single-file
140
142
  viewer; locale was fixed at plan time).
@@ -102,6 +102,6 @@ loop:
102
102
  ## 硬性规则
103
103
 
104
104
  - **只写任务规格指定的 output 文件**,绝不改动仓库源码。
105
- - 页面遵循规格内嵌的模板与 STYLE 规范:必备小节齐全、每节末尾「Section sources/章节来源」、每个 mermaid 图后「Diagram sources/图表来源」、`[path:Lx-Ly](file://path#Lx-Ly)` 格式、行号不越界、页间零链接、不用 emoji/表格。
106
- - `check` 的确定性缺陷(锚点/行号/H1)会被自动修复,无需手动处理;只需修复 `errors` 列出的语义问题。
105
+ - 页面遵循规格内嵌的模板与 STYLE 规范:必备小节齐全、每节末尾「Section sources/章节来源」、每个 mermaid 图后「Diagram sources/图表来源」、`[path:Lx-Ly](file://path#Lx-Ly)` 格式、行号不越界(起点越界/区间倒置会被打回,仅终点越界自动钳制)、页间零链接、不用 emoji/表格。
106
+ - `check` 的确定性缺陷(锚点/H1/越界的行区间终点)会被自动修复,无需手动处理;只需修复 `errors` 列出的语义问题。
107
107
  - 输出位于 `<repo>/.repowiki/`(`<locale>/content` 页面、`<locale>/meta` 元数据、`knowledge/<locale>/` 知识卡片、`<locale>/wiki.html` 单文件查看站点;locale 已在 plan 时确定)。
@@ -6,7 +6,7 @@
6
6
 
7
7
  ## Section Sources & Diagram Sources (citation format, mandatory)
8
8
  - Every body section ends with a "Section sources" list; every mermaid diagram is followed by a "Diagram sources" list.
9
- - Link format (paths relative to the repo root, forward slashes, line ranges must not exceed the file's real length):
9
+ - Link format (paths relative to the repo root, forward slashes, line ranges must not exceed the file's real length; only an overhanging end is auto-clamped, while a start past EOF or an inverted range is rejected by `check`):
10
10
  - `[README.md:1-120](file://README.md#L1-L120)`
11
11
  - `src/graphiti/graphiti.py:146-283` → `[graphiti/graphiti.py:146-283](file://graphiti/graphiti.py#L146-L283)`
12
12
  - Whole-file references may use the shorter form `[nodes.py](file://graphiti_core/nodes.py)` (inside the `<cite>` block).
@@ -35,7 +35,7 @@ Write the finished page to: <b>{{OUTPUT_ABS}}</b> (repo-relative: {{OUTPUT}}).
35
35
  1. Exactly one H1, equal to "{{TITLE}}".
36
36
  2. The `<cite>` block lists the files this page actually references (`[file name](file://repo-relative path)` format, 3~15 files).
37
37
  3. The "Contents" anchors must match the real section headings (GitHub-style anchors: lowercase, punctuation dropped, spaces → `-`).
38
- 4. After the Introduction, every section ends with "Section sources"; every mermaid diagram is followed by "Diagram sources"; link format `[path:Lx-Ly](file://path#Lx-Ly)` with line numbers within the file's real length.
38
+ 4. After the Introduction, every section ends with "Section sources"; every mermaid diagram is followed by "Diagram sources"; link format `[path:Lx-Ly](file://path#Lx-Ly)` with line numbers within the file's real length (a start past EOF or an inverted range is rejected; only an overhanging end is auto-clamped).
39
39
  5. At least 2 mermaid diagrams (a structure diagram + a sequence/dependency diagram).
40
40
  6. Beyond the required sections above you may add "Appendix: <topic>" sections as needed.
41
41
  7. Never link any other page under `.repowiki/`.
@@ -25,7 +25,7 @@ Rewrite the full updated page to: <b>{{OUTPUT_ABS}}</b> (repo-relative: {{OUTPUT
25
25
  ```
26
26
 
27
27
  ## Update rules
28
- 1. Right after the `<cite>` block and before the table of contents, insert one section:
28
+ 1. Right after the H1 and before the table of contents, insert one section:
29
29
 
30
30
  ```markdown
31
31
  ## Update Summary
@@ -7,7 +7,7 @@
7
7
 
8
8
  ## 章节来源与图表来源(引用格式,强制)
9
9
  - 每个正文章节末尾附「章节来源」列表;每个 mermaid 图后附「图表来源」列表。
10
- - 链接格式(路径相对仓库根目录,统一正斜杠,行号区间不得超出文件实际行数):
10
+ - 链接格式(路径相对仓库根目录,统一正斜杠,行号区间不得超出文件实际行数;仅终点越界会被自动钳制到文件末尾,起点越界或区间倒置会被 `check` 打回重写):
11
11
  - `[README.md:1-120](file://README.md#L1-L120)`
12
12
  - `[graphiti_core/graphiti.py:146-283](file://graphiti_core/graphiti.py#L146-L283)`
13
13
  - 仅供整文件引用时可用 `[nodes.py](file://graphiti_core/nodes.py)` 形式(`<cite>` 块内)。
@@ -35,7 +35,7 @@ hint_files:
35
35
  1. H1 必须且只能是「{{TITLE}}」。
36
36
  2. `<cite>` 块内列出本文实际引用的文件(`[文件名](file://仓库相对路径)` 格式,3~15 个)。
37
37
  3. 「目录」的锚点必须与实际章节标题对应(GitHub 中文锚点:去 `:` 等标点、空格转 `-`)。
38
- 4. 简介之后每个小节末尾都有「章节来源」;每个 mermaid 图后都有「图表来源」;链接格式 `[path:Lx-Ly](file://path#Lx-Ly)`,行号不得超出文件实际行数。
38
+ 4. 简介之后每个小节末尾都有「章节来源」;每个 mermaid 图后都有「图表来源」;链接格式 `[path:Lx-Ly](file://path#Lx-Ly)`,行号不得超出文件实际行数(起点越界/区间倒置会被打回,仅终点越界自动钳制)。
39
39
  5. 至少 2 个 mermaid 图(结构图 + 时序/依赖图)。
40
40
  6. 除模板列出的必备小节外,可按需增加「附录:<主题>」小节。
41
41
  7. 禁止链接任何 `.repowiki/` 下的其他页面。
@@ -25,7 +25,7 @@ hint_files:
25
25
  ```
26
26
 
27
27
  ## 更新规则
28
- 1. 在 `<cite>` 块之后、「目录」之前插入一个小节:
28
+ 1. 在 H1 之后、「目录」之前插入一个小节:
29
29
 
30
30
  ```markdown
31
31
  ## 更新摘要