Repository navigation
Expand file tree
/
Copy pathschema.yaml
More file actions
480 lines (370 loc) · 19 KB
/
Copy pathschema.yaml
File metadata and controls
480 lines (370 loc) · 19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
---
# ── 项目定位 ─────────────────────────────────────────────────────────────
# 用一两句话描述项目的目标和定位,会注入到所有文档生成 prompt 中。
# 留空则不注入。拷贝到项目后建议填写。
purpose: "CodeWiki-Plus 是一个用 AI IDE 驱动的代码仓库文档生成与知识管理工具:通过 MCP 服务为代码仓库生成结构化 LLM Wiki(模块文档、实体/概念页、总览),并提供知识沉淀(ingest_note)、检索(query_wiki)、蒸馏(distill_conversation)、任务记忆等知识飞轮能力。"
# ── 文档类型 ─────────────────────────────────────────────────────────────
# analyze_repo / get_prompt 的 doc_type 参数从此处取值。
# 每种类型定义 module(叶/父模块文档 prompt hint)和 overview(总览文档 prompt hint,可选)。
# 可自由增删类型,prompt_server 会自动识别。
doc_types:
default: design
types:
api:
module: "Focus on API documentation: endpoints, parameters, return types, and
usage examples."
architecture:
module: "Focus on architecture documentation: system design, component relationships,
and data flow."
overview: "Focus on system-level architecture: show how modules relate, data
flows between components, and the overall layered design. Include a high-level
Mermaid architecture diagram."
user-guide:
module: "Focus on user guide documentation: how to use features, step-by-step
tutorials."
developer:
module: "Focus on developer documentation: code structure, contribution guidelines,
and implementation details."
business:
module: "Focus on business logic documentation: describe business workflows,
processing pipelines, state transitions, and domain rules. Emphasize WHAT
the system does for users and WHY, trace end-to-end business scenarios through
the code, and document domain-specific terminology. De-emphasize infrastructure
and deployment details."
design:
module: "Generate technical design documentation optimized for AI comprehension.
For each module, describe in depth: (1) module responsibilities and boundaries,
(2) detailed implementation logic and business rules, (3) data flow within
and through the module, (4) interface contracts — inputs, outputs, and side
effects, (5) internal layered design and component collaboration patterns,
(6) relationships and dependencies with other modules, (7) constraints, assumptions,
and edge cases. Use precise technical language. Include Mermaid diagrams for
complex flows and interactions. Do not limit documentation length — let the
content depth match the module's complexity."
overview: "Focus on system-level architecture: show how modules relate to each
other, data flows between components, overall layered design, and key architectural
decisions. Provide a high-level view that helps readers understand the system's
structural blueprint. Include Mermaid diagrams for the architecture overview."
# ── 文档规范 ─────────────────────────────────────────────────────────────
conventions:
# 文档文件匹配模式,lint 和索引扫描时只处理匹配此 glob 的文件
file_pattern: "*.md"
# 模块间交叉引用的链接格式模板。
# {module_name} 会被替换为实际模块名,生成如 [引擎核心](引擎核心.md) 的相对链接
cross_reference_format: "[[{module_name}]]({{module_name}}.md)"
# 是否要求每个叶模块文档至少包含一个 Mermaid 架构图。
# true 时 get_prompt 会在系统提示中强调此要求,lint 也会检查
mermaid_required: true
# 叶模块文档的最小行数。低于此值时 lint 报 warning(内容可能过于简略)
min_leaf_doc_lines: 200
# 父模块/总览文档的最大行数。超过此值时 lint 报 warning(建议拆分子模块)
max_overview_doc_lines: 1000
# B5 聚类质量诊断:按模块完整 scope 文件文本估算 token,只给宿主建议,
# 不自动重排模块树。chars_per_token 是字符估值除数,不是计费精度;
# min/max 只作用于 leaf,0 关闭对应诊断;缺文件不会被当成 0 token。
# 默认 1000/32000 来自本仓 22 个 leaf 的实测分布,其他仓库应重新校准。
clustering_validation:
enabled: true
chars_per_token: 4
min_leaf_tokens: 1000
max_leaf_tokens: 32000
# 知识聚合(consolidate_notes)运行参数。
# doctrine_max_chars: refresh_doctrine 产出的 Team Operating Doctrine 硬上限(字符)。
# Doctrine 每轮会话全文注入系统提示,此值是「注入成本 vs 原则覆盖度」的平衡点;
# 超限 submit 直接 reject。下限 200,默认 1200(codewiki/mcp/tools/doctrine.py)。
aggregation:
doctrine_max_chars: 2000
# 是否在 write_doc_file 后自动注入「相关模块」交叉链接章节。
# 基于模块树的依赖关系计算 "Depends on" / "Used by" 链接
auto_crosslink: true
# 是否在 write_doc_file 写模块文档时自动打代码证据(P0,openwiki 借鉴):
# 为页面 frontmatter.sources 写入模块组件对应代码区间的 content_hash,
# lint 的 stale_evidence 检查据此在代码漂移时报复核提醒(证据不自动改写)。
auto_evidence: true
# 是否强制 OKF(Open Knowledge Format)v0.2 frontmatter。
# true 时每个 .md 文件必须以 YAML frontmatter 开头,包含 type/title/description/tags 字段,
# 以及 v0.2 溯源/生命周期字段(generated/status/stale_after)
okf_frontmatter: true
# 遵循的 OKF 规范版本,写入 wiki/index.md 的 okf_version 字段(§12)
okf_version: "0.2"
# 知识保鲜期(天)。write_doc_file / ingest_note 据此计算 stale_after 日期,
# 过期后 lint 的 okf_conformance 检查会提示复核(§5.5)。
# 对 notes/ 而言此值只是 freshness 未配置时的回退(见下方 freshness 节)。
default_stale_days: 90
# 类型感知的新鲜度窗口(新鲜度机制专项,docs/新鲜度机制设计方案.md)。
# 笔记的 stale_after 在 ingest/confirm 时按 note_type 查表计算:
# confirm 之后,该类知识在窗口内视为新鲜;超窗后进入 lint 的 stale_notes
# 复核提醒(confirm_note 续期 或 retire_note 退役),而不是自动作废。
# 回退链:by_type[type] → default_window_days → default_stale_days → 90。
freshness:
default_window_days: 180 # 全局默认窗口(by_type 缺省类型用)
retrieval_defer_days: 60 # 复核期过后若近期被检索过则顺延(活跃度豁免)
by_type:
workaround: 45 # 临时方案天然短命
known_issue: 60 # 已知问题通常随修复而失效
general: 120
pitfall: 180 # 坑的保质期较长
lesson: 180
bug_fix: 180
decision: 365 # 决策长期有效,除非被新决策推翻
architecture: 365 # 架构事实最长寿
# 使用信号反馈(U 线,docs/知识飞轮增强设计方案-P0三项.md §3):
# 把 retrieval_stats.db 的检索热度接入 BM25 排序(final = BM25 × authority × heat)。
# heat = 1 + min(boost_cap, 0.03 × ln(1 + hit_count))
# − cold_penalty(仅当 hit_count ≥ cold_min_hits 且 last_hit 超过 cold_days 天)
# 无检索记录的文档 heat = 1.0(新文档不受影响,规避马太效应);
# enabled=false 时排序行为与关闭前完全一致(结果条目仍携带 usage 字段)。
usage_ranking:
enabled: true
boost_cap: 0.15 # 热度增益上限(heat 上界 ~1.15)
cold_penalty: 0.2 # 冷文档惩罚幅度(heat 下界 0.8)
cold_days: 180 # 距最近一次命中的天数超过此值视为冷
cold_min_hits: 3 # 只有「热过后来冷」的文档才受罚
adopted_weight: 0.06 # 采纳权重(实际引用 vs 单纯召回,2 倍关系;设 0 关闭采纳影响)
low_adoption: # lint low_adoption 检查:高频召回却零采纳的笔记
min_hits: 5 # 触发检查的最低召回次数
max_adopted: 0 # 采纳次数上限(超过则视为已满足需求)
recent_days: 60 # 仅统计近期仍被检索的(历史冷文档归 stale_notes 管)
# P1 C 线:笔记晋升正式 wiki 页面的门槛(wiki_stats.promotion_candidates 判定用)
promotion:
min_adopted: 3 # 被采纳次数下限
min_age_days: 14 # 笔记树龄下限(防新笔记速通)
# T2 团队遥测:per-user 使用信号事件流(.meta/telemetry/<user_id>.jsonl,入库共享)。
# query_wiki 的检索命中与采纳记录以 user_id(优先 CODEWIKI_USER 环境变量,回退
# git config user.name / 系统登录名)署名写入,聚合(热度排序/采纳计数/冷启动检查)
# 纯内存进行。enabled=false 时写入切到 .meta/telemetry-local/(gitignore,纯本机
# 退化模式),聚合逻辑不变(两个目录都会扫描)。user_id 不鉴权,仅作命名空间;
# 不愿以 git 真名署名的成员可用 CODEWIKI_USER 设置花名。
telemetry:
enabled: true
# 团队化 git 同步策略(Phase 4)。mode: off 完全静默;advisory(默认)
# 每进程每仓一次只读 git fetch 检测远端分叉,结果作为告警附在
# ingest_note / write_doc_file 返回中,不阻断、不改动工作区;
# session_ff_only / auto_push(第二刀)仅限"repowiki 所在仓不含业务
# 代码"的 harness/工作区根仓显式开启。
git_sync:
mode: advisory
auto_push: false
# 全局默认标签列表,会自动追加到每个文档的 frontmatter tags 中。
# 例如 [project-x, v2] 会让所有文档带上这些标签,便于跨项目检索
okf_tags: []
module_naming: snake_case
note_types:
workaround:
freshness_days: 45
promote_to: query
merge_fields:
body: append
related_modules: replace
title: replace
tags: union
known_issue:
freshness_days: 60
promote_to: query
merge_fields:
body: append
related_modules: replace
title: replace
tags: union
general:
freshness_days: 120
promote_to: ''
merge_fields:
body: append
related_modules: replace
title: replace
tags: union
pitfall:
freshness_days: 180
promote_to: query
merge_fields:
body: append
related_modules: replace
title: replace
tags: union
lesson:
freshness_days: 180
promote_to: concept
merge_fields:
body: append
related_modules: replace
title: replace
tags: union
bug_fix:
freshness_days: 180
promote_to: query
merge_fields:
body: append
related_modules: replace
title: replace
tags: union
decision:
freshness_days: 365
promote_to: concept
merge_fields:
body: append
related_modules: replace
title: replace
tags: union
architecture:
freshness_days: 365
promote_to: concept
merge_fields:
body: append
related_modules: replace
title: replace
tags: union
procedure:
freshness_days: 180
promote_to: ''
merge_fields:
body: append
related_modules: replace
title: replace
tags: union
# ── 必需章节(兼容键) ─────────────────────────────────────────────────────
# 模块章节的权威配置是 page_types.module.required_sections;
# 这里仅作旧版回退。显式空列表会关闭结构要求,但证据与反凑字数规则仍生效。
required_sections:
- title: Positioning and Boundaries
- title: Component Responsibilities
- title: Architecture and Data Flow
- title: Key Call Chains
- title: Detailed Implementation
- title: Constraints and Failure Modes
- title: Testing and Validation
- title: Dependencies and Known Limitations-c3
documentation_dimensions:
- architecture_decisions # 架构决策:为什么选择这种设计,有哪些权衡
- api_contracts # API 契约:公开接口的输入输出、错误码、版本兼容
- data_model_changes # 数据模型变更:核心数据结构的演进历史和迁移策略
- dependency_rationale # 依赖理由:为什么引入某个外部依赖,替代方案是什么
- build_entrypoints # 构建入口:Make/脚本/manifest 如何构建、验证与运行
- ci_workflows # CI 工作流:触发、job、runner 与校验步骤
- container_runtime # 容器运行:镜像、stage、端口、服务依赖与数据流
- deployment_topology # 部署拓扑:Compose/基础设施如何编排与暴露服务
# ── 增量更新策略 ─────────────────────────────────────────────────────────
update_policy:
# 代码变更时的更新策略:
# update_affected — 只更新受影响的模块(默认,推荐)
# full_regen — 全量重新生成所有文档
# skip — 不自动更新,仅标记过时
on_code_change: update_affected
# 增量更新时是否保留文档中已有的架构决策描述(不被新代码覆盖)。
# true 时 edit_doc_file 只更新变更部分,保留人工撰写的设计说明
preserve_decisions: true
# 子模块更新后是否级联刷新父模块总览和 overview.md。
# true 确保总览文档始终反映最新子模块状态
cascade_to_overview: true
# ── Lint 检查配置 ────────────────────────────────────────────────────────
lint:
# 「未文档化组件」检查的阈值:当一个模块中未文档化的组件数量超过此值时,
# lint 报 warning。设大一些可减少噪音,设小则更严格
high_impact_threshold: 5
# 模块页深度检查:缺失/空章节、实现章节缺代码行号、验证章节缺测试证据。
# 默认 warning,不阻塞写入;enabled=false 可关闭,severity 可改为 info/error。
documentation_depth:
enabled: true
severity: warning
# 页内退化检查:重复段落/长句/短行、无标点循环、相对来源异常膨胀。
# 默认 warning,不阻塞写入;enabled=false 可关闭,severity 可改为 info/error。
# 异常增长只在调用方提供 source_char_count 时判定。
page_degeneration:
enabled: true
severity: warning
min_repeated_chars: 200
paragraph_repeat_ratio: 0.05
sentence_repeat_ratio: 0.10
short_line_repeat_ratio: 0.20
short_line_min_occurrences: 9
growth_min_chars: 16000
growth_multiplier: 4
# ── LLM Wiki 知识层配置 ──────────────────────────────────────────────────
# 以下配置控制 Wiki 结构化布局、页面类型路由和知识提取行为。
# 修改后重新 analyze_repo 即可生效;已有项目的 schema.yaml 增量合并时保留用户自定义值。
# 页面类型路由表:每种类型对应 wiki/ 下的一个子目录。
# 可自定义 directory(输出目录)、description(描述,会注入到 LLM 提示词)、required_sections(必需章节)。
# 新增类型时,在 schema.yaml 中添加即可,page_router.py 会自动识别。
page_types:
module:
directory: wiki/modules
description: 代码模块文档,描述一个功能模块的架构、组件和依赖
# 模块章节的权威配置;非空列表覆盖顶层 required_sections 和内置默认。
# 显式空列表 [] 关闭结构要求,但不会关闭证据与反凑字数规则。
required_sections:
- title: Positioning and Boundaries
- title: Component Responsibilities
- title: Architecture and Data Flow
- title: Key Call Chains
- title: Detailed Implementation
- title: Constraints and Failure Modes
- title: Testing and Validation
- title: Dependencies and Known Limitations
entity:
directory: wiki/entities
description: 关键类、接口、数据模型、API 端点的独立文档
required_sections:
- 职责描述
- 公开 API
- 使用示例
- 依赖关系
concept:
directory: wiki/concepts
description: 设计模式、架构理念、领域概念的文档
required_sections:
- 概念定义
- 适用场景
- 在本项目中的应用
source:
directory: wiki/sources
description: 第三方文档(SDK/API/框架文档)的摘要
required_sections:
- 文档概述
- 关键 API/概念
- 与本项目相关的部分
comparison:
directory: wiki/comparisons
description: 方案对比、技术选型分析
required_sections:
- 背景与目标
- 候选方案
- 对比分析
- 结论与决策
query:
directory: wiki/queries
description: 方案设计决策记录,包含推理过程和权衡
required_sections:
- 问题描述
- 调研过程
- 方案权衡
- 决策结论
# skill-creator (issue #24, ADR-0004):技能草稿区。注意 directory 是
# output_dir 相对路径——skills/ 在 repowiki 根(与 notes/ 同层的知识资产),
# 不在 wiki/ 代码文档层;生效区在仓库根 .codebuddy/skills/,repowiki 不扫描。
# 正文五段骨架与 scenario 同构(When to Apply ≈ 适用条件,Instructions ≈ SOP)。
skill:
directory: skills
description: 从已确认知识编译的 SKILL.md 行为指令草稿(两区制草稿区:进索引进 lint、不生效),由 skill_creator
生成,经确认后 install 到生效区
required_sections:
- 工作场景
- 适用条件
- 核心 SOP
- 判断逻辑
- 禁忌与反模式
# 提取粒度:控制 extraction_scan 提示词扫描源码时提取实体/概念的密度。
# focused — 3-7 个关键项,适合小型项目或快速概览
# standard — 适度提取,默认值
# exhaustive — 全面提取,适合大型项目的深度文档化
extraction_granularity: exhaustive
# Wiki 链接语法:启用后,文档后处理会将标识符替换为 [[slug|display]] 格式。
wiki_link_syntax: false
project:
name: CodeWiki-Plus
languages:
- python
total_components: 3570
generated_at: '2026-12-01T11:15:49.972267'
version: 1
export:
html: false