@zosmaai/pi-llm-wiki 0.9.2 → 0.9.3

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.
@@ -2,6 +2,7 @@ import { existsSync, readFileSync, writeFileSync } from "node:fs";
2
2
  import { basename, join } from "node:path";
3
3
  import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
4
4
  import { installGuardrails } from "./lib/guardrails.js";
5
+ import { appendWikiStatus } from "./lib/inject.js";
5
6
  import { registerWikiModelCommand } from "./lib/model-command.js";
6
7
  import {
7
8
  buildSessionNotice,
@@ -295,8 +296,7 @@ Then call wiki_bootstrap with the inferred topic and mode to finalize the setup.
295
296
 
296
297
  // Always inject a visible wiki status footer, even when empty
297
298
  // This ensures the model knows the wiki is active and can use it
298
- injectedContext +=
299
- "\n\n<wiki_status>LLM Wiki active — use wiki_recall for deeper search, wiki_observe to record observations, wiki_retro to save insights.</wiki_status>";
299
+ injectedContext = appendWikiStatus(injectedContext);
300
300
 
301
301
  if (injectedContext === event.systemPrompt) return;
302
302
  return { systemPrompt: injectedContext };
@@ -0,0 +1,27 @@
1
+ /**
2
+ * System-prompt context injection primitives (issue #87).
3
+ *
4
+ * The `before_agent_start` hook augments the chained system prompt with a
5
+ * visible wiki-status footer. This module isolates that append so it can be
6
+ * unit-tested for idempotency — a turn that aborts (network error / ESC) and is
7
+ * retried can carry the prior injection forward, and a naive append stacks the
8
+ * footer 2x, 3x, ...
9
+ */
10
+
11
+ /** The always-injected wiki-status footer (sans surrounding whitespace). */
12
+ export const WIKI_STATUS_BLOCK =
13
+ "<wiki_status>LLM Wiki active — use wiki_recall for deeper search, wiki_observe to record observations, wiki_retro to save insights.</wiki_status>";
14
+
15
+ /**
16
+ * Append the wiki-status footer to a system prompt — idempotently (issue #87).
17
+ *
18
+ * Strips any already-present footer (with its leading blank line) before
19
+ * appending exactly one. This makes the injection safe across aborted/retried
20
+ * agent starts that carry the prior injection forward in the chained system
21
+ * prompt, so the footer never stacks (2x, 3x, ...).
22
+ * See test/inject-idempotent.test.ts.
23
+ */
24
+ export function appendWikiStatus(systemPrompt: string): string {
25
+ const base = systemPrompt.split(`\n\n${WIKI_STATUS_BLOCK}`).join("");
26
+ return `${base}\n\n${WIKI_STATUS_BLOCK}`;
27
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zosmaai/pi-llm-wiki",
3
- "version": "0.9.2",
3
+ "version": "0.9.3",
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",