@complexthings/superpowers-agent 9.1.0 → 9.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/docs/SUPERPOWERS.md +18 -23
- package/.agents/superpowers-agent +131 -131
- package/.agents/templates/AGENTS.md.template +29 -39
- package/.agents/templates/SUPERPOWERS.md.template +18 -23
- package/.github/copilot-instructions.md +109 -1
- package/AGENTS.md +27 -32
- package/README.md +10 -24
- package/package.json +1 -1
- package/skills/meta/using-superpowers/SKILL.md +36 -50
- package/.agents/templates/TOOLS.md.template +0 -15
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
#!/bin/sh
|
|
2
2
|
// 2>/dev/null; exec "$(command -v bun 2>/dev/null || echo node)" "$0" "$@"
|
|
3
|
-
import{relative as
|
|
4
|
-
`)
|
|
5
|
-
`),
|
|
6
|
-
`).trim(),frontmatter:
|
|
7
|
-
`);for(let
|
|
3
|
+
import{relative as _X,dirname as GX,join as TY}from"path";import{existsSync as DQ}from"fs";import{homedir as sQ,platform as WY}from"os";import{join as O,parse as zY,dirname as tQ}from"path";import{existsSync as d}from"fs";import{fileURLToPath as HY}from"url";var BY=HY(import.meta.url),KQ=tQ(BY),KY=()=>{let Q=sQ();switch(WY()){case"darwin":return O(Q,"Library","Application Support","Code","User");case"win32":return O(Q,"AppData","Roaming","Code","User");case"linux":return O(Q,".config","Code","User");default:return O(Q,".config","Code","User")}},EY=()=>{let Q=process.cwd(),X=zY(Q).root;while(Q!==X){if(d(O(Q,".agents")))return Q;Q=tQ(Q)}return process.cwd()},H={home:sQ(),vscodeUserDir:KY(),projectRoot:EY(),get projectClaudeSkills(){return O(this.projectRoot,".claude","skills")},get projectAgentsSkills(){return O(this.projectRoot,".agents","skills")},get projectCopilotSkills(){return O(this.projectRoot,".copilot","skills")},get projectOpencodeSkills(){return O(this.projectRoot,".opencode","skill")},get projectSkillsDir(){return O(this.projectRoot,"skills")},get homePersonalSkills(){return O(this.home,".agents","skills")},get homeClaudeSkills(){return O(this.home,".claude","skills")},get homeCopilotSkills(){return O(this.home,".copilot","skills")},get claudeSettings(){return O(this.home,".claude","settings.json")},get copilotHooksDir(){return process.env.COPILOT_HOME?O(process.env.COPILOT_HOME,"hooks"):O(this.home,".copilot","hooks")},get homeOpencodeSkills(){return O(this.home,".config","opencode","skill")},get bootstrap(){return O(this.projectRoot,".agents","superpowers-bootstrap.md")},get superpowersRepo(){let Q=O(KQ,"..","..","..");if(d(O(Q,"skills"))&&d(O(Q,".agents","superpowers-agent")))return Q;let X=O(KQ,"..");if(d(O(X,"skills"))&&d(O(X,".agents","superpowers-agent")))return X;return O(this.home,".agents","superpowers")},get homeSuperpowersSkills(){return O(this.superpowersRepo,"skills")},get isSuperpowersRepo(){let Q=O(KQ,"..","..","..");if(d(O(Q,"skills"))&&d(O(Q,".agents","superpowers-agent")))return!0;let X=O(KQ,"..");return d(O(X,"skills"))&&d(O(X,".agents","superpowers-agent"))}};import{readFileSync as eQ}from"fs";var $Q=(Q)=>{try{let Y=eQ(Q,"utf8").split(`
|
|
4
|
+
`),$={name:"",description:"",whenToUse:""},Z=!1;for(let q of Y){if(q.trim()==="---"){if(Z)break;Z=!0;continue}if(Z){let z=q.match(/^(\w+):\s*(.*)$/);if(z){let[,W,K]=z,B={name:"name",description:"description",when_to_use:"whenToUse"};if(B[W])$[B[W]]=K.trim()}}}return $}catch{return{name:"",description:"",whenToUse:""}}},MQ=(Q)=>{try{let X=eQ(Q,"utf8"),Y=$Q(Q),$=X.split(`
|
|
5
|
+
`),Z=!1,q=!1,z=[];for(let W of $){if(W.trim()==="---"){if(Z){q=!0;continue}Z=!0;continue}if(q||!Z)z.push(W)}return{content:z.join(`
|
|
6
|
+
`).trim(),frontmatter:Y}}catch(X){throw Error(`Error reading skill file: ${X.message}`)}};import{existsSync as TQ,readdirSync as YX,statSync as ZX}from"fs";import{join as vQ,relative as lZ}from"path";import{readFileSync as VY,existsSync as _Y}from"fs";import{join as QX}from"path";var qQ=(Q)=>{let X=QX(Q,"skill.json");if(!_Y(X))return null;try{let Y=VY(X,"utf8");return JSON.parse(Y)}catch(Y){return null}};var AQ=(Q)=>{if(Q.startsWith("superpowers:"))return{type:"superpowers",path:Q.substring(12).replace(/^skills\//,"")};if(Q.startsWith("claude:"))return{type:"claude",path:Q.substring(7).replace(/^skills\//,"")};if(Q.startsWith("copilot:"))return{type:"copilot",path:Q.substring(8).replace(/^skills\//,"")};if(Q.startsWith("opencode:"))return{type:"opencode",path:Q.substring(9).replace(/^skills\//,"")};return{type:null,path:Q.replace(/^skills\//,"")}},XX=(Q,X)=>{let Y=qQ(Q);if(!Y||!Y.helpers||!Array.isArray(Y.helpers))return null;let $=Y.helpers,Z=X.toLowerCase(),q=null,z=0;for(let W of $){let K=W.toLowerCase();if(K===Z){q=W;break}if(K.includes(Z)){let E=Z.length/K.length;if(E>z)z=E,q=W}let B=W.split("/").pop().split(".")[0].toLowerCase();if(Z.includes(B)){let E=B.length/Z.length;if(E>z)z=E,q=W}}return q?QX(Q,q):null},s={project:{dir:"projectAgentsSkills",prefix:""},claude:{dir:"projectClaudeSkills",prefix:"claude:"},copilot:{dir:"projectCopilotSkills",prefix:"copilot:"},opencode:{dir:"projectOpencodeSkills",prefix:"opencode:"},personal:{dir:"homePersonalSkills",prefix:""},personalClaude:{dir:"homeClaudeSkills",prefix:"claude:"},personalCopilot:{dir:"homeCopilotSkills",prefix:"copilot:"},personalOpencode:{dir:"homeOpencodeSkills",prefix:"opencode:"},superpowers:{dir:"homeSuperpowersSkills",prefix:"superpowers:"}};var EQ=(Q,X,Y=null)=>{let $=[];if(!TQ(Q))return $;let Z=(q,z)=>{if(Y!==null&&z>Y)return;try{let W=YX(q,{withFileTypes:!0});for(let K of W){if(K.name==="node_modules"||K.name===".git"||K.name.startsWith("."))continue;let B=vQ(q,K.name),E=K.isDirectory();if(K.isSymbolicLink())try{E=ZX(B).isDirectory()}catch{continue}if(!E)continue;let V=vQ(B,"SKILL.md");if(TQ(V))$.push(B);if(Y===null||z<Y)Z(B,z+1)}}catch{}};return Z(Q,0),$};var $X=(Q,X)=>{if(!TQ(Q))return[];let Y=[],$=X.toLowerCase().replace(/\\/g,"/"),Z=(q,z="")=>{try{let W=YX(q,{withFileTypes:!0});for(let K of W){let B=vQ(q,K.name),E=z?`${z}/${K.name}`:K.name,V=K.isDirectory();if(K.isSymbolicLink())try{V=ZX(B).isDirectory()}catch{continue}if(V&&(K.name==="node_modules"||K.name===".git"||K.name.startsWith(".")))continue;if(V)Z(B,E);else if(K.name==="SKILL.md"){let _=z.toLowerCase().replace(/\\/g,"/");if(_===$||_.endsWith("/"+$)||_.endsWith($))Y.push({file:B,path:z})}}}catch(W){}};return Z(Q),Y},qX=(Q,X,Y)=>{let $={project:"project skills (.agents/skills/)",claude:"claude skills (.claude/skills/)",copilot:"copilot skills (.copilot/skills/)",opencode:"opencode skills (.opencode/skill/)",personal:"personal skills (~/.agents/skills/)",personalClaude:"personal claude skills (~/.claude/skills/)",personalCopilot:"personal copilot skills (~/.copilot/skills/)",personalOpencode:"personal opencode skills (~/.config/opencode/skill/)",superpowers:"superpowers skills (~/.agents/superpowers/skills/)"}[Y];console.log(`Error: Multiple skills match "${Q}" in ${$}:
|
|
7
|
+
`);for(let Z of X){let z=s[Y].prefix+Z.path;try{let W=$Q(Z.file),K=W.description||W.whenToUse||"(no description)";console.log(` ${z}`),console.log(` ${K}
|
|
8
8
|
`)}catch(W){console.log(` ${z}`),console.log(` (unable to read description)
|
|
9
|
-
`)}}console.log("Please be more specific. Examples:");for(let
|
|
10
|
-
superpowers-agent execute <skill-name> # Load a specific skill`)},
|
|
9
|
+
`)}}console.log("Please be more specific. Examples:");for(let Z of X.slice(0,2)){let q=s[Y].prefix;console.log(` superpowers-agent execute ${q}${Z.path}`)}};import{existsSync as CQ}from"fs";import{join as GY,relative as UY}from"path";var IY=(Q)=>{let{type:X,path:Y}=AQ(Q),$={superpowers:[H.homeSuperpowersSkills],claude:[H.projectClaudeSkills,H.homeClaudeSkills],copilot:[H.projectCopilotSkills,H.homeCopilotSkills],opencode:[H.projectOpencodeSkills,H.homeOpencodeSkills],project:[H.projectAgentsSkills],personal:[H.homePersonalSkills]},Z;if(X)Z=($[X]||[]).map((z)=>({type:X,dir:z}));else if(H.isSuperpowersRepo&&CQ(H.projectSkillsDir))Z=[{type:"project",dir:H.projectSkillsDir},{type:"project",dir:H.projectAgentsSkills},{type:"claude",dir:H.projectClaudeSkills},{type:"copilot",dir:H.projectCopilotSkills},{type:"opencode",dir:H.projectOpencodeSkills},{type:"personal",dir:H.homePersonalSkills},{type:"personalClaude",dir:H.homeClaudeSkills},{type:"personalCopilot",dir:H.homeCopilotSkills},{type:"personalOpencode",dir:H.homeOpencodeSkills},{type:"superpowers",dir:H.homeSuperpowersSkills}];else Z=[{type:"project",dir:H.projectAgentsSkills},{type:"claude",dir:H.projectClaudeSkills},{type:"copilot",dir:H.projectCopilotSkills},{type:"opencode",dir:H.projectOpencodeSkills},{type:"personal",dir:H.homePersonalSkills},{type:"personalClaude",dir:H.homeClaudeSkills},{type:"personalCopilot",dir:H.homeCopilotSkills},{type:"personalOpencode",dir:H.homeOpencodeSkills},{type:"superpowers",dir:H.homeSuperpowersSkills}];for(let{type:q,dir:z}of Z){let W=$X(z,Y);if(W.length===1)return{skillFile:W[0].file,sourceType:q,actualSkillPath:W[0].path};if(W.length>1)qX(Y,W,q)}return null},m=(Q)=>{let X=IY(Q);if(X)return X;let{type:Y,path:$}=AQ(Q),Z={superpowers:[H.homeSuperpowersSkills],claude:[H.projectClaudeSkills,H.homeClaudeSkills],copilot:[H.projectCopilotSkills,H.homeCopilotSkills],opencode:[H.projectOpencodeSkills,H.homeOpencodeSkills],project:[H.projectAgentsSkills],personal:[H.homePersonalSkills]},q;if(Y)q=(Z[Y]||[]).map((W)=>({type:Y,dir:W}));else if(H.isSuperpowersRepo&&CQ(H.projectSkillsDir))q=[{type:"project",dir:H.projectSkillsDir},{type:"project",dir:H.projectAgentsSkills},{type:"claude",dir:H.projectClaudeSkills},{type:"copilot",dir:H.projectCopilotSkills},{type:"opencode",dir:H.projectOpencodeSkills},{type:"personal",dir:H.homePersonalSkills},{type:"personalClaude",dir:H.homeClaudeSkills},{type:"personalCopilot",dir:H.homeCopilotSkills},{type:"personalOpencode",dir:H.homeOpencodeSkills},{type:"superpowers",dir:H.homeSuperpowersSkills}];else q=[{type:"project",dir:H.projectAgentsSkills},{type:"claude",dir:H.projectClaudeSkills},{type:"copilot",dir:H.projectCopilotSkills},{type:"opencode",dir:H.projectOpencodeSkills},{type:"personal",dir:H.homePersonalSkills},{type:"personalClaude",dir:H.homeClaudeSkills},{type:"personalCopilot",dir:H.homeCopilotSkills},{type:"personalOpencode",dir:H.homeOpencodeSkills},{type:"superpowers",dir:H.homeSuperpowersSkills}];for(let{type:z,dir:W}of q){if(!CQ(W))continue;let K=EQ(W,z,null);for(let B of K){let E=qQ(B);if(E&&E.aliases&&Array.isArray(E.aliases)){let V=$.toLowerCase();for(let _ of E.aliases)if(_.toLowerCase()===V){let U=GY(B,"SKILL.md"),L=UY(W,B);return{skillFile:U,sourceType:z,actualSkillPath:L}}}}}return null};import{readFileSync as WX,writeFileSync as zX,existsSync as NQ}from"fs";import{join as l}from"path";import{execSync as LY}from"child_process";var bQ=()=>({auto_update:!0,last_update_check:null,last_updated_commit:null}),WQ=()=>{let Q=l(H.superpowersRepo,".config.json");try{if(!NQ(Q))return bQ();let X=WX(Q,"utf8");return{...bQ(),...JSON.parse(X)}}catch{return bQ()}},HX=(Q)=>{let X=l(H.superpowersRepo,".config.json"),$={...WQ(),...Q};try{zX(X,JSON.stringify($,null,2))}catch(Z){console.log(`Warning: couldn't save config: ${Z.message}`)}},y=(Q)=>{let X=Q?l(H.home,".agents","config.json"):l(process.cwd(),".agents","config.json");if(!NQ(X))return{};try{let Y=WX(X,"utf8");return JSON.parse(Y)}catch(Y){return{}}},h=(Q,X)=>{let Y=X?l(H.home,".agents"):l(process.cwd(),".agents"),$=l(Y,"config.json");try{if(!NQ(Y))LY(`mkdir -p "${Y}"`,{stdio:"pipe"});return zX($,JSON.stringify(Q,null,2),"utf8"),!0}catch(Z){throw Error(`Failed to write config: ${Z.message}`)}},k=(Q=!1)=>{return y(Q).repositories||{}},BX=(Q,X,Y)=>{let $=y(Y);if(!$.repositories)$.repositories={};$.repositories[Q]=X,h($,Y)};function KX(Q=!0){return y(Q).installedSkills||{}}function FQ(Q,X=!0){let Y=y(X);if(Y.installedSkills)delete Y.installedSkills[Q];h(Y,X)}function EX(){return y(!0).installedAgents||{}}import{readFileSync as JY}from"fs";import{join as jQ,dirname as wY}from"path";import{fileURLToPath as OY}from"url";import{existsSync as VX}from"fs";import{execSync as MY}from"child_process";var AY=OY(import.meta.url),xQ=wY(AY),P=()=>{try{let Q=jQ(xQ,"package.json");if(!VX(Q))Q=jQ(xQ,"..","package.json");if(!VX(Q))Q=jQ(xQ,"..","..","package.json");return JSON.parse(JY(Q,"utf8")).version||"0.0.0"}catch{return"0.0.0"}},u=()=>{let Q=P();console.log(`^^SAV:${Q}^^`)},VQ=async()=>{try{let X=MY('curl -sS "https://registry.npmjs.org/@complexthings/superpowers-agent/latest"',{encoding:"utf8",timeout:1e4}),Y=JSON.parse(X);if(!Y.version)return P();return Y.version}catch(Q){throw Error(`Failed to fetch remote version: ${Q.message}`)}},_Q=(Q,X)=>{let Y=Q.split(".").map(Number),$=X.split(".").map(Number);for(let Z=0;Z<3;Z++){let q=Y[Z]||0,z=$[Z]||0;if(q>z)return!0;if(q<z)return!1}return!1};var vY={project:{dir:"projectAgentsSkills",prefix:""},claude:{dir:"projectClaudeSkills",prefix:"claude:"},copilot:{dir:"projectCopilotSkills",prefix:"copilot:"},opencode:{dir:"projectOpencodeSkills",prefix:"opencode:"},personal:{dir:"homePersonalSkills",prefix:""},personalClaude:{dir:"homeClaudeSkills",prefix:"claude:"},personalCopilot:{dir:"homeCopilotSkills",prefix:"copilot:"},personalOpencode:{dir:"homeOpencodeSkills",prefix:"opencode:"},superpowers:{dir:"homeSuperpowersSkills",prefix:"superpowers:"}},CY=(Q,X)=>{let Y=TY(Q,"SKILL.md"),{dir:$,prefix:Z}=vY[X],q=_X(H[$],Q).replace(/\\/g,"/");console.log(`${Z}${q}`);let{description:z,whenToUse:W}=$Q(Y);if(z)console.log(` ${z}`);if(W)console.log(` When to use: ${W}`);console.log("")},t=()=>{u();let Q=new Set,X=[{type:"project",dir:H.projectAgentsSkills,maxDepth:null},{type:"claude",dir:H.projectClaudeSkills,maxDepth:null},{type:"copilot",dir:H.projectCopilotSkills,maxDepth:null},{type:"opencode",dir:H.projectOpencodeSkills,maxDepth:null},{type:"personal",dir:H.homePersonalSkills,maxDepth:null},{type:"personalClaude",dir:H.homeClaudeSkills,maxDepth:null},{type:"personalCopilot",dir:H.homeCopilotSkills,maxDepth:null},{type:"personalOpencode",dir:H.homeOpencodeSkills,maxDepth:null},{type:"superpowers",dir:H.homeSuperpowersSkills,maxDepth:null}];for(let{type:Y,dir:$,maxDepth:Z}of X){let q=EQ($,Y,Z);for(let z of q){let W=_X($,z);if(!Q.has(W))Q.add(W),CY(z,Y)}}console.log(`Usage:
|
|
10
|
+
superpowers-agent execute <skill-name> # Load a specific skill`)},UX=()=>{u();let Q=process.argv[3];if(!Q){console.log(`Usage: superpowers-agent execute <skill-name-or-alias>
|
|
11
11
|
|
|
12
12
|
Examples:
|
|
13
13
|
superpowers-agent execute brainstorming
|
|
@@ -17,26 +17,26 @@ Examples:
|
|
|
17
17
|
|
|
18
18
|
Description:
|
|
19
19
|
Instructs the agent to execute the specified skill.
|
|
20
|
-
Supports skill aliases defined in skill.json files.`);return}let
|
|
20
|
+
Supports skill aliases defined in skill.json files.`);return}let X=m(Q);if(!X){console.log(`Error: Skill not found: ${Q}
|
|
21
21
|
|
|
22
|
-
Available skills:`),
|
|
22
|
+
Available skills:`),t();return}let{skillFile:Y,sourceType:$}=X,Z=process.cwd(),q=Y.startsWith(Z),z=DQ(H.projectAgentsSkills)||DQ(H.projectClaudeSkills);if(q)console.log(`Open this file with your Read Tool: ${Y}
|
|
23
23
|
|
|
24
24
|
<IMPORTANT>
|
|
25
25
|
USE YOUR Read Tool to process this file. DO NOT use \`cat\` or print commands.
|
|
26
|
-
</IMPORTANT>`);else if(z
|
|
26
|
+
</IMPORTANT>`);else if(z&&$!=="project")console.log(`Open this file with your Read Tool: ${Y}
|
|
27
27
|
|
|
28
28
|
<IMPORTANT>
|
|
29
29
|
1. Try using your Read Tool first
|
|
30
|
-
2. If your Read tool fails (file outside workspace), use: cat "${
|
|
30
|
+
2. If your Read tool fails (file outside workspace), use: cat "${Y}"
|
|
31
31
|
3. Consider using workspace-local skills for better tool compatibility
|
|
32
32
|
Run: superpowers-agent setup-skills
|
|
33
|
-
</IMPORTANT>`);else console.log(`Open this file with your Read Tool: ${
|
|
33
|
+
</IMPORTANT>`);else console.log(`Open this file with your Read Tool: ${Y}
|
|
34
34
|
|
|
35
35
|
<IMPORTANT>
|
|
36
36
|
1. Try using your Read Tool first
|
|
37
|
-
2. If your Read tool fails (file outside workspace), use: cat "${
|
|
37
|
+
2. If your Read tool fails (file outside workspace), use: cat "${Y}"
|
|
38
38
|
3. NEVER skip loading the skill content
|
|
39
|
-
</IMPORTANT>`)},
|
|
39
|
+
</IMPORTANT>`)},IX=()=>{let Q=process.argv[3];if(!Q){console.log(`Usage: superpowers-agent path <skill-name-or-alias>
|
|
40
40
|
|
|
41
41
|
Examples:
|
|
42
42
|
superpowers-agent path brainstorming
|
|
@@ -46,9 +46,9 @@ Examples:
|
|
|
46
46
|
|
|
47
47
|
Description:
|
|
48
48
|
Outputs the file system path of the specified SKILL.md file.
|
|
49
|
-
Supports skill aliases defined in skill.json files.`);return}let
|
|
49
|
+
Supports skill aliases defined in skill.json files.`);return}let X=m(Q);if(!X){console.log(`Error: Skill not found: ${Q}
|
|
50
50
|
|
|
51
|
-
Available skills:`),
|
|
51
|
+
Available skills:`),t();return}let{skillFile:Y}=X;console.log(Y)},LX=()=>{let Q=process.argv[3];if(!Q){console.log(`Usage: superpowers-agent dir <skill-name>
|
|
52
52
|
|
|
53
53
|
Examples:
|
|
54
54
|
superpowers-agent dir brainstorming
|
|
@@ -58,9 +58,9 @@ Examples:
|
|
|
58
58
|
|
|
59
59
|
Description:
|
|
60
60
|
Returns the directory path where the specified skill is located.
|
|
61
|
-
Supports skill aliases defined in skill.json files.`);return}let
|
|
61
|
+
Supports skill aliases defined in skill.json files.`);return}let X=m(Q);if(!X){console.log(`Error: Skill not found: ${Q}
|
|
62
62
|
|
|
63
|
-
Available skills:`),
|
|
63
|
+
Available skills:`),t();return}let{skillFile:Y}=X,$=GX(Y);console.log($)},JX=()=>{u();let Q=process.argv[3],X=process.argv[4];if(!Q||!X){console.log(`Usage: superpowers-agent get-helpers <skill-name> <helper-search-term>
|
|
64
64
|
|
|
65
65
|
Examples:
|
|
66
66
|
superpowers-agent get-helpers block-collection search-block
|
|
@@ -72,69 +72,69 @@ Description:
|
|
|
72
72
|
Returns the full path to the best matching helper file.
|
|
73
73
|
|
|
74
74
|
The command uses the skill's aliases if available, so you can use
|
|
75
|
-
short names like "block-collection" instead of the full path.`);return}let
|
|
75
|
+
short names like "block-collection" instead of the full path.`);return}let Y=m(Q);if(!Y){console.log(`Error: Skill not found: ${Q}
|
|
76
76
|
|
|
77
|
-
Available skills:`),
|
|
78
|
-
Location: ${
|
|
79
|
-
Location: ${
|
|
80
|
-
Available helpers:`);for(let W of q.helpers)console.log(` - ${W}`);return}if(!
|
|
81
|
-
Defined in skill.json but missing from filesystem`);return}console.log(z)},
|
|
77
|
+
Available skills:`),t();return}let{skillFile:$}=Y,Z=GX($),q=qQ(Z);if(!q){console.log(`Error: No skill.json found for skill: ${Q}
|
|
78
|
+
Location: ${Z}`);return}if(!q.helpers||!Array.isArray(q.helpers)||q.helpers.length===0){console.log(`Error: No helpers defined in skill.json for skill: ${Q}
|
|
79
|
+
Location: ${Z}`);return}let z=XX(Z,X);if(!z){console.log(`Error: No helper found matching "${X}" in skill: ${Q}`),console.log(`
|
|
80
|
+
Available helpers:`);for(let W of q.helpers)console.log(` - ${W}`);return}if(!DQ(z)){console.log(`Error: Helper file not found: ${z}
|
|
81
|
+
Defined in skill.json but missing from filesystem`);return}console.log(z)},wX=()=>{let Q=WQ();console.log("Current configuration:"),console.log(JSON.stringify(Q,null,2))},OX=()=>{let Q=process.argv[3],X=process.argv[4];if(!Q||X===void 0){console.log(`Usage: .agents/superpowers-agent config-set <key> <value>
|
|
82
82
|
|
|
83
83
|
Available keys:
|
|
84
84
|
auto_update (true/false) - Enable/disable automatic updates during bootstrap
|
|
85
85
|
|
|
86
86
|
Examples:
|
|
87
87
|
.agents/superpowers-agent config-set auto_update false
|
|
88
|
-
.agents/superpowers-agent config-set auto_update true`);return}let X
|
|
88
|
+
.agents/superpowers-agent config-set auto_update true`);return}let Y=X;if(X==="true")Y=!0;else if(X==="false")Y=!1;let $={};$[Q]=Y,HX($),console.log(`✓ Set ${Q} = ${Y}`)},MX=()=>{u();let Q=k(!0),X=k(!1),Y=[];for(let[q,z]of Object.entries(Q))Y.push({alias:q,url:z,source:"global"});for(let[q,z]of Object.entries(X)){let W=Y.findIndex((K)=>K.alias===q);if(W>=0)Y[W]={alias:q,url:z,source:"project"};else Y.push({alias:q,url:z,source:"project"})}if(Y.length===0){console.log(`No repository aliases configured.
|
|
89
89
|
|
|
90
90
|
Add a repository using:
|
|
91
|
-
superpowers-agent add-repository <git-url> [--as=@alias]`);return}let
|
|
92
|
-
`),console.log(`${"Alias".padEnd(
|
|
93
|
-
Total: ${
|
|
94
|
-
`);let
|
|
95
|
-
`)
|
|
91
|
+
superpowers-agent add-repository <git-url> [--as=@alias]`);return}let $=Math.max(5,...Y.map((q)=>q.alias.length)),Z=Math.max(3,...Y.map((q)=>q.url.length));console.log(`Repositories:
|
|
92
|
+
`),console.log(`${"Alias".padEnd($)} ${"URL".padEnd(Z)} Source`);for(let q of Y)console.log(`${q.alias.padEnd($)} ${q.url.padEnd(Z)} (${q.source})`);console.log(`
|
|
93
|
+
Total: ${Y.length} repository alias(es)`)};var GQ=async()=>{try{let Q=P(),X=await VQ();return{hasUpdates:_Q(X,Q),localVersion:Q,remoteVersion:X}}catch{return{hasUpdates:!1,localVersion:P(),remoteVersion:"",error:!0}}};import{execSync as AX}from"child_process";var RQ=async({skipReinstall:Q=!1}={})=>{console.log(`# Checking for Superpowers updates...
|
|
94
|
+
`);let X=await GQ();if(X.error){console.log("⚠️ Could not check for updates (network issue)");return}if(!X.hasUpdates){console.log(`✓ Already up to date (v${X.localVersion})`);return}if(console.log(`\uD83D\uDCE6 Update available: v${X.localVersion} → v${X.remoteVersion}
|
|
95
|
+
`),Q){console.log(" Skipping install (--no-reinstall flag set)"),console.log(` Run manually: npm install -g @complexthings/superpowers-agent
|
|
96
96
|
`);return}console.log(` Installing update...
|
|
97
|
-
`);try{
|
|
98
|
-
✓ Update complete!`)}catch(
|
|
99
|
-
✗ Update failed: ${
|
|
97
|
+
`);try{AX("npm install -g @complexthings/superpowers-agent",{stdio:"inherit"}),console.log(`
|
|
98
|
+
✓ Update complete!`)}catch(Y){console.log(`
|
|
99
|
+
✗ Update failed: ${Y.message}`),console.log(" Try running manually: npm install -g @complexthings/superpowers-agent"),process.exit(1)}console.log(`
|
|
100
100
|
Running bootstrap to complete setup...
|
|
101
|
-
`);try{
|
|
102
|
-
✓ Bootstrap complete!`)}catch(
|
|
103
|
-
⚠️ Bootstrap step failed: ${
|
|
104
|
-
`,"utf8")}catch(
|
|
105
|
-
`;if(
|
|
106
|
-
${
|
|
107
|
-
<!-- SUPERPOWERS_SKILLS_END -->`;if(
|
|
108
|
-
`,
|
|
109
|
-
`+
|
|
110
|
-
`+
|
|
111
|
-
|
|
112
|
-
`+
|
|
113
|
-
|
|
114
|
-
`+
|
|
115
|
-
⚠️ Warning: ${
|
|
116
|
-
`)},
|
|
117
|
-
`)
|
|
101
|
+
`);try{AX("superpowers-agent bootstrap --no-update",{stdio:"inherit"}),console.log(`
|
|
102
|
+
✓ Bootstrap complete!`)}catch(Y){console.log(`
|
|
103
|
+
⚠️ Bootstrap step failed: ${Y.message}`),console.log(" The update installed successfully. Run manually to finish setup:"),console.log(" superpowers-agent bootstrap")}},TX=async()=>{u();let Q=P();console.log(`Current version: ${Q}`);try{let X=await VQ();if(console.log(`Latest version: ${X}`),_Q(X,Q))console.log("Update available: Yes"),process.exit(1);else console.log("You are up to date"),process.exit(0)}catch(X){console.log(`Error checking for updates: ${X.message}`),process.exit(1)}},vX=()=>{let Q=P();console.log(Q)};import{existsSync as A,readFileSync as r,writeFileSync as XQ,rmSync as hX,lstatSync as BZ}from"fs";import{join as v,dirname as pX,parse as QQ}from"path";import{execSync as f}from"child_process";import{platform as KZ}from"os";import{execSync as bY}from"child_process";var zQ=(Q)=>{try{return bY(`which ${Q}`,{stdio:"pipe",timeout:2000}),!0}catch{return!1}};var R={opencode:{check:()=>zQ("opencode"),cli:!0,name:"OpenCode",installUrl:"https://opencode.ai/docs/installation",bootstrapCommand:"install-opencode-commands"},claude:{check:()=>zQ("claude"),cli:!0,name:"Claude Code",installUrl:"https://code.claude.com/docs/en/installation",bootstrapCommand:"install-claude-commands"},copilot:{check:()=>!0,cli:!1,name:"GitHub Copilot",bootstrapCommand:"install-copilot-prompts"}},CX=()=>{let Q=[];if(R.copilot.check())Q.push("github-copilot");if(R.claude.check())Q.push("claude-code");if(R.opencode.check())Q.push("opencode");return Q};import{existsSync as fQ,readdirSync as g0,lstatSync as NY,symlinkSync as bX,unlinkSync as FY,mkdirSync as jY,readlinkSync as xY}from"fs";import{join as SQ,dirname as u0}from"path";import{platform as DY}from"os";var yQ=(Q)=>{try{return NY(Q).isSymbolicLink()}catch{return!1}},RY=(Q,X)=>{try{if(!yQ(Q))return!1;return xY(Q)===X}catch{return!1}},NX=()=>{let Q=SQ(H.superpowersRepo,".opencode","plugins","superpowers-agent.js"),X=SQ(H.home,".config","opencode","plugins"),Y=SQ(X,"superpowers-agent.js");if(console.log("Installing OpenCode plugin symlink..."),!fQ(Q))return console.log("⚠️ Source plugin not found, skipping symlink creation"),console.log(` Expected at: ${Q}`),{created:!1,error:"Source plugin not found"};if(RY(Y,Q))return console.log("✓ Plugin symlink already exists and is correct"),{created:!1,existed:!0};if(fQ(Y)&&!yQ(Y))return console.log("⚠️ Warning: A file already exists at the destination path"),console.log(` Path: ${Y}`),console.log(" Skipping symlink creation to avoid overwriting existing file"),console.log(" To use superpowers-agent plugin, manually remove or rename the existing file"),{created:!1,error:"File already exists at destination"};if(!fQ(X))try{jY(X,{recursive:!0}),console.log(`✓ Created ${X.replace(H.home,"~")}`)}catch(Z){return console.log(`⚠️ Failed to create plugins directory: ${Z.message}`),{created:!1,error:`Failed to create directory: ${Z.message}`}}if(yQ(Y))try{FY(Y)}catch(Z){return console.log(`⚠️ Failed to remove existing symlink: ${Z.message}`),{created:!1,error:`Failed to remove existing symlink: ${Z.message}`}}let $=DY();try{if($==="win32")bX(Q,Y,"file");else bX(Q,Y);let Z=Q.replace(H.home,"~"),q=Y.replace(H.home,"~");return console.log(`✓ Created symlink: ${q}`),console.log(` -> ${Z}`),{created:!0}}catch(Z){if($==="win32"&&Z.code==="EPERM")return console.log("⚠️ Windows requires Developer Mode or admin privileges for symlinks"),console.log(" Enable Developer Mode: Settings > Update & Security > For developers"),{created:!1,error:"Windows symlink permission denied"};return console.log(`⚠️ Failed to create symlink: ${Z.message}`),{created:!1,error:`Failed to create symlink: ${Z.message}`}}};import{existsSync as FX,readdirSync as c0,readFileSync as fY,writeFileSync as SY,mkdirSync as yY,copyFileSync as PY}from"fs";import{join as o0,dirname as gY}from"path";var kY="superpowers-agent session-context",uY="superpowers-agent session-context --format=claude 2>/dev/null || true",dY="startup|resume|clear|compact",jX=(Q=H.claudeSettings)=>{let X={},Y=!1,$;if(FX(Q)){Y=!0;let E;try{E=fY(Q,"utf8")}catch(_){return{error:!0,message:`Failed to read settings.json: ${_.message}`}}try{X=E.trim()?JSON.parse(E):{}}catch(_){return{error:!0,message:`settings.json is not valid JSON, leaving it untouched: ${_.message}`}}let V=new Date().toISOString().split("T")[0];$=`${Q}.backup-${V}`;try{PY(Q,$)}catch(_){return{error:!0,message:`Failed to back up settings.json: ${_.message}`}}}if(typeof X!=="object"||X===null||Array.isArray(X))return{error:!0,message:"settings.json root is not an object"};X.hooks=X.hooks||{};let Z=Array.isArray(X.hooks.SessionStart)?X.hooks.SessionStart:[],q=(E)=>{try{return JSON.stringify(E).includes(kY)}catch{return!1}},z=Z.some(q),W=Z.filter((E)=>!q(E)),K={matcher:dY,hooks:[{type:"command",command:uY}]};X.hooks.SessionStart=[...W,K];let B=gY(Q);if(!FX(B))try{yY(B,{recursive:!0})}catch(E){return{error:!0,message:`Failed to create ${B}: ${E.message}`}}try{SY(Q,JSON.stringify(X,null,2)+`
|
|
104
|
+
`,"utf8")}catch(E){return{error:!0,message:`Failed to write settings.json: ${E.message}`}}if(!Y)return{created:!0};if(z)return{existed:!0,updated:!0,backup:$};return{updated:!0,backup:$}};import{existsSync as PQ,readdirSync as r0,readFileSync as mY,writeFileSync as hY,mkdirSync as pY}from"fs";import{join as cY}from"path";var nY="superpowers.json",oY=()=>({version:1,hooks:{sessionStart:[{type:"command",bash:"superpowers-agent session-context --format=copilot 2>/dev/null || true",powershell:"superpowers-agent session-context --format=copilot 2>$null; exit 0",timeoutSec:15}]}}),xX=(Q=H.copilotHooksDir)=>{let X=cY(Q,nY),Y=JSON.stringify(oY(),null,2)+`
|
|
105
|
+
`;if(PQ(X)){let Z;try{Z=mY(X,"utf8")}catch(q){return{error:!0,message:`Failed to read ${X}: ${q.message}`}}if(Z===Y)return{existed:!0,path:X}}if(!PQ(Q))try{pY(Q,{recursive:!0})}catch(Z){return{error:!0,message:`Failed to create ${Q}: ${Z.message}`}}let $=PQ(X);try{hY(X,Y,"utf8")}catch(Z){return{error:!0,message:`Failed to write ${X}: ${Z.message}`}}return $?{updated:!0,path:X}:{created:!0,path:X}};import{existsSync as a,readdirSync as iY,lstatSync as lY,symlinkSync as UQ,unlinkSync as gQ,mkdirSync as DX,readlinkSync as aY}from"fs";import{join as n,dirname as rY,basename as sY}from"path";import{homedir as o,platform as RX}from"os";var IQ=[{name:"claude",parentDir:()=>n(o(),".claude"),skillsDir:()=>n(o(),".claude","skills")},{name:"copilot",parentDir:()=>n(o(),".copilot"),skillsDir:()=>n(o(),".copilot","skills")},{name:"opencode",parentDir:()=>n(o(),".config","opencode"),skillsDir:()=>n(o(),".config","opencode","skill")}],e=(Q)=>{try{return lY(Q).isSymbolicLink()}catch{return!1}},fX=(Q,X)=>{try{if(!e(Q))return!1;return aY(Q)===X}catch{return!1}},SX=(Q,X)=>{if(!a(Q))return{created:!1,existed:!1,error:`Source does not exist: ${Q}`};if(fX(X,Q))return{created:!1,existed:!0};if(a(X)||e(X))if(e(X))try{gQ(X)}catch(Z){return{created:!1,existed:!1,error:`Failed to remove existing symlink: ${Z.message}`}}else return{created:!1,existed:!1,error:`Target exists and is not a symlink: ${X}`};let Y=rY(X);if(!a(Y))try{DX(Y,{recursive:!0})}catch(Z){return{created:!1,existed:!1,error:`Failed to create parent directory: ${Z.message}`}}let $=RX();try{if($==="win32")UQ(Q,X,"junction");else UQ(Q,X,"dir");return{created:!0,existed:!1}}catch(Z){if($==="win32"&&Z.code==="EPERM")return{created:!1,existed:!1,error:"Windows requires Developer Mode or admin privileges for symlinks. Enable Developer Mode: Settings > Update & Security > For developers"};return{created:!1,existed:!1,error:`Failed to create symlink: ${Z.message}`}}},kQ=(Q)=>{if(!a(Q)&&!e(Q))return{removed:!1,error:"Symlink does not exist"};if(!e(Q))return{removed:!1,error:"Target is not a symlink"};try{return gQ(Q),{removed:!0}}catch(X){return{removed:!1,error:`Failed to remove symlink: ${X.message}`}}};var yX=(Q,X,Y="skills")=>{let $=y(!0);if(!$.symlinks||!$.symlinks[Q])return;if(Y==="superpowers")$.symlinks[Q].superpowers=null;else{let Z=$.symlinks[Q].skills||[];$.symlinks[Q].skills=Z.filter((q)=>q!==X)}h($,!0)};var PX=(Q,X=[])=>{let Y;try{Y=iY(Q,{withFileTypes:!0})}catch{return X}let $=!1,Z=[];for(let q of Y){if(!q.isDirectory()&&q.name==="SKILL.md")$=!0;if(q.isDirectory()&&!q.name.startsWith("."))Z.push(n(Q,q.name))}if($)X.push(Q);for(let q of Z)PX(q,X);return X},gX=()=>{let Q=H.homeSuperpowersSkills,X=H.homePersonalSkills;if(!a(Q))return{created:0,existed:0,updated:0,errors:[`Skills directory not found: ${Q}`]};if(!a(X))try{DX(X,{recursive:!0})}catch(Z){return{created:0,existed:0,updated:0,errors:[`Failed to create ${X}: ${Z.message}`]}}let Y=PX(Q),$={created:0,existed:0,updated:0,errors:[]};for(let Z of Y){let q=sY(Z),z=n(X,q);if(fX(z,Z)){$.existed++;continue}if(e(z))try{gQ(z),$.updated++}catch(K){$.errors.push(`Failed to remove stale symlink ${z}: ${K.message}`);continue}else if(a(z)){$.errors.push(`Skipped ${z}: path exists and is not a symlink`);continue}let W=RX();try{if(W==="win32")UQ(Z,z,"junction");else UQ(Z,z,"dir");let K=z.replace(o(),"~"),B=Z.replace(o(),"~");console.log(` ✓ ${K} -> ${B}`),$.created++}catch(K){$.errors.push(`Failed to create symlink ${z}: ${K.message}`)}}return $};import{existsSync as kX,readdirSync as tY,lstatSync as eY,unlinkSync as QZ,realpathSync as uX}from"fs";import{join as D}from"path";import{homedir as dX}from"os";var XZ=(Q)=>{try{return uX(Q)}catch{return Q}},YZ=(Q)=>{try{return eY(Q).isSymbolicLink()}catch{return!1}},ZZ=(Q)=>{try{return uX(Q)}catch{return null}},$Z=(Q,X)=>{let Y=X.endsWith("/")?X:X+"/";return Q.startsWith(Y)||Q===X},qZ=(Q,X)=>X.some((Y)=>$Z(Q,Y)),WZ=(Q)=>{try{return kX(D(Q,"skill.json"))}catch{return!1}},zZ=({platformDirs:Q,managedSkillRoots:X})=>{let Y=[],$=0,Z=X.map(XZ);for(let q of Q){if(!kX(q))continue;let z;try{z=tY(q)}catch{continue}for(let W of z){let K=D(q,W);if(!YZ(K))continue;let B=ZZ(K);if(!B||!qZ(B,Z)){$++;continue}if(!WZ(B)){$++;continue}try{QZ(K),Y.push(K)}catch{$++}}}return{removed:Y,skipped:$}},HZ=(Q)=>{let X=dX(),Y=[D(X,".claude","skills"),D(X,".copilot","skills"),D(X,".config","opencode","skill"),D(X,".cursor","skills"),D(X,".gemini","skills"),D(X,".codex","skills")];if(!Q)return Y;let $=[D(Q,".claude","skills"),D(Q,".github","skills"),D(Q,".opencode","skill"),D(Q,".cursor","skills"),D(Q,".gemini","skills"),D(Q,".codex","skills")];return[...Y,...$]},mX=(Q={})=>{let X=dX(),Y=[D(X,".agents","skills"),...Q.projectRoot?[D(Q.projectRoot,".agents","skills")]:[]],$=HZ(Q.projectRoot);return zZ({platformDirs:$,managedSkillRoots:Y})};var LQ=(Q,X,Y,$=!0)=>{let Z=A(Q);if(!Z&&!$)return{updated:!1,created:!1,skipped:!0};let q=X,z=new Date().toISOString().split("T")[0];q=q.replace(/\{\{DATE\}\}/g,z),q=q.replace(/\{\{SUPERPOWERS_PATH\}\}/g,H.superpowersRepo);let W=`<!-- SUPERPOWERS_SKILLS_START -->
|
|
106
|
+
${q}
|
|
107
|
+
<!-- SUPERPOWERS_SKILLS_END -->`;if(Z){let K=new Date().toISOString().split("T")[0],B=`${Q}.backup-${K}`;try{f(`cp "${Q}" "${B}"`,{stdio:"pipe"})}catch(L){return{updated:!1,error:!0,message:`Failed to backup: ${L.message}`}}let E;try{E=r(Q,"utf8")}catch(L){return{updated:!1,error:!0,message:`Failed to read: ${L.message}`}}let V="<!-- SUPERPOWERS_SKILLS_START -->",_="<!-- SUPERPOWERS_SKILLS_END -->",U;if(E.includes(V)&&E.includes(_)){let L=new RegExp(`${V}[\\s\\S]*?${_}`,"g");U=E.replace(L,W)}else{let L=E.match(/^#\s+.+$/m);if(L){let I=E.indexOf(`
|
|
108
|
+
`,L.index)+1;U=E.slice(0,I)+`
|
|
109
|
+
`+W+`
|
|
110
|
+
`+E.slice(I)}else U=W+`
|
|
111
|
+
|
|
112
|
+
`+E}try{return XQ(Q,U,"utf8"),{updated:!0,created:!1,backup:B}}catch(L){return{updated:!1,error:!0,message:`Failed to write: ${L.message}`}}}else try{let K=pX(Q);if(!A(K))f(`mkdir -p "${K}"`,{stdio:"pipe"});let V=`# ${QQ(Q).base.toUpperCase()}
|
|
113
|
+
|
|
114
|
+
`+W;return XQ(Q,V,"utf8"),{updated:!1,created:!0}}catch(K){return{updated:!1,created:!1,error:!0,message:`Failed to create: ${K.message}`}}},EZ=()=>{console.log("Installing Unix aliases...");let Q=v(H.superpowersRepo,".agents","superpowers-agent"),X=v(H.home,".local","bin"),Y=v(X,"superpowers-agent"),$=v(X,"superpowers");if(!A(Q)){console.log("⚠️ superpowers-agent executable not found");return}if(!A(X))try{f(`mkdir -p "${X}"`,{stdio:"pipe"}),console.log(`✓ Created ${X}`)}catch(q){console.log(`⚠️ Failed to create ${X}: ${q.message}`);return}try{if(A(Y))f(`rm "${Y}"`,{stdio:"pipe"});f(`ln -s "${Q}" "${Y}"`,{stdio:"pipe"}),console.log(`✓ Created symlink: superpowers-agent -> ${Q}`)}catch(q){console.log(`⚠️ Failed to create superpowers-agent symlink: ${q.message}`)}try{if(A($))f(`rm "${$}"`,{stdio:"pipe"});f(`ln -s "${Q}" "${$}"`,{stdio:"pipe"}),console.log(`✓ Created symlink: superpowers -> ${Q}`)}catch(q){console.log(`⚠️ Failed to create superpowers symlink: ${q.message}`)}if(!(process.env.PATH||"").includes(X))console.log(`
|
|
115
|
+
⚠️ Warning: ${X} is not in your PATH`),console.log(" Add this to your shell profile (~/.bashrc, ~/.zshrc, etc.):"),console.log(` export PATH="$HOME/.local/bin:$PATH"
|
|
116
|
+
`)},VZ=()=>{console.log("Installing Windows aliases..."),console.log("✓ Windows alias installation (implementation pending)")},uQ=()=>{let Q=KZ();if(console.log(`## Installing Universal Aliases
|
|
117
|
+
`),Q==="win32")return VZ();else return EZ()},_Z=(Q)=>{let X=v(H.superpowersRepo,".github","copilot-instructions.md"),Y=v(H.superpowersRepo,"skills","meta","using-superpowers","SKILL.md"),$=v(Q,".github","copilot-instructions.md"),Z="<!-- SUPERPOWERS_-_INSTRUCTIONS_START -->",q="<!-- SUPERPOWERS_-_INSTRUCTIONS_END -->";if(!A(X))return{error:!0,message:"Source template not found"};if(!A(Y))return{error:!0,message:"using-superpowers SKILL.md not found"};let z,W;try{z=r(X,"utf8"),W=r(Y,"utf8")}catch(E){return{error:!0,message:`Failed to read source files: ${E.message}`}}let K=z.replace("${content}",W);if(!K.includes("<!-- SUPERPOWERS_-_INSTRUCTIONS_START -->")||!K.includes("<!-- SUPERPOWERS_-_INSTRUCTIONS_END -->"))return{error:!0,message:"Template is missing required markers"};let B=pX($);try{if(!A(B))f(`mkdir -p "${B}"`,{stdio:"pipe"})}catch(E){return{error:!0,message:`Failed to create .github directory: ${E.message}`}}if(A($)){let E;try{E=r($,"utf8")}catch(U){return{error:!0,message:`Failed to read existing file: ${U.message}`}}let V=new Date().toISOString().replace(/[:.]/g,"-"),_=`${$}.backup-${V}`;try{f(`cp "${$}" "${_}"`,{stdio:"pipe"})}catch(U){return{error:!0,message:`Failed to backup: ${U.message}`}}if(E.includes("<!-- SUPERPOWERS_-_INSTRUCTIONS_START -->")&&E.includes("<!-- SUPERPOWERS_-_INSTRUCTIONS_END -->")){let U=new RegExp("<!-- SUPERPOWERS_-_INSTRUCTIONS_START -->[\\s\\S]*?<!-- SUPERPOWERS_-_INSTRUCTIONS_END -->","g"),L=E.replace(U,K.trim());try{return XQ($,L,"utf8"),{updated:!0,backup:_}}catch(I){return{error:!0,message:`Failed to update: ${I.message}`}}}else{let U=E.trimEnd()+`
|
|
118
118
|
|
|
119
119
|
`+K.trim()+`
|
|
120
|
-
`;try{return
|
|
121
|
-
`);let
|
|
120
|
+
`;try{return XQ($,U,"utf8"),{updated:!0,backup:_}}catch(L){return{error:!0,message:`Failed to append: ${L.message}`}}}}else try{return XQ($,K,"utf8"),{created:!0}}catch(E){return{error:!0,message:`Failed to create: ${E.message}`}}},cX=()=>{u(),console.log(`# Setting up Superpowers skills for this project
|
|
121
|
+
`);let Q=process.cwd(),X=v(Q,".agents"),Y=v(X,"skills"),$=v(Q,"AGENTS.md"),Z=v(X,"AGENTS.md"),q=A($)?$:Z,z=v(H.superpowersRepo,".agents","templates","AGENTS.md.template");if(!A(z)){console.log(`✗ Error: AGENTS.md template not found
|
|
122
122
|
Expected at: ${z}
|
|
123
|
-
Please update your Superpowers installation`);return}if(!A(
|
|
124
|
-
Detected platforms for project: ${
|
|
125
|
-
`);let
|
|
123
|
+
Please update your Superpowers installation`);return}if(!A(X))try{f(`mkdir -p "${X}"`,{stdio:"pipe"}),console.log("✓ Created .agents/ directory")}catch(w){console.log(`✗ Failed to create .agents/ directory: ${w.message}`);return}else console.log("✓ .agents/ directory exists");if(!A(Y))try{f(`mkdir -p "${Y}"`,{stdio:"pipe"}),f(`touch "${v(Y,".gitkeep")}"`,{stdio:"pipe"}),console.log("✓ Created .agents/skills/ directory")}catch(w){console.log(`✗ Failed to create skills directory: ${w.message}`);return}else console.log("✓ .agents/skills/ directory exists");let W=v(X,"docs"),K=v(W,"SUPERPOWERS.md"),B=v(H.superpowersRepo,".agents","templates","SUPERPOWERS.md.template");if(!A(W))try{f(`mkdir -p "${W}"`,{stdio:"pipe"}),console.log("✓ Created .agents/docs/ directory")}catch(w){console.log(`⚠️ Failed to create docs directory: ${w.message}`)}else console.log("✓ .agents/docs/ directory exists");let E=A(q);if(E){let w=new Date().toISOString().split("T")[0],c=`${q}.backup-${w}`;try{f(`cp "${q}" "${c}"`,{stdio:"pipe"}),console.log(`✓ Backed up existing AGENTS.md to ${QQ(c).base}`)}catch(BQ){console.log(`✗ Failed to backup AGENTS.md: ${BQ.message}`);return}}let V;try{V=r(z,"utf8")}catch(w){console.log(`✗ Failed to read template: ${w.message}`);return}let _=P();if(V=V.replace(/\{\{VERSION\}\}/g,_),A(B))try{let w=r(B,"utf8"),c=new Date().toISOString().split("T")[0];w=w.replace(/\{\{VERSION\}\}/g,_),w=w.replace(/\{\{DATE\}\}/g,c),XQ(K,w,"utf8"),console.log("✓ Created .agents/docs/SUPERPOWERS.md")}catch(w){console.log(`⚠️ Failed to create SUPERPOWERS.md: ${w.message}`)}else console.log("⚠️ SUPERPOWERS.md.template not found");let U=[],L=v(Q,".github","copilot-instructions.md"),I=v(H.home,".github","copilot-instructions.md");if(A(L)||A(I)||R.copilot.check())U.push("github-copilot");let M=v(Q,"CLAUDE.md"),N=v(X,"CLAUDE.md");if(A(M)||A(N)||R.claude.check())U.push("claude-code");if(R.opencode.check())U.push("opencode");console.log(`
|
|
124
|
+
Detected platforms for project: ${U.join(", ")||"none"}
|
|
125
|
+
`);let S=U.filter((w)=>["github-copilot","opencode"].includes(w)),C=LQ(q,V,S,!E);if(C.created)console.log(`✓ Created AGENTS.md with platform tool mappings (${q===$?"root":".agents/"})`);else if(C.updated)console.log(`✓ Updated AGENTS.md with platform tool mappings (${q===$?"root":".agents/"})`);else if(C.error)console.log("⚠️ Failed to update AGENTS.md");let i=A(M)?M:N,G=LQ(i,V,["claude-code"],!1);if(G.created)console.log(`✓ Created CLAUDE.md with Claude Code tool mappings (${i===M?"root":".agents/"})`);else if(G.updated){if(console.log(`✓ Updated CLAUDE.md with Claude Code tool mappings (${i===M?"root":".agents/"})`),G.backup)console.log(` Backed up to ${QQ(G.backup).base}`)}else if(G.skipped)console.log("ℹ️ Skipped CLAUDE.md (does not exist)");else if(G.error)console.log("⚠️ Failed to update CLAUDE.md");let J=v(Q,".github","copilot-instructions.md"),F={skipped:!0};if(U.includes("github-copilot")){if(F=_Z(Q),F.created)console.log("✓ Created .github/copilot-instructions.md with Superpowers instructions");else if(F.updated){if(console.log("✓ Updated .github/copilot-instructions.md with Superpowers instructions"),F.backup)console.log(` Backed up to ${QQ(F.backup).base}`)}else if(F.error)console.log(`⚠️ Failed to update .github/copilot-instructions.md: ${F.message||""}`)}else console.log("ℹ️ Skipped .github/copilot-instructions.md (GitHub Copilot not detected)");let x=!A($)&&!A(Z);if(A(J)&&x){let w=LQ(J,V,["github-copilot"],!1);if(w.updated){if(console.log("✓ Updated .github/copilot-instructions.md with GitHub Copilot tool mappings"),w.backup)console.log(` Backed up to ${QQ(w.backup).base}`)}else if(w.error)console.log("⚠️ Failed to update .github/copilot-instructions.md with tool mappings")}else if(A(J)&&!x)console.log("ℹ️ Skipped .github/copilot-instructions.md tool mappings (AGENTS.md exists, using that instead)");else if(!A(J)&&!U.includes("github-copilot"))console.log("ℹ️ Skipped .github/copilot-instructions.md tool mappings (does not exist)");let g=`
|
|
126
126
|
# Setup complete!
|
|
127
127
|
|
|
128
128
|
Your project now has:
|
|
129
|
-
- .agents/ directory structure`;if(
|
|
130
|
-
- AGENTS.md with universal skills instructions`;if(
|
|
129
|
+
- .agents/ directory structure`;if(C.updated||C.created)g+=`
|
|
130
|
+
- AGENTS.md with universal skills instructions`;if(G.updated||G.created)g+=`
|
|
131
131
|
- CLAUDE.md with Claude Code skills instructions`;if(F.updated||F.created)g+=`
|
|
132
132
|
- .github/copilot-instructions.md with Superpowers instructions`;g+=`
|
|
133
133
|
- .agents/skills/ ready for project-specific skills`,g+=`
|
|
134
134
|
- .agents/docs/SUPERPOWERS.md for detailed reference
|
|
135
|
-
`,console.log(g)},
|
|
135
|
+
`,console.log(g)},GZ=()=>{let Q=[...["brainstorming.prompt.md","execute-plan.prompt.md","write-plan.prompt.md","setup-skills.prompt.md","create-meta-prompt.md","finding-skills.prompt.md","skills.prompt.md","use-skill.prompt.md","using-a-skill.prompt.md"].map((Y)=>v(H.vscodeUserDir,"prompts",Y)),...["brainstorm.md","create-meta-prompt.md","execute-plan.md","finding-skills.md","skills.md","use-skill.md","using-a-skill.md","write-plan.md","setup-skills.md"].map((Y)=>v(H.home,".claude","commands",Y)),...["brainstorm.md","create-meta-prompt.md","execute-plan.md","finding-skills.md","skills.md","use-skill.md","using-a-skill.md","write-plan.md","setup-skills.md"].map((Y)=>v(H.home,".config","opencode","command",Y))],X=0;for(let Y of Q)if(A(Y))try{hX(Y),X++}catch($){console.log(` ⚠️ Could not remove ${Y}: ${$.message}`)}if(X>0)console.log(`✓ Removed ${X} legacy prompt/command file${X!==1?"s":""}`);else console.log("✓ No legacy prompt/command files found")},UZ=()=>{let Q=0;for(let X of IQ){let Y=X.skillsDir(),$=v(Y,"superpowers");try{if(BZ($).isSymbolicLink())hX($),console.log(`✓ Removed legacy superpowers symlink from ${Y.replace(H.home,"~")}`),Q++}catch{}}if(Q===0)console.log("✓ No legacy superpowers directory symlinks found")},nX=async()=>{u(),console.log(`# Superpowers Bootstrap for Agents
|
|
136
136
|
# ==================================
|
|
137
|
-
`);let
|
|
137
|
+
`);let Q=process.argv.includes("--no-update"),Y=new Set(["copilot","claude","opencode"].filter((z)=>process.argv.includes(`--force-${z}`))),$=Y.size>0;if(!Q){let z=WQ(),W=await GQ();if(W.error)console.log(`## Update Check
|
|
138
138
|
|
|
139
139
|
⚠️ Could not check for updates (network issue)
|
|
140
140
|
|
|
@@ -143,47 +143,47 @@ Your project now has:
|
|
|
143
143
|
`),console.log(`⚠️ Update available: v${W.localVersion} → v${W.remoteVersion}
|
|
144
144
|
To update, run: \`npm install -g @complexthings/superpowers-agent\``),console.log(`
|
|
145
145
|
---
|
|
146
|
-
`)}if(
|
|
147
|
-
`);if(
|
|
148
|
-
`),
|
|
146
|
+
`)}if(!$)uQ(),console.log(`---
|
|
147
|
+
`);if(!$)console.log(`## Cleaning Up Legacy Files
|
|
148
|
+
`),GZ(),console.log(`
|
|
149
149
|
---
|
|
150
|
-
`);if(
|
|
151
|
-
`),console.log("✓ Skill symlinks handled in sync step below"),
|
|
150
|
+
`);if(!$||Y.has("copilot")){if(console.log(`## GitHub Copilot Integration
|
|
151
|
+
`),console.log("✓ Skill symlinks handled in sync step below"),zQ("copilot")||A(v(H.home,".copilot"))||Y.has("copilot")){let W=xX();if(W.created)console.log(`✓ Installed Copilot sessionStart hook -> ${W.path.replace(H.home,"~")}`);else if(W.updated)console.log(`✓ Updated Copilot sessionStart hook -> ${W.path.replace(H.home,"~")}`);else if(W.existed)console.log("✓ Copilot sessionStart hook already up to date");else if(W.error)console.log(`⚠️ Failed to install Copilot sessionStart hook: ${W.message}`)}else console.log("ℹ️ Skipped Copilot sessionStart hook (Copilot CLI not detected; run with --force-copilot to install anyway)");console.log(`
|
|
152
152
|
---
|
|
153
|
-
`)}if(
|
|
154
|
-
`),!
|
|
153
|
+
`)}if(!$||Y.has("claude")){if(console.log(`## Claude Code Integration
|
|
154
|
+
`),!R.claude.check()&&!Y.has("claude"))console.log(`⚠️ Skipped (${R.claude.name} CLI not detected)
|
|
155
155
|
\uD83D\uDCA1 To enable Claude Code integration:
|
|
156
|
-
1. Install Claude Code: ${
|
|
157
|
-
2. Run: superpowers-agent bootstrap --force-claude`);else{console.log("✓ Skill symlinks handled in sync step below");let W=
|
|
156
|
+
1. Install Claude Code: ${R.claude.installUrl}
|
|
157
|
+
2. Run: superpowers-agent bootstrap --force-claude`);else{console.log("✓ Skill symlinks handled in sync step below");let W=jX();if(W.created)console.log(`✓ Installed SessionStart hook -> ${H.claudeSettings.replace(H.home,"~")}`);else if(W.updated){if(console.log(`✓ ${W.existed?"Refreshed":"Added"} SessionStart hook in ${H.claudeSettings.replace(H.home,"~")}`),W.backup)console.log(` Backed up to ${QQ(W.backup).base}`)}else if(W.error)console.log(`⚠️ Failed to install SessionStart hook: ${W.message}`)}console.log(`
|
|
158
158
|
---
|
|
159
|
-
`)}if(
|
|
160
|
-
`),
|
|
159
|
+
`)}if(!$||Y.has("opencode")){if(console.log(`## OpenCode Integration
|
|
160
|
+
`),R.opencode.check())NX();else console.log(`⚠️ Skipped (${R.opencode.name} CLI not detected)
|
|
161
161
|
\uD83D\uDCA1 To enable OpenCode integration:
|
|
162
|
-
1. Install OpenCode: ${
|
|
163
|
-
2. Run: superpowers-agent ${
|
|
162
|
+
1. Install OpenCode: ${R.opencode.installUrl}
|
|
163
|
+
2. Run: superpowers-agent ${R.opencode.bootstrapCommand}`);console.log(`
|
|
164
164
|
---
|
|
165
|
-
`)}if(
|
|
166
|
-
`);let z=
|
|
167
|
-
`);let W=
|
|
168
|
-
`)}if(K){let
|
|
165
|
+
`)}if(!$){console.log(`## Generating Platform-Specific Files
|
|
166
|
+
`);let z=CX();console.log(`Detected platforms: ${z.join(", ")||"none"}
|
|
167
|
+
`);let W=v(H.superpowersRepo,".agents","templates","AGENTS.md.template"),K="";try{K=r(W,"utf8")}catch(B){console.log(`⚠️ Could not read AGENTS.md template: ${B.message}
|
|
168
|
+
`)}if(K){let B=P();K=K.replace(/\{\{VERSION\}\}/g,B);let E=v(H.home,".agents","AGENTS.md"),V=LQ(E,K,z,!0);if(V.created)console.log(`✓ Created ${E}`);else if(V.updated)console.log(`✓ Updated ${E}`)}console.log(`
|
|
169
169
|
---
|
|
170
170
|
`)}console.log(`## Cleaning Up Legacy Superpowers Dir Symlinks
|
|
171
|
-
`),
|
|
171
|
+
`),UZ(),console.log(`
|
|
172
172
|
---
|
|
173
173
|
`),console.log(`## Syncing Repo Skills -> ~/.agents/skills/
|
|
174
|
-
`);let
|
|
174
|
+
`);let Z=gX();if(Z.created>0||Z.updated>0)console.log(` ✓ ${Z.created} created, ${Z.updated} updated, ${Z.existed} already current`);else if(Z.errors.length>0)for(let z of Z.errors)console.log(` ⚠️ ${z}`);else console.log(` ✓ ${Z.existed} skill symlinks already up to date`);console.log(`
|
|
175
175
|
---
|
|
176
176
|
`),console.log(`## Cleaning Up Stale Platform Skill Symlinks
|
|
177
|
-
`);let q=
|
|
177
|
+
`);let q=mX({projectRoot:process.cwd()});if(q.removed.length>0){console.log(` ✓ Removed ${q.removed.length} stale skill symlink(s):`);for(let z of q.removed)console.log(` - ${z}`)}else console.log(" ✓ No stale platform skill symlinks found");console.log(`
|
|
178
178
|
---
|
|
179
179
|
`),console.log(`# Bootstrap Complete!
|
|
180
180
|
`),console.log("✓ All integrations installed"),console.log("✓ Skills system ready"),console.log(`✓ Skill symlinks synced
|
|
181
|
-
`),console.log("Next steps:"),console.log(" - Run `superpowers-agent find-skills` to see available skills"),console.log(" - Run `superpowers-agent setup-skills` in your project directory")};import{existsSync as b,readFileSync as
|
|
182
|
-
⚠ Could not parse agents.json: ${
|
|
183
|
-
⚠ Invalid agents.json: ${
|
|
184
|
-
\uD83D\uDCE6 Found agents.json (${q} v${z})`);let
|
|
185
|
-
${W} ${
|
|
186
|
-
${K} ${
|
|
181
|
+
`),console.log("Next steps:"),console.log(" - Run `superpowers-agent find-skills` to see available skills"),console.log(" - Run `superpowers-agent setup-skills` in your project directory")};import{existsSync as b,readFileSync as wQ,mkdirSync as vZ,rmSync as oQ,cpSync as CZ,lstatSync as bZ}from"fs";import{join as T,dirname as OQ,parse as HQ,sep as NZ}from"path";import{execSync as j}from"child_process";import{homedir as p}from"os";import{createInterface as FZ}from"readline";import{readFileSync as IZ,existsSync as pQ,unlinkSync as LZ,lstatSync as JZ,mkdirSync as wZ}from"fs";import{join as OZ,dirname as MZ}from"path";import{join as YQ}from"path";import{homedir as dQ}from"os";var mQ={github:{name:"github",sourceDir:".github/agents",sourceExt:".agent.md",getDestDir:()=>YQ(H.vscodeUserDir,"prompts"),getExtraDestDirs:()=>[YQ(dQ(),".copilot","agents")],destExt:".agent.md"},opencode:{name:"opencode",sourceDir:".opencode/agents",sourceExt:".md",getDestDir:()=>YQ(dQ(),".config","opencode","agents"),destExt:".md"},claude:{name:"claude",sourceDir:".claude/agents",sourceExt:".md",getDestDir:()=>YQ(dQ(),".claude","agents"),destExt:".md"}};function oX(Q,X,Y){let $=mQ[X];if(!$)return null;return YQ(Q,$.sourceDir,`${Y}${$.sourceExt}`)}function iX(Q,X){let Y=mQ[Q];if(!Y)return[];return[Y.getDestDir(),...Y.getExtraDestDirs?Y.getExtraDestDirs():[]].map((Z)=>YQ(Z,`${X}${Y.destExt}`))}function hQ(){return Object.keys(mQ)}function AZ(Q){if(!Q||typeof Q!=="object")return{valid:!1,error:"agents.json must be a JSON object"};if(!Q.version||typeof Q.version!=="string")return{valid:!1,error:'agents.json must have a "version" string field'};if(!Q.agents||typeof Q.agents!=="object")return{valid:!1,error:'agents.json must have an "agents" object field'};let X=hQ(),Y=[];for(let[$,Z]of Object.entries(Q.agents)){if(!X.includes($)){Y.push($);continue}if(!Array.isArray(Z))return{valid:!1,error:`agents.${$} must be an array of agent names`};for(let q of Z)if(typeof q!=="string")return{valid:!1,error:`agents.${$} must contain only string agent names`}}return{valid:!0,data:Q,skippedPlatforms:Y}}function TZ(Q,X){if(!pQ(Q))return{installed:!1,error:`Source file not found: ${Q}`};if(pQ(X))try{if(!JZ(X).isSymbolicLink())LZ(X)}catch($){}wZ(MZ(X),{recursive:!0});let Y=SX(Q,X);if(Y.error)return{installed:!1,error:Y.error};return{installed:!0}}function cQ(Q,X={}){let Y=OZ(Q,"agents.json");if(!pQ(Y))return;let $;try{$=JSON.parse(IZ(Y,"utf8"))}catch(U){console.log(`
|
|
182
|
+
⚠ Could not parse agents.json: ${U.message}`);return}let Z=AZ($);if(!Z.valid){console.log(`
|
|
183
|
+
⚠ Invalid agents.json: ${Z.error}`);return}for(let U of Z.skippedPlatforms)console.log(` ⚠ Skipping unknown platform: ${U}`);let q=$.repository||"unknown",z=$.version,W=X.isUpdate?"Updating":"Installing",K=X.isUpdate?"Updated":"Installed";console.log(`
|
|
184
|
+
\uD83D\uDCE6 Found agents.json (${q} v${z})`);let B=hQ(),E=0,V=0,_=[];for(let[U,L]of Object.entries($.agents)){if(!B.includes(U))continue;console.log(`
|
|
185
|
+
${W} ${U} agents:`);for(let I of L){let M=oX(Q,U,I),N=iX(U,I),S=[],C=[];for(let i of N){let G=TZ(M,i);if(G.installed)S.push(i);else C.push(G.error)}if(S.length>0)console.log(` ✓ ${I}`),_.push({platformKey:U,agentName:I,sourcePath:M,destPaths:S}),E++;else console.log(` ✗ ${I}: ${C.join("; ")}`),V++}}if(_.length>0){let U=y(!0);if(!U.installedAgents)U.installedAgents={};if(!U.installedAgents[q])U.installedAgents[q]={version:z,agents:{}};U.installedAgents[q].version=z;for(let{platformKey:L,agentName:I,sourcePath:M,destPaths:N}of _){if(!U.installedAgents[q].agents[L])U.installedAgents[q].agents[L]={};U.installedAgents[q].agents[L][I]={source:M,destination:N[0],destinations:N,installedAt:new Date().toISOString()}}h(U,!0)}if(E>0)console.log(`
|
|
186
|
+
${K} ${E} agent(s)${V>0?` (${V} failed)`:""}`)}var lX=(Q,X)=>{if(X.type==="local"){let $=Q;for(let Z=0;Z<10;Z++){if(b(T($,"agents.json")))return $;let q=OQ($);if(q===$)break;$=q}return Q}let Y=T(".agents","tmp");if(Q.includes(Y)){let $=Q.indexOf(Y),q=Q.substring($+Y.length+1).split(NZ)[0];return T(Q.substring(0,$),".agents","tmp",q)}return Q},aX=(Q,X)=>{let Y=T(p(),".agents","repos"),$=X.replace(/^@/,"").replace(/[^a-zA-Z0-9_-]/g,"_"),Z=T(Y,$);try{if(vZ(Y,{recursive:!0}),b(Z))oQ(Z,{recursive:!0,force:!0});return CZ(Q,Z,{recursive:!0}),Z}catch(q){return console.log(` Warning: Could not persist repository for agents: ${q.message}`),null}},iQ=(Q)=>{let X=Q.match(/^https:\/\/github\.com\/([^/]+)\/([^/]+)\/tree\/([^/]+)\/(.+)$/);if(X){let[,Z,q,z,W]=X;return{type:"git-tree",repoUrl:`https://github.com/${Z}/${q}.git`,branch:z,path:W,original:Q}}let Y=Q.match(/^git@github\.com:([^/]+)\/([^/]+?)(?:\.git)?$/);if(Y){let[,Z,q]=Y;return{type:"git-repo",repoUrl:`git@github.com:${Z}/${q}.git`,branch:null,path:null,original:Q}}let $=Q.match(/^https:\/\/github\.com\/([^/]+)\/([^/]+?)(?:\.git)?$/);if($){let[,Z,q]=$;return{type:"git-repo",repoUrl:`https://github.com/${Z}/${q}.git`,branch:null,path:null,original:Q}}if(b(Q))return{type:"local",path:Q,original:Q};return null},lQ=(Q)=>{let X=Q.includes("--global")||Q.includes("-g"),Y=Q.includes("--project")||Q.includes("-p");if(X)return T(p(),".agents","skills");if(Y)return T(process.cwd(),".agents","skills");let $=T(process.cwd(),".agents","config.json"),Z=T(p(),".agents","config.json");for(let q of[$,Z])if(b(q))try{if(JSON.parse(wQ(q,"utf8")).installLocation==="project")return T(process.cwd(),".agents","skills")}catch(z){}return T(p(),".agents","skills")},aQ=(Q,X)=>{let Y=T(p(),".agents","tmp",`skill-install-${Date.now()}`);try{if(j(`mkdir -p "${Y}"`,{stdio:"pipe"}),X)j(`git clone --branch ${X} --depth 1 "${Q}" "${Y}"`,{stdio:"pipe",timeout:30000});else j(`git clone --depth 1 "${Q}" "${Y}"`,{stdio:"pipe",timeout:30000});return Y}catch($){try{j(`rm -rf "${Y}"`,{stdio:"pipe"})}catch{}throw Error(`Failed to clone repository: ${$.message}`)}},ZQ=(Q)=>{let X=T(Q,"skill.json");if(!b(X))return null;try{let Y=wQ(X,"utf8");return JSON.parse(Y)}catch(Y){throw Error(`Failed to read skill.json: ${Y.message}`)}},JQ=(Q,X,Y,$)=>{let Z=T(Q,X);if(!b(Z)){$.errors.push(`Skill directory not found: ${X}`);return}let q=ZQ(Z);if(!q){$.errors.push(`No skill.json found in: ${X}`);return}let z=q.name||X,W=z.split("/").pop()||z,K=T(Y,W),B=OQ(K);try{j(`mkdir -p "${B}"`,{stdio:"pipe"})}catch(E){$.errors.push(`Failed to create directory ${B}: ${E.message}`);return}try{if(b(K))j(`rm -rf "${K}"`,{stdio:"pipe"});j(`cp -R "${Z}" "${K}"`,{stdio:"pipe"}),$.installed.push({name:W,path:K,title:q.title||q.description||W})}catch(E){$.errors.push(`Failed to install ${X}: ${E.message}`)}},rX=(Q,X,Y,$,Z=null)=>{let q=y($);if(!q.installedSkills)q.installedSkills={};let z={source:Q,installBase:X,installedAt:new Date().toISOString(),skills:Y.installed.map((W)=>({name:W.name,path:W.path}))};if(q.installedSkills[Q]=z,Z&&Z!==Q)q.installedSkills[Z]=z;h(q,$)},sX=()=>{let Q=process.argv.slice(3),X=Q.find((V)=>!V.startsWith("-")),Y=Q.filter((V)=>V.startsWith("-"));if(!X){console.log(`Usage: superpowers-agent add <url-or-path|@alias> [skill-path] [options]
|
|
187
187
|
|
|
188
188
|
Options:
|
|
189
189
|
--global, -g Install skills globally in ~/.agents/skills/ (default)
|
|
@@ -205,18 +205,18 @@ Description:
|
|
|
205
205
|
|
|
206
206
|
Repository aliases can be added using:
|
|
207
207
|
superpowers-agent add-repository <git-url> [--as=@alias]`);return}console.log(`Installing skill(s)...
|
|
208
|
-
`);let
|
|
209
|
-
Available aliases:`);let
|
|
210
|
-
Add a repository using:`),console.log(" superpowers-agent add-repository <git-url>");else for(let[
|
|
211
|
-
`);else
|
|
212
|
-
`);else if(
|
|
213
|
-
`);else console.log(`Repository URL: ${
|
|
214
|
-
`)}let W=
|
|
215
|
-
`);let E
|
|
216
|
-
`);for(let
|
|
217
|
-
**Successfully installed skills:**`),console.log(`- Source: ${
|
|
218
|
-
**Errors:**`);for(let
|
|
219
|
-
Error: ${
|
|
208
|
+
`);let $=!Y.includes("--project")&&!Y.includes("-p"),Z=null,q=null,z=null;if(X.startsWith("@")){let V=X;z=V,q=Q.find((I,M)=>M>0&&!I.startsWith("-")&&I!==V);let _=k(!1),U=k(!0);if(_[V])Z=_[V],console.log(`Using project repository alias: ${V}`);else if(U[V])Z=U[V],console.log(`Using global repository alias: ${V}`);else{console.log(`Error: Repository alias not found: ${V}`),console.log(`
|
|
209
|
+
Available aliases:`);let I={...U,..._};if(Object.keys(I).length===0)console.log(" (none)"),console.log(`
|
|
210
|
+
Add a repository using:`),console.log(" superpowers-agent add-repository <git-url>");else for(let[M,N]of Object.entries(I))console.log(` ${M} -> ${N}`);return}let L=b(Z);if(q)if(L)X=T(Z,q),console.log(`Repository path: ${Z}`),console.log(`Skill path: ${q}
|
|
211
|
+
`);else X=Z,console.log(`Repository URL: ${Z}`),console.log(`Skill path: ${q}
|
|
212
|
+
`);else if(X=Z,L)console.log(`Repository path: ${Z}
|
|
213
|
+
`);else console.log(`Repository URL: ${Z}
|
|
214
|
+
`)}let W=iQ(X);if(!W){console.log(`Error: Invalid URL or path not found: ${X}`);return}if(q&&W.type==="git-repo"&&!W.path)W.path=q;let K=lQ(Y);console.log(`Install location: ${K}
|
|
215
|
+
`);let B,E=!1;try{if(W.type==="git-repo"||W.type==="git-tree"){if(console.log(`Cloning repository: ${W.repoUrl}`),W.branch)console.log(`Branch: ${W.branch}`);if(B=aQ(W.repoUrl,W.branch),E=!0,W.path){if(B=T(B,W.path),!b(B))throw Error(`Path not found in repository: ${W.path}`)}console.log("")}else B=W.path;let V=ZQ(B);if(!V)throw Error("No skill.json found in source directory");let _={installed:[],errors:[],source:W.original};if(V.skills&&Array.isArray(V.skills)){console.log(`Found ${V.skills.length} skill(s) to install
|
|
216
|
+
`);for(let I of V.skills)JQ(B,I,K,_)}else{let I=V.name||HQ(B).base;JQ(OQ(B),HQ(B).base,K,_)}let U=lX(B,W),L=T(U,"agents.json");if(b(L)){let I=U;if(E){let M;try{M=JSON.parse(wQ(L,"utf8"))}catch{}let N=M?.repository||W.original,S=aX(U,N);if(S)I=S}cQ(I,{isUpdate:!1})}if(E&&B)try{let I=B.split("/.agents/tmp/")[0]+"/.agents/tmp/"+B.split("/.agents/tmp/")[1].split("/")[0];j(`rm -rf "${I}"`,{stdio:"pipe"})}catch{}if(console.log(`
|
|
217
|
+
**Successfully installed skills:**`),console.log(`- Source: ${_.source}`),_.installed.length>0)for(let I of _.installed)console.log(` - Installed: ${I.name} at ${I.path}`),console.log(` ${I.title}`);if(_.errors.length>0){console.log(`
|
|
218
|
+
**Errors:**`);for(let I of _.errors)console.log(` - ${I}`)}if(_.installed.length===0&&_.errors.length===0)console.log(" No skills were installed");if(_.installed.length>0)rX(W.original,K,_,$,z)}catch(V){if(E&&B)try{let _=B.split("/.agents/tmp/")[0]+"/.agents/tmp/"+B.split("/.agents/tmp/")[1].split("/")[0];j(`rm -rf "${_}"`,{stdio:"pipe"})}catch{}console.log(`
|
|
219
|
+
Error: ${V.message}`)}},tX=()=>{let Q=process.argv.slice(3),X=Q.find((V)=>!V.startsWith("-")),Y=Q.filter((V)=>V.startsWith("-"));if(!X){console.log(`Usage: superpowers-agent pull <url-or-path|@alias> [skill-path] [options]
|
|
220
220
|
|
|
221
221
|
Options:
|
|
222
222
|
--global, -g Update skills globally in ~/.agents/skills/ (default)
|
|
@@ -241,18 +241,18 @@ Description:
|
|
|
241
241
|
|
|
242
242
|
Repository aliases can be added using:
|
|
243
243
|
superpowers-agent add-repository <git-url> [--as=@alias]`);return}console.log(`Updating skill(s)...
|
|
244
|
-
`);let
|
|
245
|
-
Available aliases:`);let
|
|
246
|
-
Add a repository using:`),console.log(" superpowers-agent add-repository <git-url>");else for(let[
|
|
247
|
-
`);else
|
|
248
|
-
`);else if(
|
|
249
|
-
`);else console.log(`Repository URL: ${
|
|
250
|
-
`)}let W=
|
|
251
|
-
`);let E
|
|
252
|
-
`);for(let
|
|
253
|
-
**Successfully updated skills:**`),console.log(`- Source: ${
|
|
254
|
-
**Errors:**`);for(let
|
|
255
|
-
Error: ${
|
|
244
|
+
`);let $=!Y.includes("--project")&&!Y.includes("-p"),Z=null,q=null,z=null;if(X.startsWith("@")){let V=X;z=V,q=Q.find((I,M)=>M>0&&!I.startsWith("-")&&I!==V);let _=k(!1),U=k(!0);if(_[V])Z=_[V],console.log(`Using project repository alias: ${V}`);else if(U[V])Z=U[V],console.log(`Using global repository alias: ${V}`);else{console.log(`Error: Repository alias not found: ${V}`),console.log(`
|
|
245
|
+
Available aliases:`);let I={...U,..._};if(Object.keys(I).length===0)console.log(" (none)"),console.log(`
|
|
246
|
+
Add a repository using:`),console.log(" superpowers-agent add-repository <git-url>");else for(let[M,N]of Object.entries(I))console.log(` ${M} -> ${N}`);return}let L=b(Z);if(q)if(L)X=T(Z,q),console.log(`Repository path: ${Z}`),console.log(`Skill path: ${q}
|
|
247
|
+
`);else X=Z,console.log(`Repository URL: ${Z}`),console.log(`Skill path: ${q}
|
|
248
|
+
`);else if(X=Z,L)console.log(`Repository path: ${Z}
|
|
249
|
+
`);else console.log(`Repository URL: ${Z}
|
|
250
|
+
`)}let W=iQ(X);if(!W){console.log(`Error: Invalid URL or path not found: ${X}`);return}if(q&&W.type==="git-repo"&&!W.path)W.path=q;let K=lQ(Y);console.log(`Install location: ${K}
|
|
251
|
+
`);let B,E=!1;try{if(W.type==="git-repo"||W.type==="git-tree"){if(console.log(`Cloning repository: ${W.repoUrl}`),W.branch)console.log(`Branch: ${W.branch}`);if(B=aQ(W.repoUrl,W.branch),E=!0,W.path){if(B=T(B,W.path),!b(B))throw Error(`Path not found in repository: ${W.path}`)}console.log("")}else B=W.path;let V=ZQ(B);if(!V)throw Error("No skill.json found in source directory");let _={installed:[],errors:[],source:W.original};if(V.skills&&Array.isArray(V.skills)){console.log(`Found ${V.skills.length} skill(s) to update
|
|
252
|
+
`);for(let I of V.skills)JQ(B,I,K,_)}else{let I=V.name||HQ(B).base;JQ(OQ(B),HQ(B).base,K,_)}let U=lX(B,W),L=T(U,"agents.json");if(b(L)){let I=U;if(E){let M;try{M=JSON.parse(wQ(L,"utf8"))}catch{}let N=M?.repository||W.original,S=aX(U,N);if(S)I=S}cQ(I,{isUpdate:!0})}if(E&&B)try{let I=B.split("/.agents/tmp/")[0]+"/.agents/tmp/"+B.split("/.agents/tmp/")[1].split("/")[0];j(`rm -rf "${I}"`,{stdio:"pipe"})}catch{}if(console.log(`
|
|
253
|
+
**Successfully updated skills:**`),console.log(`- Source: ${_.source}`),_.installed.length>0)for(let I of _.installed)console.log(` - Updated: ${I.name} at ${I.path}`),console.log(` ${I.title}`);if(_.errors.length>0){console.log(`
|
|
254
|
+
**Errors:**`);for(let I of _.errors)console.log(` - ${I}`)}if(_.installed.length===0&&_.errors.length===0)console.log(" No skills were updated");if(_.installed.length>0)rX(W.original,K,_,$,z)}catch(V){if(E&&B)try{let _=B.split("/.agents/tmp/")[0]+"/.agents/tmp/"+B.split("/.agents/tmp/")[1].split("/")[0];j(`rm -rf "${_}"`,{stdio:"pipe"})}catch{}console.log(`
|
|
255
|
+
Error: ${V.message}`)}},jZ=(Q)=>new Promise((X)=>{let Y=FZ({input:process.stdin,output:process.stdout});Y.question(Q,($)=>{Y.close(),X($.trim())})}),nQ=(Q)=>{try{return bZ(Q).isSymbolicLink()}catch{return!1}},eX=async()=>{let Q=process.argv.slice(3),X=Q.find((G)=>!G.startsWith("-")),Y=Q.filter((G)=>G.startsWith("-"));if(!X){console.log(`Usage: superpowers-agent rm <url-or-path|@alias> [options]
|
|
256
256
|
|
|
257
257
|
Options:
|
|
258
258
|
--global, -g Remove globally installed skills (default)
|
|
@@ -261,10 +261,10 @@ Options:
|
|
|
261
261
|
Examples:
|
|
262
262
|
superpowers-agent rm https://github.com/example/skills
|
|
263
263
|
superpowers-agent rm @myrepo
|
|
264
|
-
superpowers-agent rm ~/my-local-skills`);return}let
|
|
265
|
-
`);let
|
|
266
|
-
Proceed? [y/N] `)).toLowerCase()!=="y"){console.log("Aborted.");return}for(let
|
|
267
|
-
Done.`)}
|
|
264
|
+
superpowers-agent rm ~/my-local-skills`);return}let $=!Y.includes("--project")&&!Y.includes("-p"),Z=X,q=null;if(X.startsWith("@")){q=X;let G=k(!1),J=k(!0);if(G[X])Z=G[X];else if(J[X])Z=J[X];else{console.log(`Error: Repository alias not found: ${X}`);return}}let z=KX($),W=z[X]||z[Z],K=W?.installBase||lQ(Y),B=[];if(W)B=W.skills;else{console.log(`No tracking data found. Attempting to re-resolve skills from source...
|
|
265
|
+
`);let G=iQ(Z);if(!G){console.log(`Error: Invalid URL or path not found: ${Z}`);return}let J,F=!1;try{if(G.type==="git-repo"||G.type==="git-tree"){if(console.log(`Cloning repository: ${G.repoUrl}`),J=aQ(G.repoUrl,G.branch),F=!0,G.path){if(J=T(J,G.path),!b(J))throw Error(`Path not found in repository: ${G.path}`)}}else J=G.path;let x=ZQ(J);if(!x)throw Error("No skill.json found in source");let g=x.skills&&Array.isArray(x.skills)?x.skills:[x.name||HQ(J).base];for(let w of g){let c=w;if(x.skills){let BQ=T(J,w);if(b(BQ)){let rQ=ZQ(BQ);if(rQ?.name)c=rQ.name}}B.push({name:c,path:T(K,c)})}if(F)try{let w=J.split("/.agents/tmp/")[0]+"/.agents/tmp/"+J.split("/.agents/tmp/")[1].split("/")[0];j(`rm -rf "${w}"`,{stdio:"pipe"})}catch{}}catch(x){if(F&&J)try{let g=J.split("/.agents/tmp/")[0]+"/.agents/tmp/"+J.split("/.agents/tmp/")[1].split("/")[0];j(`rm -rf "${g}"`,{stdio:"pipe"})}catch{}console.log(`Error resolving source: ${x.message}`);return}}let E=B.filter((G)=>b(G.path)||nQ(G.path)),V=[];for(let G of B)for(let J of IQ){let F=T(J.skillsDir(),G.name);if(b(F)||nQ(F))V.push({platform:J.name,path:F})}let _=EX(),U=q||Z,L=[];if(_[U])for(let[,G]of Object.entries(_[U].agents||{}))for(let[,J]of Object.entries(G)){let F=J.destinations||(J.destination?[J.destination]:[]);for(let x of F)if(x&&(b(x)||nQ(x)))L.push({path:x})}let I=U.replace(/^@/,"").replace(/[^a-zA-Z0-9_-]/g,"_"),M=T(p(),".agents","repos",I),N=b(M),S=p(),C=(G)=>G.replace(S,"~");if(E.length===0&&V.length===0&&L.length===0&&!N){console.log("Nothing to remove.");return}if(console.log("Will remove:"),E.length>0){console.log(" Skills:");for(let G of E)console.log(` ${C(G.path)}`)}if(V.length>0){console.log(" Platform symlinks:");for(let G of V)console.log(` ${C(G.path)}`)}if(L.length>0){console.log(" Agents:");for(let G of L)console.log(` ${C(G.path)}`)}if(N)console.log(" Persisted repo:"),console.log(` ${C(M)}`);if((await jZ(`
|
|
266
|
+
Proceed? [y/N] `)).toLowerCase()!=="y"){console.log("Aborted.");return}for(let G of V){let J=kQ(G.path);if(J.removed)console.log(`Removed symlink: ${C(G.path)}`),yX(G.platform,G.path,"skills");else if(J.error==="Symlink does not exist")console.log(`Already removed: ${C(G.path)}`);else console.log(`Warning: ${C(G.path)}: ${J.error}`)}for(let G of L){let J=kQ(G.path);if(J.removed)console.log(`Removed agent: ${C(G.path)}`);else if(J.error==="Symlink does not exist")console.log(`Already removed: ${C(G.path)}`);else console.log(`Warning: ${C(G.path)}: ${J.error}`)}if(N)try{oQ(M,{recursive:!0,force:!0}),console.log(`Removed persisted repo: ${C(M)}`)}catch(G){console.log(`Warning: Failed to remove persisted repo: ${G.message}`)}for(let G of E){if(!b(G.path)){console.log(`Already removed: ${C(G.path)}`);continue}try{oQ(G.path,{recursive:!0,force:!0}),console.log(`Removed skill: ${C(G.path)}`)}catch(J){console.log(`Warning: Failed to remove ${C(G.path)}: ${J.message}`)}}if(FQ(X,$),Z!==X)FQ(Z,$);if(_[U]){let G=y(!0);if(G.installedAgents)delete G.installedAgents[U],h(G,!0)}console.log(`
|
|
267
|
+
Done.`)},QY=()=>{let Q=process.argv.slice(3),X=Q.find((B)=>!B.startsWith("-")),Y=Q.filter((B)=>B.startsWith("-"));if(!X){console.log(`Usage: superpowers-agent add-repository <git-url> [options]
|
|
268
268
|
|
|
269
269
|
Options:
|
|
270
270
|
--global, -g Add repository globally in ~/.agents/config.json (default)
|
|
@@ -282,15 +282,15 @@ Description:
|
|
|
282
282
|
The repository's skill.json will be read to determine the default alias.
|
|
283
283
|
Use --as to specify a custom alias.
|
|
284
284
|
After adding, you can install skills using: superpowers-agent add @alias path/to/skill`);return}console.log(`Adding repository...
|
|
285
|
-
`);let
|
|
286
|
-
You can now install skills using:`),console.log(` superpowers-agent add ${
|
|
287
|
-
Error: ${
|
|
288
|
-
# ${
|
|
289
|
-
# When to use: ${
|
|
285
|
+
`);let $=Y.some((B)=>B==="--global"||B==="-g"),Z=Y.some((B)=>B==="--project"||B==="-p"),q=Y.find((B)=>B.startsWith("--as=")),z=q?q.split("=")[1]:null,W=Z?!1:!0,K;try{console.log(`Cloning repository: ${X}`),K=T(p(),".agents","tmp",`repo-add-${Date.now()}`),j(`mkdir -p "${K}"`,{stdio:"pipe"}),j(`git clone --depth 1 "${X}" "${K}"`,{stdio:"pipe",timeout:30000}),console.log("");let B=ZQ(K);if(!B)throw Error("No skill.json found in repository");let E;if(z)E=z;else if(B.repository)E=B.repository;else{let U=X.match(/\/([^/]+?)(?:\.git)?$/);if(U)E="@"+U[1];else throw Error("Could not determine repository alias. Use --as=@alias to specify manually.")}BX(E,X,W),j(`rm -rf "${K}"`,{stdio:"pipe"});let V=W?"globally":"in project",_=W?T(p(),".agents","config.json"):T(process.cwd(),".agents","config.json");console.log(`✓ Repository added ${V}`),console.log(` Alias: ${E}`),console.log(` URL: ${X}`),console.log(` Config: ${_}`),console.log(`
|
|
286
|
+
You can now install skills using:`),console.log(` superpowers-agent add ${E} <path-to-skill>`)}catch(B){if(K)try{j(`rm -rf "${K}"`,{stdio:"pipe"})}catch{}console.log(`
|
|
287
|
+
Error: ${B.message}`)}};import{dirname as XY}from"path";var YY=(Q,X,Y)=>{let{content:$,frontmatter:Z}=MQ(Q),q=s[X].prefix+Y,z=XY(Q),W=`# ${Z.name||q}`;if(Z.description)W+=`
|
|
288
|
+
# ${Z.description}`;if(Z.whenToUse)W+=`
|
|
289
|
+
# When to use: ${Z.whenToUse}`;return W+=`
|
|
290
290
|
# Supporting tools and docs are in ${z}
|
|
291
291
|
# ============================================
|
|
292
292
|
|
|
293
|
-
${
|
|
293
|
+
${$}`,W},ZY=(Q)=>{if(!Q){console.log(`Usage: superpowers-agent use-skill <skill-name>
|
|
294
294
|
|
|
295
295
|
Examples (smart matching):
|
|
296
296
|
superpowers-agent use-skill brainstorming # Matches superpowers:collaboration/brainstorming
|
|
@@ -305,24 +305,24 @@ Examples (explicit paths):
|
|
|
305
305
|
Smart matching:
|
|
306
306
|
- Type just the skill name or any suffix of the path
|
|
307
307
|
- Priority: .agents/skills/ > .claude/skills/ > ~/.agents/skills/ > ~/.agents/superpowers/skills/
|
|
308
|
-
- If multiple skills match at same priority, you'll see them with descriptions`);return}let
|
|
308
|
+
- If multiple skills match at same priority, you'll see them with descriptions`);return}let X=m(Q);if(!X){console.log(`Error: Skill not found: ${Q}
|
|
309
309
|
|
|
310
|
-
Available skills:`),console.log("Run: superpowers-agent find-skills");return}let{skillFile:
|
|
311
|
-
# ${z.description}`;if(z.whenToUse)
|
|
312
|
-
# When to use: ${z.whenToUse}`;
|
|
310
|
+
Available skills:`),console.log("Run: superpowers-agent find-skills");return}let{skillFile:Y,sourceType:$,actualSkillPath:Z}=X;try{let{content:q,frontmatter:z}=MQ(Y),W=s[$].prefix+Z,K=XY(Y),B=`# ${z.name||W}`;if(z.description)B+=`
|
|
311
|
+
# ${z.description}`;if(z.whenToUse)B+=`
|
|
312
|
+
# When to use: ${z.whenToUse}`;B+=`
|
|
313
313
|
# Supporting tools and docs are in ${K}
|
|
314
314
|
# ============================================
|
|
315
315
|
|
|
316
|
-
${q}`,console.log(
|
|
316
|
+
${q}`,console.log(B)}catch(q){console.log(q.message)}};var xZ=`You have superpowers.
|
|
317
317
|
|
|
318
|
-
**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.**`,
|
|
319
|
-
${
|
|
318
|
+
**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.**`,DZ="---\n\n**YOU MUST read and use the `leveraging-cli-tools` skill** the moment a task involves using BASH, searching code, parsing JSON/YAML, finding files, structural refactors, data wrangling, or any command that floods your context with verbose output (logs, CI logs, test runs). Load it with your skill tool BEFORE you reach for grep/find/sed or before you read large command output. It routes you to high-performance tools (rg, jq, fd, yq, ast-grep, gh, sd) and reduces output to just the signal — cutting token cost and latency 5-50x. Skipping it wastes tokens and time on work the right tool does instantly.",RZ=()=>{let Q=m("using-superpowers");if(!Q)return null;let X;try{X=YY(Q.skillFile,Q.sourceType,Q.actualSkillPath)}catch{return null}return`<EXTREMELY_IMPORTANT>
|
|
319
|
+
${xZ}
|
|
320
320
|
|
|
321
|
-
${
|
|
321
|
+
${X}
|
|
322
322
|
|
|
323
|
-
${
|
|
324
|
-
</EXTREMELY_IMPORTANT>`},
|
|
325
|
-
`)};var
|
|
323
|
+
${DZ}
|
|
324
|
+
</EXTREMELY_IMPORTANT>`},fZ=(Q="raw")=>{let X=RZ();if(Q==="claude")return JSON.stringify({hookSpecificOutput:{hookEventName:"SessionStart",additionalContext:X||""}});if(Q==="copilot")return JSON.stringify({additionalContext:X||""});return X||""},$Y=()=>{let Q=process.argv.find((Y)=>Y.startsWith("--format=")),X=Q?Q.split("=")[1]:"raw";process.stdout.write(fZ(X)+`
|
|
325
|
+
`)};var qY={bootstrap:nX,version:vX,"check-updates":()=>{TX().catch((Q)=>{console.error(Q.message),process.exit(1)})},update:()=>{let Q=process.argv.includes("--no-reinstall");RQ({skipReinstall:Q})},"config-get":wX,"config-set":OX,"setup-skills":cX,"use-skill":()=>ZY(process.argv[3]),"session-context":$Y,execute:UX,"find-skills":t,add:sX,"add-repository":QY,"list-repositories":MX,pull:tX,rm:eX,dir:LX,path:IX,"get-helpers":JX,"install-aliases":uQ,default:()=>{console.log(`Superpowers for Agents
|
|
326
326
|
Usage:
|
|
327
327
|
superpowers-agent bootstrap [--no-update] [--force] # Run complete bootstrap
|
|
328
328
|
superpowers-agent version # Show current version
|
|
@@ -346,4 +346,4 @@ Usage:
|
|
|
346
346
|
superpowers-agent install-aliases # Install universal aliases (superpowers, superpowers-agent)
|
|
347
347
|
|
|
348
348
|
Documentation: https://github.com/complexthings/superpowers
|
|
349
|
-
`)}},
|
|
349
|
+
`)}},SZ=process.argv[2]||"default",yZ=qY[SZ]||qY.default;try{let Q=yZ();if(Q&&typeof Q.then==="function")Q.catch((X)=>{console.error(`Error: ${X.message}`),process.exit(1)})}catch(Q){console.error(`Error: ${Q.message}`),process.exit(1)}
|