@wiki0/core 0.0.3 → 0.0.5
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 +38 -23
- package/dist/documents.d.ts +12 -0
- package/dist/documents.js +143 -0
- package/dist/documents.js.map +1 -0
- package/dist/events.d.ts +9 -0
- package/dist/events.js +56 -0
- package/dist/events.js.map +1 -0
- package/dist/facts.d.ts +4 -0
- package/dist/facts.js +108 -16
- package/dist/facts.js.map +1 -1
- package/dist/graph.js +14 -2
- package/dist/graph.js.map +1 -1
- package/dist/index.d.ts +8 -4
- package/dist/index.js +8 -4
- package/dist/index.js.map +1 -1
- package/dist/indexer.d.ts +11 -1
- package/dist/indexer.js +132 -21
- package/dist/indexer.js.map +1 -1
- package/dist/ingest.d.ts +2 -0
- package/dist/ingest.js +253 -0
- package/dist/ingest.js.map +1 -0
- package/dist/lint.js +1 -1
- package/dist/lint.js.map +1 -1
- package/dist/pages.js +25 -3
- package/dist/pages.js.map +1 -1
- package/dist/schema.sql +32 -0
- package/dist/search.d.ts +4 -2
- package/dist/search.js +162 -6
- package/dist/search.js.map +1 -1
- package/dist/sync.d.ts +2 -0
- package/dist/sync.js +340 -0
- package/dist/sync.js.map +1 -0
- package/dist/topics.d.ts +2 -0
- package/dist/topics.js +55 -0
- package/dist/topics.js.map +1 -0
- package/dist/types.d.ts +83 -29
- package/dist/workflow.d.ts +2 -3
- package/dist/workflow.js +5 -92
- package/dist/workflow.js.map +1 -1
- package/package.json +3 -1
package/dist/topics.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { open_wiki_database } from './database.js';
|
|
2
|
+
export function list_topic_threads(root = '.', limit = 50) {
|
|
3
|
+
const db = open_wiki_database(root);
|
|
4
|
+
const rows = db
|
|
5
|
+
.prepare(`SELECT path, title, heading, page_tags FROM page_chunks
|
|
6
|
+
ORDER BY path, sequence`)
|
|
7
|
+
.all();
|
|
8
|
+
db.close();
|
|
9
|
+
const topics = new Map();
|
|
10
|
+
for (const row of rows) {
|
|
11
|
+
const path = String(row.path);
|
|
12
|
+
const heading = row.heading === null ? null : String(row.heading);
|
|
13
|
+
const tags = parse_tags(row.page_tags);
|
|
14
|
+
for (const topic of [...tags, ...(heading ? [heading] : [])]) {
|
|
15
|
+
const normalized_topic = topic.trim();
|
|
16
|
+
if (!normalized_topic)
|
|
17
|
+
continue;
|
|
18
|
+
const bucket = topics.get(normalized_topic) ?? {
|
|
19
|
+
paths: new Set(),
|
|
20
|
+
references: 0,
|
|
21
|
+
headings: new Set(),
|
|
22
|
+
};
|
|
23
|
+
bucket.paths.add(path);
|
|
24
|
+
bucket.references += 1;
|
|
25
|
+
if (heading)
|
|
26
|
+
bucket.headings.add(heading);
|
|
27
|
+
topics.set(normalized_topic, bucket);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return [...topics]
|
|
31
|
+
.map(([topic, bucket]) => ({
|
|
32
|
+
topic,
|
|
33
|
+
reference_count: bucket.references,
|
|
34
|
+
page_count: bucket.paths.size,
|
|
35
|
+
paths: [...bucket.paths].sort(),
|
|
36
|
+
summary: [...bucket.headings].slice(0, 5).join('; '),
|
|
37
|
+
}))
|
|
38
|
+
.sort((left, right) => right.reference_count - left.reference_count ||
|
|
39
|
+
left.topic.localeCompare(right.topic))
|
|
40
|
+
.slice(0, limit);
|
|
41
|
+
}
|
|
42
|
+
function parse_tags(value) {
|
|
43
|
+
if (value === null)
|
|
44
|
+
return [];
|
|
45
|
+
try {
|
|
46
|
+
const parsed = JSON.parse(String(value));
|
|
47
|
+
return Array.isArray(parsed)
|
|
48
|
+
? parsed.filter((tag) => typeof tag === 'string')
|
|
49
|
+
: [];
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return [];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=topics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"topics.js","sourceRoot":"","sources":["../src/topics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AO,EAAE,CAAC;IACX,CAAC;AACF,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export type WikiConfig = {
|
|
2
2
|
root: string;
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
wiki_dir?: string;
|
|
4
|
+
db_path?: string;
|
|
5
5
|
};
|
|
6
6
|
export type WikiLink = {
|
|
7
7
|
raw: string;
|
|
@@ -35,21 +35,24 @@ export type PageFrontmatterOptions = {
|
|
|
35
35
|
};
|
|
36
36
|
export type IndexResult = {
|
|
37
37
|
root: string;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
db_path: string;
|
|
39
|
+
page_count: number;
|
|
40
|
+
link_count: number;
|
|
41
|
+
indexed_at: string;
|
|
42
|
+
schema_version: number;
|
|
43
|
+
package_version: string;
|
|
43
44
|
};
|
|
44
45
|
export type IndexStatus = {
|
|
45
46
|
root: string;
|
|
46
|
-
|
|
47
|
+
db_path: string;
|
|
47
48
|
exists: boolean;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
indexed_at: string | null;
|
|
50
|
+
schema_version: number | null;
|
|
51
|
+
current_schema_version: number;
|
|
52
|
+
package_version: string | null;
|
|
53
|
+
current_package_version: string;
|
|
54
|
+
page_count: number;
|
|
55
|
+
indexed_page_count: number;
|
|
53
56
|
stale: boolean;
|
|
54
57
|
reasons: string[];
|
|
55
58
|
};
|
|
@@ -59,15 +62,27 @@ export type SearchResult = {
|
|
|
59
62
|
snippet: string;
|
|
60
63
|
rank: number;
|
|
61
64
|
};
|
|
65
|
+
export type ChunkSearchResult = SearchResult & {
|
|
66
|
+
chunk_id: number;
|
|
67
|
+
heading: string | null;
|
|
68
|
+
body: string;
|
|
69
|
+
start_line: number;
|
|
70
|
+
end_line: number;
|
|
71
|
+
page_priority?: number;
|
|
72
|
+
page_status?: string | null;
|
|
73
|
+
page_tags?: string[];
|
|
74
|
+
};
|
|
75
|
+
export type ShowChunkResult = ChunkSearchResult;
|
|
62
76
|
export type ContextResult = {
|
|
63
77
|
query: string;
|
|
64
|
-
results:
|
|
78
|
+
results: ChunkSearchResult[];
|
|
79
|
+
warnings: string[];
|
|
65
80
|
markdown: string;
|
|
66
81
|
};
|
|
67
82
|
export type BacklinkResult = {
|
|
68
83
|
path: string;
|
|
69
84
|
title: string;
|
|
70
|
-
|
|
85
|
+
raw_text: string;
|
|
71
86
|
alias: string | null;
|
|
72
87
|
embed: boolean;
|
|
73
88
|
};
|
|
@@ -79,7 +94,7 @@ export type GraphEdge = {
|
|
|
79
94
|
from: string;
|
|
80
95
|
to: string;
|
|
81
96
|
target: string;
|
|
82
|
-
|
|
97
|
+
raw_text: string;
|
|
83
98
|
alias: string | null;
|
|
84
99
|
embed: boolean;
|
|
85
100
|
status: 'resolved' | 'unresolved';
|
|
@@ -92,12 +107,17 @@ export type GraphResult = {
|
|
|
92
107
|
export type FactConfidence = 'unknown' | 'low' | 'medium' | 'high' | 'verified';
|
|
93
108
|
export type Fact = {
|
|
94
109
|
id: number;
|
|
95
|
-
|
|
110
|
+
page_path: string | null;
|
|
96
111
|
category: string;
|
|
97
112
|
summary: string;
|
|
98
113
|
body: string | null;
|
|
99
114
|
confidence: FactConfidence;
|
|
100
|
-
|
|
115
|
+
source_path: string | null;
|
|
116
|
+
source_heading: string | null;
|
|
117
|
+
source_start_line: number | null;
|
|
118
|
+
source_end_line: number | null;
|
|
119
|
+
source_quote: string | null;
|
|
120
|
+
created_at: string;
|
|
101
121
|
};
|
|
102
122
|
export type FactWriteOptions = {
|
|
103
123
|
root?: string;
|
|
@@ -106,6 +126,8 @@ export type FactWriteOptions = {
|
|
|
106
126
|
summary: string;
|
|
107
127
|
body?: string;
|
|
108
128
|
confidence?: FactConfidence;
|
|
129
|
+
source?: string;
|
|
130
|
+
source_quote?: string;
|
|
109
131
|
};
|
|
110
132
|
export type ReviewResult = {
|
|
111
133
|
path: string;
|
|
@@ -124,17 +146,14 @@ export type LintIssue = {
|
|
|
124
146
|
export type LintResult = {
|
|
125
147
|
root: string;
|
|
126
148
|
ok: boolean;
|
|
127
|
-
|
|
149
|
+
issue_count: number;
|
|
128
150
|
issues: LintIssue[];
|
|
129
151
|
};
|
|
130
152
|
export type WikiSourceType = 'general' | 'codebase' | 'docs' | 'research' | 'notes';
|
|
131
153
|
export type WikiPlanOptions = {
|
|
132
|
-
|
|
154
|
+
source_type?: WikiSourceType;
|
|
133
155
|
scope?: string;
|
|
134
|
-
|
|
135
|
-
export type WikiBootstrapOptions = WikiPlanOptions & {
|
|
136
|
-
root?: string;
|
|
137
|
-
overwrite?: boolean;
|
|
156
|
+
sources?: string[];
|
|
138
157
|
};
|
|
139
158
|
export type WikiPlanPage = {
|
|
140
159
|
title: string;
|
|
@@ -143,16 +162,51 @@ export type WikiPlanPage = {
|
|
|
143
162
|
tags: string[];
|
|
144
163
|
};
|
|
145
164
|
export type WikiPlanResult = {
|
|
146
|
-
|
|
165
|
+
source_type: WikiSourceType;
|
|
147
166
|
scope: string;
|
|
148
167
|
workflow: string;
|
|
149
168
|
pages: WikiPlanPage[];
|
|
150
|
-
|
|
169
|
+
next_steps: string[];
|
|
151
170
|
};
|
|
152
|
-
export type
|
|
171
|
+
export type WikiDocumentSyncOptions = {
|
|
172
|
+
root?: string;
|
|
173
|
+
sources: string[];
|
|
174
|
+
overwrite?: boolean;
|
|
175
|
+
index?: boolean;
|
|
176
|
+
include?: string[];
|
|
177
|
+
ignore?: string[];
|
|
178
|
+
derive_facts?: boolean;
|
|
179
|
+
propose_pages?: boolean;
|
|
180
|
+
};
|
|
181
|
+
export type WikiDocumentSync = {
|
|
182
|
+
source: string;
|
|
183
|
+
page: string;
|
|
184
|
+
kind: 'markdown' | 'text' | 'pdf' | 'docx' | 'unsupported';
|
|
185
|
+
status: 'created' | 'updated' | 'unchanged' | 'changed' | 'warning';
|
|
186
|
+
warnings: string[];
|
|
187
|
+
};
|
|
188
|
+
export type WikiDocumentSyncResult = {
|
|
153
189
|
root: string;
|
|
154
|
-
|
|
190
|
+
sources: string[];
|
|
155
191
|
created: string[];
|
|
156
192
|
skipped: string[];
|
|
157
|
-
|
|
193
|
+
proposed_pages: string[];
|
|
194
|
+
derived_facts: Fact[];
|
|
195
|
+
synced_sources: WikiDocumentSync[];
|
|
196
|
+
indexed: IndexResult | null;
|
|
197
|
+
};
|
|
198
|
+
export type WikiEvent = {
|
|
199
|
+
id: number;
|
|
200
|
+
operation: string;
|
|
201
|
+
summary: string;
|
|
202
|
+
target: string | null;
|
|
203
|
+
details: string | null;
|
|
204
|
+
created_at: string;
|
|
205
|
+
};
|
|
206
|
+
export type TopicThreadResult = {
|
|
207
|
+
topic: string;
|
|
208
|
+
reference_count: number;
|
|
209
|
+
page_count: number;
|
|
210
|
+
paths: string[];
|
|
211
|
+
summary: string;
|
|
158
212
|
};
|
package/dist/workflow.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const wiki_building_workflow_markdown = "# Wiki building workflow\n\nUse this workflow when a user asks to
|
|
1
|
+
import type { WikiPlanOptions, WikiPlanResult } from './types.js';
|
|
2
|
+
export declare const wiki_building_workflow_markdown = "# Wiki building workflow\n\nUse this workflow when a user asks to plan, sync, generate, or improve a wiki from source material. A codebase is one source type; the same workflow applies to docs, notes, research, transcripts, or any mixed knowledge corpus.\n\n## Steps\n\n1. Clarify the source scope only if it is ambiguous.\n2. Inspect source material before writing pages.\n3. Propose a small page plan with names, purposes, and review flags.\n4. Create an index page that explains the corpus and links to major sections.\n5. Create focused pages for concepts, workflows, decisions, sources, and open questions.\n6. Use [[WikiLinks]] to connect related pages instead of duplicating context.\n7. Use frontmatter for title, aliases, tags, status, and review markers.\n8. Add structured facts for durable claims, decisions, or constraints.\n9. Run sync after source discovery, then index_wiki after page creation.\n10. Run lint_wiki and fix unresolved links or duplicate names.\n11. Run review_wiki and surface pages that still need human review.\n\n## Quality bar\n\n- Prefer many focused pages over one giant dump.\n- Mark uncertain pages with needs-review instead of inventing confidence.\n- Preserve citations or source paths when facts come from external material.\n- Make the wiki navigable for humans and retrievable for agents.\n";
|
|
3
3
|
export declare function plan_wiki(options?: WikiPlanOptions): WikiPlanResult;
|
|
4
|
-
export declare function bootstrap_wiki(options?: WikiBootstrapOptions): WikiBootstrapResult;
|
package/dist/workflow.js
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
import { existsSync, readdirSync } from 'node:fs';
|
|
2
|
-
import { join } from 'node:path';
|
|
3
|
-
import { index_wiki } from './indexer.js';
|
|
4
|
-
import { serialize_frontmatter } from './markdown.js';
|
|
5
|
-
import { create_page } from './pages.js';
|
|
6
|
-
import { page_file_path, resolve_wiki_root } from './paths.js';
|
|
7
1
|
export const wiki_building_workflow_markdown = `# Wiki building workflow
|
|
8
2
|
|
|
9
|
-
Use this workflow when a user asks to
|
|
3
|
+
Use this workflow when a user asks to plan, sync, generate, or improve a wiki from source material. A codebase is one source type; the same workflow applies to docs, notes, research, transcripts, or any mixed knowledge corpus.
|
|
10
4
|
|
|
11
5
|
## Steps
|
|
12
6
|
|
|
@@ -18,7 +12,7 @@ Use this workflow when a user asks to build, bootstrap, generate, or improve a w
|
|
|
18
12
|
6. Use [[WikiLinks]] to connect related pages instead of duplicating context.
|
|
19
13
|
7. Use frontmatter for title, aliases, tags, status, and review markers.
|
|
20
14
|
8. Add structured facts for durable claims, decisions, or constraints.
|
|
21
|
-
9. Run index_wiki after page creation.
|
|
15
|
+
9. Run sync after source discovery, then index_wiki after page creation.
|
|
22
16
|
10. Run lint_wiki and fix unresolved links or duplicate names.
|
|
23
17
|
11. Run review_wiki and surface pages that still need human review.
|
|
24
18
|
|
|
@@ -103,15 +97,15 @@ const source_pages = {
|
|
|
103
97
|
],
|
|
104
98
|
};
|
|
105
99
|
export function plan_wiki(options = {}) {
|
|
106
|
-
const source_type = options.
|
|
100
|
+
const source_type = options.source_type ?? 'general';
|
|
107
101
|
const scope = options.scope ?? 'user-provided source material';
|
|
108
102
|
const pages = [...common_pages, ...source_pages[source_type]];
|
|
109
103
|
return {
|
|
110
|
-
|
|
104
|
+
source_type: source_type,
|
|
111
105
|
scope,
|
|
112
106
|
workflow: wiki_building_workflow_markdown,
|
|
113
107
|
pages,
|
|
114
|
-
|
|
108
|
+
next_steps: [
|
|
115
109
|
'Inspect the source material and adjust this plan before writing pages.',
|
|
116
110
|
'Create or update the index page first so later pages have a navigation target.',
|
|
117
111
|
'Create focused pages with frontmatter and wikilinks.',
|
|
@@ -119,85 +113,4 @@ export function plan_wiki(options = {}) {
|
|
|
119
113
|
],
|
|
120
114
|
};
|
|
121
115
|
}
|
|
122
|
-
export function bootstrap_wiki(options = {}) {
|
|
123
|
-
const root = resolve_wiki_root(options.root);
|
|
124
|
-
const plan = plan_wiki(options);
|
|
125
|
-
const created = [];
|
|
126
|
-
const skipped = [];
|
|
127
|
-
const detected_sources = detect_source_inventory(root, plan.sourceType);
|
|
128
|
-
for (const page of plan.pages) {
|
|
129
|
-
if (!options.overwrite &&
|
|
130
|
-
existsSync(page_file_path(page.path, root))) {
|
|
131
|
-
skipped.push(page.path);
|
|
132
|
-
continue;
|
|
133
|
-
}
|
|
134
|
-
create_page(page.path, page_template(page, plan, detected_sources), {
|
|
135
|
-
root,
|
|
136
|
-
overwrite: options.overwrite,
|
|
137
|
-
});
|
|
138
|
-
created.push(page.path);
|
|
139
|
-
}
|
|
140
|
-
return {
|
|
141
|
-
root,
|
|
142
|
-
plan,
|
|
143
|
-
created,
|
|
144
|
-
skipped,
|
|
145
|
-
indexed: index_wiki(root),
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
function page_template(page, plan, detected_sources) {
|
|
149
|
-
if (page.path === 'index')
|
|
150
|
-
return index_template(page, plan);
|
|
151
|
-
const frontmatter = serialize_frontmatter({
|
|
152
|
-
title: page.title,
|
|
153
|
-
tags: page.tags,
|
|
154
|
-
});
|
|
155
|
-
if (page.path === 'sources/index') {
|
|
156
|
-
return `${frontmatter}# ${page.title}\n\n${page.purpose}\n\n## Source scope\n\n${plan.scope}\n\n## Detected sources\n\n${format_source_inventory(detected_sources)}\n\n## Ingestion notes\n\n- Record source paths, URLs, owners, and freshness before extracting durable facts.\n`;
|
|
157
|
-
}
|
|
158
|
-
if (page.path === 'questions/open-questions') {
|
|
159
|
-
return `${frontmatter}# ${page.title}\n\n${page.purpose}\n\n## Source scope\n\n${plan.scope}\n\n## Questions\n\n- What source material has not been inspected yet?\n- Which claims need citations or owner confirmation?\n- Which pages should move from needs-review to verified?\n`;
|
|
160
|
-
}
|
|
161
|
-
return `${frontmatter}# ${page.title}\n\n${page.purpose}\n\n## Source scope\n\n${plan.scope}\n\n## Evidence\n\n- Add source-backed details here with citations or file paths.\n\n## Candidate facts\n\n- Add durable claims here before promoting them with add_fact.\n`;
|
|
162
|
-
}
|
|
163
|
-
function index_template(page, plan) {
|
|
164
|
-
const frontmatter = serialize_frontmatter({
|
|
165
|
-
title: page.title,
|
|
166
|
-
tags: page.tags,
|
|
167
|
-
});
|
|
168
|
-
const links = plan.pages
|
|
169
|
-
.filter((planned_page) => planned_page.path !== page.path)
|
|
170
|
-
.map((planned_page) => `- [[${planned_page.path}|${planned_page.title}]] — ${planned_page.purpose}`)
|
|
171
|
-
.join('\n');
|
|
172
|
-
return `${frontmatter}# ${page.title}\n\nWiki for ${plan.scope}.\n\n## Start here\n\n${links}\n\n## Workflow\n\nUse [[workflows/index|Workflows]] to capture repeatable processes, [[sources/index|Sources]] to track inspected material, and [[questions/open-questions|Open questions]] for uncertain claims.\n`;
|
|
173
|
-
}
|
|
174
|
-
function detect_source_inventory(root, source_type) {
|
|
175
|
-
const candidates = ['README.md', 'package.json', 'docs'];
|
|
176
|
-
if (source_type === 'codebase')
|
|
177
|
-
candidates.push('packages');
|
|
178
|
-
const sources = [];
|
|
179
|
-
for (const candidate of candidates) {
|
|
180
|
-
const candidate_path = join(root, candidate);
|
|
181
|
-
if (!existsSync(candidate_path))
|
|
182
|
-
continue;
|
|
183
|
-
if (candidate === 'packages') {
|
|
184
|
-
for (const entry of readdirSync(candidate_path, {
|
|
185
|
-
withFileTypes: true,
|
|
186
|
-
})) {
|
|
187
|
-
if (entry.isDirectory()) {
|
|
188
|
-
sources.push(`packages/${entry.name}/package.json`);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
continue;
|
|
192
|
-
}
|
|
193
|
-
sources.push(candidate);
|
|
194
|
-
}
|
|
195
|
-
return sources;
|
|
196
|
-
}
|
|
197
|
-
function format_source_inventory(sources) {
|
|
198
|
-
if (sources.length === 0) {
|
|
199
|
-
return '- No local sources detected automatically; add source paths or URLs here.';
|
|
200
|
-
}
|
|
201
|
-
return sources.map((source) => `- \`${source}\``).join('\n');
|
|
202
|
-
}
|
|
203
116
|
//# sourceMappingURL=workflow.js.map
|
package/dist/workflow.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow.js","sourceRoot":"","sources":["../src/workflow.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"workflow.js","sourceRoot":"","sources":["../src/workflow.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,MAAM,+BAA+B,GAAG;;;;;;;;;;;;;;;;;;;;;;;;CAwB9C,CAAC;AAEF,MAAM,YAAY,GAAmB;IACpC;QACC,KAAK,EAAE,OAAO;QACd,IAAI,EAAE,OAAO;QACb,OAAO,EACN,mEAAmE;QACpE,IAAI,EAAE,CAAC,OAAO,CAAC;KACf;IACD;QACC,KAAK,EAAE,SAAS;QAChB,IAAI,EAAE,eAAe;QACrB,OAAO,EAAE,sDAAsD;QAC/D,IAAI,EAAE,CAAC,SAAS,CAAC;KACjB;IACD;QACC,KAAK,EAAE,UAAU;QACjB,IAAI,EAAE,gBAAgB;QACtB,OAAO,EACN,2DAA2D;QAC5D,IAAI,EAAE,CAAC,UAAU,CAAC;KAClB;IACD;QACC,KAAK,EAAE,WAAW;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AI,+BAA+B,CAAC;IAC/D,MAAM,KAAK,GAAG,CAAC,GAAG,YAAY,EAAE,GAAG,YAAY,CAAC,WAAW,CAAC,CAAC,CAAC;IAE9D,OAAO;QACN,WAAW,EAAE,WAAW;QACxB,KAAK;QACL,QAAQ,EAAE,+BAA+B;QACzC,KAAK;QACL,UAAU,EAAE;YACX,wEAAwE;YACxE,gFAAgF;YAChF,sDAAsD;YACtD,gEAAgE;SAChE;KACD,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wiki0/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "Core wiki0 Markdown wiki indexing and retrieval primitives",
|
|
5
5
|
"homepage": "https://github.com/spences10/wiki0/tree/main/packages/core#readme",
|
|
6
6
|
"license": "MIT",
|
|
@@ -27,6 +27,8 @@
|
|
|
27
27
|
"access": "public"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
+
"mammoth": "^1.12.0",
|
|
31
|
+
"pdf-parse": "^2.4.5",
|
|
30
32
|
"yaml": "^2.9.0"
|
|
31
33
|
},
|
|
32
34
|
"devDependencies": {
|