markdown-lsp 1.1.0 → 1.2.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.
- package/README.md +79 -8
- package/dist/cli.js +806 -108
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
[](https://github.com/Docsbook-io/markdown-lsp/blob/main/LICENSE)
|
|
7
7
|
[](https://www.npmjs.com/package/markdown-lsp)
|
|
8
8
|
|
|
9
|
-
CLI and library for querying Markdown documentation graphs. Point it at a folder of `.md` files and get instant full-text search, outline, link analysis,
|
|
9
|
+
CLI and library for querying Markdown documentation graphs. Point it at a folder of `.md` files and get instant full-text search, outline, link analysis, symbol lookup, interactive HTML graphs, and AI-powered semantic search — all as JSON.
|
|
10
10
|
|
|
11
|
-
**Status: v1.
|
|
11
|
+
**Status: v1.2.0. CLI is the default interface. LSP stdio mode available as a subcommand.**
|
|
12
12
|
|
|
13
13
|
---
|
|
14
14
|
|
|
@@ -18,11 +18,40 @@ CLI and library for querying Markdown documentation graphs. Point it at a folder
|
|
|
18
18
|
# List all pages
|
|
19
19
|
npx markdown-lsp workspace-outline ./docs
|
|
20
20
|
|
|
21
|
+
# Heading outline of a page
|
|
22
|
+
npx markdown-lsp outline ./docs introduction.md
|
|
23
|
+
|
|
21
24
|
# Full-text search (natural-language, ranked)
|
|
22
25
|
npx markdown-lsp search-text ./docs "getting started"
|
|
23
26
|
|
|
24
27
|
# Fuzzy heading search
|
|
25
28
|
npx markdown-lsp search-symbols ./docs "auth" --limit 10
|
|
29
|
+
|
|
30
|
+
# Find pages by glob
|
|
31
|
+
npx markdown-lsp search-paths ./docs "ai/*.md"
|
|
32
|
+
|
|
33
|
+
# Backlinks and outgoing links
|
|
34
|
+
npx markdown-lsp links-to ./docs quick-start.md
|
|
35
|
+
npx markdown-lsp links-from ./docs README.md
|
|
36
|
+
|
|
37
|
+
# Resolve a link text / read a section
|
|
38
|
+
npx markdown-lsp resolve-link ./docs README.md "Getting Started"
|
|
39
|
+
npx markdown-lsp get-section ./docs overview.md "quick-links"
|
|
40
|
+
|
|
41
|
+
# Interactive link graph (HTML, JSON, DOT, Mermaid)
|
|
42
|
+
npx markdown-lsp graph ./docs --format html --out graph.html
|
|
43
|
+
npx markdown-lsp graph ./docs --format json --pretty
|
|
44
|
+
npx markdown-lsp graph ./docs --format dot | dot -Tsvg > graph.svg
|
|
45
|
+
npx markdown-lsp graph ./docs --format mermaid
|
|
46
|
+
|
|
47
|
+
# Build embeddings + interactive semantic graph in one command
|
|
48
|
+
OPENROUTER_API_KEY=sk-or-... npx markdown-lsp graph ./docs --format html --semantic --out graph.html
|
|
49
|
+
|
|
50
|
+
# AI semantic search
|
|
51
|
+
OPENROUTER_API_KEY=sk-or-... npx markdown-lsp semantic-search ./docs "how to configure webhooks"
|
|
52
|
+
|
|
53
|
+
# LSP server (for editors)
|
|
54
|
+
npx markdown-lsp lsp --stdio
|
|
26
55
|
```
|
|
27
56
|
|
|
28
57
|
---
|
|
@@ -54,9 +83,9 @@ All subcommands accept a **`--pretty`** flag for indented JSON output (compact b
|
|
|
54
83
|
| `links-from` | `<docs-dir> <page>` | All links originating from `<page>` |
|
|
55
84
|
| `resolve-link` | `<docs-dir> <from-page> <link-text>` | Resolve a specific link text from a page |
|
|
56
85
|
| `get-section` | `<docs-dir> <page> <anchor>` | Get a section by anchor slug |
|
|
86
|
+
| `graph` | `<docs-dir> [--format json\|dot\|mermaid\|html] [--out file] [--semantic] [--sim-threshold n] [--sim-top-k n] [--model m]` | Export doc link graph; `--semantic` adds AI similarity edges |
|
|
87
|
+
| `semantic-search` | `<docs-dir> <query> [--limit n] [--model m]` | AI semantic search via embeddings |
|
|
57
88
|
| `lsp` / `serve` | `[--stdio]` | Start the LSP stdio server |
|
|
58
|
-
| `graph` | `<docs-dir> [--format json\|dot\|mermaid\|html] [--out file]` | Export the doc link graph |
|
|
59
|
-
| `semantic-search` | `<docs-dir> <query> [--limit n] [--model model]` | AI semantic search via embeddings |
|
|
60
89
|
|
|
61
90
|
### search-text modes
|
|
62
91
|
|
|
@@ -118,21 +147,60 @@ markdown-lsp graph ./docs --format dot > graph.dot
|
|
|
118
147
|
markdown-lsp graph ./docs --format mermaid
|
|
119
148
|
|
|
120
149
|
# Self-contained interactive HTML with D3 force-directed graph
|
|
121
|
-
# (drag, zoom, hover highlights neighbours, click to inspect)
|
|
150
|
+
# (drag, zoom, hover highlights neighbours, click to inspect side-panel)
|
|
122
151
|
markdown-lsp graph ./docs --format html --out graph.html
|
|
123
152
|
```
|
|
124
153
|
|
|
125
154
|
JSON output shape:
|
|
126
155
|
```json
|
|
127
156
|
{
|
|
128
|
-
"nodes": [{"id": "README.md", "title": "Docsbook", "charCount": 2634, "sectionsCount": 10
|
|
157
|
+
"nodes": [{"id": "README.md", "title": "Docsbook", "charCount": 2634, "sectionsCount": 10,
|
|
158
|
+
"sections": [...], "outgoing": [...], "incoming": [...], "topSimilar": []}],
|
|
129
159
|
"edges": [{"source": "README.md", "target": "quick-start.md", "kind": "inline", "label": "Get started"}],
|
|
160
|
+
"semanticEdges": [],
|
|
130
161
|
"unresolvedCount": 3
|
|
131
162
|
}
|
|
132
163
|
```
|
|
133
164
|
|
|
134
165
|
---
|
|
135
166
|
|
|
167
|
+
## Turnkey semantic graph (v1.2)
|
|
168
|
+
|
|
169
|
+
Overlay AI-powered semantic similarity edges on top of the link graph — one command, no pipeline.
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
# Build embeddings + interactive semantic graph in one command
|
|
173
|
+
OPENROUTER_API_KEY=sk-or-... markdown-lsp graph ./docs --format html --semantic --out graph.html
|
|
174
|
+
|
|
175
|
+
# With explicit thresholds
|
|
176
|
+
OPENROUTER_API_KEY=sk-or-... markdown-lsp graph ./docs --format html --semantic \
|
|
177
|
+
--sim-threshold 0.75 --sim-top-k 5 --out graph.html
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
**What you get in the HTML:**
|
|
181
|
+
|
|
182
|
+
- Two types of edges — **solid lines** (explicit markdown links) and **dashed amber lines** (semantic similarity)
|
|
183
|
+
- **Checkboxes** in the toolbar to toggle each edge type independently
|
|
184
|
+
- **Click any node** to open a side-panel showing: title, path, sections, outgoing links, incoming links, and top semantically similar pages with scores
|
|
185
|
+
- Clicking a linked page in the side-panel focuses the graph on that node
|
|
186
|
+
- Background click closes the panel and clears selection
|
|
187
|
+
- Drag and zoom preserved from v1.1
|
|
188
|
+
|
|
189
|
+
**Semantic flags:**
|
|
190
|
+
|
|
191
|
+
| Flag | Default | Description |
|
|
192
|
+
|---|---|---|
|
|
193
|
+
| `--semantic` | off | Enable AI similarity edges |
|
|
194
|
+
| `--sim-threshold` | `0.75` | Minimum cosine similarity score to draw an edge |
|
|
195
|
+
| `--sim-top-k` | `5` | Max semantic neighbours per node |
|
|
196
|
+
| `--model` | `openai/text-embedding-3-small` | Embedding model override |
|
|
197
|
+
|
|
198
|
+
**Caching:** embeddings are cached in `.markdown-lsp-cache/embeddings/` — the second run is instant with 0 API calls.
|
|
199
|
+
|
|
200
|
+
**OpenRouter model naming:** when using `OPENROUTER_API_KEY`, the model name requires the `openai/` prefix (e.g. `openai/text-embedding-3-small`). When using `AI_GATEWAY_API_KEY` (Vercel AI Gateway), use the bare name (`text-embedding-3-small`). If the model is rejected, the CLI outputs a clear hint to try the other form.
|
|
201
|
+
|
|
202
|
+
---
|
|
203
|
+
|
|
136
204
|
## Semantic search
|
|
137
205
|
|
|
138
206
|
AI-powered semantic search using text embeddings — finds conceptually related pages even if they
|
|
@@ -233,6 +301,7 @@ export AI_GATEWAY_API_KEY=... # Vercel AI Gateway
|
|
|
233
301
|
|
|
234
302
|
- **CLI** — `node:util parseArgs`, zero extra deps, reads `.md` files into an in-memory graph
|
|
235
303
|
- **Graph** — pure TypeScript, no DB needed; `buildGraph(docsRoot)` walks the directory tree
|
|
304
|
+
- **Semantic graph** — in-memory cosine similarity (N×N in ~5ms); embeddings via OpenRouter or Vercel AI Gateway; disk-cached per sha256(model+text)
|
|
236
305
|
- **LSP** — `vscode-languageserver/node` over stdio; requires Postgres (Drizzle ORM, `mdlsp_` prefix)
|
|
237
306
|
- **AI layer** (opt-in) — pgvector cosine search on canonical-term embeddings; `text-embedding-3-small` via Vercel AI Gateway
|
|
238
307
|
- **Bridge** — pure in-memory search (searchText, searchTextRanked, searchSymbols, searchPaths, listPages)
|
|
@@ -255,8 +324,10 @@ pnpm test
|
|
|
255
324
|
- **M1 — Structural layer** ✅
|
|
256
325
|
- **M2 — Semantic extract** (opt-in, code present, awaiting live AI Gateway credit)
|
|
257
326
|
- **M3 — CLI-first interface** ✅ (v1.0.0)
|
|
258
|
-
- M4 —
|
|
259
|
-
- M5 —
|
|
327
|
+
- **M4 — Graph export + HTML D3 visualisation** ✅ (v1.1.0)
|
|
328
|
+
- **M5 — Turnkey semantic graph (graph --semantic)** ✅ (v1.2.0)
|
|
329
|
+
- M6 — User overrides for the glossary (merge / split / rename / add_synonym)
|
|
330
|
+
- M7 — Docsbook integration
|
|
260
331
|
|
|
261
332
|
---
|
|
262
333
|
|