@zosmaai/pi-llm-wiki 0.6.6 → 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.
@@ -28,8 +28,8 @@ import {
28
28
  * All LLM Wiki custom tools.
29
29
  */
30
30
 
31
- function getPaths(cwd = process.cwd()): VaultPaths {
32
- return resolveVaultPaths(cwd);
31
+ function getPaths(cwd?: string): VaultPaths {
32
+ return resolveVaultPaths(cwd ?? process.cwd());
33
33
  }
34
34
 
35
35
  function requireVault(paths: VaultPaths): { ok: true } | { ok: false; reason: string } {
@@ -58,7 +58,7 @@ export function registerWikiBootstrap(pi: ExtensionAPI): void {
58
58
  ),
59
59
  }),
60
60
  async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
61
- const root = params.root ? params.root : (ctx.cwd ?? process.cwd());
61
+ const root = params.root ?? ctx.cwd ?? process.cwd();
62
62
  const mode = params.mode || "personal";
63
63
  const paths = getVaultPaths(root);
64
64
 
@@ -121,6 +121,7 @@ export function registerWikiBootstrap(pi: ExtensionAPI): void {
121
121
  type: "text",
122
122
  text: [
123
123
  `✅ Wiki bootstrapped at \`${paths.root}\``,
124
+ "**Scope:** project-local",
124
125
  "",
125
126
  "**Structure:**",
126
127
  "- .llm-wiki/raw/sources/ — immutable source packets",
@@ -158,8 +159,8 @@ export function registerWikiCaptureSource(pi: ExtensionAPI): void {
158
159
  text: Type.Optional(Type.String({ description: "Pasted text content" })),
159
160
  title: Type.Optional(Type.String({ description: "Title for pasted text" })),
160
161
  }),
161
- async execute(_toolCallId, params, signal) {
162
- const paths = getPaths();
162
+ async execute(_toolCallId, params, signal, _onUpdate, ctx) {
163
+ const paths = getPaths(ctx.cwd);
163
164
  const vaultCheck = requireVault(paths);
164
165
  if (!vaultCheck.ok) {
165
166
  return {
@@ -239,8 +240,8 @@ export function registerWikiIngest(pi: ExtensionAPI): void {
239
240
  Type.Number({ description: "Max sources to return (default: 3, max: 5)", default: 3 }),
240
241
  ),
241
242
  }),
242
- async execute(_toolCallId, params) {
243
- const paths = getPaths();
243
+ async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
244
+ const paths = getPaths(ctx.cwd);
244
245
  const vaultCheck = requireVault(paths);
245
246
  if (!vaultCheck.ok) {
246
247
  return {
@@ -377,8 +378,8 @@ export function registerWikiEnsurePage(pi: ExtensionAPI): void {
377
378
  Type.String({ description: "Optional initial content (otherwise uses template)" }),
378
379
  ),
379
380
  }),
380
- async execute(_toolCallId, params) {
381
- const paths = getPaths();
381
+ async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
382
+ const paths = getPaths(ctx.cwd);
382
383
  const vaultCheck = requireVault(paths);
383
384
  if (!vaultCheck.ok) {
384
385
  return {
@@ -523,8 +524,8 @@ export function registerWikiSearch(pi: ExtensionAPI): void {
523
524
  query: Type.String({ description: "Search term" }),
524
525
  type: Type.Optional(Type.String({ description: "Filter by page type" })),
525
526
  }),
526
- async execute(_toolCallId, params) {
527
- const paths = getPaths();
527
+ async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
528
+ const paths = getPaths(ctx.cwd);
528
529
  const registry = readJson<Registry>(join(paths.meta, "registry.json"), {
529
530
  version: "1.0",
530
531
  last_updated: "",
@@ -586,8 +587,8 @@ export function registerWikiLint(pi: ExtensionAPI): void {
586
587
  Type.Boolean({ description: "Auto-fix orphans and missing pages", default: false }),
587
588
  ),
588
589
  }),
589
- async execute(_toolCallId, params) {
590
- const paths = getPaths();
590
+ async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
591
+ const paths = getPaths(ctx.cwd);
591
592
  const vaultCheck = requireVault(paths);
592
593
  if (!vaultCheck.ok) {
593
594
  return {
@@ -741,8 +742,8 @@ export function registerWikiStatus(pi: ExtensionAPI): void {
741
742
  promptSnippet: "Report wiki health and stats",
742
743
  promptGuidelines: ["Use wiki_status for a quick overview."],
743
744
  parameters: Type.Object({}),
744
- async execute() {
745
- const paths = getPaths();
745
+ async execute(_toolCallId, _params, _signal, _onUpdate, ctx) {
746
+ const paths = getPaths(ctx.cwd);
746
747
  const vaultCheck = requireVault(paths);
747
748
  if (!vaultCheck.ok) {
748
749
  return {
@@ -818,8 +819,8 @@ export function registerWikiRebuildMeta(pi: ExtensionAPI): void {
818
819
  promptSnippet: "Rebuild all wiki metadata",
819
820
  promptGuidelines: ["Use wiki_rebuild_meta if metadata seems out of sync."],
820
821
  parameters: Type.Object({}),
821
- async execute() {
822
- const paths = getPaths();
822
+ async execute(_toolCallId, _params, _signal, _onUpdate, ctx) {
823
+ const paths = getPaths(ctx.cwd);
823
824
  const vaultCheck = requireVault(paths);
824
825
  if (!vaultCheck.ok) {
825
826
  return {
@@ -864,8 +865,8 @@ export function registerWikiLogEvent(pi: ExtensionAPI): void {
864
865
  kind: Type.String({ description: "Event kind (e.g., ingest, query, decision)" }),
865
866
  details: Type.Optional(Type.Object({}, { description: "Additional event fields" })),
866
867
  }),
867
- async execute(_toolCallId, params) {
868
- const paths = getPaths();
868
+ async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
869
+ const paths = getPaths(ctx.cwd);
869
870
  const vaultCheck = requireVault(paths);
870
871
  if (!vaultCheck.ok) {
871
872
  return {
@@ -904,7 +905,7 @@ export function registerWikiWatch(pi: ExtensionAPI): void {
904
905
  parameters: Type.Object({
905
906
  interval: Type.String({ description: "daily, weekly, hourly, or stop" }),
906
907
  }),
907
- async execute(_toolCallId, params) {
908
+ async execute(_toolCallId, params, _signal, _onUpdate, _ctx) {
908
909
  if (params.interval === "stop") {
909
910
  return {
910
911
  content: [
@@ -1,4 +1,5 @@
1
1
  import { existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
2
+ import { homedir } from "node:os";
2
3
  import { dirname, join, resolve } from "node:path";
3
4
  import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
4
5
 
@@ -32,7 +33,35 @@ export function detectVaultFormat(dir: string): VaultFormat {
32
33
  return "none";
33
34
  }
34
35
 
35
- /** Resolve vault root from cwd or find nearest wiki root. */
36
+ /** Get the personal wiki root directory (~/.llm-wiki/). */
37
+ export function getPersonalWikiRoot(): string {
38
+ const envWiki = process.env.WIKI_HOME;
39
+ if (envWiki) return envWiki;
40
+ return join(homedir(), ".llm-wiki");
41
+ }
42
+
43
+ /** Get VaultPaths for the personal wiki. */
44
+ export function getPersonalWikiPaths(): VaultPaths {
45
+ return getVaultPaths(getPersonalWikiRoot());
46
+ }
47
+
48
+ /**
49
+ * Check if a vault is the personal wiki location.
50
+ * Used in layered recall to avoid double-counting.
51
+ */
52
+ export function isPersonalVault(paths: VaultPaths): boolean {
53
+ return paths.root === getPersonalWikiRoot();
54
+ }
55
+
56
+ /**
57
+ * Resolve vault root from cwd with personal fallback.
58
+ *
59
+ * Priority:
60
+ * 1. cwd has .llm-wiki/ → project wiki (explicit)
61
+ * 2. Walk up from cwd → parent project wiki
62
+ * 3. ~/.llm-wiki/ exists → personal wiki
63
+ * 4. Fallback: ~/.llm-wiki/ (create personal wiki)
64
+ */
36
65
  export function resolveVaultRoot(cwd: string): string {
37
66
  // Check for any vault format at cwd
38
67
  if (detectVaultFormat(cwd) !== "none") return cwd;
@@ -44,8 +73,12 @@ export function resolveVaultRoot(cwd: string): string {
44
73
  if (detectVaultFormat(dir) !== "none") return dir;
45
74
  }
46
75
 
47
- // Fallback: cwd itself
48
- return cwd;
76
+ // Check personal wiki at ~/.llm-wiki/
77
+ const personalRoot = getPersonalWikiRoot();
78
+ if (detectVaultFormat(personalRoot) !== "none") return personalRoot;
79
+
80
+ // Fallback: personal wiki
81
+ return personalRoot;
49
82
  }
50
83
 
51
84
  /** Get all vault paths for the new (.llm-wiki) layout. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zosmaai/pi-llm-wiki",
3
- "version": "0.6.6",
3
+ "version": "0.7.1",
4
4
  "description": "Self-maintaining LLM Wiki for Pi — Karpathy-pattern knowledge base with immutable source capture, automated ingestion, search, linting, and Obsidian-compatible vault. auto-updating personal & company wiki.",
5
5
  "keywords": [
6
6
  "pi",
@@ -15,13 +15,14 @@ $ARGUMENTS
15
15
 
16
16
  ## Steps
17
17
 
18
- 1. Read `wiki/LOG.md` filter entries since last digest
19
- 2. Read pages created/updated in that period
18
+ 1. Call `wiki_status()` to get current stats (page count, orphans, gaps, health).
19
+ 2. Read `.llm-wiki/meta/log.md` for recent events since the last digest period.
20
20
  3. Summarize:
21
- - New sources ingested
22
- - New pages created
23
- - Key insights or connections
21
+ - New sources captured
22
+ - New pages created or updated
23
+ - Key insights or connections made
24
24
  - Knowledge gaps identified
25
- - Health trends
26
- 4. Save `outputs/digest-YYYY-MM-DD.md`
27
- 5. Report concise digest
25
+ - Health trends (improving, stable, declining)
26
+ 4. Save the digest to `.llm-wiki/outputs/digest-YYYY-MM-DD.md` using the `write` tool.
27
+ 5. Call `wiki_log_event(kind=digest)` to record this digest was generated.
28
+ 6. Report a concise digest to the user.
@@ -7,27 +7,24 @@ topLevelCli: true
7
7
 
8
8
  # /wiki-discover
9
9
 
10
- Find new source material for the wiki by searching the web.
10
+ Find new source material for the wiki by searching the web and capturing them as source packets.
11
11
 
12
12
  ## User Arguments
13
13
 
14
14
  $ARGUMENTS
15
15
 
16
- Read the LLM Wiki skill at `.pi/skills/llm-wiki/SKILL.md` first. Also read `config.yaml` for topics and feeds.
17
-
18
16
  ## Steps
19
17
 
20
- 1. Read `.llm-wiki/config.yaml` extract topics, keywords, feeds
21
- 2. Read `.llm-wiki/.discoveries/gaps.json` knowledge gaps to fill
22
- 3. Read `.llm-wiki/.discoveries/history.json` already-fetched URLs
23
- 4. Search for new sources:
24
- - Web search each topic + latest keywords
25
- - Search for gaps from `.llm-wiki/.discoveries/gaps.json`
26
- - If `--topic` specified, focus search on that topic
27
- 5. For each promising result:
28
- a. Fetch full content
29
- b. Save to `.llm-wiki/raw/articles/YYYY-MM-DD-slug.md` with frontmatter (title, url, discovered, topic)
30
- 6. Update `.llm-wiki/.discoveries/history.json`
31
- 7. Report: "Discovered [N] new sources. Run `/wiki-ingest` to process them."
32
-
33
- **Rules:** Max 5-10 sources. Skip ads, listicles, duplicates. Prefer in-depth analysis.
18
+ 1. Call `wiki_status()` to get the current topic and mode from the wiki config.
19
+ 2. Use `wiki_search(query=<topic>)` to find existing pages and identify what's already covered.
20
+ 3. Search the web for new sources:
21
+ - If `--topic` is specified in `$ARGUMENTS`, focus on that topic
22
+ - Otherwise, search for the wiki's main topic + "latest", "news", "update"
23
+ 4. For each promising result (max 5-10):
24
+ a. Call `wiki_capture_source(url=<url>)` to capture it as an immutable source packet
25
+ b. Skip ads, listicles, and duplicates — prefer in-depth analysis
26
+ 5. Report: "Discovered [N] new sources captured as packets. Run `/wiki-ingest` to synthesize them into knowledge pages."
27
+
28
+ **Rules:**
29
+ - Do NOT manually save files to `raw/` always use `wiki_capture_source`.
30
+ - The extension handles manifest, extraction, and skeleton page creation automatically.
@@ -1,34 +1,33 @@
1
1
  ---
2
- description: Process new source files in raw/ and update the wiki. Creates summaries, entities, concepts, and cross-references.
3
- argument-hint: "[path]"
2
+ description: Process new source packets and synthesize them into wiki knowledge pages.
3
+ argument-hint: "[source_id]"
4
4
  section: LLM Wiki
5
5
  topLevelCli: true
6
6
  ---
7
7
 
8
8
  # /wiki-ingest
9
9
 
10
- Process new files in `.llm-wiki/raw/` and integrate them into the wiki.
10
+ Process uningested source packets and synthesize them into wiki knowledge pages.
11
11
 
12
12
  ## User Arguments
13
13
 
14
14
  $ARGUMENTS
15
15
 
16
- Read the LLM Wiki skill at `.pi/skills/llm-wiki/SKILL.md` first to understand the full schema, page formats, and conventions.
17
-
18
16
  ## Steps
19
17
 
20
- 1. Read `.llm-wiki/config.yaml` and `.llm-wiki/.discoveries/history.json`
21
- 2. If a specific path is given (e.g., `/wiki-ingest .llm-wiki/raw/articles/my-file.md`), process just that file
22
- 3. If no path given, scan all files in `.llm-wiki/raw/` (respecting `.gitignore` — skip any matched files) and find ones not in history
23
- 4. For each new source:
24
- a. Read the full content
25
- b. Briefly discuss with the user: "This is about [topic]. Key points: [summary]. Any specific emphasis?"
26
- c. Create/update pages in `.llm-wiki/wiki/sources/`, `.llm-wiki/wiki/entities/`, `.llm-wiki/wiki/concepts/`
27
- d. Add `[[wikilinks]]` cross-references between related pages
28
- e. Flag any contradictions with existing wiki content
29
- 5. Update `.llm-wiki/wiki/INDEX.md` with all new/updated pages
30
- 6. Append to `.llm-wiki/wiki/LOG.md`
31
- 7. Update `.llm-wiki/.discoveries/history.json`
32
- 8. Report: "Ingested [N] sources → [M] pages created/updated. [X] contradictions flagged."
33
-
34
- **Rules:** Never modify raw/ files. Never fabricate information. Always cite sources.
18
+ 1. Call `wiki_ingest(source_id=<id if provided>, batch_size=3)` to get sources needing synthesis.
19
+ 2. If the tool reports "All sources ingested", inform the user and stop.
20
+ 3. For each source in the returned batch:
21
+ a. Read the extracted text from `raw/sources/<SOURCE_ID>/extracted.md`
22
+ b. Update the skeleton source page in `wiki/sources/` with a proper summary, key entities, and concepts
23
+ c. Use `wiki_ensure_page(type=entity, title=<name>)` for each new entity (people, orgs, tools, products)
24
+ d. Use `wiki_ensure_page(type=concept, title=<name>)` for each new concept (ideas, patterns, frameworks)
25
+ e. Add `[[wikilinks]]` cross-references between related pages
26
+ f. Flag any contradictions with existing wiki content using `⚠️ **Contradiction**` markers
27
+ 4. After processing the batch, call `wiki_rebuild_meta` to update metadata.
28
+ 5. Report: "Ingested [N] sources → [M] pages created/updated. [X] contradictions flagged."
29
+
30
+ **Rules:**
31
+ - Never modify files in `raw/` — source packets are immutable after capture.
32
+ - Never fabricate information always cite sources with `[[sources/SRC-...]]`.
33
+ - The extension auto-updates metadata — you do NOT need to manually edit `meta/` files.
@@ -7,28 +7,24 @@ topLevelCli: true
7
7
 
8
8
  # /wiki-init
9
9
 
10
- Initialize a new LLM Wiki in the current directory.
10
+ Initialize a new LLM Wiki vault using the `wiki_bootstrap` tool.
11
11
 
12
12
  ## User Arguments
13
13
 
14
14
  $ARGUMENTS
15
15
 
16
- Read the LLM Wiki skill at `.pi/skills/llm-wiki/SKILL.md` (or wherever the skill is installed) first to understand the full schema and conventions.
17
-
18
16
  ## Steps
19
17
 
20
- 1. Ask the user for the wiki topic and mode (`personal` or `company`)
21
- 2. Create the directory structure:
22
- - `.llm-wiki/raw/articles/`, `.llm-wiki/raw/papers/`, `.llm-wiki/raw/notes/`, `.llm-wiki/raw/assets/`
23
- - `.llm-wiki/wiki/entities/`, `.llm-wiki/wiki/concepts/`, `.llm-wiki/wiki/sources/`, `.llm-wiki/wiki/syntheses/`, `.llm-wiki/wiki/changes/`
24
- - `.llm-wiki/outputs/`
25
- - `.llm-wiki/.discoveries/`
26
- 3. Create `.llm-wiki/config.yaml` with the topic, mode, and default settings
27
- 4. Create `.llm-wiki/wiki/INDEX.md` with section headings organized by page type
28
- 5. Create `.llm-wiki/wiki/LOG.md` with initial entry
29
- 6. Create `.llm-wiki/wiki/DASHBOARD.md` with Dataview queries for Obsidian
30
- 7. Create `.gitignore` to exclude `.llm-wiki/outputs/` from version control if desired
31
- 8. Initialize git repo if not already present
32
- 9. Report the structure and suggest first steps: "Drop sources into `.llm-wiki/raw/` and run `/wiki-ingest`"
33
-
34
- If `--mode company`, add the `change_detection: true` flag to config.yaml and add a `.llm-wiki/wiki/decisions/` folder.
18
+ 1. If the user provided a topic in `$ARGUMENTS`, use it. Otherwise, ask the user for the wiki **topic**.
19
+ 2. Determine mode: default to `personal`; use `company` if the user specifies `--mode company` or requests it.
20
+ 3. Call `wiki_bootstrap(topic=<topic>, mode=<mode>)` to create the vault.
21
+ 4. Report the result and suggest next steps:
22
+ - "Use `wiki_capture_source` to add your first source (URL, file, or text)."
23
+ - "Run `/wiki-ingest` after capturing sources to synthesize them into knowledge pages."
24
+
25
+ **Do NOT manually create directories or files.** The `wiki_bootstrap` tool handles all scaffolding including:
26
+ - `.llm-wiki/raw/sources/` immutable source packets
27
+ - `.llm-wiki/wiki/` editable knowledge pages
28
+ - `.llm-wiki/meta/` auto-generated metadata
29
+ - `.llm-wiki/config.json` vault configuration
30
+ - `.llm-wiki/WIKI_SCHEMA.md` operating rules
@@ -13,21 +13,13 @@ Run a comprehensive health check on the wiki.
13
13
 
14
14
  $ARGUMENTS
15
15
 
16
- Read the LLM Wiki skill at `.pi/skills/llm-wiki/SKILL.md` first to understand the full schema and conventions.
17
-
18
16
  ## Steps
19
17
 
20
- 1. Scan all files in `.llm-wiki/wiki/` (respecting `.gitignore` skip any matched files)
21
- 2. Check for:
22
- - **Contradictions:** Conflicting claims between pages
23
- - **Orphans:** Pages with zero inbound `[[wikilinks]]`
24
- - **Missing pages:** `[[links]]` pointing to non-existent files
25
- - **Stale claims:** Info superseded by newer sources
26
- - **Broken raw links:** References to `.llm-wiki/raw/` files that don't exist
27
- - **Knowledge gaps:** Topics mentioned but lacking their own page
28
- - **Quality:** Pages under 3 lines, pages with no sources or cross-refs
29
- 3. If `--fix` flag is present: auto-fix broken links, create missing pages for frequently-linked concepts, add cross-refs to orphans. Flag contradictions for human decision.
30
- 4. Save report → `.llm-wiki/outputs/lint-YYYY-MM-DD.md`
31
- 5. Update `.llm-wiki/.discoveries/gaps.json`
32
- 6. Append to `.llm-wiki/wiki/LOG.md`
33
- 7. Report key findings
18
+ 1. Determine if auto-fix is requested: set `auto_fix=true` if `$ARGUMENTS` contains `--fix`, otherwise `false`.
19
+ 2. Call `wiki_lint(auto_fix=<true/false>)` to run the health check.
20
+ 3. Present the lint report to the user, including:
21
+ - Page count, orphans, missing pages, contradictions
22
+ - Knowledge gaps found
23
+ - Any auto-fixes applied
24
+ 4. If contradictions are found, flag them for human review — do NOT auto-resolve contradictions.
25
+ 5. If knowledge gaps are identified, suggest creating pages for frequently-mentioned topics.
@@ -13,24 +13,25 @@ Ask a question and get an answer synthesized from wiki content.
13
13
 
14
14
  $ARGUMENTS
15
15
 
16
- Read the LLM Wiki skill at `.pi/skills/llm-wiki/SKILL.md` first to understand the full schema and conventions.
17
-
18
16
  ## Steps
19
17
 
20
- 1. Read `wiki/INDEX.md` to find pages relevant to the question
21
- 2. Read those pages in full (don't stop at 1-2 pages get thorough context)
22
- 3. Synthesize an answer with `[[wikilink]]` citations to specific wiki pages
23
- 4. If the answer reveals a new connection or analysis, save it as a synthesis page in `wiki/syntheses/`
24
- 5. Append to `wiki/LOG.md`
18
+ 1. Call `wiki_recall(query=<question>)` to find relevant wiki pages.
19
+ 2. Read the full content of each matching page using the `read` tool.
20
+ 3. Synthesize an answer with `[[wikilink]]` citations to specific wiki pages.
21
+ 4. If the answer reveals a new connection or analysis worth preserving:
22
+ - Call `wiki_ensure_page(type=synthesis, title=<title>, content=<content>)` to save it
23
+ 5. Call `wiki_log_event(kind=query, details={question: <question>})` to log the query.
25
24
 
26
- **Rules:** Answer ONLY from wiki content, not from general knowledge. If the wiki lacks information, say so clearly and suggest what sources would help fill the gap.
25
+ **Rules:**
26
+ - Answer ONLY from wiki content, not from general knowledge.
27
+ - If the wiki lacks information, say so clearly and suggest what sources would help fill the gap.
27
28
 
28
29
  **Example:**
29
30
 
30
31
  ```
31
32
  /wiki-query What are the key differences between RAG and LLM Wiki?
32
- Reads INDEX.md, finds pages on RAG and LLM Wiki patterns
33
- → Reads both pages
34
- → Synthesizes a comparison table with [[wikilink]] citations
35
- → Saves as wiki/syntheses/rag-vs-llm-wiki.md
33
+ Calls wiki_recall(query="RAG LLM Wiki differences")
34
+ → Reads matching pages
35
+ → Synthesizes a comparison with [[wikilink]] citations
36
+ → Saves as synthesis page via wiki_ensure_page(type=synthesis, ...)
36
37
  ```
@@ -1,5 +1,5 @@
1
1
  ---
2
- description: Save an atomic insight from the current task into the wiki. Creates a source packet and source page for future auto-recall.
2
+ description: Save an atomic insight from the current task into the wiki. Creates a single markdown file that layered recall surfaces in future sessions.
3
3
  argument-hint: "<title> [--category <category>]"
4
4
  section: LLM Wiki
5
5
  topLevelCli: true
@@ -9,7 +9,7 @@ topLevelCli: true
9
9
 
10
10
  Save an atomic insight from a completed task into the wiki.
11
11
 
12
- Captures what you learned as an immutable source packet + wiki source page so that `wiki_recall` automatically surfaces it in future sessions.
12
+ Captures what you learned as a single markdown file so that layered recall surfaces it in future sessions.
13
13
 
14
14
  ## User Arguments
15
15
 
@@ -25,7 +25,7 @@ Read the LLM Wiki skill at `.pi/skills/llm-wiki/SKILL.md` first to understand th
25
25
  - `title`: short descriptive phrase, ≤60 chars, noun phrase not a sentence
26
26
  - `body`: markdown explanation with `[[wikilinks]]` to related wiki pages
27
27
  - `category`: optional (frontend, architecture, devops, bugfix, design, etc.)
28
- 3. Confirm the insight was saved and will be auto-surfaced in future sessions
28
+ 3. Confirm the insight was saved and will be surfaced by layered recall in future sessions
29
29
  4. If the insight relates to existing wiki pages, update those pages with cross-references
30
30
 
31
31
  **Rules:**
@@ -13,27 +13,17 @@ Run the complete wiki maintenance cycle: discover new sources, ingest them, and
13
13
 
14
14
  $ARGUMENTS
15
15
 
16
- Read the LLM Wiki skill at `.pi/skills/llm-wiki/SKILL.md` first.
17
-
18
16
  ## Steps
19
17
 
20
- 1. Run `/wiki-discover` find new sources
21
- 2. Run `/wiki-ingest` process all new files
22
- 3. Run `/wiki-lint` health check
23
- 4. If critical gaps found → optionally one more discover+ingest cycle
24
- 5. Save summary `outputs/run-YYYY-MM-DD.md`
25
- 6. Report final summary
18
+ 1. **Discover:** Use web search to find new sources on the wiki's topic, then capture each with `wiki_capture_source(url=<url>)` (max 5-10).
19
+ 2. **Ingest:** Call `wiki_ingest(batch_size=3)` and process returned sources — read extracted.md, update source pages, create entity/concept pages, add cross-references.
20
+ 3. **Lint:** Call `wiki_lint(auto_fix=false)` to run a health check.
21
+ 4. If critical gaps found → optionally run one more discover+ingest cycle.
22
+ 5. Save summary to `.llm-wiki/outputs/run-YYYY-MM-DD.md` using the `write` tool.
23
+ 6. Report final summary.
26
24
 
27
25
  ### Scheduling
28
26
 
29
- If `--schedule daily` is used, use `schedule_prompt` to set up daily runs:
30
-
31
- ```
32
- schedule_prompt action=add schedule="0 0 8 * * *" prompt="Run /wiki-run for the LLM Wiki"
33
- ```
34
-
35
- If `--schedule weekly` is used:
27
+ If `--schedule` is provided, call `wiki_watch(interval=<daily|weekly>)` to set up automatic updates.
36
28
 
37
- ```
38
- schedule_prompt action=add schedule="0 0 9 * * 1" prompt="Run /wiki-run for the LLM Wiki"
39
- ```
29
+ If `--schedule hourly` is provided, call `wiki_watch(interval=hourly)`.
@@ -11,23 +11,6 @@ Show a quick overview of wiki health and statistics.
11
11
 
12
12
  ## Steps
13
13
 
14
- 1. Count sources in `.llm-wiki/raw/` (recursive, respecting `.gitignore`)
15
- 2. Count pages in `.llm-wiki/wiki/` (by type: entities, concepts, sources, syntheses, respecting `.gitignore`)
16
- 3. Check `.llm-wiki/wiki/LOG.md` for last ingest, lint, and discover dates
17
- 4. Check for orphan pages (zero inbound links)
18
- 5. Read `.llm-wiki/.discoveries/gaps.json` for known gaps
19
- 6. Report:
20
-
21
- ```
22
- 📊 LLM Wiki Status
23
- ══════════════════
24
- Wiki Root: [topic1], [topic2]
25
- Mode: Personal | Company
26
- Sources: [N] files
27
- Wiki Pages: [N] total ([E] entities, [C] concepts, [S] sources, [Y] syntheses)
28
- Last Ingest: YYYY-MM-DD
29
- Last Lint: YYYY-MM-DD
30
- Orphans: [N]
31
- Knowledge Gaps: [N]
32
- Health: ✅ Good | ⚠️ Warning | 🔴 Needs Attention
33
- ```
14
+ 1. Call `wiki_status()` to get the current wiki health report.
15
+ 2. Present the results to the user.
16
+ 3. If health shows warnings (orphans > 5, many gaps), suggest running `/wiki-lint` for a detailed analysis.
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  name: llm-wiki
3
3
  description: Build and maintain a persistent, interlinked Obsidian-compatible markdown wiki using Karpathy's LLM Wiki pattern. Extension-backed with auto-generated metadata, guardrails, and 12 custom tools.
4
+ whenToUse: Call wiki_recall at task start to find relevant wiki pages. Call wiki_retro at task end to save new insights. The extension injects a brief status line, but explicit wiki_recall calls with task-specific terms get better results.
4
5
  ---
5
6
 
6
7
  # LLM Wiki for Pi
@@ -55,39 +56,53 @@ WIKI_ROOT/
55
56
  | Find orphans | Shell `grep` scans | Instant from `backlinks.json` |
56
57
  | Block raw edits | Skill says "don't" | Extension **enforces** immutability |
57
58
  | Create source page | 8 tool calls | `wiki_capture_source` + LLM synthesis |
58
- | **Recall wiki knowledge** | Never happens | **Auto-search before every turn** |
59
+ | **Recall wiki knowledge** | Never happens | **Layered search before every turn (personal + project)** |
59
60
  | **Save task insights** | Manual capture | `wiki_retro` — one tool call |
60
61
 
61
- ## 🔄 Auto-Recall (New)
62
+ ## 🔄 Wiki Usage
62
63
 
63
- **The extension now automatically searches the wiki before every user turn.**
64
+ ### At Start Call wiki_recall
64
65
 
65
- When you send a prompt, the extension:
66
- 1. Extracts key terms from your request
67
- 2. Searches the wiki registry for matching pages
68
- 3. Injects matching page titles + summaries into context
69
- 4. You see this as "Relevant Wiki Knowledge" in your system prompt
66
+ **Call `wiki_recall` at the START of every task** to find relevant wiki pages:
70
67
 
71
- **This means the wiki works as an automatic second brain.**
72
- You don't need to remember to search — relevant knowledge is surfaced automatically.
68
+ ```
69
+ wiki_recall(query="key terms from the user's request", max_results=5)
70
+ ```
71
+
72
+ This searches both your **personal wiki** (`~/.llm-wiki/`) and the **project wiki** (`.llm-wiki/` in the current directory), merging results.
73
+
74
+ The extension also briefly searches automatically, but explicit calls with task-specific terms get better results.
75
+
76
+ ### At End — Save Insights with wiki_retro
73
77
 
74
- ### Manual recall for deeper searches
78
+ After completing any meaningful task, call `wiki_retro` to save key insights:
79
+ - Non-obvious bug fixes or workarounds
80
+ - Architectural decisions and their rationale
81
+ - Tool/library gotchas you discovered
82
+ - Patterns worth remembering for future sessions
75
83
 
76
- If the auto-recall doesn't find enough context, call `wiki_recall` explicitly:
84
+ **Do not wait for the user to ask.** Save insights proactively one atomic insight per call.
77
85
 
78
86
  ```
79
- wiki_recall(query="specific terms...", max_results=10)
87
+ wiki_retro(slug="kebab-case-slug", title="Brief descriptive title", body="Insight in your own words with [[wikilinks]]")
80
88
  ```
81
89
 
82
- This gives you more control over the search terms and returns content previews.
90
+ ### Deeper Searches
83
91
 
84
- ### No Wiki Yet
92
+ For thorough research, also use `wiki_search` to browse the full registry:
85
93
 
86
- If the extension injects a "No LLM Wiki found" hint, use `ask_user` to offer creating one:
94
+ ```
95
+ wiki_search(query="broad topic")
96
+ ```
97
+
98
+ ### Auto-Bootstrap (One-Time)
87
99
 
88
- > "No LLM Wiki found in this directory. Would you like to create one? It gives you a linked knowledge base with automatic recall."
100
+ The extension creates the wiki vault automatically on startup. On the first turn, it injects a directive asking you to infer topic and mode, then call:
101
+ ```
102
+ wiki_bootstrap(topic="...", mode="personal|company")
103
+ ```
89
104
 
90
- If the user agrees, call `wiki_bootstrap(topic="...", mode="personal")`. Suggest only once per session.
105
+ This is a one-time step.
91
106
 
92
107
  ## Available Tools
93
108
 
@@ -95,7 +110,7 @@ Use these directly — they handle scaffolding, bookkeeping, recall, and capture
95
110
 
96
111
  - `wiki_bootstrap` — Initialize a new vault
97
112
  - `wiki_capture_source` — Capture URL/file/text into immutable packet + skeleton page
98
- - `wiki_recall` — **Auto-called at turn start.** Search wiki for task-relevant pages
113
+ - `wiki_recall` — Search both personal + project wikis for task-relevant pages
99
114
  - `wiki_retro` — Save an atomic insight from a completed task into the wiki
100
115
  - `wiki_ingest` — Get batch of uningested sources with extracted text
101
116
  - `wiki_ensure_page` — Create entity/concept/synthesis/analysis page from template
@@ -120,19 +135,20 @@ Use these directly — they handle scaffolding, bookkeeping, recall, and capture
120
135
 
121
136
  ### Query → Answer → File
122
137
 
123
- 1. **Auto-recall**: Extension surfaces relevant wiki pages automatically
124
- 2. Read those pages
125
- 3. Synthesize answer with `[[wikilink]]` citations
126
- 4. If novel: create analysis page via `wiki_ensure_page(type="analysis")`
127
- 5. Extension auto-updates metadata
138
+ 1. **Layered recall**: Extension searches personal + project vaults, injects matching pages with vault labels
139
+ 2. For better results: call `wiki_recall` explicitly with task-specific terms
140
+ 3. Read those pages
141
+ 4. Synthesize answer with `[[wikilink]]` citations
142
+ 5. If novel: create analysis page via `wiki_ensure_page(type="analysis")`
143
+ 6. Extension auto-updates metadata
128
144
 
129
145
  ### Task → Capture → Retro
130
146
 
131
147
  1. Complete a meaningful task
132
148
  2. Call `wiki_retro` to save key insights
133
- 3. The insight is captured as a source packet
149
+ 3. The insight is saved as a single markdown file
134
150
  4. Extension auto-updates metadata
135
- 5. Next time, auto-recall surfaces your saved insight
151
+ 5. Next time, layered recall surfaces your saved insight
136
152
 
137
153
  ## Page Conventions
138
154