@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 +251 -0
- package/dist/cli.d.ts +11 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +181 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -0
- package/dist/server.d.ts +14 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +474 -0
- package/dist/server.js.map +1 -0
- package/dist/wiki.d.ts +218 -0
- package/dist/wiki.d.ts.map +1 -0
- package/dist/wiki.js +1378 -0
- package/dist/wiki.js.map +1 -0
- package/package.json +53 -0
package/dist/wiki.d.ts
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core Wiki engine — pure data layer, zero LLM dependency.
|
|
3
|
+
*
|
|
4
|
+
* Architecture (Karpathy LLM Wiki pattern):
|
|
5
|
+
*
|
|
6
|
+
* raw/ — Immutable source documents. Write-once, never modified.
|
|
7
|
+
* Each file has a .meta.yaml sidecar with provenance.
|
|
8
|
+
*
|
|
9
|
+
* wiki/ — Mutable Markdown layer. Three kinds of files:
|
|
10
|
+
* 1. System: index.md, log.md, timeline.md (auto-maintained)
|
|
11
|
+
* 2. Entity pages: concept-*, person-*, artifact-*, etc.
|
|
12
|
+
* 3. Synthesis pages: synthesis-* (distilled from multiple pages)
|
|
13
|
+
*
|
|
14
|
+
* schemas/ — Entity templates (person, concept, event, etc.)
|
|
15
|
+
*
|
|
16
|
+
* Key principles:
|
|
17
|
+
* - Raw files are IMMUTABLE — the source of truth
|
|
18
|
+
* - Wiki pages are MUTABLE — compiled knowledge, continuously refined
|
|
19
|
+
* - Self-checking: lint detects contradictions, broken links, stale claims
|
|
20
|
+
* - Knowledge compounds: every write improves the whole
|
|
21
|
+
*/
|
|
22
|
+
export interface WikiPage {
|
|
23
|
+
path: string;
|
|
24
|
+
title: string;
|
|
25
|
+
type?: string;
|
|
26
|
+
tags: string[];
|
|
27
|
+
sources: string[];
|
|
28
|
+
content: string;
|
|
29
|
+
frontmatter: Record<string, unknown>;
|
|
30
|
+
links: string[];
|
|
31
|
+
created?: string;
|
|
32
|
+
updated?: string;
|
|
33
|
+
derivedFrom?: string[];
|
|
34
|
+
}
|
|
35
|
+
export interface RawDocument {
|
|
36
|
+
path: string;
|
|
37
|
+
sourceUrl?: string;
|
|
38
|
+
downloadedAt: string;
|
|
39
|
+
sha256: string;
|
|
40
|
+
size: number;
|
|
41
|
+
mimeType?: string;
|
|
42
|
+
description?: string;
|
|
43
|
+
tags?: string[];
|
|
44
|
+
}
|
|
45
|
+
export interface LintIssue {
|
|
46
|
+
severity: "error" | "warning" | "info";
|
|
47
|
+
page: string;
|
|
48
|
+
message: string;
|
|
49
|
+
suggestion?: string;
|
|
50
|
+
autoFixable: boolean;
|
|
51
|
+
category?: "contradiction" | "orphan" | "broken-link" | "missing-source" | "stale" | "structure" | "integrity";
|
|
52
|
+
}
|
|
53
|
+
export interface LintReport {
|
|
54
|
+
pagesChecked: number;
|
|
55
|
+
rawChecked: number;
|
|
56
|
+
issues: LintIssue[];
|
|
57
|
+
contradictions: Contradiction[];
|
|
58
|
+
}
|
|
59
|
+
export interface Contradiction {
|
|
60
|
+
claim: string;
|
|
61
|
+
pageA: string;
|
|
62
|
+
excerptA: string;
|
|
63
|
+
pageB: string;
|
|
64
|
+
excerptB: string;
|
|
65
|
+
severity: "error" | "warning";
|
|
66
|
+
}
|
|
67
|
+
export interface TimelineEntry {
|
|
68
|
+
time: string;
|
|
69
|
+
operation: string;
|
|
70
|
+
page?: string;
|
|
71
|
+
summary: string;
|
|
72
|
+
}
|
|
73
|
+
export interface WikiConfig {
|
|
74
|
+
/** Where the config file was loaded from (or --wiki-path). */
|
|
75
|
+
configRoot: string;
|
|
76
|
+
/** The workspace directory — all data lives here. */
|
|
77
|
+
workspace: string;
|
|
78
|
+
wikiDir: string;
|
|
79
|
+
rawDir: string;
|
|
80
|
+
schemasDir: string;
|
|
81
|
+
lint: {
|
|
82
|
+
checkOrphans: boolean;
|
|
83
|
+
checkStaleDays: number;
|
|
84
|
+
checkMissingSources: boolean;
|
|
85
|
+
checkContradictions: boolean;
|
|
86
|
+
checkIntegrity: boolean;
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
export declare class Wiki {
|
|
90
|
+
readonly config: WikiConfig;
|
|
91
|
+
/**
|
|
92
|
+
* @param root — path to config root (where .agent-wiki.yaml lives)
|
|
93
|
+
* @param workspace — override workspace directory (all data: wiki/, raw/, schemas/).
|
|
94
|
+
* If not set, falls back to: AGENT_WIKI_WORKSPACE env → config file → root.
|
|
95
|
+
*/
|
|
96
|
+
constructor(root?: string, workspace?: string);
|
|
97
|
+
/**
|
|
98
|
+
* Initialize a new knowledge base.
|
|
99
|
+
* @param path — config root (where .agent-wiki.yaml is created)
|
|
100
|
+
* @param workspace — optional separate workspace directory for all data.
|
|
101
|
+
* If set, wiki/, raw/, schemas/ go there instead of path.
|
|
102
|
+
*/
|
|
103
|
+
static init(path: string, workspace?: string): Wiki;
|
|
104
|
+
/**
|
|
105
|
+
* Load config from .agent-wiki.yaml.
|
|
106
|
+
*
|
|
107
|
+
* Workspace resolution priority:
|
|
108
|
+
* 1. Explicit `workspaceOverride` parameter (from CLI --workspace)
|
|
109
|
+
* 2. `AGENT_WIKI_WORKSPACE` environment variable
|
|
110
|
+
* 3. `workspace` field in .agent-wiki.yaml (absolute, or relative to config file)
|
|
111
|
+
* 4. Fall back to config root itself
|
|
112
|
+
*
|
|
113
|
+
* All data dirs (wiki/, raw/, schemas/) resolve relative to workspace.
|
|
114
|
+
*/
|
|
115
|
+
static loadConfig(root: string, workspaceOverride?: string): WikiConfig;
|
|
116
|
+
/** Register a raw document. Copies file to raw/ with metadata sidecar.
|
|
117
|
+
* If content is provided as string, writes it directly.
|
|
118
|
+
* If sourcePath is an existing file, copies it.
|
|
119
|
+
* Raw files are IMMUTABLE — re-adding the same path is an error. */
|
|
120
|
+
rawAdd(filename: string, opts: {
|
|
121
|
+
content?: string;
|
|
122
|
+
sourcePath?: string;
|
|
123
|
+
sourceUrl?: string;
|
|
124
|
+
description?: string;
|
|
125
|
+
tags?: string[];
|
|
126
|
+
mimeType?: string;
|
|
127
|
+
}): RawDocument;
|
|
128
|
+
/** List all raw documents with metadata. */
|
|
129
|
+
rawList(): RawDocument[];
|
|
130
|
+
/** Read a raw document's content. */
|
|
131
|
+
rawRead(filename: string): {
|
|
132
|
+
content: string;
|
|
133
|
+
meta: RawDocument | null;
|
|
134
|
+
} | null;
|
|
135
|
+
/** Verify integrity of all raw files against their stored hashes. */
|
|
136
|
+
rawVerify(): Array<{
|
|
137
|
+
path: string;
|
|
138
|
+
status: "ok" | "corrupted" | "missing-meta";
|
|
139
|
+
}>;
|
|
140
|
+
/**
|
|
141
|
+
* Fetch a file from a URL and save it to raw/.
|
|
142
|
+
* Supports arXiv smart resolution: arxiv.org/abs/XXXX → arxiv.org/pdf/XXXX.pdf
|
|
143
|
+
* Returns the RawDocument metadata.
|
|
144
|
+
*/
|
|
145
|
+
rawFetch(url: string, opts?: {
|
|
146
|
+
filename?: string;
|
|
147
|
+
description?: string;
|
|
148
|
+
tags?: string[];
|
|
149
|
+
}): Promise<RawDocument>;
|
|
150
|
+
/** Read a wiki page. Returns null if not found. */
|
|
151
|
+
read(pagePath: string): WikiPage | null;
|
|
152
|
+
/** Write (create or update) a wiki page. Content must include frontmatter.
|
|
153
|
+
* Automatically injects/updates created and updated timestamps. */
|
|
154
|
+
write(pagePath: string, content: string, source?: string): void;
|
|
155
|
+
/** Delete a wiki page. Returns true if it existed. */
|
|
156
|
+
delete(pagePath: string): boolean;
|
|
157
|
+
/** List all wiki pages, optionally filtered by type or tag. */
|
|
158
|
+
list(filterType?: string, filterTag?: string): string[];
|
|
159
|
+
/** Keyword search across all wiki pages. Returns paths sorted by relevance. */
|
|
160
|
+
search(query: string, limit?: number): Array<{
|
|
161
|
+
path: string;
|
|
162
|
+
score: number;
|
|
163
|
+
snippet: string;
|
|
164
|
+
}>;
|
|
165
|
+
/** Run comprehensive health checks. Pure rules, no LLM.
|
|
166
|
+
* Detects: contradictions, orphans, broken links, missing sources,
|
|
167
|
+
* stale content, structural issues, integrity problems. */
|
|
168
|
+
lint(): LintReport;
|
|
169
|
+
/** Detect contradictions between pages.
|
|
170
|
+
* Looks for numeric claims, date claims, and factual statements
|
|
171
|
+
* that conflict across pages about the same entity/topic. */
|
|
172
|
+
private detectContradictions;
|
|
173
|
+
/** Get context for synthesis: reads multiple pages and returns
|
|
174
|
+
* their content for the agent to distill into a new page. */
|
|
175
|
+
synthesizeContext(pagePaths: string[]): {
|
|
176
|
+
pages: Array<{
|
|
177
|
+
path: string;
|
|
178
|
+
title: string;
|
|
179
|
+
content: string;
|
|
180
|
+
}>;
|
|
181
|
+
suggestions: string[];
|
|
182
|
+
};
|
|
183
|
+
/** Auto-classify content into entity type and suggested tags.
|
|
184
|
+
* Pure heuristic — zero LLM dependency. Analyzes title, body,
|
|
185
|
+
* and structure to determine the best type and relevant tags.
|
|
186
|
+
* If frontmatter already has a type, respects it. */
|
|
187
|
+
classify(content: string): {
|
|
188
|
+
type: string;
|
|
189
|
+
tags: string[];
|
|
190
|
+
confidence: number;
|
|
191
|
+
};
|
|
192
|
+
/** Auto-classify and inject type/tags into content if missing.
|
|
193
|
+
* Returns the enriched content string. */
|
|
194
|
+
autoClassifyContent(content: string): string;
|
|
195
|
+
/** Extract relevant tags from text using keyword matching. */
|
|
196
|
+
private extractTags;
|
|
197
|
+
/** List available entity type schemas. */
|
|
198
|
+
schemas(): Array<{
|
|
199
|
+
name: string;
|
|
200
|
+
description: string;
|
|
201
|
+
template: string;
|
|
202
|
+
}>;
|
|
203
|
+
/** Get operation log entries. */
|
|
204
|
+
getLog(limit?: number): Array<{
|
|
205
|
+
time: string;
|
|
206
|
+
operation: string;
|
|
207
|
+
page: string;
|
|
208
|
+
summary: string;
|
|
209
|
+
}>;
|
|
210
|
+
/** Rebuild index.md from all pages. Groups by type with page counts. */
|
|
211
|
+
rebuildIndex(): void;
|
|
212
|
+
/** Rebuild timeline.md — chronological view of all knowledge. */
|
|
213
|
+
rebuildTimeline(): void;
|
|
214
|
+
private listAllPages;
|
|
215
|
+
private parsePage;
|
|
216
|
+
private log;
|
|
217
|
+
}
|
|
218
|
+
//# sourceMappingURL=wiki.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wiki.d.ts","sourceRoot":"","sources":["../src/wiki.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAYH,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,OAAO,GAAG,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