docbridge 0.6.1 → 0.8.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.
- package/CHANGELOG.md +132 -1
- package/README.md +78 -42
- package/dist/bin/darwin-arm64/SHA256SUMS +3 -2
- package/dist/bin/darwin-arm64/docbridge-rust-scanner +0 -0
- package/dist/bin/darwin-arm64/docbridge-swift-scanner +0 -0
- package/dist/bin/darwin-arm64/docbridge_dart_scanner +0 -0
- package/dist/bin/linux-x64/SHA256SUMS +3 -2
- package/dist/bin/linux-x64/docbridge-rust-scanner +0 -0
- package/dist/bin/linux-x64/docbridge-swift-scanner +0 -0
- package/dist/bin/linux-x64/docbridge_dart_scanner +0 -0
- package/dist/index.js +8599 -987
- package/docs/user/agent-integration.md +96 -0
- package/docs/user/annotations.md +173 -0
- package/docs/user/commands.md +64 -0
- package/docs/user/configuration.md +77 -0
- package/docs/user/getting-started.md +75 -0
- package/docs/user/link-review.md +53 -0
- package/docs/user/linking-workflow.md +70 -0
- package/docs/user/troubleshooting.md +61 -0
- package/package.json +4 -2
- package/schemas/common-output.schema.json +56 -0
- package/schemas/context-output.schema.json +2 -32
- package/schemas/docbridge.schema.json +77 -7
- package/schemas/graph-output.schema.json +6 -52
- package/schemas/scanner-worker.schema.json +122 -0
- package/templates/skills/README.md +17 -25
- package/templates/skills/docbridge/SKILL.md +126 -0
- package/templates/skills/docbridge-adopt/SKILL.md +0 -96
- package/templates/skills/docbridge-annotate/SKILL.md +0 -99
- package/templates/skills/docbridge-link/SKILL.md +0 -80
- package/templates/skills/docbridge-review/SKILL.md +0 -62
- package/templates/skills/docbridge-sync/SKILL.md +0 -68
|
@@ -0,0 +1,96 @@
|
|
|
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`.
|
|
@@ -0,0 +1,173 @@
|
|
|
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.
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Choose between check, related, context, and graph.
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Commands
|
|
6
|
+
|
|
7
|
+
Use the narrowest command for the question you need to answer.
|
|
8
|
+
|
|
9
|
+
<!-- @code src/cli/index.ts#run -->
|
|
10
|
+
|
|
11
|
+
## Command dispatch
|
|
12
|
+
|
|
13
|
+
The first argument selects a command. Global `--help` and `--version` are
|
|
14
|
+
handled before project scanning, while each command validates its own options.
|
|
15
|
+
|
|
16
|
+
<!-- @code src/core/resolver.ts#check -->
|
|
17
|
+
|
|
18
|
+
### `check`: validate the project
|
|
19
|
+
|
|
20
|
+
Run `docbridge check` before committing and in CI. It validates configuration,
|
|
21
|
+
annotations, targets, and reciprocal links. Add `--audit` to include warnings
|
|
22
|
+
for undocumented code declarations and unlinked Markdown sections. Add
|
|
23
|
+
`--json` for machine-readable diagnostics.
|
|
24
|
+
|
|
25
|
+
<!-- @code src/core/related.ts#related -->
|
|
26
|
+
|
|
27
|
+
### `related`: find counterpart files
|
|
28
|
+
|
|
29
|
+
Pass changed paths to learn which linked files may also need attention:
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
git diff --name-only | docbridge related --stdin
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
`--gate` exits `1` when a linked counterpart is absent from the supplied change
|
|
36
|
+
set. It identifies review obligations; it does not decide whether the
|
|
37
|
+
counterpart actually needs an edit.
|
|
38
|
+
|
|
39
|
+
<!-- @code src/core/context.ts#context -->
|
|
40
|
+
|
|
41
|
+
### `context`: read counterpart content
|
|
42
|
+
|
|
43
|
+
Use `context` when a human or agent needs the linked sections themselves:
|
|
44
|
+
|
|
45
|
+
```sh
|
|
46
|
+
docbridge context src/auth.ts
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
The default Markdown output is suitable for an agent prompt. `--json` returns
|
|
50
|
+
structured contexts, diagnostics, and a summary.
|
|
51
|
+
|
|
52
|
+
<!-- @code src/core/graph-output.ts#graph -->
|
|
53
|
+
|
|
54
|
+
### `graph`: inspect link structure
|
|
55
|
+
|
|
56
|
+
Use `graph` for endpoints, edges, reciprocal pairs, and unresolved links across
|
|
57
|
+
the project. Passing file paths scopes the result to those files and their
|
|
58
|
+
direct counterparts. `--include-content` is available only with `--json`.
|
|
59
|
+
|
|
60
|
+
## Common options
|
|
61
|
+
|
|
62
|
+
The project commands accept `--root <path>` when invoked outside the project
|
|
63
|
+
root. Run `docbridge <command> --help` for the exact options and exit behavior
|
|
64
|
+
of a command.
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "Configure docbridge.config.json: roots, includes, excludes, languages."
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Configuration
|
|
6
|
+
|
|
7
|
+
DocBridge loads `docbridge.config.json` from the project root supplied by
|
|
8
|
+
`--root`, or from the current directory by default. Paths and glob patterns are
|
|
9
|
+
interpreted relative to that root.
|
|
10
|
+
|
|
11
|
+
<!-- @code src/core/config.ts#loadConfig -->
|
|
12
|
+
|
|
13
|
+
## Loading configuration
|
|
14
|
+
|
|
15
|
+
The configuration loader requires the file, validates its schema, and rejects
|
|
16
|
+
source files claimed by more than one configured language.
|
|
17
|
+
|
|
18
|
+
## Minimal configuration
|
|
19
|
+
|
|
20
|
+
Declare documentation patterns and at least one supported code language:
|
|
21
|
+
|
|
22
|
+
```json
|
|
23
|
+
{
|
|
24
|
+
"$schema": "./node_modules/docbridge/schemas/docbridge.schema.json",
|
|
25
|
+
"include": {
|
|
26
|
+
"code": {
|
|
27
|
+
"typescript": {
|
|
28
|
+
"patterns": ["src/**/*.ts"]
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"docs": ["docs/**/*.md"]
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Supported language keys are `typescript`, `swift`, `dart`, and `rust`. A project can
|
|
37
|
+
enable more than one language, each with its own patterns.
|
|
38
|
+
|
|
39
|
+
Each language accepts an optional `visibility` array. Omitting it uses the
|
|
40
|
+
scanner default: TypeScript `public` and `protected` members, Swift `public`
|
|
41
|
+
and `open`, Dart `public` only, Rust unrestricted `pub`. A declaration
|
|
42
|
+
excluded by visibility is not an endpoint; an `@doc` on one is
|
|
43
|
+
`unsupported_declaration`. See `docbridge docs show annotations` for the
|
|
44
|
+
per-language rules, including Dart's leading-underscore privacy.
|
|
45
|
+
|
|
46
|
+
<!-- @code src/core/glob.ts#collectFiles -->
|
|
47
|
+
|
|
48
|
+
## Excluded files
|
|
49
|
+
|
|
50
|
+
The configuration has no `exclude` property. Narrow the include patterns when
|
|
51
|
+
tests, fixtures, generated files, or general documentation should stay outside
|
|
52
|
+
the graph:
|
|
53
|
+
|
|
54
|
+
```json
|
|
55
|
+
{
|
|
56
|
+
"include": {
|
|
57
|
+
"code": {
|
|
58
|
+
"typescript": {
|
|
59
|
+
"patterns": ["src/domain/**/*.ts", "src/services/**/*.ts"]
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"docs": ["docs/specs/**/*.md"]
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
DocBridge always ignores dependency directories, Git metadata, dot-prefixed
|
|
68
|
+
path segments, symbolic links, and TypeScript declaration files (`.d.ts`).
|
|
69
|
+
Keep patterns narrow enough that `docbridge check --audit` reports useful
|
|
70
|
+
coverage gaps rather than every implementation detail or general prose file.
|
|
71
|
+
|
|
72
|
+
## Validate changes
|
|
73
|
+
|
|
74
|
+
Run `docbridge check` after editing configuration. A missing, malformed, or
|
|
75
|
+
schema-invalid configuration produces `config_file_invalid`. Use
|
|
76
|
+
`docbridge init --dry-run` to inspect a safe generated starting point without
|
|
77
|
+
overwriting an existing file.
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Set up DocBridge in an existing TypeScript, Swift, Dart, or Rust project.
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Getting Started
|
|
6
|
+
|
|
7
|
+
DocBridge checks that Markdown documentation and supported code declarations
|
|
8
|
+
link to each other. It scans only the files selected by
|
|
9
|
+
`docbridge.config.json`; it does not send source or documentation anywhere.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
Add DocBridge to a project with the package manager used by that project:
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
npm install --save-dev docbridge
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
The CLI supports Node.js 22 or later and Bun 1.1.31 or later.
|
|
20
|
+
|
|
21
|
+
<!-- @code src/cli/init.ts#runInit -->
|
|
22
|
+
|
|
23
|
+
## Set up a project
|
|
24
|
+
|
|
25
|
+
Preview the files DocBridge would create:
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
npx docbridge init --dry-run
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Then run `npx docbridge init` interactively, or use `--yes` when the detected
|
|
32
|
+
scope is unambiguous. The command can create `docbridge.config.json` and install
|
|
33
|
+
the distributable `docbridge` skill for Codex, Claude Code, or both. It never
|
|
34
|
+
overwrites an existing configuration.
|
|
35
|
+
|
|
36
|
+
If a coding agent should choose the documentation and code scope, use:
|
|
37
|
+
|
|
38
|
+
```sh
|
|
39
|
+
npx docbridge init-with-agent
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Add the first reciprocal link
|
|
43
|
+
|
|
44
|
+
Add `@doc` to a supported declaration and `@code` before the matching Markdown
|
|
45
|
+
heading. Both targets are relative to the project root:
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
/** @doc docs/auth.md#login-flow */
|
|
49
|
+
export function login(): void {}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
```md
|
|
53
|
+
<!-- @code src/auth.ts#login -->
|
|
54
|
+
|
|
55
|
+
## Login Flow
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Run the quality gate:
|
|
59
|
+
|
|
60
|
+
```sh
|
|
61
|
+
npx docbridge check
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
A clean graph exits `0`. Broken links and invalid configuration exit `1`.
|
|
65
|
+
|
|
66
|
+
## Next steps
|
|
67
|
+
|
|
68
|
+
- Read `docbridge docs show configuration` before narrowing scan scope.
|
|
69
|
+
- Read `docbridge docs show annotations` for link target rules.
|
|
70
|
+
- Read `docbridge docs show linking-workflow` to choose sections and propose
|
|
71
|
+
candidates.
|
|
72
|
+
- Read `docbridge docs show link-review` to audit existing links for meaning.
|
|
73
|
+
- Read `docbridge docs show commands` to choose an inspection command.
|
|
74
|
+
- Read `docbridge docs show troubleshooting` when `check` reports a diagnostic.
|
|
75
|
+
- Add `docbridge check` to CI after the local graph passes.
|
|
@@ -0,0 +1,53 @@
|
|
|
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.
|
|
@@ -0,0 +1,70 @@
|
|
|
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`.
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Diagnose configuration, scanner, parsing, and broken-link errors.
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Troubleshooting
|
|
6
|
+
|
|
7
|
+
Start with the first error line, then follow any recovery guidance printed on
|
|
8
|
+
stderr. Use `docbridge <command> --help` for invocation errors and
|
|
9
|
+
`docbridge check --json` when a tool needs stable diagnostic fields.
|
|
10
|
+
|
|
11
|
+
## Configuration errors
|
|
12
|
+
|
|
13
|
+
`config_file_invalid` means `docbridge.config.json` is missing, malformed, or
|
|
14
|
+
does not match the schema. Run `docbridge init --dry-run` when the file is
|
|
15
|
+
missing. When it exists, repair or remove it before running `check` again.
|
|
16
|
+
|
|
17
|
+
`config_unknown_key` and `config_invalid_value` mean a present file has a key
|
|
18
|
+
or value the schema rejects. Confirm that include patterns match real files
|
|
19
|
+
relative to the selected `--root`, language keys are supported, and excludes
|
|
20
|
+
do not remove an intended link target.
|
|
21
|
+
|
|
22
|
+
## Scanner errors
|
|
23
|
+
|
|
24
|
+
Swift, Dart, and Rust use packaged scanner workers. A
|
|
25
|
+
`code_scanner_unavailable` diagnostic usually means the installed package
|
|
26
|
+
lacks a binary for the current platform or the binary cannot execute.
|
|
27
|
+
Reinstall the package first. If the platform is not supported, run DocBridge
|
|
28
|
+
in a supported environment or build the scanner from the repository.
|
|
29
|
+
|
|
30
|
+
`code_scanner_failed` diagnostics contain the worker failure rather than
|
|
31
|
+
converting it into a broken link. Check that the source parses with the
|
|
32
|
+
project's own toolchain, then reproduce with the smallest configured file
|
|
33
|
+
set.
|
|
34
|
+
|
|
35
|
+
## Link-authoring errors
|
|
36
|
+
|
|
37
|
+
These codes appear while writing `@doc` / `@code` pairs:
|
|
38
|
+
|
|
39
|
+
| Diagnostic | Meaning | Usual fix |
|
|
40
|
+
| ---------------------------------------------------- | ---------------------------------------- | ----------------------------------------------------- |
|
|
41
|
+
| `doc_file_not_found` / `code_file_not_found` | target file not in the managed set | fix the path, or extend `docbridge.config.json` globs |
|
|
42
|
+
| `doc_anchor_not_found` | file found, anchor wrong | regenerate the anchor from the exact heading text |
|
|
43
|
+
| `doc_backlink_not_found` / `code_backlink_not_found` | one direction missing | add the missing `@code` or `@doc` side |
|
|
44
|
+
| `unsupported_declaration` | `@doc` on an unsupported declaration | move the tag to a supported declaration |
|
|
45
|
+
| `dangling_code_annotation` | text between `@code` and the heading | move the comment directly above the heading |
|
|
46
|
+
| `invalid_link_target` | malformed `file#fragment` | rewrite the target; see `docs show annotations` |
|
|
47
|
+
| `duplicate_doc_anchor` | two headings share an anchor in one file | rename one heading so anchors stay unique |
|
|
48
|
+
| `duplicate_code_symbol` | two annotated declarations share an ID | keep one `@doc` per canonical ID in that file |
|
|
49
|
+
| `duplicate_link` | the same source repeats the same target | remove the extra annotation |
|
|
50
|
+
|
|
51
|
+
Use `docbridge graph --json` to inspect resolved and one-way edges. Use
|
|
52
|
+
`docbridge context <file>` to confirm which counterpart content DocBridge can
|
|
53
|
+
currently resolve.
|
|
54
|
+
|
|
55
|
+
<!-- @code src/cli/errors.ts#formatCliError -->
|
|
56
|
+
|
|
57
|
+
## CLI invocation errors
|
|
58
|
+
|
|
59
|
+
Unknown commands, unknown options, missing values, invalid roots, and missing
|
|
60
|
+
required inputs exit `1`, write to stderr, and leave stdout empty. These are not
|
|
61
|
+
included in diagnostic JSON because the project scan did not run.
|