Skip to content

feat(provider, webview): add GUI editing for PI system prompt files - #2

Merged
Printaga merged 1 commit into
mainfrom
freebuff/can-you-add-a-option-in-the-gui-to-edit-pi-s-syste-79896cfc-62ef-4818-9aad-aeb1cd99bd8a
Sep 13, 2026
Merged

Printaga merged 1 commit into
mainfrom
freebuff/can-you-add-a-option-in-the-gui-to-edit-pi-s-syste-79896cfc-62ef-4818-9aad-aeb1cd99bd8a

Conversation

@Printaga

Copy link
Copy Markdown
Owner

What this does

User-facing feature: Settings → Configuration Files now has "Open SYSTEM.md" and "Open APPEND_SYSTEM.md" buttons, mirroring the existing settings/auth/models buttons. Clicking creates the file in PI's agent directory (default ~/.pi/agent, configurable via pi-agent.agentDir) when missing and opens it in a VS Code editor tab. SYSTEM.md replaces PI's built-in system prompt for new sessions, so first creation asks for confirmation; APPEND_SYSTEM.md appends to PI's prompt and is created silently. Existing files are never clobbered.

Override warning: when pi-agent.systemPrompt / pi-agent.appendSystemPrompts are set in VS Code settings, PI's SDK ignores the SYSTEM.md/APPEND_SYSTEM.md files entirely. The Settings panel now fetches the active override state from the host and shows a warning naming the overriding setting, so the buttons are never silently inert.

pi-agent.agentDir env bridge: the setting was documented (README, package.json) but read by nothing — the SDK honors only the PI_CODING_AGENT_DIR env var. Activation now bridges the setting into that env var before the provider is built, so agent dir resolution (sessions, auth, models, prompt files) honors it. Changes take effect after a window reload; the setting description now says so.

Test-lane repairs:

  • New real-host spec (src/test/suite/realhost-openconfigfile.test.ts): drives openConfigFile inside the actual VS Code extension host — real dialogs (auto-answered), real editor tabs, real filesystem, temp agent dir — covering create, confirm, cancel, EEXIST-preserve, and invalid-key rejection.
  • runTest.ts now prefers the real Electron binary over the distro code wrapper: /usr/bin/code → …/bin/code re-forks the GUI via cli.js, the test runner loses process ownership, and the run exits 0 without ever starting mocha (observed silent-exit flake).
  • The vscode facade (suite/index.ts) stays mockable against VS Code 1.137's frozen workspace.fs namespace: frozen plain objects are now treated as real namespaces (never copied by reference), and resetVscodeMocks stubs fs.readFile like the plain-Node facade already does.

Also: unit tests for the new message/handler paths (deduplicated scaffolding via a shared stub helper) and a CHANGELOG entry.

Verification

  • pnpm run build — 0 errors
  • pnpm run lint — clean
  • Node lane (node scripts/run-node-tests.mjs) — 571 pass / 1 fail; the 1 is the pre-existing light-mode flake, which fails identically on the untouched baseline
  • Focused Electron gate, MOCHA_GREP="MessageHandler" — 116 pass, exit 0
  • REALHOST spec — 6 pass inside the real extension host
  • The full-Electron-lane exit-7 instability is documented-environmental in this sandbox (the reason scripts/run-node-tests.mjs exists) and unrelated to this change

- Settings -> Configuration Files: "Open SYSTEM.md" / "Open
  APPEND_SYSTEM.md" buttons create the file in the agent directory when
  missing (SYSTEM.md with a confirmation) and open it in an editor tab
- Show a warning in Settings when pi-agent.systemPrompt /
  pi-agent.appendSystemPrompts override the SYSTEM.md files
- Apply pi-agent.agentDir by bridging it to PI_CODING_AGENT_DIR at
  activation; setting description notes the required window reload
- Test lane: add a real-host openConfigFile spec, prefer the real
  Electron binary over the distro code wrapper in runTest (silent-exit
  flake), and keep the vscode facade mockable against VS Code 1.137's
  frozen workspace.fs namespace

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
@Printaga
Printaga merged commit 353c745 into main Sep 13, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant