summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Vincent <jesse@fsck.com>2026-10-22 20:51:39 +0000
committerJesse Vincent <jesse@fsck.com>2026-10-22 20:51:39 +0000
commit7455441f77de6c33b3f2f25159fa9dc6d2cc1305 (patch)
treefb8a53c8b10848531768d2563ae90b3227e89ec5
parent0f9581f6c1525b51dc1600b14d24f3db1f601446 (diff)
fix(pi): stop resources_discover from bypassing package skill filtersfix/2394-pi-skill-filters
The pi extension registered a resources_discover handler that returned the whole skills/ directory. pi applies a package's `skills` filter (the one `pi config` writes) only to manifest-declared resources; paths an extension contributes are merged afterwards, unfiltered. So with `"skills": []` or an allowlist on the superpowers package entry, pi 0.85.1 still loaded all 15 skills, every one attributed to extension:superpowers. package.json already declares `pi.skills: ["./skills"]`, and pi loads that with the user's filter applied, so the handler was redundant for package installs, including the README's `pi -e /path/to/superpowers`. Remove it. The bootstrap handlers are unchanged. The porting guide now names the manifest as pi's discovery mechanism. Verified against the real pi 0.85.1 CLI (RPC get_commands, no model call): skills [] loads 0 (was 15), an allowlist of using-superpowers loads 1 (was 15), no filter loads 15, `pi -e <checkout>` loads 15. Fixes #2394 Co-authored-by: m2dumpling <224757904+m2dumpling@users.noreply.github.com> Claude-Session: https://claude.ai/code/session_01SHANcr4A71nzuU9et4Fnba
-rw-r--r--.pi/extensions/superpowers.ts4
-rw-r--r--docs/porting-to-a-new-harness.md6
-rw-r--r--tests/pi/test-pi-extension.mjs14
3 files changed, 6 insertions, 18 deletions
diff --git a/.pi/extensions/superpowers.ts b/.pi/extensions/superpowers.ts
index a978e80..2e948e9 100644
--- a/.pi/extensions/superpowers.ts
+++ b/.pi/extensions/superpowers.ts
@@ -16,10 +16,6 @@ let cachedBootstrap: string | null | undefined;
export default function superpowersPiExtension(pi: ExtensionAPI) {
let injectBootstrap = true;
- pi.on("resources_discover", async () => ({
- skillPaths: [skillsDir],
- }));
-
pi.on("session_start", async () => {
injectBootstrap = true;
});
diff --git a/docs/porting-to-a-new-harness.md b/docs/porting-to-a-new-harness.md
index f52cd70..4964ff0 100644
--- a/docs/porting-to-a-new-harness.md
+++ b/docs/porting-to-a-new-harness.md
@@ -519,8 +519,8 @@ honors the rule rather than breaking it. Distinguish three cases:
`activate_skill`): point the mapping at that tool.
2. **Native skill *discovery* but no `Skill` tool** (pi, Antigravity): the harness
can find and list skills, but the model can't call a tool to load one. Get the
- skills installed where the harness scans (pi registers via `resources_discover`
- → `skillPaths`; OpenCode via its `config` hook; `agy plugin install` copies
+ skills installed where the harness scans (pi declares them in the package
+ manifest's `pi.skills`; OpenCode via its `config` hook; `agy plugin install` copies
them in), and tell the model to load a skill by **reading its `SKILL.md` with
the file-read tool when the skill applies** — the sanctioned mechanism here,
the way `references/pi-tools.md` states it.
@@ -811,7 +811,7 @@ Use this as the live index; when in doubt, read the files, not this table.
| Gemini CLI | `gemini-extension.json` + `GEMINI.md` | instructions file `@`-includes bootstrap + mapping | `references/gemini-tools.md` | — | `gemini extensions install` |
| Kimi Code | `.kimi-plugin/plugin.json` | manifest `sessionStart.skill` loads `using-superpowers` | inline `skillInstructions` in manifest | `tests/kimi/` | marketplace or `/plugins install` GitHub URL |
| OpenCode | `.opencode/plugins/superpowers.js` (root `package.json` `main` for package installs; root `index.js` re-export for the V2 directory form) | in-process: `config` hook registers skills dir; `experimental.chat.messages.transform` (V1) / `session.hook("context")` (V2) injects user message | inline in `superpowers.js` | `tests/opencode/` | `opencode.json` `plugin` (V1) / `plugins` (V2) git URL |
-| pi | `.pi/extensions/superpowers.ts` | in-process: `resources_discover` registers skills; `context` event injects user message; lifecycle-flag + compaction-aware | `piToolMapping()` inline **and** `references/pi-tools.md` | `tests/pi/` | repo-root `package.json` fields |
+| pi | `.pi/extensions/superpowers.ts` | in-process: package manifest registers skills; `context` event injects user message; lifecycle-flag + compaction-aware | `piToolMapping()` inline **and** `references/pi-tools.md` | `tests/pi/` | repo-root `package.json` fields |
## Appendix B — Gotchas that have bitten porters
diff --git a/tests/pi/test-pi-extension.mjs b/tests/pi/test-pi-extension.mjs
index d7af9cb..c79f710 100644
--- a/tests/pi/test-pi-extension.mjs
+++ b/tests/pi/test-pi-extension.mjs
@@ -51,24 +51,16 @@ test('package.json declares a pi package with skills and extension resources', a
assert.deepEqual(pkg.pi.extensions, ['./.pi/extensions/superpowers.ts']);
});
-test('extension registers lifecycle hooks without pre-compaction injection', async () => {
+test('extension leaves package skill discovery to Pi and registers lifecycle hooks', async () => {
const { handlers } = await loadExtension();
- for (const event of ['resources_discover', 'session_start', 'session_compact', 'context', 'agent_end']) {
+ assert.equal((handlers.get('resources_discover') ?? []).length, 0, 'extension must not bypass package skill filters');
+ for (const event of ['session_start', 'session_compact', 'context', 'agent_end']) {
assert.equal((handlers.get(event) ?? []).length, 1, `missing ${event} handler`);
}
assert.equal((handlers.get('session_before_compact') ?? []).length, 0);
});
-test('resources_discover contributes the bundled skills directory', async () => {
- const { handlers } = await loadExtension();
- const discover = firstHandler(handlers, 'resources_discover');
-
- const result = await discover({ type: 'resources_discover', cwd: repoRoot, reason: 'startup' }, {});
-
- assert.deepEqual(result.skillPaths, [resolve(repoRoot, 'skills')]);
-});
-
test('startup context injects the bootstrap as one user message until agent_end', async () => {
const { handlers } = await loadExtension();
const sessionStart = firstHandler(handlers, 'session_start');