mirror of
https://github.com/waybarrios/opencode-power-pack.git
synced 2026-11-18 18:03:43 +00:00
Merge pull request #52 from wolfer82/feat/opencode-v2-support
Skip a skill the host rejects instead of disabling the plugin
This commit is contained in:
@@ -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)) {
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user