Просмотр исходного кода

fix(opencode): skip V2 setup when V1 invokes it with a V1-shaped ctx

opencode 1.18.18 also calls default.setup, but with a ctx that lacks
the skill/session domains, so the defensive try/catch logged a TypeError
into every V1 session transcript even though V1 is fully served by the
SuperpowersPlugin named export. Detect the V1 shape and return quietly.
GoldJohnKing 1 месяц назад
Родитель
Сommit
ca8cb53f46
1 измененных файлов с 7 добавлено и 0 удалено
  1. 7 0
      .opencode/plugins/superpowers.js

+ 7 - 0
.opencode/plugins/superpowers.js

@@ -155,6 +155,13 @@ export const SuperpowersPlugin = async ({ client, directory }) => {
  *    equivalent of V1's experimental.chat.messages.transform.
  */
 async function setup(ctx) {
+  // V1 (observed on opencode 1.18.18) also invokes default.setup, but with a
+  // V1-shaped ctx that lacks the skill/session domains. Detect it and return
+  // quietly — V1 is served entirely by the SuperpowersPlugin named export.
+  if (!ctx || !ctx.skill || typeof ctx.skill.transform !== 'function' || !ctx.session || typeof ctx.session.hook !== 'function') {
+    return;
+  }
+
   // 1. Register skills (one transform; one draft.add per skill)
   try {
     const skills = [];