feat(providers/pi): opt-in extension discovery via config flag#1298
feat(providers/pi): opt-in extension discovery via config flag#1298
Conversation
Adds `assistants.pi.enableExtensions` (default false) to `.archon/config.yaml`. When true, Pi's `noExtensions` guard is lifted so the session loads tools and lifecycle hooks from `~/.pi/agent/extensions/`, packages installed via `pi install npm:<pkg>`, and the workflow's cwd `.pi/` directory — opening up the community extension ecosystem at https://shittycodingagent.ai/packages. Default stays suppressed to preserve the "Archon is source of truth" trust boundary: enabling this loads arbitrary JS under the Archon server's OS permissions, including whatever extension code the target repo happens to ship. Operators opt in explicitly, per-host. Skills, prompt templates, themes, and context files remain suppressed even when extensions are enabled — only the extensions gate opens. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
📝 WalkthroughWalkthroughThis PR adds configuration-driven extension discovery support to the Pi provider. The Changes
Sequence DiagramsequenceDiagram
participant Config as YAML Config
participant Parser as parsePiConfig
participant Provider as PiProvider
participant ResourceLoader as createNoopResourceLoader
participant Loader as DefaultResourceLoader
Config->>Parser: raw config with enableExtensions
Parser->>Parser: Check if enableExtensions is boolean
alt Boolean value
Parser->>Provider: PiProviderDefaults {enableExtensions: true/false}
else Non-boolean or absent
Parser->>Provider: PiProviderDefaults {}
end
Provider->>Provider: Compute enableExtensions from piConfig
Provider->>ResourceLoader: {enableExtensions: true/false}
ResourceLoader->>ResourceLoader: Set noExtensions = !enableExtensions
ResourceLoader->>Loader: Create with noExtensions setting
Loader->>Loader: Initialize with extension discovery enabled/disabled
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/providers/src/community/pi/config.ts (1)
18-20: LGTM — consistent with existing defensive-parse pattern.The
typeof … === 'boolean'guard preserves the "never throw on malformed user config" invariant documented at the top of the function and mirrors the handling ofraw.model. Silently dropping non-boolean values is intentional and already documented in the function-level comment.Minor consideration (non-blocking): operators who mistype
enableExtensions: "true"(YAML string) will silently get the disabled default with no feedback. A debug-level log when dropping a present-but-wrong-typed key would make misconfiguration easier to diagnose, but this is consistent with the other providers' parsers so it's fine to defer.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/providers/src/community/pi/config.ts` around lines 18 - 20, Keep the current typeof guard for raw.enableExtensions that silently drops non-boolean values (preserving the defensive-parse invariant) but optionally add a debug-level log when raw.enableExtensions is present but not a boolean: detect the presence of the property (raw.hasOwnProperty('enableExtensions') or 'enableExtensions' in raw) and when typeof raw.enableExtensions !== 'boolean' call your logger.debug with a concise message referencing the key and its actual type/value; leave assignment to result.enableExtensions unchanged when the value is a boolean.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages/providers/src/community/pi/config.ts`:
- Around line 18-20: Keep the current typeof guard for raw.enableExtensions that
silently drops non-boolean values (preserving the defensive-parse invariant) but
optionally add a debug-level log when raw.enableExtensions is present but not a
boolean: detect the presence of the property
(raw.hasOwnProperty('enableExtensions') or 'enableExtensions' in raw) and when
typeof raw.enableExtensions !== 'boolean' call your logger.debug with a concise
message referencing the key and its actual type/value; leave assignment to
result.enableExtensions unchanged when the value is a boolean.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: a6ea1650-77e3-4bda-a560-e50a7071610f
📒 Files selected for processing (6)
packages/providers/src/community/pi/config.test.tspackages/providers/src/community/pi/config.tspackages/providers/src/community/pi/provider.test.tspackages/providers/src/community/pi/provider.tspackages/providers/src/community/pi/resource-loader.tspackages/providers/src/types.ts
Archon PR Validation ReportVerdict: APPROVE SummaryClean, minimal feature addition threading a single Bug Confirmation
IssuesNo blocking issues found. No regressions detected. Fix quality: 5/5. Validated by archon-validate-pr workflow |
Summary
assistants.pi.enableExtensions(defaultfalse) to.archon/config.yaml, gating Pi's extension discovery behind an explicit operator opt-in.true, Pi loads tools + lifecycle hooks from~/.pi/agent/extensions/, packages installed viapi install npm:<pkg>, and the workflow's<cwd>/.pi/directory — opening access to the community extension marketplace at https://shittycodingagent.ai/packages.Implementation
PiProviderDefaults.enableExtensions?: booleanadded inpackages/providers/src/types.tswith a JSDoc-documented trust-boundary note.parsePiConfigparses the boolean defensively (silently drops non-boolean values, matching Claude/Codex parsers).createNoopResourceLoaderacceptsenableExtensions?: boolean; flipsDefaultResourceLoader({ noExtensions })fromtrue→falseonly when the flag is explicitlytrue.PiProvider.sendQuerythreads the flag through frompiConfig→ resource loader and logsextensionsEnabledinpi.session_started.Test plan
bun run validate(check:bundled, type-check, lint, format, tests) — all greenparsePiConfigtests: parsestrue, parsesfalse, drops non-boolean silently, combines withmodelPiProvidertests:noExtensions: true)enableExtensions: trueflipsnoExtensionstofalsewhile keeping skills/prompts/themes/context suppressedenableExtensions: falsekeepsnoExtensions: true🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes