repositories / pi-ext

pi-ext

bugabingas pi extensions

owned by admin

fix(the-system): remove shell mutation guard

1967ef280d045fd84d31fa98aeb6e9df60c6773f

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Changed files (3)

CHANGELOG.md

Modified
6 6 - Modernize extensions for Pi 0.84 API changes around agent sessions, provider headers, auth, and RPC message updates
7 7 - Fix The System README artifact path docs to show plural directories
8 8 - Make `/system init` deterministic with confirmation; it creates schema v3 config, plural artifact directories, and core files directly
9 +- Add an optional project title to The System config; `/system init` writes it from the project directory name and rendered books use it
10 +- Remove The System advisory shell mutation guard; governed confirmation remains on `write` and `edit`
9 11 - Seed `/system init` core files with concise SYSTEM, MISSION, and RULES role guidance while preserving existing core content on rerun
10 12 - Fix `/system init` so rerunning in an initialized project reuses the existing prefix instead of asking again
11 13 - Fix exact `/system` subcommands such as `doctor` and `book` so autocomplete does not consume Enter

extensions/the-system/__tests__/system.test.ts

Modified
14 14 CORE_BYTE_LIMIT,
15 15 composeSystemPrompt,
16 16 preflightFileMutation,
17 - preflightShellMutation,
18 17 runtimeNotice,
19 18 } from "../system.ts";
358 357 assert.match(linked?.reason ?? "", /symbolic link/i);
362 -describe("runtime shell advisory guard", () => {
363 - it.each([
364 - "printf replacement > .system/RULES.md",
365 - "sed -i 's/Approved/Changed/' .system/specs/PX-SPEC-SPEC0001-contract/index.md",
366 - "rm .system/phases/PX-PHASE-PHASE001-delivery/index.md",
367 - "rm -rf .system/plans/PX-PLAN-PLAN0001-build",
368 - "mkdir .system/specs/PX-SPEC-SPEC0001-contract/assets",
369 - "chmod 600 .system/specs/PX-SPEC-SPEC0001-contract/index.md",
370 - "git restore .system/specs/PX-SPEC-SPEC0001-contract/index.md",
371 - ])("blocks recognizable owned mutation: %s", (command) => {
372 - const result = preflightShellMutation(command);
373 - assert.equal(result?.block, true);
374 - assert.match(result?.reason ?? "not a sandbox", /not a sandbox/);
375 - });
376 - it.each([
377 - "cat .system/RULES.md",
378 - "printf report > build/report.txt",
379 - "git status --short",
380 - ])("allows safe shell command: %s", (command) => {
381 - assert.equal(preflightShellMutation(command), undefined);
382 - });
383 -});

extensions/the-system/system.ts

Modified
262 262 return undefined;
265 -const SHELL_MUTATOR =
266 - /(?:^|[;&|]\s*)(?:rm|mv|cp|install|truncate|touch|tee|mkdir|rmdir|ln|chmod|chown|git\s+(?:restore|checkout|clean)|sed\s+-[^\n]*i|perl\s+-[^\n]*i)\b|(?:^|[^<])>>?/i;
267 -const OWNED_SHELL_PATH =
268 - /(?:^|[\s"'`])([^\s"'`;&|]*\.system\/(?:SYSTEM\.md|MISSION\.md|RULES\.md|(?:specs|phases|plans|issues|research)\/[^/\s"'`;&|]+(?:\/[^\s"'`;&|]+)?))(?=$|[\s"'`;&|])/i;
269 -export function preflightShellMutation(command: string): GateResult {
270 - if (!SHELL_MUTATOR.test(command)) return undefined;
271 - const owned = OWNED_SHELL_PATH.exec(command)?.[1];
272 - if (!owned) return undefined;
273 - return blocked(
274 - `The System advisory shell guard blocked recognizable mutation of ${owned}; use write or edit for candidate validation and ownership approval. Shell recognition is not a sandbox or security boundary.`,
275 - );
278 265 export async function preflightFileMutation(
279 266 cwd: string,
280 267 kind: MutationKind,
449 436 hasUI: ctx.hasUI,
450 437 select: (title, items) => ctx.ui.select(title, items),
452 - if (isToolCallEventType("bash", event))
453 - return preflightShellMutation(event.input.command);
454 439 if (isToolCallEventType("write", event))
455 440 return preflightFileMutation(ctx.cwd, "write", event.input, ui);
456 441 if (isToolCallEventType("edit", event))