summaryrefslogtreecommitdiff
path: root/.opencode
diff options
context:
space:
mode:
Diffstat (limited to '.opencode')
-rw-r--r--.opencode/INSTALL.md31
-rw-r--r--.opencode/plugins/superpowers.js31
2 files changed, 56 insertions, 6 deletions
diff --git a/.opencode/INSTALL.md b/.opencode/INSTALL.md
index 2dc2b23..94c3415 100644
--- a/.opencode/INSTALL.md
+++ b/.opencode/INSTALL.md
@@ -14,10 +14,14 @@ Add superpowers to the `plugin` array in your `opencode.json` (global or project
}
```
-Restart OpenCode. That's it — the plugin auto-installs and registers all skills.
+Restart OpenCode. The plugin installs through OpenCode's plugin manager and
+registers all skills.
Verify by asking: "Tell me about your superpowers"
+OpenCode uses its own plugin install. If you also use Claude Code, Codex, or
+another harness, install Superpowers separately for each one.
+
## Migrating from the old symlink-based install
If you previously installed superpowers using `git clone` and symlinks, remove the old setup:
@@ -46,7 +50,10 @@ use skill tool to load superpowers/brainstorming
## Updating
-Superpowers updates automatically when you restart OpenCode.
+OpenCode installs Superpowers through a git-backed package spec. Some OpenCode
+and Bun versions pin that resolved git dependency in a lockfile or cache, so a
+restart may not pick up the newest Superpowers commit. If updates do not appear,
+clear OpenCode's package cache or reinstall the plugin.
To pin a specific version:
@@ -64,6 +71,26 @@ To pin a specific version:
2. Verify the plugin line in your `opencode.json`
3. Make sure you're running a recent version of OpenCode
+### Windows install issues
+
+Some Windows OpenCode builds have upstream installer issues with git-backed
+plugin specs, including cache paths for `git+https` URLs and Bun not finding
+`git.exe` even when it works in a normal terminal. If OpenCode cannot install
+the plugin, try installing with system npm and pointing OpenCode at the local
+package:
+
+```powershell
+npm install superpowers@git+https://github.com/obra/superpowers.git --prefix "$HOME\.config\opencode"
+```
+
+Then use the installed package path in `opencode.json`:
+
+```json
+{
+ "plugin": ["~/.config/opencode/node_modules/superpowers"]
+}
+```
+
### Skills not found
1. Use `skill` tool to list what's discovered
diff --git a/.opencode/plugins/superpowers.js b/.opencode/plugins/superpowers.js
index 48a2b72..f2b95f2 100644
--- a/.opencode/plugins/superpowers.js
+++ b/.opencode/plugins/superpowers.js
@@ -46,17 +46,29 @@ const normalizePath = (p, homeDir) => {
return path.resolve(normalized);
};
+// Module-level cache for bootstrap content.
+// The SKILL.md file does not change during a session, so reading + parsing it
+// once eliminates redundant fs.existsSync + fs.readFileSync + regex work on
+// every agent step. See #1202 for the full analysis.
+let _bootstrapCache = undefined; // undefined = not yet loaded, null = file missing
+
export const SuperpowersPlugin = async ({ client, directory }) => {
const homeDir = os.homedir();
const superpowersSkillsDir = path.resolve(__dirname, '../../skills');
const envConfigDir = normalizePath(process.env.OPENCODE_CONFIG_DIR, homeDir);
const configDir = envConfigDir || path.join(homeDir, '.config/opencode');
- // Helper to generate bootstrap content
+ // Helper to generate bootstrap content (cached after first call)
const getBootstrapContent = () => {
+ // Return cached result on subsequent calls
+ if (_bootstrapCache !== undefined) return _bootstrapCache;
+
// Try to load using-superpowers skill
const skillPath = path.join(superpowersSkillsDir, 'using-superpowers', 'SKILL.md');
- if (!fs.existsSync(skillPath)) return null;
+ if (!fs.existsSync(skillPath)) {
+ _bootstrapCache = null;
+ return null;
+ }
const fullContent = fs.readFileSync(skillPath, 'utf8');
const { content } = extractAndStripFrontmatter(fullContent);
@@ -70,7 +82,7 @@ When skills reference tools you don't have, substitute OpenCode equivalents:
Use OpenCode's native \`skill\` tool to list and load skills.`;
- return `<EXTREMELY_IMPORTANT>
+ _bootstrapCache = `<EXTREMELY_IMPORTANT>
You have superpowers.
**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.**
@@ -79,6 +91,8 @@ ${content}
${toolMapping}
</EXTREMELY_IMPORTANT>`;
+
+ return _bootstrapCache;
};
return {
@@ -98,13 +112,22 @@ ${toolMapping}
// Using a user message instead of a system message avoids:
// 1. Token bloat from system messages repeated every turn (#750)
// 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. 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;
const firstUser = output.messages.find(m => m.info.role === 'user');
if (!firstUser || !firstUser.parts.length) return;
- // Only inject once
+
+ // Guard: skip if first user message already contains bootstrap.
+ // 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];
firstUser.parts.unshift({ ...ref, type: 'text', text: bootstrap });
}