summaryrefslogtreecommitdiff
path: root/.opencode
diff options
context:
space:
mode:
authororibi <oribarilan@gmail.com>2026-01-19 23:54:50 +0200
committerGitHub <noreply@github.com>2026-01-19 13:54:50 -0800
commita01a135fe185559ff9dc84dd70d6e9bb57d92bdf (patch)
treecd69a5a00092889a40670f005deddee070c0bd33 /.opencode
parentac471e69c2a672f50e491a45f6ff56b104d0e562 (diff)
fix: respect OPENCODE_CONFIG_DIR for personal skills lookup (#297)
* fix: respect OPENCODE_CONFIG_DIR for personal skills lookup The plugin was hardcoded to look for personal skills in ~/.config/opencode/skills, ignoring users who set OPENCODE_CONFIG_DIR to a custom path (e.g., for dotfiles management). Now uses OPENCODE_CONFIG_DIR if set, falling back to the default path. * fix: update help text to use dynamic paths Use configDir and personalSkillsDir variables in help text so paths are accurate when OPENCODE_CONFIG_DIR is set. * fix: normalize OPENCODE_CONFIG_DIR before use Handle edge cases where the env var might be: - Empty or whitespace-only - Using ~ for home directory (common in .env files) - A relative path Now trims, expands ~, and resolves to absolute path.
Diffstat (limited to '.opencode')
-rw-r--r--.opencode/plugin/superpowers.js24
1 files changed, 21 insertions, 3 deletions
diff --git a/.opencode/plugin/superpowers.js b/.opencode/plugin/superpowers.js
index d94c1ba..3b441f9 100644
--- a/.opencode/plugin/superpowers.js
+++ b/.opencode/plugin/superpowers.js
@@ -14,12 +14,30 @@ import * as skillsCore from '../../lib/skills-core.js';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
+// Normalize a path: trim whitespace, expand ~, resolve to absolute
+const normalizePath = (p, homeDir) => {
+ if (!p || typeof p !== 'string') return null;
+ let normalized = p.trim();
+ if (!normalized) return null;
+ // Expand ~ to home directory
+ if (normalized.startsWith('~/')) {
+ normalized = path.join(homeDir, normalized.slice(2));
+ } else if (normalized === '~') {
+ normalized = homeDir;
+ }
+ // Resolve to absolute path
+ return path.resolve(normalized);
+};
+
export const SuperpowersPlugin = async ({ client, directory }) => {
const homeDir = os.homedir();
const projectSkillsDir = path.join(directory, '.opencode/skills');
// Derive superpowers skills dir from plugin location (works for both symlinked and local installs)
const superpowersSkillsDir = path.resolve(__dirname, '../../skills');
- const personalSkillsDir = path.join(homeDir, '.config/opencode/skills');
+ // Respect OPENCODE_CONFIG_DIR if set, otherwise fall back to default
+ const envConfigDir = normalizePath(process.env.OPENCODE_CONFIG_DIR, homeDir);
+ const configDir = envConfigDir || path.join(homeDir, '.config/opencode');
+ const personalSkillsDir = path.join(configDir, 'skills');
// Helper to generate bootstrap content
const getBootstrapContent = (compact = false) => {
@@ -42,7 +60,7 @@ When skills reference tools you don't have, substitute OpenCode equivalents:
**Skills naming (priority order):**
- Project skills: \`project:skill-name\` (in .opencode/skills/)
-- Personal skills: \`skill-name\` (in ~/.config/opencode/skills/)
+- Personal skills: \`skill-name\` (in ${configDir}/skills/)
- Superpowers skills: \`superpowers:skill-name\`
- Project skills override personal, which override superpowers when names match`;
@@ -158,7 +176,7 @@ ${toolMapping}
const allSkills = [...projectSkills, ...personalSkills, ...superpowersSkills];
if (allSkills.length === 0) {
- return 'No skills found. Install superpowers skills to ~/.config/opencode/superpowers/skills/ or add project skills to .opencode/skills/';
+ return `No skills found. Install superpowers skills to ${superpowersSkillsDir}/ or add personal skills to ${personalSkillsDir}/`;
}
let output = 'Available skills:\n\n';