indexion-readme
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chineseindexion readme — README Construction
indexion README — README构建
Build project READMEs from templates, doc comments, hand-written prose, and
per-package READMEs. This skill covers the construction side: scaffolding,
generating, planning, assembling, and verifying. For evaluating existing
documentation, see .
indexion-documentation从模板、文档注释、手写文本以及每个包的README构建项目README。本技能涵盖构建环节:脚手架搭建、生成、规划、组装和验证。如需评估现有文档,请查看。
indexion-documentationWhere things live
文件位置说明
The conventions vary by project; check what actually exists before editing:
| Asset | Location patterns seen |
|---|---|
| Config | |
| Per-package template | |
| Static prose | |
| Per-package READMEs | |
| Assembled root README | usually |
| |
The first thing to check is / for: a symlink on , a (at root or under ), and . The presence of these tells you whether the README is hand-maintained, build-assembled, or a hybrid.
git diffls -laREADME.mddoc.json.indexion/readme/.indexion.toml不同项目的约定有所不同,编辑前请先确认实际存在的文件:
| 资源 | 常见位置模式 |
|---|---|
| 配置 | |
| 每个包的模板 | |
| 静态文本 | |
| 每个包的README | |
| 组装后的根目录README | 通常为 |
| |
首先需要检查的是通过 / 查看:是否为符号链接、是否存在(根目录或下)以及。这些文件的存在情况可以告诉你README是手动维护、构建组装还是混合模式。
git diffls -laREADME.mddoc.json.indexion/readme/.indexion.tomlWorkflow overview
工作流程概述
doc init → .indexion/readme/template.md + doc.json (greenfield)
edit doc.json + docs/*.md → declare sources of truth
doc readme --per-package → cmd/<pkg>/README.md (API skeletons; non-overwriting)
hand-write each per-package README's Overview / Usage / Options / Examples
doc readme --config → assembled root README
plan drift <prev> <new> → verify the assembled output (or hand-edit) is purely additivedoc init → .indexion/readme/template.md + doc.json(新项目初始化)
edit doc.json + docs/*.md → 声明信息来源
doc readme --per-package → cmd/<pkg>/README.md(API框架;不会覆盖现有文件)
hand-write each per-package README's Overview / Usage / Options / Examples
doc readme --config → 组装根目录README
plan drift <prev> <new> → 验证组装输出(或手动编辑)仅为增量内容Step 1: Initialize (greenfield only)
步骤1:初始化(仅适用于新项目)
bash
indexion doc init <project-dir>Creates + . Skip this step on a project that already has or pointing at one.
.indexion/readme/template.md.indexion/readme/doc.jsondoc.json.indexion.tomlbash
indexion doc init <project-dir>创建 + 。如果项目已存在或指向该文件,请跳过此步骤。
.indexion/readme/template.md.indexion/readme/doc.jsondoc.json.indexion.tomlStep 2: Configure doc.json
步骤2:配置doc.json
json
{
"$schema": "./schemas/doc-config.schema.json",
"version": "1.0",
"spec": "moonbit",
"output": { "format": "markdown", "filename": "README.md" },
"packages": [
{
"path": "cmd/<name>",
"title": "<command name>",
"include_in_root": true,
"sections": ["overview", "usage"]
}
// …one entry per package that should appear in the assembled root README
],
"root": {
"output": "README.md",
"sections": [
{ "type": "static", "file": "docs/intro.md" },
{ "type": "toc", "title": "Commands" },
{ "type": "packages", "filter": "cmd/**" },
{ "type": "static", "file": "docs/installation.md" },
{ "type": "static", "file": "docs/license.md" }
]
}
}Root section types:
- — include a markdown file verbatim
static - — insert a table-of-contents heading
toc - — pull in entries from the
packagesarray, filtered by globpackages
Package fields:
- — whether to include in the assembled root README
include_in_root - — README headings to extract; honored by per-package extraction flows. Note that
sectionsin the root currently emits a table of package links, not the rich Overview/Usage expansion implied by per-package{ "type": "packages" }. See "Known limitation" below.sections
json
{
"$schema": "./schemas/doc-config.schema.json",
"version": "1.0",
"spec": "moonbit",
"output": { "format": "markdown", "filename": "README.md" },
"packages": [
{
"path": "cmd/<name>",
"title": "<command name>",
"include_in_root": true,
"sections": ["overview", "usage"]
}
// …每个应出现在组装后的根目录README中的包对应一个条目
],
"root": {
"output": "README.md",
"sections": [
{ "type": "static", "file": "docs/intro.md" },
{ "type": "toc", "title": "Commands" },
{ "type": "packages", "filter": "cmd/**" },
{ "type": "static", "file": "docs/installation.md" },
{ "type": "static", "file": "docs/license.md" }
]
}
}根目录章节类型:
- — 直接包含指定markdown文件的内容
static - — 插入目录标题
toc - — 从
packages数组中提取条目,通过通配符过滤packages
包字段说明:
- — 是否包含在组装后的根目录README中
include_in_root - — 要提取的README标题;会被每个包的提取流程遵循。注意根目录中的
sections当前仅生成一个包链接表格,并非每个包{ "type": "packages" }所暗示的详细Overview/Usage扩展内容。请查看下方“已知限制”。sections
Step 3: Generate per-package READMEs
步骤3:生成每个包的README
bash
indexion doc readme --per-package src/ cmd/Generates in each package directory that doesn't already have one. Non-overwriting — existing per-package READMEs are left alone.
README.mdThe skeleton is API-only (extracted from doc comments via KGF). Treat it as a starting point and hand-write the prose sections (Overview, Usage, Options, Examples) afterwards.
///bash
undefinedbash
indexion doc readme --per-package src/ cmd/在每个尚未拥有README的包目录中生成。不会覆盖现有文件——已存在的每个包的README将保持不变。
README.md生成的框架仅包含API内容(通过KGF从文档注释提取)。请将其作为起点,后续手动编写文本章节(概述、用法、选项、示例)。
///bash
undefinedSingle package to stdout
将单个包的README输出到标准输出
indexion doc readme src/kgf/lexer/
indexion doc readme src/kgf/lexer/
Single package to a file
将单个包的README输出到文件
indexion doc readme -o=README.md src/kgf/lexer/
**Note on side effects**: `doc readme --template=<t> <paths...>` (the template-based mode below) walks the given paths and **auto-creates** per-package READMEs for any package that lacks one — even without `--per-package`. If you run it on a broad path (`cmd/`, `src/`), expect new files in unrelated packages. Run with a narrow path or grep `git status` afterwards to clean up unintended creations.indexion doc readme -o=README.md src/kgf/lexer/
**副作用说明**:`doc readme --template=<t> <paths...>`(下方的模板模式)会遍历指定路径,并**自动创建**所有缺少README的包的README——即使未使用`--per-package`参数。如果在宽泛路径(如`cmd/`, `src/`)上运行该命令,可能会在无关包中创建新文件。请使用窄路径运行,或在运行后通过`git status`检查并清理意外创建的文件。Step 4: Write static content
步骤4:编写静态内容
Create , , etc. — whatever your references. These are the hand-written prose; the assembler pulls them in verbatim.
docs/intro.mddocs/installation.mdroot.sections创建, 等文件——即中引用的所有文件。这些是手写文本,组装器会直接将其内容纳入。
docs/intro.mddocs/installation.mdroot.sectionsStep 5: Generate writing plans (optional)
步骤5:生成写作计划(可选)
bash
indexion plan readme --template=docs/templates/readme.md --plans-dir=.indexion/plans src/Emits per-section writing tasks for manual or LLM-assisted authoring.
bash
indexion plan readme --template=docs/templates/readme.md --plans-dir=.indexion/plans src/输出每个章节的写作任务,用于手动或LLM辅助创作。
Step 6: Assemble the README
步骤6:组装README
bash
undefinedbash
undefinedConfig-driven (preferred; doc.json controls layout and packages list)
配置驱动(推荐;doc.json控制布局和包列表)
indexion doc readme --config=doc.json
indexion doc readme --config=doc.json
Template-driven (alternative; {{include:…}} and {{packages}} placeholders)
模板驱动(替代方案;使用{{include:…}}和{{packages}}占位符)
indexion doc readme --template=docs/templates/readme.md -o=README.md cmd/
The config path can live at repo root or under `.indexion/readme/`. With `.indexion.toml`'s `[doc] config_path = "…"`, the `--config=` flag becomes optional.indexion doc readme --template=docs/templates/readme.md -o=README.md cmd/
配置文件可位于仓库根目录或`.indexion/readme/`下。如果`.indexion.toml`中设置了`[doc] config_path = "…"`,则`--config=`参数为可选。Step 7: Verify with plan drift
plan drift步骤7:使用plan drift
验证
plan driftAfter regeneration or any hand-edit of the root README, verify the change is purely additive (no silent deletions, no reflowing of unrelated sections):
bash
undefined在重新生成或手动编辑根目录README后,验证更改仅为增量内容(无静默删除、无无关章节的重排):
bash
undefinedSnapshot the previous version
保存之前版本的快照
git show HEAD:README.md > /tmp/README.before.md
git show HEAD:README.md > /tmp/README.before.md
Compare against the new version
与新版本对比
indexion plan drift --top=20 /tmp/README.before.md README.md
What to look for in the output:
- `Drift terms in /tmp/README.before.md (missing on the other side): (none)` — nothing was removed
- `Drift terms in README.md (missing on the other side): …` — exactly the new vocabulary you intended to add (command names, new flags, new concepts)
- `Cosine similarity` near 1.0 for a small additive change; substantially lower if you reshaped a section
For CI integration:
```bash
indexion plan drift --vocab-threshold=0.05 /tmp/README.before.md README.mdindexion plan drift --top=20 /tmp/README.before.md README.md
输出内容需关注:
- `Drift terms in /tmp/README.before.md (missing on the other side): (none)` — 未删除任何内容
- `Drift terms in README.md (missing on the other side): …` — 仅添加了你预期的新词汇(命令名称、新标志、新概念)
- 对于小的增量更改,`Cosine similarity`接近1.0;如果重排了章节,则相似度会显著降低
用于CI集成:
```bash
indexion plan drift --vocab-threshold=0.05 /tmp/README.before.md README.mdexits 1 if cosine_distance > 0.05 — useful as a guard against accidental large rewrites
如果余弦距离>0.05则返回1——可作为防止意外大范围重写的防护措施
This same workflow applies to translated README pairs (`README.md` ↔ `README-ja.md`): cross-lingual drift detection works natively because vocab sub-tokenization delegates to the natural-language KGFs in `kgfs/natural/`.
此工作流程同样适用于翻译后的README对(`README.md` ↔ `README-ja.md`):跨语言漂移检测原生支持,因为词汇子分词由`kgfs/natural/`中的自然语言KGF处理。Template syntax
模板语法
The template file supports substitution:
{{placeholder}}| Placeholder | Expansion |
|---|---|
| Contents of the file (relative to project root) |
| All discovered packages (filtered by CLI |
| Module-level documentation only |
模板文件支持替换:
{{placeholder}}| 占位符 | 扩展内容 |
|---|---|
| 指定文件的内容(相对于项目根目录) |
| 所有发现的包(通过CLI的 |
| 仅模块级文档 |
.indexion.toml integration
.indexion.toml集成
toml
[doc]
config_path = "doc.json" # auto-loads doc.json without --config
per_package = true # makes `doc readme <path>` default to --per-packageExplicit always takes priority.
--config=…toml
[doc]
config_path = "doc.json" # 自动加载doc.json,无需使用--config参数
per_package = true # 使`doc readme <path>`默认启用--per-package显式的参数始终优先。
--config=…Known limitation: packages
root section produces a table, not rich expansion
packages已知限制:packages
根目录章节仅生成表格,不支持详细扩展
packagesThe permits on each , but the current implementation does not expand those sections inline when emitting in the root. The output is a markdown table of package links with empty descriptions.
doc-config.schema.jsonsections: ["overview", "usage", …]packageEntrydoc readme --config{ "type": "packages" }Two practical consequences:
- If the project's checked-in root README has rich per-command Overview / Usage paragraphs, they were not produced by as it stands now. They are hand-maintained. Diff
doc readme --configagainst the checked-in README to see how much of it is hand-curated; very large diffs mean the README is mostly hand-maintained.doc readme --config -o=/tmp/regen.md - For new commands, you currently need to also hand-edit the rich section into the assembled README, in addition to adding the package entry to and writing the per-package README. Use the
doc.jsonverification above to confirm the hand-edit only adds, never removes.plan drift
If you fix this limitation (so honors per-entry ), update this skill to remove this section.
{ "type": "packages" }sectionsdoc-config.schema.jsonpackageEntrysections: ["overview", "usage", …]doc readme --config{ "type": "packages" }实际影响如下:
- 如果项目已提交的根目录README包含详细的每个命令的概述/用法段落,那么这些内容并非由当前的生成,而是手动维护的。对比
doc readme --config和已提交的README,查看手动维护的内容占比;如果差异很大,说明README主要是手动维护的。doc readme --config -o=/tmp/regen.md - 对于新命令,除了在中添加包条目并编写每个包的README外,你目前还需要手动编辑组装后的README,添加详细章节。使用上述
doc.json验证来确认手动编辑仅添加内容,未删除任何内容。plan drift
如果修复了此限制(使支持每个条目的),请更新本技能以移除本节内容。
{ "type": "packages" }sectionsCommon pitfalls
常见陷阱
"doc readme --per-package generated nothing"
- All packages already have READMEs. The command only creates new files, never overwrites. Delete existing READMEs first to regenerate.
"doc readme --template … on created READMEs in packages I didn't touch"
cmd/- Template mode auto-generates missing per-package READMEs as a side effect.
Either pass a narrow path, or revert unintended creations from .
git status
"Auto-generated per-package READMEs are just API listings"
- By design. Hand-write Overview, Usage, Options, Examples. For CLI commands,
the authoritative behavior comes from .
indexion <command> --help
"My hand-edit to README.md will be wiped out by "
doc readme --config- It will if the assembler ever produces the rich shape (see "Known
limitation"). Until then, the assembler produces a strict subset (the
table) and your hand-edits to the rich sections survive. Always run the
cross-check to be sure.
plan drift
"README.md edit destroyed unrelated sections"
- Run and look at the "missing on the other side" output for the previous version. If it lists anything other than
plan drift HEAD:README.md README.md, you removed content.(none)
"doc readme --per-package未生成任何内容"
- 所有包都已存在README。该命令仅创建新文件,从不覆盖。如需重新生成,请先删除现有README。
"在上运行在我未修改的包中创建了README"
cmd/doc readme --template …- 模板模式会自动生成缺失的每个包的README作为副作用。请使用窄路径运行,或从中恢复意外创建的文件。
git status
"自动生成的每个包的README仅包含API列表"
- 这是设计如此。请手动编写概述、用法、选项、示例。对于CLI命令,权威行为来自。
indexion <command> --help
"我对README.md的手动编辑会被覆盖"
doc readme --config- 如果组装器能够生成详细内容(见“已知限制”),则会被覆盖。在此之前,组装器仅生成严格的子集(表格),你对详细章节的手动编辑会保留。请始终运行交叉检查以确保安全。
plan drift
"编辑README.md破坏了无关章节"
- 运行,查看旧版本的“missing on the other side”输出。如果除了
plan drift HEAD:README.md README.md之外还有其他内容,说明你删除了部分内容。(none)