Skip to content

feat(providers/pi): opt-in extension discovery via config flag#1298

Merged
coleam00 merged 1 commit intodevfrom
feat/pi-enable-extensions
Apr 19, 2026
Merged

feat(providers/pi): opt-in extension discovery via config flag#1298
coleam00 merged 1 commit intodevfrom
feat/pi-enable-extensions

Conversation

@coleam00
Copy link
Copy Markdown
Owner

@coleam00 coleam00 commented Apr 19, 2026

Summary

  • Adds assistants.pi.enableExtensions (default false) to .archon/config.yaml, gating Pi's extension discovery behind an explicit operator opt-in.
  • When true, Pi loads tools + lifecycle hooks from ~/.pi/agent/extensions/, packages installed via pi install npm:<pkg>, and the workflow's <cwd>/.pi/ directory — opening access to the community extension marketplace at https://shittycodingagent.ai/packages.
  • Trust boundary preserved: default stays suppressed. Enabling this loads arbitrary JS under the Archon server's OS permissions, so operators opt in per-host.
  • Scoped narrowly to extensions only — skills, prompts, themes, and context files remain suppressed (Archon stays the source of truth for those).

Implementation

  • PiProviderDefaults.enableExtensions?: boolean added in packages/providers/src/types.ts with a JSDoc-documented trust-boundary note.
  • parsePiConfig parses the boolean defensively (silently drops non-boolean values, matching Claude/Codex parsers).
  • createNoopResourceLoader accepts enableExtensions?: boolean; flips DefaultResourceLoader({ noExtensions }) from truefalse only when the flag is explicitly true.
  • PiProvider.sendQuery threads the flag through from piConfig → resource loader and logs extensionsEnabled in pi.session_started.

Test plan

  • bun run validate (check:bundled, type-check, lint, format, tests) — all green
  • 4 new parsePiConfig tests: parses true, parses false, drops non-boolean silently, combines with model
  • 3 new PiProvider tests:
    • default suppresses extensions (noExtensions: true)
    • enableExtensions: true flips noExtensions to false while keeping skills/prompts/themes/context suppressed
    • enableExtensions: false keeps noExtensions: true

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • New Features
    • Pi Provider now supports configurable extension discovery and loading. Users can enable or disable extensions through their configuration settings based on their deployment needs. Extensions remain disabled by default to ensure secure and optimized performance, while advanced users can activate them when required for additional functionality.

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>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 19, 2026

📝 Walkthrough

Walkthrough

This PR adds configuration-driven extension discovery support to the Pi provider. The enableExtensions flag is introduced to PiProviderDefaults, parsed from YAML config, and propagated through provider setup to conditionally enable the resource loader's extension discovery capabilities.

Changes

Cohort / File(s) Summary
Type Definitions
packages/providers/src/types.ts
Added enableExtensions?: boolean optional property to PiProviderDefaults interface to support configuration of extension discovery.
Configuration Parsing
packages/providers/src/community/pi/config.ts, packages/providers/src/community/pi/config.test.ts
Added conditional logic to copy enableExtensions into parsed config only when it is a boolean value; non-boolean values are ignored. Test cases verify boolean handling and omission of invalid values.
Provider Implementation
packages/providers/src/community/pi/provider.ts, packages/providers/src/community/pi/provider.test.ts
Updated sendQuery() to compute and propagate enableExtensions from piConfig into resource loader options, and added extensionsEnabled field to session start logs. Tests verify resource loader initialization with correct extension settings based on config presence and value.
Resource Loader
packages/providers/src/community/pi/resource-loader.ts
Added enableExtensions?: boolean option to NoopResourceLoaderOptions and made DefaultResourceLoader's noExtensions setting conditional on this flag (default true, becomes false when enableExtensions: true).

Sequence Diagram

sequenceDiagram
    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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 Extensions bloom when flags align,
Config whispers, loaders shine,
From YAML's words to discovery's call,
Tools and hooks now dance and sprawl! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding an opt-in configuration flag for Pi extension discovery.
Description check ✅ Passed The PR description covers summary, implementation, and test plan comprehensively, though it lacks the detailed UX journey, architecture diagrams, and risk/compatibility sections from the template.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/pi-enable-extensions

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 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 of raw.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

📥 Commits

Reviewing files that changed from the base of the PR and between fb73a50 and b846c46.

📒 Files selected for processing (6)
  • packages/providers/src/community/pi/config.test.ts
  • packages/providers/src/community/pi/config.ts
  • packages/providers/src/community/pi/provider.test.ts
  • packages/providers/src/community/pi/provider.ts
  • packages/providers/src/community/pi/resource-loader.ts
  • packages/providers/src/types.ts

@coleam00
Copy link
Copy Markdown
Owner Author

Archon PR Validation Report

Verdict: APPROVE

Summary

Clean, minimal feature addition threading a single enableExtensions boolean config flag through all four layers of the Pi provider pipeline (type → parser → provider → resource loader). Default behavior preserved (extensions suppressed), security boundary well-documented, and 7 new tests cover all edge cases.

Bug Confirmation

Claim Main Feature
noExtensions: true hardcoded Confirmed Fixed — conditional on config flag
PiProviderDefaults missing field Confirmed Fixed — enableExtensions?: boolean added
parsePiConfig ignores extensions Confirmed Fixed — defensive boolean parsing added
Provider doesn't thread config Confirmed Fixed — threaded + logged in session event

Issues

No blocking issues found. No regressions detected. Fix quality: 5/5.


Validated by archon-validate-pr workflow

@coleam00 coleam00 merged commit ec5e5a5 into dev Apr 19, 2026
4 checks passed
@coleam00 coleam00 deleted the feat/pi-enable-extensions branch April 19, 2026 19:35
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