feat: optional pi-hard-no & pi-branch-enforcer + shared pi-settings module (v0.5.40)#148
feat: optional pi-hard-no & pi-branch-enforcer + shared pi-settings module (v0.5.40)#148royosherove wants to merge 5 commits into
Conversation
- New src/pi-settings.ts with readPiSettings, writePiSettings, updatePiSettings (locked RMW), enablePiPackage, disablePiPackage, isPiPackageEnabled. Throws MalformedPiSettingsError on parse failure. - Add proper-lockfile as direct dependency for cross-process locking. - Migrate src/cli/setup/runtime.ts to use updatePiSettings() - Migrate src/gateway/model-command.ts to use updatePiSettings() - Migrate src/cli/update.ts patchPiSettings() to use updatePiSettings() - provisionExtensions() in bundle.ts: remove pi-hard-no and pi-branch-enforcer from coreExtensions (now opt-in for new setups). - All 591 existing tests pass.
- Remove both packages from coreExtensions in runtime.ts and bundle.ts - Leave GLOBAL_PI_EXTENSION_PACKAGES in update.ts unchanged (npm packages stay installed globally, just not auto-enabled) - Add tests: provisionExtensions no longer adds them to fresh settings, and does NOT strip them from existing settings
- New src/gateway/extension-toggle-command.ts with idempotent setter semantics (on/off arg or inline keyboard menu) - Distinct action IDs (ext_toggle_qi, ext_toggle_be) to avoid duplicate-action-id rejection in command-registry - Button value is just 'on'/'off' (≤3 bytes, under Telegram 64-byte limit) - Stage: pre-turn (works during in-flight agent turn) - Wired in gateway.ts buildCommandDescriptors() - Added to BOT_COMMANDS in telegram/bot-commands.ts - Doctor pi-settings check now distinguishes ENOENT (warn) from SyntaxError (fail + parse message)
- test/pi-settings.test.ts: 12 tests covering read/write/update/ enable/disable/dedup/malformed/concurrency - test/extension-toggle.test.ts: 7 tests covering on/off/menu/ idempotent/action-handler/live-dispatch via dispatchInTurnCommand - All 612 tests pass
- README.md: new 'Optional extensions' section explaining /toggle-* commands, opt-in default, and the restart requirement - CHANGELOG.md: v0.5.40 entry with Added section for new features - Bump package.json version to 0.5.40
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: af6bc75074
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| await updatePiSettings((s) => ({ | ||
| ...s, | ||
| defaultProvider: resolved.provider, | ||
| defaultModel: resolved.model, | ||
| })); |
There was a problem hiding this comment.
Catch malformed settings errors before posting /model result
applyModelSelection() now writes via updatePiSettings(), which throws MalformedPiSettingsError when ~/.pi/agent/settings.json is malformed (including invalid packages types). This function does not catch that error, so /model invocations can bubble an unhandled rejection through command dispatch and return no user-facing response. This is a regression from the previous behavior (which tolerated parse failures via readSettings() fallback) and can break model switching for users with a corrupted settings file until they manually repair it.
Useful? React with 👍 / 👎.
Codex Review — Round 1 (post-implementation)PR #148 verified against PLAN.md v3 (which Codex already approved). Found 2 High, 3 Medium, 1 Low. 🔴 High1. 2. Setup writer is not concurrency-safe — 🟡 Medium3. Setup malformed-JSON handling missing — 4. 5. Concurrency test only covers in-process queue — 🔵 Low6. Verdict: needs fixes before merge. All 6 issues are real and within scope of this PR. |
Summary
Makes
pi-hard-no(quality inspector) andpi-branch-enforceropt-in for new setups, with explicit chat commands to toggle them on/off after install. Existing setups are unaffected.What changed
Shared
pi-settingsmodule (src/pi-settings.ts) — centralises all~/.pi/agent/settings.jsonI/O with atomic writes, per-process queue + on-disk lockfile (proper-lockfile), and typedMalformedPiSettingsError. All 4 existing writers migrated.Opt-in default — Removed
pi-hard-noandpi-branch-enforcerfromcoreExtensionsinruntime.tsandbundle.ts. New installs no longer auto-enable them. The npm packages stay globally installed (via/update) so toggling on doesn't require a fresh install.Toggle commands —
/toggle-quality-inspector [on|off]and/toggle-branch-enforcer [on|off]:ext_toggle_qi,ext_toggle_be) to avoid command-registry duplicate rejectionDoctor check improvement —
pi-settingscheck now distinguishes ENOENT (warn) from SyntaxError (fail + parse message + path).Tests — 21 new tests (12 pi-settings + 7 extension-toggle + 2 bundle provisioning). All 612 tests green.
Codex review history (3 rounds, 11 issues addressed)
Full plan at
~/.roundhouse/workspace/roundhouse-optional-extensions/PLAN.md. Key issues resolved:updatePiSettings()with per-process queue + lockfileCommits