@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.
- package/CHANGELOG.md +4 -0
- package/README.de.md +35 -4
- package/README.es.md +260 -170
- package/README.fr.md +35 -4
- package/README.hi.md +35 -4
- package/README.ja.md +35 -4
- package/README.ko.md +35 -4
- package/README.md +38 -3
- package/README.pt.md +35 -4
- package/README.ru.md +35 -4
- package/README.zh.md +260 -170
- package/assets/demo.gif +0 -0
- package/dist/extensions/llm-wiki/lib/bootstrap.js +71 -0
- package/dist/extensions/llm-wiki/lib/embeddings.js +401 -0
- package/dist/extensions/llm-wiki/lib/guardrails.js +232 -0
- package/dist/extensions/llm-wiki/lib/indexing.js +78 -0
- package/dist/extensions/llm-wiki/lib/ingest-worker.js +310 -0
- package/dist/extensions/llm-wiki/lib/inject.js +65 -0
- package/dist/extensions/llm-wiki/lib/knowledge-document.js +442 -0
- package/dist/extensions/llm-wiki/lib/knowledge-links.js +206 -0
- package/dist/extensions/llm-wiki/lib/legacy-repair.js +443 -0
- package/dist/extensions/llm-wiki/lib/metadata.js +499 -0
- package/dist/extensions/llm-wiki/lib/model-command.js +86 -0
- package/dist/extensions/llm-wiki/lib/observation.js +283 -0
- package/dist/extensions/llm-wiki/lib/recall.js +875 -0
- package/dist/extensions/llm-wiki/lib/retro.js +158 -0
- package/dist/extensions/llm-wiki/lib/runtime.js +191 -0
- package/dist/extensions/llm-wiki/lib/source-extractors.js +426 -0
- package/dist/extensions/llm-wiki/lib/source-packet.js +229 -0
- package/dist/extensions/llm-wiki/lib/subagent.js +41 -0
- package/dist/extensions/llm-wiki/lib/task-config.js +172 -0
- package/dist/extensions/llm-wiki/lib/tools.js +1192 -0
- package/dist/extensions/llm-wiki/lib/trajectories-command.js +51 -0
- package/dist/extensions/llm-wiki/lib/trajectory.js +467 -0
- package/dist/extensions/llm-wiki/lib/utils.js +347 -0
- package/dist/extensions/llm-wiki/lib/vault-format.js +247 -0
- package/dist/extensions/llm-wiki/lib/visible-status.js +31 -0
- package/dist/extensions/llm-wiki/lib/wiki-service.js +128 -0
- package/dist/mcp/exec.js +121 -0
- package/dist/mcp/index.js +229 -0
- package/dist/mcp/operations.js +130 -0
- package/dist/package.json +1 -0
- package/docs/superpowers/plans/2026-08-02-okf-foundation.md +1579 -0
- package/docs/superpowers/plans/2026-08-03-okf-foundation-remediation.md +3005 -0
- package/docs/superpowers/plans/2026-08-06-okf-foundation-release-remediation.md +1174 -0
- package/docs/superpowers/specs/2026-08-02-okf-foundation-design.md +578 -0
- package/docs/superpowers/specs/2026-08-02-okf-v0.2-interoperability-design.md +538 -0
- package/extensions/llm-wiki/index.ts +22 -36
- package/extensions/llm-wiki/lib/bootstrap.ts +84 -0
- package/extensions/llm-wiki/lib/embeddings.ts +9 -3
- package/extensions/llm-wiki/lib/guardrails.ts +174 -29
- package/extensions/llm-wiki/lib/indexing.ts +2 -1
- package/extensions/llm-wiki/lib/ingest-worker.ts +170 -29
- package/extensions/llm-wiki/lib/knowledge-document.ts +661 -0
- package/extensions/llm-wiki/lib/knowledge-links.ts +282 -0
- package/extensions/llm-wiki/lib/legacy-repair.ts +572 -0
- package/extensions/llm-wiki/lib/metadata.ts +531 -116
- package/extensions/llm-wiki/lib/observation.ts +37 -43
- package/extensions/llm-wiki/lib/recall.ts +61 -33
- package/extensions/llm-wiki/lib/retro.ts +65 -41
- package/extensions/llm-wiki/lib/source-extractors.ts +12 -17
- package/extensions/llm-wiki/lib/source-packet.ts +44 -31
- package/extensions/llm-wiki/lib/tools.ts +406 -348
- package/extensions/llm-wiki/lib/trajectory.ts +15 -1
- package/extensions/llm-wiki/lib/utils.ts +121 -130
- package/extensions/llm-wiki/lib/vault-format.ts +363 -0
- package/extensions/llm-wiki/lib/wiki-service.ts +183 -0
- package/mcp/exec.ts +122 -0
- package/mcp/index.ts +60 -250
- package/mcp/operations.ts +176 -0
- package/package.json +8 -2
- package/scripts/migrate-llm-wiki.js +801 -0
- package/skills/llm-wiki/SKILL.md +8 -6
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { getAgentDir } from "@mariozechner/pi-coding-agent";
|
|
4
|
+
export const TASK_DEFAULTS = {};
|
|
5
|
+
/**
|
|
6
|
+
* Resolve whether user-facing wiki notices are enabled (issue #77). Defaults
|
|
7
|
+
* to `true`; only an explicit `notices: false` disables them.
|
|
8
|
+
*/
|
|
9
|
+
export function noticesEnabled(config) {
|
|
10
|
+
return config?.notices !== false;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Resolve whether agent-trajectory working-memory is enabled (issue #80).
|
|
14
|
+
* INVERSE polarity of `noticesEnabled`: defaults to `false`; only an explicit
|
|
15
|
+
* `trajectories: true` turns it on.
|
|
16
|
+
*/
|
|
17
|
+
export function trajectoriesEnabled(config) {
|
|
18
|
+
return config?.trajectories === true;
|
|
19
|
+
}
|
|
20
|
+
const SETTINGS_KEY = "llm-wiki";
|
|
21
|
+
function readModelSpec(value) {
|
|
22
|
+
if (!value || typeof value !== "object")
|
|
23
|
+
return undefined;
|
|
24
|
+
const v = value;
|
|
25
|
+
if (typeof v.provider === "string" && typeof v.id === "string" && v.provider && v.id) {
|
|
26
|
+
return { provider: v.provider, id: v.id };
|
|
27
|
+
}
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
function readNamespacedConfig(path) {
|
|
31
|
+
try {
|
|
32
|
+
const raw = readSettingsObject(path);
|
|
33
|
+
const nested = raw[SETTINGS_KEY];
|
|
34
|
+
if (!nested || typeof nested !== "object")
|
|
35
|
+
return {};
|
|
36
|
+
const section = nested;
|
|
37
|
+
const out = {};
|
|
38
|
+
const taskModel = readModelSpec(section.taskModel);
|
|
39
|
+
if (taskModel)
|
|
40
|
+
out.taskModel = taskModel;
|
|
41
|
+
for (const key of [
|
|
42
|
+
"embeddingProvider",
|
|
43
|
+
"embeddingModel",
|
|
44
|
+
"embeddingBaseUrl",
|
|
45
|
+
"embeddingApiKey",
|
|
46
|
+
"embeddingApiKeyEnv",
|
|
47
|
+
]) {
|
|
48
|
+
const value = section[key];
|
|
49
|
+
if (typeof value === "string" && value.trim())
|
|
50
|
+
out[key] = value.trim();
|
|
51
|
+
}
|
|
52
|
+
const weight = section.semanticWeight;
|
|
53
|
+
if (typeof weight === "number" && Number.isFinite(weight)) {
|
|
54
|
+
out.semanticWeight = Math.min(1, Math.max(0, weight));
|
|
55
|
+
}
|
|
56
|
+
const threshold = section.recallLinksThreshold;
|
|
57
|
+
if (typeof threshold === "number" && Number.isFinite(threshold)) {
|
|
58
|
+
out.recallLinksThreshold = Math.max(0, Math.floor(threshold));
|
|
59
|
+
}
|
|
60
|
+
const inlineMax = section.recallSkillInlineMax;
|
|
61
|
+
if (typeof inlineMax === "number" && Number.isFinite(inlineMax)) {
|
|
62
|
+
out.recallSkillInlineMax = Math.max(0, Math.floor(inlineMax));
|
|
63
|
+
}
|
|
64
|
+
if (typeof section.notices === "boolean") {
|
|
65
|
+
out.notices = section.notices;
|
|
66
|
+
}
|
|
67
|
+
if (typeof section.trajectories === "boolean") {
|
|
68
|
+
out.trajectories = section.trajectories;
|
|
69
|
+
}
|
|
70
|
+
return out;
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
return {};
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Parse a `"provider/id"` model reference (issue #69). Splits on the FIRST
|
|
78
|
+
* slash so model ids that themselves contain slashes (e.g.
|
|
79
|
+
* `openrouter/meta/llama-3`) are preserved. Returns `undefined` for empty,
|
|
80
|
+
* slashless, or partial (`provider/` / `/id`) refs so callers can reject bad
|
|
81
|
+
* input. Whitespace is trimmed.
|
|
82
|
+
*/
|
|
83
|
+
export function parseModelRef(ref) {
|
|
84
|
+
const trimmed = ref.trim();
|
|
85
|
+
const slash = trimmed.indexOf("/");
|
|
86
|
+
if (slash <= 0)
|
|
87
|
+
return undefined;
|
|
88
|
+
const provider = trimmed.slice(0, slash).trim();
|
|
89
|
+
const id = trimmed.slice(slash + 1).trim();
|
|
90
|
+
if (!provider || !id)
|
|
91
|
+
return undefined;
|
|
92
|
+
return { provider, id };
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Read a settings JSON file as a plain object, or `{}` when it is absent or
|
|
96
|
+
* corrupt. Reads directly (no `existsSync` pre-check) so there is no
|
|
97
|
+
* check-then-use race: a missing file throws ENOENT, which the catch treats
|
|
98
|
+
* the same as an empty file.
|
|
99
|
+
*/
|
|
100
|
+
function readSettingsObject(path) {
|
|
101
|
+
try {
|
|
102
|
+
const parsed = JSON.parse(readFileSync(path, "utf-8"));
|
|
103
|
+
if (parsed && typeof parsed === "object")
|
|
104
|
+
return parsed;
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
// Missing or corrupt settings file: start from an empty object.
|
|
108
|
+
}
|
|
109
|
+
return {};
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Persist (or clear) the wiki background `taskModel` in the PROJECT settings
|
|
113
|
+
* file `<cwd>/.pi/settings.json` under the namespaced `llm-wiki` key (issue
|
|
114
|
+
* #69). Project settings win over global in `loadTaskConfig`, so this takes
|
|
115
|
+
* effect immediately on the next config load. Other top-level keys and other
|
|
116
|
+
* `llm-wiki` settings are preserved; passing `undefined` removes the key
|
|
117
|
+
* (reverting to the session model).
|
|
118
|
+
*/
|
|
119
|
+
export function persistTaskModel(cwd, model) {
|
|
120
|
+
const settingsPath = join(cwd, ".pi", "settings.json");
|
|
121
|
+
const raw = readSettingsObject(settingsPath);
|
|
122
|
+
const existing = raw[SETTINGS_KEY];
|
|
123
|
+
const section = existing && typeof existing === "object" ? { ...existing } : {};
|
|
124
|
+
if (model) {
|
|
125
|
+
section.taskModel = { provider: model.provider, id: model.id };
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
// biome-ignore lint/performance/noDelete: one-off settings rewrite, not a hot path; removing the key (vs setting undefined) keeps the JSON clean
|
|
129
|
+
delete section.taskModel;
|
|
130
|
+
}
|
|
131
|
+
raw[SETTINGS_KEY] = section;
|
|
132
|
+
mkdirSync(dirname(settingsPath), { recursive: true });
|
|
133
|
+
writeFileSync(settingsPath, `${JSON.stringify(raw, null, 2)}\n`, "utf-8");
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Persist the agent-trajectory flag in the PROJECT settings file
|
|
137
|
+
* `<cwd>/.pi/settings.json` under the namespaced `llm-wiki` key (issue #80).
|
|
138
|
+
* Mirrors `persistTaskModel`: project settings win in `loadTaskConfig`, other
|
|
139
|
+
* keys are preserved. `true` writes `trajectories: true`; `false` removes the
|
|
140
|
+
* key (reverting to the default-off behavior).
|
|
141
|
+
*/
|
|
142
|
+
export function persistTrajectoriesEnabled(cwd, enabled) {
|
|
143
|
+
const settingsPath = join(cwd, ".pi", "settings.json");
|
|
144
|
+
const raw = readSettingsObject(settingsPath);
|
|
145
|
+
const existing = raw[SETTINGS_KEY];
|
|
146
|
+
const section = existing && typeof existing === "object" ? { ...existing } : {};
|
|
147
|
+
if (enabled) {
|
|
148
|
+
section.trajectories = true;
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
// biome-ignore lint/performance/noDelete: one-off settings rewrite, not a hot path; removing the key keeps the JSON clean (default is off)
|
|
152
|
+
delete section.trajectories;
|
|
153
|
+
}
|
|
154
|
+
raw[SETTINGS_KEY] = section;
|
|
155
|
+
mkdirSync(dirname(settingsPath), { recursive: true });
|
|
156
|
+
writeFileSync(settingsPath, `${JSON.stringify(raw, null, 2)}\n`, "utf-8");
|
|
157
|
+
}
|
|
158
|
+
export function loadTaskConfig(cwd) {
|
|
159
|
+
let globalPath;
|
|
160
|
+
try {
|
|
161
|
+
globalPath = join(getAgentDir(), "settings.json");
|
|
162
|
+
}
|
|
163
|
+
catch {
|
|
164
|
+
globalPath = "";
|
|
165
|
+
}
|
|
166
|
+
const projectPath = join(cwd, ".pi", "settings.json");
|
|
167
|
+
return {
|
|
168
|
+
...TASK_DEFAULTS,
|
|
169
|
+
...(globalPath ? readNamespacedConfig(globalPath) : {}),
|
|
170
|
+
...readNamespacedConfig(projectPath),
|
|
171
|
+
};
|
|
172
|
+
}
|