nium-wiki
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseNium Wiki Generator
Nium Wiki Generator
Produce professional-grade, domain-organized project Wiki under the directory.
.nium-wiki/Core Principle: Generated documentation must be detailed, structured, diagrammed, and cross-linked, meeting enterprise-level technical documentation standards.
在目录下生成专业级、按领域划分的项目Wiki文档。
.nium-wiki/核心原则:生成的文档必须详细、结构化、配有图表且具备交叉链接,符合企业级技术文档标准。
Quality Gate for Generated Documentation
生成文档的质量门槛
MANDATORY: Every piece of generated documentation MUST satisfy the following criteria:
强制要求:所有生成的文档必须满足以下标准:
Depth of Coverage
覆盖深度
- Provide full context for every topic — never leave bare lists or placeholder outlines
- Write specific, explanatory descriptions that address the WHY and HOW behind each concept
- Supply runnable code examples paired with their expected output (🔴 secrets must be sanitized - see "Secret & Credential Sanitization")
- Call out edge cases, caveats, and common mistakes explicitly
Substantive content: A section has real content if it contains ≥ 3 non-empty, non-heading lines, OR at least one code block, diagram, or table. A heading followed by a single sentence or a bare list does not count.
- 为每个主题提供完整上下文——绝不留下空列表或占位符大纲
- 撰写具体、具备解释性的描述,阐明每个概念背后的原因与实现方式
- 提供可运行的代码示例及预期输出(🔴 必须清理敏感信息 - 参见「机密信息与凭证脱敏」)
- 明确标注边缘情况、注意事项及常见错误
实质性内容定义:若某章节包含≥3条非空、非标题的内容,或至少一个代码块、图表、表格,则视为具备真实内容。仅标题加单句或空列表不满足要求。
Structural Conventions
结构规范
- Organize content with hierarchical headings (H2 → H3 → H4) to form a clear information hierarchy
- Summarize key concepts in tables for scanability
- Illustrate processes and flows using Mermaid diagrams
- Interconnect documents via cross-links
- 使用层级标题(H2 → H3 → H4)组织内容,形成清晰的信息层级
- 将关键概念汇总为表格,提升可读性
- 使用Mermaid图表展示流程与逻辑
- 通过交叉链接实现文档间的互联互通
🔴 MANDATORY: Link Path Format
🔴 强制要求:链接路径格式
ALL source file links MUST use project-root-relative POSIX paths starting with. NEVER use/URIs, absolute filesystem paths, or OS-specific paths. The IDE/editor may provide file paths asfile://— you MUST strip the prefix and convert tofile:///Users/.../project/src/foo.ts./src/foo.ts
| ❌ Wrong | ✅ Correct | Reason |
|---|---|---|
| | Strip |
| | Must start with |
| | No Windows paths |
Conversion rule: Given any absolute path, remove everything up to and including the project root directory name, then prepend . Example: → .
/file:///home/user/my-project/src/core/foo.ts/src/core/foo.ts所有源文件链接必须使用以开头的、相对于项目根目录的POSIX路径。 禁止使用/URI、绝对文件系统路径或特定操作系统路径。 若IDE/编辑器提供的文件路径为file://,必须移除前缀并转换为file:///Users/.../project/src/foo.ts。/src/foo.ts
| ❌ 错误格式 | ✅ 正确格式 | 原因 |
|---|---|---|
| | 移除 |
| | 必须以 |
| | 禁止使用Windows路径 |
转换规则:对于任意绝对路径,移除项目根目录名称及之前的所有内容,然后添加前缀。示例: → 。
/file:///home/user/my-project/src/core/foo.ts/src/core/foo.ts🔴 MANDATORY: Secret & Credential Sanitization
🔴 强制要求:机密信息与凭证脱敏
CRITICAL: NEVER include actual secrets, credentials, API keys, or sensitive information in generated documentation.
MANDATORY sanitization rules:
| Scenario | Action | Example |
|---|---|---|
| Hard-coded API keys in source | Replace with placeholders | |
| Database credentials | Redact or use example values | |
| Private tokens/keys | Mask with descriptive placeholders | |
| Environment vars with secrets | Show safe example values | |
Sanitization pattern library:
- API keys: ,
sk_live_XXXXXXXX,pk_test_XXXXXXXXapi_key_XXXXXXXX - Passwords: ,
***REDACTED***<your-password-here> - Tokens: ,
<your-access-token><auth-token-here> - Generic: ,
XXXXXXXX,<secret-value><sensitive-data>
Exception: Mermaid diagrams, source file path links, and markdown structure MUST still be preserved unchanged (except for secret removal within code blocks).
关键要求:绝不在生成的文档中包含真实的机密信息、凭证、API密钥或敏感数据。
强制脱敏规则:
| 场景 | 操作 | 示例 |
|---|---|---|
| 源代码中硬编码的API密钥 | 替换为占位符 | |
| 数据库凭证 | 隐藏或使用示例值 | |
| 私有令牌/密钥 | 使用描述性占位符掩码 | |
| 包含机密信息的环境变量 | 展示安全示例值 | |
脱敏模板库:
- API密钥:,
sk_live_XXXXXXXX,pk_test_XXXXXXXXapi_key_XXXXXXXX - 密码:,
***REDACTED***<your-password-here> - 令牌:,
<your-access-token><auth-token-here> - 通用占位符:,
XXXXXXXX,<secret-value><sensitive-data>
例外情况:Mermaid图表、源文件路径链接及Markdown结构必须保持不变(代码块中的机密信息除外,需移除)。
Diagram Requirements (at least 2-3 per document)
图表要求(每份文档至少2-3个)
| Content Type | Diagram Type | Condition |
|---|---|---|
| System architecture | | always |
| Request / data flow | | always |
| Lifecycle / state transitions | | only for stateful modules |
| Class / Interface shape | | only when source is read |
| Module dependencies | | always |
| Data models / ORM | | when project has database/ORM |
| Module conceptual relationships | | optional, for abstract module relationships only (NOT file trees) |
Diagram diversity: Count ≥ 2 distinct diagram types toward the minimum. Three identical flowcharts do not satisfy the requirement — use,flowchart LR,sequenceDiagram,stateDiagram-v2as appropriate for the module.erDiagramNote:is optional and does not count toward the ≥ 2 distinct types requirement. It may supplement but never replace the required diagram types above.mindmap
Layout rules: Choose direction by content — for hierarchies, for flows/dependencies. Use to group related nodes when count > 6. Apply color coding to highlight key nodes.
TBLRsubgraphstyleFile/directory structure MUST use plain-text tree format (├──), NEVER use Mermaid diagrams (including└──). Mermaidmindmapis only for showing abstract conceptual relationships between modules, never for file paths or directory trees.mindmap
| 内容类型 | 图表类型 | 适用条件 |
|---|---|---|
| 系统架构 | 带子图的 | 始终适用 |
| 请求/数据流 | | 始终适用 |
| 生命周期/状态转换 | | 仅适用于有状态模块 |
| 类/接口结构 | 展示类型/模块关系的 | 仅在读取源代码时使用 |
| 模块依赖 | | 始终适用 |
| 数据模型/ORM | | 当项目包含数据库/ORM时适用 |
| 模块概念关系 | | 可选,仅用于展示抽象模块关系(不用于文件树) |
图表多样性要求:至少需要2种不同类型的图表满足最低要求。三个相同的流程图不符合要求——需根据模块情况选择、flowchart LR、sequenceDiagram、stateDiagram-v2等合适的类型。erDiagram注意:为可选图表,不计算在≥2种不同类型的要求内。它可作为补充,但绝不能替代上述必填图表类型。mindmap
布局规则:根据内容选择方向——用于层级结构,用于流程/依赖关系。当节点数量>6时,使用对相关节点进行分组。使用颜色编码突出关键节点。
TBLRsubgraphstyle文件/目录结构必须使用纯文本树形格式(├──),禁止使用Mermaid图表(包括└──)。 Mermaidmindmap仅用于展示模块间的抽象概念关系,绝不用于文件路径或目录树。mindmap
🔴 Mermaid Syntax Safety Rules (MANDATORY — Read Before Every Diagram)
🔴 Mermaid语法安全规则(强制要求——生成图表前必读)
⚠️ HARD REQUIREMENT: Before generating ANY Mermaid diagram, you MUST read refs/mermaid-syntax.md in full. Generating without reading this file is a hard requirement violation.
✅ Hard Rules — parser errors (must fix). ⚠️ Suggestions — best practices.
| Category | Rule | Wrong ❌ | Correct ✅ |
|---|---|---|---|
| ✅ | subgraph ID must not collide with node ID | | |
| ✅ | Unescaped quotes in plain labels | | |
| ✅ | Reserved keywords as IDs | | |
| ⚠️ | Plain labels preferred for simple text | | |
| ⚠️ | Alphanumeric IDs preferred | | |
| ⚠️ | English subgraph IDs preferred | | |
Complexity grouping (when nodes > 6):
| Node Count | Strategy |
|---|---|
| ≤ 6 | Linear — no grouping needed |
| 7-12 | |
| 13-20 | Layered abstraction (overview + detail) |
| > 20 | Split into multiple diagrams |
Example — Grouped vs waterfall:
mermaid
%% WRONG — narrow waterfall
flowchart TD
A --> B --> C --> D --> E --> F --> G --> H
%% CORRECT — grouped by phase
flowchart TD
subgraph Phase1[Phase 1]
A --> B
end
subgraph Phase2[Phase 2]
C --> D --> E
end
Phase1 --> Phase2⚠️ 硬性要求:在生成任何Mermaid图表之前,必须完整阅读refs/mermaid-syntax.md。未阅读此文件即生成图表属于严重违规。
✅ 硬性规则——解析错误(必须修复)。⚠️ 建议——最佳实践。
| 类别 | 规则 | 错误示例 ❌ | 正确示例 ✅ |
|---|---|---|---|
| ✅ | 子图ID不能与节点ID冲突 | | |
| ✅ | 纯文本标签中的引号必须转义 | | |
| ✅ | 保留关键字不能作为ID | | |
| ⚠️ | 简单文本优先使用纯标签 | | |
| ⚠️ | 优先使用字母数字ID | | |
| ⚠️ | 子图ID优先使用英文 | | |
复杂度分组策略(节点数>6时):
| 节点数量 | 策略 |
|---|---|
| ≤ 6 | 线性排列——无需分组 |
| 7-12 | 使用 |
| 13-20 | 分层抽象(概览+细节) |
| > 20 | 拆分为多个图表 |
示例——分组式 vs 瀑布式:
mermaid
%% WRONG — 狭窄瀑布式
flowchart TD
A --> B --> C --> D --> E --> F --> G --> H
%% CORRECT — 按阶段分组
flowchart TD
subgraph Phase1[Phase 1]
A --> B
end
subgraph Phase2[Phase 2]
C --> D --> E
end
Phase1 --> Phase2🔴 MANDATORY: Source File Back-References
🔴 强制要求:源文件反向引用
Each section MUST end with links back to the originating source files (see "Link Path Format" above for path rules):
markdown
**Source references**
- [cli.ts](/src/cli.ts#L1-L50)
- [index.ts](/src/index.ts#L20-L80)
**Diagram data sources**
- [core/analyzeProject.ts](/src/core/analyzeProject.ts#L1-L100)每个章节末尾必须添加指向原始源文件的链接(路径规则参见「链接路径格式」):
markdown
**源文件参考**
- [cli.ts](/src/cli.ts#L1-L50)
- [index.ts](/src/index.ts#L20-L80)
**图表数据源**
- [core/analyzeProject.ts](/src/core/analyzeProject.ts#L1-L100)🔴 MANDATORY: Source Attribution for Code Block Excerpts
🔴 强制要求:代码块摘录的源文件归属标注
Any code block that is a direct excerpt from a source file (function body, class definition, type definition, import/export statement) MUST carry a source attribution line immediately above the code block. This applies to , , , , , , and other language source files.
.ts.js.py.go.rs.java⚠️ CRITICAL: The attribution line MUST be placed outside the code fence (above the opening ```), using plain text format without any language-specific comment syntax (no,//,#, etc.). The attribution line is plain text, and the Markdown link inside it will be rendered as a clickable link./* */
✅ CORRECT format:
markdown
[Source: cli.ts](/src/cli.ts#L42-L67)
```typescript
const result = cli.parse(process.argv);
**❌ WRONG formats (links will NOT be clickable)**:
```markdown
// Wrong: Inside the code block as a comment — the link won't work
```typescript
// Source: [cli.ts](/src/cli.ts#L42-L67)
const result = cli.parse(process.argv);markdown
// Wrong: Uses comment syntax (//, #, etc.) — renders as code, not text
// [Source: cli.ts](/src/cli.ts#L42-L67)
```typescript
const result = cli.parse(process.argv);
Attribution is **not required** for:
| Content type | Example | Why no attribution |
|---|---|---|
| Usage / call-site examples | `cli.run(['--help'])` | Calling code, not source excerpt |
| Teaching / invented examples | Any code that does not exist in the source | Not in any source file |
| Mermaid / shell / CLI commands | `flowchart TD\n A --> B` | Not source code |
| Output / runtime results | `// Output: { id: 1 }` | Results, not source |任何直接从源文件摘录的代码块(函数体、类定义、类型定义、导入/导出语句)必须在代码块上方立即添加源文件归属标注行。此规则适用于、、、、、等各类语言的源文件。
.ts.js.py.go.rs.java⚠️ 关键要求:归属标注行必须放在代码围栏外部(在开头```上方),使用纯文本格式禁止使用任何语言特定的注释语法(如、//、#等)。归属标注行是纯文本,其中的Markdown链接会被渲染为可点击的链接。/* */
✅ 正确格式:
markdown
[Source: cli.ts](/src/cli.ts#L42-L67)
```typescript
const result = cli.parse(process.argv);
**❌ 错误格式(链接无法点击)**:
```markdown
// 错误:放在代码块内作为注释——链接无法生效
```typescript
// Source: [cli.ts](/src/cli.ts#L42-L67)
const result = cli.parse(process.argv);markdown
// 错误:使用注释语法(//、#等)——会被渲染为代码而非文本
// [Source: cli.ts](/src/cli.ts#L42-L67)
```typescript
const result = cli.parse(process.argv);
以下内容无需添加归属标注:
| 内容类型 | 示例 | 无需标注原因 |
|---|---|---|
| 使用/调用示例 | `cli.run(['--help'])` | 调用代码,而非源文件摘录 |
| 教学/虚构示例 | 任何不存在于源文件中的代码 | 不属于任何源文件 |
| Mermaid/Shell/CLI命令 | `flowchart TD\n A --> B` | 不属于源代码 |
| 输出/运行结果 | `// Output: { id: 1 }` | 运行结果,而非源代码 |🔴 MANDATORY: Complexity-Scaled Quality Targets
🔴 强制要求:按复杂度分级的质量目标
Quality standards scale with module complexity — not fixed numbers.
| Module Role | Doc Depth | Code Examples | Diagrams |
|---|---|---|---|
| core | Comprehensive (use | 5+ | 2+ |
| util / config | Concise (use | 1-2 | 1 |
| test / example | Minimal (use | 1 | optional |
General rules: larger source files → longer docs; more exports → more examples; more dependents → more diagrams.
In incremental mode, these targets are overridden — see Mode Overrides.
质量标准随模块复杂度调整——而非固定数值。
| 模块角色 | 文档深度 | 代码示例数量 | 图表数量 |
|---|---|---|---|
| core(核心模块) | 全面(使用 | 5+ | 2+ |
| util / config(工具/配置模块) | 简洁(使用 | 1-2 | 1 |
| test / example(测试/示例模块) | 极简(使用 | 1 | 可选 |
通用规则:源文件越大→文档越长;导出内容越多→示例越多;依赖模块越多→图表越多。
在增量模式下,这些目标会被覆盖——参见「模式覆盖」。
Module Document Sections
模块文档章节
Use (11 sections) for core modules, (6 sections) for util/config/helper modules.
module.mdmodule-simple.mdFull template () — for core modules:
module.md| # | Section | Content | Lines Target | Diagram |
|---|---|---|---|---|
| 1 | Overview | Intro + value proposition + architecture role | 2-3 paragraphs | — |
| 2 | Architecture Position | Mermaid diagram highlighting module position | — | flowchart TB |
| 3 | Feature Table | Features with related APIs | N features | — |
| 4 | File Structure | File tree + responsibilities | tree | — |
| 5 | Core Workflow | Mermaid flowchart | — | sequenceDiagram |
| 6 | State Diagram | ⚡ OPTIONAL — only for stateful modules | OPTIONAL | stateDiagram-v2 |
| 7 | API Summary | Overview table + link to api.md (no detailed signatures) | table + link | — |
| 8 | Usage Examples | 1-3 examples (first = Quick Start) | 5+ (core) / 1-2 (util) | — |
| 9 | Best Practices | Recommended / avoid patterns | recommended/avoid | — |
| 10 | Design Decisions | ⚡ OPTIONAL — only for core modules with significant choices | OPTIONAL | — |
| 11 | Dependencies & Related Docs | Dependency diagram + cross-links | — | flowchart LR |
Lightweight template () — for util/config/helper/test modules:
module-simple.md| # | Section | Content |
|---|---|---|
| 1 | Overview | 1 paragraph |
| 2 | API Summary | Overview table + link to api.md |
| 3 | Usage Examples | 1-2 examples |
| 4 | File Structure | File tree |
| 5 | Best Practices | ⚡ OPTIONAL |
| 6 | Related Docs | Cross-links |
Template selection: Before generating each module's documentation, run to get structured signals. Use as the primary signal — it appears as in the JSON output:
cd <skill-root> && node scripts/index.cjs analyze-module <module-path> --jsondocScope"docScope": "core" | Use this template | Lines target | Diagrams |
|---|---|---|---|
| | 400+ | 2+ distinct types required |
| | 80-150 | optional |
| | 30-50 | none |
The and fields are also present in the output and are based on quantifiable metrics but are overrideable: your semantic understanding of the module's business role takes precedence.
templateRecommendationroleRecommendationCode provides signals. You make the final decision.
核心模块使用(11个章节),工具/配置/辅助模块使用(6个章节)。
module.mdmodule-simple.md完整模板()——适用于核心模块:
module.md| # | 章节 | 内容 | 行数目标 | 图表类型 |
|---|---|---|---|---|
| 1 | 概述 | 介绍+价值定位+架构角色 | 2-3段 | — |
| 2 | 架构定位 | 展示模块位置的Mermaid图表 | — | flowchart TB |
| 3 | 特性表格 | 特性及相关API | N个特性 | — |
| 4 | 文件结构 | 文件树+职责说明 | 树形结构 | — |
| 5 | 核心工作流 | Mermaid流程图 | — | sequenceDiagram |
| 6 | 状态图 | ⚡ 可选——仅适用于有状态模块 | 可选 | stateDiagram-v2 |
| 7 | API摘要 | 概览表格+指向api.md的链接(不含详细签名) | 表格+链接 | — |
| 8 | 使用示例 | 1-3个示例(第一个为快速入门) | 核心模块≥5行 / 工具模块1-2行 | — |
| 9 | 最佳实践 | 推荐/避免的模式 | 推荐/避免项 | — |
| 10 | 设计决策 | ⚡ 可选——仅适用于有重大选择的核心模块 | 可选 | — |
| 11 | 依赖与相关文档 | 依赖图表+交叉链接 | — | flowchart LR |
轻量模板()——适用于工具/配置/辅助/测试模块:
module-simple.md| # | 章节 | 内容 |
|---|---|---|
| 1 | 概述 | 1段文字 |
| 2 | API摘要 | 概览表格+指向api.md的链接 |
| 3 | 使用示例 | 1-2个示例 |
| 4 | 文件结构 | 文件树 |
| 5 | 最佳实践 | ⚡ 可选 |
| 6 | 相关文档 | 交叉链接 |
模板选择规则:在生成每个模块的文档前,运行获取结构化信号。以作为主要判断信号——JSON输出中会显示:
cd <skill-root> && node scripts/index.cjs analyze-module <module-path> --jsondocScope"docScope": "core" | 使用模板 | 行数目标 | 图表要求 |
|---|---|---|---|
| | ≥400行 | 至少2种不同类型 |
| | 80-150行 | 可选 |
| 仅 | 30-50行 | 无 |
输出中还包含和字段,它们基于量化指标生成,但可被覆盖:你对模块业务角色的语义理解优先级更高。
templateRecommendationroleRecommendation代码提供信号,最终决策由你做出。
🔴 Code Examples
🔴 代码示例要求
Every code example must:
- Complete and runnable: Include import, initialization, invocation, result handling
- Cover exported interfaces: At least 1 example per major exported API
- Include comments: Explain key steps and design intent
- Match project language: Follow language best practices
- Tiered examples for core APIs (minimum 5 examples per core doc): Three levels — basic usage, advanced usage, and error handling — for each major exported function
- Sanitized secrets: NO actual credentials — use placeholders (see "Secret & Credential Sanitization" above)
每个代码示例必须满足:
- 完整可运行:包含导入、初始化、调用、结果处理
- 覆盖导出接口:每个主要导出API至少1个示例
- 包含注释:解释关键步骤与设计意图
- 匹配项目语言:遵循语言最佳实践
- 核心API的分层示例(核心文档至少5个示例):每个主要导出函数需提供三个层级的示例——基础用法、高级用法、错误处理
- 敏感信息脱敏:禁止包含真实凭证——使用占位符(参见「机密信息与凭证脱敏」)
Cross-Document Linking
跨文档链接
- Every document MUST contain a "Related Documents" section at the end
- Module docs should link outward to: architecture position, API reference, dependency graph
- API docs should link back to: parent module, usage examples, type definitions
Path format rules for "Related Docs" table ("Related Docs" in / "Dependencies & Related Docs" in ):
module-simple.mdmodule.md- Wiki page links: Use relative paths from the current doc's location. E.g., from :
modules/badge.md→ resolved to[version]({{ ../api/version.md }})../api/version.md - Source file references: Do NOT put source files (,
.ts, etc.) in the Related Docs table. Source files belong in section footers with absolute paths:.js[version.ts](/src/utils/version.ts#L1) - Wrong: — mixes wiki path prefix with source file name
[version.ts](/wiki/utils/version.md) - Wrong: — links to a wiki page, not the source file
[version.ts](../modules/version.md) - Correct (source):
[version.ts](/src/utils/version.ts#L1) - Correct (wiki page):
[API reference](../api/version.md)
- 每份文档末尾必须包含**「相关文档」**章节
- 模块文档应向外链接:架构定位、API参考、依赖图
- API文档应向内链接:父模块、使用示例、类型定义
「相关文档」表格的路径格式规则(中的「相关文档」/ 中的「依赖与相关文档」):
module-simple.mdmodule.md- Wiki页面链接:使用相对于当前文档位置的相对路径。例如,从链接:
modules/badge.md→ 解析为[version]({{ ../api/version.md }})../api/version.md - 源文件参考:不要将源文件(、
.ts等)放在「相关文档」表格中。源文件应放在章节页脚,使用绝对路径:.js[version.ts](/src/utils/version.ts#L1) - 错误示例:——混合了wiki路径前缀与源文件名
[version.ts](/wiki/utils/version.md) - 错误示例:——链接到wiki页面而非源文件
[version.ts](../modules/version.md) - 正确示例(源文件):
[version.ts](/src/utils/version.ts#L1) - 正确示例(wiki页面):
[API参考](../api/version.md)
Facts-First Rule
事实优先规则
Before writing any API description, function signature, or export list for a module:
- Read
.nium-wiki/cache/facts/<module-path-with-slashes-replaced-by-double-underscores>.json - All export names and signatures in the documentation MUST match in the facts file
exports[] - If a symbol is not in , do not document it as a public API. If
exports[]contains symbols not yet in the document, add them.exports[] - If the facts file does not exist, run before proceeding — this writes facts to
cd <skill-root> && node scripts/index.cjs analyze-batch <project-root>. Do NOT generate documentation without facts..nium-wiki/cache/facts/
在撰写任何模块的API描述、函数签名或导出列表前:
- 读取
.nium-wiki/cache/facts/<模块路径(斜杠替换为双下划线)>.json - 文档中的所有导出名称和签名必须与事实文件中的匹配
exports[] - 若某个符号不在中,请勿将其作为公共API记录。若
exports[]包含文档中未提及的符号,需添加进去。exports[] - 若事实文件不存在,先运行——此命令会将事实写入
cd <skill-root> && node scripts/index.cjs analyze-batch <project-root>。禁止在无事实文件的情况下生成文档。.nium-wiki/cache/facts/
Multi-Module Generation Mode
多模块生成模式
When generating documentation for multiple modules at once using :
analyze-batch- Run to get the full module list
cd <skill-root> && node scripts/index.cjs discover-modules <project-root> --json - Run to extract facts for all modules
cd <skill-root> && node scripts/index.cjs analyze-batch <project-root> - Output one summary table before starting generation:
- Total modules discovered
- Modules with (list paths and reasons)
needsReview: true - Estimated documents to generate
- For modules with : pause and list them with their reason (
needsReview: trueorconfidence < 0.3). Wait for user confirmation before generating those modules. All other modules proceed automatically.secret detected - Do NOT output a per-module Exploration Report in Multi-Module Generation Mode — the summary table replaces it.
当使用同时生成多个模块的文档时:
analyze-batch- 运行获取完整模块列表
cd <skill-root> && node scripts/index.cjs discover-modules <project-root> --json - 运行提取所有模块的事实
cd <skill-root> && node scripts/index.cjs analyze-batch <project-root> - 在开始生成前输出一个汇总表格:
- 发现的模块总数
- 标记为的模块(列出路径及原因)
needsReview: true - 预计生成的文档数量
- 对于标记为的模块:暂停并列出它们及原因(
needsReview: true或检测到敏感信息)。等待用户确认后再生成这些模块。其他模块自动继续。confidence < 0.3 - 在多模块生成模式下,请勿输出每个模块的探索报告——汇总表格替代了该报告。
Incremental Facts Rule
增量事实规则
On patch operations (updating existing documentation after code changes), run this before Step 1 (Read the baseline) of the Surgical Edit sequence:
- Re-read the module's even if the document already exists
facts.json - The facts file is the authoritative source for what the current API looks like
- The existing document is a starting point for structure, not a source of truth for API signatures
在补丁操作(代码变更后更新现有文档)时,在「精准编辑:修改现有文档」流程的**步骤1(读取基线)**之前运行以下操作:
- 重新读取模块的,即使文档已存在
facts.json - 事实文件是当前API状态的权威来源
- 现有文档仅作为结构起点,而非API签名的事实来源
Mode Overrides
模式覆盖
Applies when: Running in incremental mode, triggered by thepipeline. Priority: These overrides take precedence over the Quality Gate rules above. See Surgical Edit: Modifying Existing Docs for the full execution guide.incremental
| Quality Gate Rule | Incremental Mode Behavior |
|---|---|
| core doc ≥ 5 code examples | Add 0–1 example only when a new API is introduced by the changed source |
| ≥ 2 distinct diagram types | Do NOT regenerate any diagram — preserve existing diagrams unchanged |
Full 11-section | Patch only the affected section(s) based on which source files are listed in |
| Skip unless the class was modified and its source was read |
| API summary must cover all exports | Only cover exports that changed |
| core doc ≥ 400 lines | No minimum — a 50-line targeted patch is preferable to a 400-line rewrite |
| ≥ 3 source reference links | Only links related to changed source files |
适用场景:在增量模式下运行,由流水线触发。 优先级:这些覆盖规则优先于上述质量门槛规则。 完整执行指南参见「精准编辑:修改现有文档」。incremental
| 质量门槛规则 | 增量模式行为 |
|---|---|
| 核心文档≥5个代码示例 | 仅当变更的源代码引入新API时,添加0–1个示例 |
| ≥2种不同类型的图表 | 不重新生成任何图表——保留现有图表不变 |
使用完整的11章节 | 仅修补受影响的章节,基于 |
使用 | 跳过,除非类被修改且其源文件已被读取 |
| API摘要必须覆盖所有导出 | 仅覆盖变更的导出 |
| 核心文档≥400行 | 无最低行数要求——50行的针对性补丁优于400行的重写 |
| ≥3个源文件参考链接 | 仅包含与变更源文件相关的链接 |
Input Classification
输入分类
Before invoking any CLI commands, parse the user input to determine the execution path:
| InputType | Trigger Phrases | Execution Path |
|---|---|---|
| "generate wiki", "create docs", "rebuild wiki" | Full pipeline — all modules |
| "generate wiki for X", "update X docs", "upgrade X docs" | Module-level pipeline |
| "upgrade wiki", "refresh wiki", "audit docs" | Maintenance pipeline |
| "analyze module X", "explore X" | Read-only analysis, no file writes |
在调用任何CLI命令前,解析用户输入以确定执行路径:
| 输入类型 | 触发短语 | 执行路径 |
|---|---|---|
| "generate wiki"、"create docs"、"rebuild wiki" | 完整流水线——所有模块 |
| "generate wiki for X"、"update X docs"、"upgrade X docs" | 模块级流水线 |
| "upgrade wiki"、"refresh wiki"、"audit docs" | 维护流水线 |
| "analyze module X"、"explore X" | 只读分析,不写入文件 |
Module-Targeted Generation
模块定向生成
Applies when: InputType =(user specifies a specific module). Otherwise: ForMODULE_TARGETEDmode (no module specified, e.g. "generate wiki" / "rebuild wiki"), skip this entire section and follow Multi-Module Generation Mode — the summary table there replaces the per-module Exploration Report.FULL
适用场景:输入类型 =(用户指定特定模块)。 其他情况:对于MODULE_TARGETED模式(未指定模块,例如"generate wiki" / "rebuild wiki"),跳过本节并遵循「多模块生成模式」——该模式下的汇总表格替代了每个模块的探索报告。FULL
Step 0 — Path Resolution
步骤0 — 路径解析
Extract the module path from user input:
"generate wiki for src/core/analyzeProject" → src/core/analyzeProject
"update modules/auth docs" → modules/auth
"explore utils/fileWalker" → src/utils/fileWalkerNormalize all paths relative to the project root.
从用户输入中提取模块路径:
"generate wiki for src/core/analyzeProject" → src/core/analyzeProject
"update modules/auth docs" → modules/auth
"explore utils/fileWalker" → src/utils/fileWalker将所有路径归一化为相对于项目根目录的路径。
Step 1 — Pre-flight Check
步骤1 — 预检
bash
cd <skill-root> && node scripts/index.cjs analyze-module <module-path> --jsonRead the returned and :
docScoperoleRecommendationdocScope: core → module.md (11-section, 400+ lines, 2+ diagrams)
docScope: overview → overview.md (5-section, 80-150 lines)
docScope: _index → _index.md onlyAlso read the module's facts file (Facts-First Rule):
<project-root>/.nium-wiki/cache/facts/<module-path-with-slashes-as-double-underscores>.jsonIf missing, run first.
cd <skill-root> && node scripts/index.cjs analyze-batch <project-root>Determine document state:
if wiki file already exists for this module:
→ EXPLORE_THEN_PATCH (surgical edit, preserve existing content)
else:
→ EXPLORE_THEN_GENERATE (first-time generation)bash
cd <skill-root> && node scripts/index.cjs analyze-module <module-path> --json读取返回的和:
docScoperoleRecommendationdocScope: core → module.md(11章节,≥400行,≥2个图表)
docScope: overview → overview.md(5章节,80-150行)
docScope: _index → 仅_index.md同时读取模块的事实文件(事实优先规则):
<project-root>/.nium-wiki/cache/facts/<模块路径(斜杠替换为双下划线)>.json若文件缺失,先运行。
cd <skill-root> && node scripts/index.cjs analyze-batch <project-root>确定文档状态:
若该模块的wiki文件已存在:
→ EXPLORE_THEN_PATCH(精准编辑,保留现有内容)
否则:
→ EXPLORE_THEN_GENERATE(首次生成)Step 2 — Code Exploration (Read-Only, No File Writes)
步骤2 — 代码探索(只读,不写入文件)
Read the actual source code — do not rely on file names or structure alone:
read_file: all source files in the module directory (*.ts/*.js, *.py, *.go, *.rs, *.java, *.cs, *.rb, *.php, etc.)
read_file: entry/index file (index.ts, __init__.py, mod.rs, package-info.java, etc.)
read_file: type/interface definitions if present (types.ts, types.d.ts, interfaces/, etc.)Analyze:
- Function signatures: purpose, parameters, return values, side effects
- Class hierarchies and inheritance
- Data flow paths and state mutations
- Error handling strategies
- Design patterns in use
- 🔴 Secrets detection: identify hard-coded credentials, API keys, tokens
读取实际源代码——不要仅依赖文件名或结构:
read_file: 模块目录下的所有源文件(*.ts/*.js、*.py、*.go、*.rs、*.java、*.cs、*.rb、*.php等)
read_file: 入口/索引文件(index.ts、__init__.py、mod.rs、package-info.java等)
read_file: 类型/接口定义文件(若存在,如types.ts、types.d.ts、interfaces/等)分析内容:
- 函数签名:用途、参数、返回值、副作用
- 类层次结构与继承关系
- 数据流路径与状态变更
- 错误处理策略
- 使用的设计模式
- 🔴 敏感信息检测:识别硬编码的凭证、API密钥、令牌
Step 3 — Exploration Report (Output to User, No File Writes)
步骤3 — 探索报告(输出给用户,不写入文件)
Display a structured report and await user confirmation before proceeding:
markdown
undefined展示结构化报告并等待用户确认后再继续:
markdown
undefinedModule Exploration Report: <module-name>
模块探索报告:<模块名称>
Role: <roleRecommendation>
Template: <module.md / module-simple.md>
State: <EXPLORE_THEN_GENERATE / EXPLORE_THEN_PATCH>
角色:<roleRecommendation>
模板:<module.md / module-simple.md>
状态:<EXPLORE_THEN_GENERATE / EXPLORE_THEN_PATCH>
Key Findings
关键发现
- Exports: N functions, M types
- Dependents: N modules depend on this
- 导出内容:N个函数,M个类型
- 依赖模块:N个模块依赖此模块
Recommended Sections
推荐章节
(see Module Document Sections for section list, lines targets, and diagram types)
Proceed with generation? [yes / no / customize]
**This step is mandatory.** A confirmation gate prevents generating content before understanding the code. Do not skip to Step 4 without presenting this report.(参见「模块文档章节」获取章节列表、行数目标及图表类型)
是否继续生成?[是 / 否 / 自定义]
**此步骤为强制要求**。确认环节可避免在理解代码前生成内容。未展示此报告请勿跳至步骤4。Step 4 — User Response
步骤4 — 用户响应
| Response | Action |
|---|---|
| Proceed to Step 5 using the recommended template |
| Exit — write nothing, report nothing |
| Apply user-specified section additions or removals, then proceed |
| 响应 | 操作 |
|---|---|
| 使用推荐模板继续步骤5 |
| 退出——不写入任何内容,不生成报告 |
| 应用用户指定的章节增删,然后继续 |
Step 5 — Execution
步骤5 — 执行
If returns empty (no code changes detected, but user explicitly specified a module):
incrementalSkip incremental dependency computation
Use user-specified module path as the sole target
Do NOT treat as surgical patch (no old doc to compare against)
Resume from Step 1 Pre-flight Check, then proceed to generationIf returns affected docs: use the pipeline's + to decide full vs. surgical.
incrementaltriggeredByupdateStrength若返回空(未检测到代码变更,但用户明确指定了模块):
incremental跳过增量依赖计算
使用用户指定的模块路径作为唯一目标
不视为精准补丁(无旧文档可对比)
从步骤1预检重新开始,然后继续生成若返回受影响的文档:使用流水线的 + 决定是完整生成还是精准补丁。
incrementaltriggeredByupdateStrengthFull Decision Tree
完整决策树
User Input
│
├─ "generate wiki" (no module specified)
│ ├─ .nium-wiki does not exist → init → FULL pipeline (Sections 1–9, + Section 10 if multi-language)
│ └─ .nium-wiki exists → FULL pipeline (Sections 1–9, + Section 10 if multi-language)
│ │
│ ├─ Section 4 runs: build-deps → discover-modules → analyze-batch
│ │ └─ Follow Multi-Module Generation Mode rules during Section 8 (Content Generation)
│ │
│ └─ After Section 4: check project size
│ ├─ module count > 10 OR source files > 50 OR LOC > 10,000
│ │ └─ Switch to Progressive Scanning (see "Progressive Scanning for Large Projects")
│ └─ otherwise → continue full pipeline normally
│
├─ "generate wiki for <module>"
│ ├─ .nium-wiki does not exist → init → MODULE_TARGETED
│ └─ .nium-wiki exists
│ ├─ incremental has changes → affected docs from pipeline
│ └─ incremental is empty → use user-specified module as target
│ → Exploration Report → User confirms → Generate
│
├─ "upgrade <module> docs"
│ └─ MODULE_TARGETED + force full regeneration
│
├─ "analyze module X"
│ └─ Run `cd <skill-root> && node scripts/index.cjs analyze-module <module-path> --json` — JSON signals only, no wiki files written
│
└─ "refresh / upgrade wiki" (no module)
└─ MAINTENANCE → audit → regenerate failing docs用户输入
│
├─ "generate wiki"(未指定模块)
│ ├─ .nium-wiki不存在 → 初始化 → FULL流水线(章节1–9,若为多语言则加章节10)
│ └─ .nium-wiki存在 → FULL流水线(章节1–9,若为多语言则加章节10)
│ │
│ ├─ 执行章节4:build-deps → discover-modules → analyze-batch
│ │ └─ 在章节8(内容生成)期间遵循多模块生成模式规则
│ │
│ └─ 章节4完成后:检查项目规模
│ ├─ 模块数>10 或 源文件数>50 或 代码行数>10,000
│ │ └─ 切换为渐进式扫描(参见「大型项目的渐进式扫描」)
│ └─ 否则 → 正常继续完整流水线
│
├─ "generate wiki for <module>"
│ ├─ .nium-wiki不存在 → 初始化 → MODULE_TARGETED
│ └─ .nium-wiki存在
│ ├─ incremental检测到变更 → 流水线返回受影响的文档
│ └─ incremental返回空 → 使用用户指定的模块作为目标
│ → 探索报告 → 用户确认 → 生成
│
├─ "upgrade <module> docs"
│ └─ MODULE_TARGETED + 强制完整重新生成
│
├─ "analyze module X"
│ └─ 运行`cd <skill-root> && node scripts/index.cjs analyze-module <module-path> --json`——仅输出JSON信号,不写入wiki文件
│
└─ "refresh / upgrade wiki"(未指定模块)
└─ MAINTENANCE → 审核 → 重新生成不合格文档Workflow
工作流程
1. CLI Commands Quick Reference
1. CLI命令速查
🔴 Execution context: Skill CWD is not guaranteed to be the skill root across Coding Agents, socannot be resolved from the default CWD. Every runnable example is written asscripts/index.cjs— the Agent MUSTcd <skill-root> && node scripts/index.cjs ...in first, then passcdas an argument.<project-root>is the directory containing this<skill-root>file. Resolve it from this file's absolute path, do not guess from agent-specific conventions.SKILL.md
bash
undefined🔴 执行上下文:在不同的编码Agent中,Skill的当前工作目录(CWD)不一定是Skill根目录,因此无法从默认CWD解析。每个可运行示例都写为scripts/index.cjs——Agent必须先cd <skill-root> && node scripts/index.cjs ...到该目录,再传入cd作为参数。<project-root>是包含此<skill-root>文件的目录。需从此文件的绝对路径解析,不要根据Agent特定的约定猜测。SKILL.md
bash
undefinedSignatures (paths shown without the cd <skill-root> &&
prefix for readability)
cd <skill-root> &&签名(为便于阅读,示例中省略了cd <skill-root> &&
前缀)
cd <skill-root> &&node scripts/index.cjs init <project-root> --lang <code> # Initialize .nium-wiki directory (lang: zh/en/ja/ko/fr/de)
node scripts/index.cjs build-deps <project-root> # Build import/require dependency graph
node scripts/index.cjs discover-modules <project-root> # Discover all modules via import graph + directory scan
node scripts/index.cjs analyze-batch <project-root> [--force] [--min-confidence <n>] # Extract facts for all modules
node scripts/index.cjs analyze-module <module-path> [--json] # Analyze one module: classify role, recommend template
node scripts/index.cjs incremental <project-root> [--no-commit] [-v] # Full pipeline: diff → deps → doc-index → affected docs
node scripts/index.cjs diff-index <project-root> # Detect file changes (--no-update to skip hash write)
node scripts/index.cjs build-index <project-root> # Build source ↔ doc mapping index
node scripts/index.cjs generate-sidebar <wiki-path> [--all] # Generate sidebar.json for all language directories
node scripts/index.cjs audit-docs <wiki-path> [--verbose|--json|--mermaid-strict|--role <role>] # Check doc quality
node scripts/index.cjs serve <wiki-path> # Start docsify server
For detailed usage, see `cd <skill-root> && node scripts/index.cjs --help`
> **⚠️ Path argument convention**: This document uses four distinct path notations — do not confuse them:
>
> | Notation | Meaning |
> |---|---|
> | `<skill-root>` | **The directory containing this `SKILL.md` file.** Always `cd` here before invoking `node scripts/index.cjs ...` so the relative path `scripts/index.cjs` resolves regardless of the Agent's default CWD |
> | `<project-root>` | **Absolute path of the user's current workspace root** — the directory the user is working in (e.g. `/Users/alice/repos/my-app`). Passed as a command argument, NOT as CWD |
> | `<module-path>` | Project-root-relative path to a single module (e.g. `src/core/analyzeProject`). Used only with `analyze-module` |
> | `<wiki-path>` | Path to the `.nium-wiki` directory, usually `<project-root>/.nium-wiki`. Used with `generate-sidebar`, `audit-docs`, `serve`, `i18n` |
>
> The Agent is responsible for substituting every placeholder with a real value before executing. Do NOT
> pass the placeholder string literally, and do NOT pass `.` — `.` would resolve against an unpredictable
> CWD depending on the host Agent.node scripts/index.cjs init <project-root> --lang <code> # 初始化.nium-wiki目录(语言代码:zh/en/ja/ko/fr/de)
node scripts/index.cjs build-deps <project-root> # 构建导入/依赖关系图
node scripts/index.cjs discover-modules <project-root> # 通过导入图+目录扫描发现所有模块
node scripts/index.cjs analyze-batch <project-root> [--force] [--min-confidence <n>] # 提取所有模块的事实
node scripts/index.cjs analyze-module <module-path> [--json] # 分析单个模块:分类角色,推荐模板
node scripts/index.cjs incremental <project-root> [--no-commit] [-v] # 完整流水线:差异检测 → 依赖分析 → 文档索引 → 受影响文档
node scripts/index.cjs diff-index <project-root> # 检测文件变更(--no-update跳过哈希写入)
node scripts/index.cjs build-index <project-root> # 构建源代码 ↔ 文档的映射索引
node scripts/index.cjs generate-sidebar <wiki-path> [--all] # 为所有语言目录生成sidebar.json
node scripts/index.cjs audit-docs <wiki-path> [--verbose|--json|--mermaid-strict|--role <role>] # 检查文档质量
node scripts/index.cjs serve <wiki-path> # 启动docsify服务器
详细用法参见`cd <skill-root> && node scripts/index.cjs --help`
> **⚠️ 路径参数约定**:本文档使用四种不同的路径表示法——请勿混淆:
>
> | 表示法 | 含义 |
> |---|---|
> | `<skill-root>` | **包含此`SKILL.md`文件的目录**。调用`node scripts/index.cjs ...`前必须先`cd`到此处,这样相对路径`scripts/index.cjs`才能在Agent的默认CWD不确定的情况下正确解析 |
> | `<project-root>` | **用户当前工作区根目录的绝对路径**——用户正在工作的目录(例如`/Users/alice/repos/my-app`)。作为命令参数传入,而非作为CWD |
> | `<module-path>` | 相对于项目根目录的单个模块路径(例如`src/core/analyzeProject`)。仅与`analyze-module`一起使用 |
> | `<wiki-path>` | `.nium-wiki`目录的路径,通常为`<project-root>/.nium-wiki`。与`generate-sidebar`、`audit-docs`、`serve`、`i18n`一起使用 |
>
> Agent负责在执行前将所有占位符替换为真实值。请勿直接传入占位符字符串,也不要传入`.`——`.`会根据宿主Agent的不同解析为不可预测的CWD。2. Language Detection (MANDATORY)
2. 语言检测(强制要求)
⚠️ CRITICAL: This step must be completed BEFORE any other operation.
Before running any CLI commands or generating any documentation:
- Check if exists
.nium-wiki/config.json - If exists: Read the field — this is the primary documentation language and the source of truth
language - If not exists: You will set it when running (determine from project's natural language + user conversation language)
init --lang <code>
Rule: Thefield inlanguageis the only authoritative source for documentation language. Do NOT infer language from source code comments, README, file names, or conversation context.config.json
⚠️ 关键要求:此步骤必须在任何其他操作之前完成。
在运行任何CLI命令或生成任何文档前:
- 检查是否存在
.nium-wiki/config.json - 若存在:读取字段——这是主要文档语言,也是唯一的事实来源
language - 若不存在:运行时设置该字段(根据项目的自然语言+用户对话语言确定)
init --lang <code>
规则:中的config.json字段是文档语言的唯一权威来源。 请勿从源代码注释、README、文件名或对话上下文推断语言。language
2.1 Language Conflict Resolution
2.1 语言冲突解决
🔴 CRITICAL: Never modifydirectly via file write or text replacement. Use the following procedures instead:config.json
| Scenario | Action |
|---|---|
Config exists, user wants to add a secondary language (e.g. config= | Run |
User wants to change the primary language (e.g. config= | Run |
| User wants to generate docs in a language already in config | No config change needed — run |
Why: Direct file edits to bypass the CLI's validation and can corrupt the JSON structure. Always go through the CLI.
config.json🔴 关键要求:绝不通过文件写入或文本替换直接修改。 请改用以下流程:config.json
| 场景 | 操作 |
|---|---|
配置已存在,用户想要添加次要语言(例如配置= | 运行 |
用户想要更改主要语言(例如配置= | 运行 |
| 用户想要生成已在配置中的语言文档 | 无需更改配置——直接运行 |
原因:直接编辑会绕过CLI的验证,可能破坏JSON结构。始终通过CLI进行操作。
config.json3. Language Configuration
3. 语言配置
Read and extract the setting.
Format is slash-separated: the first language is the primary language (e.g. , , ).
.nium-wiki/config.jsonlanguagezhenzh/en- Generate all primary documentation in the primary language to .
.nium-wiki/wiki/ - If secondary languages are configured (e.g. means primary=zh, secondary=en), after primary docs are written, translate all wiki documents into
zh/endirectories (e.g.wiki_{lang}/). See Section 10 for details..nium-wiki/wiki_en/
Convention:= primary language,wiki/= secondary language. The translated directory must mirror the exact same structure and filenames aswiki_{lang}/.wiki/
🔴 IMPORTANT: Single-language output only. Templates contain bilingual headings (e.g.) for reference purposes only. When generating documentation, output only the primary language. Do NOT mix languages or copy the## Architecture Preview / 架构预览format into the output.English / 中文
- If
islanguage: headings should been, NOT## Architecture Preview## Architecture Preview / 架构预览- If
islanguage: headings should bezh, NOT## 架构预览## Architecture Preview / 架构预览
读取并提取设置。格式为斜杠分隔:第一个语言是主要语言(例如、、)。
.nium-wiki/config.jsonlanguagezhenzh/en- 将所有主要文档以主要语言生成到目录。
.nium-wiki/wiki/ - 若配置了次要语言(例如表示主要语言=zh,次要语言=en),在生成主要文档后,将所有wiki文档翻译到
zh/en目录(例如wiki_{lang}/)。详情参见章节10。.nium-wiki/wiki_en/
约定:= 主要语言,wiki/= 次要语言。翻译后的目录必须与wiki_{lang}/的结构和文件名完全一致。wiki/
🔴 重要提示:仅输出单一语言。 模板包含双语标题(例如)仅作为参考。生成文档时,仅输出主要语言。请勿混合语言或复制## Architecture Preview / 架构预览格式到输出中。English / 中文
- 若
为language:标题应为en,而非## Architecture Preview## Architecture Preview / 架构预览- 若
为language:标题应为zh,而非## 架构预览## Architecture Preview / 架构预览
4. Project Analysis (Deep)
4. 项目深度分析
Run the following commands to build the dependency graph, discover modules, and extract facts:
bash
cd <skill-root> && node scripts/index.cjs build-deps <project-root>
cd <skill-root> && node scripts/index.cjs discover-modules <project-root>
cd <skill-root> && node scripts/index.cjs analyze-batch <project-root>is auto-triggered bybuild-depsanddiscover-modulesifanalyze-batchis missing — you can skip it if the graph is already up to date.dep-graph.json
- Identify tech stack: Check dependency manifests (e.g. package.json, requirements.txt, go.mod, Cargo.toml, pom.xml, etc.)
- Find entry points: Locate main source files (e.g. src/index.ts, main.py, main.go, main.rs, src/main/java/App.java, etc.)
- Identify modules: Use output — it merges import-graph discovery with directory scan for full coverage
discover-modules - Find existing docs: README.md, CHANGELOG.md, etc.
运行以下命令构建依赖关系图、发现模块并提取事实:
bash
cd <skill-root> && node scripts/index.cjs build-deps <project-root>
cd <skill-root> && node scripts/index.cjs discover-modules <project-root>
cd <skill-root> && node scripts/index.cjs analyze-batch <project-root>若缺失,dep-graph.json和discover-modules会自动触发analyze-batch——若依赖图已更新,可跳过build-deps。build-deps
- 识别技术栈:检查依赖清单(例如package.json、requirements.txt、go.mod、Cargo.toml、pom.xml等)
- 找到入口点:定位主源文件(例如src/index.ts、main.py、main.go、main.rs、src/main/java/App.java等)
- 识别模块:使用的输出——它结合了导入图发现与目录扫描,实现全覆盖
discover-modules - 查找现有文档:README.md、CHANGELOG.md等
5. Deep Code Analysis (CRITICAL)
5. 深度代码分析(关键步骤)
IMPORTANT: For every module, read the actual source code — do not rely on file names or directory structure alone:
- Read source files: Open key files with read_file tool
- Parse semantics: Determine what the code does, not merely how it is organized
- Capture details:
- Function signatures: purpose, parameters, return values, side effects
- Class hierarchies and inheritance chains
- Data flow paths and state mutations
- Error handling strategies
- Design patterns in use
- 🔴 Secrets detection: Identify hard-coded credentials, API keys, tokens, and sensitive data that need sanitization
- Map relationships: Module dependencies, call graphs, data flow
- Flag complexity hotspots: Functions with deep nesting (> 4 levels), high branching (> 10 conditions), or excessive length (> 100 LOC). Document these in module docs with logic explanations and refactoring suggestions.
重要提示:对于每个模块,读取实际源代码——不要仅依赖文件名或目录结构:
- 读取源文件:使用read_file工具打开关键文件
- 解析语义:确定代码的功能,而非仅关注其组织方式
- 捕获细节:
- 函数签名:用途、参数、返回值、副作用
- 类层次结构与继承链
- 数据流路径与状态变更
- 错误处理策略
- 使用的设计模式
- 🔴 敏感信息检测:识别需要脱敏的硬编码凭证、API密钥、令牌和敏感数据
- 映射关系:模块依赖、调用图、数据流
- 标记复杂度热点:深度嵌套(>4层)、高分支(>10个条件)或过长(>100行)的函数。在模块文档中记录这些内容,并提供逻辑说明和重构建议。
6. Change Detection
6. 变更检测
Use the automated incremental pipeline to detect changes and compute the precise list of affected docs in one step:
bash
cd <skill-root> && node scripts/index.cjs incremental <project-root> [--no-commit] [-v]This runs the full pipeline: → → → transitive-impact → doc-dep analysis. It outputs:
diff-indexbuild-depsbuild-index- Which source files changed (+added, ~modified, -deleted)
- Which wiki docs need regeneration (with reason: source_changed, dep_changed, doc_dep_changed, inferred)
- Which docs will be deleted
- Which docs are preserved (unchanged)
If wiki doesn't exist yet: the pipeline automatically falls back to full-generation mode.
IMPORTANT: Always runbefore generating, notincrementalalone.diff-indexonly detects source changes — it does NOT map them to wiki docs. Afterdiff-indexcompletes, always check i18n sync status (see Section 10) before declaring the update done.incremental
使用自动化增量流水线一步检测变更并计算受影响文档的精确列表:
bash
cd <skill-root> && node scripts/index.cjs incremental <project-root> [--no-commit] [-v]此命令运行完整流水线: → → → 传递性影响分析 → 文档依赖分析。输出内容包括:
diff-indexbuild-depsbuild-index- 哪些源文件发生了变更(+新增,~修改,-删除)
- 哪些wiki文档需要重新生成(原因:source_changed、dep_changed、doc_dep_changed、inferred)
- 哪些文档将被删除
- 哪些文档保留不变(未变更)
若wiki尚未存在:流水线自动回退到完整生成模式。
重要提示:生成前始终运行,而非仅运行incremental。diff-index仅检测源代码变更——无法将变更映射到wiki文档。diff-index完成后,在宣布更新完成前始终检查i18n同步状态(参见章节10)。incremental
7. Target Docs (resolved by the pipeline above)
7. 目标文档(由上述流水线解析)
The command in Section 6 already resolves this. Each affected doc includes:
incremental- : relative wiki path (e.g.
docPath)modules/core/source-index.md - : why it needs updating
reason - : source files that triggered the update
triggeredBy
Manual fallback (if pipeline not available): Read → field. If a changed source file has no entry, infer by naming convention: → , and nested paths: → .
.nium-wiki/cache/doc-index.jsonsourceToDocsrc/fooBar.tsmodules/foo-bar.mdsrc/core/analyzeProject.tsmodules/core/analyze-project.md章节6中的命令已解析出目标文档。每个受影响的文档包含:
incremental- :相对wiki路径(例如
docPath)modules/core/source-index.md - :需要更新的原因
reason - :触发更新的源文件
triggeredBy
手动回退方案(若流水线不可用):读取 → 字段。若变更的源文件无对应条目,按命名约定推断: → ,嵌套路径: → 。
.nium-wiki/cache/doc-index.jsonsourceToDocsrc/fooBar.tsmodules/foo-bar.mdsrc/core/analyzeProject.tsmodules/core/analyze-project.md8. Content Generation
8. 内容生成
🔴 Language: usefromlanguage— see Section 3. Do NOT infer from source code or conversation..nium-wiki/config.json
Generate content adhering to the quality gate defined above:
🔴 语言要求:使用中的.nium-wiki/config.json设置——参见章节3。请勿从源代码或对话推断语言。language
生成内容时需遵守上述质量门槛:
8.1 Template Selection Rules
8.1 模板选择规则
Read the named template file from before writing each doc. Not all templates are needed for every project — apply these rules:
templates/| Doc | Template file | When to generate | Notes |
|---|---|---|---|
| | always | — |
| | always | — |
| | always (choose by | Module docs only contain an API overview table + link. Detailed signatures and type definitions belong exclusively in |
| | one per domain directory under | Short overview + architecture diagram + sub-module table. No detailed API docs. |
| | project has install steps OR is a library/framework | — |
| | project exports programmatic APIs (functions/classes/types) | Single source of truth for all API signatures/types. Mark |
| | module count >= 5 | — |
在撰写每个文档前,从目录读取指定的模板文件。并非所有模板都适用于每个项目——请遵循以下规则:
templates/| 文档 | 模板文件 | 生成时机 | 说明 |
|---|---|---|---|
| | 始终生成 | — |
| | 始终生成 | — |
| | 始终生成(根据 | 模块文档仅包含API概览表格+链接。详细签名和类型定义仅放在 |
| | | 简短概述+架构图+子模块表格。无详细API文档。 |
| | 项目包含安装步骤或为库/框架时生成 | — |
| | 项目导出可编程API(函数/类/类型)时生成 | 所有API签名/类型的唯一事实来源。标记 |
| | 模块数≥5时生成 | — |
8.2 Source Links
8.2 源文件链接
Attach navigable source links next to documented symbols:
markdown
undefined在记录的符号旁添加可导航的源文件链接:
markdown
undefinedundefinedundefined9. Save
9. 保存
- Write wiki files to
.nium-wiki/wiki/ - Sanitize link paths and build indexes after wiki files are written:
bash
cd <skill-root> && node scripts/index.cjs sanitize-links <project-root>
cd <skill-root> && node scripts/index.cjs build-index <project-root>
cd <skill-root> && node scripts/index.cjs diff-index <project-root> # --no-update to skip hash writescans all wikisanitize-linksfiles and converts any.mdabsolute paths to project-root-relative paths. MUST run beforefile://.build-indexscans source path links in wiki files to buildbuild-index(source ↔ doc mapping for incremental updates).cache/doc-index.json(withoutdiff-index) is called last so the hash snapshot reflects the final state.--no-update
- Refresh timestamp
meta.json - 🔴 MANDATORY — Generate sidebar:
bash
cd <skill-root> && node scripts/index.cjs generate-sidebar <wiki-path> --allThis generatesfor all language directories. It is idempotent — ifsidebar.jsonalready exists it will be skipped. If a legacysidebar.jsonexists it will be migrated automatically. This step is mandatory after every wiki generation — the preview server and all modern tooling depend on_sidebar.md. Do NOT skip it.sidebar.json
- 将wiki文件写入目录
.nium-wiki/wiki/ - 在wiki文件写入后,清理链接路径并构建索引:
bash
cd <skill-root> && node scripts/index.cjs sanitize-links <project-root>
cd <skill-root> && node scripts/index.cjs build-index <project-root>
cd <skill-root> && node scripts/index.cjs diff-index <project-root> # --no-update跳过哈希写入扫描所有wikisanitize-links文件,将任何.md绝对路径转换为相对于项目根目录的路径。必须在file://之前运行。build-index扫描wiki文件中的源路径链接,构建build-index(用于增量更新的源代码 ↔ 文档映射)。 最后调用cache/doc-index.json(不带diff-index),使哈希快照反映最终状态。--no-update
- 更新的时间戳
meta.json - 🔴 强制要求——生成侧边栏:
bash
cd <skill-root> && node scripts/index.cjs generate-sidebar <wiki-path> --all此命令为所有语言目录生成。它是幂等的——若sidebar.json已存在则跳过。若存在旧版sidebar.json会自动迁移。每次wiki生成后必须运行此步骤——预览服务器和所有现代工具都依赖_sidebar.md。请勿跳过。sidebar.json
10. Multi-language Translation
10. 多语言翻译
Applies to both full generation and incremental updates. Every timeis modified, secondary language files inwiki/that correspond to changed docs must be kept in sync — do not leave them stale.wiki_{lang}/Skip this step ifcontains only one language.language
适用于完整生成和增量更新。每次目录被修改时,必须同步wiki/目录中对应变更文档的次要语言文件——请勿让它们过期。wiki_{lang}/若仅包含一种语言,跳过此步骤。language
10.1 Build Translation Task List
10.1 构建翻译任务列表
Run to get the sync report. Extract every file marked or into an explicit checklist (e.g. , ).
cd <skill-root> && node scripts/index.cjs i18n status <wiki-path>MissingOutdated❌ [Missing] index.md⚠️ [Outdated] architecture.mdYou MUST translate every file in this list — no exceptions, no skipping.
Incremental mode: If this is a partial update (incremental pipeline detected changes), only translate files that areorOutdated— do NOT re-translate allMissingfiles. Full generation mode: Translate allSyncedfiles (Missingmay not exist yet since memory has not been populated).**Outdated
运行获取同步报告。将每个标记为或的文件提取到明确的检查清单中(例如、)。
cd <skill-root> && node scripts/index.cjs i18n status <wiki-path>MissingOutdated❌ [Missing] index.md⚠️ [Outdated] architecture.md必须翻译清单中的每个文件——无例外,无跳过。
增量模式:若为部分更新(增量流水线检测到变更),仅翻译或Outdated的文件——请勿重新翻译所有Missing文件。 完整生成模式:翻译所有Synced文件(由于内存尚未填充,可能不存在Missing文件)。**Outdated
10.2 Translate Files One by One
10.2 逐个翻译文件
🔴 MANDATORY: Process EVERY file in the checklist sequentially.
For each file:
- Read the primary wiki file from
wiki/ - Translate content to the target language
- Write to with identical path and filename (e.g.
wiki_{lang}/→wiki/core/auth.md)wiki_en/core/auth.md - Preserve unchanged: all Mermaid diagrams, code blocks (EXCEPT sanitize any secrets/credentials if found), source path links, and markdown structure
- Secret sanitization exception: If code blocks contain secrets/credentials, sanitize them using the rules from the "Secret & Credential Sanitization" section
After each file, report progress:
✅ [3/17] wiki_en/core/_index.mdBatching rule: If the file count exceeds 10, translate in batches of 5. After each batch, report progress and continue immediately — do NOT stop or ask the user unless you hit a context limit. If you must stop, clearly list the remaining untranslated files so the user can say "continue" to resume.
🔴 强制要求:按顺序处理清单中的每个文件。
对于每个文件:
- 从目录读取主要语言的wiki文件
wiki/ - 将内容翻译为目标语言
- 写入目录,保持完全相同的路径和文件名(例如
wiki_{lang}/→wiki/core/auth.md)wiki_en/core/auth.md - 保留不变内容:所有Mermaid图表、代码块(若发现敏感信息/凭证则需脱敏)、源路径链接和Markdown结构
- 敏感信息脱敏例外:若代码块包含敏感信息/凭证,需按照「机密信息与凭证脱敏」章节的规则进行脱敏
每个文件翻译完成后,报告进度:
✅ [3/17] wiki_en/core/_index.md批量规则:若文件数量超过10个,每5个为一批进行翻译。每批完成后报告进度并立即继续——除非遇到上下文限制,否则不要停止或询问用户。若必须停止,需明确列出剩余未翻译的文件,以便用户说"continue"时继续。
10.3 Finalize
10.3 完成
After ALL files are translated:
bash
cd <skill-root> && node scripts/index.cjs i18n sync-memory <wiki-path>Run again to verify all files show as . If any files are still or , go back and translate them.
cd <skill-root> && node scripts/index.cjs i18n status <wiki-path>SyncedMissingOutdatedDelete rule: When deleting any file from (e.g. because the source file was deleted), you MUST also delete the corresponding file from ALL directories.
wiki/wiki_{lang}/所有文件翻译完成后:
bash
cd <skill-root> && node scripts/index.cjs i18n sync-memory <wiki-path>再次运行验证所有文件显示为。若仍有文件标记为或,返回重新翻译。
cd <skill-root> && node scripts/index.cjs i18n status <wiki-path>SyncedMissingOutdated删除规则:当从目录删除任何文件(例如源文件被删除),必须同时从所有目录删除对应的文件。
wiki/wiki_{lang}/Surgical Edit: Modifying Existing Docs
精准编辑:修改现有文档
Applies when: Updating 1-3 existing wiki documents (incremental pipeline result), not full generation.When an existing doc already exists, your goal is to patch the minimum surface area, not regenerate the full file. Every line you leave untouched is a line that does not need to be reviewed, diffed, or reverted.
适用场景:更新1-3个现有wiki文档(增量流水线结果),而非完整生成。当文档已存在时,目标是最小化修改范围,而非重新生成整个文件。每一行未修改的内容都是无需审核、对比或回滚的内容。
🔴 Quality Gate Disabled During Incremental Updates
🔴 增量更新期间禁用质量门槛
⚠️ CRITICAL: When running in incremental mode (triggered bypipeline), the global Quality Gate rules above do NOT apply to existing docs being surgically patched. Applying those rules blindly is the primary cause of oversized diffs and unnecessary rewrites.incremental
See Mode Overrides for the full table of Quality Gate rule overrides in incremental mode.
updateStrengthincremental | Meaning | Action |
|---|---|---|
| Function signature changed OR module role changed | Full regeneration of this doc |
| Transitive/dep/doc-dep propagation | Surgical patch only — no quality gate, no template |
Rule: If the pipeline saysfor a doc, treat it as a targeted patch — update only the section that mentions the triggering source, leave everything else untouched.updateStrength: incremental
⚠️ 关键要求:在增量模式下(由流水线触发),上述全局质量门槛规则不适用于正在进行精准补丁的现有文档。盲目应用这些规则是导致差异过大和不必要重写的主要原因。incremental
增量模式下的质量门槛规则覆盖详情参见「模式覆盖」。
增量流水线返回的控制补丁深度:
updateStrength | 含义 | 操作 |
|---|---|---|
| 函数签名变更或模块角色变更 | 完整重新生成此文档 |
| 传递性/依赖/文档依赖传播 | 仅精准补丁——无质量门槛,无模板 |
规则:若流水线标记某文档的,则将其视为针对性补丁——仅更新提及触发源的章节,其余内容保持不变。updateStrength: incremental
Mandatory Steps (Execute in Order)
强制步骤(按顺序执行)
Never start from the template when updating an existing doc.
Step 1 — Read the baseline
- read_file: the existing wiki doc (read-only, this is what you are preserving)
- read_file: all source files that triggered the update (from output)
incremental
Step 2 — Evaluate match degree
Cross-read the existing doc against the changed source files. Answer:
- Which sections of the existing doc directly correspond to the changed code?
- Which sections are completely unaffected?
- What is your overall match degree?
Step 3 — Decide strategy by match degree
| Match degree | Signals | Action |
|---|---|---|
| ≥ 80% | Internal change only (comment, variable rename, refactor); function signatures unchanged; core topics not touched | Default: PRESERVE — update version footer only, do not touch the body. If no version footer exists, create one (a single line). |
| 40–80% | One function's behavior changed; new export added; file structure changed | Patch only the affected sections — leave everything else untouched |
| < 40% | Function renamed or signature changed; module role changed; multiple sections invalidated | Full regeneration of this document |
Step 4 — Write the patched doc
- Output MUST be a minimal diff from the original — significantly smaller than a full regeneration
- Do not use the module template as the starting point for an existing doc
Step 5 — Self-verify
Before finalizing, mentally check: does the new file differ from the original in anything beyond the source-change-affected sections, newly-added sections, and now-incorrect sections? If yes, you are rewriting too much — restore the preserved sections.
更新现有文档时绝不要从模板开始。
步骤1 — 读取基线
- read_file:现有wiki文档(只读,这是需要保留的内容)
- read_file:所有触发更新的源文件(来自输出)
incremental
步骤2 — 评估匹配度
交叉读取现有文档与变更的源文件。回答以下问题:
- 现有文档的哪些章节与变更的代码直接对应?
- 哪些章节完全不受影响?
- 整体匹配度是多少?
步骤3 — 根据匹配度决定策略
| 匹配度 | 信号 | 操作 |
|---|---|---|
| ≥ 80% | 仅内部变更(注释、变量重命名、重构);函数签名未变更;核心主题未触及 | 默认:保留——仅更新版本页脚,不修改正文。若无版本页脚,添加一行。 |
| 40–80% | 某个函数的行为变更;新增导出;文件结构变更 | 仅修补受影响的章节——其余内容保持不变 |
| < 40% | 函数重命名或签名变更;模块角色变更;多个章节失效 | 完整重新生成此文档 |
步骤4 — 写入补丁后的文档
- 输出必须与原始文档的差异最小——远小于完整重新生成的差异
- 不要以模块模板作为现有文档的起点
步骤5 — 自我验证
最终确定前,检查:新文件与原始文件的差异是否仅涉及受源变更影响的章节、新增章节和现在不正确的章节?若是,则修改范围过大——恢复保留的章节。
Principle 1 — Preservation Priority
原则1 — 优先保留
Unless the source has actually changed, the following MUST be preserved exactly as-is:
| Content type | When to update |
|---|---|
| Accurate description paragraphs | Never (unless source logic changed) |
| Correct code examples | Never (unless the code itself changed) |
| Mermaid diagrams | Never (unless the underlying flow/calls changed) |
| File structure tree | Only when files were added/removed |
| API summary table | Only when function signatures changed |
| Best practices section | Never (unless the module logic changed) |
| Cross-links | Only when linked docs were moved/renamed |
除非源代码实际变更,否则以下内容必须完全保留:
| 内容类型 | 更新时机 |
|---|---|
| 准确的描述段落 | 绝不更新(除非源代码逻辑变更) |
| 正确的代码示例 | 绝不更新(除非代码本身变更) |
| Mermaid图表 | 绝不更新(除非底层流程/调用变更) |
| 文件结构树 | 仅在文件新增/删除时更新 |
| API摘要表格 | 仅在函数签名变更时更新 |
| 最佳实践章节 | 绝不更新(除非模块逻辑变更) |
| 交叉链接 | 仅在链接的文档被移动/重命名时更新 |
Principle 2 — Change Scope Isolation
原则2 — 隔离变更范围
Before editing, write down the minimum scope:
Change type → Minimum doc impact
1. Function logic changed (signature unchanged)
→ Update only that function's description paragraph
→ Code example only if the behavior changed in a user-visible way (callers must change)
→ If change only affects internal call chains, not external callers: update version footer only
→ Do NOT rewrite other functions' descriptions
2. New exported function added
→ Append one row to the API summary table
→ Add one usage example (optional)
→ Do NOT rewrite existing examples
3. File added/removed
→ Update the File Structure tree
→ Do NOT regenerate Architecture Position diagram (unless the module's position actually changed)
4. Bug fix (doc described old/wrong behavior)
→ Fix only the affected paragraph
→ Do NOT restructure the entire section编辑前,写下最小变更范围:
变更类型 → 最小文档影响
1. 函数逻辑变更(签名未变)
→ 仅更新该函数的描述段落
→ 仅当行为变更对用户可见(调用者必须修改)时,更新代码示例
→ 若变更仅影响内部调用链,不影响外部调用者:仅更新版本页脚
→ 不要重写其他函数的描述
2. 新增导出函数
→ 在API摘要表格中添加一行
→ 可选:添加一个使用示例
→ 不要重写现有示例
3. 文件新增/删除
→ 更新文件结构树
→ 不要重新生成架构定位图(除非模块的实际位置变更)
4. bug修复(文档描述了旧的/错误的行为)
→ 仅修复受影响的段落
→ 不要重构整个章节Principle 3 — When in Doubt, Don't Touch
原则3 — 存疑时,请勿修改
🔴 PRESERVE is the default at ≥ 80% match. If a paragraph is accurate (correctly describes the code) and not outdated (code hasn't changed in a way that contradicts it), leave it alone. Rewriting for style, phrasing, or "cleaner" expression is always wrong — a smaller diff beats a prettier paragraph. The burden of proof is on rewriting, not on preserving.
🔴 匹配度≥80%时默认保留。若段落准确(正确描述代码)且未过期(代码变更未与之矛盾),则保留原样。为了风格、措辞或"更简洁"的表达而重写始终是错误的——更小的差异优于更漂亮的段落。重写的举证责任在你,而非保留。
Bug-Level Violations (Anti-Patterns + Hard Rules)
严重违规(反模式+硬性规则)
Treat the following as bugs, not stylistic choices:
| Violation | Why it's wrong |
|---|---|
| Starting from the module template when patching an existing doc | Creates massive diff for no reason; contradicts "read the baseline first" |
| Full regeneration when function signature is unchanged | Internal implementation change ≠ doc invalidation |
| Rewriting a paragraph that remains accurate | Accurate = leave alone; "improving" wording yields diff noise |
| Rewriting code examples whose code has not changed | Even correct examples get rephrased |
| Regenerating a Mermaid diagram whose source has not changed | Diagram was fine before |
| Reordering sections | Changes diff noise, no factual benefit |
| Rephrasing the file structure tree | Only update when structure changed |
| Writing to an existing doc without reading it first | You can't preserve what you haven't read |
将以下情况视为错误,而非风格选择:
| 违规行为 | 错误原因 |
|---|---|
| 补丁现有文档时从模块模板开始 | 无理由产生大量差异;违反"先读取基线"规则 |
| 函数签名未变更时完整重新生成文档 | 内部实现变更≠文档失效 |
| 重写仍然准确的段落 | 准确=保留;"改进"措辞会产生差异噪声 |
| 重写未变更代码的示例 | 即使正确的示例也被改写 |
| 重新生成未变更源代码的Mermaid图表 | 图表原本没问题 |
| 重新排序章节 | 产生差异噪声,无实际益处 |
| 改写文件结构树 | 仅在结构变更时更新 |
| 未读取现有文档就写入内容 | 无法保留未读取的内容 |
Output Structure
输出结构
🔴 MANDATORY: Domain-Based Directory Hierarchy (No Flat Layout!)
🔴 强制要求:基于领域的目录层级(禁止扁平布局!)
Organize by business domain, not flat modules/ directory.
Directory naming rule: All wiki directory names MUST use lowercase + hyphens (kebab-case), e.g.,core/,language-handlers/. Never use PascalCase or camelCase.utils/
.nium-wiki/
├── config.json
├── meta.json
├── cache/
├── wiki/ # Primary language docs
│ ├── index.md # Project homepage
│ ├── architecture.md # System architecture
│ ├── getting-started.md # Quick start
│ ├── doc-map.md # Document relationship map
│ │
│ ├── <Domain-1>/ # Business domain 1
│ │ ├── _index.md # Domain overview
│ │ ├── <Sub-domain>/ # Sub-domain
│ │ │ ├── _index.md
│ │ │ └── <module>.md # 400+ lines
│ │ └── ...
│ │
│ ├── <Domain-2>/ # Business domain 2
│ │ └── ...
│ │
│ └── api/ # API reference
├── wiki_en/ # Secondary language (if configured)
│ ├── index.md # Same structure as wiki/
│ ├── architecture.md
│ └── ...按业务领域组织,而非扁平的modules/目录。
目录命名规则:所有wiki目录名称必须使用小写+连字符(kebab-case),例如、core/、language-handlers/。禁止使用PascalCase或camelCase。utils/
.nium-wiki/
├── config.json
├── meta.json
├── cache/
├── wiki/ # 主要语言文档
│ ├── index.md # 项目首页
│ ├── architecture.md # 系统架构
│ ├── getting-started.md # 快速入门
│ ├── doc-map.md # 文档关系图
│ │
│ ├── <Domain-1>/ # 业务领域1
│ │ ├── _index.md # 领域概述
│ │ ├── <Sub-domain>/ # 子领域
│ │ │ ├── _index.md
│ │ │ └── <module>.md # ≥400行
│ │ └── ...
│ │
│ ├── <Domain-2>/ # 业务领域2
│ │ └── ...
│ │
│ └── api/ # API参考
├── wiki_en/ # 次要语言(若配置)
│ ├── index.md # 与wiki/结构完全相同
│ ├── architecture.md
│ └── ...Automatic Domain Discovery
自动领域发现
Infer business domains from the project's directory structure, package boundaries, and import graph. Group modules that share a cohesive responsibility into the same domain directory. Each domain MUST contain:
| File | Description |
|---|---|
| Domain overview, architecture diagram, sub-module list |
| Sub-domain dirs | Related modules grouped by function |
| Each document | Depth scales with module role — see Complexity-Scaled Quality Targets |
从项目的目录结构、包边界和导入图推断业务领域。将具有内聚职责的模块分组到同一个领域目录中。每个领域必须包含:
| 文件 | 描述 |
|---|---|
| 领域概述、架构图、子模块列表 |
| 子领域目录 | 按功能分组的相关模块 |
| 每个文档 | 深度随模块角色调整——参见「按复杂度分级的质量目标」 |
Progressive Scanning for Large Projects
大型项目的渐进式扫描
When module count > 10, source files > 50, or LOC > 10,000, switch to Progressive Scanning:
- Prioritize modules — entry points (weight 5) > dependents (4) > has docs (3) > code size (2) > recently modified (1)
- Generate 1-2 modules per batch — depth scales with complexity
- Track progress in — record completed/pending modules and current batch number
cache/progress.json - After each batch — run , report results to user, then prompt:
cd <skill-root> && node scripts/index.cjs audit-docs <wiki-path> --verbose --mermaid-strict- — next batch
"continue" - — re-run validation
"audit docs" - — redo a specific module
"regenerate <module>" - If reports errors: fix them before continuing — Mermaid syntax errors degrade the diagram catalog silently and accumulate technical debt.
--mermaid-strict
- Resume — when user says "continue wiki generation", read and pick up where you left off
cache/progress.json
当模块数>10、源文件数>50或代码行数>10,000时,切换为渐进式扫描:
- 模块优先级——入口点(权重5)> 被依赖模块(4)> 已有文档(3)> 代码规模(2)> 最近修改(1)
- 每批生成1-2个模块——深度随复杂度调整
- 在中跟踪进度——记录已完成/待完成的模块及当前批次号
cache/progress.json - 每批完成后——运行,向用户报告结果,然后提示:
cd <skill-root> && node scripts/index.cjs audit-docs <wiki-path> --verbose --mermaid-strict- ——下一批
"continue" - ——重新运行验证
"audit docs" - ——重新生成特定模块
"regenerate <module>" - 若报告错误:修复后再继续——Mermaid语法错误会悄然降低图表质量并积累技术债务。
--mermaid-strict
- 恢复——当用户说"continue wiki generation"时,读取并从上次中断处继续
cache/progress.json
Documentation Upgrade & Maintenance
文档升级与维护
When existing wiki docs are outdated or below quality gate, use one of these strategies:
| Strategy | When to Use | User Command |
|---|---|---|
| Large version gap or poor overall quality | "refresh all wiki" |
| Many modules, want to keep existing content | "upgrade wiki" |
| Only specific modules need attention | "upgrade <module> docs" |
Execution: scan existing docs with , generate an upgrade report, then re-generate failing docs batch by batch. Always include so that Mermaid syntax errors block the upgrade and prevent bad diagrams from entering the wiki.
cd <skill-root> && node scripts/index.cjs audit-docs <wiki-path> --mermaid-strict--mermaid-strictVersion footer — append to every generated document:
*Generated by [Nium-Wiki v{{ NIUM_WIKI_VERSION }}](https://github.com/niuma996/nium-wiki) | {{ GENERATED_AT }}*当现有wiki文档过期或未达到质量门槛时,使用以下策略之一:
| 策略 | 使用场景 | 用户命令 |
|---|---|---|
| 版本差距大或整体质量差 | "refresh all wiki" |
| 模块多,想要保留现有内容 | "upgrade wiki" |
| 仅特定模块需要关注 | "upgrade <module> docs" |
执行流程:使用扫描现有文档,生成升级报告,然后分批重新生成不合格的文档。始终包含,以便Mermaid语法错误阻止升级,防止不良图表进入wiki。
cd <skill-root> && node scripts/index.cjs audit-docs <wiki-path> --mermaid-strict--mermaid-strict版本页脚——添加到每个生成的文档末尾:
*Generated by [Nium-Wiki v{{ NIUM_WIKI_VERSION }}](https://github.com/niuma996/nium-wiki) | {{ GENERATED_AT }}*Finalization Checklist (MANDATORY — Run After Every Generation)
最终检查清单(强制要求——每次生成后运行)
Applies after every wiki generation: full pipeline, module-targeted, incremental, or surgical patch. This checklist is the last step of every execution path. Do not skip any item.
-
→ Generates
cd <skill-root> && node scripts/index.cjs generate-sidebar <wiki-path> --allfor all language directories. Idempotent — safe to run multiple times. → Migrates legacysidebar.jsonto_sidebar.mdautomatically if encountered. → ⚠️ Do NOT skip: the preview server and modern tooling depend onsidebar.json.sidebar.json -
(if multi-language) → Updates translation memory so subsequent runs show accurate sync status.
cd <skill-root> && node scripts/index.cjs i18n sync-memory <wiki-path> -
(full generation only) → Validates all Mermaid diagrams. Mermaid errors block the run — fix them before declaring done.
cd <skill-root> && node scripts/index.cjs audit-docs <wiki-path> --mermaid-strict
Rule: These finalization steps must run after all wiki content is written and after all translation files are updated. They are not optional cleanup — they are part of the generation contract. (read version from—scripts/version.jsonfield)version
适用于每次wiki生成:完整流水线、模块定向、增量或精准补丁。 此清单是每个执行路径的最后一步。请勿跳过任何项。
-
→ 为所有语言目录生成
cd <skill-root> && node scripts/index.cjs generate-sidebar <wiki-path> --all。幂等——可安全多次运行。 → 若遇到旧版sidebar.json会自动迁移为_sidebar.md。 → ⚠️ 请勿跳过:预览服务器和现代工具依赖sidebar.json。sidebar.json -
(多语言时) → 更新翻译记忆,以便后续运行显示准确的同步状态。
cd <skill-root> && node scripts/index.cjs i18n sync-memory <wiki-path> -
(仅完整生成时) → 验证所有Mermaid图表。Mermaid错误会阻止运行——修复后再宣布完成。
cd <skill-root> && node scripts/index.cjs audit-docs <wiki-path> --mermaid-strict
规则:这些最终步骤必须在所有wiki内容写入后、所有翻译文件更新后运行。它们不是可选的清理步骤——而是生成契约的一部分。 (版本从的scripts/version.json字段读取)version