docbridge 0.7.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,39 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "title": "DocBridge Link Manifest",
4
+ "type": "object",
5
+ "additionalProperties": false,
6
+ "required": ["links"],
7
+ "properties": {
8
+ "$schema": {
9
+ "type": "string"
10
+ },
11
+ "links": {
12
+ "type": "array",
13
+ "items": { "$ref": "#/$defs/link" }
14
+ }
15
+ },
16
+ "$defs": {
17
+ "link": {
18
+ "type": "object",
19
+ "additionalProperties": false,
20
+ "required": ["code", "doc"],
21
+ "properties": {
22
+ "code": {
23
+ "description": "Code endpoint as file#canonicalId, relative to the project root.",
24
+ "type": "string",
25
+ "pattern": "^[^/\\\\#\\s][^\\\\#\\s]*#[^#\\s]+$"
26
+ },
27
+ "doc": {
28
+ "description": "Documentation endpoint as file#anchor, relative to the project root.",
29
+ "type": "string",
30
+ "pattern": "^[^/\\\\#\\s][^\\\\#\\s]*\\.md#[^#\\s]+$"
31
+ },
32
+ "note": {
33
+ "description": "Free-form text for human readers. It reaches no command output.",
34
+ "type": "string"
35
+ }
36
+ }
37
+ }
38
+ }
39
+ }
@@ -29,6 +29,7 @@
29
29
  "canonicalId": { "type": "string" },
30
30
  "endpoint": { "type": "string" },
31
31
  "location": { "$ref": "common-output.schema.json#/$defs/location" },
32
+ "isMember": { "type": "boolean" },
32
33
  "nameRange": { "$ref": "common-output.schema.json#/$defs/range" },
33
34
  "declarationRange": { "$ref": "common-output.schema.json#/$defs/range" },
34
35
  "signatureRange": { "$ref": "common-output.schema.json#/$defs/range" }
@@ -1,34 +1,27 @@
1
1
  # DocBridge skill templates
2
2
 
3
- Distributable agent skills for projects that use DocBridge. Prefer
3
+ Distributable agent skill for projects that use DocBridge. Prefer
4
4
  `docbridge init` for CLI-driven setup or `docbridge init-with-agent` for
5
- agent-guided adoption. `init-with-agent` installs `docbridge-adopt` first;
6
- `docbridge-adopt` installs the companion skills after scope is confirmed.
7
- Manual copy-based installation remains available: copy a
8
- skill directory into your repository's skill location (`.claude/skills/` for
9
- Claude Code or `.agents/skills/` for Codex-style project skills) and adjust
10
- nothing unless your DocBridge invocation differs from the examples inside.
5
+ agent-guided adoption. Both commands install the same `docbridge` skill.
6
+ Manual copy-based installation remains available: copy the skill directory
7
+ into your repository's skill location (`.claude/skills/` for Claude Code or
8
+ `.agents/skills/` for Codex-style project skills).
11
9
 
12
- - [`docbridge-annotate`](docbridge-annotate/SKILL.md) — create correct
13
- `@doc`/`@code` link pairs and verify them with `docbridge check`.
14
- - [`docbridge-sync`](docbridge-sync/SKILL.md) — triage `related --gate`
15
- findings: fetch the flagged counterpart content with `docbridge context`,
16
- then update the counterpart or justify leaving it unchanged.
17
- - [`docbridge-adopt`](docbridge-adopt/SKILL.md) — adopt DocBridge in an existing
18
- TypeScript, Swift, Dart, or Rust project by confirming docs/code scope, creating
19
- or improving config, installing companion skills, and handling simple CI or
20
- Git-hook setup.
21
- - [`docbridge-link`](docbridge-link/SKILL.md) — link existing docs sections to
22
- existing supported code declarations through docs-first candidate discovery
23
- and section-level confirmation.
24
- - [`docbridge-review`](docbridge-review/SKILL.md) — review the whole DocBridge
25
- graph for semantic validity using `docbridge graph --json --include-content`.
10
+ - [`docbridge`](docbridge/SKILL.md) — route adopt, discover-and-link, annotate,
11
+ review, and sync work. Facts about the binary live in
12
+ `docbridge docs show`, not in this file.
26
13
 
27
- This repository dogfoods the distributable DocBridge skills from both
14
+ This repository dogfoods the distributable DocBridge skill from both
28
15
  `.claude/skills/` and `.agents/skills/` as skill-level symlinks to this
29
16
  directory. The template is the source of truth; do not edit the symlinked
30
17
  copies in place. In-repository dogfood links require symlink-capable checkouts;
31
18
  external projects should use the copy-based installation above.
32
19
 
33
- The Git-hook and CI integration that complements these skills is described
20
+ Existing installs may still have the five legacy skill directories
21
+ (`docbridge-adopt`, `docbridge-annotate`, `docbridge-link`,
22
+ `docbridge-review`, `docbridge-sync`). `docbridge init --force` removes those
23
+ copied directories after you review local edits. Symlinked skill directories
24
+ are reported and left untouched.
25
+
26
+ The Git-hook and CI integration that complements this skill is described
34
27
  under [`docs/integrations/`](../../docs/integrations/).
@@ -0,0 +1,125 @@
1
+ ---
2
+ name: docbridge
3
+ description: Adopt or introduce DocBridge, choose docs and code scope, create or improve docbridge.config.json, add @doc and @code annotations, fix link diagnostics, triage related --gate findings, and review existing links for stale docs or semantic validity.
4
+ ---
5
+
6
+ # docbridge
7
+
8
+ Route DocBridge work, then apply the matching judgment. Facts about the binary
9
+ — annotation syntax, supported declarations, the anchor algorithm, diagnostic
10
+ codes — live in packaged docs, not in this skill. Read them with
11
+ `docbridge docs show`. Invocation is documented in
12
+ `docbridge docs show automation`.
13
+
14
+ An agent with no DocBridge skill can still finish the job from
15
+ `docbridge --help` plus `docbridge docs list` / `docbridge docs show`.
16
+
17
+ ## Task router
18
+
19
+ Pick **one** job before editing. The first matching question wins:
20
+
21
+ | Job | Ask this | Not this |
22
+ | ----------------- | ------------------------------------------------------------------------------ | --------------------------------------------- |
23
+ | Adopt | Introduce DocBridge, choose docs/code scope, or write `docbridge.config.json`? | Linking existing files |
24
+ | Discover and link | Choose what to link in existing docs, docs-first? | A known pair already confirmed |
25
+ | Annotate | Add or fix a `@doc` / `@code` pair, or clear link diagnostics? | Deciding _whether_ a section should be linked |
26
+ | Review | Check whether the docs still match the code, with no change set? | Gate findings on a diff |
27
+ | Sync | A Git hook, CI comment, or `related --gate` flagged unchanged counterparts? | Auditing the whole graph |
28
+
29
+ **Review versus sync.** Whole graph, no change set → **review**. A change set's
30
+ flagged counterparts → **sync**. "Check whether the docs still match the code"
31
+ is review. "These counterparts were not updated in this diff" is sync.
32
+
33
+ ## Adopt
34
+
35
+ Survey the repo: existing config, likely specification directories, public API
36
+ locations, existing annotations, scripts, CI, and Git hooks.
37
+
38
+ Recommend docs scope, code scope, and whether to wire simple CI or hooks now.
39
+ Show the tradeoff, then wait for confirmation. Create or improve
40
+ `docbridge.config.json` only after that. Use the language-keyed `include.code`
41
+ object, never the old array form. Never replace a user-authored config blindly.
42
+
43
+ Handle CI and Git hooks conservatively: implement a simple confirmed setup;
44
+ otherwise provide a patch plan. Prefer a non-blocking gate early in adoption.
45
+
46
+ Verify with `docbridge check`. A clean zero-link result is acceptable. Then
47
+ continue into discover-and-link.
48
+
49
+ Read `docbridge docs show getting-started` and `configuration`.
50
+
51
+ ## Discover and link
52
+
53
+ Work docs-first. Confirm docs scope, then follow
54
+ `docbridge docs show linking`: prioritize unlinked specification
55
+ sections, propose at most three symbols per section with why/uncertain, present
56
+ 5–10 sections per round, collect adopt/exclude/hold, and classify no-matches
57
+ instead of forcing a link.
58
+
59
+ Add annotations only after section-level confirmation. Then follow Annotate.
60
+
61
+ ## Annotate
62
+
63
+ Create both sides of a pair, or add the missing backlink. Read
64
+ `docbridge docs show linking` for syntax, supported declarations, anchors,
65
+ and target grammar. Read `docbridge docs show troubleshooting` for diagnostic
66
+ codes and fixes.
67
+
68
+ Procedure: identify the declaration and the heading; add `@doc` on the
69
+ declaration (create a minimal doc comment if missing); add `@code` directly
70
+ above the heading; verify with `docbridge check`. The pair is correct only when
71
+ no diagnostic mentions either endpoint.
72
+
73
+ Do not split or rename headings in this job. Preserve existing annotations
74
+ unless the user asked to fix a wrong link.
75
+
76
+ ## Sync
77
+
78
+ A `related --gate` violation means nobody has decided yet, not that the
79
+ counterpart must change. Read `docbridge docs show automation` for the
80
+ three-way judgment.
81
+
82
+ 1. Collect violations from the hook, CI comment, or, for uncommitted work
83
+ including new files,
84
+ `{ git diff --name-only HEAD; git ls-files --others --exclude-standard; } | docbridge related --stdin --gate`.
85
+ 2. Fetch counterpart content with `docbridge context` over the changed files.
86
+ 3. Per counterpart: update it when the documented contract diverged; leave it
87
+ unchanged with a written justification that cites the counterpart content;
88
+ or fix the annotation pair when the link itself is wrong.
89
+ 4. Re-run the gate. Report every decision.
90
+
91
+ Never detach a link to silence the gate. Do not rubber-stamp: unread
92
+ counterpart content is not a judgment. When a code change contradicts an
93
+ explicit documented promise, surface that instead of quietly rewriting the
94
+ promise.
95
+
96
+ ## Review
97
+
98
+ Audit meaning across the whole graph, not a diff. Follow the semantic review
99
+ procedure in `docbridge docs show linking`.
100
+
101
+ Requires `docbridge graph --json --include-content`. Read `diagnostics` first.
102
+ Batch by docs file. Read both sides. Classify High / Medium / Low. Report
103
+ severity, endpoints, evidence, and a recommended fix. Do not edit annotations
104
+ automatically.
105
+
106
+ `check` proves mechanics; this job reviews meaning. Do not rubber-stamp a
107
+ resolving link. Prefer fewer, clearer links. Do not delete annotations to
108
+ silence uncertainty.
109
+
110
+ ## Shared guardrails
111
+
112
+ - Confirm scope and section-level decisions with the user before writing links.
113
+ - Do not decide branch or pull-request policy.
114
+ - Prefer public API declarations as link targets.
115
+ - After edits, re-run `docbridge check` (and `related --gate` for sync).
116
+
117
+ ## Read more
118
+
119
+ - `docbridge docs list` — the full menu
120
+ - `docbridge docs show linking` — discovery, annotations, and semantic review
121
+ - `docbridge docs show automation` — invocation, gate judgment, hooks, and CI
122
+ - `docbridge docs show troubleshooting` — diagnostic codes and fixes
123
+ - `docbridge docs show getting-started` — first-time setup
124
+ - `docbridge docs show configuration` — `docbridge.config.json`
125
+ - `docbridge docs show commands` — check, related, context, graph, docs, upgrade
@@ -1,70 +0,0 @@
1
- ---
2
- description: Wire DocBridge into coding agents, Git hooks, and CI.
3
- ---
4
-
5
- # Agent Integration
6
-
7
- DocBridge gives coding agents deterministic link data instead of asking them
8
- to infer documentation relationships from filenames.
9
-
10
- <!-- @code src/cli/init.ts#runInitWithAgent -->
11
-
12
- ## Install agent skills
13
-
14
- `docbridge init` can install the distributable skills while creating project
15
- configuration. To let an agent decide the scope, run:
16
-
17
- ```sh
18
- docbridge init-with-agent --agent-target codex
19
- ```
20
-
21
- Use `claude` or `both` for other supported targets. The command installs the
22
- adoption skill and prints the next command or prompt; it does not launch an
23
- agent process.
24
-
25
- ## Editing workflow
26
-
27
- Before changing a linked file, provide its counterpart content:
28
-
29
- ```sh
30
- docbridge context path/to/changed-file
31
- ```
32
-
33
- After editing, inspect the change set:
34
-
35
- ```sh
36
- git diff --name-only | docbridge related --stdin --gate
37
- ```
38
-
39
- For every reported counterpart, update it when behavior diverged or record why
40
- no documentation or code change is necessary.
41
-
42
- ## Hooks
43
-
44
- Put the automation in Git hooks rather than in one agent's configuration, so
45
- it covers every contributor and every tool. A `pre-commit` hook can run
46
- `docbridge check` as a hard gate, then report `related --gate` over the staged
47
- files:
48
-
49
- ```sh
50
- git diff --cached --name-only | docbridge related --stdin --gate
51
- ```
52
-
53
- When an agent runs `git commit` through a shell, the hook's output lands in the
54
- tool result and therefore in the agent's context, so the counterpart findings
55
- reach it without any agent-specific wiring. Attach the counterparts' content
56
- with `docbridge context --stdin` to make the finding actionable in place.
57
-
58
- Keep the gate stage non-blocking while the link graph is still sparse: a
59
- blocking gate on a staged subset mostly trains `--no-verify`. Hooks must not
60
- silently rewrite files or replace the repository's mandatory checks.
61
-
62
- Git hooks cannot signal before an edit, and they are skipped by `--no-verify`
63
- and by some GUI clients, so the pull request stays the enforcement point.
64
-
65
- ## CI
66
-
67
- Run `docbridge check` over the whole project as the hard link-validity gate. A
68
- pull-request workflow can additionally pass the base-to-head changed file list
69
- to `related --stdin --gate` and attach `context` output for reviewers. Ensure
70
- the checkout includes both commits needed for the diff.
@@ -1,52 +0,0 @@
1
- ---
2
- description: Write @doc and @code annotations and valid link targets.
3
- ---
4
-
5
- # Annotations
6
-
7
- DocBridge links supported code declarations to Markdown headings. A complete
8
- pair has `@doc` on the declaration and `@code` immediately before the heading.
9
-
10
- ## Code to documentation
11
-
12
- Use a documentation path and heading anchor in a declaration's documentation
13
- comment:
14
-
15
- ```ts
16
- /**
17
- * @doc docs/auth.md#login-flow
18
- */
19
- export function login(): void {}
20
- ```
21
-
22
- Swift, Dart, and Rust use their normal documentation comment syntax with the same
23
- target format. Paths are relative to the configured project root.
24
-
25
- <!-- @code src/core/markdown.ts#scanMarkdown -->
26
-
27
- ## Documentation to code
28
-
29
- Place an HTML comment immediately before the linked heading:
30
-
31
- ```md
32
- <!-- @code src/auth.ts#login -->
33
-
34
- ## Login Flow
35
- ```
36
-
37
- The code fragment is the canonical symbol ID emitted by the language scanner.
38
- Top-level functions and types normally use their declaration name. Members use
39
- their type-qualified identity. TypeScript member IDs omit parameter signatures,
40
- Swift member IDs include argument labels, Dart member IDs omit parameter
41
- signatures, and Rust member IDs use `::` path qualification.
42
-
43
- ## Anchors and reciprocity
44
-
45
- Markdown anchors use the normalized heading text, such as `# Login Flow`
46
- becoming `#login-flow`. Duplicate headings receive the same numeric suffixes
47
- used by GitHub-style Markdown anchors.
48
-
49
- Each direction is validated independently. A target can resolve while still
50
- reporting a missing reciprocal annotation. Run `docbridge check` to validate
51
- targets and pair completeness, and `docbridge graph --json` when you need the
52
- resolved endpoints and edges.
@@ -1,96 +0,0 @@
1
- ---
2
- name: docbridge-adopt
3
- description: Adopt DocBridge in an existing TypeScript, Swift, Dart, or Rust project. Use when asked to introduce DocBridge into a repository, choose docs/code scope, create or improve docbridge.config.json, and optionally wire simple CI or Git hooks.
4
- ---
5
-
6
- # docbridge-adopt
7
-
8
- Adopt DocBridge in an existing project. This skill assumes it is already
9
- installed in the agent environment through `docbridge init-with-agent`,
10
- `docbridge init`, or a manual copy into `.agents/skills/` or
11
- `.claude/skills/`.
12
-
13
- The goal is to make the repository ready for DocBridge links, then continue
14
- into an initial docs-first link-candidate pass. Do not assume a pull request.
15
-
16
- Run DocBridge with the project's native invocation: `docbridge` on `PATH`, a
17
- repo recipe such as `just check`, or
18
- `bun run /path/to/docbridge/src/cli/index.ts`.
19
-
20
- ## Procedure
21
-
22
- 1. **Survey the repository.** Inspect:
23
- - existing `docbridge.config.json`
24
- - Markdown docs structure and likely specification directories
25
- - TypeScript, Swift, Dart, or Rust source structure and public API locations
26
- - existing `@doc` / `@code` annotations
27
- - package scripts, CI files, and Git hooks
28
-
29
- 2. **Recommend scope, then ask for confirmation.** Present concise options and
30
- your recommendation for:
31
- - docs scope: directories/files whose sections are likely specifications,
32
- contracts, behavior, constraints, or design decisions
33
- - code scope: language-keyed TypeScript, Swift, Dart, or Rust directories/files
34
- whose supported declarations should be linkable
35
- - CI/Git-hook mode: if any integration should be added now
36
-
37
- Do not ask the user to rediscover obvious facts from the repository. Show
38
- your recommendation and the tradeoff, then wait for confirmation.
39
-
40
- 3. **Create or improve config.**
41
- - If no config exists, create `docbridge.config.json` with the confirmed
42
- `include.code` and `include.docs` globs.
43
- - Use the language-keyed `include.code` object. Do not write the old
44
- array form; for example, use `{ "typescript": { "patterns": [...] } }`,
45
- `{ "swift": { "patterns": [...] } }`, `{ "dart": { "patterns": [...] } }`,
46
- or `{ "rust": { "patterns": [...] } }`.
47
- - If config exists, read it, explain the current scope, propose any
48
- improvement, and edit only after confirmation.
49
- - Never replace a user-authored config blindly.
50
-
51
- 4. **Install companion DocBridge skills.**
52
- - After scope is confirmed and `docbridge.config.json` exists or has been
53
- intentionally left unchanged, install the rest of the distributable
54
- DocBridge skills for the same agent target.
55
- - Prefer the project-native DocBridge invocation. From the project root, run
56
- `docbridge init --yes --agent-target codex` for Codex,
57
- `docbridge init --yes --agent-target claude` for Claude Code, or
58
- `docbridge init --yes --agent-target both` for both. Use the target that
59
- matches the existing `.agents/` and/or `.claude/` setup.
60
- - This command should leave an existing `docbridge.config.json` unchanged
61
- and copy any missing `docbridge-annotate`, `docbridge-link`,
62
- `docbridge-review`, and `docbridge-sync` skill directories. Do not use
63
- `--force` unless the user explicitly asks to overwrite installed skills.
64
- - If the command is unavailable, explain the blocker and provide the manual
65
- copy target paths from `templates/skills/docbridge-*` instead of silently
66
- skipping this step.
67
-
68
- 5. **Handle CI and Git hooks conservatively.**
69
- - If the existing setup is simple and the user confirmed the mode, implement
70
- it.
71
- - If the setup is complex or ambiguous, provide a concrete patch plan or
72
- snippet instead of editing.
73
- - Prefer non-blocking awareness early in adoption unless the user requests a
74
- hard gate.
75
-
76
- 6. **Verify the setup.** Run `docbridge check` or the repository's equivalent.
77
- If the project intentionally has no links yet, a clean zero-link result is
78
- acceptable. Surface config or scanning diagnostics before proceeding.
79
-
80
- 7. **Continue into initial candidate discovery.** After setup, inspect the
81
- confirmed docs scope and present 5-10 high-value section candidates using
82
- the `docbridge-link` rules. Candidate discovery may continue in the same
83
- turn, but annotation edits still require section-level user confirmation.
84
-
85
- ## Scope Rules
86
-
87
- - Prefer docs sections that state behavior, contracts, inputs/outputs,
88
- constraints, user-visible behavior, or design decisions.
89
- - Treat README, changelogs, contribution docs, runbooks, logs, and release
90
- notes as exclusions by default unless the user identifies specific sections
91
- as specifications.
92
- - Prefer supported public API declarations as link targets. TypeScript starts
93
- with top-level exported declarations; Swift, Dart, and Rust also support member
94
- endpoints with scanner-produced canonical IDs.
95
- - Do not decide project workflow policy such as branch or PR strategy. Mention
96
- only what affects DocBridge adoption.
@@ -1,99 +0,0 @@
1
- ---
2
- name: docbridge-annotate
3
- description: Create bidirectional DocBridge links between supported code declarations and Markdown sections. Use when asked to link code to its specification, add @doc or @code annotations, annotate new code with docs, or fix DocBridge link diagnostics.
4
- ---
5
-
6
- # docbridge-annotate
7
-
8
- Create a DocBridge link pair: a `@doc` tag in the code documentation comment
9
- and a `@code` comment above the Markdown heading. A link is valid only when
10
- both directions exist and point at each other.
11
-
12
- Run DocBridge with the project's native invocation: `docbridge` on `PATH`, a
13
- repo recipe such as `just check`, or
14
- `bun run /path/to/docbridge/src/cli/index.ts`.
15
-
16
- ## Link anatomy
17
-
18
- Code side — a `@doc` tag in the documentation comment of a supported
19
- declaration:
20
-
21
- ```ts
22
- /**
23
- * @doc docs/auth.md#login-spec
24
- */
25
- export async function login() {}
26
- ```
27
-
28
- ```swift
29
- /// @doc docs/auth.md#login-spec
30
- public struct AuthService {
31
- public func login(email: String, password: String) {}
32
- }
33
- ```
34
-
35
- Markdown side — a standalone HTML comment directly above the heading of the
36
- section:
37
-
38
- ```md
39
- <!-- @code src/auth/login.ts#login -->
40
-
41
- ## Login Spec
42
- ```
43
-
44
- Both targets are `file#fragment`: the file path is project-root-relative with
45
- `/` separators (no `./`, `../`, or absolute paths), and the fragment is
46
- required. Optional text after the target is allowed and ignored
47
- (`@doc docs/auth.md#login-spec human note`).
48
-
49
- ## Rules that decide whether the link resolves
50
-
51
- - `@doc` works only on top-level exported declarations: `function`, `class`,
52
- `abstract class`, `interface`, `type`, `enum`, `const enum`, `const` with a
53
- single declarator, named default `function`/`class`, and their `declare`
54
- forms. Anything else (anonymous default exports, multi-declarator `const`,
55
- namespaces, re-exports, non-exported declarations) produces
56
- `unsupported_declaration`.
57
- - Swift `@doc` works on supported public/open declarations and configured
58
- internal declarations. Member endpoints are type-qualified and include
59
- argument labels, for example `AuthService.login(email:password:)`.
60
- - Dart `@doc` works on supported public declarations. Member endpoints are
61
- type-qualified without parameter signatures, for example
62
- `AuthService.login`; setters carry a trailing `=`.
63
- - The code-side fragment is the scanner-produced canonical ID.
64
- - The doc-side fragment is the anchor generated from the ATX heading
65
- (`#`–`######`): lowercase via JavaScript `toLowerCase()`, Unicode letters
66
- and numbers preserved, whitespace and punctuation runs collapsed to `-`,
67
- leading/trailing `-` removed. Example: `## Login Spec (v2)` →
68
- `#login-spec-v2`. Setext headings have no anchors.
69
- - The `@code` comment must be standalone, indented at most 3 spaces, with the
70
- body starting with `@code`. Blank lines between the comment and its heading
71
- are fine; any other text in between makes it `dangling_code_annotation`.
72
- - One declaration may carry multiple `@doc` tags and one heading multiple
73
- `@code` comments; each pair is an independent link.
74
- - Anchors must be unique within one Markdown file; symbols must be unique
75
- among annotated declarations in one TypeScript file.
76
-
77
- ## Procedure
78
-
79
- 1. Identify the two endpoints: the exported declaration and the Markdown
80
- section. If the section does not exist yet, write it first — the heading
81
- text fixes the anchor.
82
- 2. Add the `@doc` tag to the declaration's documentation comment (create the
83
- documentation comment if missing), pointing at the doc file and the
84
- generated heading anchor.
85
- 3. Add the `@code` comment directly above the heading, pointing back at the
86
- code file and the scanner-produced canonical ID.
87
- 4. Verify with `docbridge check`. The link is correct only when no diagnostic
88
- mentions either endpoint.
89
-
90
- ## Diagnosing check failures
91
-
92
- | Diagnostic | Meaning | Usual fix |
93
- | ---------------------------------------------------- | ------------------------------------ | ----------------------------------------------------- |
94
- | `doc_file_not_found` / `code_file_not_found` | target file not in the managed set | fix the path, or extend `docbridge.config.json` globs |
95
- | `doc_anchor_not_found` | file found, anchor wrong | regenerate the anchor from the exact heading text |
96
- | `doc_backlink_not_found` / `code_backlink_not_found` | one direction missing | add the missing `@code` or `@doc` side |
97
- | `unsupported_declaration` | `@doc` on an unsupported declaration | move the tag to a supported declaration |
98
- | `dangling_code_annotation` | text between `@code` and the heading | move the comment directly above the heading |
99
- | `invalid_link_target` | malformed `file#fragment` | rewrite the target per the rules above |
@@ -1,80 +0,0 @@
1
- ---
2
- name: docbridge-link
3
- description: Link existing Markdown specification sections to existing supported code declarations. Use for docs-first candidate discovery, section-level confirmation, and adding @doc/@code annotations to existing projects.
4
- ---
5
-
6
- # docbridge-link
7
-
8
- Create DocBridge annotations for existing docs and code. Work docs-first: choose
9
- Markdown sections that look like specifications, then propose supported
10
- TypeScript, Swift, Dart, or Rust declarations that implement or represent each
11
- section.
12
-
13
- Run DocBridge with the project's native invocation: `docbridge` on `PATH`, a
14
- repo recipe such as `just check`, or
15
- `bun run /path/to/docbridge/src/cli/index.ts`.
16
-
17
- ## Procedure
18
-
19
- 1. **Determine docs scope.** Use the scope confirmed by `docbridge-adopt` when
20
- available. Otherwise, inspect the repository and ask the user to confirm the
21
- docs directories/files before proposing links.
22
-
23
- 2. **Find section candidates.**
24
- - Prioritize unlinked sections.
25
- - Include already linked sections at lower priority when an additional link
26
- may be justified.
27
- - Ignore sections that are clearly prose-only, changelog entries, runbook
28
- steps, or project process unless the user says they are specifications.
29
-
30
- 3. **For each candidate section, propose up to three code symbols.** Base the
31
- ranking on:
32
- - heading text and section body
33
- - exported symbol names
34
- - existing JSDoc and nearby comments
35
- - file paths and directory names
36
- - implementation body only when the surrounding information is insufficient
37
-
38
- Include both:
39
- - why the symbol may match
40
- - what remains uncertain
41
-
42
- 4. **Ask for section-level decisions.** Present 5-10 section candidates at a
43
- time. For each section the user can choose:
44
- - adopt: select one or more code symbols to link
45
- - exclude: do not link this section
46
- - hold: keep undecided for later
47
-
48
- The user may also name a symbol not in the proposed top three.
49
-
50
- 5. **Classify no-match sections.** If no reasonable exported symbol exists,
51
- report the likely reason instead of forcing a link:
52
- - not implemented yet
53
- - spans multiple symbols without a clear public representative
54
- - likely stale docs
55
- - not a specification section
56
- - target appears internal or not exported
57
-
58
- 6. **Add annotations only after confirmation.**
59
- - Add `@code` directly above the Markdown heading, as the nearest comment
60
- to the heading.
61
- - Add `@doc` to the code declaration's documentation comment.
62
- - If the declaration has no documentation comment, create a minimal one
63
- containing only `@doc`, using the language's documentation comment form.
64
- - If the pair already exists on one side, show it and, after confirmation,
65
- add the missing backlink.
66
- - Preserve existing annotations; do not replace or clean up suspicious links
67
- in this skill.
68
-
69
- 7. **Verify.** Run `docbridge check`, then inspect the affected links with
70
- `docbridge context` or `docbridge graph --json --include-content` for the
71
- changed files. Report any remaining diagnostics or semantic uncertainty.
72
-
73
- ## Boundaries
74
-
75
- - Do not split Markdown sections or rename headings. If a section is too broad
76
- or ambiguous, classify it as held or no-match.
77
- - Multiple code symbols may link to one docs section when each role is clear.
78
- - One code symbol may link to multiple docs sections when each section covers a
79
- distinct specification aspect.
80
- - Do not link solely because names are similar.