@zosmaai/pi-llm-wiki 0.10.7 → 0.11.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.
Files changed (73) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.de.md +35 -4
  3. package/README.es.md +260 -170
  4. package/README.fr.md +35 -4
  5. package/README.hi.md +35 -4
  6. package/README.ja.md +35 -4
  7. package/README.ko.md +35 -4
  8. package/README.md +38 -3
  9. package/README.pt.md +35 -4
  10. package/README.ru.md +35 -4
  11. package/README.zh.md +260 -170
  12. package/assets/demo.gif +0 -0
  13. package/dist/extensions/llm-wiki/lib/bootstrap.js +71 -0
  14. package/dist/extensions/llm-wiki/lib/embeddings.js +401 -0
  15. package/dist/extensions/llm-wiki/lib/guardrails.js +232 -0
  16. package/dist/extensions/llm-wiki/lib/indexing.js +78 -0
  17. package/dist/extensions/llm-wiki/lib/ingest-worker.js +310 -0
  18. package/dist/extensions/llm-wiki/lib/inject.js +65 -0
  19. package/dist/extensions/llm-wiki/lib/knowledge-document.js +442 -0
  20. package/dist/extensions/llm-wiki/lib/knowledge-links.js +206 -0
  21. package/dist/extensions/llm-wiki/lib/legacy-repair.js +443 -0
  22. package/dist/extensions/llm-wiki/lib/metadata.js +499 -0
  23. package/dist/extensions/llm-wiki/lib/model-command.js +86 -0
  24. package/dist/extensions/llm-wiki/lib/observation.js +283 -0
  25. package/dist/extensions/llm-wiki/lib/recall.js +875 -0
  26. package/dist/extensions/llm-wiki/lib/retro.js +158 -0
  27. package/dist/extensions/llm-wiki/lib/runtime.js +191 -0
  28. package/dist/extensions/llm-wiki/lib/source-extractors.js +426 -0
  29. package/dist/extensions/llm-wiki/lib/source-packet.js +229 -0
  30. package/dist/extensions/llm-wiki/lib/subagent.js +41 -0
  31. package/dist/extensions/llm-wiki/lib/task-config.js +172 -0
  32. package/dist/extensions/llm-wiki/lib/tools.js +1192 -0
  33. package/dist/extensions/llm-wiki/lib/trajectories-command.js +51 -0
  34. package/dist/extensions/llm-wiki/lib/trajectory.js +467 -0
  35. package/dist/extensions/llm-wiki/lib/utils.js +347 -0
  36. package/dist/extensions/llm-wiki/lib/vault-format.js +247 -0
  37. package/dist/extensions/llm-wiki/lib/visible-status.js +31 -0
  38. package/dist/extensions/llm-wiki/lib/wiki-service.js +128 -0
  39. package/dist/mcp/exec.js +121 -0
  40. package/dist/mcp/index.js +229 -0
  41. package/dist/mcp/operations.js +130 -0
  42. package/dist/package.json +1 -0
  43. package/docs/superpowers/plans/2026-08-02-okf-foundation.md +1579 -0
  44. package/docs/superpowers/plans/2026-08-03-okf-foundation-remediation.md +3005 -0
  45. package/docs/superpowers/plans/2026-08-06-okf-foundation-release-remediation.md +1174 -0
  46. package/docs/superpowers/specs/2026-08-02-okf-foundation-design.md +578 -0
  47. package/docs/superpowers/specs/2026-08-02-okf-v0.2-interoperability-design.md +538 -0
  48. package/extensions/llm-wiki/index.ts +22 -36
  49. package/extensions/llm-wiki/lib/bootstrap.ts +84 -0
  50. package/extensions/llm-wiki/lib/embeddings.ts +9 -3
  51. package/extensions/llm-wiki/lib/guardrails.ts +174 -29
  52. package/extensions/llm-wiki/lib/indexing.ts +2 -1
  53. package/extensions/llm-wiki/lib/ingest-worker.ts +170 -29
  54. package/extensions/llm-wiki/lib/knowledge-document.ts +661 -0
  55. package/extensions/llm-wiki/lib/knowledge-links.ts +282 -0
  56. package/extensions/llm-wiki/lib/legacy-repair.ts +572 -0
  57. package/extensions/llm-wiki/lib/metadata.ts +531 -116
  58. package/extensions/llm-wiki/lib/observation.ts +37 -43
  59. package/extensions/llm-wiki/lib/recall.ts +61 -33
  60. package/extensions/llm-wiki/lib/retro.ts +65 -41
  61. package/extensions/llm-wiki/lib/source-extractors.ts +12 -17
  62. package/extensions/llm-wiki/lib/source-packet.ts +44 -31
  63. package/extensions/llm-wiki/lib/tools.ts +406 -348
  64. package/extensions/llm-wiki/lib/trajectory.ts +15 -1
  65. package/extensions/llm-wiki/lib/utils.ts +121 -130
  66. package/extensions/llm-wiki/lib/vault-format.ts +363 -0
  67. package/extensions/llm-wiki/lib/wiki-service.ts +183 -0
  68. package/mcp/exec.ts +122 -0
  69. package/mcp/index.ts +60 -250
  70. package/mcp/operations.ts +176 -0
  71. package/package.json +8 -2
  72. package/scripts/migrate-llm-wiki.js +801 -0
  73. package/skills/llm-wiki/SKILL.md +8 -6
@@ -1,6 +1,8 @@
1
1
  import { mkdirSync, writeFileSync } from "node:fs";
2
+ import { copyFile } from "node:fs/promises";
2
3
  import { extname, join } from "node:path";
3
4
  import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
5
+ import { createKnowledgeDocument, serializeKnowledgeDocument } from "./knowledge-document.js";
4
6
  import { appendEvent } from "./metadata.js";
5
7
  import {
6
8
  type ExtractedContent,
@@ -9,7 +11,16 @@ import {
9
11
  extractUrlContent,
10
12
  fileExtractorFor,
11
13
  } from "./source-extractors.js";
12
- import { type VaultPaths, exec, fmtDate, nextSourceId, readText, writeJson } from "./utils.js";
14
+ import {
15
+ type ExecApi,
16
+ type VaultPaths,
17
+ exec,
18
+ fmtDate,
19
+ nextSourceId,
20
+ readText,
21
+ writeJson,
22
+ } from "./utils.js";
23
+ import { assertWritableVault } from "./vault-format.js";
13
24
 
14
25
  /**
15
26
  * Source packet capture and management.
@@ -47,7 +58,7 @@ const URL_ORIGINAL_EXTENSIONS = new Set([".html", ".htm", ".md", ".pdf", ".txt",
47
58
 
48
59
  /** Capture a URL into a source packet. */
49
60
  export async function captureUrl(
50
- pi: ExtensionAPI,
61
+ pi: ExecApi,
51
62
  paths: VaultPaths,
52
63
  url: string,
53
64
  signal?: AbortSignal,
@@ -57,7 +68,7 @@ export async function captureUrl(
57
68
 
58
69
  /** Capture a local file into a source packet. */
59
70
  export async function captureFile(
60
- pi: ExtensionAPI,
71
+ pi: ExecApi,
61
72
  paths: VaultPaths,
62
73
  filePath: string,
63
74
  signal?: AbortSignal,
@@ -71,6 +82,7 @@ export function captureText(paths: VaultPaths, text: string, title?: string): Ca
71
82
  }
72
83
 
73
84
  async function captureSource(paths: VaultPaths, source: CaptureSource): Promise<CaptureResult> {
85
+ assertWritableVault(paths);
74
86
  const packet = createSourcePacket(paths, source.needsOriginalDir);
75
87
  await source.preserveOriginal?.(packet.packetPath);
76
88
  const content = await source.extract();
@@ -78,12 +90,13 @@ async function captureSource(paths: VaultPaths, source: CaptureSource): Promise<
78
90
  }
79
91
 
80
92
  function captureSourceSync(paths: VaultPaths, source: CaptureSource): CaptureResult {
93
+ assertWritableVault(paths);
81
94
  const packet = createSourcePacket(paths, source.needsOriginalDir);
82
95
  const content = source.extract() as ExtractedContent;
83
96
  return finalizeCapture(paths, packet, source, content);
84
97
  }
85
98
 
86
- function urlCaptureSource(pi: ExtensionAPI, url: string, signal?: AbortSignal): CaptureSource {
99
+ function urlCaptureSource(pi: ExecApi, url: string, signal?: AbortSignal): CaptureSource {
87
100
  return {
88
101
  needsOriginalDir: true,
89
102
  fallbackText: contentExtractionFailureMessage(url),
@@ -98,11 +111,7 @@ function urlCaptureSource(pi: ExtensionAPI, url: string, signal?: AbortSignal):
98
111
  };
99
112
  }
100
113
 
101
- function fileCaptureSource(
102
- pi: ExtensionAPI,
103
- filePath: string,
104
- signal?: AbortSignal,
105
- ): CaptureSource {
114
+ function fileCaptureSource(pi: ExecApi, filePath: string, signal?: AbortSignal): CaptureSource {
106
115
  const fileName = filePath.split("/").pop() || "unknown";
107
116
  const extractor = fileExtractorFor(filePath);
108
117
  const content = extractor.shouldReadText ? readText(filePath) : "";
@@ -110,8 +119,7 @@ function fileCaptureSource(
110
119
  return {
111
120
  needsOriginalDir: true,
112
121
  fallbackText: "",
113
- preserveOriginal: (packetPath) =>
114
- preserveFileOriginal(pi, packetPath, filePath, fileName, content, signal),
122
+ preserveOriginal: (packetPath) => preserveFileOriginal(packetPath, filePath, fileName, content),
115
123
  extract: async () => {
116
124
  // Guard: if we hit the generic catch-all extractor, check for binary magic bytes first
117
125
  if (extractor.format === "file") {
@@ -171,6 +179,7 @@ function finalizeCapture(
171
179
  source: CaptureSource,
172
180
  content: ExtractedContent,
173
181
  ): CaptureResult {
182
+ assertWritableVault(paths);
174
183
  const extracted = content.extracted || source.fallbackText;
175
184
  const manifest = {
176
185
  id: packet.sourceId,
@@ -203,23 +212,21 @@ function finalizeCapture(
203
212
  }
204
213
 
205
214
  async function preserveFileOriginal(
206
- pi: ExtensionAPI,
207
215
  packetPath: string,
208
216
  filePath: string,
209
217
  fileName: string,
210
218
  fallbackContent: string,
211
- signal?: AbortSignal,
212
219
  ): Promise<void> {
213
220
  try {
214
- await exec(pi, "cp", [filePath, join(packetPath, "original", fileName)], { signal });
221
+ await copyFile(filePath, join(packetPath, "original", fileName));
215
222
  } catch {
216
- // If cp fails, preserve whatever text content was available.
223
+ // If copying fails, preserve whatever text content was available.
217
224
  writeFileSync(join(packetPath, "original", fileName), fallbackContent, "utf-8");
218
225
  }
219
226
  }
220
227
 
221
228
  async function preserveUrlOriginal(
222
- pi: ExtensionAPI,
229
+ pi: ExecApi,
223
230
  packetPath: string,
224
231
  url: string,
225
232
  signal?: AbortSignal,
@@ -268,16 +275,7 @@ function buildSourcePageSkeleton(manifest: Record<string, unknown>, extracted: s
268
275
  .trim()
269
276
  .slice(0, 500);
270
277
 
271
- return `---
272
- type: source
273
- format: ${format}
274
- source_id: ${id}
275
- raw_path: raw/sources/${id}/extracted.md
276
- captured: ${captured}
277
- status: skeleton
278
- ---
279
-
280
- # ${title}${url}
278
+ const body = `# ${title}${url}
281
279
 
282
280
  ## Summary
283
281
 
@@ -293,11 +291,11 @@ status: skeleton
293
291
 
294
292
  ## Entities Mentioned
295
293
 
296
- - [[entity-name]]
294
+ - [LLM: Add linked entities after review]
297
295
 
298
296
  ## Concepts Mentioned
299
297
 
300
- - [[concept-name]]
298
+ - [LLM: Add linked concepts after review]
301
299
 
302
300
  ## Notable Quotes
303
301
 
@@ -305,8 +303,23 @@ status: skeleton
305
303
 
306
304
  ## Source Packet
307
305
 
308
- - **ID:** \`[[sources/${id}]]\`
309
- - **Extracted:** [raw/sources/${id}/extracted.md](../raw/sources/${id}/extracted.md)
310
- - **Manifest:** [raw/sources/${id}/manifest.json](../raw/sources/${id}/manifest.json)
306
+ - **ID:** \`sources/${id}\`
307
+ - **Extracted:** \`raw/sources/${id}/extracted.md\`
308
+ - **Manifest:** \`raw/sources/${id}/manifest.json\`
311
309
  `;
310
+
311
+ const doc = createKnowledgeDocument(
312
+ `sources/${id}.md`,
313
+ {
314
+ type: "source",
315
+ title,
316
+ format,
317
+ source_id: id,
318
+ raw_path: `raw/sources/${id}/extracted.md`,
319
+ captured,
320
+ status: "skeleton",
321
+ },
322
+ body,
323
+ );
324
+ return serializeKnowledgeDocument(doc);
312
325
  }