@bradwagoner/mcpdia 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +176 -2
- package/dist/cli.js +79 -0
- package/dist/cli.js.map +1 -0
- package/dist/context.js +51 -0
- package/dist/context.js.map +1 -0
- package/dist/core/annotate.js +53 -0
- package/dist/core/annotate.js.map +1 -0
- package/dist/core/errors.js +9 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/export.js +42 -0
- package/dist/core/export.js.map +1 -0
- package/dist/core/get.js +40 -0
- package/dist/core/get.js.map +1 -0
- package/dist/core/keys.js +89 -0
- package/dist/core/keys.js.map +1 -0
- package/dist/core/lifecycle.js +120 -0
- package/dist/core/lifecycle.js.map +1 -0
- package/dist/core/link.js +89 -0
- package/dist/core/link.js.map +1 -0
- package/dist/core/nodes.js +53 -0
- package/dist/core/nodes.js.map +1 -0
- package/dist/core/orient.js +51 -0
- package/dist/core/orient.js.map +1 -0
- package/dist/core/recent.js +27 -0
- package/dist/core/recent.js.map +1 -0
- package/dist/core/render.js +176 -0
- package/dist/core/render.js.map +1 -0
- package/dist/core/search.js +82 -0
- package/dist/core/search.js.map +1 -0
- package/dist/core/settings.js +31 -0
- package/dist/core/settings.js.map +1 -0
- package/dist/core/starters.js +308 -0
- package/dist/core/starters.js.map +1 -0
- package/dist/core/types.js +24 -0
- package/dist/core/types.js.map +1 -0
- package/dist/core/upsert.js +131 -0
- package/dist/core/upsert.js.map +1 -0
- package/dist/core/vocabulary.js +36 -0
- package/dist/core/vocabulary.js.map +1 -0
- package/dist/http.js +82 -0
- package/dist/http.js.map +1 -0
- package/dist/index.js +176 -0
- package/dist/index.js.map +1 -0
- package/dist/metrics.js +30 -0
- package/dist/metrics.js.map +1 -0
- package/dist/server.js +73 -0
- package/dist/server.js.map +1 -0
- package/dist/starters.js +82 -0
- package/dist/starters.js.map +1 -0
- package/dist/store/GraphStore.js +15 -0
- package/dist/store/GraphStore.js.map +1 -0
- package/dist/store/postgres/PostgresStore.js +388 -0
- package/dist/store/postgres/PostgresStore.js.map +1 -0
- package/dist/store/postgres/db.js +34 -0
- package/dist/store/postgres/db.js.map +1 -0
- package/dist/store/postgres/migrate.js +43 -0
- package/dist/store/postgres/migrate.js.map +1 -0
- package/dist/store/postgres/migrations/001_init.sql +130 -0
- package/dist/store/sqlite/SqliteStore.js +400 -0
- package/dist/store/sqlite/SqliteStore.js.map +1 -0
- package/dist/store/sqlite/migrate.js +38 -0
- package/dist/store/sqlite/migrate.js.map +1 -0
- package/dist/store/sqlite/migrations/001_init.sql +156 -0
- package/dist/store/sqlite/migrations/002_last_wrong_at.sql +3 -0
- package/dist/tools/annotate.js +17 -0
- package/dist/tools/annotate.js.map +1 -0
- package/dist/tools/delete.js +22 -0
- package/dist/tools/delete.js.map +1 -0
- package/dist/tools/deps.js +2 -0
- package/dist/tools/deps.js.map +1 -0
- package/dist/tools/feedback.js +14 -0
- package/dist/tools/feedback.js.map +1 -0
- package/dist/tools/get.js +65 -0
- package/dist/tools/get.js.map +1 -0
- package/dist/tools/link.js +28 -0
- package/dist/tools/link.js.map +1 -0
- package/dist/tools/listTypes.js +24 -0
- package/dist/tools/listTypes.js.map +1 -0
- package/dist/tools/orient.js +42 -0
- package/dist/tools/orient.js.map +1 -0
- package/dist/tools/recent.js +23 -0
- package/dist/tools/recent.js.map +1 -0
- package/dist/tools/resolveConflicts.js +12 -0
- package/dist/tools/resolveConflicts.js.map +1 -0
- package/dist/tools/respond.js +36 -0
- package/dist/tools/respond.js.map +1 -0
- package/dist/tools/search.js +48 -0
- package/dist/tools/search.js.map +1 -0
- package/dist/tools/supersede.js +31 -0
- package/dist/tools/supersede.js.map +1 -0
- package/dist/tools/upsert.js +45 -0
- package/dist/tools/upsert.js.map +1 -0
- package/dist/tools/verify.js +10 -0
- package/dist/tools/verify.js.map +1 -0
- package/dist/ulid.js +22 -0
- package/dist/ulid.js.map +1 -0
- package/package.json +66 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Brad Wagoner
|
|
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
CHANGED
|
@@ -1,3 +1,177 @@
|
|
|
1
|
-
#
|
|
1
|
+
# MCPdia
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://github.com/bradwagoner/mcpdia/actions/workflows/ci.yml)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
|
|
6
|
+
**Model Context Protocol: Distilled, Indexed Answers.** Long-term memory for LLMs, stored as a knowledge graph and served over MCP.
|
|
7
|
+
|
|
8
|
+
Tell your LLM "remember this" once, and have it find the answer later without re-reading whole files. MCPdia stores what you know as linked nodes, hands the model small summaries first, and lets it decide what is worth reading in full. The model does the filing too: it writes, links and corrects nodes as it works.
|
|
9
|
+
|
|
10
|
+
## The result
|
|
11
|
+
|
|
12
|
+
Same questions, same facts, fresh Claude sessions, three ways to keep memory:
|
|
13
|
+
|
|
14
|
+
| Memory | Tasks done right | Cost per session |
|
|
15
|
+
|---|---|---|
|
|
16
|
+
| **MCPdia** | **20/20** | **$0.0027** |
|
|
17
|
+
| One `CLAUDE.md` with everything in it | 20/20 | $0.0049 |
|
|
18
|
+
| A `CLAUDE.md` index plus hand-split topic files | 19/20 | $0.0022 |
|
|
19
|
+
|
|
20
|
+
**Every task right, at 44% less cost than one big memory file.** Hand-split markdown comes close on cost, but someone has to keep that index and those topic files in order. With MCPdia, the model files what it learns as it goes.
|
|
21
|
+
|
|
22
|
+
Method: Claude Haiku 5.5, ten read and write tasks against a fictional product team's knowledge (82 facts), each run twice, every session starting from a fresh copy. Run it yourself from [`bench/sessions`](bench/sessions/README.md); every session's pass, cost and tokens are in [`sessions.csv`](bench/sessions/data/sessions.csv).
|
|
23
|
+
|
|
24
|
+
## How it works
|
|
25
|
+
|
|
26
|
+
- **Stubs first.** `search` returns one line per node (title, summary, or the snippet around the match), so the model reads a few hundred tokens instead of a whole file.
|
|
27
|
+
- **Read only what matters.** `get` loads a node at the level it needs: `title`, `summary`, `snippet` or `full`.
|
|
28
|
+
- **Follow the links.** Nodes link to their parents and to each other, so related facts are one hop away.
|
|
29
|
+
- **Write back as you go.** `upsert`, `annotate`, `link`, `supersede` and `verify` are named for what the model is trying to do; the server does the bookkeeping.
|
|
30
|
+
- **Nothing is lost.** Every edit is versioned, deletes are soft, and a superseded node points to its replacement.
|
|
31
|
+
- **Learn what helps.** `feedback` marks nodes useful, not useful or wrong, and search flags nodes marked wrong.
|
|
32
|
+
|
|
33
|
+
## See what your LLM knows
|
|
34
|
+
|
|
35
|
+
<!-- Screenshot 1 (hero): docs/images/viewer-tree.png, concept/mcpdia selected with its family tree around it -->
|
|
36
|
+
|
|
37
|
+
**[Try the live demo](https://bradwagoner.github.io/mcpdia/)**: MCPdia's own notes about itself, in your browser, nothing to install.
|
|
38
|
+
|
|
39
|
+
Memory you can look at. The graph viewer opens your graph in the browser: every node your LLMs have written, linked the way they linked it, updating live while they work.
|
|
40
|
+
|
|
41
|
+
- **Click any node** and its family tree gathers around it: parents above, children below, siblings beside, and every other link grouped by type at the sides.
|
|
42
|
+
- **Search as you type**, then hide everything unrelated to focus on one corner of the graph.
|
|
43
|
+
- **Read it all** in the detail panel: summary, full text, properties and every connection, each one a link.
|
|
44
|
+
- **Watch it grow.** New nodes appear next to their neighbors as your LLM writes them, and your selection, search and camera stay put.
|
|
45
|
+
- **Fast on big graphs:** WebGL rendering with Sigma.js, tested at 10,000 nodes. Prefer Cytoscape.js? It's one dropdown away.
|
|
46
|
+
|
|
47
|
+
<!-- Screenshot 2: docs/images/viewer-search.png, a search with Hide unrelated ticked and the detail panel open -->
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
cd viewer
|
|
51
|
+
npm install
|
|
52
|
+
npm start
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
That's your graph, live and read-only, at http://localhost:8000. With Docker it's already running at http://localhost:7412. Add `-- --lan` to browse it from your phone. More in the [viewer guide](viewer/README.md).
|
|
56
|
+
|
|
57
|
+
## Features
|
|
58
|
+
|
|
59
|
+
- Twelve tools over stdio or HTTP: `orient`, `search`, `get`, `upsert`, `annotate`, `link`, `supersede`, `verify`, `delete`, `feedback`, `recent` and `list_types` ([reference](docs/tools.md))
|
|
60
|
+
- A local SQLite store with full-text search, ready to use with no setup
|
|
61
|
+
- One shared graph for a whole team: Postgres and HTTP in a single `docker compose up`
|
|
62
|
+
- Free-form node and edge types: a new type is pointed out, never blocked
|
|
63
|
+
- A tiny, configurable `orient` tool as the welcome mat for a new session
|
|
64
|
+
- Tools load on demand in Claude Code: until the model needs MCPdia, a session carries only its tool names
|
|
65
|
+
- JSONL export of the whole graph, and starter sets: exports loaded next to your own graph at startup, with your edits kept and conflicts flagged
|
|
66
|
+
- A per-call metrics log, to see where a session's tokens went
|
|
67
|
+
- A read-only [graph viewer](viewer/README.md) for browsing what your LLMs have written
|
|
68
|
+
- CI on Linux, macOS and Windows, with Node 22 and 24
|
|
69
|
+
|
|
70
|
+
## How it scales
|
|
71
|
+
|
|
72
|
+
Measured with the repo's own benches on a Windows desktop. No model is involved, so they cost nothing to rerun.
|
|
73
|
+
|
|
74
|
+
**Answers stay findable.** 40 questions about a demo project, with the answers hidden among generated nodes on other topics (`npm run bench:lookups`):
|
|
75
|
+
|
|
76
|
+
| Nodes | Answer in the top 3 | Search p50 / p95 | Get p50 |
|
|
77
|
+
| --- | --- | --- | --- |
|
|
78
|
+
| 82 | 39/40 | 2.0 / 3.3 ms | 0.1 ms |
|
|
79
|
+
| 1,082 | 40/40 | 2.3 / 3.9 ms | 0.1 ms |
|
|
80
|
+
| 10,082 | 39/40 | 9.6 / 22 ms | 0.2 ms |
|
|
81
|
+
| 100,082 | 38/40 | 339 / 755 ms | 0.2 ms |
|
|
82
|
+
|
|
83
|
+
**The cost of an answer stays flat.** Reading one answer from MCPdia takes about 660 tokens whether the memory holds 82 facts or 1,600. Loading the same memory as one markdown file grows from 15,000 to 250,000 tokens (`npm run bench:growth`).
|
|
84
|
+
|
|
85
|
+
**SQLite or Postgres.** Both stores find the same nodes: 177 and 176 of 177 in the top 3 on a real graph. SQLite is quickest for one person; Postgres keeps up when many clients share a big graph. Both Docker stacks on one machine, over HTTP, with a real 177-node graph and then with 10,000 more nodes (`npm run bench:stores`):
|
|
86
|
+
|
|
87
|
+
| | SQLite | Postgres | SQLite +10k | Postgres +10k |
|
|
88
|
+
| --- | --- | --- | --- | --- |
|
|
89
|
+
| Search, 1 client, p50 | 32 ms | 39 ms | 81 ms | 121 ms |
|
|
90
|
+
| Get, 1 client, p50 | 15 ms | 15 ms | 15 ms | 15 ms |
|
|
91
|
+
| 16 clients, 1 write in 4 | 144 calls/s | 56 calls/s | 23 calls/s | 77 calls/s |
|
|
92
|
+
|
|
93
|
+
Your numbers will differ with your machine; the shape holds.
|
|
94
|
+
|
|
95
|
+
## Install
|
|
96
|
+
|
|
97
|
+
Needs Node 22 or later. Nothing to clone and no build tools: the SQLite driver ships prebuilt. Register it with Claude Code:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
claude mcp add mcpdia -- npx -y @bradwagoner/mcpdia
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Other MCP clients take the same command in their config. The graph lives in `~/.mcpdia/mcpdia.db`. Set `MCPDIA_DB` to keep it somewhere else.
|
|
104
|
+
|
|
105
|
+
To run from source instead:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
git clone https://github.com/bradwagoner/mcpdia.git
|
|
109
|
+
cd mcpdia
|
|
110
|
+
npm install
|
|
111
|
+
npm run build
|
|
112
|
+
claude mcp add mcpdia -- node /path/to/mcpdia/dist/index.js
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Run it in Docker
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
docker compose up -d
|
|
119
|
+
claude mcp add --transport http mcpdia http://localhost:7411/mcp
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
That's MCPdia on Postgres, serving every client from one graph, with the live graph viewer at http://localhost:7412. Prefer a single SQLite file? `docker compose -f docker-compose.sqlite.yml up -d`. Settings are in [`docs/docker.md`](docs/docker.md).
|
|
123
|
+
|
|
124
|
+
### Export
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
node dist/index.js export --out graph.jsonl
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
This writes active nodes and their links. Add `--namespace ns` to pick namespaces, `--tag tag` to keep only tagged nodes and the links between them, or `--all-status` to include superseded and deleted nodes. The format is in [`docs/schema.md`](docs/schema.md#jsonl-export-format).
|
|
131
|
+
|
|
132
|
+
### Starter sets
|
|
133
|
+
|
|
134
|
+
Start with a graph that already knows things. A starter set is an export that loads into its own namespace whenever the server starts, next to your own graph:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
claude mcp add mcpdia -e MCPDIA_STARTERS=team=http://localhost:7411/export,mcpdia=mcpdia-starter.jsonl -- node /path/to/mcpdia/dist/index.js
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
One search covers your notes and every set, and your notes can link into them (`team:concept/billing`). Edit anything: untouched nodes follow the source, your edits stay, and if the source changed a node you edited too, you get a conflict node to review, listed at load and marked on the node. The `resolve-conflicts` prompt walks through them. Leave a set out of the list and it's gone from view at the next start. A relative file path is read from the database's folder (`~/.mcpdia`), since the client may start the server anywhere. Sharing a set with someone? Have them list it under the same name, so your links to `mcpdia:concept/...` resolve on their side too; your exports carry only your own graph, never the sets you loaded. Cut a set from any graph with `export --tag`, or load one by hand with `mcpdia seed set.jsonl --namespace name`. More in [ADR 0026](docs/decisions/0026-starter-sets-on-startup.md).
|
|
141
|
+
|
|
142
|
+
### Measure it yourself
|
|
143
|
+
|
|
144
|
+
Set `MCPDIA_METRICS=1` and every tool call adds one line to `mcpdia-metrics.jsonl` next to your database:
|
|
145
|
+
|
|
146
|
+
```json
|
|
147
|
+
{"ts":"2026-10-19T15:40:02.114Z","session":"01K7…","tool":"search","ms":4,"ok":true,"req_chars":38,"res_chars":912,"level":"summary"}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Each line is something the server measured: no estimates, no query text, no node content. Pair it with Claude's own usage report (`claude -p --output-format json`) to see where a session's tokens went, request by request.
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
claude mcp add mcpdia -e MCPDIA_METRICS=1 -- node /path/to/mcpdia/dist/index.js
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## Security
|
|
157
|
+
|
|
158
|
+
MCPdia feeds stored text back to LLMs, so treat what it returns as data, not instructions: a node can inform an agent, never authorize it. By default it runs locally over stdio against a SQLite file on your machine, with no network port. The HTTP server answers on localhost only. Details in [SECURITY.md](SECURITY.md).
|
|
159
|
+
|
|
160
|
+
## Roadmap
|
|
161
|
+
|
|
162
|
+
- **v0.2, cleanup and packs:** duplicate and stale-node finders, bulk merges and renames with dry runs, JSONL import, and seeding a graph from a document or repo.
|
|
163
|
+
- **v0.3, team mode:** Postgres, HTTP and the Docker image are in. Next come token auth, per-namespace permissions and a documented AWS deployment.
|
|
164
|
+
|
|
165
|
+
The full plan and release diary are in [`docs/SCOPE.md`](docs/SCOPE.md).
|
|
166
|
+
|
|
167
|
+
## Design
|
|
168
|
+
|
|
169
|
+
Every significant choice is written down with its reasoning:
|
|
170
|
+
|
|
171
|
+
- [Decision records](docs/decisions/README.md)
|
|
172
|
+
- [Schema](docs/schema.md)
|
|
173
|
+
- [Scope and release diary](docs/SCOPE.md)
|
|
174
|
+
|
|
175
|
+
## License
|
|
176
|
+
|
|
177
|
+
[MIT](LICENSE)
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { createWriteStream, realpathSync, renameSync, rmSync } from 'node:fs';
|
|
2
|
+
import { basename, dirname, join, resolve } from 'node:path';
|
|
3
|
+
import { UserError } from './core/errors.js';
|
|
4
|
+
/** Command-line helpers for src/index.ts, kept apart so they can be tested without starting anything. */
|
|
5
|
+
export const COMMANDS = ['export', 'seed'];
|
|
6
|
+
/** No command (or only flags) starts the server. Anything else must be a known command. */
|
|
7
|
+
export function pickCommand(argv) {
|
|
8
|
+
const [first, ...rest] = argv;
|
|
9
|
+
if (first === undefined || first.startsWith('-'))
|
|
10
|
+
return { command: 'serve', args: argv };
|
|
11
|
+
if (COMMANDS.includes(first))
|
|
12
|
+
return { command: first, args: rest };
|
|
13
|
+
throw new UserError(`Unknown command: ${first}.`, `Commands: ${COMMANDS.join(', ')} (or no command to start the server).`);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Writes lines to `path` through a temp file next to it, renamed into place
|
|
17
|
+
* once everything is written. If writing fails, the target is left untouched.
|
|
18
|
+
*/
|
|
19
|
+
export async function writeLinesAtomically(path, produce) {
|
|
20
|
+
const tmp = `${path}.${process.pid}.tmp`;
|
|
21
|
+
const out = createWriteStream(tmp);
|
|
22
|
+
const closed = new Promise((done) => out.once('close', () => done()));
|
|
23
|
+
const failed = new Promise((_, reject) => out.once('error', reject));
|
|
24
|
+
failed.catch(() => { }); // Raced below; this only stops an unhandled rejection warning.
|
|
25
|
+
const write = async (line) => {
|
|
26
|
+
if (!out.write(line + '\n'))
|
|
27
|
+
await Promise.race([new Promise((done) => out.once('drain', done)), failed]);
|
|
28
|
+
};
|
|
29
|
+
try {
|
|
30
|
+
const result = await Promise.race([produce(write), failed]);
|
|
31
|
+
await Promise.race([new Promise((done) => out.end(() => done())), failed]);
|
|
32
|
+
renameSync(tmp, path);
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
catch (err) {
|
|
36
|
+
// The file may still be opening; remove it only once the stream has let go of it.
|
|
37
|
+
out.destroy();
|
|
38
|
+
await closed;
|
|
39
|
+
rmSync(tmp, { force: true });
|
|
40
|
+
throw err;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Refuses an export path that is the database itself or one of its side files
|
|
45
|
+
* (-wal, -shm, -journal): writing there would replace the graph.
|
|
46
|
+
* Paths are compared after resolving symlinks, and case-insensitively on Windows and macOS.
|
|
47
|
+
*/
|
|
48
|
+
export function assertNotDatabase(out, dbPath) {
|
|
49
|
+
// The output usually doesn't exist yet, so resolve its folder instead.
|
|
50
|
+
const real = (path) => {
|
|
51
|
+
try {
|
|
52
|
+
return realpathSync(path);
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
try {
|
|
56
|
+
return join(realpathSync(dirname(resolve(path))), basename(path));
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return resolve(path);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
const fold = (path) => process.platform === 'win32' || process.platform === 'darwin' ? path.toLowerCase() : path;
|
|
64
|
+
const db = real(dbPath);
|
|
65
|
+
const target = fold(real(out));
|
|
66
|
+
if (['', '-wal', '-shm', '-journal'].some((suffix) => fold(db + suffix) === target)) {
|
|
67
|
+
throw new UserError(`--out ${out} is the database being exported.`, 'Pick another file name.');
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/** Turns errors a user can fix (a bad flag, an unknown namespace) into one line. */
|
|
71
|
+
export function errorLine(err) {
|
|
72
|
+
if (err instanceof UserError)
|
|
73
|
+
return [err.message, err.hint].filter(Boolean).join(' ');
|
|
74
|
+
const code = err?.code;
|
|
75
|
+
if (typeof code === 'string' && code.startsWith('ERR_PARSE_ARGS_'))
|
|
76
|
+
return err.message;
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC9E,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,yGAAyG;AAEzG,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAU,CAAC;AAGpD,2FAA2F;AAC3F,MAAM,UAAU,WAAW,CAAC,IAAc;IACxC,MAAM,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;IAC9B,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE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;IAC5F,MAAM,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;IACxB,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAC/B,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,GAAG,MAAM,CAAC,KAAK,MAAM,CAAC,EAAE,CAAC;QACpF,MAAM,IAAI,SAAS,CAAC,SAAS,GAAG,kCAAkC,EAAE,yBAAyB,CAAC,CAAC;IACjG,CAAC;AACH,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,SAAS,CAAC,GAAY;IACpC,IAAI,GAAG,YAAY,SAAS;QAAE,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACvF,MAAM,IAAI,GAAI,GAAiC,EAAE,IAAI,CAAC;IACtD,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC;QAAE,OAAQ,GAAa,CAAC,OAAO,CAAC;IAClG,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/context.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { UserError } from './core/errors.js';
|
|
2
|
+
/** The only place the default namespace is spelled out. */
|
|
3
|
+
export const DEFAULT_NAMESPACE = 'default';
|
|
4
|
+
export function soloContext() {
|
|
5
|
+
return { caller: 'local', namespaces: [DEFAULT_NAMESPACE], writeNamespace: DEFAULT_NAMESPACE };
|
|
6
|
+
}
|
|
7
|
+
/** Namespace names: letters, digits, `-` and `_`. No `:` or `/`, which keys use. */
|
|
8
|
+
const NAMESPACE = /^[a-z0-9][a-z0-9_-]*$/i;
|
|
9
|
+
export function checkNamespace(name, setting) {
|
|
10
|
+
if (!NAMESPACE.test(name)) {
|
|
11
|
+
throw new UserError(`${setting}: "${name}" is not a namespace name.`, 'Use letters, digits, - and _.');
|
|
12
|
+
}
|
|
13
|
+
return name;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The solo context with the namespaces from the environment (ADR 0026):
|
|
17
|
+
* MCPDIA_WRITE_NAMESPACE picks where writes go, MCPDIA_NAMESPACES adds read
|
|
18
|
+
* namespaces, and MCPDIA_STARTERS (`name=source,...`) adds starter sets.
|
|
19
|
+
*/
|
|
20
|
+
export function configFromEnv(env) {
|
|
21
|
+
const writeNamespace = checkNamespace(env.MCPDIA_WRITE_NAMESPACE?.trim() || DEFAULT_NAMESPACE, 'MCPDIA_WRITE_NAMESPACE');
|
|
22
|
+
const extra = list(env.MCPDIA_NAMESPACES).map((ns) => checkNamespace(ns, 'MCPDIA_NAMESPACES'));
|
|
23
|
+
const starters = list(env.MCPDIA_STARTERS).map(parseStarter);
|
|
24
|
+
const names = starters.map((s) => s.name);
|
|
25
|
+
const twice = names.find((name, i) => names.indexOf(name) !== i);
|
|
26
|
+
if (twice)
|
|
27
|
+
throw new UserError(`MCPDIA_STARTERS names "${twice}" twice.`, 'Give each starter set its own name.');
|
|
28
|
+
if (names.includes(writeNamespace)) {
|
|
29
|
+
throw new UserError(`Starter set "${writeNamespace}" is also the write namespace.`, 'A reload would overwrite your work. Pick another name, or set MCPDIA_WRITE_NAMESPACE.');
|
|
30
|
+
}
|
|
31
|
+
const ctx = {
|
|
32
|
+
...soloContext(),
|
|
33
|
+
namespaces: [...new Set([writeNamespace, ...extra, ...names])],
|
|
34
|
+
writeNamespace,
|
|
35
|
+
};
|
|
36
|
+
return { ctx, starters };
|
|
37
|
+
}
|
|
38
|
+
function list(value) {
|
|
39
|
+
return (value ?? '')
|
|
40
|
+
.split(',')
|
|
41
|
+
.map((s) => s.trim())
|
|
42
|
+
.filter(Boolean);
|
|
43
|
+
}
|
|
44
|
+
function parseStarter(entry) {
|
|
45
|
+
const eq = entry.indexOf('=');
|
|
46
|
+
if (eq <= 0 || eq === entry.length - 1) {
|
|
47
|
+
throw new UserError(`MCPDIA_STARTERS: "${entry}" is not name=source.`, 'Example: mcpdia=./starters/mcpdia.jsonl');
|
|
48
|
+
}
|
|
49
|
+
return { name: checkNamespace(entry.slice(0, eq).trim(), 'MCPDIA_STARTERS'), source: entry.slice(eq + 1).trim() };
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAe7C,2DAA2D;AAC3D,MAAM,CAAC,MAAM,iBAAiB,GAAG,SAAS,CAAC;AAE3C,MAAM,UAAU,WAAW;IACzB,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,iBAAiB,CAAC,EAAE,cAAc,EAAE,iBAAiB,EAAE,CAAC;AACjG,CAAC;AAaD,oFAAoF;AACpF,MAAM,SAAS,GAAG,wBAAwB,CAAC;AAE3C,MAAM,UAAU,cAAc,CAAC,IAAY,EAAE,OAAe;IAC1D,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,SAAS,CAAC,GAAG,OAAO,MAAM,IAAI,4BAA4B,EAAE,+BAA+B,CAAC,CAAC;IACzG,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,GAAsB;IAClD,MAAM,cAAc,GAAG,cAAc,CACnC,GAAG,CAAC,sBAAsB,EAAE,IAAI,EAAE,IAAI,iBAAiB,EACvD,wBAAwB,CACzB,CAAC;IACF,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,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AC,CAAC;IAC9B,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvC,MAAM,IAAI,SAAS,CAAC,qBAAqB,KAAK,uBAAuB,EAAE,yCAAyC,CAAC,CAAC;IACpH,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,iBAAiB,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;AACpH,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { UserError } from './errors.js';
|
|
2
|
+
import { displayKey, slugify, uniqueKey } from './keys.js';
|
|
3
|
+
import { requireActive } from './nodes.js';
|
|
4
|
+
export const NOTE_TYPE = 'note';
|
|
5
|
+
export const COMMENTS_ON = 'comments_on';
|
|
6
|
+
const TITLE_LENGTH = 80;
|
|
7
|
+
/**
|
|
8
|
+
* Leaves a note about a node (ADR 0008): a new `note` node with a key built
|
|
9
|
+
* from its text, the caller as author, and a `comments_on` edge to the
|
|
10
|
+
* target. The target's body and version are untouched.
|
|
11
|
+
*/
|
|
12
|
+
export async function annotate(ctx, store, input) {
|
|
13
|
+
const text = input.text.trim();
|
|
14
|
+
if (!text)
|
|
15
|
+
throw new UserError('text is empty.');
|
|
16
|
+
const target = await requireActive(ctx, store, input.on);
|
|
17
|
+
const title = (input.title?.trim() || firstLine(text)).slice(0, TITLE_LENGTH);
|
|
18
|
+
const namespace = ctx.writeNamespace;
|
|
19
|
+
// Notes are many and never meant to merge, so a clash just takes a suffix (ADR 0012).
|
|
20
|
+
const key = await uniqueKey(`${NOTE_TYPE}/${slugify(title)}`, async (k) => (await store.getNode(namespace, k)) !== null);
|
|
21
|
+
const note = await store.createNode({
|
|
22
|
+
namespace,
|
|
23
|
+
key,
|
|
24
|
+
type: NOTE_TYPE,
|
|
25
|
+
title,
|
|
26
|
+
summary: null,
|
|
27
|
+
body: text === title ? null : text,
|
|
28
|
+
properties: {},
|
|
29
|
+
aliases: [],
|
|
30
|
+
tags: [],
|
|
31
|
+
source: 'local',
|
|
32
|
+
author: ctx.caller,
|
|
33
|
+
});
|
|
34
|
+
await store.upsertEdge({
|
|
35
|
+
fromNamespace: note.namespace,
|
|
36
|
+
fromKey: note.key,
|
|
37
|
+
toNamespace: target.namespace,
|
|
38
|
+
toKey: target.key,
|
|
39
|
+
type: COMMENTS_ON,
|
|
40
|
+
note: null,
|
|
41
|
+
source: 'local',
|
|
42
|
+
author: ctx.caller,
|
|
43
|
+
});
|
|
44
|
+
return {
|
|
45
|
+
note,
|
|
46
|
+
noteKey: displayKey(ctx, note.namespace, note.key),
|
|
47
|
+
onKey: displayKey(ctx, target.namespace, target.key),
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function firstLine(text) {
|
|
51
|
+
return text.split('\n')[0].trim();
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=annotate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotate.js","sourceRoot":"","sources":["../../src/core/annotate.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC;AAChC,MAAM,CAAC,MAAM,WAAW,GAAG,aAAa,CAAC;AACzC,MAAM,YAAY,GAAG,EAAE,CAAC;AAgBxB;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,GAAY,EAAE,KAAiB,EAAE,KAAoB;IAClF,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,C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AAM,EAAE,OAAO;QACf,MAAM,EAAE,GAAG,CAAC,MAAM;KACnB,CAAC,CAAC;IACH,OAAO;QACL,IAAI;QACJ,OAAO,EAAE,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC;QAClD,KAAK,EAAE,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,GAAG,CAAC;KACrD,CAAC;AACJ,CAAC;AAED,SAAS,SAAS,CAAC,IAAY;IAC7B,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAE,CAAC,IAAI,EAAE,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,MAAM,OAAO,SAAU,SAAQ,KAAK;IAGhB,IAAI;IAFtB,YACE,OAAe,EACC,IAAa;QAE7B,KAAK,CAAC,OAAO,CAAC,CAAC;oBAFC,IAAI;IAGtB,CAAC;CACF"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { UserError } from './errors.js';
|
|
2
|
+
import { normalizeTag } from './vocabulary.js';
|
|
3
|
+
/** Bump when the line format changes in a way import must know about. */
|
|
4
|
+
export const EXPORT_FORMAT_VERSION = 1;
|
|
5
|
+
/**
|
|
6
|
+
* Writes the graph as JSON Lines: one header, then the nodes, then the active
|
|
7
|
+
* edges. Nodes come before edges so an importer can create them first.
|
|
8
|
+
* Active nodes only unless `allStatus` is set. The format is in docs/schema.md.
|
|
9
|
+
*/
|
|
10
|
+
export async function exportJsonl(ctx, store, input, write) {
|
|
11
|
+
const namespaces = input.namespaces?.length ? input.namespaces : [ctx.writeNamespace];
|
|
12
|
+
const hidden = namespaces.filter((ns) => !ctx.namespaces.includes(ns));
|
|
13
|
+
if (hidden.length) {
|
|
14
|
+
throw new UserError(`Unknown namespace: ${hidden.join(', ')}.`, `readable: ${ctx.namespaces.join(', ')}`);
|
|
15
|
+
}
|
|
16
|
+
// Current state only: version history is not exported. For a full backup, copy the database file.
|
|
17
|
+
const tags = input.tags?.map(normalizeTag).filter(Boolean) ?? [];
|
|
18
|
+
const nodes = (await store.listNodes(namespaces))
|
|
19
|
+
.filter((n) => input.allStatus || n.status === 'active')
|
|
20
|
+
.filter((n) => !tags.length || n.tags.some((t) => tags.includes(t)));
|
|
21
|
+
const at = (ns, key) => `${ns}:${key}`;
|
|
22
|
+
const kept = new Set(nodes.map((n) => at(n.namespace, n.key)));
|
|
23
|
+
const edges = (await store.listEdges(namespaces)).filter((e) => !tags.length || (kept.has(at(e.fromNamespace, e.fromKey)) && kept.has(at(e.toNamespace, e.toKey))));
|
|
24
|
+
const header = {
|
|
25
|
+
kind: 'header',
|
|
26
|
+
format: 'mcpdia-jsonl',
|
|
27
|
+
version: EXPORT_FORMAT_VERSION,
|
|
28
|
+
exportedAt: new Date().toISOString(),
|
|
29
|
+
namespaces,
|
|
30
|
+
...(tags.length ? { tags } : {}),
|
|
31
|
+
statuses: input.allStatus ? ['active', 'superseded', 'deleted'] : ['active'],
|
|
32
|
+
nodes: nodes.length,
|
|
33
|
+
edges: edges.length,
|
|
34
|
+
};
|
|
35
|
+
await write(JSON.stringify(header));
|
|
36
|
+
for (const node of nodes)
|
|
37
|
+
await write(JSON.stringify({ kind: 'node', ...node }));
|
|
38
|
+
for (const edge of edges)
|
|
39
|
+
await write(JSON.stringify({ kind: 'edge', ...edge }));
|
|
40
|
+
return header;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=export.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export.js","sourceRoot":"","sources":["../../src/core/export.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,yEAAyE;AACzE,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CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC;IACjF,KAAK,MAAM,IAAI,IAAI,KAAK;QAAE,MAAM,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC;IACjF,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/core/get.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { UserError } from './errors.js';
|
|
2
|
+
import { displayKey, parseRef } from './keys.js';
|
|
3
|
+
import { findNode, openConflicts, supersededByKey } from './nodes.js';
|
|
4
|
+
import { getSetting } from './settings.js';
|
|
5
|
+
export const MAX_NEIGHBORS = 20;
|
|
6
|
+
export async function get(ctx, store, input) {
|
|
7
|
+
const max = await getSetting(store, ctx, 'get.max_keys');
|
|
8
|
+
if (input.keys.length === 0)
|
|
9
|
+
throw new UserError('Pass at least one key.');
|
|
10
|
+
if (input.keys.length > max) {
|
|
11
|
+
throw new UserError(`Too many keys: ${input.keys.length}. get takes up to ${max} per call.`, 'Split them across calls.');
|
|
12
|
+
}
|
|
13
|
+
const items = [];
|
|
14
|
+
for (const ref of input.keys) {
|
|
15
|
+
const node = await findNode(ctx, store, parseRef(ctx, ref));
|
|
16
|
+
if (!node || (node.status === 'deleted' && !input.allStatus)) {
|
|
17
|
+
items.push({ ref, node: null, deleted: node !== null });
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
const conflict = (await openConflicts(ctx, store, [node])).get(node.id);
|
|
21
|
+
const item = { ref, node, supersededByKey: await supersededByKey(ctx, store, node) };
|
|
22
|
+
if (conflict)
|
|
23
|
+
item.conflictKey = conflict;
|
|
24
|
+
if (input.neighbors) {
|
|
25
|
+
// Links can cross namespaces; only show the ends the caller can read.
|
|
26
|
+
const readable = (await store.neighbors(node.id)).filter((n) => ctx.namespaces.includes(n.otherNamespace));
|
|
27
|
+
const all = readable.map((n) => ({
|
|
28
|
+
direction: n.direction,
|
|
29
|
+
type: n.edge.type,
|
|
30
|
+
key: displayKey(ctx, n.otherNamespace, n.otherKey),
|
|
31
|
+
node: n.other,
|
|
32
|
+
}));
|
|
33
|
+
item.neighbors = all.slice(0, MAX_NEIGHBORS);
|
|
34
|
+
item.moreNeighbors = Math.max(0, all.length - MAX_NEIGHBORS);
|
|
35
|
+
}
|
|
36
|
+
items.push(item);
|
|
37
|
+
}
|
|
38
|
+
return items;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=get.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get.js","sourceRoot":"","sources":["../../src/core/get.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,MAAM,CAAC,MAAM,aAAa,GAAG,EAAE,CAAC;AA+BhC,MAAM,CAAC,KAAK,UAAU,GAAG,CAAC,GAAY,EAAE,KAAiB,EAAE,KAAe;IACxE,MAAM,GAAG,GAAG,MAAM,UAAU,CAAC,KAAK,EAAE,GAAG,EAAE,cAAc,CAAC,CAAC;IACzD,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,MAAM,IAAI,SAAS,CAAC,wBAAwB,CAAC,CAAC;IAC3E,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC;QAC5B,MAAM,IAAI,SAAS,CACjB,kBAAkB,KAAK,CAAC,IAAI,CAAC,MAAM,qBAAqB,GAAG,YAAY,EACvE,0BAA0B,CAC3B,CAAC;IACJ,CAAC;IAED,MAAM,KAAK,GAAc,EAAE,CAAC;IAC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jB,GAAG,EAAE,UAAU,CAAC,GAAG,EAAE,CAAC,CAAC,cAAc,EAAE,CAAC,CAAC,QAAQ,CAAC;gBAClD,IAAI,EAAE,CAAC,CAAC,KAAK;aACd,CAAC,CAAC,CAAC;YACJ,IAAI,CAAC,SAAS,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC;YAC7C,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,MAAM,GAAG,aAAa,CAAC,CAAC;QAC/D,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACnB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { isUlid } from '../ulid.js';
|
|
2
|
+
/**
|
|
3
|
+
* Keys are `<type>/<slug>`, built from words rather than random ids so they
|
|
4
|
+
* are cheap to tokenize and mean something to the model (ADR 0012).
|
|
5
|
+
*/
|
|
6
|
+
const MAX_SLUG_WORDS = 6;
|
|
7
|
+
const MAX_SLUG_LENGTH = 48;
|
|
8
|
+
/** Words that make a key read as cut off when they end it ("...fed-by"). */
|
|
9
|
+
const TRAILING_FILLER = new Set('a an and as at by for from in into is of on or the to via vs with without'.split(' '));
|
|
10
|
+
/** Sentence and clause breaks: ". ", ", ", ": ", "; ", " - ", " — ", new lines. */
|
|
11
|
+
const CLAUSE_BREAK = /[.,:;!?](?=\s)|\s[-–—]\s|\n/g;
|
|
12
|
+
/**
|
|
13
|
+
* The first clause of the text that has at least two words, so a long
|
|
14
|
+
* sentence yields its lead phrase rather than whatever six words come first.
|
|
15
|
+
*/
|
|
16
|
+
function leadClause(text) {
|
|
17
|
+
for (const match of text.matchAll(CLAUSE_BREAK)) {
|
|
18
|
+
const head = text.slice(0, match.index);
|
|
19
|
+
if (toWords(head).length >= 2)
|
|
20
|
+
return head;
|
|
21
|
+
}
|
|
22
|
+
return text;
|
|
23
|
+
}
|
|
24
|
+
function toWords(text) {
|
|
25
|
+
return text
|
|
26
|
+
.normalize('NFKD')
|
|
27
|
+
.replace(/[̀-ͯ]/g, '')
|
|
28
|
+
.toLowerCase()
|
|
29
|
+
.split(/[^a-z0-9]+/)
|
|
30
|
+
.filter(Boolean);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Up to six words of the text's lead clause, at most 48 characters, never
|
|
34
|
+
* ending on a filler word, so the key reads as a phrase rather than a cut.
|
|
35
|
+
*/
|
|
36
|
+
export function slugify(text) {
|
|
37
|
+
const words = [];
|
|
38
|
+
let length = 0;
|
|
39
|
+
for (const word of toWords(leadClause(text)).slice(0, MAX_SLUG_WORDS)) {
|
|
40
|
+
length += word.length + (words.length ? 1 : 0);
|
|
41
|
+
if (length > MAX_SLUG_LENGTH)
|
|
42
|
+
break;
|
|
43
|
+
words.push(word);
|
|
44
|
+
}
|
|
45
|
+
while (words.length > 1 && TRAILING_FILLER.has(words[words.length - 1]))
|
|
46
|
+
words.pop();
|
|
47
|
+
return words.join('-') || 'untitled';
|
|
48
|
+
}
|
|
49
|
+
export function suggestKey(type, title) {
|
|
50
|
+
return `${type}/${slugify(title)}`;
|
|
51
|
+
}
|
|
52
|
+
/** `base`, or `base-2`, `base-3`, ... whichever is free first. */
|
|
53
|
+
export async function uniqueKey(base, isTaken) {
|
|
54
|
+
if (!(await isTaken(base)))
|
|
55
|
+
return base;
|
|
56
|
+
for (let n = 2;; n++) {
|
|
57
|
+
const candidate = `${base}-${n}`;
|
|
58
|
+
if (!(await isTaken(candidate)))
|
|
59
|
+
return candidate;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/** Keys are stored as given apart from trimming; they are identities, not vocabulary. */
|
|
63
|
+
export function cleanKey(key) {
|
|
64
|
+
return key.trim();
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Parses what a caller typed: `ns:key`, a bare key (resolved against the
|
|
68
|
+
* write namespace), or a ULID id.
|
|
69
|
+
*/
|
|
70
|
+
export function parseRef(ctx, input) {
|
|
71
|
+
const value = input.trim();
|
|
72
|
+
if (isUlid(value))
|
|
73
|
+
return { kind: 'id', id: value };
|
|
74
|
+
// The namespace ends at the last colon before the first slash, so `user:alice:note/x` works.
|
|
75
|
+
const slash = value.indexOf('/');
|
|
76
|
+
const colon = (slash === -1 ? value : value.slice(0, slash)).lastIndexOf(':');
|
|
77
|
+
if (colon > 0) {
|
|
78
|
+
return { kind: 'key', namespace: value.slice(0, colon), key: value.slice(colon + 1) };
|
|
79
|
+
}
|
|
80
|
+
return { kind: 'key', namespace: ctx.writeNamespace, key: value };
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Keys in the write namespace are shown bare, since a bare key resolves there
|
|
84
|
+
* (parseRef); keys in any other namespace are qualified, e.g. `mcpdia:concept/x`.
|
|
85
|
+
*/
|
|
86
|
+
export function displayKey(ctx, namespace, key) {
|
|
87
|
+
return namespace === ctx.writeNamespace ? key : `${namespace}:${key}`;
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=keys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../../src/core/keys.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEpC;;;GAGG;AAEH,MAAM,cAAc,GAAG,CAAC,CAAC;AACzB,MAAM,eAAe,GAAG,EAAE,CAAC;AAE3B,4EAA4E;AAC5E,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,2EAA2E,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;AAExH,mFAAmF;AACnF,MAAM,YAAY,GAAG,8BAA8B,CAAC;AAEpD;;;GAGG;AACH,SAAS,UAAU,CAAC,IAAY;IAC9B,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;QAChD,MAAM,IAAI,GAAG,IAAI,CAA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