diff --git a/.opencode/plugins/opencode-power-pack.js b/.opencode/plugins/opencode-power-pack.js index 0a3e5c5..83809e1 100644 --- a/.opencode/plugins/opencode-power-pack.js +++ b/.opencode/plugins/opencode-power-pack.js @@ -36,7 +36,15 @@ export default { async setup(ctx) { const policies = agents(skills); await ctx.skill.transform((editor) => { - for (const skill of skills) editor.add({ ...skill }); + for (const skill of skills) { + // A throw here escapes the transform and the host disables the whole + // plugin, so one rejected skill must not take the other ones with it. + try { + editor.add({ ...skill }); + } catch (error) { + console.error(`[opencode-power-pack] skipped skill ${skill.id}:`, error); + } + } }); await ctx.agent.transform((editor) => { for (const [name, { permissions, ...agent }] of Object.entries(policies)) { diff --git a/tests/plugin-registration.test.mjs b/tests/plugin-registration.test.mjs index 434e987..721a094 100644 --- a/tests/plugin-registration.test.mjs +++ b/tests/plugin-registration.test.mjs @@ -124,6 +124,25 @@ test("plugin registers every bundled skill with the V2 Skill.Info shape", async ); }); +test("a skill rejected by the host does not block the other skills or agents", async (t) => { + const skills = fakeEditor(); + const agents = fakeEditor(); + const add = skills.add; + skills.add = (skill) => { + if (skill.id === "code-reviewer") throw new Error("rejected by host"); + add(skill); + }; + const logged = t.mock.method(console, "error", () => {}); + + await assert.doesNotReject(() => plugin.setup(contextFor(skills, agents))); + + assert.equal(skills.list().length, SKILL_NAMES.length - 1); + assert.equal(skills.get("code-reviewer"), undefined); + assert.ok(agents.get("code-reviewer"), "agents still register after a rejected skill"); + assert.equal(logged.mock.callCount(), 1); + assert.match(String(logged.mock.calls[0].arguments[0]), /code-reviewer/); +}); + test("plugin registers the feature workflow roles as read-only subagents", async () => { const { agents } = await register();