docbridge 0.4.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 +142 -0
- package/LICENSE +21 -0
- package/README.md +420 -0
- package/dist/bin/darwin-arm64/SHA256SUMS +2 -0
- package/dist/bin/darwin-arm64/speclink-swift-scanner +0 -0
- package/dist/bin/darwin-arm64/speclink_dart_scanner +0 -0
- package/dist/bin/linux-x64/SHA256SUMS +2 -0
- package/dist/bin/linux-x64/speclink-swift-scanner +0 -0
- package/dist/bin/linux-x64/speclink_dart_scanner +0 -0
- package/dist/index.js +172272 -0
- package/package.json +48 -0
- package/schemas/context-output.schema.json +111 -0
- package/schemas/docbridge.schema.json +58 -0
- package/schemas/graph-output.schema.json +186 -0
- package/templates/skills/README.md +31 -0
- package/templates/skills/docbridge-adopt/SKILL.md +78 -0
- package/templates/skills/docbridge-annotate/SKILL.md +98 -0
- package/templates/skills/docbridge-link/SKILL.md +80 -0
- package/templates/skills/docbridge-review/SKILL.md +62 -0
- package/templates/skills/docbridge-sync/SKILL.md +68 -0
|
@@ -0,0 +1,80 @@
|
|
|
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, or Dart 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.
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: docbridge-review
|
|
3
|
+
description: Review all existing DocBridge links for semantic validity. Use after adoption or periodically to find valid-but-wrong links, stale docs, excessive links, or ambiguous docs/code relationships.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# docbridge-review
|
|
7
|
+
|
|
8
|
+
Review the semantic validity of the entire DocBridge graph. This is not a
|
|
9
|
+
change-set or pull-request review. It checks whether valid links actually
|
|
10
|
+
connect a docs section to the code symbol that implements or represents that
|
|
11
|
+
specification.
|
|
12
|
+
|
|
13
|
+
This skill requires `docbridge graph --json --include-content`.
|
|
14
|
+
|
|
15
|
+
## Procedure
|
|
16
|
+
|
|
17
|
+
1. **Build the graph.**
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
docbridge graph --json --include-content
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
If the repository uses a wrapper, use the native invocation instead. Read
|
|
24
|
+
`diagnostics` first. Mechanical failures from `docbridge check` should be
|
|
25
|
+
fixed or acknowledged before relying on semantic findings.
|
|
26
|
+
|
|
27
|
+
2. **Batch by docs file.** Review all links, but process them in batches:
|
|
28
|
+
- docs file is the default batch boundary
|
|
29
|
+
- split a batch further when it contains too many sections or links
|
|
30
|
+
- keep notes so repeated patterns are applied consistently across batches
|
|
31
|
+
|
|
32
|
+
3. **Read both sides.**
|
|
33
|
+
- For docs nodes, use the graph range to read the full Markdown section.
|
|
34
|
+
- For code nodes, start with graph content: JSDoc plus signature. Read the
|
|
35
|
+
implementation only when necessary to judge the relationship.
|
|
36
|
+
- Compare behavior, contract, input/output, constraints, and design intent.
|
|
37
|
+
|
|
38
|
+
4. **Classify findings.**
|
|
39
|
+
- High: clearly wrong link, stale docs fixed in place by a link, or a link
|
|
40
|
+
to a section that is not a specification.
|
|
41
|
+
- Medium: partial overlap, unclear representative symbol, overly broad
|
|
42
|
+
section, or multiple linked symbols with ambiguous roles.
|
|
43
|
+
- Low: cleanup opportunity, duplicate docs, excessive links, or missing
|
|
44
|
+
explanation of why multiple links are needed.
|
|
45
|
+
|
|
46
|
+
5. **Report findings and fixes.** For each finding include:
|
|
47
|
+
- severity
|
|
48
|
+
- doc endpoint and code endpoint
|
|
49
|
+
- evidence from both sides
|
|
50
|
+
- recommended fix
|
|
51
|
+
|
|
52
|
+
Do not edit annotations automatically. If the user approves a fix, use
|
|
53
|
+
`docbridge-link` or `docbridge-annotate` rules to make the change.
|
|
54
|
+
|
|
55
|
+
## Principles
|
|
56
|
+
|
|
57
|
+
- `docbridge check` proves link mechanics; this skill reviews meaning.
|
|
58
|
+
- Do not rubber-stamp links because the target resolves.
|
|
59
|
+
- Do not delete annotations merely to silence uncertainty. Explain the
|
|
60
|
+
uncertainty and ask for a decision.
|
|
61
|
+
- Prefer fewer, clearer links over broad many-to-many links without explicit
|
|
62
|
+
roles.
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: docbridge-sync
|
|
3
|
+
description: Triage DocBridge related-gate findings — linked counterparts of changed files that were not themselves updated. Use when a Stop-hook message, CI comment, or docbridge related --gate run flags unchanged counterparts, to judge divergence with docbridge context and then update or justify each one.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# docbridge-sync
|
|
7
|
+
|
|
8
|
+
Resolve `docbridge related --gate` findings. A gate violation means a changed
|
|
9
|
+
file has a linked counterpart that nobody updated — it does **not** mean the
|
|
10
|
+
counterpart must change; it means nobody has decided yet. This skill makes
|
|
11
|
+
that decision explicit, per counterpart.
|
|
12
|
+
|
|
13
|
+
Run DocBridge with the project's native invocation: `docbridge` on `PATH`, a
|
|
14
|
+
repo recipe such as `just related-gate`, or
|
|
15
|
+
`bun run /path/to/docbridge/src/cli/index.ts`.
|
|
16
|
+
|
|
17
|
+
## Procedure
|
|
18
|
+
|
|
19
|
+
1. **Collect the violations.** Use the gate report you were given (Stop-hook
|
|
20
|
+
message, CI comment), or produce one over the change set:
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
git diff --name-only HEAD | docbridge related --stdin --gate
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Each violation names a changed endpoint and its unchanged counterpart
|
|
27
|
+
endpoint.
|
|
28
|
+
|
|
29
|
+
2. **Fetch the counterpart content.** If the report did not include it, run
|
|
30
|
+
the context command over the changed files; its output is the counterparts'
|
|
31
|
+
content:
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
git diff --name-only HEAD | docbridge context --stdin
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Read the block for each flagged counterpart: the full spec section for a
|
|
38
|
+
doc counterpart, the full declaration including JSDoc for a code one.
|
|
39
|
+
|
|
40
|
+
3. **Judge divergence, per counterpart.** Compare what the counterpart says
|
|
41
|
+
with what the change did:
|
|
42
|
+
- Behavior, contract, format, or constraint described by the counterpart no
|
|
43
|
+
longer matches → **update the counterpart** in the same change set.
|
|
44
|
+
- The change is internal (refactoring, comments, test-only, formatting) and
|
|
45
|
+
every documented statement still holds → **no update**, with a written
|
|
46
|
+
justification.
|
|
47
|
+
- The link itself is wrong (points at the wrong section or symbol) → fix
|
|
48
|
+
the annotation pair instead; follow the `docbridge-annotate` skill.
|
|
49
|
+
|
|
50
|
+
4. **Re-run the gate** after updates. Counterparts you edited leave the
|
|
51
|
+
violation list; what remains must be covered by justifications.
|
|
52
|
+
|
|
53
|
+
5. **Report every decision.** In the final response (and the PR description
|
|
54
|
+
when one exists), list each flagged counterpart with either the update made
|
|
55
|
+
or the justification. A justification must reference the counterpart's
|
|
56
|
+
actual content ("the section documents the exit codes, which this change
|
|
57
|
+
does not alter"), not just assert irrelevance.
|
|
58
|
+
|
|
59
|
+
## Principles
|
|
60
|
+
|
|
61
|
+
- Never silence a violation by deleting or rewriting annotations to detach
|
|
62
|
+
the link; that defeats the graph the gate protects.
|
|
63
|
+
- Do not rubber-stamp: if the counterpart content was not read, the judgment
|
|
64
|
+
has no basis.
|
|
65
|
+
- Updating a spec section to match changed code is a *decision about the
|
|
66
|
+
contract*, not bookkeeping — when the change contradicts an explicit
|
|
67
|
+
documented promise, surface it to the user instead of quietly rewriting the
|
|
68
|
+
promise.
|