-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Fix superpowers bootstrap injection via experimental.chat.system.transform (top-level hook)
#228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
📝 WalkthroughWalkthroughThe superpowers plugin refactors how bootstrap content is injected. The local Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
my test procedure: Analyzing system prompt superpowersSession ID: ses_47aa089a3ffei3XJ1eYhuG297l Useris there something about superpowers in your system prompt AssistantThinking: Investigating Prompt Content I'm currently focused on the prompt's content, specifically the potential mention of "superpowers." I'm reviewing the system prompt to determine if it's there. My current perspective is that my adherence to the system prompt is a primary aspect of my behavior. I'm focusing on the Reviewing Skill Application I've determined that the "using-superpowers" skill is active and directly relevant, as the request pertains to my inherent capabilities. Though the question is informational, the prompt directly states "You have superpowers." Therefore, I'm confirming this detail, which is outlined in the "Using Skills" section of my operational framework. I will provide a straightforward answer based on this skill's definition. Confirming Response Details I have a concrete answer now, though I am balancing it with the concern for the system prompt's potential sensitivity. The system prompt contains the specifics the user is interested in: "You have superpowers," and this is mentioned in the "superpowers skill library" as well. I'm choosing a concise "Yes" as the appropriate reply. Yes. My instructions state "You have superpowers" and detail how to use a "superpowers skill library" to follow specific workflows for tasks like debugging, testing, and planning. Userlist all superpowers AssistantThinking: Checking Skill Inventory I'm currently focused on identifying all the available "superpowers." I'm using the Compiling Skill Lists I'm now incorporating my library skills. The goal is to create a complete and organized skill inventory. By using the tool, I believe I can get a precise view of all my skills. Output: Tool: find_skills Input: {}Output: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
.opencode/plugin/superpowers.js (1)
177-179: Consider removing or documenting the empty event handler.The event handler now contains only a placeholder comment. If no event handling is required, consider removing it entirely to reduce dead code. If it's intentionally kept for future use or to satisfy a plugin interface requirement, a brief comment explaining the intent would improve clarity.
Option 1: Remove if not needed
}) - }, - event: async ({ event }) => { - // Event handling } + } };Option 2: Document if intentionally kept
event: async ({ event }) => { - // Event handling + // Placeholder: no event handling currently needed. + // Retained for potential future session lifecycle hooks. }
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.opencode/plugin/superpowers.js
🔇 Additional comments (1)
.opencode/plugin/superpowers.js (1)
61-66: Implementation correctly fixes the hook exposure.The hook is now properly exposed at the top level as OpenCode expects. The
||=pattern for initializingoutput.systemis clean.Minor observation: the function is marked
asyncbut contains noawait. If OpenCode doesn't require the hook to return a Promise, this could be simplified to a synchronous function. However, keeping it async is harmless and may future-proof if async operations are added later.
|
Can you please elaborate on the limitation? Do you mean that with this PR, a slightly larger prompt would be injected after session compaction? Or is there something more to it? |
|
Since we cannot know if the session is compacted i can not use the compact = true when generating the injection. |
|
I agree, having a bit larger post-compaction prompt (by hundreds of tokens?) is a walk in the park compared to needing to manually undo, switch agents and resend the initial prompt in every single new conversation. |
|
Superseded by PR #330, which incorporates this fix along with additional changes (native skills support, Windows docs). Thank you for identifying the solution! |
Fixes #226
Summary
This PR refactors bootstrap injection to use the
experimental.chat.system.transformhook instead ofclient.session.prompt.The previous method of injecting a synthetic message caused OpenCode to reset the agent to
buildon the first prompt (see #226). Using the system transform hook avoids this side effect by modifying the system prompt directly before it is sent to the model.Implementation
injectBootstrapand thesession.created/session.compactedevent handlers.experimental.chat.system.transformat the top level of the plugin object.output.system.Known Limitations
sessionIDneeded to track compaction state.