docbridge 0.8.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.
@@ -9,7 +9,7 @@ Route DocBridge work, then apply the matching judgment. Facts about the binary
9
9
  — annotation syntax, supported declarations, the anchor algorithm, diagnostic
10
10
  codes — live in packaged docs, not in this skill. Read them with
11
11
  `docbridge docs show`. Invocation is documented in
12
- `docbridge docs show agent-integration`.
12
+ `docbridge docs show automation`.
13
13
 
14
14
  An agent with no DocBridge skill can still finish the job from
15
15
  `docbridge --help` plus `docbridge docs list` / `docbridge docs show`.
@@ -51,7 +51,7 @@ Read `docbridge docs show getting-started` and `configuration`.
51
51
  ## Discover and link
52
52
 
53
53
  Work docs-first. Confirm docs scope, then follow
54
- `docbridge docs show linking-workflow`: prioritize unlinked specification
54
+ `docbridge docs show linking`: prioritize unlinked specification
55
55
  sections, propose at most three symbols per section with why/uncertain, present
56
56
  5–10 sections per round, collect adopt/exclude/hold, and classify no-matches
57
57
  instead of forcing a link.
@@ -61,7 +61,7 @@ Add annotations only after section-level confirmation. Then follow Annotate.
61
61
  ## Annotate
62
62
 
63
63
  Create both sides of a pair, or add the missing backlink. Read
64
- `docbridge docs show annotations` for syntax, supported declarations, anchors,
64
+ `docbridge docs show linking` for syntax, supported declarations, anchors,
65
65
  and target grammar. Read `docbridge docs show troubleshooting` for diagnostic
66
66
  codes and fixes.
67
67
 
@@ -76,11 +76,12 @@ unless the user asked to fix a wrong link.
76
76
  ## Sync
77
77
 
78
78
  A `related --gate` violation means nobody has decided yet, not that the
79
- counterpart must change. Read `docbridge docs show agent-integration` for the
79
+ counterpart must change. Read `docbridge docs show automation` for the
80
80
  three-way judgment.
81
81
 
82
- 1. Collect violations from the hook, CI comment, or
83
- `git diff --name-only HEAD | docbridge related --stdin --gate`.
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`.
84
85
  2. Fetch counterpart content with `docbridge context` over the changed files.
85
86
  3. Per counterpart: update it when the documented contract diverged; leave it
86
87
  unchanged with a written justification that cites the counterpart content;
@@ -94,8 +95,8 @@ promise.
94
95
 
95
96
  ## Review
96
97
 
97
- Audit meaning across the whole graph, not a diff. Follow
98
- `docbridge docs show link-review`.
98
+ Audit meaning across the whole graph, not a diff. Follow the semantic review
99
+ procedure in `docbridge docs show linking`.
99
100
 
100
101
  Requires `docbridge graph --json --include-content`. Read `diagnostics` first.
101
102
  Batch by docs file. Read both sides. Classify High / Medium / Low. Report
@@ -116,11 +117,9 @@ silence uncertainty.
116
117
  ## Read more
117
118
 
118
119
  - `docbridge docs list` — the full menu
119
- - `docbridge docs show agent-integration` — invocation, gate judgment, hooks, CI
120
- - `docbridge docs show annotations` — `@doc` / `@code` rules
121
- - `docbridge docs show linking-workflow` — docs-first candidate discovery
122
- - `docbridge docs show link-review` — semantic audit
120
+ - `docbridge docs show linking` — discovery, annotations, and semantic review
121
+ - `docbridge docs show automation` — invocation, gate judgment, hooks, and CI
123
122
  - `docbridge docs show troubleshooting` — diagnostic codes and fixes
124
123
  - `docbridge docs show getting-started` — first-time setup
125
124
  - `docbridge docs show configuration` — `docbridge.config.json`
126
- - `docbridge docs show commands` — check, related, context, graph
125
+ - `docbridge docs show commands` — check, related, context, graph, docs, upgrade
@@ -1,96 +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. An agent can do the whole
9
- job from `docbridge --help` plus `docbridge docs list` / `docbridge docs show`.
10
- A project skill is an accelerator, not a prerequisite.
11
-
12
- <!-- @code src/cli/init.ts#runInitWithAgent -->
13
-
14
- ## Invoking DocBridge
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
- `docbridge init` can create `docbridge.config.json` and copy the distributable
21
- `docbridge` skill for Codex, Claude Code, or both. To let an agent decide the
22
- scope, run:
23
-
24
- ```sh
25
- docbridge init-with-agent --agent-target codex
26
- ```
27
-
28
- Use `claude` or `both` for other supported targets. The command installs the
29
- skill and prints the next command or prompt; it does not launch an agent
30
- process.
31
-
32
- <!-- @code src/core/context.ts#context -->
33
- <!-- @code src/core/related.ts#related -->
34
-
35
- ## Editing workflow
36
-
37
- Before changing a linked file, provide its counterpart content:
38
-
39
- ```sh
40
- docbridge context path/to/changed-file
41
- ```
42
-
43
- After editing, inspect the change set:
44
-
45
- ```sh
46
- git diff --name-only | docbridge related --stdin --gate
47
- ```
48
-
49
- For every reported counterpart, choose one of three judgments:
50
-
51
- - Update the counterpart when behavior, contract, format, or constraint
52
- diverged.
53
- - Leave it unchanged, with a written justification that cites the counterpart
54
- content, when the change is internal and every documented statement still
55
- holds.
56
- - Fix the link itself when the annotation pair points at the wrong section or
57
- symbol.
58
-
59
- Do not detach a link only to silence the gate.
60
-
61
- ## Hooks
62
-
63
- Put the automation in Git hooks rather than in one agent's configuration, so
64
- it covers every contributor and every tool. A `pre-commit` hook can run
65
- `docbridge check` as a hard gate, then report `related --gate` over the staged
66
- files:
67
-
68
- ```sh
69
- git diff --cached --name-only | docbridge related --stdin --gate
70
- ```
71
-
72
- When an agent runs `git commit` through a shell, the hook's output lands in the
73
- tool result and therefore in the agent's context, so the counterpart findings
74
- reach it without any agent-specific wiring. Attach the counterparts' content
75
- with `docbridge context --stdin` to make the finding actionable in place.
76
-
77
- Keep the gate stage non-blocking while the link graph is still sparse: a
78
- blocking gate on a staged subset mostly trains `--no-verify`. Hooks must not
79
- silently rewrite files or replace the repository's mandatory checks.
80
-
81
- Git hooks cannot signal before an edit, and they are skipped by `--no-verify`
82
- and by some GUI clients, so the pull request stays the enforcement point.
83
-
84
- ## CI
85
-
86
- Run `docbridge check` over the whole project as the hard link-validity gate. A
87
- pull-request workflow can additionally pass the base-to-head changed file list
88
- to `related --stdin --gate` and attach `context` output for reviewers. Ensure
89
- the checkout includes both commits needed for the diff.
90
-
91
- ## Read more
92
-
93
- Run `docbridge docs list` for the full menu of packaged guides, then
94
- `docbridge docs show <name>` for a page. Start with `getting-started`,
95
- `annotations`, `linking-workflow`, `link-review`, `troubleshooting`, and
96
- `commands`.
@@ -1,173 +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 src/core/links.ts#parseLinkTarget -->
11
-
12
- ## Target grammar
13
-
14
- Both `@doc` and `@code` take a `file#fragment` target:
15
-
16
- - The file path is project-root-relative and uses `/` separators.
17
- - `./`, `../`, and absolute paths are invalid.
18
- - The fragment is required. File-only, fragment-only, and same-file targets
19
- are invalid.
20
- - Optional text after the target is allowed and ignored
21
- (`@doc docs/auth.md#login-spec human note`).
22
-
23
- One declaration may carry multiple `@doc` tags, and one heading may carry
24
- multiple `@code` comments. Each pair is an independent link. Duplicate
25
- annotations from the same source to the same target produce `duplicate_link`.
26
-
27
- ## Code to documentation
28
-
29
- Use a documentation path and heading anchor in a declaration's documentation
30
- comment:
31
-
32
- ```ts
33
- /**
34
- * @doc docs/auth.md#login-flow
35
- */
36
- export function login(): void {}
37
- ```
38
-
39
- ```swift
40
- /// @doc docs/auth.md#login-flow
41
- public func login(email: String, password: String) {}
42
- ```
43
-
44
- ```dart
45
- /// @doc docs/auth.md#login-flow
46
- void login(String email, String password) {}
47
- ```
48
-
49
- ```rust
50
- /// @doc docs/auth.md#login-flow
51
- pub fn login(email: &str, password: &str) {}
52
- ```
53
-
54
- Swift, Dart, and Rust use their normal documentation comment syntax. Paths are
55
- relative to the configured project root.
56
-
57
- An `@doc` on an unsupported declaration produces `unsupported_declaration`. The
58
- same declaration without `@doc` is ignored.
59
-
60
- ### TypeScript
61
-
62
- Supported top-level exported forms: `function`, `class`, `abstract class`,
63
- `interface`, `type`, `enum`, `const enum`, `const` with a single declarator,
64
- named default `function`/`class`, and their `declare` forms in `.ts` files.
65
- Type members are also supported: class methods, properties, getters, setters,
66
- constructors, and static members; interface property and method signatures;
67
- and property and method signatures of a type alias written as an object type
68
- literal.
69
-
70
- By default, `public` and `protected` members are included; `private` members
71
- are included only when `include.code.typescript.visibility` lists `private`.
72
- TypeScript `visibility` applies only to type members. Top-level declarations
73
- are scoped by `export`. Members excluded by visibility are not endpoints; an
74
- `@doc` on one is `unsupported_declaration`.
75
-
76
- Unsupported examples include anonymous default exports, multi-declarator
77
- `const`, namespaces, re-exports, non-exported declarations, members whose name
78
- is not a plain identifier, enum members, index signatures, call and construct
79
- signatures, and constructor parameter properties.
80
-
81
- Canonical IDs omit parameter signatures (`AuthService.login`,
82
- `AuthService.constructor`).
83
-
84
- ### Swift
85
-
86
- Supported forms include top-level and member `class`, `struct`, `enum`,
87
- `protocol`, and `actor`; top-level and member `func`, `var`, `let`, and
88
- `init`; and members declared in extensions, canonicalized as members of the
89
- extended type.
90
-
91
- By default only `public` and `open` declarations are included. `internal`
92
- declarations are included when `include.code.swift.visibility` lists
93
- `internal`. An `@doc` on a visibility-excluded declaration is
94
- `unsupported_declaration`.
95
-
96
- Member IDs are type-qualified and include argument labels, for example
97
- `AuthService.login(email:password:)`, `AuthService.refresh(_:)`, and
98
- `AuthService.init(email:password:)`.
99
-
100
- ### Dart
101
-
102
- Supported forms include top-level functions, getters, setters, and variables;
103
- `class`, `enum`, `mixin`, and their members; and members declared in
104
- extensions, canonicalized as members of the extended type.
105
-
106
- Only public declarations are scanned. Dart marks library-private names with a
107
- leading `_`, so an endpoint is excluded when any segment of its canonical ID
108
- starts with `_`, including a public member of a `_Private` type.
109
- `include.code.dart.visibility` accepts only `public`. An `@doc` on a
110
- visibility-excluded declaration is `unsupported_declaration`.
111
-
112
- Member IDs omit parameter signatures (`AuthService.login`). Setters carry a
113
- trailing `=` (`AuthService.token=`). The unnamed constructor is
114
- `AuthService.new`; named constructors keep their name (`AuthService.guest`).
115
-
116
- ### Rust
117
-
118
- Supported forms are `mod` (including nested modules), `struct`, `enum`, free
119
- `fn`, and inherent `impl` methods. Trait definitions, trait-impl methods,
120
- macros, const/static items, unions, and extern blocks are unsupported.
121
-
122
- By default only unrestricted `pub` declarations are included. A plain `fn` or
123
- `struct` without `pub` is not an endpoint. Non-`pub` items are included when
124
- `include.code.rust.visibility` lists `private`. An `@doc` on a
125
- visibility-excluded declaration is `unsupported_declaration`.
126
-
127
- Canonical IDs use `::` path qualification, for example `normalize`,
128
- `TypingEngine`, `TypingEngine::advance`, and `domain::typing`.
129
-
130
- <!-- @code src/core/markdown.ts#scanMarkdown -->
131
-
132
- ## Documentation to code
133
-
134
- Place a standalone HTML comment immediately before the linked heading. The
135
- comment may be indented by 0 to 3 spaces; 4 or more spaces are ignored. The
136
- trimmed comment body must start with `@code`. Blank lines between the comment
137
- and the heading are allowed. Any other text in between produces
138
- `dangling_code_annotation`.
139
-
140
- ```md
141
- <!-- @code src/auth.ts#login -->
142
-
143
- ## Login Flow
144
- ```
145
-
146
- The code fragment is the canonical symbol ID emitted by the language scanner.
147
- Use that ID exactly in the `@code` target.
148
-
149
- ## Anchors and reciprocity
150
-
151
- Anchors come from ATX headings (`#` through `######`) only. Setext headings
152
- have no anchors. Empty headings do not create linkable anchors; a `@code`
153
- attached to an empty heading is `dangling_code_annotation`.
154
-
155
- The algorithm:
156
-
157
- 1. Take the heading text after the `#` markers.
158
- 2. Lowercase with JavaScript `toLowerCase()`.
159
- 3. Collapse runs of whitespace and punctuation to `-`. Unicode letters and
160
- numbers are preserved.
161
- 4. Strip leading and trailing `-`.
162
-
163
- Example: `## Login Spec (v2)` becomes `#login-spec-v2`. `# Login Flow`
164
- becomes `#login-flow`.
165
-
166
- Duplicate non-empty anchors in the same Markdown file produce
167
- `duplicate_doc_anchor`. The same anchor in different files is allowed.
168
- DocBridge does not add GitHub-style numeric suffixes.
169
-
170
- Each direction is validated independently. A target can resolve while still
171
- reporting a missing reciprocal annotation. Run `docbridge check` to validate
172
- targets and pair completeness, and `docbridge graph --json` when you need the
173
- resolved endpoints and edges.
@@ -1,53 +0,0 @@
1
- ---
2
- description: Audit existing links for semantic correctness, not just resolution.
3
- ---
4
-
5
- # Link Review
6
-
7
- Audit the semantic validity of the entire DocBridge graph. This is not a
8
- change-set or pull-request review, and it is not `related --gate` triage. It
9
- checks whether valid links actually connect a docs section to the code symbol
10
- that implements or represents that specification.
11
-
12
- `docbridge check` proves link mechanics. This review judges meaning. Do not
13
- rubber-stamp a link because the target resolves.
14
-
15
- ## Procedure
16
-
17
- 1. Build the graph:
18
-
19
- ```sh
20
- docbridge graph --json --include-content
21
- ```
22
-
23
- Read `diagnostics` first. Mechanical failures from `docbridge check`
24
- should be fixed or acknowledged before relying on semantic findings.
25
-
26
- 2. Batch by docs file. Review all links, but process them in batches:
27
- - the docs file is the default batch boundary
28
- - split a batch further when it contains too many sections or links
29
- - keep notes so repeated patterns are applied consistently across batches
30
-
31
- 3. Read both sides.
32
- - For docs nodes, use the graph range to read the full Markdown section.
33
- - For code nodes, start with graph content: documentation comment plus
34
- signature. Read the implementation only when necessary to judge the
35
- relationship.
36
- - Compare behavior, contract, input/output, constraints, and design
37
- intent.
38
-
39
- 4. Classify findings.
40
- - High: clearly wrong link, stale docs fixed in place by a link, or a
41
- link to a section that is not a specification.
42
- - Medium: partial overlap, unclear representative symbol, overly broad
43
- section, or multiple linked symbols with ambiguous roles.
44
- - Low: cleanup opportunity, duplicate docs, excessive links, or missing
45
- explanation of why multiple links are needed.
46
-
47
- 5. Report findings. For each finding include severity, the doc endpoint, the
48
- code endpoint, evidence from both sides, and a recommended fix.
49
-
50
- Do not edit annotations automatically. Prefer fewer, clearer links over
51
- broad many-to-many links without explicit roles. Do not delete annotations
52
- merely to silence uncertainty; explain the uncertainty and ask for a
53
- decision.
@@ -1,70 +0,0 @@
1
- ---
2
- description: Choose what to link and propose candidates docs-first.
3
- ---
4
-
5
- # Linking Workflow
6
-
7
- Choose Markdown sections that look like specifications, then propose supported
8
- code declarations that implement or represent each section. Add annotations
9
- only after a section-level decision.
10
-
11
- ## What to link
12
-
13
- Prefer sections that state behavior, contracts, inputs/outputs, constraints,
14
- user-visible behavior, or design decisions.
15
-
16
- Treat README files, changelogs, contribution docs, runbooks, logs, and
17
- release notes as exclusions by default unless a specific section is identified
18
- as a specification.
19
-
20
- Prefer supported public API declarations as link targets. TypeScript starts
21
- with top-level exported declarations; Swift, Dart, and Rust also support
22
- member endpoints. Use the scanner-produced canonical ID exactly; see
23
- `docbridge docs show annotations`.
24
-
25
- Do not decide project workflow policy such as branch or pull-request
26
- strategy.
27
-
28
- ## Propose candidates
29
-
30
- 1. Confirm docs scope first. Inspect the repository and agree the
31
- documentation directories before proposing links.
32
- 2. Find section candidates. Prioritize unlinked sections. Include already
33
- linked sections at lower priority when an additional link may be justified.
34
- Ignore prose-only sections, changelog entries, runbook steps, and project
35
- process unless they are specifications.
36
- 3. For each candidate section, propose at most three code symbols. Rank them
37
- from heading text and section body, exported symbol names, existing
38
- documentation comments, file paths, and the implementation body only when
39
- that surrounding information is insufficient. For each symbol, state why it
40
- may match and what remains uncertain.
41
- 4. Present 5–10 section candidates per round. For each section, choose:
42
- - adopt: select one or more code symbols to link
43
- - exclude: do not link this section
44
- - hold: keep undecided for later
45
-
46
- A symbol that is not in the proposed top three may still be named.
47
-
48
- 5. Classify no-match sections instead of forcing a link:
49
- - not implemented yet
50
- - spans multiple symbols without a clear public representative
51
- - likely stale docs
52
- - not a specification section
53
- - target appears internal or not exported
54
-
55
- ## After confirmation
56
-
57
- Add `@code` directly above the Markdown heading and `@doc` on the chosen
58
- declaration. If the declaration has no documentation comment, create a
59
- minimal one containing only `@doc`. If one side already exists, show it and
60
- add the missing backlink after confirmation. Preserve existing annotations;
61
- do not replace or clean up suspicious links in this pass.
62
-
63
- Do not split Markdown sections or rename headings. If a section is too broad
64
- or ambiguous, classify it as held or no-match. Multiple code symbols may link
65
- to one docs section when each role is clear. One code symbol may link to
66
- multiple docs sections when each section covers a distinct specification
67
- aspect. Do not link solely because names are similar.
68
-
69
- Verify with `docbridge check`, then inspect the affected links with
70
- `docbridge context` or `docbridge graph --json --include-content`.