sync-docs

A command for keeping Chinese feature documentation and its English copy aligned with code changes. It uses a file map to connect source modules with their documentation.

In plain words
What is it for?
It helps inspect code changes, update matching Chinese Markdown files, find missing or outdated English copies, and produce a closing report.
Why use it?
It reduces the chance that documentation describes old code, misses new features, or has incomplete English translations before a pull request.

Command

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/zhangshenao/harness9/sync-docs
Clone the repo
git clone --depth 1 https://github.com/ZhangShenao/harness9
Per session 24 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,341 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00024 $0.01341
Opus 5 $0.00012 $0.00671
Sonnet 5 $0.00005 $0.00268
Haiku 4.5 $0.00002 $0.00134

Measured 2d ago against content hash a0b7a8c00eb0, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

sync-docs scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.opencode/commands/sync-docs.md · 102 lines

How it starts

The opening of the file, as written. The whole thing — 102 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Sync Docs(文档同步管线)

Overview

维护 docs/核心功能/(中文,唯一信息源)与 docs/core-features-en/(英文镜像)的完整同步:

  • Phase 1: 代码变更 → 中文文档更新(基于 docs/doc-map.json 模块映射 + git diff)
  • Phase 2: 中文文档 → 英文镜像同步(MISSING / STALE 扫描)
  • Phase 3: 统一收尾报告

CI 中有对应的机械式漂移检测(scripts/check-doc-drift.sh,warn 模式),本命令是其 LLM 辅助的落地执行手段:提 PR 前先跑本命令补文档。

When to Run

  • 修改了任何 internal/cmd/skills/ 源码之后、提交 PR 之前
  • 创建或修改了 docs/核心功能/ 下任何文件之后
  • 用户执行 /sync-docs(可附带 diff 范围参数,如 /sync-docs HEAD~3

Phase 1: 代码变更 → 中文文档

  1. 确定变更范围:用户显式指定时以用户为准;否则优先工作区未提交改动(git status --porcelain + git diff),无未提交改动时用 git diff --name-only master...HEAD
  2. 过滤出变更的源码路径(忽略 *_test.go 与生成产物)。
  3. 读取 docs/doc-map.json,对每个映射条目:paths 中任一模式命中变更文件、且 docs 非空时,将其 docs 列入候选更新清单。映射表之外的模块不强制;若发现明显的未登记模块→文档对应关系,在报告中建议补充映射表。
  4. 对每个候选文档:
    • 通读文档全文 + 相关代码 diff
    • 判断需要更新的内容:新增功能 / 新增接口与类型 / 行为变更 / 删除的内容 / 过时的代码片段与文件结构描述
    • 直接编辑中文文档,保持现有章节结构与写作风格;无实质影响的变更(注释措辞、测试内部调整)可跳过并在报告中说明理由
  5. 候选清单为空时,报告"代码变更无需文档同步",直接进入 Phase 3。

Phase 2: 中文 → 英文镜像

2.1 Scan for mismatches

Run this check to identify missing or stale English docs:

for f in docs/核心功能/*.md; do
  name=$(basename "$f")
  en_path="docs/core-features-en/$name"
  if [ ! -f "$en_path" ]; then
    echo "MISSING: $en_path"
  elif [ "$f" -nt "$en_path" ]; then
    echo "STALE: $en_path (Chinese version is newer)"
  fi
done

Classify results:

  • MISSING: English doc does not exist--must be created
  • STALE: English doc exists but Chinese version was modified more recently--should be reviewed and updated
  • OK: Both exist and English is not older than Chinese

If all docs are OK, report success and go to Phase 3.

2.2 For each MISSING doc: create the English version

Read the Chinese doc in full. Then create the English counterpart at docs/core-features-en/<same-filename> following these rules:

Translation principles:

  • The English version is an independently written technical document, not a machine translation
  • Content and structure must align with the Chinese version (same sections, same code blocks, same tables)
  • Follow English technical writing conventions: active voice, concise sentences, no unnecessary hedging
  • Code blocks, Go struct definitions, and CLI examples remain identical (they are language-neutral)
  • Chinese-specific UI strings shown in examples (e.g., TUI output) should be translated to English equivalents
  • Comments in code blocks: translate Chinese comments to English

Read the full file on GitHub · 102 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 102 lines · 24 tokens per session scan A a0b7a8c00eb0

Subscribe to this mod's changes

sync-docs is a command published in the GitHub repository ZhangShenao/harness9 (135 stars, last pushed 3d ago), licensed MIT. It adds 24 tokens to every session and 1,341 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.