@agent-wiki/mcp-server 0.3.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/README.md ADDED
@@ -0,0 +1,251 @@
1
+ # agent-wiki
2
+
3
+ [![CI](https://github.com/xinhuagu/agent-wiki/actions/workflows/ci.yml/badge.svg)](https://github.com/xinhuagu/agent-wiki/actions/workflows/ci.yml)
4
+ [![Node](https://img.shields.io/badge/node-%3E%3D18-brightgreen)](https://nodejs.org)
5
+ [![MCP](https://img.shields.io/badge/protocol-MCP-blue)](https://modelcontextprotocol.io)
6
+ [![License: MIT](https://img.shields.io/badge/license-MIT-yellow.svg)](LICENSE)
7
+
8
+ A structured knowledge base that any AI agent can read, write, and maintain through the [Model Context Protocol](https://modelcontextprotocol.io). No LLM built in — your agent IS the LLM.
9
+
10
+ ```
11
+ npx @agent-wiki/mcp-server
12
+ ```
13
+
14
+ ---
15
+
16
+ ## The Idea
17
+
18
+ Most AI systems treat knowledge as disposable. You ask a question, it retrieves some fragments, generates an answer, and everything is forgotten. Next time you ask, it starts from zero.
19
+
20
+ agent-wiki takes a different approach: **knowledge compilation**. Instead of retrieving raw documents every time (RAG), the agent incrementally builds and maintains a persistent wiki — structured, interlinked, and continuously refined. Every interaction makes the knowledge base smarter.
21
+
22
+ The key insight: **LLMs are better editors than search engines.** Let them curate, synthesize, and maintain knowledge over time, not just retrieve it on demand.
23
+
24
+ ### RAG vs Knowledge Compilation
25
+
26
+ | | RAG | agent-wiki |
27
+ |---|---|---|
28
+ | **Approach** | Retrieve fragments at query time | Build and maintain compiled knowledge |
29
+ | **Memory** | Stateless — forgets after each query | Persistent — knowledge accumulates |
30
+ | **Quality** | Raw chunks, often noisy | Curated, structured, interlinked |
31
+ | **Cost** | Embedding + retrieval every query | One-time compilation, free reads |
32
+ | **Contradictions** | Invisible — buried in source docs | Detected automatically by lint |
33
+ | **Source tracking** | Lost after retrieval | Full provenance chain (raw -> wiki) |
34
+
35
+ ## Architecture
36
+
37
+ Three immutability layers, inspired by how compilers work:
38
+
39
+ ```
40
+ raw/ Immutable source documents (write-once, SHA-256 verified)
41
+ Papers, articles, web pages — the "source code" of knowledge
42
+
43
+ wiki/ Mutable compiled knowledge (entity pages, synthesis, index)
44
+ Structured Markdown — the "compiled output"
45
+
46
+ schemas/ Entity templates (person, concept, event, artifact, ...)
47
+ Consistent structure across all knowledge
48
+ ```
49
+
50
+ The agent reads from `raw/`, compiles understanding into `wiki/`, and the lint system ensures quality:
51
+
52
+ <p align="center">
53
+ <img src="architecture.svg" alt="agent-wiki architecture" width="700" />
54
+ </p>
55
+
56
+ ## Key Features
57
+
58
+ ### Immutable Source Layer (`raw/`)
59
+
60
+ - **Write-once** — raw files can never be modified or overwritten after creation
61
+ - **SHA-256 integrity** — every file is hashed; corruption or tampering is detected
62
+ - **Provenance tracking** — `.meta.yaml` sidecars record source URL, download time, description
63
+ - **URL fetching** — `raw_fetch` downloads directly from URLs, with smart arXiv handling (`arxiv.org/abs/XXXX` auto-converts to PDF)
64
+ - **Local file copy** — `raw_add` with `source_path` physically copies files into `raw/`
65
+
66
+ ### Mutable Knowledge Layer (`wiki/`)
67
+
68
+ - **Structured Markdown** — YAML frontmatter (title, type, tags, sources) + Markdown body
69
+ - **9 entity types** — person, concept, event, artifact, comparison, summary, how-to, note, synthesis
70
+ - **Auto-classification** — heuristic classifier assigns entity type and suggests tags, zero LLM needed
71
+ - **`[[wiki-links]]`** — interlink pages to build a knowledge graph
72
+ - **Synthesis pages** — higher-order knowledge distilled from combining multiple pages
73
+ - **Auto-timestamps** — `created` and `updated` managed automatically
74
+ - **System pages** — index.md, log.md, timeline.md maintained by the engine
75
+
76
+ ### Self-Checking (`lint`)
77
+
78
+ No human review needed. The lint system catches problems automatically:
79
+
80
+ - **Contradictions** — conflicting dates, numbers, and claims across pages
81
+ - **Orphan pages** — pages with no incoming links
82
+ - **Broken links** — `[[page]]` references to non-existent pages
83
+ - **Missing sources** — wiki claims not traceable to raw documents
84
+ - **Stale content** — pages not updated beyond a configurable threshold
85
+ - **Raw integrity** — SHA-256 re-verification of all source files
86
+ - **Synthesis integrity** — checks that source pages of synthesis still exist
87
+
88
+ ### Workspace Separation
89
+
90
+ Code and data live in separate directories. The tool is stateless; all state lives in the workspace:
91
+
92
+ ```yaml
93
+ # .agent-wiki.yaml
94
+ wiki:
95
+ workspace: /path/to/data # all data goes here
96
+ path: wiki/
97
+ raw_path: raw/
98
+ schemas_path: schemas/
99
+ ```
100
+
101
+ Workspace resolution priority: CLI `--workspace` > `AGENT_WIKI_WORKSPACE` env > config file > config root.
102
+
103
+ ### Auto-Classification
104
+
105
+ Every `wiki_write` automatically classifies content if no type is specified:
106
+
107
+ ```
108
+ Input: "# YOLO Object Detection\n\nYOLO is a real-time detection model..."
109
+ Output: { type: "concept", tags: ["yolo", "object-detection", "real-time"], confidence: 0.8 }
110
+ ```
111
+
112
+ Pure heuristic — no LLM calls, no API keys, zero latency. Supports English and Chinese keywords.
113
+
114
+ ## Setup
115
+
116
+ ### Claude Code / AceClaw
117
+
118
+ `~/.aceclaw/mcp-servers.json`:
119
+
120
+ ```json
121
+ {
122
+ "mcpServers": {
123
+ "agent-wiki": {
124
+ "command": "npx",
125
+ "args": ["-y", "agent-wiki", "serve", "--wiki-path", "/path/to/config", "--workspace", "/path/to/data"]
126
+ }
127
+ }
128
+ }
129
+ ```
130
+
131
+ ### Cursor / Windsurf / any MCP client
132
+
133
+ Same pattern — `npx -y @agent-wiki/mcp-server serve --wiki-path /path/to/config`.
134
+
135
+ ### Claude Desktop
136
+
137
+ `claude_desktop_config.json`:
138
+
139
+ ```json
140
+ {
141
+ "mcpServers": {
142
+ "agent-wiki": {
143
+ "command": "npx",
144
+ "args": ["-y", "agent-wiki", "serve", "--wiki-path", "/path/to/config"]
145
+ }
146
+ }
147
+ }
148
+ ```
149
+
150
+ ## MCP Tools (17 total)
151
+
152
+ ### Raw Layer — Immutable Sources
153
+
154
+ | Tool | Description |
155
+ |------|-------------|
156
+ | `raw_add` | Add a source document (immutable, SHA-256 hashed, .meta.yaml sidecar) |
157
+ | `raw_fetch` | Download from URL to raw/ (smart arXiv handling, auto-provenance) |
158
+ | `raw_list` | List all raw documents with metadata |
159
+ | `raw_read` | Read a raw document's content and metadata |
160
+ | `raw_verify` | Verify integrity of all raw files (SHA-256 check) |
161
+
162
+ ### Wiki Layer — Compiled Knowledge
163
+
164
+ | Tool | Description |
165
+ |------|-------------|
166
+ | `wiki_read` | Read a page (frontmatter + Markdown) |
167
+ | `wiki_write` | Create or update a page (auto-timestamps, auto-classify) |
168
+ | `wiki_delete` | Delete a page (guards system pages) |
169
+ | `wiki_list` | List pages, filter by type or tag |
170
+ | `wiki_search` | Full-text keyword search with relevance scoring |
171
+ | `wiki_lint` | Health checks: contradictions, orphans, broken links, integrity |
172
+ | `wiki_classify` | Auto-classify content into entity type + suggest tags |
173
+ | `wiki_synthesize` | Prepare context for knowledge distillation across pages |
174
+ | `wiki_log` | Operation history with timestamps |
175
+ | `wiki_init` | Initialize a new knowledge base |
176
+ | `wiki_schemas` | List entity templates |
177
+ | `wiki_rebuild_index` | Rebuild index.md (grouped by type) |
178
+ | `wiki_rebuild_timeline` | Rebuild timeline.md (chronological view) |
179
+ | `wiki_config` | Show current workspace configuration |
180
+
181
+ ## Entity Types
182
+
183
+ | Type | Use Case | Example |
184
+ |------|----------|---------|
185
+ | `person` | People profiles | Researchers, engineers, historical figures |
186
+ | `concept` | Ideas and definitions | YOLO, attention mechanism, mutex |
187
+ | `event` | Things that happened | Conference talks, releases, incidents |
188
+ | `artifact` | Created things | Papers, tools, models, datasets |
189
+ | `comparison` | Side-by-side analysis | YOLOv8 vs YOLOv9, PyTorch vs TensorFlow |
190
+ | `summary` | Document summaries | Paper summaries, article digests |
191
+ | `how-to` | Procedures and guides | Setup guides, deployment steps |
192
+ | `note` | Freeform knowledge | Anything that doesn't fit other types |
193
+ | `synthesis` | Distilled knowledge | Insights from combining multiple pages |
194
+
195
+ ## Page Format
196
+
197
+ ```markdown
198
+ ---
199
+ title: YOLO Object Detection
200
+ type: concept
201
+ tags: [yolo, detection, computer-vision]
202
+ sources: [paper-yolo-v1.pdf]
203
+ created: "2026-04-05T12:00:00.000Z"
204
+ updated: "2026-04-05T14:30:00.000Z"
205
+ ---
206
+
207
+ # YOLO Object Detection
208
+
209
+ You Only Look Once — real-time object detection.
210
+
211
+ Related: [[comparison-detectors]], [[person-redmon]]
212
+ ```
213
+
214
+ Synthesis pages track their derivation:
215
+
216
+ ```markdown
217
+ ---
218
+ title: Object Detection Overview
219
+ type: synthesis
220
+ derived_from: [concept-yolo.md, concept-ssd.md, concept-rcnn.md]
221
+ ---
222
+ ```
223
+
224
+ ## CLI
225
+
226
+ ```bash
227
+ npx agent-wiki serve # start MCP server (stdio)
228
+ npx agent-wiki serve --workspace ./data # separate data directory
229
+ npx agent-wiki init ./my-kb # initialize new knowledge base
230
+ npx agent-wiki search "yolo" # search wiki
231
+ npx agent-wiki list # list all pages
232
+ npx agent-wiki list --type concept # filter by type
233
+ npx agent-wiki raw-list # list raw sources
234
+ npx agent-wiki raw-verify # verify raw file integrity
235
+ npx agent-wiki lint # run health checks
236
+ ```
237
+
238
+ ## Design Principles
239
+
240
+ 1. **Raw is immutable** — Source documents are write-once, SHA-256 verified. The ground truth never changes.
241
+ 2. **Wiki is mutable** — Compiled knowledge improves with every interaction. Pages are refined, not replaced.
242
+ 3. **No LLM dependency** — Zero API keys, zero cost per operation. The agent calling the tools IS the intelligence.
243
+ 4. **Self-checking** — Lint catches contradictions, broken links, and integrity issues without human review.
244
+ 5. **Knowledge compounds** — Every write enriches the whole wiki. Synthesis creates higher-order understanding.
245
+ 6. **Provenance matters** — Every wiki claim traces back to raw sources. No hallucination without accountability.
246
+ 7. **Code and data separate** — Configurable workspace keeps your knowledge portable and independent.
247
+ 8. **Git-native** — Plain Markdown files. Every change is diffable, blameable, and revertable.
248
+
249
+ ## License
250
+
251
+ MIT
package/dist/cli.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * CLI entry point for agent-wiki.
4
+ *
5
+ * Usage:
6
+ * npx @agent-wiki/mcp-server # start MCP server (stdio)
7
+ * npx @agent-wiki/mcp-server --wiki-path /kb # custom wiki root
8
+ * npx @agent-wiki/mcp-server init ./my-kb # initialize a new knowledge base
9
+ */
10
+ export {};
11
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA;;;;;;;GAOG"}
package/dist/cli.js ADDED
@@ -0,0 +1,181 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * CLI entry point for agent-wiki.
4
+ *
5
+ * Usage:
6
+ * npx @agent-wiki/mcp-server # start MCP server (stdio)
7
+ * npx @agent-wiki/mcp-server --wiki-path /kb # custom wiki root
8
+ * npx @agent-wiki/mcp-server init ./my-kb # initialize a new knowledge base
9
+ */
10
+ import { Command } from "commander";
11
+ import { Wiki } from "./wiki.js";
12
+ import { runServer } from "./server.js";
13
+ const program = new Command();
14
+ program
15
+ .name("agent-wiki")
16
+ .description("Agent-driven knowledge base — structured Markdown wiki with MCP server.\n" +
17
+ "raw/ = immutable sources | wiki/ = mutable knowledge | schemas/ = templates")
18
+ .version("0.3.0");
19
+ // Default command: start MCP server
20
+ program
21
+ .command("serve", { isDefault: true })
22
+ .description("Start MCP server (stdio transport)")
23
+ .option("-w, --wiki-path <path>", "Path to config root (where .agent-wiki.yaml lives)", ".")
24
+ .option("--workspace <path>", "Workspace directory for all data (wiki/, raw/, schemas/). Overrides config and env.")
25
+ .action(async (opts) => {
26
+ await runServer(opts.wikiPath, opts.workspace);
27
+ });
28
+ // Init
29
+ program
30
+ .command("init [path]")
31
+ .description("Initialize a new knowledge base")
32
+ .option("--workspace <path>", "Separate workspace directory for data (wiki/, raw/, schemas/)")
33
+ .action((path, opts) => {
34
+ const target = path ?? ".";
35
+ const ws = opts.workspace;
36
+ Wiki.init(target, ws);
37
+ console.error(`Knowledge base initialized:`);
38
+ console.error(` Config: ${target}/.agent-wiki.yaml`);
39
+ if (ws) {
40
+ console.error(` Workspace: ${ws}/`);
41
+ }
42
+ console.error(" wiki/ — Mutable Markdown pages (agent-managed)");
43
+ console.error(" raw/ — Immutable source documents (write-once)");
44
+ console.error(" schemas/ — Entity templates (person, concept, event, ...)");
45
+ });
46
+ // Search
47
+ program
48
+ .command("search <query>")
49
+ .description("Search wiki pages by keyword")
50
+ .option("-w, --wiki-path <path>", "Path to config root", ".")
51
+ .option("--workspace <path>", "Workspace directory override")
52
+ .option("-n, --limit <n>", "Max results", "10")
53
+ .action((query, opts) => {
54
+ const wiki = new Wiki(opts.wikiPath, opts.workspace);
55
+ const results = wiki.search(query, parseInt(opts.limit));
56
+ if (results.length === 0) {
57
+ console.log("No matches.");
58
+ return;
59
+ }
60
+ for (const r of results) {
61
+ console.log(` [${r.score}] ${r.path}`);
62
+ console.log(` ${r.snippet}`);
63
+ }
64
+ });
65
+ // List wiki pages
66
+ program
67
+ .command("list")
68
+ .description("List all wiki pages")
69
+ .option("-w, --wiki-path <path>", "Path to config root", ".")
70
+ .option("--workspace <path>", "Workspace directory override")
71
+ .option("-t, --type <type>", "Filter by entity type")
72
+ .option("--tag <tag>", "Filter by tag")
73
+ .action((opts) => {
74
+ const wiki = new Wiki(opts.wikiPath, opts.workspace);
75
+ const pages = wiki.list(opts.type, opts.tag);
76
+ if (pages.length === 0) {
77
+ console.log("No pages.");
78
+ return;
79
+ }
80
+ console.log(`${pages.length} pages:`);
81
+ for (const p of pages) {
82
+ console.log(` ${p}`);
83
+ }
84
+ });
85
+ // List raw sources
86
+ program
87
+ .command("raw-list")
88
+ .description("List all raw source documents")
89
+ .option("-w, --wiki-path <path>", "Path to config root", ".")
90
+ .option("--workspace <path>", "Workspace directory override")
91
+ .action((opts) => {
92
+ const wiki = new Wiki(opts.wikiPath, opts.workspace);
93
+ const docs = wiki.rawList();
94
+ if (docs.length === 0) {
95
+ console.log("No raw documents.");
96
+ return;
97
+ }
98
+ console.log(`${docs.length} raw documents:`);
99
+ for (const d of docs) {
100
+ const url = d.sourceUrl ? ` (${d.sourceUrl})` : "";
101
+ console.log(` ${d.path} — ${formatBytes(d.size)}${url}`);
102
+ }
103
+ });
104
+ // Verify raw integrity
105
+ program
106
+ .command("raw-verify")
107
+ .description("Verify integrity of raw source documents (SHA-256)")
108
+ .option("-w, --wiki-path <path>", "Path to config root", ".")
109
+ .option("--workspace <path>", "Workspace directory override")
110
+ .action((opts) => {
111
+ const wiki = new Wiki(opts.wikiPath, opts.workspace);
112
+ const results = wiki.rawVerify();
113
+ if (results.length === 0) {
114
+ console.log("No raw documents to verify.");
115
+ return;
116
+ }
117
+ let ok = 0, bad = 0, noMeta = 0;
118
+ for (const r of results) {
119
+ if (r.status === "ok") {
120
+ ok++;
121
+ }
122
+ else if (r.status === "corrupted") {
123
+ bad++;
124
+ console.log(` [CORRUPT] ${r.path}`);
125
+ }
126
+ else {
127
+ noMeta++;
128
+ console.log(` [NO META] ${r.path}`);
129
+ }
130
+ }
131
+ console.log(`\n${ok} ok, ${bad} corrupted, ${noMeta} missing metadata`);
132
+ });
133
+ // Lint
134
+ program
135
+ .command("lint")
136
+ .description("Run health checks (contradictions, orphans, broken links, integrity)")
137
+ .option("-w, --wiki-path <path>", "Path to config root", ".")
138
+ .option("--workspace <path>", "Workspace directory override")
139
+ .action((opts) => {
140
+ const wiki = new Wiki(opts.wikiPath, opts.workspace);
141
+ const report = wiki.lint();
142
+ if (report.issues.length === 0) {
143
+ console.log(`All ${report.pagesChecked} pages + ${report.rawChecked} raw files healthy.`);
144
+ return;
145
+ }
146
+ console.log(`Checked ${report.pagesChecked} pages + ${report.rawChecked} raw files\n`);
147
+ if (report.contradictions.length > 0) {
148
+ console.log(`Contradictions (${report.contradictions.length}):`);
149
+ for (const c of report.contradictions) {
150
+ console.log(` ${c.pageA} vs ${c.pageB}: ${c.claim}`);
151
+ console.log(` "${c.excerptA}" vs "${c.excerptB}"`);
152
+ }
153
+ console.log();
154
+ }
155
+ const grouped = {};
156
+ for (const issue of report.issues) {
157
+ const cat = issue.category ?? "other";
158
+ if (!grouped[cat])
159
+ grouped[cat] = [];
160
+ grouped[cat].push(issue);
161
+ }
162
+ for (const [cat, issues] of Object.entries(grouped)) {
163
+ console.log(`${cat} (${issues.length}):`);
164
+ for (const issue of issues) {
165
+ const icon = issue.severity === "error" ? "ERR" : issue.severity === "warning" ? "WARN" : "INFO";
166
+ console.log(` [${icon}] ${issue.page}: ${issue.message}`);
167
+ if (issue.suggestion)
168
+ console.log(` -> ${issue.suggestion}`);
169
+ }
170
+ console.log();
171
+ }
172
+ });
173
+ program.parse();
174
+ function formatBytes(bytes) {
175
+ if (bytes < 1024)
176
+ return `${bytes} B`;
177
+ if (bytes < 1024 * 1024)
178
+ return `${(bytes / 1024).toFixed(1)} KB`;
179
+ return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
180
+ }
181
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA;;;;;;;GAOG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,YAAY,CAAC;KAClB,WAAW,CACV,2EAA2E;IAC3E,6EAA6E,CAC9E;KACA,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,oCAAoC;AACpC,OAAO;KACJ,OAAO,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;KACrC,WAAW,CAAC,oCAAoC,CAAC;KACjD,MAAM,CAAC,wBAAwB,EAAE,oDAAoD,E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,CAAC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * agent-wiki — Agent-driven knowledge base.
3
+ *
4
+ * Architecture (Karpathy LLM Wiki pattern):
5
+ *
6
+ * raw/ — Immutable sources. Write-once, never modified. SHA-256 verified.
7
+ * wiki/ — Mutable knowledge. System pages, entity pages, synthesis pages.
8
+ * schemas/ — Entity templates.
9
+ *
10
+ * No LLM dependency. Your agent IS the LLM.
11
+ * This package provides:
12
+ * - Raw document management (immutable, integrity-checked)
13
+ * - Wiki CRUD with auto-timestamping
14
+ * - Keyword search with relevance scoring
15
+ * - Lint with contradiction detection and integrity checks
16
+ * - Knowledge synthesis preparation
17
+ * - MCP server interface
18
+ *
19
+ * Usage as MCP server:
20
+ * npx @agent-wiki/mcp-server
21
+ *
22
+ * Usage as library:
23
+ * import { Wiki } from "@agent-wiki/mcp-server";
24
+ * const wiki = new Wiki("/path/to/kb");
25
+ * wiki.rawAdd("paper.md", { content: "...", sourceUrl: "..." });
26
+ * wiki.write("concept-gil.md", content);
27
+ * const results = wiki.search("python");
28
+ * const report = wiki.lint(); // contradiction detection included
29
+ */
30
+ export { Wiki } from "./wiki.js";
31
+ export type { WikiPage, RawDocument, LintIssue, LintReport, Contradiction, TimelineEntry, WikiConfig, } from "./wiki.js";
32
+ export { createServer, runServer } from "./server.js";
33
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,YAAY,EACV,QAAQ,EACR,WAAW,EACX,SAAS,EACT,UAAU,EACV,aAAa,EACb,aAAa,EACb,UAAU,GACX,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,32 @@
1
+ /**
2
+ * agent-wiki — Agent-driven knowledge base.
3
+ *
4
+ * Architecture (Karpathy LLM Wiki pattern):
5
+ *
6
+ * raw/ — Immutable sources. Write-once, never modified. SHA-256 verified.
7
+ * wiki/ — Mutable knowledge. System pages, entity pages, synthesis pages.
8
+ * schemas/ — Entity templates.
9
+ *
10
+ * No LLM dependency. Your agent IS the LLM.
11
+ * This package provides:
12
+ * - Raw document management (immutable, integrity-checked)
13
+ * - Wiki CRUD with auto-timestamping
14
+ * - Keyword search with relevance scoring
15
+ * - Lint with contradiction detection and integrity checks
16
+ * - Knowledge synthesis preparation
17
+ * - MCP server interface
18
+ *
19
+ * Usage as MCP server:
20
+ * npx @agent-wiki/mcp-server
21
+ *
22
+ * Usage as library:
23
+ * import { Wiki } from "@agent-wiki/mcp-server";
24
+ * const wiki = new Wiki("/path/to/kb");
25
+ * wiki.rawAdd("paper.md", { content: "...", sourceUrl: "..." });
26
+ * wiki.write("concept-gil.md", content);
27
+ * const results = wiki.search("python");
28
+ * const report = wiki.lint(); // contradiction detection included
29
+ */
30
+ export { Wiki } from "./wiki.js";
31
+ export { createServer, runServer } from "./server.js";
32
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAUjC,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * MCP Server — Exposes Agent Wiki as tools to any MCP-compatible agent.
3
+ *
4
+ * Architecture (Karpathy LLM Wiki, upgraded):
5
+ *
6
+ * raw/ → Immutable source layer (raw_add, raw_list, raw_read, raw_verify)
7
+ * wiki/ → Mutable knowledge layer (read, write, delete, search, lint, synthesize)
8
+ *
9
+ * The agent IS the LLM. This server is pure data operations.
10
+ */
11
+ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
12
+ export declare function createServer(wikiPath?: string, workspace?: string): Server;
13
+ export declare function runServer(wikiPath?: string, workspace?: string): Promise<void>;
14
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAUnE,wBAAgB,YAAY,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CA6U1E;AAyLD,wBAAsB,SAAS,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAIpF"}