From 7e59af81488ceb21976eeb1c2d66fe21f8bf697b Mon Sep 17 00:00:00 2001 From: Drew Ritter Date: Mon, 27 Apr 2026 11:38:26 -0700 Subject: test(opencode): simplify bootstrap cache coverage --- .opencode/plugins/superpowers.js | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) (limited to '.opencode/plugins') diff --git a/.opencode/plugins/superpowers.js b/.opencode/plugins/superpowers.js index e32848b..f2b95f2 100644 --- a/.opencode/plugins/superpowers.js +++ b/.opencode/plugins/superpowers.js @@ -114,8 +114,9 @@ ${toolMapping} // 2. Multiple system messages breaking Qwen and other models (#894) // // The hook fires on every agent step (not just every turn) because - // opencode's prompt.ts reloads messages from DB each step. The guard - // below prevents duplicate injection on the fresh in-memory objects. + // opencode's prompt.ts reloads messages from DB each step. Fresh message + // arrays may need injection again, so getBootstrapContent() must not do + // repeated disk work. 'experimental.chat.messages.transform': async (_input, output) => { const bootstrap = getBootstrapContent(); if (!bootstrap || !output.messages.length) return; @@ -123,15 +124,8 @@ ${toolMapping} if (!firstUser || !firstUser.parts.length) return; // Guard: skip if first user message already contains bootstrap. - // Because messages are loaded fresh from DB each step (the previous - // in-memory injection is never persisted), this guard fires on the - // *new* in-memory objects. It still works correctly: the first step - // injects, and on subsequent steps the content-based check catches it - // because we're looking at the same logical first-user message that - // was just injected into (the DB hasn't changed between steps within - // a single turn, so filterCompactedEffect returns the same message - // contents and we re-inject the same bootstrap — the guard prevents - // doubling up within the same messages array). + // This prevents double injection when OpenCode passes an already + // transformed in-memory message array through the hook again. if (firstUser.parts.some(p => p.type === 'text' && p.text.includes('EXTREMELY_IMPORTANT'))) return; const ref = firstUser.parts[0]; @@ -139,9 +133,3 @@ ${toolMapping} } }; }; - -// Exported for testing — allows tests to reset the cache between runs -export const _testing = { - resetCache: () => { _bootstrapCache = undefined; }, - getCache: () => _bootstrapCache, -}; -- cgit