pi-para 0.6.7 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ARCHITECTURE.md +4 -6
- package/CHANGELOG.md +19 -0
- package/CONFIGURATION.md +1 -16
- package/README.md +2 -13
- package/SETUP.md +1 -7
- package/STRUCTURE.md +7 -18
- package/dist/cli-legacy.d.ts +2 -1
- package/dist/cli-legacy.d.ts.map +1 -1
- package/dist/cli-legacy.js +13 -25
- package/dist/cli-legacy.js.map +1 -1
- package/dist/cli.d.ts +2 -24
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +29 -271
- package/dist/cli.js.map +1 -1
- package/dist/commands.d.ts.map +1 -1
- package/dist/commands.js +1 -28
- package/dist/commands.js.map +1 -1
- package/dist/config.d.ts +1 -5
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +0 -5
- package/dist/config.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -64
- package/dist/index.js.map +1 -1
- package/dist/link-utils.d.ts +1 -1
- package/dist/link-utils.js +1 -1
- package/dist/processor.d.ts +7 -0
- package/dist/processor.d.ts.map +1 -1
- package/dist/processor.js +29 -15
- package/dist/processor.js.map +1 -1
- package/dist/settings.d.ts +0 -3
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +0 -11
- package/dist/settings.js.map +1 -1
- package/dist/tools/edit-read.d.ts +18 -0
- package/dist/tools/edit-read.d.ts.map +1 -0
- package/dist/tools/edit-read.js +161 -0
- package/dist/tools/edit-read.js.map +1 -0
- package/dist/tools/ingest.d.ts +12 -0
- package/dist/tools/ingest.d.ts.map +1 -0
- package/dist/tools/ingest.js +48 -0
- package/dist/tools/ingest.js.map +1 -0
- package/dist/tools/lint.d.ts +10 -0
- package/dist/tools/lint.d.ts.map +1 -0
- package/dist/tools/lint.js +57 -0
- package/dist/tools/lint.js.map +1 -0
- package/dist/tools/migrate.d.ts +6 -0
- package/dist/tools/migrate.d.ts.map +1 -0
- package/dist/tools/migrate.js +36 -0
- package/dist/tools/migrate.js.map +1 -0
- package/dist/tools/move.d.ts +9 -0
- package/dist/tools/move.d.ts.map +1 -0
- package/dist/tools/move.js +61 -0
- package/dist/tools/move.js.map +1 -0
- package/dist/tools/query.d.ts +12 -0
- package/dist/tools/query.d.ts.map +1 -0
- package/dist/tools/query.js +47 -0
- package/dist/tools/query.js.map +1 -0
- package/dist/tools/schemas.d.ts +109 -0
- package/dist/tools/schemas.d.ts.map +1 -0
- package/dist/tools/schemas.js +80 -0
- package/dist/tools/schemas.js.map +1 -0
- package/dist/tools/shared.d.ts +14 -0
- package/dist/tools/shared.d.ts.map +1 -0
- package/dist/tools/shared.js +25 -0
- package/dist/tools/shared.js.map +1 -0
- package/dist/tools/summarize.d.ts +8 -0
- package/dist/tools/summarize.d.ts.map +1 -0
- package/dist/tools/summarize.js +82 -0
- package/dist/tools/summarize.js.map +1 -0
- package/dist/tools/write.d.ts +23 -0
- package/dist/tools/write.d.ts.map +1 -0
- package/dist/tools/write.js +215 -0
- package/dist/tools/write.js.map +1 -0
- package/dist/tools.d.ts +1 -8
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +13 -795
- package/dist/tools.js.map +1 -1
- package/dist/wiki.d.ts.map +1 -1
- package/dist/wiki.js +1 -0
- package/dist/wiki.js.map +1 -1
- package/package.json +2 -6
- package/src/cli-legacy.ts +14 -26
- package/src/cli.ts +29 -293
- package/src/commands.ts +0 -21
- package/src/config.ts +1 -6
- package/src/index.ts +5 -66
- package/src/link-utils.ts +1 -1
- package/src/processor.ts +28 -13
- package/src/settings.ts +0 -14
- package/src/tools/edit-read.ts +193 -0
- package/src/tools/ingest.ts +63 -0
- package/src/tools/lint.ts +74 -0
- package/src/tools/migrate.ts +44 -0
- package/src/tools/move.ts +79 -0
- package/src/tools/query.ts +63 -0
- package/src/tools/schemas.ts +157 -0
- package/src/tools/shared.ts +35 -0
- package/src/tools/summarize.ts +89 -0
- package/src/tools/write.ts +252 -0
- package/src/tools.ts +18 -1046
- package/src/wiki.ts +1 -0
- package/dist/daemon.d.ts +0 -49
- package/dist/daemon.d.ts.map +0 -1
- package/dist/daemon.js +0 -226
- package/dist/daemon.js.map +0 -1
- package/dist/link-discovery.d.ts +0 -40
- package/dist/link-discovery.d.ts.map +0 -1
- package/dist/link-discovery.js +0 -122
- package/dist/link-discovery.js.map +0 -1
- package/dist/maintainer.d.ts +0 -24
- package/dist/maintainer.d.ts.map +0 -1
- package/dist/maintainer.js +0 -358
- package/dist/maintainer.js.map +0 -1
- package/dist/watcher.d.ts +0 -25
- package/dist/watcher.d.ts.map +0 -1
- package/dist/watcher.js +0 -84
- package/dist/watcher.js.map +0 -1
- package/dist/webui/client/dist/index.html +0 -1885
- package/dist/webui/server.d.ts +0 -31
- package/dist/webui/server.d.ts.map +0 -1
- package/dist/webui/server.js +0 -566
- package/dist/webui/server.js.map +0 -1
- package/scripts/build-assets.mjs +0 -17
- package/src/daemon.ts +0 -288
- package/src/link-discovery.ts +0 -170
- package/src/maintainer.ts +0 -404
- package/src/python/__pycache__/minimax_lm.cpython-312.pyc +0 -0
- package/src/python/minimax_lm.py +0 -198
- package/src/python/rlm_capture.py +0 -215
- package/src/watcher.ts +0 -101
- package/src/webui/client/dist/index.html +0 -1885
- package/src/webui/server.ts +0 -765
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { formatFreshness } from "../query.js";
|
|
2
|
+
import { autoLinkSlugs, syncFrontmatterLinks } from "../link-utils.js";
|
|
3
|
+
import { normalizeTags, normalizeScopes } from "../tag-registry.js";
|
|
4
|
+
import { redactSecrets } from "../redact.js";
|
|
5
|
+
import { appendLog, gitCommit, listPages, readIndex, readPage, writePage } from "../wiki.js";
|
|
6
|
+
import { parsePagePath, scheduleWikiMaintenance } from "./shared.js";
|
|
7
|
+
// -- Factory: wiki_read execute ----------------------------------------------
|
|
8
|
+
export function createEditExecute(wikiDir, store, markDirty) {
|
|
9
|
+
return async (params) => {
|
|
10
|
+
const parsed = parsePagePath(params.path);
|
|
11
|
+
if (!parsed) {
|
|
12
|
+
return {
|
|
13
|
+
content: [{ type: "text", text: `Invalid page path: ${params.path}` }],
|
|
14
|
+
details: { pagesWritten: [], pagesSkipped: [params.path], indexUpdated: false, logAppended: false },
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
const existing = await readPage(wikiDir, parsed.category, parsed.slug);
|
|
18
|
+
const pagePath = `${parsed.category}/${parsed.slug}`;
|
|
19
|
+
if (!existing) {
|
|
20
|
+
return {
|
|
21
|
+
content: [{ type: "text", text: `Page not found: ${pagePath}` }],
|
|
22
|
+
details: { pagesWritten: [], pagesSkipped: [pagePath], indexUpdated: false, logAppended: false },
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
if (params.edits.length === 0) {
|
|
26
|
+
return {
|
|
27
|
+
content: [{ type: "text", text: "No edits supplied." }],
|
|
28
|
+
details: { pagesWritten: [], pagesSkipped: [pagePath], indexUpdated: false, logAppended: false },
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
// Atomic validation: all oldText strings must exist exactly once before writing.
|
|
32
|
+
const errors = [];
|
|
33
|
+
for (const edit of params.edits) {
|
|
34
|
+
const first = existing.body.indexOf(edit.oldText);
|
|
35
|
+
const last = existing.body.lastIndexOf(edit.oldText);
|
|
36
|
+
if (first === -1) {
|
|
37
|
+
errors.push(`oldText not found: "${edit.oldText.slice(0, 60)}..."`);
|
|
38
|
+
}
|
|
39
|
+
else if (first !== last) {
|
|
40
|
+
errors.push(`oldText is not unique: "${edit.oldText.slice(0, 60)}..."`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (errors.length > 0) {
|
|
44
|
+
return {
|
|
45
|
+
content: [{ type: "text", text: `No changes written.\n${errors.join("\n")}` }],
|
|
46
|
+
details: { pagesWritten: [], pagesSkipped: [pagePath], indexUpdated: false, logAppended: false },
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
let editedBody = existing.body;
|
|
50
|
+
for (const edit of params.edits) {
|
|
51
|
+
editedBody = editedBody.replace(edit.oldText, edit.newText);
|
|
52
|
+
}
|
|
53
|
+
// Surgical edit path: do not scan/autolink/rebuild/reindex the whole wiki.
|
|
54
|
+
// wiki_edit is often called mid-task and must stay fast; broader maintenance
|
|
55
|
+
// can run via wiki_lint/rebuildIndex or on startup.
|
|
56
|
+
const linkedBody = redactSecrets(editedBody).text;
|
|
57
|
+
const now = new Date().toISOString();
|
|
58
|
+
const rawScope = params.scope ?? existing.frontmatter.scope;
|
|
59
|
+
const newScope = normalizeScopes(rawScope);
|
|
60
|
+
const rawTags = params.tags ?? existing.frontmatter.tags;
|
|
61
|
+
const updatedPage = {
|
|
62
|
+
category: parsed.category,
|
|
63
|
+
slug: parsed.slug,
|
|
64
|
+
frontmatter: {
|
|
65
|
+
...existing.frontmatter,
|
|
66
|
+
title: params.title ?? existing.frontmatter.title,
|
|
67
|
+
scope: newScope,
|
|
68
|
+
tags: normalizeTags(rawTags, newScope),
|
|
69
|
+
updated: now,
|
|
70
|
+
links: syncFrontmatterLinks(linkedBody),
|
|
71
|
+
},
|
|
72
|
+
body: linkedBody,
|
|
73
|
+
};
|
|
74
|
+
await writePage(wikiDir, updatedPage);
|
|
75
|
+
if (params.logSummary) {
|
|
76
|
+
await appendLog(wikiDir, {
|
|
77
|
+
date: now.split("T")[0],
|
|
78
|
+
operation: "edit",
|
|
79
|
+
summary: params.logSummary,
|
|
80
|
+
pages: [pagePath],
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
markDirty();
|
|
84
|
+
await gitCommit(wikiDir, params.logSummary ?? `wiki_edit: ${pagePath}`);
|
|
85
|
+
scheduleWikiMaintenance(wikiDir, store, markDirty);
|
|
86
|
+
return {
|
|
87
|
+
content: [{ type: "text", text: `Edited ${pagePath}. Scheduled background index/search refresh.` }],
|
|
88
|
+
details: {
|
|
89
|
+
pagesWritten: [pagePath],
|
|
90
|
+
pagesSkipped: [],
|
|
91
|
+
indexUpdated: false,
|
|
92
|
+
logAppended: !!params.logSummary,
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
export function createReadExecute(wikiDir) {
|
|
98
|
+
return async (params) => {
|
|
99
|
+
const now = Date.now();
|
|
100
|
+
const normalizedPath = params.path.trim().toLowerCase().replace(/^\/+/, "");
|
|
101
|
+
if (normalizedPath === "index" || normalizedPath === "index.md" || normalizedPath === "wiki-index") {
|
|
102
|
+
const index = await readIndex(wikiDir);
|
|
103
|
+
return {
|
|
104
|
+
content: [{ type: "text", text: index }],
|
|
105
|
+
details: { found: true, path: "index.md" },
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
// Try parsing as category/slug path
|
|
109
|
+
const parsed = parsePagePath(params.path);
|
|
110
|
+
if (parsed) {
|
|
111
|
+
const page = await readPage(wikiDir, parsed.category, parsed.slug);
|
|
112
|
+
if (page) {
|
|
113
|
+
const fm = page.frontmatter;
|
|
114
|
+
const freshness = formatFreshness(fm.updated, now);
|
|
115
|
+
const header = [
|
|
116
|
+
`# ${fm.title}`,
|
|
117
|
+
`PARA: ${fm.para} | Scope: ${fm.scope.join(", ")} | Tags: ${fm.tags.join(", ")}`,
|
|
118
|
+
`Created: ${fm.created} | Updated: ${fm.updated} | ${freshness}`,
|
|
119
|
+
fm.sources.length > 0 ? `Sources: ${fm.sources.join(", ")}` : "",
|
|
120
|
+
fm.links.length > 0 ? `Links: ${fm.links.map((l) => `[[${l}]]`).join(", ")}` : "",
|
|
121
|
+
]
|
|
122
|
+
.filter(Boolean)
|
|
123
|
+
.join("\n");
|
|
124
|
+
return {
|
|
125
|
+
content: [{ type: "text", text: `${header}\n\n${page.body}` }],
|
|
126
|
+
details: { found: true, path: `${parsed.category}/${parsed.slug}` },
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
// Try finding by title (case-insensitive search across all pages)
|
|
131
|
+
const allPages = await listPages(wikiDir);
|
|
132
|
+
const titleLower = params.path.toLowerCase();
|
|
133
|
+
for (const ref of allPages) {
|
|
134
|
+
if (ref.title.toLowerCase() === titleLower || ref.slug === titleLower) {
|
|
135
|
+
const page = await readPage(wikiDir, ref.category, ref.slug);
|
|
136
|
+
if (page) {
|
|
137
|
+
const fm = page.frontmatter;
|
|
138
|
+
const freshness = formatFreshness(fm.updated, now);
|
|
139
|
+
const header = [
|
|
140
|
+
`# ${fm.title}`,
|
|
141
|
+
`PARA: ${fm.para} | Scope: ${fm.scope.join(", ")} | Tags: ${fm.tags.join(", ")}`,
|
|
142
|
+
`Created: ${fm.created} | Updated: ${fm.updated} | ${freshness}`,
|
|
143
|
+
fm.sources.length > 0 ? `Sources: ${fm.sources.join(", ")}` : "",
|
|
144
|
+
fm.links.length > 0 ? `Links: ${fm.links.map((l) => `[[${l}]]`).join(", ")}` : "",
|
|
145
|
+
]
|
|
146
|
+
.filter(Boolean)
|
|
147
|
+
.join("\n");
|
|
148
|
+
return {
|
|
149
|
+
content: [{ type: "text", text: `${header}\n\n${page.body}` }],
|
|
150
|
+
details: { found: true, path: `${ref.category}/${ref.slug}` },
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return {
|
|
156
|
+
content: [{ type: "text", text: `Page not found: "${params.path}"` }],
|
|
157
|
+
details: { found: false },
|
|
158
|
+
};
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
//# sourceMappingURL=edit-read.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edit-read.js","sourceRoot":"","sources":["../../src/tools/edit-read.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,EAAE,aAAa,E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I,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE;wBAChE,EAAE,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE;qBAClF;yBACE,MAAM,CAAC,OAAO,CAAC;yBACf,IAAI,CAAC,IAAI,CAAC,CAAC;oBAEd,OAAO;wBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,OAAO,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;wBAC9D,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,IAAI,EAAE,EAAE;qBAC9D,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO;YACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,oBAAoB,MAAM,CAAC,IAAI,GAAG,EAAE,CAAC;YACrE,OAAO,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE;SAC1B,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AgentToolResult } from "@earendil-works/pi-agent-core";
|
|
2
|
+
import type { QMDStore } from "qmd-engine";
|
|
3
|
+
import type { ProjectScope } from "../scope.js";
|
|
4
|
+
import type { ParaCategory } from "../wiki.js";
|
|
5
|
+
import type { WikiIngestDetails } from "./schemas.js";
|
|
6
|
+
export declare function createIngestExecute(wikiDir: string, _store: QMDStore, getScope: () => ProjectScope): (params: {
|
|
7
|
+
source: string;
|
|
8
|
+
sourceType?: "url" | "file" | "text";
|
|
9
|
+
category?: ParaCategory;
|
|
10
|
+
scope?: string[];
|
|
11
|
+
}) => Promise<AgentToolResult<WikiIngestDetails>>;
|
|
12
|
+
//# sourceMappingURL=ingest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ingest.d.ts","sourceRoot":"","sources":["../../src/tools/ingest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG/C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAItD,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,QAAQ,EAChB,QAAQ,EAAE,MAAM,YAAY,IAG1B,QAAQ;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,YAAY,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,KAC1G,OAAO,CAAC,eAAe,CAAC,iBAAiB,CAAC,CAAC,CA6C/C"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { resolveSource, truncateSource } from "../ingest.js";
|
|
2
|
+
import { INGEST_PROMPT } from "../templates/prompts.js";
|
|
3
|
+
// -- Factory: wiki_ingest execute --------------------------------------------
|
|
4
|
+
export function createIngestExecute(wikiDir, _store, getScope) {
|
|
5
|
+
return async (params) => {
|
|
6
|
+
const scope = getScope();
|
|
7
|
+
const resolved = await resolveSource(wikiDir, {
|
|
8
|
+
source: params.source,
|
|
9
|
+
sourceType: params.sourceType,
|
|
10
|
+
scope: params.scope,
|
|
11
|
+
category: params.category,
|
|
12
|
+
}, scope);
|
|
13
|
+
const categoryHint = resolved.categoryHint
|
|
14
|
+
? `\nSuggested PARA category: ${resolved.categoryHint}`
|
|
15
|
+
: "";
|
|
16
|
+
// Assemble the tool result with instructions for the LLM
|
|
17
|
+
const toolResultText = [
|
|
18
|
+
INGEST_PROMPT,
|
|
19
|
+
"",
|
|
20
|
+
`Current scope: ${resolved.scopeName} (tags: ${resolved.scopeTags.join(", ")})`,
|
|
21
|
+
categoryHint,
|
|
22
|
+
resolved.rawPath ? `Raw source saved to: ${resolved.rawPath}` : "",
|
|
23
|
+
"",
|
|
24
|
+
"<wiki-schema>",
|
|
25
|
+
resolved.schema,
|
|
26
|
+
"</wiki-schema>",
|
|
27
|
+
"",
|
|
28
|
+
"<wiki-index>",
|
|
29
|
+
resolved.index,
|
|
30
|
+
"</wiki-index>",
|
|
31
|
+
"",
|
|
32
|
+
"<source-content>",
|
|
33
|
+
truncateSource(resolved.content),
|
|
34
|
+
"</source-content>",
|
|
35
|
+
"",
|
|
36
|
+
"Now analyze the source content and use wiki_write to create/update pages, update the index, and log the operation.",
|
|
37
|
+
].join("\n");
|
|
38
|
+
return {
|
|
39
|
+
content: [{ type: "text", text: toolResultText }],
|
|
40
|
+
details: {
|
|
41
|
+
sourceType: resolved.sourceType,
|
|
42
|
+
rawPath: resolved.rawPath,
|
|
43
|
+
sourceLength: resolved.content.length,
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=ingest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ingest.js","sourceRoot":"","sources":["../../src/tools/ingest.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAGxD,+EAA+E;AAE/E,MAAM,UAAU,mBAAmB,CACjC,OAAe,EACf,MAAgB,EAChB,QAA4B;IAE5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,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AgentToolResult } from "@earendil-works/pi-agent-core";
|
|
2
|
+
import type { QMDStore } from "qmd-engine";
|
|
3
|
+
import type { WikiLintDetails } from "./schemas.js";
|
|
4
|
+
export declare function createLintExecute(wikiDir: string, store: QMDStore, markDirty: () => void, getLintConfig?: () => {
|
|
5
|
+
autoFix: boolean;
|
|
6
|
+
staleDays: number;
|
|
7
|
+
}): (params: {
|
|
8
|
+
autoFix?: boolean;
|
|
9
|
+
}) => Promise<AgentToolResult<WikiLintDetails>>;
|
|
10
|
+
//# sourceMappingURL=lint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lint.d.ts","sourceRoot":"","sources":["../../src/tools/lint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAI3C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAKpD,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,QAAQ,EACf,SAAS,EAAE,MAAM,IAAI,EACrB,aAAa,CAAC,EAAE,MAAM;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,IAG3D,QAAQ;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,KAC5B,OAAO,CAAC,eAAe,CAAC,eAAe,CAAC,CAAC,CAuD7C"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { lintWiki } from "../lint.js";
|
|
2
|
+
import { PARA_CATEGORIES } from "../wiki.js";
|
|
3
|
+
import { LINT_PROMPT } from "../templates/prompts.js";
|
|
4
|
+
import { scheduleWikiMaintenance } from "./shared.js";
|
|
5
|
+
// -- Factory: wiki_lint execute ----------------------------------------------
|
|
6
|
+
export function createLintExecute(wikiDir, store, markDirty, getLintConfig) {
|
|
7
|
+
return async (params) => {
|
|
8
|
+
const configured = getLintConfig?.();
|
|
9
|
+
const report = await lintWiki(wikiDir, {
|
|
10
|
+
autoFix: params.autoFix ?? configured?.autoFix ?? true,
|
|
11
|
+
staleDays: configured?.staleDays ?? 90,
|
|
12
|
+
});
|
|
13
|
+
if (report.fixed.length > 0) {
|
|
14
|
+
scheduleWikiMaintenance(wikiDir, store, markDirty);
|
|
15
|
+
}
|
|
16
|
+
const { issues, fixed, stats } = report;
|
|
17
|
+
// Format report for the LLM
|
|
18
|
+
const parts = [];
|
|
19
|
+
parts.push("## Wiki Lint Report\n");
|
|
20
|
+
parts.push(`Total pages: ${stats.totalPages}`);
|
|
21
|
+
parts.push(`By category: ${PARA_CATEGORIES.map((c) => `${c}: ${stats.byCategory[c]}`).join(", ")}`);
|
|
22
|
+
parts.push(`Total links: ${stats.totalLinks} (broken: ${stats.brokenLinks})`);
|
|
23
|
+
parts.push(`Orphan pages: ${stats.orphanPages}`);
|
|
24
|
+
if (stats.oldestPage)
|
|
25
|
+
parts.push(`Oldest page: ${stats.oldestPage}`);
|
|
26
|
+
if (stats.newestPage)
|
|
27
|
+
parts.push(`Newest page: ${stats.newestPage}`);
|
|
28
|
+
if (stats.lastIngest)
|
|
29
|
+
parts.push(`Last ingest: ${stats.lastIngest}`);
|
|
30
|
+
if (fixed.length > 0) {
|
|
31
|
+
parts.push(`\n## Auto-fixed (${fixed.length})\n`);
|
|
32
|
+
for (const f of fixed) {
|
|
33
|
+
parts.push(`- [${f.severity}] ${f.page ?? ""}: ${f.message}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (issues.length > 0) {
|
|
37
|
+
parts.push(`\n## Remaining Issues (${issues.length})\n`);
|
|
38
|
+
for (const issue of issues) {
|
|
39
|
+
parts.push(`- [${issue.severity}] ${issue.category}${issue.page ? ` (${issue.page})` : ""}: ${issue.message}`);
|
|
40
|
+
}
|
|
41
|
+
parts.push("");
|
|
42
|
+
parts.push(LINT_PROMPT);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
parts.push("\nNo remaining issues. Wiki is healthy.");
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
content: [{ type: "text", text: parts.join("\n") }],
|
|
49
|
+
details: {
|
|
50
|
+
issueCount: issues.length,
|
|
51
|
+
fixedCount: fixed.length,
|
|
52
|
+
stats,
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=lint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lint.js","sourceRoot":"","sources":["../../src/tools/lint.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAEtD,+EAA+E;AAE/E,MAAM,UAAU,iBAAiB,CAC/B,OAAe,EACf,KAAe,EACf,SAAqB,EACrB,aAA6D;IAE7D,OAAO,KAAK,EACV,MAA6B,EACc,EAAE;QAC7C,MAAM,UAAU,GAAG,aAAa,EAAE,EAAE,CAAC;QACrC,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,OAAO,EAAE;YACrC,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,UAAU,EAAE,OAAO,IAAI,IAAI;YACtD,SAAS,EAAE,UAAU,EAAE,SAAS,IAAI,EAAE;SACvC,CAAC,CAAC;QACH,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC5B,uBAAuB,CAAC,OAAO,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;QACrD,CAAC;QAED,MAAM,EAAE,MAAM,EAAE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 @@
|
|
|
1
|
+
import { CURRENT_SCHEMA_VERSION, migrateToLatest } from "../frontmatter.js";
|
|
2
|
+
import { listPages, readPage, writePage } from "../wiki.js";
|
|
3
|
+
// -- Factory: wiki_migrate execute -------------------------------------------
|
|
4
|
+
export function createMigrateExecute(wikiDir) {
|
|
5
|
+
return async () => {
|
|
6
|
+
const allRefs = await listPages(wikiDir);
|
|
7
|
+
let migratedCount = 0;
|
|
8
|
+
for (const ref of allRefs) {
|
|
9
|
+
const page = await readPage(wikiDir, ref.category, ref.slug);
|
|
10
|
+
if (!page)
|
|
11
|
+
continue;
|
|
12
|
+
const version = page.frontmatter.schemaVersion ?? 1;
|
|
13
|
+
if (version >= CURRENT_SCHEMA_VERSION)
|
|
14
|
+
continue;
|
|
15
|
+
const rawObj = page.frontmatter;
|
|
16
|
+
const result = migrateToLatest(rawObj, page.body);
|
|
17
|
+
const migratedFm = result.fm;
|
|
18
|
+
migratedFm.updated = new Date().toISOString();
|
|
19
|
+
await writePage(wikiDir, {
|
|
20
|
+
category: ref.category,
|
|
21
|
+
slug: ref.slug,
|
|
22
|
+
frontmatter: migratedFm,
|
|
23
|
+
body: result.body,
|
|
24
|
+
});
|
|
25
|
+
migratedCount++;
|
|
26
|
+
}
|
|
27
|
+
const summary = migratedCount > 0
|
|
28
|
+
? `Migrated ${migratedCount} page(s) to schema version ${CURRENT_SCHEMA_VERSION}.`
|
|
29
|
+
: `All ${allRefs.length} page(s) already at schema version ${CURRENT_SCHEMA_VERSION}.`;
|
|
30
|
+
return {
|
|
31
|
+
content: [{ type: "text", text: summary }],
|
|
32
|
+
details: { migratedCount, totalPages: allRefs.length },
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=migrate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate.js","sourceRoot":"","sources":["../../src/tools/migrate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,eA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sBAAsB,GAAG,CAAC;QAEzF,OAAO;YACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;YAC1C,OAAO,EAAE,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,CAAC,MAAM,EAAE;SACvD,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AgentToolResult } from "@earendil-works/pi-agent-core";
|
|
2
|
+
import type { QMDStore } from "qmd-engine";
|
|
3
|
+
import { type ParaCategory } from "../wiki.js";
|
|
4
|
+
import type { WikiMoveDetails } from "./schemas.js";
|
|
5
|
+
export declare function createMoveExecute(wikiDir: string, store: QMDStore, markDirty: () => void): (params: {
|
|
6
|
+
path: string;
|
|
7
|
+
to: ParaCategory;
|
|
8
|
+
}) => Promise<AgentToolResult<WikiMoveDetails>>;
|
|
9
|
+
//# sourceMappingURL=move.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"move.d.ts","sourceRoot":"","sources":["../../src/tools/move.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAwE,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AACrH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAKpD,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,QAAQ,EACf,SAAS,EAAE,MAAM,IAAI,IAGnB,QAAQ;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,YAAY,CAAA;CAAE,KACzC,OAAO,CAAC,eAAe,CAAC,eAAe,CAAC,CAAC,CA+D7C"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { appendLog, gitCommit, movePage, readPage, rebuildIndex } from "../wiki.js";
|
|
2
|
+
import { parsePagePath, scheduleWikiMaintenance } from "./shared.js";
|
|
3
|
+
// -- Factory: wiki_move execute ----------------------------------------------
|
|
4
|
+
export function createMoveExecute(wikiDir, store, markDirty) {
|
|
5
|
+
return async (params) => {
|
|
6
|
+
const parsed = parsePagePath(params.path);
|
|
7
|
+
if (!parsed) {
|
|
8
|
+
throw new Error(`Invalid page path: "${params.path}". Expected format: category/slug`);
|
|
9
|
+
}
|
|
10
|
+
const page = await readPage(wikiDir, parsed.category, parsed.slug);
|
|
11
|
+
if (!page) {
|
|
12
|
+
throw new Error(`Page not found: "${params.path}"`);
|
|
13
|
+
}
|
|
14
|
+
if (parsed.category === params.to) {
|
|
15
|
+
return {
|
|
16
|
+
content: [
|
|
17
|
+
{
|
|
18
|
+
type: "text",
|
|
19
|
+
text: `Page "${params.path}" is already in ${params.to}. No move needed.`,
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
details: { from: params.path, to: `${params.to}/${parsed.slug}` },
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
const ref = {
|
|
26
|
+
category: parsed.category,
|
|
27
|
+
slug: parsed.slug,
|
|
28
|
+
title: page.frontmatter.title,
|
|
29
|
+
path: `${parsed.category}/${parsed.slug}.md`,
|
|
30
|
+
};
|
|
31
|
+
await movePage(wikiDir, ref, params.to);
|
|
32
|
+
// Rebuild index.md inline (fast, single-pass); defer QMD reindex to the
|
|
33
|
+
// debounced background maintenance queue like wiki_write/wiki_edit.
|
|
34
|
+
await rebuildIndex(wikiDir);
|
|
35
|
+
scheduleWikiMaintenance(wikiDir, store, markDirty);
|
|
36
|
+
markDirty();
|
|
37
|
+
// Git commit
|
|
38
|
+
await gitCommit(wikiDir, `move: ${page.frontmatter.title} → ${params.to}`);
|
|
39
|
+
// Log the move
|
|
40
|
+
const now = new Date().toISOString();
|
|
41
|
+
await appendLog(wikiDir, {
|
|
42
|
+
date: now.split("T")[0],
|
|
43
|
+
operation: "move",
|
|
44
|
+
summary: `Moved ${page.frontmatter.title} from ${parsed.category} to ${params.to}`,
|
|
45
|
+
pages: [`${params.to}/${parsed.slug}`],
|
|
46
|
+
});
|
|
47
|
+
return {
|
|
48
|
+
content: [
|
|
49
|
+
{
|
|
50
|
+
type: "text",
|
|
51
|
+
text: `Moved "${page.frontmatter.title}" from ${parsed.category}/ to ${params.to}/`,
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
details: {
|
|
55
|
+
from: `${parsed.category}/${parsed.slug}`,
|
|
56
|
+
to: `${params.to}/${parsed.slug}`,
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=move.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"move.js","sourceRoot":"","sources":["../../src/tools/move.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,EAAmC,MAAM,YAAY,CAAC;AAErH,OAAO,EAAE,aAAa,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAErE,+EAA+E;AAE/E,MAAM,UAAU,iBAAiB,CAC/B,OAAe,EACf,KAAe,EACf,SAAqB;IAErB,OAAO,KAAK,EACV,MAA0C,EACC,EAAE;QAC7C,MAAM,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC1C,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,uBAAuB,MAAM,CAAC,IAAI,mCAAmC,CAAC,CAAC;QACzF,CAAC;QAED,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;QACnE,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,IAAI,KAAK,CAAC,oBAAoB,MAAM,CAAC,IAAI,GA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AS,IAAI,CAAC,WAAW,CAAC,KAAK,SAAS,MAAM,CAAC,QAAQ,OAAO,MAAM,CAAC,EAAE,EAAE;YAClF,KAAK,EAAE,CAAC,GAAG,MAAM,CAAC,EAAE,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;SACvC,CAAC,CAAC;QAEH,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,UAAU,IAAI,CAAC,WAAW,CAAC,KAAK,UAAU,MAAM,CAAC,QAAQ,QAAQ,MAAM,CAAC,EAAE,GAAG;iBACpF;aACF;YACD,OAAO,EAAE;gBACP,IAAI,EAAE,GAAG,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,IAAI,EAAE;gBACzC,EAAE,EAAE,GAAG,MAAM,CAAC,EAAE,IAAI,MAAM,CAAC,IAAI,EAAE;aAClC;SACF,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AgentToolResult } from "@earendil-works/pi-agent-core";
|
|
2
|
+
import type { QMDStore } from "qmd-engine";
|
|
3
|
+
import type { ProjectScope } from "../scope.js";
|
|
4
|
+
import type { ParaCategory } from "../wiki.js";
|
|
5
|
+
import type { WikiQueryDetails } from "./schemas.js";
|
|
6
|
+
export declare function createQueryExecute(_wikiDir: string, store: QMDStore, getScope: () => ProjectScope, getGraphBoost?: () => boolean): (params: {
|
|
7
|
+
query: string;
|
|
8
|
+
global?: boolean;
|
|
9
|
+
category?: ParaCategory;
|
|
10
|
+
limit?: number;
|
|
11
|
+
}) => Promise<AgentToolResult<WikiQueryDetails>>;
|
|
12
|
+
//# sourceMappingURL=query.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/tools/query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG/C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAIrD,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,QAAQ,EACf,QAAQ,EAAE,MAAM,YAAY,EAC5B,aAAa,CAAC,EAAE,MAAM,OAAO,IAG3B,QAAQ;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,YAAY,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,KACnF,OAAO,CAAC,eAAe,CAAC,gBAAgB,CAAC,CAAC,CA4C9C"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { queryWiki as queryWikiLib, formatQueryResults } from "../query.js";
|
|
2
|
+
import { QUERY_PROMPT } from "../templates/prompts.js";
|
|
3
|
+
// -- Factory: wiki_query execute ---------------------------------------------
|
|
4
|
+
export function createQueryExecute(_wikiDir, store, getScope, getGraphBoost) {
|
|
5
|
+
return async (params) => {
|
|
6
|
+
const scope = getScope();
|
|
7
|
+
const result = await queryWikiLib(store, {
|
|
8
|
+
query: params.query,
|
|
9
|
+
global: params.global,
|
|
10
|
+
category: params.category,
|
|
11
|
+
limit: params.limit,
|
|
12
|
+
graphBoost: getGraphBoost?.() ?? true,
|
|
13
|
+
}, scope);
|
|
14
|
+
if (result.results.length === 0) {
|
|
15
|
+
return {
|
|
16
|
+
content: [
|
|
17
|
+
{
|
|
18
|
+
type: "text",
|
|
19
|
+
text: `No wiki pages found for "${params.query}". The wiki may not have content on this topic yet.`,
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
details: {
|
|
23
|
+
resultCount: 0,
|
|
24
|
+
scopeUsed: result.wasGlobal ? "global" : scope.name,
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
const formatted = formatQueryResults(result.results);
|
|
29
|
+
const toolResultText = [
|
|
30
|
+
QUERY_PROMPT,
|
|
31
|
+
"",
|
|
32
|
+
`Query: "${params.query}"`,
|
|
33
|
+
`Scope: ${result.wasGlobal ? "global (all scopes)" : scope.name}`,
|
|
34
|
+
`Results: ${result.results.length}`,
|
|
35
|
+
"",
|
|
36
|
+
formatted,
|
|
37
|
+
].join("\n");
|
|
38
|
+
return {
|
|
39
|
+
content: [{ type: "text", text: toolResultText }],
|
|
40
|
+
details: {
|
|
41
|
+
resultCount: result.results.length,
|
|
42
|
+
scopeUsed: result.wasGlobal ? "global" : scope.name,
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.js","sourceRoot":"","sources":["../../src/tools/query.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,IAAI,YAAY,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAGvD,+EAA+E;AAE/E,MAAM,UAAU,kBAAkB,CAChC,QAAgB,EAChB,KAAe,EACf,QAA4B,EAC5B,aAA6B;IAE7B,OAAO,KAAK,EACV,MAAoF,EACxC,EAAE;QAC9C,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAC;QACzB,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,KAAK,EAAE;YACvC,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,UAAU,EAAE,aAAa,EAAE,EAAE,IAAI,IAAI;SACtC,EAAE,KAAK,CAAC,CAAC;QAEV,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAChC,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,4BAA4B,MAAM,CAAC,KAAK,qDAAqD;qBACpG;iBACF;gBACD,OAAO,EAAE;oBACP,WAAW,EAAE,CAAC;oBACd,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI;iBACpD;aACF,CAAC;QACJ,CAAC;QAED,MAAM,SAAS,GAAG,kBAAkB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACrD,MAAM,cAAc,GAAG;YACrB,YAAY;YACZ,EAAE;YACF,WAAW,MAAM,CAAC,KAAK,GAAG;YAC1B,UAAU,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE;YACjE,YAAY,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE;YACnC,EAAE;YACF,SAAS;SACV,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEb,OAAO;YACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC;YACjD,OAAO,EAAE;gBACP,WAAW,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM;gBAClC,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI;aACpD;SACF,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { Type } from "typebox";
|
|
2
|
+
import type { LintReport } from "../lint.js";
|
|
3
|
+
export declare const PARA_ENUM: Type.TUnsafe<"projects" | "areas" | "resources" | "archives">;
|
|
4
|
+
export declare const PARA_ENUM_NO_ARCHIVES: Type.TUnsafe<"projects" | "areas" | "resources">;
|
|
5
|
+
export declare const WikiIngestParams: Type.TObject<{
|
|
6
|
+
source: Type.TString;
|
|
7
|
+
sourceType: Type.TOptional<Type.TUnsafe<"url" | "file" | "text">>;
|
|
8
|
+
category: Type.TOptional<Type.TUnsafe<"projects" | "areas" | "resources">>;
|
|
9
|
+
scope: Type.TOptional<Type.TArray<Type.TString>>;
|
|
10
|
+
}>;
|
|
11
|
+
export declare const WikiQueryParams: Type.TObject<{
|
|
12
|
+
query: Type.TString;
|
|
13
|
+
global: Type.TOptional<Type.TBoolean>;
|
|
14
|
+
category: Type.TOptional<Type.TUnsafe<"projects" | "areas" | "resources" | "archives">>;
|
|
15
|
+
limit: Type.TOptional<Type.TNumber>;
|
|
16
|
+
}>;
|
|
17
|
+
export declare const WikiEditSchema: Type.TObject<{
|
|
18
|
+
oldText: Type.TString;
|
|
19
|
+
newText: Type.TString;
|
|
20
|
+
}>;
|
|
21
|
+
export declare const WikiWritePageSchema: Type.TObject<{
|
|
22
|
+
category: Type.TUnsafe<"projects" | "areas" | "resources" | "archives">;
|
|
23
|
+
slug: Type.TString;
|
|
24
|
+
title: Type.TString;
|
|
25
|
+
scope: Type.TArray<Type.TString>;
|
|
26
|
+
tags: Type.TArray<Type.TString>;
|
|
27
|
+
body: Type.TString;
|
|
28
|
+
mode: Type.TUnsafe<"replace" | "edit" | "append" | "create">;
|
|
29
|
+
edits: Type.TOptional<Type.TArray<Type.TObject<{
|
|
30
|
+
oldText: Type.TString;
|
|
31
|
+
newText: Type.TString;
|
|
32
|
+
}>>>;
|
|
33
|
+
}>;
|
|
34
|
+
export declare const WikiWriteParams: Type.TObject<{
|
|
35
|
+
pages: Type.TArray<Type.TObject<{
|
|
36
|
+
category: Type.TUnsafe<"projects" | "areas" | "resources" | "archives">;
|
|
37
|
+
slug: Type.TString;
|
|
38
|
+
title: Type.TString;
|
|
39
|
+
scope: Type.TArray<Type.TString>;
|
|
40
|
+
tags: Type.TArray<Type.TString>;
|
|
41
|
+
body: Type.TString;
|
|
42
|
+
mode: Type.TUnsafe<"replace" | "edit" | "append" | "create">;
|
|
43
|
+
edits: Type.TOptional<Type.TArray<Type.TObject<{
|
|
44
|
+
oldText: Type.TString;
|
|
45
|
+
newText: Type.TString;
|
|
46
|
+
}>>>;
|
|
47
|
+
}>>;
|
|
48
|
+
indexContent: Type.TOptional<Type.TString>;
|
|
49
|
+
logSummary: Type.TOptional<Type.TString>;
|
|
50
|
+
}>;
|
|
51
|
+
export declare const WikiEditParams: Type.TObject<{
|
|
52
|
+
path: Type.TString;
|
|
53
|
+
edits: Type.TArray<Type.TObject<{
|
|
54
|
+
oldText: Type.TString;
|
|
55
|
+
newText: Type.TString;
|
|
56
|
+
}>>;
|
|
57
|
+
title: Type.TOptional<Type.TString>;
|
|
58
|
+
scope: Type.TOptional<Type.TArray<Type.TString>>;
|
|
59
|
+
tags: Type.TOptional<Type.TArray<Type.TString>>;
|
|
60
|
+
logSummary: Type.TOptional<Type.TString>;
|
|
61
|
+
}>;
|
|
62
|
+
export declare const WikiReadParams: Type.TObject<{
|
|
63
|
+
path: Type.TString;
|
|
64
|
+
}>;
|
|
65
|
+
export declare const WikiMoveParams: Type.TObject<{
|
|
66
|
+
path: Type.TString;
|
|
67
|
+
to: Type.TUnsafe<"projects" | "areas" | "resources" | "archives">;
|
|
68
|
+
}>;
|
|
69
|
+
export declare const WikiLintParams: Type.TObject<{
|
|
70
|
+
autoFix: Type.TOptional<Type.TBoolean>;
|
|
71
|
+
}>;
|
|
72
|
+
export declare const WikiMigrateParams: Type.TObject<{}>;
|
|
73
|
+
export declare const WikiSummarizeParams: Type.TObject<{
|
|
74
|
+
target: Type.TString;
|
|
75
|
+
depth: Type.TOptional<Type.TUnsafe<"brief" | "detailed">>;
|
|
76
|
+
}>;
|
|
77
|
+
export interface WikiIngestDetails {
|
|
78
|
+
sourceType: "url" | "file" | "text";
|
|
79
|
+
rawPath?: string;
|
|
80
|
+
sourceLength: number;
|
|
81
|
+
}
|
|
82
|
+
export interface WikiQueryDetails {
|
|
83
|
+
resultCount: number;
|
|
84
|
+
scopeUsed: string;
|
|
85
|
+
}
|
|
86
|
+
export interface WikiWriteDetails {
|
|
87
|
+
pagesWritten: string[];
|
|
88
|
+
indexUpdated: boolean;
|
|
89
|
+
logAppended: boolean;
|
|
90
|
+
pagesSkipped?: string[];
|
|
91
|
+
}
|
|
92
|
+
export interface WikiReadDetails {
|
|
93
|
+
found: boolean;
|
|
94
|
+
path?: string;
|
|
95
|
+
}
|
|
96
|
+
export interface WikiMoveDetails {
|
|
97
|
+
from: string;
|
|
98
|
+
to: string;
|
|
99
|
+
}
|
|
100
|
+
export interface WikiLintDetails {
|
|
101
|
+
issueCount: number;
|
|
102
|
+
fixedCount: number;
|
|
103
|
+
stats: LintReport["stats"];
|
|
104
|
+
}
|
|
105
|
+
export interface WikiSummarizeDetails {
|
|
106
|
+
target: string;
|
|
107
|
+
pageCount: number;
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=schemas.d.ts.map
|