summaryrefslogtreecommitdiff
path: root/.opencode/plugins/superpowers.js
diff options
context:
space:
mode:
authorJesse Vincent <jesse@fsck.com>2026-10-22 22:26:39 +0000
committerJesse Vincent <jesse@fsck.com>2026-10-22 22:55:47 +0000
commit9e663a0dd87ac082f10f8ee6b46476951be027d1 (patch)
treeff4adb67a468856e9aaecc9513b525e6776e333b /.opencode/plugins/superpowers.js
parentb58deb3b948d4c305feeac122700100419ee2777 (diff)
fix(opencode): don't mistake a prompt that mentions EXTREMELY_IMPORTANT for the bootstrapfix/2197-opencode-bootstrap-guard
Both bootstrap injectors skip a first user message whose text parts include the substring 'EXTREMELY_IMPORTANT', to avoid injecting twice into the same message. Any user prompt that names the tag matches too, so the bootstrap is silently dropped for that session. That is what #2197 hit. The reporter's probe was opencode run "Is there an 'EXTREMELY_IMPORTANT' block in your context? ..." and the prompt itself tripped the guard. `opencode run` is not the cause: with the real hosts (V1 1.18.21 path and git-package forms, V1 1.19.4, V2 2.1.2, V2 2.1.3) and a request-recording stub model, the reporter's prompt reaches the model without the bootstrap on every host, and a neutral prompt gets the bootstrap on every host. Match the bootstrap's own opening line at the start of a part instead. The injected part always starts with it (the template now uses the same constant), so the double-injection guard keeps working, and a prompt that only mentions the tag no longer suppresses the bootstrap. Fixes #2197 Claude-Session: https://claude.ai/code/session_01SHANcr4A71nzuU9et4Fnba
Diffstat (limited to '.opencode/plugins/superpowers.js')
-rw-r--r--.opencode/plugins/superpowers.js12
1 files changed, 8 insertions, 4 deletions
diff --git a/.opencode/plugins/superpowers.js b/.opencode/plugins/superpowers.js
index 9eff811..50e123f 100644
--- a/.opencode/plugins/superpowers.js
+++ b/.opencode/plugins/superpowers.js
@@ -112,6 +112,11 @@ Use OpenCode's native \`skill\` tool to list and load skills.`;
// regex work on every agent step. See #1202 for the full analysis.
const _bootstrapCache = new Map(); // mapping -> bootstrap (null = file missing)
+// Opening of every injected bootstrap part. The already-injected guards match
+// it at the start of a part, so a prompt that merely mentions the tag (#2197)
+// is not mistaken for the bootstrap.
+const BOOTSTRAP_MARKER = '<EXTREMELY_IMPORTANT>\nYou have superpowers.';
+
// Helper to generate bootstrap content (cached after first call per mapping)
const getBootstrapContent = (toolMapping) => {
// Return cached result on subsequent calls
@@ -127,8 +132,7 @@ const getBootstrapContent = (toolMapping) => {
const fullContent = fs.readFileSync(skillPath, 'utf8');
const { content } = extractAndStripFrontmatter(fullContent);
- _bootstrapCache.set(toolMapping, `<EXTREMELY_IMPORTANT>
-You have superpowers.
+ _bootstrapCache.set(toolMapping, `${BOOTSTRAP_MARKER}
**IMPORTANT: The using-superpowers skill content is included below. It is ALREADY LOADED - you are currently following it. Do NOT use the skill tool to load "using-superpowers" again - that would be redundant.**
@@ -248,7 +252,7 @@ export const SuperpowersPlugin = async ({ client, directory }) => {
if (!firstUser || !firstUser.parts.length) return;
// Guard: skip if first user message already contains bootstrap.
- if (firstUser.parts.some(p => p.type === 'text' && p.text.includes('EXTREMELY_IMPORTANT'))) return;
+ if (firstUser.parts.some(p => p.type === 'text' && p.text.startsWith(BOOTSTRAP_MARKER))) return;
// #2160: never restart the controller workflow inside task subagent
// (child) sessions. V1 passes no input to this hook (verified in the
@@ -342,7 +346,7 @@ async function setup(ctx) {
if (!bootstrap || !event.messages || !event.messages.length) return;
const firstUser = event.messages.find(m => m.role === 'user');
if (firstUser && (!firstUser.content || !firstUser.content.length)) return;
- if (firstUser?.content.some(p => p.type === 'text' && p.text && p.text.includes('EXTREMELY_IMPORTANT'))) return;
+ if (firstUser?.content.some(p => p.type === 'text' && p.text && p.text.startsWith(BOOTSTRAP_MARKER))) return;
// #2160: the context event carries the sessionID directly. Skip the
// controller bootstrap when this prompt belongs to a task subagent