piroboros 0.1.0 → 0.3.2

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 (52) hide show
  1. package/CHANGELOG.md +69 -1
  2. package/NOTICE +12 -0
  3. package/README.md +91 -167
  4. package/dist/chat/compactor.js +5 -4
  5. package/dist/chat/log.js +3 -2
  6. package/dist/chat/plan.js +1 -0
  7. package/dist/chat/tree.js +1 -0
  8. package/dist/chat/turn.js +0 -15
  9. package/dist/conclave/pipeline.js +222 -19
  10. package/dist/config.js +127 -12
  11. package/dist/diff.js +90 -0
  12. package/dist/durable.js +69 -4
  13. package/dist/guard.js +170 -14
  14. package/dist/learn.js +938 -0
  15. package/dist/main.js +3 -9
  16. package/dist/memory/akashic/tools.js +25 -28
  17. package/dist/memory/mnemosia/conflicts.js +0 -4
  18. package/dist/memory/mnemosia/orchestrator.js +1 -11
  19. package/dist/memory/mnemosia/policy.js +0 -3
  20. package/dist/memory/mnemosia/rank.js +0 -4
  21. package/dist/memory/mnemosia/rerank.js +3 -30
  22. package/dist/memory/mnemosia/rollback.js +1 -149
  23. package/dist/memory/mnemosia/tokens.js +1 -11
  24. package/dist/memory/mnemosia/tools.js +0 -10
  25. package/dist/memory/mnemosia/types.js +0 -2
  26. package/dist/runtime.js +80 -11
  27. package/dist/search.js +25 -12
  28. package/dist/shell.js +2 -2
  29. package/dist/telemetry.js +84 -0
  30. package/dist/tui/app.js +17 -3
  31. package/dist/tui/commands.js +6 -2
  32. package/dist/tui/settings.js +4 -1
  33. package/dist/tui/thinking/parse.js +0 -3
  34. package/dist/ws/apply.js +817 -0
  35. package/dist/ws/cas.js +144 -0
  36. package/dist/ws/confine.js +194 -0
  37. package/dist/ws/docker.js +151 -0
  38. package/dist/ws/git.js +162 -0
  39. package/dist/ws/lww.js +48 -0
  40. package/dist/ws/merge.js +129 -0
  41. package/dist/ws/workspace.js +1596 -0
  42. package/dist/ws/wsl.js +259 -0
  43. package/docs/conclave.md +35 -0
  44. package/docs/configuration.md +54 -0
  45. package/docs/development.md +25 -0
  46. package/docs/interface.md +33 -0
  47. package/docs/memory.md +11 -0
  48. package/docs/privacy.md +15 -0
  49. package/docs/tools.md +62 -0
  50. package/docs/web.md +38 -0
  51. package/package.json +23 -10
  52. package/settings.json.example +4 -1
package/dist/ws/wsl.js ADDED
@@ -0,0 +1,259 @@
1
+ import { spawn } from "node:child_process";
2
+ import { copyFileSync, existsSync, mkdirSync, readFileSync } from "node:fs";
3
+ import { posix, win32 } from "node:path";
4
+ import { err, ExecutionError, ok } from "@earendil-works/pi-durable/env";
5
+ import { sgrStripper } from "../shell.js";
6
+ import { bwrapArgs, seccompExec, within } from "./confine.js";
7
+ export class SelfTestError extends Error {
8
+ }
9
+ export function wslDeps() {
10
+ const systemRoot = process.env.SystemRoot ?? "C:\\Windows";
11
+ // Only SystemRoot, WSL_UTF8 and an empty WSLENV: nothing from the Windows environment reaches the distro.
12
+ const env = { SystemRoot: systemRoot, WSL_UTF8: "1", WSLENV: "" };
13
+ return { systemRoot, run: (args, o = {}) => new Promise((done) => {
14
+ const child = spawn(win32.join(systemRoot, "System32", "wsl.exe"), args, { env, stdio: [o.stdin === undefined ? "ignore" : "pipe", "pipe", "pipe"], windowsHide: true });
15
+ const out = [];
16
+ let errs = "";
17
+ let timedOut = false;
18
+ let end;
19
+ let over = false;
20
+ const fin = (code) => { if (over)
21
+ return; over = true; clearTimeout(timer); clearTimeout(end); o.signal?.removeEventListener("abort", kill); done({ code, out: Buffer.concat(out), err: errs, timedOut }); };
22
+ const kill = () => { child.kill(); };
23
+ const timer = o.timeoutMs === undefined ? undefined : setTimeout(() => { timedOut = true; kill(); }, o.timeoutMs);
24
+ o.signal?.addEventListener("abort", kill, { once: true });
25
+ if (o.signal?.aborted)
26
+ kill();
27
+ child.stdout?.on("data", (b) => { if (o.onData !== undefined)
28
+ o.onData(b, "stdout");
29
+ else
30
+ out.push(b); });
31
+ child.stderr?.on("data", (b) => { if (o.onData !== undefined)
32
+ o.onData(b, "stderr");
33
+ else if (errs.length < 4096)
34
+ errs += b.toString("utf8"); });
35
+ child.stdin?.on("error", () => undefined);
36
+ if (o.stdin !== undefined)
37
+ child.stdin?.end(o.stdin);
38
+ child.on("error", (e) => { errs += e.message; fin(null); });
39
+ child.on("close", fin);
40
+ // A descendant holding the pipes open must not keep the call waiting.
41
+ child.on("exit", (code) => { end = setTimeout(() => fin(code), 2000); });
42
+ }) };
43
+ }
44
+ export const via = (w, argv) => [...(w.distro === undefined ? [] : ["--distribution", w.distro]), ...(w.user === undefined ? [] : ["--user", w.user]), "--exec", ...argv];
45
+ const key = (p) => win32.resolve(p).replaceAll("\\", "/").toLowerCase();
46
+ export const posixOf = (p) => p.replaceAll("\\", "/");
47
+ /** A Windows path that may not be bound or mounted: protected, the profile or a direct child of it, or something holding the Workspace root, PIROBOROS_HOME or a deny root. */
48
+ export function wslBad(d, path) {
49
+ const k = key(path);
50
+ const above = (root) => key(root) === k || key(root).startsWith(`${k}/`);
51
+ return !d.allowed(path) || above(d.home) || key(win32.dirname(path)) === key(d.home) || [d.wsRoot, d.piroHome, ...d.deny].some(above);
52
+ }
53
+ /** One call of a constant script; a refusal names the call, the distro or user, or what wsl.exe said. */
54
+ export async function call(d, w, what, script, args = [], timeoutMs = 20_000) {
55
+ const r = await d.run(via(w, ["sh", "-c", script, "sh", ...args]), { timeoutMs });
56
+ if (r.timedOut)
57
+ throw new Error(`${what}: wsl.exe did not answer within ${timeoutMs / 1000} s`);
58
+ if (r.code === null && /ENOENT/u.test(r.err))
59
+ throw new Error("wsl.exe is not available on this machine");
60
+ if (r.code === -1 || r.code === 0xFFFFFFFF)
61
+ throw new Error(`distro ${w.distro ?? "(default)"} or user ${w.user ?? "(default)"} not found`);
62
+ if (r.code !== 0)
63
+ throw new Error(`${what}: exit ${r.code}${r.err === "" ? "" : ` (${r.err.trim().slice(0, 200)})`}`);
64
+ return r.out.toString("utf8");
65
+ }
66
+ const RESOLVE = 'printf "%s\\n" "$WSL_DISTRO_NAME" "$(id -u)" "$(id -g)" "$(id -un)" "$(getent passwd "$(id -un)" | cut -d: -f6)" "$(uname -r)" "$(test -x /usr/bin/bwrap && echo 1)" "$(wslinfo --networking-mode 2>/dev/null)"; cat /proc/self/mounts';
67
+ const LOGIN = 'printf "\\001S"; printf "%s\\0" "$PATH" "${LANG:-C.UTF-8}" "$(readlink -f /etc/resolv.conf)"; printf "\\001E"';
68
+ export const WSLPATH = 'for p; do wslpath -a -u "$p" || echo; done';
69
+ const REALPATH = 'for p; do realpath -e -- "$p" 2>/dev/null || echo; done';
70
+ const PIDRUN = 'echo $$ > "$1"; shift; exec "$@"';
71
+ const KILL = 'kill -KILL "$(cat -- "$1")" 2>/dev/null; rm -f -- "$1"';
72
+ // Runs inside the sandbox: write and remove a file in the Workspace, no auth.json, a readable resolv.conf, no Windows program, no System32, then the
73
+ // node version and what each masked mount lists.
74
+ const SELF_TEST = 'm="$1/.piroboros-selftest"; : > "$m" || { echo "the Workspace is not writable"; exit 1; }; rm -f "$m"; [ ! -e "$2/auth.json" ] || { echo "auth.json is visible"; exit 1; }; [ "$3" = 0 ] || [ -r /etc/resolv.conf ] || { echo "resolv.conf is not readable"; exit 1; }; command -v perl >/dev/null && { perl -e \'socket(S,40,1,0) and exit 1; exit($!+0==97?0:2)\' || { echo "an AF_VSOCK socket can be created"; exit 1; }; }; if "$4" >/dev/null 2>&1; then echo "a Windows program ran"; exit 1; fi; [ ! -e "$5" ] || { echo "the Windows System32 folder is visible"; exit 1; }; echo "node $(node --version 2>/dev/null || echo none)"; shift 5; for m; do echo "mount $m"; ls -A "$m" 2>/dev/null; done; true';
75
+ export const WRAPPER = 'IFS= read -rd "" c; exec bash -c "$c"';
76
+ /** The distro and user (the pinned ones, or the default), refused when bubblewrap (unless `bwrap` is false, for Docker) cannot work there. Also reads the Windows-backed mounts. */
77
+ export async function resolveWsl(d, who, bwrapNeeded = true) {
78
+ const lines = (await call(d, who, "resolving the distro", RESOLVE)).split("\n");
79
+ const [distro = "", uid = "", gid = "", user = "", home = "", kernel = "", bwrap = "", net = ""] = lines;
80
+ if (/^docker-desktop/iu.test(distro))
81
+ throw new Error(`distro ${distro} is Docker Desktop's own and cannot run commands`);
82
+ if (distro === "" || user === "" || home === "")
83
+ throw new Error("the distro did not report its name, user and home");
84
+ if (uid === "0")
85
+ throw new Error(`the default user of ${distro} is root; set a normal default user in the distro`);
86
+ if (!/WSL2/iu.test(kernel))
87
+ throw new Error(`${distro} runs kernel ${kernel}, which is not WSL2 (bubblewrap needs it)`);
88
+ if (bwrapNeeded && bwrap !== "1")
89
+ throw new Error(`bubblewrap is not installed in ${distro} (package bubblewrap)`);
90
+ const unescape = (s) => s.replace(/\\([0-7]{3})/gu, (_, o) => String.fromCharCode(Number.parseInt(o, 8)));
91
+ const mounts = lines.slice(8).map((l) => l.split(" ")).filter((f) => ["9p", "drvfs", "virtiofs"].includes(f[2] ?? "")).map((f) => unescape(f[1] ?? ""));
92
+ return { distro, user, uid, gid, home, net, mounts: ["/mnt", ...new Set(mounts)].filter((m) => m !== "") };
93
+ }
94
+ /** PATH, LANG and the resolv.conf target from the login shell; empty and relative entries and entries under a Windows-backed mount are dropped. */
95
+ async function loginValues(d, who, mounts) {
96
+ const parse = (r) => {
97
+ if (r.timedOut || r.code !== 0)
98
+ return undefined;
99
+ const s = r.out.toString("utf8");
100
+ const i = s.indexOf("\x01S");
101
+ const j = s.lastIndexOf("\x01E");
102
+ const f = i < 0 || j < i ? [] : s.slice(i + 2, j).split("\0");
103
+ return f.length >= 3 ? f : undefined;
104
+ };
105
+ let f = parse(await d.run(via(who, ["bash", "-lc", LOGIN]), { timeoutMs: 10_000 }));
106
+ const fallback = f === undefined;
107
+ f ??= parse(await d.run(via(who, ["env", "LANG=C.UTF-8", "sh", "-c", LOGIN]), { timeoutMs: 10_000 }));
108
+ if (f === undefined)
109
+ throw new Error("reading PATH from the distro failed");
110
+ return { path: (f[0] ?? "").split(":").filter((e) => e.startsWith("/") && !mounts.some((m) => within(m, e))), lang: f[1] || "C.UTF-8", resolv: f[2] ?? "", fallback };
111
+ }
112
+ /** Run `fn` until the paths it asks `real` about are all resolved in the distro (realpath -e, one call per round). */
113
+ async function settled(d, who, fn) {
114
+ const known = new Map();
115
+ for (let round = 0; round < 4; round++) {
116
+ const ask = new Set();
117
+ const out = fn((p) => { if (known.has(p))
118
+ return known.get(p); ask.add(p); return undefined; });
119
+ if (ask.size === 0)
120
+ return out;
121
+ const lines = (await call(d, who, "resolving sandbox paths", REALPATH, [...ask])).split("\n");
122
+ [...ask].forEach((p, i) => known.set(p, lines[i] || undefined));
123
+ }
124
+ throw new Error("resolving sandbox paths did not settle");
125
+ }
126
+ /**
127
+ * Choose bubblewrap in WSL for the Workspace folder `ws` (a Windows path under `<wsRoot>/<home hash>/<id>`): resolve and pin the distro and user,
128
+ * translate the Windows paths, create the ext4 folders, build the argv and run the self-test. A refusal throws; a failed check throws SelfTestError.
129
+ */
130
+ export async function wslPick(s, d, ws, p) {
131
+ const w = d.wsl;
132
+ if (/^docker-desktop/iu.test(s.distro ?? ""))
133
+ throw new Error("workspace.wsl.distro names Docker Desktop's own distro, which cannot run commands");
134
+ let info;
135
+ try {
136
+ info = await resolveWsl(w, p.prev === undefined ? { distro: s.distro } : { distro: p.prev.distro, user: p.prev.user });
137
+ }
138
+ catch (error) {
139
+ if (p.prev === undefined)
140
+ throw error;
141
+ info = await resolveWsl(w, { distro: s.distro }).catch(() => { throw error; });
142
+ }
143
+ const who = { distro: info.distro, user: info.user };
144
+ const notice = [];
145
+ if (p.prev !== undefined && (p.prev.distro !== info.distro || p.prev.user !== info.user))
146
+ notice.push(`The earlier sandbox folders of this Workspace stay in ${p.prev.distro} as ${p.prev.user} at ${p.prev.ext4}; remove them there.`);
147
+ // Deny-root check of each Windows path before it is translated.
148
+ for (const x of [ws, ...p.alt])
149
+ if (win32.isAbsolute(x) && !/^[A-Za-z]:[\\/]/u.test(x))
150
+ throw new Error(`${x} is not on a local Windows drive`);
151
+ const alt = p.alt.filter((a) => win32.isAbsolute(a) && !wslBad(d, a));
152
+ const hash = win32.basename(win32.dirname(ws));
153
+ const selftest = win32.join(d.wsRoot, hash, "selftest");
154
+ if (!existsSync(win32.join(selftest, "w.exe"))) {
155
+ mkdirSync(selftest, { recursive: true });
156
+ copyFileSync(win32.join(w.systemRoot, "System32", "whoami.exe"), win32.join(selftest, "w.exe"));
157
+ }
158
+ const system32 = win32.join(w.systemRoot, "System32");
159
+ const wins = [...new Set([ws, d.wsRoot, d.piroHome, ...d.deny, selftest, system32, ...alt])];
160
+ const out = (await call(w, who, "translating paths", WSLPATH, wins.map((x) => win32.resolve(x)))).split("\n");
161
+ const to = new Map(wins.map((x, i) => [x, out[i] ?? ""]));
162
+ const lin = (x) => to.get(x) ?? "";
163
+ for (const x of [ws, ...alt])
164
+ if (!info.mounts.some((m) => within(m, lin(x))))
165
+ throw new Error(`${x} is not on a local Windows drive`);
166
+ const login = await loginValues(w, who, info.mounts);
167
+ const wsLin = lin(ws);
168
+ const ext4 = `${info.home}/.local/state/piroboros-ws/${hash}/${win32.basename(ws)}`;
169
+ const nm = p.places.map((place, i) => [`${ext4}/nm/${i}`, `${wsLin}/${place}`]);
170
+ await call(w, who, "creating the sandbox folders", 'mkdir -p -m 0700 -- "$@"', [`${ext4}/run`, ...nm.map(([src]) => src)]);
171
+ const env = [["PATH", login.path.join(":")], ["HOME", info.home], ["USER", info.user], ["LOGNAME", info.user], ["LANG", login.lang], ["TMPDIR", "/tmp"], ["NO_COLOR", "1"], ["TERM", "dumb"]];
172
+ const c = { ws: wsLin, cwd: wsLin, net: s.network, path: login.path.join(":"), wsl: { mounts: info.mounts, alt: alt.map(lin), nm, env, extra: [] } };
173
+ const test = ["sh", "-c", SELF_TEST, "sh", wsLin, lin(d.piroHome), s.network ? "1" : "0", `${lin(selftest)}/w.exe`, lin(system32), ...info.mounts];
174
+ const built = await settled(w, who, (real) => {
175
+ const dl = { ...d, platform: "linux", home: info.home, piroHome: lin(d.piroHome), wsRoot: lin(d.wsRoot), deny: d.deny.map(lin).filter((x) => x !== ""), allowed: () => true, real, read: () => undefined };
176
+ return { real: bwrapArgs(dl, c, []), test: bwrapArgs(dl, { ...c, wsl: { ...c.wsl, extra: [lin(selftest)] } }, test) };
177
+ });
178
+ const ran = await w.run(via(who, seccompExec("/usr/bin/bwrap", built.test.args)), { timeoutMs: 20_000 });
179
+ const lines = ran.out.toString("utf8").split("\n");
180
+ if (ran.timedOut || ran.code !== 0)
181
+ throw new SelfTestError(ran.timedOut ? "the self-test did not finish within 20 s" : lines[0] || ran.err.trim().split("\n")[0] || "bwrap did not start");
182
+ // Each masked mount may list only the first folder of a bound path inside it.
183
+ const bound = [wsLin, ...c.wsl.alt, lin(selftest), ...nm.map(([, dst]) => dst), login.resolv];
184
+ let mount = "";
185
+ for (const line of lines.slice(1)) {
186
+ if (line.startsWith("mount ")) {
187
+ mount = line.slice(6);
188
+ continue;
189
+ }
190
+ if (mount !== "" && line !== "" && !bound.some((b) => within(mount, b) && b.slice(mount.length + 1).split("/")[0] === line))
191
+ throw new SelfTestError(`${mount} lists ${line}, which is not a bind parent`);
192
+ }
193
+ const have = /^node (.+)$/mu.exec(ran.out.toString("utf8"))?.[1] ?? "none";
194
+ const need = /^>=\s*(\d+\.\d+\.\d+)\s*$/u.exec((() => { try {
195
+ return JSON.parse(readFileSync(win32.join(p.project, "package.json"), "utf8")).engines?.node ?? "";
196
+ }
197
+ catch {
198
+ return "";
199
+ } })())?.[1];
200
+ // ponytail: only `>=X.Y.Z` is compared; add a semver range check when a project uses another form.
201
+ const lt = (a, b) => { const x = a.replace(/^v/u, "").split(".").map(Number), y = b.split(".").map(Number); for (let i = 0; i < 3; i++)
202
+ if ((x[i] ?? 0) !== (y[i] ?? 0))
203
+ return (x[i] ?? 0) < (y[i] ?? 0); return false; };
204
+ if (need !== undefined && (have === "none" || lt(have, need)))
205
+ notice.push(`Node in ${info.distro} is ${have}; this project needs >=${need}. Install a newer Node in the distro for npm commands.`);
206
+ if (s.network)
207
+ notice.push(`Network: on. Confined commands can reach the WSL VM's network, which includes the Windows host (${info.net === "nat" || info.net === "mirrored" ? `networking mode: ${info.net}` : "through the NAT gateway, or on Windows localhost with mirrored networking"}), and can send any file they can see.`);
208
+ if (p.files > 1000)
209
+ notice.push(`git in the sandbox reads this project through drvfs: the first git status takes about ${Math.round(p.files * 0.0057)} s, later ones about ${(0.5 + p.files * 0.0003).toFixed(1)} s.`);
210
+ const left = [...p.alt.filter((a) => !alt.includes(a)), ...built.real.refused];
211
+ if (left.length > 0)
212
+ notice.push(`Left hidden in the sandbox because they are protected: ${left.join(", ")}`);
213
+ if (login.fallback)
214
+ notice.push(`The login shell of ${info.distro} did not answer, so PATH comes from wsl.exe itself; put toolchain PATH lines in ~/.profile.`);
215
+ return { confine: { name: "bubblewrap", bwrap: "/usr/bin/bwrap", net: s.network, wsl: { ...who, ws: wsLin, ext4, argv: built.real.args, alt: p.alt, places: p.places } }, label: `bubblewrap in WSL (${info.distro})`, notice, alt: alt.map(lin) };
216
+ }
217
+ /** The sandbox folders of a Workspace, removed with the Workspace (exactly the computed path, never one read from Workspace content). */
218
+ export const wslRemove = (d, c) => call(d, c, "removing the sandbox folders", 'rm -rf --one-file-system -- "$1"', [c.ext4]);
219
+ /** Remove the ids under the own home-hash folder of a distro that no open, held or conflicted Workspace names. */
220
+ export async function wslSweep(d, c, keep) {
221
+ const base = posix.dirname(c.ext4);
222
+ for (const name of (await call(d, c, "listing the sandbox folders", 'ls -1A -- "$1" 2>/dev/null || true', [base])).split("\n"))
223
+ if (/^\d+$/u.test(name) && !keep.has(name))
224
+ await call(d, c, "removing a sandbox folder", 'rm -rf --one-file-system -- "$1"', [`${base}/${name}`]);
225
+ }
226
+ let seq = 0;
227
+ /** Run one command of a Workspace in the sandbox: wsl.exe with a constant argv, the command on stdin. Timeout and abort also end bwrap through its PID file. */
228
+ export async function execWsl(w, cwd, command, options, context) {
229
+ const c = w.confine.wsl;
230
+ const d = w.deps.wsl;
231
+ const rel = posixOf(win32.relative(w.ws, cwd));
232
+ // The guard sets GIT_CEILING_DIRECTORIES for a plain Workspace; its value here is the Linux form of the Workspace's parent.
233
+ const ceiling = options?.env?.GIT_CEILING_DIRECTORIES === undefined ? [] : ["--setenv", "GIT_CEILING_DIRECTORIES", posix.dirname(c.ws)];
234
+ const pid = `${c.ext4}/run/${process.pid}-${++seq}.pid`;
235
+ const args = via(c, ["sh", "-c", PIDRUN, "sh", pid, ...seccompExec(w.confine.bwrap, [...c.argv.slice(0, -2), ...ceiling, "--chdir", rel === "" ? c.ws : `${c.ws}/${rel}`, "bash", "-c", WRAPPER])]);
236
+ return wslCommand(d, args, command, options, context, async () => { await call(d, c, "ending the sandbox", KILL, [pid], 10_000).catch(() => ""); }, () => { void call(d, c, "removing the PID file", 'rm -f -- "$1"', [pid]).catch(() => ""); }, `distro ${c.distro} or user ${c.user} not found`);
237
+ }
238
+ /** One wsl.exe call whose stdin is the command (the constant wrapper reads it): output streams to the tool, `kill` runs on timeout or abort, `done` after a normal exit. */
239
+ export async function wslCommand(d, args, command, options, context, kill, done, missing) {
240
+ const strip = sgrStripper();
241
+ const dec = { stdout: new TextDecoder(), stderr: new TextDecoder() };
242
+ const emit = (text, stream) => { const clean = strip.push(text, stream); if (clean !== "")
243
+ options?.onOutput?.(clean, context, { stream }); };
244
+ const r = await d.run(args, { stdin: command, timeoutMs: options?.timeout === undefined ? undefined : options.timeout * 1000, signal: context.abortSignal, onData: (b, stream) => emit(dec[stream].decode(b, { stream: true }), stream) });
245
+ for (const stream of ["stdout", "stderr"]) {
246
+ emit(dec[stream].decode(), stream);
247
+ const rest = strip.flush(stream);
248
+ if (rest !== "")
249
+ options?.onOutput?.(rest, context, { stream });
250
+ }
251
+ if (r.timedOut || context.abortSignal?.aborted) {
252
+ await kill();
253
+ return err(new ExecutionError(r.timedOut ? "timeout" : "aborted", r.timedOut ? `timeout:${options?.timeout}` : "aborted"));
254
+ }
255
+ done();
256
+ if (r.code === null || r.code === -1 || r.code === 0xFFFFFFFF)
257
+ return err(new ExecutionError("spawn_error", `confinement backend unavailable: ${r.code === null ? (r.err.trim() || "wsl.exe did not start") : missing}`));
258
+ return ok({ exitCode: r.code });
259
+ }
@@ -0,0 +1,35 @@
1
+ # The Conclave
2
+
3
+ [Back to the README](../README.md)
4
+
5
+ The Conclave is a team of eight agents defined in `agents/*.md` and `skills/conclave/SKILL.md`. `/conclave <task>` starts a review. Samaela plans, then Nytheria, Elaria, Raskreia, Avaritia, Vaelia and Astrelia review in that order. Each member runs alone, in its own child conversation, and sees the task and the reports posted so far. If any reviewer's verdict is `proceed with changes` or `send back`, Samaela runs once more as the final-plan seat (shown as "Samaela (final plan)" in the pane). She gets the task, her first plan and all the reviewer reports, and her report is the final plan; Vesperia is briefed with it in place of the first plan. When every verdict is `proceed`, this step is skipped. Each member's final message is posted as a report, but the reports are held while the pipeline runs: they reach the chat together, in one turn, when the review ends at `awaiting approve`, or when the execution finishes, fails or is cancelled. Messages you send meanwhile are answered as usual and do not bring the held reports in. A report over 4,000 characters keeps its first 2,400 and last 1,400 characters, and every report ends with a pointer to the member's whole chat. When the report's verdict line falls in the cut part, it is repeated after the cut marker, so the verdict still counts. `zoom("Name")` shows that member's latest run, 30,000 characters per page (`zoom` with `page`). Names are not case-sensitive; an unknown name and a member that has not run yet get different answers.
6
+
7
+ ## The pane
8
+
9
+ While a pipeline exists, the chat shows a Conclave pane. Each member is `waiting`, `running`, `done`, `partial`, `blocked`, `failed (reason)`, `not run` or, for Vesperia after a complete review, `awaiting approve`. The running member's last entries and its answer in progress appear under the list, at most 10 lines. A hint under the list says what to do next: `/conclave cancel stops it` while it runs, `/conclave approve runs Vesperia` when it waits, `/conclave approve runs Vesperia again` after a stopped execution, and `/conclave <task> starts a new review` after a failed review. When the terminal has too few rows, the pane drops rows in this order: the stream, the thinking steps, the member's name, members that wait, finished members, the hint, other members, the running member and the title. A pane under the chat is hidden when the chat would get fewer than 8 rows. In a terminal of 100 columns or more there is always a right column, 30% wide. It shows the Conclave pane while a pipeline is running, waiting for approval or stopped with a failed member, and a session panel otherwise: the main model, the thinking level, the chat view size against 128 KB, the compactor state, the memory status, web access, and the outcome of the last run (or the hint `/conclave <task>`). In a narrower terminal the pane goes under the chat at full width with 4 stream lines, and there is no idle panel. A pipeline that completed shows one line with its outcome, and a stopped one keeps the member list so the failed member and its reason stay visible.
10
+
11
+ ## Running and controlling a pipeline
12
+
13
+ - `/conclave approve` runs Vesperia, who executes the plan of the latest complete review. Only Vesperia can write files and run shell commands, and she can write only inside the working directory. The reviewers can read, search, `zoom` and `date`. They also have `mnemosia_brief`. They have no shell, because the shell is not confined to a directory, and they cannot write memory.
14
+ - `/conclave cancel` stops a running pipeline and posts a `FAILED (cancelled)` report. `/conclave status` shows the current member.
15
+ - `/conclave undo` restores the files of the last Vesperia run. It covers only what she changed with the `write` and `edit` tools. Changes made through `bash` are not covered; the list says how many shell commands she ran. Only the latest run is kept. Before the first change, the tools save the exact bytes of each file under `<home>/undo/<run>/`, so these copies can hold file contents, secrets included. They are not redacted and are deleted by the undo or when the next run starts. Files over 1 MB, or past 20 MB of copies per run, are listed as not restorable. The command shows what it would restore, delete and skip, and asks before it touches anything. A file that changed after the run is skipped. A file the run created is deleted only if it is unchanged since. It is refused while a pipeline runs. Her decision memory, if any, stays quarantined until you run `/akashic accept`; there is no reject command.
16
+ - After a run that ended `partial`, `blocked` or failed, `/conclave approve` starts a new Vesperia and gives her the earlier report as one more card, marked as evidence and not as instructions. Type your new instruction in the chat first. The brief says whether `/conclave undo` restored the files. The pane shows `partial` or `blocked` for Vesperia instead of `done`. A new review forgets the earlier report. After a run that ended `done`, `/conclave approve` is refused: start a new review with `/conclave <task>`. A run with no verdict line can be approved again.
17
+ - `/conclave` is refused while the chat is busy with a turn or while another pipeline runs. Esc in the chat does not stop a pipeline.
18
+ - A member that gives no report, makes too many model calls (`maxTurns`, 64, or 256 for Vesperia), produces no output for too long (`idleTimeoutMs`, 10 minutes, not counted while a tool runs) or repeats the same failing call is reported as `FAILED`, and the pipeline stops there. A member whose final answer is empty, aborted or errored is reported as `FAILED: no report produced`.
19
+ - Each member's model is `conclave.members.<name>.model`, then `conclave.defaultModel`, then `main`. The choice is made once when the pipeline starts. A member whose model has no credentials fails the start before any member runs. `model:` is not allowed in an agent file, because the model is your choice and belongs in `settings.json`. `thinking`, `maxTurns` and `idleTimeoutMs` can be set per member in `settings.json` as well. The thinking level defaults come from the agent files: Samaela `high`, Vesperia `medium`, Astrelia and Vaelia `low`, the other reviewers `medium`. To give Samaela one model and the others another, set `conclave.members.samaela.model` and `conclave.defaultModel`, as in `settings.json.example`; `/settings conclave.members.samaela` edits the same keys from the chat.
20
+ - While a pipeline runs, the root chat cannot write files or run commands. A chat turn that was started only by member reports cannot either, until you send a message. Reports are treated as untrusted data. Such a turn ends its input with one line from piroboros that tells the model this rule, so it summarizes the reports and points to `/conclave approve` or a reply from you instead of trying a tool that would be refused.
21
+ - If piroboros closes while a pipeline runs, it resumes the pipeline at the next start and says so.
22
+
23
+ ## Workspaces
24
+
25
+ Vesperia works in a Workspace by default: a private copy of your project's git-visible files, made when `/conclave approve` starts her. Your project folder is not touched while she runs. When her run ends with the verdict `done`, piroboros merges her changes back, line by line, and `/conclave undo` restores the files from a snapshot taken before the merge.
26
+
27
+ - What is copied: the files git shows for the project (tracked files, and untracked files that are not ignored), and a reduced `.git` so her git commands work. Files with secret-like names (`auth.json`, `.npmrc`, `.env.*`, `*.sqlite`, `token*`, keys and similar) are left out and listed in the start notice. Git-ignored folders such as `dist/` are not copied. `node_modules` is an empty folder in the Workspace, wherever it occurs; she installs into it when she needs it, and nothing under it is merged back. A project without git is copied by a walk with the same exceptions.
28
+ - Her `git push` is disabled in the Workspace and her commits stay there. Nothing she writes into the Workspace's `.git/config` or `.gitattributes` is run by piroboros.
29
+ - A merge writes nothing to your folder when a path conflicts (you changed the same place), and lists the paths and the kinds. A run that ends with another verdict, a cancel, a moved HEAD, 20 or more deletions, a live file over 64 MiB or a failed pre-flight check leaves the Workspace in place as a hold. `/conclave merge` shows every reason and asks once, `/conclave discard` drops the Workspace, `/conclave retry` continues a pipeline that a restart limit parked, and `/conclave status` shows the Workspace and its state.
30
+ - Resolving conflicts. For a text file both of you changed, the Workspace copy gets `<<<<<<< workspace N`, `=======` and `>>>>>>> live N` marker lines, and the report gives the line of each block. Remove the blocks (or copy the live file over the Workspace file) and run `/conclave merge` again; the path stays conflicted while any `<<<<<<< workspace N` or `>>>>>>> live N` line is left; the merge then applies your resolution against the live text it was made from. If you change the live file again in between, that path conflicts again and the markers are rewritten from Vesperia's stored version, so edits to the old markers are lost. A binary file or a deletion conflict is resolved by making the Workspace file equal to the live one. `/conclave merge` with conflicts left asks whether to replace your version of those paths with hers (her deletions delete); yes writes her stored version, not the marker text, and `/conclave undo` restores yours. A path that conflicts because a file and a folder meet, or because the names differ only in case, is not offered that choice; make the Workspace path equal the live one, or discard. A marker block with another number in a tracked file is ordinary text.
31
+ - Approving the same plan again after a conflict or a hold continues in the same Workspace. Files you changed in your folder that she never touched are copied into it first, so her next merge builds on your current files.
32
+ - A `.lww` file in the project root (gitignore-style patterns, `%include` for more files) names paths where the side modified later wins instead of conflicting: the Workspace file's modification time against the live file's, the Workspace on a tie. A path she deleted counts as modified when the deletion was seen, and a path deleted live loses. The report names the rule and the side kept.
33
+ - The merge is not atomic across files. It stores every live path it will change before it writes, replaces each file only after checking its bytes, rolls back when a step fails, and rolls back or finishes at the next start after a crash. A live file over 64 MiB is never merged: copy it yourself before `/conclave merge`, which removes the Workspace afterwards.
34
+ - On Linux with bubblewrap installed, on Windows with bubblewrap in WSL 2, or with a Docker image set in `workspace.docker.image`, her commands run confined: see [Shell confinement](tools.md#shell-confinement). Everywhere else, and when the self-test fails, shell commands are not confined: they run in the Workspace folder but can still read and write any path your account can, including your live project. The start notice and `/conclave status` say which applies. The Workspace keeps her away from your files by where she works, not by a sandbox.
35
+ - A project folder that is a subfolder of a repository, a worktree or a submodule asks once whether she should work in place or on a copy without git. `workspace.nested` overrides the answer. `workspace.enabled: false` runs her in place, as piroboros 0.2.0 did.
@@ -0,0 +1,54 @@
1
+ # Configuration and commands
2
+
3
+ [Back to the README](../README.md)
4
+
5
+ ## Files and data
6
+
7
+ Everything piroboros stores lives under `PIROBOROS_HOME` (default `~/.piroboros`): the chat database, `chat.schema1.sqlite` (the copy made before the schema 2 upgrade), `telemetry.sqlite`, `auth.json`, `settings.json`, `models.json`, the memory stores, the optional vault clone, your `skills` folder and `skills-trust.json`. Copy `settings.json.example` and `models.json.example` from this repository as a starting point; the examples use placeholder hosts.
8
+
9
+ `PIROBOROS_HOME/instructions.md` is an optional file of your own standing instructions. It is read again for every request, so an edit applies at the next turn and `/reload` is not needed. The text goes to the main model as an `instructions` section and is also appended to the compactor's system prompt, so the compactor follows it too. A line meant only for replies should say so, for example "Do not apply this to compaction lines."
10
+
11
+ ## Custom providers (`models.json`)
12
+
13
+ `models.json` adds providers that speak one of three wire formats: `openai-completions`, `openai-responses` or `anthropic-messages`. Each model needs `id`, `api`, `baseUrl`, `contextWindow` and `maxTokens`. See `models.json.example`.
14
+
15
+ - OpenAI formats take a base URL that ends in `/v1`. The Anthropic format takes the host root, because the client adds `/v1/messages` itself; a base URL ending in `/v1` is rejected.
16
+ - A provider id must not contain `/`, and must not be the id of a built-in provider.
17
+ - A model needs `contextWindow` minus `maxTokens` of at least 24,000 to load. The main model needs `contextWindow` minus `maxTokens` minus 2,000 to be at least 72,000, otherwise it is listed as disabled in the main-model picker.
18
+ - The API key comes from the variable `<ID>_API_KEY`: the id is upper-cased and every character outside A-Z and 0-9 becomes an underscore, so `my-llm.v2` reads `MY_LLM_V2_API_KEY`. A key stored through setup or `/login` takes precedence over the variable.
19
+ - A UTF-8 BOM at the start of the file is accepted.
20
+ - Two optional keys control reasoning. `thinkingLevelMap` maps piroboros thinking levels (`off`, `minimal`, `low`, `medium`, `high`, `xhigh`, `max`) to the value the provider accepts, or to `null` for a level the model does not support; it needs `"reasoning": true`. `compat` is passed to pi-ai unchanged and covers provider differences such as `supportsReasoningEffort` or `thinkingFormat`. Some models reason by default even when no level is sent, so mapping `off` to the provider's lowest value is how you cap them. For example, a model that accepts only `low` and `high`:
21
+
22
+ ```json
23
+ "reasoning": true,
24
+ "compat": { "supportsReasoningEffort": true },
25
+ "thinkingLevelMap": { "off": "low", "minimal": "low", "low": "low", "medium": "low", "high": "high", "xhigh": "high", "max": "high" }
26
+ ```
27
+ - An invalid file does not stop startup. piroboros starts without custom providers and shows the error, which names the field. `/reload` re-reads `models.json` and `settings.json` and keeps the previous configuration if either is invalid.
28
+
29
+ ## Command line
30
+
31
+ - `npm start` opens the chat. If no main model is set it runs setup first. To type `piroboros` in any terminal instead, run `npm link` once in this folder; `npm unlink -g piroboros` removes it. While the chat is open the window title reads `piroboros - <folder>`, the folder it was started in.
32
+ - `npm run setup` runs the guided setup. It needs the same exclusive access as the chat, so it exits with code 3 while the chat is open. If a config file was edited outside piroboros, setup shows the change and asks whether to accept it before it starts, the same as starting the chat does; answering no exits with code 5.
33
+ - `--print <message>` sends one message and prints the answer. `--model provider/model` uses another model for that run only, with `--print` and for the interactive start; an unknown model exits 2 and does not open setup. Exit codes: 2 when no main model is set, 4 when login is required, 5 when the config files were changed outside piroboros.
34
+ - `--backup <file>` writes a copy of the chat database.
35
+
36
+ ## Chat commands
37
+
38
+ `/model`, `/reload`, `/login`, `/settings`, `/status`, `/conclave`, `/akashic`, `/thinking-steps`, `/skills`, `/learn` and `/telemetry` are available in the chat, and so is one command for each skill you have installed (see [Skills](tools.md#skills)).
39
+
40
+ `/telemetry` prints the model requests of the last 24 hours, one line per model: requests, failures, average time, tokens and cost. The last 10 seconds may not show yet. It says so when telemetry is off.
41
+
42
+ `/learn` runs the learning loop by hand and manages what it proposes. The loop is off until `learning.model` is set. After every `learning.everyTurns` user turns (3 to 100, default 10) that hold at least 1,500 characters of your own text, one background pass sends the recent chat to that model as data, with no tools, and asks for at most 2 skills and 3 memories worth keeping. `learning.thinking` sets the reasoning level (default `low`). A pass that keeps nothing three times in a row doubles the wait, up to 40 turns, and a pass that keeps something resets it. Turns you abort, turns made only of Conclave reports and repeated sends of the same text do not count. A learned skill is never written without you: it is staged under `PIROBOROS_HOME/learn/proposed`, and `/learn accept <name>` shows its text, or a line diff for a change, and asks. `/learn reject <name|all>` drops proposals and the names are not proposed again. `/learn undo <name>` restores the text before the learner changed a skill, or removes a skill it created, and refuses when you have edited the file since. Only skills the learner created can be changed by it, and a name that already exists anywhere is refused. Memories the learner keeps are written as quarantined with the actor `piroboros:learner` and stay out of the memory snapshot until `/akashic accept` releases them. `/learn` alone shows the state, the counts, the last error, why items were refused, the proposals and a pass that the restart limit parked; `/learn retry` runs a parked pass again and `/learn skip` drops it. `/learn now` starts a pass at once over the chat written since the learner became permitted. Learned skills live in `PIROBOROS_HOME/skills`, which is scanned first, so one shadows a later skill of the same name; `/learn` lists such cases.
43
+
44
+ `/login` signs in from the chat. `/login` alone lists the providers, with `[ready]` on the ones that already resolve, and the two web search keys. `/login <provider>` goes straight to one, and `/login web-tinyfish` or `/login web-exa` stores a search key. A provider that offers both an OAuth and an API key method asks which one you want, and a provider that is already signed in asks before it signs in again. What you type is masked in a box that replaces the chat, the credential goes to `auth.json`, and error text is scrubbed before it is shown. The sign-in address is shown on screen and opened with the platform's default handler. Esc cancels, and closing piroboros during a sign-in stops its local callback server. The next turn uses the new credential without a restart.
45
+
46
+ `/settings` changes `settings.json` from the chat. `/settings` lists 32 keys and the 8 Conclave members with their current values (a default is marked as such), and the list filters as you type. `/settings conclave.members.vaelia` lists that member's four keys, and `/settings <key>`, for example `/settings web.maxFetches`, goes straight to a key; an unknown key gets a hint. The editor depends on the key: a choice for words and on/off, a number box that starts at the current value and refuses a value outside the allowed range, the setup model pick for model keys (it signs in when the provider needs it), and for lists such as `guard.deny` a menu of the entries, where picking an entry removes it and "Add an entry" adds one. Every key can be reset to its default, which removes it from the file. The editor says when a change applies: at the next turn, right away, at the next Conclave run or at the next start. `cacheRetention` applies at the next turn: `"short"` keeps the prompt cache for about 5 minutes, and `"long"` keeps it for an hour and costs more per cache write.
47
+
48
+ `guard.allow` opens a project folder inside a protected location, for the file tools and search, so a project that lives in `~/.pi/agent/extensions` can be worked on. An entry is an absolute path at or inside `<pi agent dir>/extensions` (the pi agent dir is `PI_CODING_AGENT_DIR` when set to an absolute path, otherwise `~/.pi/agent`), or strictly inside a `guard.deny` root. It cannot equal a `guard.deny` entry or lie inside `PIROBOROS_HOME`, `~/.ssh` or `~/.claude`, and an entry with a link or junction in its path is ignored with a notice. It lifts only the protected location that holds it: `auth.json`, `settings.json`, `models.json` and `mcp-auth.json` beside it stay refused, and so does any `guard.deny` root inside it. Inside an allowed folder, credential-shaped names (`.env.*` except `.env.example`, `.sample` and `.template`, `.npmrc`, `*.pem`, `*.key`, `*.db`, `*.sqlite`, `credentials*`, `token`, `secrets` and similar) and `.aws`, `.ssh` and `.gnupg` folders are refused, and write and edit refuse the `.git` folder. A setting that fails these rules is refused when saved; one written by hand is ignored at use with a notice. An allowed folder inside the extensions folder is code that pi runs with your credentials: review edits and merges there like code you install, and merge while pi is not running (or reload pi after). The skills scanner reads through the same check, so `SKILL.md` files inside an allowed folder become readable to it.
49
+
50
+ A change to a security-relevant key shows the old and the new value and asks before it is saved. Those keys are `main`, `compactor.model`, `compactor.allowThirdParty`, `learning.model`, `learning.allowThirdParty`, `conclave.defaultModel`, the model of each Conclave member, `shellEnvAllow`, `shellTimeoutMs`, `guard.deny`, `guard.allow` and the `web` keys. `/model` asks the same way when it changes the main model, and asks nothing when the model is already the main one. A compactor model on a host that is not loopback also asks whether third-party use is allowed, as setup does, and setting `web.search.provider` with no stored key offers to enter the key. Every write goes through the same checked path as `/thinking-steps global`: if `settings.json` was edited outside piroboros, the write is refused until `/reload`. When piroboros was started with `--model`, `/settings` says so and explains that a change to `main` applies when it starts without the flag.
51
+
52
+ `/reload` shows the changed security-relevant settings (hosts, `allowThirdParty`, `shellEnvAllow`, `guard.deny`, `guard.allow`, the `web` keys) and asks before it accepts files that were edited outside piroboros. `/status` shows the messages saved, the summary view size and the cache use of recent responses. The compactor asks its model for lines of at most 400 bytes; 512 bytes stays the hard limit, and a line still over it after five tries is cut at a clause boundary. A provider reply of HTTP 429 or 503 counts as busy: the compactor waits longer and does not count it as an error, up to 20 times per node, and `/status` shows the retries made while the provider was busy. Until a compactor is configured, long messages show as "not summarized yet" lines and each request carries a window of at most 128 KB of the view.
53
+
54
+ `workspace.enabled` (default `true`) and `workspace.nested` (`ask`, `copy` or `inplace`, default `ask`) decide where Vesperia works. With `enabled: false` she writes straight to your project as in 0.2.0. `nested` answers the one-time question for a project that is a repository subfolder, a worktree or a submodule: `copy` gives a Workspace without git, `inplace` works in your folder. Both apply at the next `/conclave approve`, and a held Workspace of another mode refuses the approve until you merge or discard it. `workspace.confine` (`auto`, `none` or `docker`, default `auto`) and `workspace.network` (default `true`) decide how her shell is confined; see [Tools](tools.md#shell-confinement). Both apply at the next Workspace open, and `none` is the only way to turn confinement off on purpose. On Windows, `workspace.wsl.distro` names the WSL distribution to use; unset, the default distribution is used. `workspace.docker.image` (unset by default) names an image you have pulled, such as `node:26.12.1-trixie@sha256:<digest>`; with it set, `auto` tries Docker before bubblewrap, and `docker` needs it. It is a security setting, confirmed on change.
@@ -0,0 +1,25 @@
1
+ # Development
2
+
3
+ [Back to the README](../README.md)
4
+
5
+ This page applies to a source checkout. `src/tune` is not in the npm package.
6
+
7
+ ```
8
+ npm run typecheck
9
+ npm run build
10
+ ```
11
+
12
+ `npm run build` writes `dist/`, the step `npm pack` runs before packing. The launcher never runs a `dist/` found in a checkout. The repository has no test suite.
13
+
14
+ Versions follow semver. See `CHANGELOG.md`.
15
+
16
+ ## Compactor prompt tuning
17
+
18
+ `npm run tune:compactor` runs the real compaction prompts over 12 made-up coding chats (8 dev, 4 held-out, in `src/tune/corpus`) and scores each produced line against fixed probes: exact tokens that must survive, and corrected values that must replace the old one. A candidate in `src/tune/candidates` is kept only if its held-out mean beats the baseline by `--margin` (default 0.02), its dev mean does not drop, and no probe type drops on the held-out chats. The script prints a verdict and never edits `src`; apply a winning candidate to `src/chat/prompt.ts` yourself, then delete its file. A candidate is a JSON file `{ "name", "messageTaskSuffix"?, "mergeTaskSuffix"? }`. The first one, the "was X, now Y (replaced)" rule for merges, won over three repeats (held-out 0.671 to 0.814, corrections kept 4% to 58%) and is now part of the merge task.
19
+
20
+ ```
21
+ npm run tune:compactor -- --dry-run
22
+ npm run tune:compactor -- --yes
23
+ ```
24
+
25
+ It uses the compactor model from your `settings.json` (or `--model provider/id`) with your stored login. Other options: `--repeats N` (default 1) and `--out file.json`, which also holds a `meta` block with the date, model, thinking level, repeats, margin and each candidate's name and text. A real run needs `--yes` because it sends hundreds of requests to that provider and costs money: `--dry-run` prints the minimum call count first, and replies over 512 bytes add retries. The chats are invented and the corpus is not scrubbed or sent anywhere else.
@@ -0,0 +1,33 @@
1
+ # Interface
2
+
3
+ [Back to the README](../README.md)
4
+
5
+ ## The command list and questions
6
+
7
+ Typing `/` as the first character opens a list of commands above the input, with a one-line description and the argument hint of each. Up and Down move, Tab completes the highlighted name, Enter runs a command that takes no argument or completes one that does, and Esc closes the list and keeps the text. After a space the list offers the choices for `/model`, `/conclave`, `/thinking-steps`, `/akashic`, `/login` (providers and the two web keys) and `/settings` (keys and members, matched anywhere in the name). Text that is not a command, such as `/srv/data`, goes to the chat. Questions that need an answer, such as the `/reload` confirmation, open an overlay that replaces the chat until it is answered; Esc cancels it, and a secret typed or pasted there is masked with a fixed-length mask.
8
+
9
+ ## Screen layout
10
+
11
+ The screen is never as tall as the window, because Ink clears the whole console on Windows when a frame is as tall as the window. The chat, the command list, replies, the pane and the notices share the rows, and the chat always keeps at least 3. From top to bottom the screen shows the header, the chat (with held messages under it), standing notices, replies, alerts, the status line, the command list and the input box. In a terminal under 16 rows or 60 columns there is no header and there are no boxes, and a row of key hints sits above the input; otherwise the keys show in the empty input. The chat shows the last 60 entries. PgUp and PgDn scroll it, also while the command list is open, and End returns to the newest line. A view you scrolled stays where it is while new lines arrive, until you press End or send a message. Narrowing the window wraps the text again, so the view position is not kept. Tool calls show their main argument, for example `▸ bash npm run build`, or `[tool bash: npm run build]` in a small terminal. Tool output is limited to 3 rows and ends with `(N more lines)`, and a tool error reads `✗ name message`, or `tool error (name): message` in a small terminal. Reports from Conclave members are labeled `◆ <member> report`, or `<member> report:` in a small terminal. After a failed turn the alert says that your message is back in the input and Enter sends it again, and the hint under the error names the next step for that kind of failure.
12
+
13
+ ## Look
14
+
15
+ From 60 columns and 16 rows the screen is drawn in a theme. A header row shows `◆ piroboros`, the version, the state of the app (`ready`, `working (Esc stops)`, `no model set`, `login required`, `ERROR <reason>`, `error` or `stopped`), the number of Conclave members, and `conclave D/N` while a pipeline is live. In a narrow terminal the version leaves the header first, then the member count, then the Conclave count. From 24 rows a rule runs under the header and the chat box starts with a title row: `◆ piroboros` and the main model. The chat sits in a bordered box. Your messages carry a `● You` label with a rule above it, and replies, tool calls and tool results carry a `◆ piroboros` label. A Conclave report carries a `◆ <Member> report` label that ends with a `done` or `failed` pill (Vesperia's follows her verdict: `done`, `partial`, `blocked` or `failed`) and, on the newest report of a member whose run has ended, the time the run took, such as `(2m 14s)`. While a turn or a pipeline runs, the bottom of the chat box shows a rule and one row: `piroboros is working`, or `Waiting for <member> (turn T of M)`; the rows are left out when the chat would be left with fewer than 4 rows. Below come a status row and the input in a bordered box. The input shows the keys while it is empty. When it fits, a strip at its right shows the token counts of the last reply: `IN`, `OUT`, `CACHE` (the share of the prompt read from the cache) and `CTX` (prompt and output against the model's context window). Otherwise the cache counts stay in the status row.
16
+
17
+ From 100 columns a second box sits beside the chat and has the same height. It is `◆ Conclave review` or `◆ Conclave execution` with a progress bar while a pipeline is on screen, and `◆ Session` with the session rows otherwise. Below that every member has a row with a state pill (`running`, `done`, `failed`, `partial`, `blocked`, `waiting`, `awaiting approve`, `not run` or `idle`; a box too narrow for the long words shows `approve` and `idle`). A muted row under it gives how long an ended member took, or the turn and the start time of the running one, and any detail such as the reason for a failure. The one-line description from the member's agent file follows, clipped to the box. After the members come the running member's thinking and stream, a hint, `◆ Recent Activity` (the starts and ends of the latest pipeline, newest first, each with the time and the verdict or reason, or `no conclave run yet` before a timed run) and `◆ Resource Usage` (the last reply of the main chat: input, output, cache read, the cache share, and the share of the context window with a bar). When the box is too short, rows leave in a fixed order: the descriptions and the activity first, then the thinking and the stream, the rules, the hint, the usage rows, the session rows and the progress bar, and the members and the title last. The strip at the right of the input row shows only while the Input row of Resource Usage is not on screen, and the cache counts stay out of the status row while the strip or the Read row shows them. Under 100 columns the Conclave pane sits under the chat, as described in [The Conclave](conclave.md) and the session panel is not shown.
18
+
19
+ The times come from the `conclave` document: each seat's start and end, in the clock of the harness, are stored from this version on and cleared by a new review (a re-approval clears Vesperia's entry). A run from an older version shows no durations and no activity. If piroboros closes while a seat is running, the seat's end is the time the run resumed, so its duration includes the time the program was closed. The pills and durations on report labels are drawn from these numbers when the screen is drawn; they are never written into a report or sent to a model.
20
+
21
+ The colors are a dark red accent, a lighter tint of it for text, grey for secondary text, and green, amber and red for states. At start piroboros sets the terminal's default background to #1A1A1A with OSC 11 and its default text color to white with OSC 10, and resets both with OSC 111 and OSC 110 when it ends, on SIGTERM, SIGHUP and SIGBREAK, and at process exit. Closing the console window delivers SIGHUP, and Windows ends the process shortly after. Ctrl+Break delivers SIGBREAK. SIGTERM arrives only from a program that sends it. Those handlers exit with code 1 without releasing the lock file, as a default kill does, and the operating system frees the file handle. A hard kill, for example from Task Manager, resets nothing, and the colors stay until the tab closes. `NO_COLOR` with a non-empty value, or `FORCE_COLOR=0` or `FORCE_COLOR=false`, turns the colors and the OSC writes off. The setup wizard that runs before the chat gets the palette colors but not the background.
22
+
23
+ The text cursor is the real terminal cursor, set to a blinking bar (DECSCUSR 5) when piroboros starts and reset (DECSCUSR 0) at the same points as the colors. It is set under `NO_COLOR` too, because only the colors are switched off. It sits after the typed text, at the start of the keys text while the input is empty, and is hidden while a question overlay owns the keys; the setup wizard has no cursor. The screen is redrawn with the cursor hidden and shown again each time, so the blink restarts on every redraw while an answer streams. A hard kill does not reset the shape.
24
+
25
+ ## Thinking steps
26
+
27
+ Above each assistant message the chat shows a panel built from the message's thinking blocks, and from the live partial while the answer is still being written. It is display only: thinking never reaches the index, the view, the compactor or the member briefs. There are three modes. `collapsed` is one line with the most relevant step. `summary` (the default) is up to five steps in order. `expanded` is every step with its text. Alt+T cycles the modes. Ctrl+T sets the main model's thinking level to the next of `off`, `minimal`, `low`, `medium`, `high`, `xhigh` and `max` (then `off` again), writes it to `settings.json` like `/settings thinking`, and it applies at the next turn. A model's `thinkingLevelMap` in `models.json` decides what each level sends. `/thinking-steps <mode>` sets the mode for this session. `/thinking-steps global <mode|clear>` writes `tui.thinkingSteps` in `settings.json` and also sets the session mode; `clear` removes the key and the session shows `summary`. A new session starts from the global value, then `summary`. The rows of the panel wrap to the width and keep the tree gutter. They count against the rows of the screen like any chat line, and a long panel scrolls with the chat.
28
+
29
+ The panel says `Waiting for thinking content` while a response has no thinking yet, `No thinking content supplied` when a finished message has none, and `Reasoning is hidden by the provider` for a redacted block. It is hidden when the thinking level is `off` or the main model has `reasoning` false. Steps are re-derived at most every 100 ms while streaming, from the last 32,000 characters; a finished message is parsed once. In the Conclave pane the running member's thinking steps appear under its name, within the same line limit, and only when the member produced thinking. An entry that holds only tool calls has no thinking line. Text from the model is sanitized, so a control character is shown as a symbol. A zero-width joiner between two emoji, as in a family, a flag or a skin tone, is shown as it is; anywhere else it is shown as a symbol.
30
+
31
+ ## Keys
32
+
33
+ - A message you send while a turn runs is added to that turn. Esc stops the turn and puts your unanswered messages back in the input box, in the order you sent them. Ctrl+C does the same while a turn runs, and a second press within 2 seconds exits. With no turn running, Ctrl+C clears text you typed or pasted, and exits when there is none. Text put back after a stop does not count as typed. While a turn runs, the status line starts with `working (Esc stops)`. Ctrl+T steps the main model's thinking level and Alt+T cycles the thinking steps view (see [Thinking steps](#thinking-steps)). Set `NO_COLOR` to turn colors off; an explicit `FORCE_COLOR` wins over it.
package/docs/memory.md ADDED
@@ -0,0 +1,11 @@
1
+ # Memory
2
+
3
+ [Back to the README](../README.md)
4
+
5
+ Three tools give the model memory that outlives the chat. `akashic_memory` keeps durable facts in SQLite at `${PIROBOROS_HOME}/akashic/memory.sqlite`. The categories are decisions, people, project-state, open-loops, preferences and procedures, and the actions are remember, record, search, update, forget, recent and group. Text over 4,000 characters is split into parts that share a group id. Every write records its actor as `piroboros:<role>`. `mnemosia_brief` returns a ranked briefing from those memories within a token budget, and `mnemosia_submit_feedback` reports how a briefing did. Traces and feedback go under `${PIROBOROS_HOME}/mnemosia/`. The root chat and Vesperia have all three tools. The other Conclave members have `mnemosia_brief` only.
6
+
7
+ Before a turn, the top five memories for the working directory are written to the log as a note whenever they change. The view shows the note as `[akashic snapshot <hash>: ids <list>]`, and `zoom` on it shows the text, framed as untrusted data with `<` and `>` escaped.
8
+
9
+ One scanner checks every memory that is written, updated, imported or shown. It rejects hidden characters, text that overrides instructions, asks for the system prompt, sends secrets to an address, or runs downloaded code. A memory written in a turn that holds only member reports is quarantined: it stays out of the snapshot and out of search until you run `/akashic accept <id|all>`. The status line counts quarantined memories. Vesperia's records wait for `/akashic accept` the same way. After a retry that fixed what an earlier attempt got wrong, she may record a short lesson besides her decision memory; it waits for `/akashic accept` too, and you should read it before accepting, because `/akashic accept all` takes everything.
10
+
11
+ `/akashic vault init <repo-url> [--auto-push]` mirrors every memory to a Git clone at `${PIROBOROS_HOME}/akashic/vault/` as Markdown files, committed as `piroboros <piroboros@localhost>`. SQLite stays the source of truth. Nothing is pulled before a write, and a failed mirror never loses the write: the tool result says `saved locally` and names a code (`VAULT_GIT_MISSING`, `VAULT_GH_MISSING`, `VAULT_NOT_PRIVATE`, `VAULT_TRANSPORT`, `VAULT_DIRTY`, `VAULT_PUSH_REJECTED` or `VAULT_CONFLICT`), the status line shows `vault: sync pending`, and the next write or `/akashic vault sync` tries again. A clone that was edited by hand is not written into until you deal with the edit. Project paths are written as hashes. `/akashic vault import` reads the clone's files into the store as proposed memories. It never overwrites or deletes a stored memory, and proposed memories stay out of the snapshot until you run `/akashic vault accept <id|all>`. Records tagged `source=archive` or `source=compaction-extraction` are never mirrored on their own; `/akashic vault commit [message]` copies them into the clone and commits. `/akashic vault status`, `/akashic vault push` and `/akashic` (counts) complete the set.
@@ -0,0 +1,15 @@
1
+ # Privacy and limits
2
+
3
+ [Back to the README](../README.md)
4
+
5
+ - Each provider you configure receives the prompts for the model you assign to it: the main model gets the chat view, the compactor gets the text it summarizes, and each Conclave member gets its own conversation. Everything sent to the compactor is scrubbed first: credential-shaped strings (keys, authorization headers, PEM blocks, JSON and environment-style labels, password phrases), every value in `auth.json`, and the value of every environment variable named `*_API_KEY`, `*_TOKEN` or `*_SECRET` that is 8 or more characters long. Your local log keeps the raw text. A compactor is a third party when its provider is not the one your main model or any Conclave member uses and its address is not loopback; sending the chat to a third party needs your explicit consent (`compactor.allowThirdParty: true`), and a third party also loses hex strings of 32 or more characters. Without consent the compactor shows as disabled with the reason and nothing is sent. This is checked again on every compactor request, so withdrawing consent and running `/reload` stops the next request. "Loopback" means the host is exactly `localhost`, is inside 127.0.0.0/8, or is `::1`, with no user name or password in the URL; piroboros treats it as user-declared local and cannot check that the address really is.
6
+ - The learning loop (off until `learning.model` is set) sends slices of the root chat to `learning.model`: your messages, the assistant's replies, tool calls and results cut to 1,500 characters each, the skills index, the text of up to two skills it created that the slice read, the names of its pending and rejected proposals and its own memories. It uses the compactor's scrub and the same consent rule: a provider no other role uses, at a non-loopback address, is a third party and needs `learning.allowThirdParty: true`, which is checked on every request. It reads only chat written after it became permitted, and again from the chat end whenever consent is withdrawn and given back, so withdrawn chat is never sent later. It never sends a Conclave member's own conversation. Staged skills, the ledger and its history are files under `PIROBOROS_HOME/learn`. Telemetry records learner requests like the others, without text.
7
+ - Shell output beyond 30,000 characters is cut to its first 12,000 and last 18,000 characters, with a marker in between. The cut part is not saved to any file, so the model has to run the command again to see it.
8
+ - Memory-briefing traces (mnemosia) are written under `PIROBOROS_HOME`. A trace is kept while it is under 90 days old or among the 500 newest, and older ones are deleted at startup. The feedback log, `feedback.jsonl`, is capped at 2 MB; when it passes the cap, the oldest lines are dropped.
9
+ - The shell tool is not path-confined by the guard. The guard limits which agents may write. A shell command can reach any path your account can, except Vesperia's commands in a confined Workspace (bubblewrap on Linux or in WSL 2, or Docker), which see a read-only system or a container and no home folder (see [Shell confinement](tools.md#shell-confinement)).
10
+ - Shell commands that kill processes (`kill`, `pkill`, `killall`, `taskkill`, `tskill`, `Stop-Process`, `spps`, or `wmic` deleting a process) are refused, because `taskkill /IM node.exe` would also end piroboros. This is a tripwire against accidents, not a sandbox: a command can be worded around it.
11
+ - piroboros records model request and task timings to `telemetry.sqlite` under `PIROBOROS_HOME` and sends them nowhere. It records provider and model names, tool names, token counts, cost, durations, stop reasons and error kinds, never message text, tool arguments, tool output or error messages. Records older than 7 days are deleted while piroboros runs. Telemetry is on by default; `"telemetry": false` stops it at the next start, and deleting the file removes what was recorded.
12
+ - piroboros sends no provider attribution headers. Requests still carry the User-Agent `pi/<version> (<platform>; node/<v>; <arch>)` set by pi-ai.
13
+ - The first start of this version copies `chat.sqlite` to `chat.schema1.sqlite` before upgrading it. The copy holds the whole chat, like `chat.sqlite` itself. Delete it once you no longer need to go back to 0.1.0.
14
+ - The memory vault mirrors to a private GitHub repository. Only GitHub remotes are tested.
15
+ - Vesperia's Workspace copies are folders of exact copies of your git-visible project files, under `%LOCALAPPDATA%\piroboros-ws` on Windows, `~/Library/Application Support/piroboros-ws` on macOS and `$XDG_STATE_HOME/piroboros-ws` (default `~/.local/state/piroboros-ws`) elsewhere. The snapshots taken before a merge and the merge records are stored in `PIROBOROS_HOME/ws/store.sqlite`, and a snapshot holds the live bytes of each path the merge changes. These files can contain secrets that are already in your project. Secret-named files and git-ignored files are not copied. They stay on your machine; what Vesperia reads from the Workspace goes to her model as any file she reads does.
package/docs/tools.md ADDED
@@ -0,0 +1,62 @@
1
+ # Tools and skills
2
+
3
+ [Back to the README](../README.md)
4
+
5
+ ## File search, plans and loops
6
+
7
+ - `find` and `grep` search the working directory. They use fff (`@ff-labs/fff-node`, an indexed finder) and fall back to ripgrep when fff cannot load or returns an error, or when `grep` is called with `exact: true`. Each result says which backend answered in `details.backend`. If neither fff nor `rg` works, the tools return a named error (`search_unavailable`). A ripgrep run that fails, for example on an invalid glob, returns `search_rg_failed` with its first error line instead of an empty result. The fff databases live in `${PIROBOROS_HOME}/fff/`. Results under protected locations (`PIROBOROS_HOME`, `~/.ssh`, `.env` files, `guard.deny`) are dropped, credential-shaped text is redacted, and output is capped at 20,000 characters.
8
+ - The `plan` tool keeps a short task list for the current request. The model sends the whole list each time, with exactly one item in progress. The list is shown to the model with every message of that request and is cleared when the next user message starts. Set `"planning": false` in `settings.json` to remove the tool; the change applies at the next start.
9
+ - If the model makes the same tool call five times in a row, it gets a reminder to change approach. If the same call fails eight times in a row, the turn ends and the status line says `stopped (stuck)`. Denied calls do not count. If the model's run produces no output and no tool is running for ten minutes, the turn ends and the status line says `stopped (idle)`. If one run makes 256 tool rounds without finishing, the turn ends and the status line says `stopped (round limit)`.
10
+ - A `bash` command is refused when its text names a protected location (`PIROBOROS_HOME`, `~/.pi`, `~/.ssh`, `~/.claude`, `guard.deny`) in a Windows, Git Bash, WSL or `~`/`$HOME`/`%USERPROFILE%` spelling, names a credential file (`auth.json`, `.netrc`, `id_ed25519` and the like, but not `*.pub`), or uses `..` to climb out of the `guard.allow` folder it runs in. A path inside a `guard.allow` folder is not refused. This is a tripwire against accidents, not confinement: a command can be worded around it, and only Vesperia's commands in a confined Workspace are sandboxed (see below).
11
+
12
+ ## Shell confinement
13
+
14
+ With Workspaces on (the default), Vesperia's `bash` commands run inside bubblewrap on Linux when `bwrap` is on PATH and a self-test passes at the moment the Workspace opens. The choice is kept for that Workspace and made again when it is reopened. On Ubuntu install the `bubblewrap` package. Ubuntu 23.10 and later restrict unprivileged user namespaces by default; when that blocks bubblewrap the self-test fails and the start notice names the reason. On Windows the commands run inside bubblewrap in WSL (see below). When `workspace.docker.image` is set, Docker is tried first on every system (see [Docker](#docker)). macOS has no bubblewrap, so its commands run in Docker or are not confined, and the notice and `/conclave status` say which.
15
+
16
+ - What a command sees: the whole system read-only, the Workspace read-write, an empty `/tmp`, and a home folder with nothing in it. `PIROBOROS_HOME`, `~/.pi`, `~/.ssh`, `~/.claude` and every `guard.deny` folder outside the home are hidden. Folders named on PATH under your home (`~/bin`, `~/.local/bin`, a Node version folder) stay visible read-only, so tools installed there keep working. The live `.git/objects` of the project, and the object folders it borrows from through its own alternates, are visible read-only so that git works in the Workspace. The list is taken from your live repository when the Workspace opens or reopens, never from the Workspace's own `.git/objects/info/alternates`, and only a folder named `objects` is shared.
17
+ - What it cannot do: write outside the Workspace (the write fails, or lands in `/tmp` or the empty home folder and disappears when the command ends) or read your credentials. A live project inside your home is hidden; one outside your home, its `node_modules` included, is still readable by absolute path. Because `/tmp` and the home folder are fresh for every command, `git commit` there uses only the `user.name` and `user.email` kept from the live repository's local config.
18
+ - Network: `workspace.network` (default `true`) lets installs work. With it on, a command can reach your network and send any file it can see. Set it to `false` to cut the network.
19
+ - A command is passed to `bash -c` as one argument, so it can be at most 131,071 bytes and cannot hold a NUL byte; a longer one is refused with a message that suggests a script file in the Workspace. A command that runs past the timeout is killed with everything it started.
20
+ - If a command cannot start, it fails with an error and is never run again without confinement. If bubblewrap was not usable when the Workspace opened, the start notice, her brief and `/conclave status` say the shell is not confined. `workspace.confine: "none"` turns confinement off on purpose.
21
+
22
+ ### The seccomp filter
23
+
24
+ Every sandbox, native or in WSL, also loads a small seccomp filter (written in `src/ws/confine.ts`, no library). It does three things: `socket` and `socketpair` calls for the AF_VSOCK family fail with EAFNOSUPPORT, the three `io_uring` calls fail with EPERM, and a process using a CPU architecture other than x86_64 or aarch64, or the 32-bit x32 system calls, is killed. Everything else is allowed. AF_VSOCK is not scoped to the sandbox's network namespace, and in WSL the Windows host answers on it (one of its ports serves your drives), so closing it matters more than the network setting. The self-test checks that a vsock socket cannot be created; a filter that does not load or a failing self-test gives no sandbox, with the warning, never an unfiltered one.
25
+
26
+ Residuals: with the network on, a command can still reach TCP ports on the Windows host and on your network, and can send any file it can see. 32-bit programs (x86 or ARM) and x32 programs do not run in the sandbox. The filter is not a general system call policy.
27
+
28
+ ### Windows: bubblewrap in WSL
29
+
30
+ Install WSL 2 with a distribution whose default user is not root (Ubuntu 24.04 is the tested one), then in that distribution install `bubblewrap`, and Node 26.5 or later if your project needs `npm`. Do not use the `docker-desktop` distribution; it cannot run commands. Set `workspace.wsl.distro` to pick a distribution other than the default; the distribution and user are fixed when a Workspace opens and kept while they still resolve.
31
+
32
+ - Commands run as that user through `wsl.exe` with an argument list, never a shell string, with a minimal environment (PATH, HOME, USER, LANG and a few terminal settings) built inside WSL: nothing from your Windows environment reaches them.
33
+ - The Workspace stays on your Windows drive and the sandbox sees it through `/mnt/<drive>`. Everything else Windows-backed is hidden: your profile, `System32`, `PIROBOROS_HOME` and every `guard.deny` folder. A Windows program inside the Workspace does not run, and the WSL interop socket is masked.
34
+ - `node_modules` lives in a folder in the distribution's own filesystem (under `~/.local/state/piroboros-ws`), so `npm ci` is fast; it is empty on the Windows side and is removed with the Workspace. Files a command writes there are not merged.
35
+ - The Workspace folder is on drvfs, which is slow for many small files: expect the first `git status` in a project of 5,000 tracked files to take most of a minute and later ones a couple of seconds. The start notice gives an estimate above 1,000 files. A path inside the Workspace that the sandbox shows as `/mnt/c/...` is the Linux view of a Windows path; the file tools want the Windows form.
36
+ - `workspace.network: true` gives the commands the WSL VM's network, which includes the Windows host. Set it to `false` to cut it.
37
+ - A project on a network share (UNC path) is not confined, with the reason in the notice.
38
+
39
+ ### Docker
40
+
41
+ Set `workspace.docker.image` to an image you have already pulled, for example `node:26.12.1-trixie@sha256:<digest>`. piroboros never pulls an image; a missing one refuses with the `docker pull` line to run. With the image set and `workspace.confine` at `auto`, Docker is tried first and bubblewrap second; `workspace.confine: "docker"` refuses the run when Docker cannot be used and never falls back.
42
+
43
+ - One container per Workspace, started when the Workspace opens or reopens and removed at merge, discard, hold and recovery. It runs with all capabilities dropped, `no-new-privileges`, at most 1,024 processes, and a stored 64-character container id that every command uses. Containers carry a label with a hash of your `PIROBOROS_HOME`; the startup sweep removes the ones of that hash that no open Workspace names, and never touches another home's.
44
+ - What a command sees: the image, and the Workspace at `/work`. Nothing else of your machine is mounted: not your home, `PIROBOROS_HOME` or your credentials. The live `.git/objects` is mounted read-only at `/piroboros-objects` for a Workspace with git. `HOME` is `/tmp` inside. On Linux the command runs as your user id; on Windows as the distribution's user. Writes outside `/work` land in the container and are lost when it is removed. `node_modules` is an empty folder in the Workspace (on Windows, a folder in the distribution's own filesystem), never merged.
45
+ - The Engine's built-in seccomp profile is kept, which refuses AF_VSOCK sockets and `io_uring`. An Engine without seccomp is refused. When the container starts, a self-test checks that a vsock socket cannot be created and that `io_uring_setup` fails (it needs `perl` in the image; without it the check is skipped with a notice). A failed check refuses Docker with the reason.
46
+ - piroboros runs the `docker` CLI with an empty client config of its own (so a context or credential helper in `~/.docker` never runs). Only environment variable names are passed to `docker exec`; their values are read from the CLI's own environment, never from the argument list. A command can be at most 131,071 bytes and cannot hold a NUL byte, as with bubblewrap.
47
+ - A command that runs past the timeout restarts the container, which ends everything it started; `/work` survives. When a command exits nonzero, piroboros asks the Engine whether the container is still running. If it is not, or the Engine does not answer, the command fails with `confinement backend unavailable`, no later command runs, nothing runs unconfined, and the run ends held with that reason. A reopen starts a new container.
48
+ - Windows: Docker means the Engine installed inside your WSL 2 distribution (the `docker-ce` package, with your user in the `docker` group, which is root-equivalent inside that distribution), reached as `/usr/bin/docker` through `wsl.exe`. Docker Desktop is refused, whether it is the Engine's name or its integration socket under `/mnt/wsl`. Set `workspace.wsl.distro` if it is not the default distribution. A rootless Engine is not supported.
49
+ - Network: `workspace.network` (default `true`) puts the container on the bridge network; `false` gives it none. With it on a command can reach your network (on Windows, the WSL VM's network, which includes the Windows host) and send any file it can see.
50
+ - Cost per command (measured on Windows with Docker in WSL 2): about 0.7 s, against 0.2 s for bubblewrap in WSL and 0.06 s unconfined; opening a Workspace with Docker takes about 6 s.
51
+
52
+ ## Skills
53
+
54
+ A skill is a folder with a `SKILL.md` file. The file starts with a block between two `---` lines that holds a `name` and a `description`, and the instructions follow. Skills are for the main chat. The Conclave members, the compactor and Vesperia do not get them.
55
+
56
+ - **Where they come from.** In this order, and the first skill with a name wins: `PIROBOROS_HOME/skills`, then the `skills` folder inside `.agents` in your user profile, then the project folders, which are the `skills` folder inside `.agents` and the one inside `.piroboros` in the working directory. A skill is a folder one level down, `<folder>/<skill>/SKILL.md`. A link to a folder is followed. A folder with no `SKILL.md` of its own is listed as skipped and is not searched further.
57
+ - **What is read.** Only `name` and `description`, as plain, quoted or block (`>` and `|`) values. Other keys, including nested ones, are ignored. A name is lowercase letters, digits and single hyphens, at most 64 characters, and it may differ from its folder name. A description is cut to 512 characters, and a `SKILL.md` over 256 KB is skipped. A bad file is skipped with a reason that `/skills` shows, and it never stops startup.
58
+ - **What the model sees.** One line per skill (name, description and folder) in a `skills` section of the system prompt, after the chat section. The text changes only when the list changes, or when a name, description or folder does, so prompt caching keeps working. It is capped at 20 KB, filled in the order above, and `/skills` lists what did not fit. The model opens a `SKILL.md` with the `read` tool when a task matches it, and the section says that a `SKILL.md` at a listed path is your instruction. With no skills installed there is no section. A skill deleted after the last scan gives a read error until `/reload`.
59
+ - **Project skills need a yes.** The first time a project skill is seen, and again whenever its `SKILL.md` changes, the chat asks one question for all of them, listing the names and paths. Yes loads them. No records each as declined, and it stays out until its file changes; typing `/name` for it says so. The answers are in `PIROBOROS_HOME/skills-trust.json`, which is checked like the other config files: an edit outside piroboros is shown at startup, and a missing, corrupt or edited file means every project skill is asked about again. The question opens when the chat screen opens. Until you answer, the index holds your own skills only, and a yes adds the project ones. With `--print` no question is possible, so project skills are left out, nothing is recorded and one line on stderr says how many. Only `SKILL.md` is pinned. Scripts and other files beside it can change without a new question, so say yes only to a folder you trust.
60
+ - **Learned skills.** With `learning.model` set, piroboros can propose skills from your chat. They are staged outside the skills folder and written to `PIROBOROS_HOME/skills` only by `/learn accept <name>`; see [Chat commands](configuration.md#chat-commands).
61
+ - **Commands.** `/skill-name some request` is sent to the chat exactly as typed, and the model reads the skill. Skills appear in the command list after the built-in commands, with their descriptions. A skill named like a built-in command, such as `conclave`, stays available to the model only, and so does a name that starts with a digit. A name with a digit in it is a command only when it is a loaded skill, so `/42 is the answer` and `/v2` stay ordinary text. `/skills` lists the loaded, shadowed, skipped, declined, waiting and over-budget skills. `/reload` rescans and asks about new project skills.
62
+ - **Reading inside `PIROBOROS_HOME`.** The `read` tool may open files under `PIROBOROS_HOME/skills`, so skills installed there work. Files named like secrets stay refused there: `.env` files, `*.pem`, `*.key`, `*.p12`, `*.pfx`, `*.kdbx`, `id_rsa*`, `id_ed25519*`, `id_ecdsa*`, `*.sqlite*`, `auth.json`, `.netrc` and `.npmrc`. Everything else in the home stays refused for every tool: credentials, settings, the chat database, memory, traces, undo copies and the trust file. Writing under `skills` is refused too, a link out of that folder to a protected place is refused, and a `SKILL.md` that is linked into a protected place is skipped. `find` and `grep` search the working directory only, so they never reach it. The guard is a tripwire for the file tools. It cannot tell a hard link from a file, and the root chat's shell commands are not confined.