From b68135926bffa1240c35ad75a4d3a47c4a9d2e2a Mon Sep 17 00:00:00 2001 From: Eric Nordelo Date: Wed, 29 Apr 2026 14:16:09 +0200 Subject: [PATCH 1/5] feat: add docs-sync skill --- skills/docs-sync/SKILL.md | 153 +++++++ .../config/libraries/contracts-sui.yml | 74 ++++ skills/docs-sync/process.md | 331 +++++++++++++++ skills/docs-sync/references/checks/README.md | 31 ++ .../references/checks/check_code_snippets.md | 78 ++++ .../references/checks/check_links.md | 74 ++++ .../checks/check_nav_consistency.md | 77 ++++ .../references/checks/compare_public_api.md | 98 +++++ .../references/checks/detect_missing_pages.md | 75 ++++ .../references/checks/extract_public_api.md | 123 ++++++ .../checks/find_stale_identifiers.md | 84 ++++ .../reports/docs-sync-report-template.md | 52 +++ .../references/rules/api-reference-rules.md | 238 +++++++++++ .../references/rules/change-classification.md | 388 ++++++++++++++++++ .../references/rules/config-rules.md | 97 +++++ .../references/rules/diataxis-rules.md | 178 ++++++++ .../references/rules/doc-update-matrix.md | 277 +++++++++++++ .../references/rules/docs-pr-checklist.md | 139 +++++++ .../templates/api-reference-template.md | 186 +++++++++ .../templates/explanation-template.md | 127 ++++++ .../references/templates/guide-template.md | 147 +++++++ .../references/templates/tutorial-template.md | 145 +++++++ 22 files changed, 3172 insertions(+) create mode 100644 skills/docs-sync/SKILL.md create mode 100644 skills/docs-sync/config/libraries/contracts-sui.yml create mode 100644 skills/docs-sync/process.md create mode 100644 skills/docs-sync/references/checks/README.md create mode 100644 skills/docs-sync/references/checks/check_code_snippets.md create mode 100644 skills/docs-sync/references/checks/check_links.md create mode 100644 skills/docs-sync/references/checks/check_nav_consistency.md create mode 100644 skills/docs-sync/references/checks/compare_public_api.md create mode 100644 skills/docs-sync/references/checks/detect_missing_pages.md create mode 100644 skills/docs-sync/references/checks/extract_public_api.md create mode 100644 skills/docs-sync/references/checks/find_stale_identifiers.md create mode 100644 skills/docs-sync/references/reports/docs-sync-report-template.md create mode 100644 skills/docs-sync/references/rules/api-reference-rules.md create mode 100644 skills/docs-sync/references/rules/change-classification.md create mode 100644 skills/docs-sync/references/rules/config-rules.md create mode 100644 skills/docs-sync/references/rules/diataxis-rules.md create mode 100644 skills/docs-sync/references/rules/doc-update-matrix.md create mode 100644 skills/docs-sync/references/rules/docs-pr-checklist.md create mode 100644 skills/docs-sync/references/templates/api-reference-template.md create mode 100644 skills/docs-sync/references/templates/explanation-template.md create mode 100644 skills/docs-sync/references/templates/guide-template.md create mode 100644 skills/docs-sync/references/templates/tutorial-template.md diff --git a/skills/docs-sync/SKILL.md b/skills/docs-sync/SKILL.md new file mode 100644 index 00000000..0110e452 --- /dev/null +++ b/skills/docs-sync/SKILL.md @@ -0,0 +1,153 @@ +--- +name: docs-sync +description: Update the centralized OpenZeppelin docs repo after a smart contracts library changes. Use after a contracts release, a merged PR in a contracts library, or any time you need to bring a docs slice (library + version) back in line with the contracts repo. The skill takes two contract commits (BASE_COMMIT, HEAD_COMMIT) as the source of truth and produces docs edits that follow the Diátaxis framework. Trigger on phrases like "sync docs for contracts-sui", "update docs after the contracts PR", "regenerate API reference for v1.x", "docs-sync". +--- + +# docs-sync + +Use this skill when the contracts library has changed and the centralized +docs repo needs to be brought back in sync. The skill lives **inside the +docs repo**; the contracts repo is supplied at runtime. + +## When to use + +- A contracts library has merged a PR or cut a release and the docs need + updating. +- The user names a docs slice and two commits in the contracts repo. +- The user asks to "sync docs", "update API reference for ``", + or "document the changes between commit A and commit B". + +Do **not** trigger this skill for: + +- Pure docs cleanup unrelated to contracts changes (use a regular edit). +- Changes that have not yet landed in a commit on the contracts repo. + +## Required runtime inputs + +Collect these before editing: + +- ``: `interactive` or `automatic`. +- ``: local path to the contracts repo (runtime). +- ``: local path to this docs repo (runtime). +- ``: contracts commit immediately **before** the change set. +- ``: contracts commit at the **tip** of the change set. +- ``: docs slice id (e.g. `contracts-sui`). +- ``: docs version (e.g. `1.x`). +- ``: human-facing release tag (e.g. `v1.1.0`). +- ``: `full`, `api-only`, `guides-only`, or + `targeted:`. Default: `full`. + +Optional: + +- `` +- `` + +## Source-of-truth constraint + +The contracts diff is computed by the agent itself, from two commits: + +``` +git -C diff .. +``` + +The skill must **not** accept any of the following as the primary source +of truth: + +- Raw pasted diffs. +- Patch files. +- Uncommitted local changes. +- PR descriptions or commit messages. +- Informal change summaries. + +## Mode selection + +1. If the caller passed ``, use it. +2. Otherwise read `automation.default_mode` from config + (`skills/docs-sync/config/libraries/.yml`). +3. Otherwise default to `interactive`. + +- **interactive**: summarize and classify first. Ask only questions that + change scope, examples, release notes, audience, or security framing. + API reference edits may proceed deterministically; broad guide, + tutorial, or explanation rewrites need confirmation. +- **automatic**: ask no questions. Infer from config and sibling pages, + apply all required matrix updates within scope, and record assumptions. + If a required decision cannot be inferred safely, stop or leave a + `needs-human-review` finding instead of fabricating content. + +## Scope selection + +- `full`: apply the full matrix. +- `api-only`: update API reference, source links, stale identifiers in + API pages, and API navigation only. Report skipped guide/tutorial/ + explanation/example/release-note work as out of scope. +- `guides-only`: update guides, tutorials, explanations, and snippets. + Still inspect the API diff so stale prose can be found, but do not + regenerate reference pages. +- `targeted:`: edit only the listed docs paths plus required + navigation changes for those paths. Report every matrix-required + update outside the target set as skipped. + +## Config memory + +Always load: + +``` +skills/docs-sync/config/libraries/.yml +``` + +This file is committed to the docs repo and is the canonical source of +docs slice paths, navigation system, examples style, security rules, and +automation defaults. Read `references/rules/config-rules.md` only when +config is missing, malformed, or needs a durable convention update. + +All `docs.*` paths in config are **relative to ``**. Never +hard-code absolute filesystem paths in config, prompts, reports, or +generated docs. + +## Reference Files + +Read only what the run needs: + +1. `process.md` — the deterministic end-to-end workflow. +2. `references/rules/change-classification.md` — how to classify each + contract change. +3. `references/rules/doc-update-matrix.md` — what docs each change type + forces. +4. `references/rules/api-reference-rules.md` — required for API + reference updates. +5. `references/rules/diataxis-rules.md` — required when creating or reshaping tutorial, + guide, explanation, or reference content. +6. Templates under `references/templates/` — only when creating new + pages or replacing a broken structure. +7. `references/rules/docs-pr-checklist.md` and + `references/reports/docs-sync-report-template.md` — final validation + and summary. + +Use the validation specs under `references/checks/` as check definitions. They are +not executable scripts unless later replaced with real tooling. + +## Scope of edits + +Edit only: + +- Files inside the resolved docs slice + (`docs.library_root` and `docs.version_root` from config, recursively). +- The matching navigation config (`docs.nav_config_path`). +- Shared example files **only if** the matrix says they must change. + +Do **not**: + +- Touch other docs slices in the centralized repo. +- Create or edit `meta.json` files. The docs repo uses centralized + navigation under `src/navigation/` — see the local conventions file + at `docs.local_conventions_path` for slice-specific rules. +- Modify source/doc comments in the contracts repo unless + `automation.allow_source_comment_edits: true` **and** the user asked. + +## End of run + +Run through `references/rules/docs-pr-checklist.md` before claiming the +run is done. End with a compact docs-sync report following +`references/reports/docs-sync-report-template.md`. Do not create a +report file unless the user asks for one. diff --git a/skills/docs-sync/config/libraries/contracts-sui.yml b/skills/docs-sync/config/libraries/contracts-sui.yml new file mode 100644 index 00000000..bd12f44f --- /dev/null +++ b/skills/docs-sync/config/libraries/contracts-sui.yml @@ -0,0 +1,74 @@ +# docs-sync configuration for the OpenZeppelin Contracts for Sui docs slice. +# +# All paths are RELATIVE to . Local filesystem paths +# must NOT be added to this file; they are runtime inputs to the agent. + +library: + id: "contracts-sui" + language: "MOVE_SUI" + +docs: + content_root: "content" + library_root: "content/contracts-sui" + version: "1.x" + version_root: "content/contracts-sui/1.x" + api_reference_path: "content/contracts-sui/1.x/api" + product_index_path: "content/contracts-sui/index.mdx" + version_index_path: "content/contracts-sui/1.x/index.mdx" + local_conventions_path: "content/contracts-sui/AGENTS.md" + nav_config_path: "src/navigation/sui/current.json" + tone: "clear, precise, security-conscious" + target_audience: "smart contract developers integrating OpenZeppelin libraries" + +navigation: + system: "central-json" + forbid_meta_json: true + # Categories the agent must keep in sync inside nav_config_path. New modules + # must appear under both "Packages" and "API Reference" folders. + required_folders: + - "Learn" + - "Packages" + - "API Reference" + +examples: + compile_command: "" + snippet_validation: "syntax" + # Where in-repo example projects live, if any. Empty when examples are + # only embedded as code fences in MDX files. + examples_root: "" + +security: + warning_style: "explicit warning callouts for security-sensitive behavior" + require_security_sections_for: + - access_control + - ownership + - authorization + - asset_transfer + - upgradeability + - cryptography + - signature_verification + +release: + # GitHub source URL used by APIGithubLinkHeader and similar components. + # Pinned per release tag at runtime by the agent. + source_repo_url: "https://github.com/OpenZeppelin/contracts-sui" + +automation: + default_mode: "interactive" + allow_source_comment_edits: false + fail_on_unresolved_placeholders: true + +# API Reference layout assumptions specific to this slice. Each Move package +# is documented as a single MDX file under api_reference_path, named after +# the package (kebab-case if multi-word). Modules inside that package render +# as -style sections. See content/contracts-sui/AGENTS.md for the +# canonical entry order (description, then Aborts, then Emits). +api_reference_layout: + page_per: "package" + module_section_component: "APIItem" + github_link_component: "APIGithubLinkHeader" + entry_order: + - "description" + - "aborts" + - "emits" + - "callouts" diff --git a/skills/docs-sync/process.md b/skills/docs-sync/process.md new file mode 100644 index 00000000..ca9e37c7 --- /dev/null +++ b/skills/docs-sync/process.md @@ -0,0 +1,331 @@ +# docs-sync process + +A deterministic, top-to-bottom workflow. Steps run in order. Do not +reorder. If a step fails, stop and surface the failure rather than +skipping ahead. + +All paths in this document are relative to `` unless +explicitly prefixed with ``. + +--- + +## Step 1 — Select mode + +1. If the caller passed ``, use it. +2. Otherwise read `automation.default_mode` from the config file + (Step 2). +3. Otherwise default to `interactive`. + +Mode behavior: + +- `interactive`: summarize and classify before broad edits. Ask only + questions whose answers change scope, examples, release notes, + audience, or security framing. API reference edits can proceed + deterministically; broad guide/tutorial/explanation rewrites need + confirmation. +- `automatic`: ask no questions. Infer from config and sibling pages. + Record assumptions. If a required decision cannot be inferred safely, + stop or record `needs-human-review` rather than inventing context. + +## Step 2 — Load config memory + +1. Resolve ``. Default: + `skills/docs-sync/config/libraries/.yml`. +2. If the file does not exist, **stop**. Do not fabricate a config; ask + the user (interactive) or fail with a clear message (automatic). +3. Parse the file as YAML. +4. Read `library.id`, `library.language`, `docs.*`, `navigation.*`, + `examples.*`, `security.*`, `release.*`, `automation.*`. +5. Treat all `docs.*` paths as relative to ``. +6. Apply optional overrides from runtime: `` overrides + `docs.target_audience`; `` overrides `docs.tone`. + +## Step 3 — Resolve contracts repo and docs repo + +1. Verify `` exists and is a git repository: + `git -C rev-parse --is-inside-work-tree`. +2. Verify `` exists and is a git repository. +3. Confirm `` is **not** the same as + ``. +4. Confirm the docs repo's working tree is clean **enough** to make + reviewable edits (no unrelated unstaged changes that would muddy the + diff). Warn but continue if not. + +## Step 4 — Verify base and head commits + +``` +git -C rev-parse --verify ^{commit} +git -C rev-parse --verify ^{commit} +``` + +Both must resolve. If either fails: + +- Interactive: ask the user to fetch the right revision. +- Automatic: stop with a clear error. + +Confirm `` is an ancestor of ``: + +``` +git -C merge-base --is-ancestor +``` + +If not, warn (the diff will still be computed, but the relationship is +unusual — record it in the report). + +## Step 5 — Compute the contracts diff + +``` +git -C diff --stat .. +git -C diff .. +``` + +Persist the output for use in Steps 6–10. Also gather: + +``` +git -C log --pretty=oneline .. +``` + +…to label classifications in the report. + +This diff is the **only** accepted source of truth for what changed. +Anything in chat (PR descriptions, summaries, pasted snippets) is +context, not authority. + +## Step 6 — Resolve the target docs slice + +Resolve and verify each slice path on disk: + +| Variable | Source | +| ------------------------------ | ---------------------------------------------- | +| `` | `docs.content_root` | +| `` | `docs.library_root` | +| `` | `docs.version_root` | +| `` | `docs.api_reference_path` | +| `` | `docs.nav_config_path` | +| ``| `docs.local_conventions_path` | +| `` | `docs.product_index_path` | +| `` | `docs.version_index_path` | + +For each, check that the file or directory exists under +``. For missing pieces: + +1. If `docs.library_root` exists but `docs.version_root` does not, stop; + a new version needs an explicit setup decision. +2. If `docs.api_reference_path` is missing and the scoped run requires + API reference updates, create it and record the assumption. +3. If `docs.nav_config_path` is missing, stop; do not invent navigation. +4. If `docs.local_conventions_path` is missing, fall back to repo-root + `AGENTS.md` and record the fallback. + +## Step 7 — Read local docs conventions + +If `` exists, read it and treat it as +authoritative for that docs slice (formatting, code style in snippets, +section ordering, naming conventions, table formats, etc.). + +If it does not exist, fall back to the repo-root `AGENTS.md` (e.g. +`/AGENTS.md`) for global rules and record the fallback. + +For Sui specifically: + +- Local conventions live at `content/contracts-sui/AGENTS.md`. +- API Reference function entry order is **description, then `Aborts ...`, + then `Emits ...`**, with only NOTE/INFO/WARNING blocks afterwards. + +## Step 8 — Inspect contract changes + +From the diff in Step 5, group hunks by file and by language construct. +For each changed file, record: + +- File path (relative to ``). +- Whether it is part of the public API surface (sources/, package + manifests) or internal (tests/, scripts/, internal helpers). +- The high-level construct affected: module, struct, function, constant, + event, error, ability, capability, doc comment. + +Skip files outside the contracts library's documented surface (CI, +internal tooling, vendored libs). Record what was skipped. + +## Step 9 — Extract or compare the public API surface + +Use `references/checks/extract_public_api.md` as the extraction +specification to extract the public API surface at both `` +and ``. Use `references/checks/compare_public_api.md` as +the comparison spec. If executable project tooling exists, prefer it and +record the command. Produce a structured list: + +- Added modules / packages. +- Removed modules / packages. +- Added public functions, with signatures. +- Removed public functions. +- Changed function signatures (parameter types/order, return type, + visibility, abilities). +- Added or changed structs/types and their fields/abilities. +- Added or removed constants. +- Added or removed events. +- Added or removed errors / abort codes. +- Changed doc comments on public items. + +The spec is language-agnostic; for `MOVE_SUI`, parse `module ...` +declarations, `public fun`/`entry` signatures, `struct ... has ...` +declarations, `const`s, error constants (`E*`), and event structs. + +## Step 10 — Classify changes + +Apply `references/rules/change-classification.md` to the structured +list from Step 9 and to the raw diff from Step 5. Each change becomes +one or more rows of: + +| File / construct | Classification | Evidence (commit, hunk) | + +Classification values are exactly the names in +`references/rules/change-classification.md`. + +## Step 11 — Decide required docs updates + +For each classified change, look up the corresponding row in +`references/rules/doc-update-matrix.md`. The matrix tells you: + +- Whether API reference must update. +- Whether a guide, tutorial, or explanation must update. +- Whether examples must update. +- Whether navigation must update. +- Whether changelog/release notes must update. +- Whether a security warning is required. +- The default behavior in automatic mode. +- The questions to ask in interactive mode. + +Aggregate the required updates per docs page so the same page is not +edited multiple times in incompatible ways. + +Apply ``: + +- `full`: keep every matrix-required update. +- `api-only`: keep API reference, API source-link, API stale identifier, + and API navigation updates only; report other required work as skipped. +- `guides-only`: keep guide, tutorial, explanation, and snippet updates; + do not regenerate API reference pages. +- `targeted:`: keep only listed paths plus navigation changes + required for those paths; report omitted matrix-required work. + +In `interactive` mode, present the aggregated plan and wait for +confirmation before broad rewrites of guides, tutorials, or +explanations. API reference updates proceed without confirmation but +follow `references/rules/api-reference-rules.md`. + +## Step 12 — Update API reference + +Follow `references/rules/api-reference-rules.md`: + +1. For each touched module, read the existing API reference page (if + any) under ``. +2. Regenerate the structured sections (Types, Functions, Events, Errors) + from the source. +3. Preserve existing prose that is still accurate; replace prose that no + longer matches the source. +4. Honor the entry order from `` (for Sui: + description, then Aborts, then Emits, then NOTE/INFO/WARNING). +5. If a public item has weak or missing source comments, generate only + the deterministic parts and add a `needs-human-review` report item. + Add inline TODO comments only when there is no better accurate prose; + unresolved TODOs fail validation when + `automation.fail_on_unresolved_placeholders: true`. +6. Update source links / version pins (`APIGithubLinkHeader` for Sui) + to point to `` (or `` if no matching + tag exists). + +## Step 13 — Update guides, tutorials, and explanations + +For every guide/tutorial/explanation flagged in Step 11: + +1. Use `references/rules/diataxis-rules.md` to confirm the page is + still in the right Diátaxis category. If not, propose a move + (interactive) or record it as a `needs-human-review` finding + (automatic). +2. Apply the matching template (`references/templates/guide-template.md`, + `references/templates/tutorial-template.md`, + `references/templates/explanation-template.md`) when creating new + pages. +3. When updating existing pages, edit only the sections affected by the + change set. Do not rewrite working content. +4. Update inline code snippets to match the new API. Update prose that + describes signatures, arguments, abort conditions, or events. +5. Add or update security warnings according to + `security.warning_style` and `security.require_security_sections_for` + from config. + +## Step 14 — Update examples + +If the docs slice has an `examples_root`, update it. If examples live as +fenced code blocks inside MDX, update those. + +- Replace stale identifiers, package addresses, and signatures. +- Run `examples.compile_command` if set; otherwise apply + `examples.snippet_validation` (e.g. `syntax`-only validation). +- Do not create new example projects unless the matrix requires one + (e.g. `New module/package`). + +## Step 15 — Update navigation / sidebar + +Open `` and apply the deltas: + +- Add new modules to the `Packages` and `API Reference` folders (or the + equivalent labels for the slice). +- Remove entries for deleted modules. +- Rename entries when modules were renamed. +- Preserve existing order otherwise; insert new entries alphabetically + within their folder. +- Do **not** create or edit `meta.json` files. The docs repo uses + centralized JSON navigation under `src/navigation/`. + +For Sui specifically, edit `src/navigation/sui/current.json`. + +## Step 16 — Validate + +Run, in order. The files under `references/checks/` are validation +specs, not guaranteed executables; use project tooling or implement the +checks directly from the specs. + +1. **Public API coverage**: every public item from Step 9 has a + reference entry. Use `references/checks/detect_missing_pages.md`. +2. **Stale identifiers**: search the docs slice for removed names, + package ids, addresses, and old signatures. + `references/checks/find_stale_identifiers.md`. +3. **Code snippets**: parse fenced code blocks per + `examples.snippet_validation`. `references/checks/check_code_snippets.md`. +4. **Links**: validate internal links and anchors within the slice. + `references/checks/check_links.md`. +5. **Navigation consistency**: every doc page reachable via + `` exists, and every existing reference page is + reachable via navigation. `references/checks/check_nav_consistency.md`. +6. **Placeholder check**: no unresolved ``, ``, or template + placeholder tokens remain. If + `automation.fail_on_unresolved_placeholders: true` and any are + found, stop. + +Each validation produces a pass/fail status and a list of findings. All +findings go into the report. + +## Step 17 — Produce docs PR summary + +Walk through `references/rules/docs-pr-checklist.md`. Do not skip +items. Mark each as pass/fail/N/A with one-line evidence. + +Then fill out the compact +`references/reports/docs-sync-report-template.md` in the final run +output. Do not create `docs-sync-report.md` unless the user asks. + +The report includes a suggested PR title and body, ready for `gh pr +create`. + +## Step 18 — Record assumptions and unresolved issues + +Anything that wasn't directly evidenced by the diff or the config goes +into the report as either: + +- An **assumption** (the agent picked a reasonable default and continued). +- An **unresolved TODO** (the agent could not safely proceed and left a + marker for a human). + +Both lists must be exhaustive. The goal is for the next person — human +or agent — to pick up the work without re-running the whole process. diff --git a/skills/docs-sync/references/checks/README.md b/skills/docs-sync/references/checks/README.md new file mode 100644 index 00000000..e00ad816 --- /dev/null +++ b/skills/docs-sync/references/checks/README.md @@ -0,0 +1,31 @@ +# docs-sync helper scripts + +These files are validation and extraction **specs**, not executable +scripts. They define the inputs, outputs, failure conditions, and +interpretation rules for each helper the agent uses during a +`docs-sync` run. + +The agent should pick the most appropriate concrete command in its +runtime environment (rg, grep, language-specific parsers, project +tooling) to satisfy each helper's contract. If the project ships a real +implementation, prefer it and record the command used. + +## Files + +| File | Purpose | +|---|---| +| [extract_public_api.md](./extract_public_api.md) | Extract the public API surface at a given commit. | +| [compare_public_api.md](./compare_public_api.md) | Diff two extracted surfaces and produce a structured change list. | +| [detect_missing_pages.md](./detect_missing_pages.md) | Find public items that lack a reference entry. | +| [check_links.md](./check_links.md) | Validate internal links and anchors inside the slice. | +| [check_code_snippets.md](./check_code_snippets.md) | Validate fenced code blocks per `examples.snippet_validation`. | +| [check_nav_consistency.md](./check_nav_consistency.md) | Cross-check navigation config against actual content. | +| [find_stale_identifiers.md](./find_stale_identifiers.md) | Find references to removed names, addresses, signatures. | + +Each helper: + +- Lists explicit inputs. +- Lists expected outputs in a stable, parseable shape. +- Lists failure conditions that should make the agent stop or warn. +- Lists how the agent should interpret the result (block the run? add + a `needs-human-review` finding? auto-fix?). diff --git a/skills/docs-sync/references/checks/check_code_snippets.md b/skills/docs-sync/references/checks/check_code_snippets.md new file mode 100644 index 00000000..f1a8264a --- /dev/null +++ b/skills/docs-sync/references/checks/check_code_snippets.md @@ -0,0 +1,78 @@ +# check_code_snippets spec + +Validate fenced code blocks in the docs slice per the slice's +`examples.snippet_validation` setting. + +## Inputs + +- `LIBRARY_DOCS_ROOT` — `docs.library_root` from config. +- `LANGUAGE` — `library.language` from config. +- `VALIDATION_LEVEL` — `examples.snippet_validation`: + - `none` — skip validation entirely. + - `syntax` — parse code blocks and report syntax errors. + - `compile` — run `examples.compile_command` (if set) on + extracted snippets. + - `test` — same as `compile` but also run tests. +- `COMPILE_COMMAND` — `examples.compile_command` (if set). +- `EXAMPLES_ROOT` — `examples.examples_root` (if set; otherwise empty + and only embedded snippets are checked). + +## Output + +``` +{ + "snippets_total": , + "snippets_validated": , + "syntax_errors": [ + {"file": "", "line": , "language": "", + "message": ""} + ], + "compile_errors": [ + {"file": "", "line": , "command": "", + "stdout": "<...>", "stderr": "<...>"} + ] +} +``` + +## Procedure + +1. Walk every `*.mdx` under ``. +2. Extract fenced code blocks. Track: + - File path and starting line number. + - Fence info string (` ```move`, ` ```cairo`, etc.). + - Block content. +3. For each block whose language matches `LANGUAGE` (or is plausibly + the slice's language — for `MOVE_SUI`: `move`, `move-sui`, + `move2024`): + - If `VALIDATION_LEVEL == none`: skip. + - If `VALIDATION_LEVEL == syntax`: parse with the language's + parser. Record a `syntax_errors` entry on failure. + - If `VALIDATION_LEVEL in {compile, test}`: + a. Extract to a temporary file under a scratch project. + b. Run `COMPILE_COMMAND` against the scratch project. + c. Record `compile_errors` on non-zero exit. +4. If `EXAMPLES_ROOT` is set, validate the project there separately + using the same level. + +## Failure conditions + +- The configured parser/compiler is not available → record once at + the run level and downgrade to the next-lower validation level + (e.g. `compile` → `syntax`). Note the downgrade in the report. +- A snippet has no language tag → skip and add a soft warning; + unmarked code blocks are not part of the public docs guarantee. + +## Interpretation + +- `syntax_errors` and `compile_errors` are hard failures for the + Code snippets validation step in `process.md`. +- Automatic mode attempts up to one round of mechanical fixes for + obvious issues (stale identifiers, renamed items per + `compare_public_api`). After one round, remaining failures are + recorded as `needs-human-review`. +- Interactive mode prints the failure count and the first few + examples and asks whether to auto-fix or leave alone. + +Snippets in tutorials and how-to guides have a higher bar (they +should compile when possible). Snippets inside reference entries are +typically illustrative; `syntax`-level validation is enough. diff --git a/skills/docs-sync/references/checks/check_links.md b/skills/docs-sync/references/checks/check_links.md new file mode 100644 index 00000000..f608fb5e --- /dev/null +++ b/skills/docs-sync/references/checks/check_links.md @@ -0,0 +1,74 @@ +# check_links spec + +Validate internal links and anchors inside the docs slice. + +## Inputs + +- `LIBRARY_DOCS_ROOT` — `docs.library_root` from config. +- `VERSION_DOCS_ROOT` — `docs.version_root` from config. +- `NAV_CONFIG_PATH` — `docs.nav_config_path` from config. +- `EXTERNAL_CHECK` — `false` by default. When `false`, do not fetch + external URLs. + +## Output + +``` +{ + "broken_internal_links": [ + {"file": "", "line": , "href": "", "reason": ""} + ], + "broken_anchors": [ + {"file": "", "line": , "href": "", "anchor": ""} + ], + "broken_relative_paths": [ + {"file": "", "line": , "href": ""} + ], + "external_links_skipped": [ + {"file": "", "line": , "href": ""} + ] +} +``` + +## Procedure + +1. Walk every `*.mdx` file under ``. +2. For each markdown link `[text](href)` (including images and JSX + attribute hrefs): + - If `href` starts with `http://` or `https://` and + `EXTERNAL_CHECK` is false, record under `external_links_skipped` + and skip. + - If `href` starts with `/`, treat as a docs-site root-relative + URL. Resolve to a content path using the docs framework rules: + `/contracts-sui/1.x/api/access` → `content/contracts-sui/1.x/api/access.mdx`. + - If `href` starts with `./` or `../`, resolve relative to the + current file. + - If `href` contains a `#fragment`, split into path and anchor. +3. For each resolved path, check that the file exists. +4. For each anchor, parse the target file and confirm the anchor is + declared (look for `id="..."` and ``, also any + `[#anchor]` syntax this slice uses). +5. For navigation: parse `` JSON, resolve every + `url` to a content file the same way, and record any nav entry + that points nowhere as a `broken_internal_links` finding. + +## Failure conditions + +- A file under `` cannot be parsed as MDX → record + with `reason: "parse_error"` and continue. +- `` cannot be parsed as JSON → return a clear + failure; the run cannot complete navigation validation. + +## Interpretation + +- Any `broken_internal_links`, `broken_anchors`, or + `broken_relative_paths` entry is a `fail` for the Links validation + step in `process.md`. +- Automatic mode tries to auto-fix: + - If the broken anchor was renamed in this run (per + `compare_public_api`), repoint the link. + - If the broken file path was renamed in this run, repoint the + link. + - Otherwise, leave the link and add a `needs-human-review` + finding. +- Interactive mode lists each finding once and asks "auto-fix where + possible? (yes/no)" — never re-asks within the same run. diff --git a/skills/docs-sync/references/checks/check_nav_consistency.md b/skills/docs-sync/references/checks/check_nav_consistency.md new file mode 100644 index 00000000..7153b306 --- /dev/null +++ b/skills/docs-sync/references/checks/check_nav_consistency.md @@ -0,0 +1,77 @@ +# check_nav_consistency spec + +Cross-check the slice's navigation config against the actual content +on disk. + +## Inputs + +- `NAV_CONFIG_PATH` — `docs.nav_config_path` from config. +- `LIBRARY_DOCS_ROOT` — `docs.library_root` from config. +- `VERSION_DOCS_ROOT` — `docs.version_root` from config. +- `URL_TO_PATH` — function that maps a nav `url` to a content path. + For Sui: `/contracts-sui/1.x/api/access` → + `content/contracts-sui/1.x/api/access.mdx`. +- `REQUIRED_FOLDERS` — `navigation.required_folders` from config (if + set). + +## Output + +``` +{ + "nav_entries_pointing_nowhere": [ + {"name": "