docspack 0.0.1 → 0.1.1

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.
Files changed (155) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +179 -0
  3. package/bin/docspack.js +25 -0
  4. package/dist/build.d.ts +31 -0
  5. package/dist/build.d.ts.map +1 -0
  6. package/dist/build.js +435 -0
  7. package/dist/build.js.map +1 -0
  8. package/dist/cli.d.ts +3 -0
  9. package/dist/cli.d.ts.map +1 -0
  10. package/dist/cli.js +763 -0
  11. package/dist/cli.js.map +1 -0
  12. package/dist/config.d.ts +41 -0
  13. package/dist/config.d.ts.map +1 -0
  14. package/dist/config.js +118 -0
  15. package/dist/config.js.map +1 -0
  16. package/dist/db.d.ts +60 -0
  17. package/dist/db.d.ts.map +1 -0
  18. package/dist/db.js +204 -0
  19. package/dist/db.js.map +1 -0
  20. package/dist/discovery.d.ts +31 -0
  21. package/dist/discovery.d.ts.map +1 -0
  22. package/dist/discovery.js +126 -0
  23. package/dist/discovery.js.map +1 -0
  24. package/dist/doctor.d.ts +25 -0
  25. package/dist/doctor.d.ts.map +1 -0
  26. package/dist/doctor.js +276 -0
  27. package/dist/doctor.js.map +1 -0
  28. package/dist/document.d.ts +13 -0
  29. package/dist/document.d.ts.map +1 -0
  30. package/dist/document.js +47 -0
  31. package/dist/document.js.map +1 -0
  32. package/dist/errors.d.ts +9 -0
  33. package/dist/errors.d.ts.map +1 -0
  34. package/dist/errors.js +10 -0
  35. package/dist/errors.js.map +1 -0
  36. package/dist/exports.d.ts +20 -0
  37. package/dist/exports.d.ts.map +1 -0
  38. package/dist/exports.js +100 -0
  39. package/dist/exports.js.map +1 -0
  40. package/dist/feedback.d.ts +68 -0
  41. package/dist/feedback.d.ts.map +1 -0
  42. package/dist/feedback.js +0 -0
  43. package/dist/feedback.js.map +1 -0
  44. package/dist/html.d.ts +4 -0
  45. package/dist/html.d.ts.map +1 -0
  46. package/dist/html.js +23 -0
  47. package/dist/html.js.map +1 -0
  48. package/dist/http.d.ts +30 -0
  49. package/dist/http.d.ts.map +1 -0
  50. package/dist/http.js +144 -0
  51. package/dist/http.js.map +1 -0
  52. package/dist/index.d.ts +25 -0
  53. package/dist/index.d.ts.map +1 -0
  54. package/dist/index.js +25 -0
  55. package/dist/index.js.map +1 -0
  56. package/dist/init/detect.d.ts +16 -0
  57. package/dist/init/detect.d.ts.map +1 -0
  58. package/dist/init/detect.js +120 -0
  59. package/dist/init/detect.js.map +1 -0
  60. package/dist/init/plan.d.ts +43 -0
  61. package/dist/init/plan.d.ts.map +1 -0
  62. package/dist/init/plan.js +145 -0
  63. package/dist/init/plan.js.map +1 -0
  64. package/dist/init/run.d.ts +28 -0
  65. package/dist/init/run.d.ts.map +1 -0
  66. package/dist/init/run.js +96 -0
  67. package/dist/init/run.js.map +1 -0
  68. package/dist/init/templates.d.ts +24 -0
  69. package/dist/init/templates.d.ts.map +1 -0
  70. package/dist/init/templates.js +181 -0
  71. package/dist/init/templates.js.map +1 -0
  72. package/dist/init/write.d.ts +20 -0
  73. package/dist/init/write.d.ts.map +1 -0
  74. package/dist/init/write.js +56 -0
  75. package/dist/init/write.js.map +1 -0
  76. package/dist/kinds.d.ts +14 -0
  77. package/dist/kinds.d.ts.map +1 -0
  78. package/dist/kinds.js +15 -0
  79. package/dist/kinds.js.map +1 -0
  80. package/dist/llms-txt.d.ts +25 -0
  81. package/dist/llms-txt.d.ts.map +1 -0
  82. package/dist/llms-txt.js +94 -0
  83. package/dist/llms-txt.js.map +1 -0
  84. package/dist/mcp.d.ts +15 -0
  85. package/dist/mcp.d.ts.map +1 -0
  86. package/dist/mcp.js +158 -0
  87. package/dist/mcp.js.map +1 -0
  88. package/dist/preview.d.ts +18 -0
  89. package/dist/preview.d.ts.map +1 -0
  90. package/dist/preview.js +72 -0
  91. package/dist/preview.js.map +1 -0
  92. package/dist/prompt.d.ts +27 -0
  93. package/dist/prompt.d.ts.map +1 -0
  94. package/dist/prompt.js +79 -0
  95. package/dist/prompt.js.map +1 -0
  96. package/dist/search.d.ts +41 -0
  97. package/dist/search.d.ts.map +1 -0
  98. package/dist/search.js +60 -0
  99. package/dist/search.js.map +1 -0
  100. package/dist/snippet.d.ts +20 -0
  101. package/dist/snippet.d.ts.map +1 -0
  102. package/dist/snippet.js +29 -0
  103. package/dist/snippet.js.map +1 -0
  104. package/dist/spec.d.ts +38 -0
  105. package/dist/spec.d.ts.map +1 -0
  106. package/dist/spec.js +105 -0
  107. package/dist/spec.js.map +1 -0
  108. package/dist/style.d.ts +33 -0
  109. package/dist/style.d.ts.map +1 -0
  110. package/dist/style.js +94 -0
  111. package/dist/style.js.map +1 -0
  112. package/dist/submit.d.ts +61 -0
  113. package/dist/submit.d.ts.map +1 -0
  114. package/dist/submit.js +111 -0
  115. package/dist/submit.js.map +1 -0
  116. package/dist/sync.d.ts +29 -0
  117. package/dist/sync.d.ts.map +1 -0
  118. package/dist/sync.js +73 -0
  119. package/dist/sync.js.map +1 -0
  120. package/dist/verify.d.ts +44 -0
  121. package/dist/verify.d.ts.map +1 -0
  122. package/dist/verify.js +291 -0
  123. package/dist/verify.js.map +1 -0
  124. package/package.json +61 -5
  125. package/src/build.ts +572 -0
  126. package/src/cli.ts +883 -0
  127. package/src/config.ts +158 -0
  128. package/src/db.ts +261 -0
  129. package/src/discovery.ts +161 -0
  130. package/src/doctor.ts +344 -0
  131. package/src/document.ts +59 -0
  132. package/src/errors.ts +10 -0
  133. package/src/exports.ts +120 -0
  134. package/src/feedback.ts +0 -0
  135. package/src/html.ts +24 -0
  136. package/src/http.ts +190 -0
  137. package/src/index.ts +132 -0
  138. package/src/init/detect.ts +142 -0
  139. package/src/init/plan.ts +215 -0
  140. package/src/init/run.ts +142 -0
  141. package/src/init/templates.ts +200 -0
  142. package/src/init/write.ts +83 -0
  143. package/src/kinds.ts +17 -0
  144. package/src/llms-txt.ts +116 -0
  145. package/src/mcp.ts +196 -0
  146. package/src/preview.ts +98 -0
  147. package/src/prompt.ts +103 -0
  148. package/src/search.ts +96 -0
  149. package/src/snippet.ts +30 -0
  150. package/src/spec.ts +138 -0
  151. package/src/style.ts +111 -0
  152. package/src/submit.ts +189 -0
  153. package/src/sync.ts +112 -0
  154. package/src/verify.ts +355 -0
  155. package/bin/cli.js +0 -2
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 docspack 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,179 @@
1
+ <div align="center">
2
+
3
+ <a href="https://docspack.dev"><img src="https://docspack.dev/logo.png" width="72" height="72" alt="docspack" /></a>
4
+
5
+ # docspack
6
+
7
+ Local, version-locked documentation packages for AI agents, indexed in SQLite and served over MCP.
8
+
9
+ [![npm](https://img.shields.io/npm/v/docspack.svg)](https://www.npmjs.com/package/docspack)
10
+ [![downloads](https://img.shields.io/npm/dm/docspack.svg)](https://www.npmjs.com/package/docspack)
11
+ [![license](https://img.shields.io/npm/l/docspack.svg)](./LICENSE)
12
+ [![node](https://img.shields.io/node/v/docspack.svg)](https://nodejs.org)
13
+ [![types](https://img.shields.io/badge/types-TypeScript%20strict-blue.svg)](https://www.typescriptlang.org)
14
+ [![status](https://img.shields.io/badge/status-experimental-orange.svg)](https://github.com/docspack/docspack/releases)
15
+
16
+ [Website](https://docspack.dev) ·
17
+ [Documentation](https://docspack.dev/llms.txt) ·
18
+ [GitHub](https://github.com/docspack/docspack) ·
19
+ [Releases](https://github.com/docspack/docspack/releases)
20
+
21
+ </div>
22
+
23
+ ---
24
+
25
+ > **Publishing documentation for your own library?** You want `docspack init`, which
26
+ > scaffolds a documentation package. This README is mostly about consuming them.
27
+
28
+ > **Just want your agent to read the docs?** Three lines: install a docs package, run
29
+ > `docspack sync`, and paste one sentence into `AGENTS.md`. Jump to [Quick start](#quick-start).
30
+
31
+ ## Overview
32
+
33
+ An AI coding agent answers from one of three places: its training data, which is frozen at
34
+ some past version; a docs site it fetches, which is whatever the vendor publishes today; or
35
+ nothing at all. None of those is the version in your lockfile.
36
+
37
+ docspack closes that gap by making documentation an ordinary npm dependency. A documentation
38
+ package (`@stripe/docspack`, `@docspack-community/jira`) holds Markdown split into chunks plus
39
+ a manifest describing them, and its version tracks the library's. `docspack sync` indexes the
40
+ ones this project depends on into one SQLite database per machine, and `docspack ask` answers
41
+ from that index — offline, bounded, and matched to what you actually installed.
42
+
43
+ The mental model: **publish → sync → ask.**
44
+
45
+ ## Features
46
+
47
+ - **Version-locked** — answers come from the docs package resolved in your lockfile, never a
48
+ newer or older one. The index may hold five versions of a library; a project sees only its own.
49
+ - **Offline by construction** — `sync`, `ask`, `search` and `list` make no network requests.
50
+ They read `node_modules` and a local SQLite file.
51
+ - **Bounded responses** — 3 chunks and 3,000 tokens by default, counted from the manifest
52
+ before content is returned, so a query cannot overrun its budget.
53
+ - **No server, no resident context** — every agent already has a shell. One line in `AGENTS.md`
54
+ is the whole setup, and nothing runs when nobody is asking.
55
+ - **MCP when you want it** — `docspack mcp` serves the same index over the Model Context
56
+ Protocol, returning identical text, for clients that prefer a declared tool.
57
+ - **No native modules** — the index uses `node:sqlite` from the standard library.
58
+
59
+ ## Installation
60
+
61
+ ```sh
62
+ npm install -D docspack
63
+ pnpm add -D docspack
64
+ yarn add -D docspack
65
+ ```
66
+
67
+ Requires Node 22.5 or newer.
68
+
69
+ ## Quick start
70
+
71
+ ```sh
72
+ # 1. Add a documentation package, the same way you add any dependency
73
+ pnpm add -D @acme/docspack
74
+
75
+ # 2. Index every docs package this project depends on
76
+ npx docspack sync
77
+
78
+ # 3. Ask it something
79
+ npx docspack ask "how do I verify a webhook signature"
80
+ ```
81
+
82
+ Then give the agent access by pasting these two lines into `AGENTS.md` or `CLAUDE.md`:
83
+
84
+ ```
85
+ Run `docspack ask "<question>"` for documentation on this project's
86
+ dependencies. It answers from the installed versions.
87
+ ```
88
+
89
+ That is the entire integration. No server to start, no per-client configuration.
90
+
91
+ <details>
92
+ <summary>Using MCP instead</summary>
93
+
94
+ ```sh
95
+ claude mcp add docspack -- npx -y docspack mcp
96
+ ```
97
+
98
+ The server exposes `query_local_docs` (`query`, optional `packageFilter`), returns the
99
+ best-ranked chunks and caps a response at 3,000 tokens. It also exposes `record_docs_problem`,
100
+ the equivalent of `docspack feedback add` — it appends to a local file and cannot send
101
+ anything anywhere.
102
+
103
+ </details>
104
+
105
+ ## Commands
106
+
107
+ Reading:
108
+
109
+ ```
110
+ docspack sync Index the docs packages this project depends on
111
+ docspack ask <question> Answer from the local index — the command to give an agent
112
+ docspack search <query> Same index, formatted for a human reading the terminal
113
+ docspack list Show this project's docs packages and their index state
114
+ docspack verify Check the docs still describe the code you installed
115
+ docspack feedback <sub> Record documentation problems: add, list, submit, remove
116
+ docspack mcp Serve the index over MCP instead, as a long-lived process
117
+ docspack sources List curated sources that `docspack build` can fetch
118
+ ```
119
+
120
+ Authoring:
121
+
122
+ ```
123
+ docspack init Scaffold a documentation package, then build and check it
124
+ docspack build [source] Generate the .llms/ payload for publishing
125
+ docspack doctor Check a package the way the indexer and a reviewer would
126
+ docspack preview <query> Answer a query from the local package, as an agent would
127
+ ```
128
+
129
+ Run `docspack --help` for every flag.
130
+
131
+ ## Authoring a documentation package
132
+
133
+ ```sh
134
+ npx docspack init # scaffold, build and check in one step
135
+ npx docspack build --from ./docs # Markdown, split at headings
136
+ npx docspack build --openapi ./openapi.json # one chunk per operation
137
+ npx docspack build stripe # from a project's public llms.txt
138
+ ```
139
+
140
+ `build` writes `.llms/manifest.json`, `.llms/chunks/*.md` and an `llms.txt` table of contents,
141
+ ready for `npm publish`. `docspack doctor --strict` checks the result the way the indexer and
142
+ a reviewer would.
143
+
144
+ Manifests validate against <https://docspack.dev/schema/v1.json>.
145
+
146
+ ## Recording documentation problems
147
+
148
+ An agent holds the documentation, the installed library and a failing program at the same
149
+ moment — a signal that today evaporates. `docspack feedback add` captures it locally:
150
+
151
+ ```sh
152
+ npx docspack feedback add --chunk @acme/docspack@1.4.0/api-auth \
153
+ --kind drift --evidence "client.setKey is not exported; setApiKey is"
154
+ ```
155
+
156
+ Claims must be falsifiable. `drift` must name the identifier; `incorrect` and `missing` must
157
+ carry `--expected`, `--actual` and `--repro`. There is deliberately no kind for "this page is
158
+ confusing".
159
+
160
+ **Nothing is transmitted, and nothing can be** — docspack contains no code that sends a report
161
+ anywhere. `docspack feedback submit` prints a prefilled GitHub issue URL for vendors who opted
162
+ in from their own `package.json`, and a human decides whether to open it.
163
+
164
+ ## Status
165
+
166
+ Pre-1.0 and versioned accordingly: minor releases may change behaviour. The package
167
+ specification is the part most worth depending on, and it is documented at
168
+ <https://docspack.dev/schema/v1.json>.
169
+
170
+ ## Related packages
171
+
172
+ | Package | Description |
173
+ | --- | --- |
174
+ | [`@docspack/registry`](https://www.npmjs.com/package/@docspack/registry) | Curated llms.txt sources for bootstrapping docs packages. |
175
+ | [`@docspack/docspack`](https://www.npmjs.com/package/@docspack/docspack) | docspack's own documentation, shipped as a docs package. |
176
+
177
+ ## License
178
+
179
+ MIT — see [LICENSE](./LICENSE).
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Launcher for the compiled CLI.
4
+ *
5
+ * `bin` cannot point straight at `dist/cli.js`: a package manager links bin files during
6
+ * install, which in this repository happens before anything is compiled. pnpm finds no
7
+ * `dist/cli.js`, warns, and silently skips the link — so every later `docspack …` fails with
8
+ * "command not found", including the one that builds this package's own documentation.
9
+ *
10
+ * This file is committed, so the link always succeeds. `dist/` only has to exist by the time
11
+ * someone actually runs the command.
12
+ */
13
+ import { existsSync } from "node:fs";
14
+ import { fileURLToPath } from "node:url";
15
+
16
+ const cli = new URL("../dist/cli.js", import.meta.url);
17
+
18
+ if (existsSync(fileURLToPath(cli))) {
19
+ await import(cli.href);
20
+ } else {
21
+ process.stderr.write(
22
+ "docspack is not built: dist/cli.js is missing.\nRun `pnpm turbo build --filter docspack` and try again.\n",
23
+ );
24
+ process.exitCode = 1;
25
+ }
@@ -0,0 +1,31 @@
1
+ import { HttpClient } from "./http.js";
2
+ export interface BuildOptions {
3
+ /** Directory the docs package is written to. */
4
+ readonly out: string;
5
+ readonly name?: string;
6
+ readonly version?: string;
7
+ /** Directory of Markdown files to package. */
8
+ readonly from?: string;
9
+ /** OpenAPI document (JSON) to package, one chunk per operation. */
10
+ readonly openapi?: string;
11
+ /** Registry id or llms.txt URL to fetch and package. */
12
+ readonly source?: string;
13
+ readonly pages?: number;
14
+ readonly maxChunkTokens?: number;
15
+ readonly http?: HttpClient;
16
+ readonly onProgress?: (message: string) => void;
17
+ }
18
+ export interface BuildResult {
19
+ readonly name: string;
20
+ readonly version: string;
21
+ readonly dir: string;
22
+ readonly chunks: number;
23
+ readonly tokens: number;
24
+ readonly warnings: readonly string[];
25
+ }
26
+ /**
27
+ * Generates a docs package: `.llms/manifest.json`, `.llms/chunks/*.md` and an `llms.txt` table of
28
+ * contents, ready to publish to npm as `@vendor/docspack`.
29
+ */
30
+ export declare function buildPackage(input: BuildOptions): Promise<BuildResult>;
31
+ //# sourceMappingURL=build.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAWvC,MAAM,WAAW,YAAY;IAC3B,gDAAgD;IAChD,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,8CAA8C;IAC9C,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,mEAAmE;IACnE,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,wDAAwD;IACxD,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,IAAI,CAAC,EAAE,UAAU,CAAC;IAC3B,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACjD;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;CACtC;AAkBD;;;GAGG;AACH,wBAAsB,YAAY,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC,CAsD5E"}