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 ADDED
@@ -0,0 +1,142 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [0.4.0] - 2026-06-18
11
+
12
+ ### Added
13
+
14
+ - npm distribution support for the Bun-only `speclink` package, including
15
+ `dist/index.js` as the package binary, a runtime package allowlist, dist
16
+ verification, packed-package smoke testing, and release workflow publishing.
17
+ - Platform-staged Swift and Dart scanner binary layout under
18
+ `dist/bin/<platform>/`, with initial npm scanner support for `darwin-arm64`
19
+ and `linux-x64`.
20
+ - Dart scanner worker support, including analyzer-based `@doc` extraction,
21
+ type/member canonical IDs (without parameter signatures, since Dart has no
22
+ overloading), public-by-naming visibility, and Dart end-to-end
23
+ check/context/graph/LSP integration. The Dart toolchain is provided by the Nix
24
+ dev shell.
25
+ - Swift scanner worker support for SwiftPM source checkouts, including
26
+ SwiftSyntax-based `@doc` extraction, type/member canonical IDs, visibility
27
+ filtering, and Swift end-to-end check/context/graph/LSP integration.
28
+ - Worker-backed scanner protocol foundation for Swift and Dart adapters,
29
+ including stdin/stdout JSON invocation and scanner availability/failure
30
+ diagnostics.
31
+ - `speclink graph`: prints the resolved link graph as human-readable output or
32
+ as JSON following `schemas/graph-output.schema.json`, including resolvable
33
+ one-way links, pair completeness, optional lightweight node content, and
34
+ diagnostics that do not prevent graph construction.
35
+ - Distributable adoption skills under `templates/skills/`: `speclink-adopt`
36
+ for existing-project setup, `speclink-link` for docs-first annotation
37
+ candidate confirmation, and `speclink-review` for whole-graph semantic
38
+ review using `speclink graph --json --include-content`.
39
+
40
+ ### Changed
41
+
42
+ - `speclink context` and `speclink graph --json` now carry code language
43
+ metadata for code blocks/nodes so Swift endpoints render and serialize as
44
+ Swift.
45
+ - SpecLink's distributable skills are now dogfooded from `.agents/skills/` and
46
+ `.claude/skills/` as symlinks to the canonical `templates/skills/` entries.
47
+ - TypeScript scanner endpoints now include `signatureRange` in addition to the
48
+ existing full `declarationRange`, allowing graph consumers to read the
49
+ public JSDoc/signature surface without implementation bodies.
50
+
51
+ ### Fixed
52
+
53
+ - Worker-backed scanner responses now fail when the returned file list does not
54
+ exactly match the requested files, and worker failures suppress derived link
55
+ diagnostics for the failed file.
56
+ - The npm-distributed CLI now resolves its bundled `dist/bin/<platform>` Swift
57
+ and Dart scanner binaries when launched through the `node_modules/.bin`
58
+ symlink, which previously resolved to the wrong directory on Linux and
59
+ reported the scanner as unavailable.
60
+
61
+ ## [0.3.0] - 2026-06-14
62
+
63
+ ### Added
64
+
65
+ - `speclink context`: prints the content of the counterparts linked from a set
66
+ of input files (positional arguments or newline-separated stdin via
67
+ `--stdin`) — full Markdown sections for doc counterparts, full declarations
68
+ including JSDoc for code counterparts. Default output is Markdown suitable
69
+ for direct injection into an agent prompt; `--json` emits a machine-readable
70
+ report following `schemas/context-output.schema.json`. Extraction is
71
+ best-effort: check diagnostics located in the input files are reported on
72
+ stderr (or in the `diagnostics` field) without affecting the exit code.
73
+ - TypeScript scanner: records a `declarationRange` covering each supported
74
+ declaration including its JSDoc block, backing `context` content extraction.
75
+ - `just context`: prints the linked counterpart content of the uncommitted
76
+ changes.
77
+ - AI integration recipes under `docs/integrations/`: on-edit counterpart
78
+ awareness and gate triage for Claude Code and Codex, and a CI recipe for
79
+ gating the PR change set and reporting counterpart content.
80
+ - Copyable agent hook scripts under `examples/hooks/`: a `PostToolUse` hook
81
+ that surfaces linked counterpart content on edit, and a `Stop` hook that
82
+ reports `related --gate` findings with the flagged counterparts' content as
83
+ Stop `additionalContext`.
84
+ - Distributable agent skills under `templates/skills/`: `speclink-annotate`
85
+ (create `@doc`/`@code` link pairs and verify them with `speclink check`) and
86
+ `speclink-sync` (triage `related --gate` findings using `speclink context`).
87
+ Both are also installed in this repository's `.claude/skills/`.
88
+
89
+ ### Changed
90
+
91
+ - Markdown section extraction moved from the LSP layer into `src/core/` and is
92
+ now shared by LSP hover and `speclink context` (no behavior change).
93
+
94
+ ## [0.2.0] - 2026-06-11
95
+
96
+ ### Added
97
+
98
+ - `speclink related`: an informational command that lists the linked
99
+ counterparts of a set of changed files (positional arguments or
100
+ newline-separated stdin via `--stdin`), marking whether each counterpart is
101
+ itself in the change set. Designed to sit behind `git diff --name-only` in
102
+ pre-commit hooks and CI. Supports `--root` and `--json`; always exits `0` on
103
+ success.
104
+ - `speclink related --gate`: a gate mode that reports only the counterparts
105
+ that are not themselves in the change set and exits `1` when any exist. The
106
+ check is symmetric (changed code with unchanged linked docs, and changed
107
+ docs with unchanged linked code). Combines with `--json` for a
108
+ machine-readable violations report.
109
+ - `speclink lsp`: a Language Server over stdio that exposes the SpecLink link
110
+ graph to editors, with JSON-RPC `Content-Length` framing and the standard
111
+ `initialize` / `initialized` / `shutdown` / `exit` lifecycle.
112
+ - `textDocument/publishDiagnostics`: the existing v0.1 diagnostics surfaced in
113
+ the editor, refreshed on document changes with a short debounce.
114
+ - `textDocument/hover`: inline Markdown spec sections for linked code symbols,
115
+ and the declaration signature line for linked headings.
116
+ - `textDocument/definition` and `textDocument/references` over the symmetric
117
+ counterpart relation, including one-to-many navigation.
118
+ - Scanner range enrichment (`nameRange`, `headingTextRange`, `targetRange`) and
119
+ a whole-project model with buffer overlay backing the language server.
120
+ - A minimal VS Code client extension under `editors/vscode/` to verify the
121
+ server in a real editor.
122
+
123
+ ## [0.1.0] - 2026-06-07
124
+
125
+ Initial release of the SpecLink CLI.
126
+
127
+ ### Added
128
+
129
+ - `@doc` annotation parsing from TypeScript JSDoc via the TypeScript Compiler API.
130
+ - `@code` annotation parsing from Markdown HTML comments.
131
+ - Markdown scanner with v0.1 heading anchor generation.
132
+ - Configuration loading (`speclink.config.json`) with `*`/`**` glob scanning.
133
+ - Bidirectional link resolution between code and documentation.
134
+ - Deterministic, machine-readable diagnostics.
135
+ - `speclink check` command with `--root`, `--json`, and `--audit` options.
136
+ - `speclink --version` (alias `-v`) and `speclink --help` (alias `-h`).
137
+
138
+ [Unreleased]: https://github.com/salan70/docbridge/compare/v0.4.0...HEAD
139
+ [0.4.0]: https://github.com/salan70/docbridge/releases/tag/v0.4.0
140
+ [0.3.0]: https://github.com/salan70/docbridge/releases/tag/v0.3.0
141
+ [0.2.0]: https://github.com/salan70/docbridge/releases/tag/v0.2.0
142
+ [0.1.0]: https://github.com/salan70/docbridge/releases/tag/v0.1.0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 DocBridge contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,420 @@
1
+ # DocBridge
2
+
3
+ [![Japanese README](https://img.shields.io/badge/README-%E6%97%A5%E6%9C%AC%E8%AA%9E-blue)](docs/ja/README.md)
4
+ [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/salan70/docbridge)
5
+
6
+ Bring Markdown into the LSP world.
7
+
8
+ DocBridge creates bidirectional links between TypeScript, Swift, or Dart code
9
+ and Markdown documentation, enabling LSP-like experiences such as Hover,
10
+ Definition, References, and Diagnostics across implementation and specification
11
+ files.
12
+
13
+ ## Motivation
14
+
15
+ Modern software projects often suffer from a gap between implementation and documentation:
16
+
17
+ - Code changes without documentation updates
18
+ - Documentation changes without implementation updates
19
+ - Difficulty finding which specifications relate to a given implementation
20
+ - Difficulty finding which implementation relates to a given specification
21
+ - AI coding agents missing relevant context during code modifications
22
+
23
+ DocBridge makes relationships between code and documentation explicit, navigable, and machine-readable.
24
+
25
+ ## Concept
26
+
27
+ Traditional documentation tools often focus on one direction:
28
+
29
+ ```text
30
+ Code -> Documentation
31
+ ```
32
+
33
+ DocBridge focuses on both directions:
34
+
35
+ ```text
36
+ Code <-> Documentation
37
+ ```
38
+
39
+ DocBridge links supported code declarations to Markdown sections. TypeScript is
40
+ scanned in-process; Swift and Dart are scanned through bundled first-party
41
+ worker packages.
42
+
43
+ ## Example
44
+
45
+ TypeScript:
46
+
47
+ ```ts
48
+ /**
49
+ * @doc docs/auth.md#login-spec
50
+ */
51
+ export async function login() {
52
+ // ...
53
+ }
54
+ ```
55
+
56
+ Markdown:
57
+
58
+ ```md
59
+ <!-- @code src/auth/login.ts#login -->
60
+ ## Login Spec
61
+
62
+ Login flow specification.
63
+ ```
64
+
65
+ Swift and Dart use the same `@doc` and `@code` model. Their code fragments are
66
+ the scanner-produced canonical IDs, so members are type-qualified:
67
+
68
+ ```swift
69
+ /// @doc docs/auth.md#login-spec
70
+ public struct AuthService {
71
+ public func login(email: String, password: String) {}
72
+ }
73
+ ```
74
+
75
+ ```md
76
+ <!-- @code Sources/AuthService.swift#AuthService.login(email:password:) -->
77
+ ## Login Spec
78
+ ```
79
+
80
+ ## Scope
81
+
82
+ DocBridge recognizes the following elements.
83
+
84
+ Supported code declarations:
85
+
86
+ - TypeScript top-level exported declarations: `function`, `class`,
87
+ `abstract class`, `interface`, `type`, `const`, `enum`, and supported
88
+ `declare` / named default forms
89
+ - Swift public/open declarations and configured internal declarations:
90
+ top-level and member types, functions, variables, constants, initializers,
91
+ and extension members
92
+ - Dart public declarations: top-level functions/variables, classes, enums,
93
+ mixins, constructors, fields, accessors, methods, and extension members
94
+
95
+ Supported Markdown elements:
96
+
97
+ - ATX headings
98
+ - HTML comments
99
+ - `@code` annotations attached to the next heading
100
+
101
+ Projects must define scan targets in `docbridge.config.json`. There is no
102
+ implicit default configuration; when the config file is missing, DocBridge
103
+ reports `config_file_invalid` and does not scan project files.
104
+
105
+ Minimal TypeScript configuration:
106
+
107
+ ```json
108
+ {
109
+ "include": {
110
+ "code": {
111
+ "typescript": {
112
+ "patterns": ["src/**/*.ts"]
113
+ }
114
+ },
115
+ "docs": ["docs/**/*.md"]
116
+ }
117
+ }
118
+ ```
119
+
120
+ Multilanguage configuration is language-keyed. The old `include.code` array
121
+ shape is intentionally invalid; migrate it to a `typescript` entry:
122
+
123
+ ```json
124
+ {
125
+ "include": {
126
+ "code": {
127
+ "typescript": { "patterns": ["src/**/*.ts"] },
128
+ "swift": { "patterns": ["Sources/**/*.swift"] },
129
+ "dart": { "patterns": ["lib/**/*.dart"] }
130
+ },
131
+ "docs": ["docs/**/*.md"]
132
+ }
133
+ }
134
+ ```
135
+
136
+ Swift and Dart projects must build their scanner workers in source checkouts
137
+ before checking those languages. Run `just build-swift-scanner` for Swift and
138
+ `just build-dart-scanner` for Dart, or use the native test recipes below.
139
+
140
+ ## Installation
141
+
142
+ DocBridge is distributed as the `docbridge` npm package and is intended to run
143
+ with Bun:
144
+
145
+ ```sh
146
+ bunx docbridge check
147
+ ```
148
+
149
+ The npm package is Bun-only; Node.js runtime compatibility is not part of the
150
+ initial distribution. The package includes prebuilt Swift and Dart scanner
151
+ binaries for `darwin-arm64` and `linux-x64`. TypeScript and Markdown checks run
152
+ without scanner binaries. Configured Swift or Dart projects on unsupported
153
+ platforms report `code_scanner_unavailable` and name the supported platform
154
+ keys.
155
+
156
+ ## CLI
157
+
158
+ Check links:
159
+
160
+ ```sh
161
+ just check
162
+ ```
163
+
164
+ Check another root:
165
+
166
+ ```sh
167
+ just check-example
168
+ ```
169
+
170
+ Emit JSON:
171
+
172
+ ```sh
173
+ just check-example-json
174
+ ```
175
+
176
+ Run audit diagnostics:
177
+
178
+ ```sh
179
+ just audit
180
+ ```
181
+
182
+ Audit diagnostics include:
183
+
184
+ - `undocumented_symbol`
185
+
186
+ List the linked counterparts of changed files:
187
+
188
+ ```sh
189
+ git diff --name-only | docbridge related --stdin
190
+ ```
191
+
192
+ `docbridge related` is informational: it reports each counterpart and whether it
193
+ is itself in the change set, and always exits `0` on success. Changed files can
194
+ also be passed as positional arguments. Add `--gate` to report only the
195
+ counterparts that are not themselves in the change set and exit `1` when any
196
+ exist; `just related-gate` runs this over uncommitted changes. Both modes
197
+ support `--root` and `--json`. See [docs/specs/cli.md](docs/specs/cli.md) for
198
+ details.
199
+
200
+ Print the content of the linked counterparts of changed files:
201
+
202
+ ```sh
203
+ git diff --name-only | docbridge context --stdin
204
+ ```
205
+
206
+ `docbridge context` answers "what do the linked counterparts say": full
207
+ Markdown sections for doc counterparts, full declarations including JSDoc for
208
+ code counterparts. The default output is Markdown suitable for direct
209
+ injection into an agent prompt; `--json` follows
210
+ [schemas/context-output.schema.json](schemas/context-output.schema.json).
211
+ Extraction is best-effort and the command exits `0` on success even when the
212
+ tree has broken links. See [docs/specs/cli.md](docs/specs/cli.md) for details.
213
+
214
+ Inspect the resolved link graph:
215
+
216
+ ```sh
217
+ docbridge graph
218
+ docbridge graph --json --include-content
219
+ ```
220
+
221
+ `docbridge graph` prints the resolved endpoint graph, including resolvable
222
+ one-way links. JSON output follows
223
+ [schemas/graph-output.schema.json](schemas/graph-output.schema.json).
224
+
225
+ ## AI agent integration
226
+
227
+ DocBridge's link graph is built to be consumed by AI coding agents:
228
+
229
+ - [docs/integrations](docs/integrations) — recipes for Claude Code, Codex,
230
+ and CI: on-edit counterpart awareness with `docbridge context`, gate triage
231
+ with `docbridge related --gate`, and PR reporting.
232
+ - [examples/hooks](examples/hooks) — copyable agent hook scripts implementing
233
+ those recipes.
234
+ - [templates/skills](templates/skills) — distributable agent skills:
235
+ `docbridge-annotate`, `docbridge-sync`, `docbridge-adopt`, `docbridge-link`,
236
+ and `docbridge-review`.
237
+
238
+ This repository dogfoods the hooks and skills in its own guardrails under
239
+ `.claude/`, `.codex/`, and `.agents/`.
240
+
241
+ ## Editor support
242
+
243
+ DocBridge ships a language server that exposes the same link graph to editors:
244
+
245
+ ```sh
246
+ docbridge lsp
247
+ ```
248
+
249
+ `docbridge lsp` speaks LSP over stdio and provides Diagnostics, Hover,
250
+ Definition, and References across linked code and Markdown. It takes no
251
+ options; the project root comes from the editor's `initialize` request.
252
+ `docbridge check` is unchanged.
253
+
254
+ A minimal VS Code-compatible client lives in [editors/vscode](editors/vscode);
255
+ see its README to install it into VS Code or Cursor for local testing. Full
256
+ behavior is specified in [docs/specs/lsp.md](docs/specs/lsp.md).
257
+
258
+ ## Diagnostics
259
+
260
+ Errors:
261
+
262
+ - `config_file_invalid`
263
+ - `config_unknown_key`
264
+ - `config_invalid_value`
265
+ - `invalid_link_target`
266
+ - `doc_file_not_found`
267
+ - `doc_anchor_not_found`
268
+ - `code_file_not_found`
269
+ - `code_backlink_not_found`
270
+ - `doc_backlink_not_found`
271
+ - `duplicate_doc_anchor`
272
+ - `duplicate_code_symbol`
273
+ - `code_parse_error`
274
+ - `file_read_error`
275
+
276
+ Warnings:
277
+
278
+ - `duplicate_link`
279
+ - `dangling_code_annotation`
280
+ - `unsupported_declaration`
281
+ - `undocumented_symbol` when `--audit` is enabled
282
+
283
+ Exit code policy:
284
+
285
+ - `1` when any error exists
286
+ - `0` when there are only warnings or no diagnostics
287
+
288
+ ## Development
289
+
290
+ ### Prerequisites
291
+
292
+ Recommended:
293
+
294
+ - Nix
295
+ - direnv
296
+
297
+ The Nix development shell provides the tools used by this repository:
298
+
299
+ - Bun
300
+ - just
301
+ - Git
302
+ - Dart SDK
303
+
304
+ If you do not use Nix, install Bun and just locally before running the project
305
+ commands. Swift scanner development also requires a Swift 6 toolchain on
306
+ `PATH`; CI installs Swift separately from Nix.
307
+
308
+ ### Setup
309
+
310
+ Enable the development environment with direnv:
311
+
312
+ ```sh
313
+ direnv allow
314
+ ```
315
+
316
+ Or enter the Nix development shell manually:
317
+
318
+ ```sh
319
+ nix develop
320
+ ```
321
+
322
+ Install dependencies:
323
+
324
+ ```sh
325
+ bun install --frozen-lockfile
326
+ ```
327
+
328
+ Install repository Git hooks:
329
+
330
+ ```sh
331
+ just install-git-hooks
332
+ ```
333
+
334
+ If `just` is not on `PATH` yet, run:
335
+
336
+ ```sh
337
+ nix develop -c just install-git-hooks
338
+ ```
339
+
340
+ The pre-commit hook runs `just check` and `just test`.
341
+
342
+ ### Common Tasks
343
+
344
+ Run common tasks with `just`:
345
+
346
+ ```sh
347
+ just --list
348
+ just check
349
+ just check-example
350
+ just check-swift-example
351
+ just check-dart-example
352
+ just check-fixture <code>
353
+ just audit
354
+ just related-gate
355
+ just test
356
+ just test-swift-scanner
357
+ just test-dart-scanner
358
+ just build
359
+ just verify-dist
360
+ ```
361
+
362
+ `just check`, `just test`, and `just build` are the default local and CI gates.
363
+ `just test` includes TypeScript, Swift, and Dart end-to-end integration tests;
364
+ the Swift and Dart scanner binaries must be built before those integration
365
+ tests can spawn them. Scanner-native tests are mandatory in CI and are useful
366
+ locally when changing worker code. `just verify-dist` builds confidence in the
367
+ npm entry point by checking the Bun shebang, executable bit, `--version`,
368
+ `--help`, and a TypeScript example check from `dist/index.js`.
369
+
370
+ ### Project Constraints
371
+
372
+ Runtime:
373
+
374
+ - Bun
375
+
376
+ Language:
377
+
378
+ - TypeScript
379
+ - Swift scanner worker package
380
+ - Dart scanner worker package
381
+
382
+ Task runner:
383
+
384
+ - just
385
+
386
+ Environment loader:
387
+
388
+ - direnv
389
+
390
+ Core dependencies should stay minimal. The CLI should primarily rely on Bun and
391
+ the TypeScript Compiler API; Swift and Dart parser dependencies stay isolated
392
+ inside their worker packages.
393
+
394
+ ## Documentation
395
+
396
+ - Japanese documentation: [docs/ja/README.md](docs/ja/README.md)
397
+ - Specifications: [docs/specs](docs/specs)
398
+ - v0.1 decisions: [docs/decisions/v0.1.md](docs/decisions/v0.1.md)
399
+ - v0.2 decisions: [docs/decisions/v0.2.md](docs/decisions/v0.2.md)
400
+ - v0.3 decisions: [docs/decisions/v0.3.md](docs/decisions/v0.3.md)
401
+ - AI agent integration recipes: [docs/integrations](docs/integrations)
402
+ - Commit message convention: [docs/contributing/commits.md](docs/contributing/commits.md)
403
+ - Testing convention: [docs/contributing/testing.md](docs/contributing/testing.md)
404
+
405
+ ## Roadmap
406
+
407
+ Completed v0.1–v0.3 capabilities are documented above and in
408
+ [CHANGELOG.md](CHANGELOG.md). The current roadmap tracks upcoming work only.
409
+
410
+ v0.5:
411
+
412
+ - MCP server exposing the link graph and `docbridge context` output as tools
413
+ - Editor and agent delivery channels built on it (Claude Code, Cursor, Zed,
414
+ Codex)
415
+
416
+ ## Vision
417
+
418
+ DocBridge is not a documentation generator.
419
+
420
+ Its purpose is to make relationships between code and documentation visible, navigable, and machine-readable so humans and AI agents can reach relevant context with minimal effort.
@@ -0,0 +1,2 @@
1
+ 4e8638f664e3cb08e36146dd03097d1dfe1c35be39b79219c6d633ea07e7742f speclink-swift-scanner
2
+ ef5e2d41194493de9f3cea22bc8f268c35bbd0f69ff63e275e303b6476b658a1 speclink_dart_scanner
@@ -0,0 +1,2 @@
1
+ 4100cc8c861a24821fca240c758ba188a42f677a403fe40a76bac4271a918bfe speclink-swift-scanner
2
+ 2145eac2afd09696ced849e0196a2557d6f7041224f13da1d5ef21c552ecf7bc speclink_dart_scanner