superpowers-mcp 6.4.5 → 6.4.7

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.
@@ -1,41 +1,47 @@
1
- "use strict";var V=Object.create;var R=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var Y=Object.getOwnPropertyNames;var B=Object.getPrototypeOf,Q=Object.prototype.hasOwnProperty;var Z=(e,t)=>{for(var r in t)R(e,r,{get:t[r],enumerable:!0})},T=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Y(t))!Q.call(e,s)&&s!==r&&R(e,s,{get:()=>t[s],enumerable:!(n=F(t,s))||n.enumerable});return e};var O=(e,t,r)=>(r=e!=null?V(B(e)):{},T(t||!e||!e.__esModule?R(r,"default",{value:e,enumerable:!0}):r,e)),X=e=>T(R({},"__esModule",{value:!0}),e);var ce={};Z(ce,{HARNESS_CONFIGS:()=>A,JSON_SERVER_ROOT_KEYS:()=>K,isPlainObject:()=>P,runSetup:()=>G,runSetupCli:()=>ae,safeWriteConfig:()=>z,stripJsonComments:()=>L,updateJsonConfig:()=>H,updateTomlConfig:()=>q,updateYamlConfig:()=>U});module.exports=X(ce);var u=O(require("fs")),o=O(require("path")),_=O(require("os")),M=O(require("crypto")),A={lmstudio:{name:"LM Studio",aliases:["lmstudio","lm-studio"],getConfigPath:(e,t)=>o.join(t,".lmstudio","mcp.json"),type:"json-mcpServers",defaultConfig:(e,t)=>({command:e,args:t})},roo:{name:"Roo Code (VS Code Desktop)",aliases:["roo","roo-code","roocode"],getConfigPath:(e,t,r)=>{let n=e==="win32"?r||o.join(t,"AppData","Roaming"):e==="darwin"?o.join(t,"Library","Application Support"):o.join(t,".config");return o.join(n,"Code","User","globalStorage","rooveterinaryinc.roo-cline","settings","mcp_settings.json")},type:"json-mcpServers",defaultConfig:(e,t)=>({command:e,args:t})},copilot:{name:"GitHub Copilot (VS Code)",aliases:["vscode","code","copilot"],getConfigPath:(e,t,r,n)=>e==="win32"?o.join(r||o.join(t,"AppData","Roaming"),"Code","User","mcp.json"):e==="darwin"?o.join(t,"Library","Application Support","Code","User","mcp.json"):o.join(t,".config","Code","User","mcp.json"),type:"json-servers",defaultConfig:(e,t)=>({command:e,args:t,type:"stdio"})},"copilot-insiders":{name:"GitHub Copilot (VS Code Insiders)",aliases:["vscode-insiders","code-insiders","insiders","insider","vscode-insider","code-insider","copilot-insider"],getConfigPath:(e,t,r,n)=>e==="win32"?o.join(r||o.join(t,"AppData","Roaming"),"Code - Insiders","User","mcp.json"):e==="darwin"?o.join(t,"Library","Application Support","Code - Insiders","User","mcp.json"):o.join(t,".config","Code - Insiders","User","mcp.json"),type:"json-servers",defaultConfig:(e,t)=>({command:e,args:t,type:"stdio"})},cursor:{name:"Cursor",aliases:["cursor"],getConfigPath:(e,t)=>o.join(t,".cursor","mcp.json"),type:"json-mcpServers",defaultConfig:(e,t)=>({command:e,args:t})},hermes:{name:"Hermes Desktop / Agent",aliases:["hermes","hermes-desktop"],getConfigPath:(e,t,r,n)=>{if(e==="win32"){let s=n||o.join(t,"AppData","Local");return o.join(s,"hermes","config.yaml")}return o.join(t,".hermes","config.yaml")},type:"yaml",defaultConfig:(e,t)=>({command:e,args:t})},kimi:{name:"Kimi Work / Kimi Code",aliases:["kimi","kimi-work","kimi-code"],getConfigPath:(e,t)=>o.join(t,".kimi-code","mcp.json"),type:"json-mcpServers",defaultConfig:(e,t)=>({command:e,args:t})},claude:{name:"Claude Desktop",aliases:["claude","claude-desktop"],getConfigPath:(e,t,r)=>e==="win32"?o.join(r||o.join(t,"AppData","Roaming"),"Claude","claude_desktop_config.json"):e==="darwin"?o.join(t,"Library","Application Support","Claude","claude_desktop_config.json"):o.join(t,".config","Claude","claude_desktop_config.json"),type:"json-mcpServers",defaultConfig:(e,t)=>({command:e,args:t})},devin:{name:"Devin Desktop (formerly Windsurf)",aliases:["devin","devin-desktop","windsurf","codeium"],getConfigPath:(e,t,r)=>{let n=e==="win32"&&r?r:o.join(t,".config"),s=o.join(n,"devin","mcp_config.json");return u.existsSync(s)?s:o.join(t,".codeium","windsurf","mcp_config.json")},type:"json-mcpServers",defaultConfig:(e,t)=>({command:e,args:t})},antigravity:{name:"Antigravity (Google DeepMind)",aliases:["antigravity","agy","gemini"],getConfigPath:(e,t)=>o.join(t,".gemini","config","mcp_config.json"),type:"json-mcpServers",defaultConfig:(e,t)=>({command:e,args:t})},"pi-desktop":{name:"Pi Desktop / Pi Agent",aliases:["pi-desktop","pi","pi-agent"],getConfigPath:(e,t,r)=>{if(e==="win32"){let p=o.join(r||o.join(t,"AppData","Roaming"),".pi","agent","mcp.json");if(u.existsSync(p))return p;let g=o.join(t,".pi","agent","mcp.json");if(u.existsSync(g))return g;let c=o.join(t,".pi","mcp.json");return u.existsSync(c)?c:g}let n=o.join(t,".pi","agent","mcp.json");if(u.existsSync(n))return n;let s=o.join(t,".pi","mcp.json");return u.existsSync(s)?s:n},type:"json-mcpServers",defaultConfig:(e,t)=>({command:e,args:t})},qwenpaw:{name:"QwenPaw (Personal Agent Workstation)",aliases:["qwenpaw","qwen-paw","copaw"],getConfigPath:(e,t)=>{let r=o.join(t,".qwenpaw","config.json");if(u.existsSync(r))return r;let n=o.join(t,".copaw","config.json");return u.existsSync(n)?n:r},type:"json-mcpServers",defaultConfig:(e,t)=>({command:e,args:t})},cline:{name:"Cline (VS Code / CLI)",aliases:["cline","claude-dev"],getConfigPath:(e,t,r)=>{let n="";if(e==="win32"?n=o.join(r||o.join(t,"AppData","Roaming"),"Code","User","globalStorage","saoudrizwan.claude-dev","settings","cline_mcp_settings.json"):e==="darwin"?n=o.join(t,"Library","Application Support","Code","User","globalStorage","saoudrizwan.claude-dev","settings","cline_mcp_settings.json"):n=o.join(t,".config","Code","User","globalStorage","saoudrizwan.claude-dev","settings","cline_mcp_settings.json"),u.existsSync(n))return n;let s=o.join(t,".cline","data","settings","cline_mcp_settings.json");return u.existsSync(s)?s:n},type:"json-mcpServers",defaultConfig:(e,t)=>({command:e,args:t})},kilo:{name:"Kilo Code",aliases:["kilo","kilocode","kilo-code"],getConfigPath:(e,t)=>{let r=o.join(t,".config","kilo","kilo.jsonc");if(u.existsSync(r))return r;let n=o.join(t,".config","kilo","kilo.json");return u.existsSync(n)?n:r},type:"json-mcp",defaultConfig:(e,t)=>({type:"local",command:[e,...t],enabled:!0})},qoder:{name:"Qoder",aliases:["qoder"],getConfigPath:(e,t)=>o.join(t,".qoder","settings.json"),type:"json-mcpServers",defaultConfig:(e,t)=>({command:e,args:t})},kiro:{name:"Kiro",aliases:["kiro","kiro-code"],getConfigPath:(e,t)=>o.join(t,".kiro","settings","mcp.json"),type:"json-mcpServers",defaultConfig:(e,t)=>({command:e,args:t})},trae:{name:"Trae",aliases:["trae"],getConfigPath:(e,t,r)=>{if(e==="win32"){let n=o.join(r||o.join(t,"AppData","Roaming"),"Trae","User","mcp.json");if(u.existsSync(n))return n;let s=o.join(r||o.join(t,"AppData","Roaming"),"Trae CN","User","mcp.json");return u.existsSync(s)?s:n}else if(e==="darwin"){let n=o.join(t,"Library","Application Support","Trae","User","mcp.json");if(u.existsSync(n))return n;let s=o.join(t,"Library","Application Support","Trae CN","User","mcp.json");return u.existsSync(s)?s:n}else{let n=o.join(t,".config","Trae","User","mcp.json");if(u.existsSync(n))return n;let s=o.join(t,".config","Trae CN","User","mcp.json");return u.existsSync(s)?s:n}},type:"json-mcpServers",defaultConfig:(e,t)=>({command:e,args:t})},codex:{name:"Codex",aliases:["codex"],getConfigPath:(e,t)=>o.join(t,".codex","config.toml"),type:"toml",defaultConfig:(e,t)=>({command:e,args:t})},openclaw:{name:"OpenClaw",aliases:["openclaw","open-claw"],getConfigPath:(e,t)=>o.join(t,".openclaw","openclaw.json"),type:"json-mcpServers",serverPath:["mcp","servers"],defaultConfig:(e,t)=>({command:e,args:t})},goose:{name:"Goose",aliases:["goose"],getConfigPath:(e,t,r)=>e==="win32"?o.join(r||o.join(t,"AppData","Roaming"),"Block","goose","config","config.yaml"):o.join(t,".config","goose","config.yaml"),type:"yaml",yamlProfile:"goose",defaultConfig:(e,t)=>({cmd:e,args:t})}},K=["mcpServers","servers","mcp"];function P(e){return Object.prototype.toString.call(e)==="[object Object]"}function L(e,t=!1){if(!e)return"";if(!t)try{return JSON.parse(e),e}catch{}let r=e.length,n=[],s=!1,p=!1,g=!1,c=!1,j=-1;for(let l=0;l<r;l++){let f=e[l],S=l+1<r?e[l+1]:"";if(g){(f===`
2
- `||f==="\r")&&(g=!1,n.push(f));continue}if(c){f==="*"&&S==="/"&&(c=!1,l++);continue}if(s){n.push(f),p?p=!1:f==="\\"?p=!0:f==='"'&&(s=!1);continue}if(f==='"'){s=!0,p=!1,j=-1,n.push(f);continue}if(f==="/"&&S==="/"){g=!0,l++;continue}if(f==="/"&&S==="*"){c=!0,l++;continue}if(f===","){j=n.length,n.push(f);continue}if(f==="}"||f==="]"){j!==-1&&(n[j]=" ",j=-1),n.push(f);continue}f!==" "&&f!==" "&&f!==`
3
- `&&f!=="\r"&&(j=-1),n.push(f)}return n.join("")}var W=/\s/;function ee(e){for(let t=1;t<e.length;t++){if(e[t]!=="#"||!W.test(e[t-1]))continue;let r=t-1;for(;r>0&&W.test(e[r-1]);)r--;return e.slice(r)}return""}function U(e,t,r,n=!1,s="mcp"){let p=s==="goose"?{rootKey:"extensions",ownedKeys:["cmd","args","type"],freshEntry:(i,d,a)=>[`${i}superpowers:`,`${i}${i}name: "Superpowers"`,`${i}${i}cmd: ${JSON.stringify(d)}`,`${i}${i}args: ${JSON.stringify(a)}`,`${i}${i}enabled: true`,`${i}${i}type: stdio`,`${i}${i}timeout: 300`]}:{rootKey:"mcp_servers",ownedKeys:["command","args"],freshEntry:(i,d,a)=>[`${i}superpowers:`,`${i}${i}command: ${JSON.stringify(d)}`,`${i}${i}args: ${JSON.stringify(a)}`]};if(!/^[A-Za-z0-9_-]+$/.test(p.rootKey))throw new Error("Invalid YAML root key");let g=new RegExp(`^(\\s*)${p.rootKey}\\s*:`),c=new RegExp(`^(\\s*)${p.rootKey}\\s*:\\s*(?:#.*)?$`),j=new RegExp(`^\\s*["']?(?:${p.ownedKeys.join("|")})["']?\\s*:`),l=e?e.split(/\r?\n/):[],f=l.map((i,d)=>{let a=i.match(g);return a?{index:d,indent:a[1],tail:i.slice(a[0].length).trim()}:null}).filter(i=>i!==null),S=f.filter(i=>i.indent==="");if(S.length>1)throw new Error(`Cannot safely update YAML with duplicate ${p.rootKey} keys`);if(S.length===1){let i=S[0];if(i.tail!==""&&!i.tail.startsWith("#"))throw new Error(`Cannot safely update YAML unless ${p.rootKey} is a root-level block mapping`)}else if(f.length>0)throw new Error(`Cannot safely update YAML unless ${p.rootKey} is a root-level block mapping`);let k=" ";if(S.length===1)for(let i=S[0].index+1;i<l.length;i++){if(l[i].trim()===""||l[i].trimStart().startsWith("#"))continue;if(/^[^\s]/.test(l[i]))break;let d=l[i].match(/^(\s+)\S/);d&&(k=d[1]);break}if(n){let i=[],d=!1,a=0,m=!1,C=0;for(let x=0;x<l.length;x++){let v=l[x],b=v.match(c);if(b){d=!0,a=b[1].length,i.push(v);continue}if(d){let $=v.match(/^(\s*)/)?.[1].length||0;if(v.trimStart().startsWith("#")){i.push(v);continue}if(v.trim()!==""&&$<=a)d=!1,m=!1;else{let N=v.match(/^(\s*)superpowers:\s*(?:#.*)?$/);if(N&&N[1]===k){m=!0,C=N[1].length;continue}if(m){if($>C||v.trim()==="")continue;m=!1}}}i.push(v)}return i.join(`
4
- `)}let y=p.freshEntry(k,t,r);if(!e||e.trim()==="")return`${p.rootKey}:
1
+ "use strict";var oe=Object.create;var L=Object.defineProperty;var ie=Object.getOwnPropertyDescriptor;var ae=Object.getOwnPropertyNames;var ce=Object.getPrototypeOf,pe=Object.prototype.hasOwnProperty;var le=(e,t)=>{for(var n in t)L(e,n,{get:t[n],enumerable:!0})},V=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of ae(t))!pe.call(e,s)&&s!==n&&L(e,s,{get:()=>t[s],enumerable:!(r=ie(t,s))||r.enumerable});return e};var D=(e,t,n)=>(n=e!=null?oe(ce(e)):{},V(t||!e||!e.__esModule?L(n,"default",{value:e,enumerable:!0}):n,e)),ue=e=>V(L({},"__esModule",{value:!0}),e);var ke={};le(ke,{HARNESS_CONFIGS:()=>W,JSON_SERVER_ROOT_KEYS:()=>Z,isPlainObject:()=>I,runSetup:()=>se,runSetupCli:()=>Ce,safeWriteConfig:()=>re,stripJsonComments:()=>X,updateJsonConfig:()=>ne,updateTomlConfig:()=>te,updateYamlConfig:()=>ee});module.exports=ue(ke);var l=D(require("fs")),i=D(require("path")),T=D(require("os")),Q=D(require("crypto")),W={lmstudio:{name:"LM Studio",aliases:["lmstudio","lm-studio"],getConfigPath:(e,t)=>i.join(t,".lmstudio","mcp.json"),type:"json-mcpServers",defaultConfig:(e,t)=>({command:e,args:t})},roo:{name:"Roo Code (VS Code Desktop)",aliases:["roo","roo-code","roocode"],getConfigPath:(e,t,n)=>{let r=e==="win32"?n||i.join(t,"AppData","Roaming"):e==="darwin"?i.join(t,"Library","Application Support"):i.join(t,".config");return i.join(r,"Code","User","globalStorage","rooveterinaryinc.roo-cline","settings","mcp_settings.json")},type:"json-mcpServers",defaultConfig:(e,t)=>({command:e,args:t})},copilot:{name:"GitHub Copilot (VS Code)",aliases:["vscode","code","copilot"],getConfigPath:(e,t,n,r)=>e==="win32"?i.join(n||i.join(t,"AppData","Roaming"),"Code","User","mcp.json"):e==="darwin"?i.join(t,"Library","Application Support","Code","User","mcp.json"):i.join(t,".config","Code","User","mcp.json"),type:"json-servers",defaultConfig:(e,t)=>({command:e,args:t,type:"stdio"})},"copilot-insiders":{name:"GitHub Copilot (VS Code Insiders)",aliases:["vscode-insiders","code-insiders","insiders","insider","vscode-insider","code-insider","copilot-insider"],getConfigPath:(e,t,n,r)=>e==="win32"?i.join(n||i.join(t,"AppData","Roaming"),"Code - Insiders","User","mcp.json"):e==="darwin"?i.join(t,"Library","Application Support","Code - Insiders","User","mcp.json"):i.join(t,".config","Code - Insiders","User","mcp.json"),type:"json-servers",defaultConfig:(e,t)=>({command:e,args:t,type:"stdio"})},cursor:{name:"Cursor",aliases:["cursor"],getConfigPath:(e,t)=>i.join(t,".cursor","mcp.json"),type:"json-mcpServers",defaultConfig:(e,t)=>({command:e,args:t})},hermes:{name:"Hermes Desktop / Agent",aliases:["hermes","hermes-desktop"],getConfigPath:(e,t,n,r)=>{if(e==="win32"){let s=r||i.join(t,"AppData","Local");return i.join(s,"hermes","config.yaml")}return i.join(t,".hermes","config.yaml")},type:"yaml",defaultConfig:(e,t)=>({command:e,args:t})},kimi:{name:"Kimi Work / Kimi Code",aliases:["kimi","kimi-work","kimi-code"],getConfigPath:(e,t)=>i.join(t,".kimi-code","mcp.json"),type:"json-mcpServers",defaultConfig:(e,t)=>({command:e,args:t})},claude:{name:"Claude Desktop",aliases:["claude","claude-desktop"],getConfigPath:(e,t,n)=>e==="win32"?i.join(n||i.join(t,"AppData","Roaming"),"Claude","claude_desktop_config.json"):e==="darwin"?i.join(t,"Library","Application Support","Claude","claude_desktop_config.json"):i.join(t,".config","Claude","claude_desktop_config.json"),type:"json-mcpServers",defaultConfig:(e,t)=>({command:e,args:t})},devin:{name:"Devin Desktop (formerly Windsurf)",aliases:["devin","devin-desktop","windsurf","codeium"],getConfigPath:(e,t,n)=>{let r=e==="win32"&&n?n:i.join(t,".config"),s=i.join(r,"devin","mcp_config.json");return l.existsSync(s)?s:i.join(t,".codeium","windsurf","mcp_config.json")},type:"json-mcpServers",defaultConfig:(e,t)=>({command:e,args:t})},antigravity:{name:"Antigravity (Google DeepMind)",aliases:["antigravity","agy","gemini"],getConfigPath:(e,t)=>i.join(t,".gemini","config","mcp_config.json"),type:"json-mcpServers",defaultConfig:(e,t)=>({command:e,args:t})},"pi-desktop":{name:"Pi Desktop / Pi Agent",aliases:["pi-desktop","pi","pi-agent"],getConfigPath:(e,t,n)=>{if(e==="win32"){let c=i.join(n||i.join(t,"AppData","Roaming"),".pi","agent","mcp.json");if(l.existsSync(c))return c;let g=i.join(t,".pi","agent","mcp.json");if(l.existsSync(g))return g;let p=i.join(t,".pi","mcp.json");return l.existsSync(p)?p:g}let r=i.join(t,".pi","agent","mcp.json");if(l.existsSync(r))return r;let s=i.join(t,".pi","mcp.json");return l.existsSync(s)?s:r},type:"json-mcpServers",defaultConfig:(e,t)=>({command:e,args:t})},qwenpaw:{name:"QwenPaw (Personal Agent Workstation)",aliases:["qwenpaw","qwen-paw","copaw"],getConfigPath:(e,t)=>{let n=i.join(t,".qwenpaw","config.json");if(l.existsSync(n))return n;let r=i.join(t,".copaw","config.json");return l.existsSync(r)?r:n},type:"json-mcpServers",defaultConfig:(e,t)=>({command:e,args:t})},cline:{name:"Cline (VS Code / CLI)",aliases:["cline","claude-dev"],getConfigPath:(e,t,n)=>{let r="";if(e==="win32"?r=i.join(n||i.join(t,"AppData","Roaming"),"Code","User","globalStorage","saoudrizwan.claude-dev","settings","cline_mcp_settings.json"):e==="darwin"?r=i.join(t,"Library","Application Support","Code","User","globalStorage","saoudrizwan.claude-dev","settings","cline_mcp_settings.json"):r=i.join(t,".config","Code","User","globalStorage","saoudrizwan.claude-dev","settings","cline_mcp_settings.json"),l.existsSync(r))return r;let s=i.join(t,".cline","data","settings","cline_mcp_settings.json");return l.existsSync(s)?s:r},type:"json-mcpServers",defaultConfig:(e,t)=>({command:e,args:t})},kilo:{name:"Kilo Code",aliases:["kilo","kilocode","kilo-code"],getConfigPath:(e,t)=>{let n=i.join(t,".config","kilo","kilo.jsonc");if(l.existsSync(n))return n;let r=i.join(t,".config","kilo","kilo.json");return l.existsSync(r)?r:n},type:"json-mcp",defaultConfig:(e,t)=>({type:"local",command:[e,...t],enabled:!0})},qoder:{name:"Qoder",aliases:["qoder"],getConfigPath:(e,t)=>i.join(t,".qoder","settings.json"),type:"json-mcpServers",defaultConfig:(e,t)=>({command:e,args:t})},kiro:{name:"Kiro",aliases:["kiro","kiro-code"],getConfigPath:(e,t)=>i.join(t,".kiro","settings","mcp.json"),type:"json-mcpServers",defaultConfig:(e,t)=>({command:e,args:t})},trae:{name:"Trae",aliases:["trae"],getConfigPath:(e,t,n)=>{if(e==="win32"){let r=i.join(n||i.join(t,"AppData","Roaming"),"Trae","User","mcp.json");if(l.existsSync(r))return r;let s=i.join(n||i.join(t,"AppData","Roaming"),"Trae CN","User","mcp.json");return l.existsSync(s)?s:r}else if(e==="darwin"){let r=i.join(t,"Library","Application Support","Trae","User","mcp.json");if(l.existsSync(r))return r;let s=i.join(t,"Library","Application Support","Trae CN","User","mcp.json");return l.existsSync(s)?s:r}else{let r=i.join(t,".config","Trae","User","mcp.json");if(l.existsSync(r))return r;let s=i.join(t,".config","Trae CN","User","mcp.json");return l.existsSync(s)?s:r}},type:"json-mcpServers",defaultConfig:(e,t)=>({command:e,args:t})},codex:{name:"Codex",aliases:["codex"],getConfigPath:(e,t)=>i.join(t,".codex","config.toml"),type:"toml",defaultConfig:(e,t)=>({command:e,args:t})},openclaw:{name:"OpenClaw",aliases:["openclaw","open-claw"],getConfigPath:(e,t)=>i.join(t,".openclaw","openclaw.json"),type:"json-mcpServers",serverPath:["mcp","servers"],defaultConfig:(e,t)=>({command:e,args:t})},goose:{name:"Goose",aliases:["goose"],getConfigPath:(e,t,n)=>e==="win32"?i.join(n||i.join(t,"AppData","Roaming"),"Block","goose","config","config.yaml"):i.join(t,".config","goose","config.yaml"),type:"yaml",yamlProfile:"goose",defaultConfig:(e,t)=>({cmd:e,args:t})}},Z=["mcpServers","servers","mcp"];function I(e){return Object.prototype.toString.call(e)==="[object Object]"}function X(e,t=!1){if(!e)return"";if(!t)try{return JSON.parse(e),e}catch{}let n=e.length,r=[],s=!1,c=!1,g=!1,p=!1,v=-1;for(let d=0;d<n;d++){let h=e[d],j=d+1<n?e[d+1]:"";if(g){(h===`
2
+ `||h==="\r")&&(g=!1,r.push(h));continue}if(p){h==="*"&&j==="/"&&(p=!1,d++);continue}if(s){r.push(h),c?c=!1:h==="\\"?c=!0:h==='"'&&(s=!1);continue}if(h==='"'){s=!0,c=!1,v=-1,r.push(h);continue}if(h==="/"&&j==="/"){g=!0,d++;continue}if(h==="/"&&j==="*"){p=!0,d++;continue}if(h===","){v=r.length,r.push(h);continue}if(h==="}"||h==="]"){v!==-1&&(r[v]=" ",v=-1),r.push(h);continue}h!==" "&&h!==" "&&h!==`
3
+ `&&h!=="\r"&&(v=-1),r.push(h)}return r.join("")}var H=/\s/;function K(e){for(let t=1;t<e.length;t++){if(e[t]!=="#"||!H.test(e[t-1]))continue;let n=t-1;for(;n>0&&H.test(e[n-1]);)n--;return e.slice(n)}return""}var z=/\s+/y;function U(e,t){z.lastIndex=t;let n=z.exec(e);return n===null?t:t+n[0].length}var fe=/[\n\r\u2028\u2029]/;function Y(e){let t=U(e,0),n=t;if((e[n]==='"'||e[n]==="'")&&n++,!e.startsWith("superpowers",n)||(n+=11,(e[n]==='"'||e[n]==="'")&&n++,n=U(e,n),e[n]!==":"))return null;if(n=U(e,n+1),e[n]==="{"){let r=n+1;for(;e[r]===" "||e[r]===" ";)r++;if(e[r]!=="}")return null;n=U(e,r+1)}return n!==e.length&&(e[n]!=="#"||fe.test(e.slice(n+1)))?null:e.slice(0,t)}function ee(e,t,n,r=!1,s="mcp"){let c=s==="goose"?{rootKey:"extensions",ownedKeys:["cmd","args","type"],freshEntry:(o,u,f)=>[`${o}superpowers:`,`${o}${o}cmd: ${JSON.stringify(u)}`,`${o}${o}args: ${JSON.stringify(f)}`,`${o}${o}type: stdio`,`${o}${o}name: "Superpowers"`,`${o}${o}enabled: true`,`${o}${o}timeout: 300`]}:{rootKey:"mcp_servers",ownedKeys:["command","args"],freshEntry:(o,u,f)=>[`${o}superpowers:`,`${o}${o}command: ${JSON.stringify(u)}`,`${o}${o}args: ${JSON.stringify(f)}`]};if(!/^[A-Za-z0-9_-]+$/.test(c.rootKey))throw new Error("Invalid YAML root key");let g=new RegExp(`^(\\s*)["']?${c.rootKey}["']?\\s*:`),p=new RegExp(`^(\\s*)["']?${c.rootKey}["']?\\s*:\\s*(?:#.*)?$`),v=new RegExp(`^\\s*["']?(?:${c.ownedKeys.join("|")})["']?\\s*:`),d=e?e.split(/\r?\n/):[],h=e.includes(`\r
4
+ `)?`\r
5
+ `:`
6
+ `,j=(o,u)=>{let f=o.length,E=0;for(;f>0&&o[f-1]===`
7
+ `&&(u<0||E<u);)f--,f>0&&o[f-1]==="\r"&&f--,E++;return o.slice(0,f)},b=o=>{let u=e.endsWith(`
8
+ `),f=o.split(`
9
+ `).join(h);return u?j(f,1)+h:j(f,-1)},P=d.map((o,u)=>{let f=o.match(g);return f?{index:u,indent:f[1],tail:o.slice(f[0].length).trim()}:null}).filter(o=>o!==null),m=P.filter(o=>o.indent==="");if(m.length>1)throw new Error(`Cannot safely update YAML with duplicate ${c.rootKey} keys`);let w=o=>(K(` ${o}`)?o.slice(0,o.length-K(` ${o}`).length):o).trim();if(m.length===1){let o=m[0],u=w(o.tail),f=u==="{}"||u==="{ }";if(o.tail!==""&&!o.tail.startsWith("#")&&!f)throw new Error(`Cannot safely update YAML unless ${c.rootKey} is a root-level block mapping`)}else if(P.length>0)throw new Error(`Cannot safely update YAML unless ${c.rootKey} is a root-level block mapping`);let S=" ";if(m.length===1)for(let o=m[0].index+1;o<d.length;o++){if(d[o].trim()===""||d[o].trimStart().startsWith("#"))continue;if(/^[^\s]/.test(d[o]))break;let u=d[o].match(/^(\s+)\S/);u&&(S=u[1]);break}if(r){let o=[],u=!1,f=0,E=!1,A=0,R=!1,$=-1;for(let _=0;_<d.length;_++){let x=d[_],M=x.match(p);if(M){u=!0,f=M[1].length,f===0&&($=o.length),o.push(x);continue}if(u){let J=x.match(/^(\s*)/)?.[1].length||0;if(x.trimStart().startsWith("#")){o.push(x);continue}if(x.trim()!==""&&J<=f)u=!1,E=!1;else{let N=Y(x);if(N!==null&&N===S){E=!0,A=N.length,R=!0;continue}if(E){if(J>A||x.trim()==="")continue;E=!1}}}o.push(x)}if(R&&$>=0&&$<o.length){let _=o[$],x=_.match(p);if(x){let M=x[1].length,J=!1;for(let N=$+1;N<o.length;N++){let q=o[N];if(q.trim()===""||q.trimStart().startsWith("#"))continue;if((q.match(/^(\s*)/)?.[1].length??0)<=M)break;J=!0;break}J||(o[$]=_.replace(p,`${x[1]}${c.rootKey}: {}`)+K(_))}}return b(o.join(`
10
+ `))}let y=c.freshEntry(S,t,n);if(!e||e.trim()==="")return b(`${c.rootKey}:
5
11
  ${y.join(`
6
- `)}
7
- `;let w=S.length===1?S[0].index:-1;if(w===-1)return`${e.trimEnd()}
12
+ `)}`);let C=m.length===1?m[0].index:-1;if(C===-1)return b(`${e.trimEnd()}
8
13
 
9
- ${p.rootKey}:
14
+ ${c.rootKey}:
10
15
  ${y.join(`
11
- `)}
12
- `;let h=-1;for(let i=w+1;i<l.length;i++){let d=l[i];if(/^[^\s#]/.test(d))break;if((d.match(/^(\s*)/)?.[1]||"")===k&&/^\s+["']?superpowers["']?\s*:\s*(?:#.*)?$/.test(d)){h=i;break}}if(h!==-1){let i=l[h].match(/^(\s*)/)?.[1].length||2,d=h+1;for(;d<l.length;){let v=l[d];if((v.match(/^(\s*)/)?.[1].length||0)>i||v.trim()==="")d++;else break}let a=[],m=-1,C=i+k.length;for(let v=h+1;v<d;v++){let b=l[v];if(b.trim()==="")continue;let $=b.match(/^(\s*)/)?.[1].length??0;if(!(m!==-1&&$>m)){if(m=-1,$===C&&j.test(b)){m=$;continue}a.push(b)}}y[0]+=ee(l[h]);let x=y.filter((v,b)=>{if(b===0)return!0;let $=v.match(/^\s*["']?([A-Za-z0-9_-]+)["']?\s*:/);return!$||p.ownedKeys.includes($[1])});return l.splice(h,d-h,...x,...a),l.join(`
13
- `)}else return l.splice(w+1,0,...y),l.join(`
14
- `)}function I(e){let t=null;for(let r=0;r<e.length;r++){let n=e[r];if(t){if(t==='"'&&n==="\\"&&r+1<e.length){r++;continue}n===t&&(t=null);continue}if(n==='"'||n==="'"){t=n;continue}if(n==="#"){let s=r;for(;s>0&&W.test(e[s-1]);)s--;return[e.slice(0,s),e.slice(s)]}}return[e,""]}var te=/^\s*\[\s*mcp_servers\s*\.\s*superpowers\s*\]\s*(?:#.*)?$/;function E(e){return e===" "||e===" "||e===`
15
- `||e==="\r"||e==="\f"||e==="\v"}function J(e){let t=0;for(;t<e.length&&E(e[t]);)t++;if(t>=e.length||e[t]!=="[")return!1;let r=e.lastIndexOf("]");if(r<=t)return!1;let n=r+1;for(;n<e.length&&E(e[n]);)n++;return n>=e.length?!0:e[n]==="#"}var ne=/^\s*\[\s*mcp_servers\s*\.\s*superpowers\s*\./;function se(e){let t=0;for(;t<e.length&&E(e[t]);)t++;if(t>=e.length||e[t]!=="[")return!1;let r=e.lastIndexOf("]");if(r<=t)return!1;let n=r+1;for(;n<e.length&&E(e[n]);)n++;if(n<e.length&&e[n]!=="#")return!1;let s=e.slice(t+1,r);return!s.includes("mcp_servers")||!s.includes("superpowers")?!1:s.includes('"')||s.includes("'")}function re(e){let t=0;for(;t<e.length&&E(e[t]);)t++;let r=null;if(e.startsWith("command",t))r="command",t+=7;else if(e.startsWith("args",t))r="args",t+=4;else return null;for(;t<e.length&&E(e[t]);)t++;if(t>=e.length||e[t]!=="=")return null;for(t++;t<e.length&&E(e[t]);)t++;let n=e.length;for(;n>t&&E(e[n-1]);)n--;return{key:r,value:e.slice(t,n)}}var oe=/^\s*(command|args)\s*=/;function q(e,t,r,n=!1){let s=e?e.split(/\r?\n/):[];for(let a of s)if(/^\s*mcp_servers(?:\s*\.\s*[A-Za-z0-9_-]+)*\s*=/.test(a))throw new Error("Cannot safely update TOML with inline mcp_servers assignment (expected [mcp_servers.superpowers] table)");let p=[];for(let a=0;a<s.length;a++){if(se(s[a]))throw new Error("Cannot safely update TOML with quoted mcp_servers.superpowers table names");te.test(s[a])&&p.push(a)}if(p.length>1)throw new Error("Cannot safely update TOML with duplicate mcp_servers.superpowers tables");let g=`command = ${JSON.stringify(t)}`,c=`args = ${JSON.stringify(r)}`,j=a=>a.replace(/'/g,'"').replace(/\s+/g,"");if(p.length===0){if(n)return e;let a=`[mcp_servers.superpowers]
16
- ${g}
17
- ${c}
16
+ `)}`);let k=m.length===1?w(m[0].tail):"";if(k==="{}"||k==="{ }"){let o=d[C],u=o.match(g)?.[0].length??0,f=o.slice(u);d[C]=(o.slice(0,u)+f.slice(f.indexOf(k)+k.length)).trimEnd()}let a=-1;for(let o=C+1;o<d.length;o++){let u=d[o];if(/^[^\s#]/.test(u))break;if((u.match(/^(\s*)/)?.[1]||"")===S&&Y(u)!==null){a=o;break}}if(a!==-1){let o=d[a].match(/^(\s*)/)?.[1].length||2,u=a+1;for(;u<d.length;){let $=d[u];if(($.match(/^(\s*)/)?.[1].length||0)>o||$.trim()==="")u++;else break}let f=[],E=-1,A=o+S.length;for(let $=a+1;$<u;$++){let _=d[$];if(_.trim()==="")continue;let x=_.match(/^(\s*)/)?.[1].length??0;if(!(E!==-1&&x>E)){if(E=-1,x===A&&v.test(_)){E=x;continue}f.push(_)}}y[0]+=K(d[a]);let R=y.filter(($,_)=>{if(_===0)return!0;let x=$.match(/^\s*["']?([A-Za-z0-9_-]+)["']?\s*:/);return!x||c.ownedKeys.includes(x[1])});return d.splice(a,u-a,...R,...f),b(d.join(`
17
+ `))}else return d.splice(C+1,0,...y),b(d.join(`
18
+ `))}function F(e){let t=null;for(let n=0;n<e.length;n++){let r=e[n];if(t){if(t==='"'&&r==="\\"&&n+1<e.length){n++;continue}r===t&&(t=null);continue}if(r==='"'||r==="'"){t=r;continue}if(r==="#"){let s=n;for(;s>0&&H.test(e[s-1]);)s--;return[e.slice(0,s),e.slice(s)]}}return[e,""]}var ge=/^\s*\[\s*mcp_servers\s*\.\s*superpowers\s*\]\s*(?:#.*)?$/;function O(e){return e===" "||e===" "||e===`
19
+ `||e==="\r"||e==="\f"||e==="\v"}function G(e){let t=0;for(;t<e.length&&O(e[t]);)t++;if(t>=e.length||e[t]!=="[")return!1;let n=e.lastIndexOf("]");if(n<=t)return!1;let r=n+1;for(;r<e.length&&O(e[r]);)r++;return r>=e.length?!0:e[r]==="#"}var de=/^\s*\[\s*mcp_servers\s*\.\s*superpowers\s*\./,me=/^\s*\[\[\s*mcp_servers\s*\.\s*superpowers\s*\]\]/;function he(e){let t=0;for(;t<e.length&&O(e[t]);)t++;if(t>=e.length||e[t]!=="[")return!1;let n=e.lastIndexOf("]");if(n<=t)return!1;let r=n+1;for(;r<e.length&&O(e[r]);)r++;if(r<e.length&&e[r]!=="#")return!1;let s=e.slice(t+1,n);return!s.includes("mcp_servers")||!s.includes("superpowers")?!1:s.includes('"')||s.includes("'")}function ye(e){let t=0;for(;t<e.length&&O(e[t]);)t++;let n=null;if(e.startsWith("command",t))n="command",t+=7;else if(e.startsWith("args",t))n="args",t+=4;else return null;for(;t<e.length&&O(e[t]);)t++;if(t>=e.length||e[t]!=="=")return null;for(t++;t<e.length&&O(e[t]);)t++;let r=e.length;for(;r>t&&O(e[r-1]);)r--;return{key:n,value:e.slice(t,r)}}var we=/^\s*(command|args)\s*=/;function Se(e){let t=0,n=null;for(let r=0;r<e.length;r++){let s=e[r];if(n){if(n==='"'&&s==="\\"&&r+1<e.length){r++;continue}s===n&&(n=null);continue}if(s==='"'||s==="'"){n=s;continue}s==="["||s==="{"?t++:(s==="]"||s==="}")&&t--}return t>0||n!==null}function te(e,t,n,r=!1){let s=e?e.split(/\r?\n/):[];for(let a of s)if(/^\s*mcp_servers(?:\s*\.\s*[A-Za-z0-9_-]+)*\s*=/.test(a))throw new Error("Cannot safely update TOML with inline mcp_servers assignment (expected [mcp_servers.superpowers] table)");let c=[],g=-1;for(let a=0;a<s.length;a++){if(he(s[a]))throw new Error("Cannot safely update TOML with quoted mcp_servers.superpowers table names");me.test(s[a])&&(g=a),ge.test(s[a])&&c.push(a)}if(c.length>1)throw new Error("Cannot safely update TOML with duplicate mcp_servers.superpowers tables");let p=a=>{let o=a+1;for(;o<s.length&&!(G(s[o])&&!de.test(s[o]));)o++;return o};if(r){let a=[...c,...g===-1?[]:[g]].map(u=>[u,p(u)]).sort((u,f)=>u[0]-f[0]);if(a.length===0)return e;let o=new Set;for(let[u,f]of a)for(let E=u;E<f;E++)o.add(E);return s.filter((u,f)=>!o.has(f)).join(`
20
+ `)}if(g!==-1)throw new Error("Cannot safely update TOML: [[mcp_servers.superpowers]] is an array-of-tables, which cannot coexist with a [mcp_servers.superpowers] table. Remove it first.");let v=`command = ${JSON.stringify(t)}`,d=`args = ${JSON.stringify(n)}`,h=a=>a.replace(/'/g,'"').replace(/\s+/g,"");if(c.length===0){let a=`[mcp_servers.superpowers]
21
+ ${v}
22
+ ${d}
18
23
  `;return!e||e.trim()===""?a:`${e.trimEnd()}
19
24
 
20
- ${a}`}let l=p[0],f=l+1;for(;f<s.length&&!(J(s[f])&&!ne.test(s[f]));)f++;let S=f;for(let a=l+1;a<f;a++)if(J(s[a])){S=a;break}if(n)return s.slice(0,l).concat(s.slice(f)).join(`
21
- `);let k=null,y=null,w={};for(let a=l+1;a<S;a++){let[m,C]=I(s[a]),x=re(m);x&&(x.key==="command"?k===null&&(k=j(x.value)):y===null&&(y=j(x.value)),x.key in w||(w[x.key]=C))}if(k===j(JSON.stringify(t))&&y===j(JSON.stringify(r)))return e;let h=[`${g}${w.command??""}`,`${c}${w.args??""}`],i=s.slice(0,l+1),d=!1;for(let a=l+1;a<S;a++){let[m]=I(s[a]);if(oe.test(m)){d||(i.push(...h),d=!0);continue}i.push(s[a])}return d||i.push(...h),i.push(...s.slice(S,f)),i.push(...s.slice(f)),i.join(`
22
- `)}function D(e,t,r){if(!P(e))return t;let n={...e,...t};return(e.enabled!==void 0||e.disabled!==void 0)&&(e.enabled!==void 0?n.enabled=e.enabled:delete n.enabled),r==="json-mcp"&&Array.isArray(n.command)&&delete n.args,n}function H(e,t,r,n,s=!1,p,g){let c={},j=!1;if(e&&e.trim()!=="")try{let y=JSON.parse(e);if(!P(y))throw new Error("Existing JSON root must be an object");c=y}catch(y){try{let w=L(e,!0),h=JSON.parse(w);if(!P(h))throw new Error("Existing JSON root must be an object");c=h,j=w!==e}catch(w){let h=w instanceof Error?w.message:String(w),i=y instanceof Error?y.message:String(y);throw new Error(`Failed to parse existing JSON: ${h} (raw JSON error: ${i})`)}}let l=t==="json-servers"?"servers":t==="json-mcp"?"mcp":"mcpServers";if(g&&g.length>0){let y=g.join(".");for(let i of g){if(typeof i!="string"||i.length===0)throw new Error(`Invalid JSON field "${y}"`);if(i==="__proto__"||i==="constructor"||i==="prototype")throw new Error(`Refusing to use unsafe JSON field "${y}"`);if(!/^[A-Za-z0-9_-]+$/.test(i))throw new Error(`Invalid JSON field "${y}"`)}let w=c;for(let i of g){if(i==="__proto__"||i==="constructor"||i==="prototype")throw new Error(`Refusing to use unsafe JSON field "${y}"`);let d=w[i];if(d===void 0){if(s)return e;w[i]={}}else if(!P(d))throw new Error(`Existing JSON field "${y}" must be an object`);w=w[i]}if(s)delete w.superpowers;else{let i=p?{...p}:{command:r,args:n};w.superpowers=D(w.superpowers,i,t)}let h=JSON.stringify(c,null,2)+`
23
- `;return j&&h!==e&&process.stderr.write(`[superpowers-mcp] Warning: JSONC comments/trailing commas in the existing config were removed while updating it (the file is rewritten as plain JSON).
24
- `),h}let f=K.find(y=>P(c[y])&&c[y].superpowers!==void 0)??l;if(c[f]!==void 0&&!P(c[f]))throw new Error(`Existing JSON field "${f}" must be an object`);c[f]===void 0&&(c[f]={});let S=c[f];if(s)delete S.superpowers;else{let y;p?y={...p}:t==="json-servers"?y={command:r,args:n,type:"stdio"}:t==="json-mcp"?y={type:"local",command:[r,...n],enabled:!0}:y={command:r,args:n},S.superpowers=D(S.superpowers,y,t)}let k=JSON.stringify(c,null,2)+`
25
- `;return j&&k!==e&&process.stderr.write(`[superpowers-mcp] Warning: JSONC comments/trailing commas in the existing config were removed while updating it (the file is rewritten as plain JSON).
26
- `),k}function ie(e,t=10){try{let r=o.dirname(e),n=`${o.basename(e)}.`,s=".bak",p=u.readdirSync(r).filter(g=>{if(!g.startsWith(n)||!g.endsWith(s))return!1;let c=g.slice(n.length,g.length-s.length);return/^\d+$/.test(c)}).map(g=>{let c=o.join(r,g);try{return{full:c,mtimeMs:u.statSync(c).mtimeMs}}catch{return{full:c,mtimeMs:0}}}).sort((g,c)=>c.mtimeMs-g.mtimeMs);for(let g of p.slice(t))try{u.unlinkSync(g.full)}catch{}}catch{}}function z(e,t,r=!1,n=[],s){if(n.length===0)throw new Error("safeWriteConfig requires at least one allowed destination root");let p=e;try{let a=u.lstatSync(e,{throwIfNoEntry:!1});if(a&&a.isSymbolicLink()){try{p=u.realpathSync(e)}catch{let $=u.readlinkSync(e);p=o.resolve(o.dirname(e),$)}let m=o.normalize(o.resolve(p)).toLowerCase(),C=o.normalize(o.resolve(_.tmpdir())).toLowerCase();if(!(m===C||m.startsWith(C+o.sep))&&(["/etc","/bin","/sbin","/usr","/root","/sys","/proc","/dev","/private/etc","c:\\windows"].some(b=>m===b||m.startsWith(b+o.sep))||m==="/var"||m.startsWith("/var"+o.sep)&&!m.startsWith("/var/folders"+o.sep)||m==="/private/var"||m.startsWith("/private/var"+o.sep)&&!m.startsWith("/private/var/folders"+o.sep)))throw new Error(`Refusing to write to unsafe symlink target: ${p}`)}}catch(a){if(a instanceof Error&&a.message.includes("Refusing to write to unsafe symlink target"))throw a}let g=o.dirname(p);u.existsSync(g)||u.mkdirSync(g,{recursive:!0,mode:448});let c=u.realpathSync(g),j=u.statSync(c);p=o.join(c,o.basename(p));let l=o.normalize(o.resolve(p)).toLowerCase(),f=o.normalize(o.resolve(_.tmpdir())).toLowerCase(),S=l===f||l.startsWith(f+o.sep),y=["/etc","/bin","/sbin","/usr","/root","/sys","/proc","/dev","/private/etc","c:\\windows"].some(a=>l===a||l.startsWith(a+o.sep))||l==="/var"||l.startsWith("/var"+o.sep)&&!l.startsWith("/var/folders"+o.sep)||l==="/private/var"||l.startsWith("/private/var"+o.sep)&&!l.startsWith("/private/var/folders"+o.sep);if(!S&&y)throw new Error(`Refusing to write to unsafe configuration target: ${p}`);if(!n.some(a=>{if(!a)return!1;let m=o.resolve(a);try{m=u.realpathSync(m)}catch{}let C=o.relative(m,p);return C!==".."&&!C.startsWith(`..${o.sep}`)&&!o.isAbsolute(C)}))throw new Error(`Refusing to write configuration outside allowed roots: ${p}`);let h=384;if(u.existsSync(p)){try{h=u.statSync(p).mode}catch{}if(r){let a=u.readFileSync(p,"utf8"),m=`${p}.${Date.now()}.bak`;try{u.writeFileSync(m,a,{encoding:"utf8",mode:h})}catch(C){let x=C instanceof Error?C.message:String(C);throw new Error(`Failed to create safe backup before write: ${x}`)}ie(p)}}let i=M.randomBytes(8).toString("hex"),d=o.join(c,`.tmp.${o.basename(p)}.${process.pid}.${i}`);try{u.writeFileSync(d,t,{encoding:"utf8",mode:h,flag:"wx"});let a=u.existsSync(p);if(s===null&&a)throw new Error("Configuration changed concurrently before it could be created");if(s!=null&&(!a||u.readFileSync(p,"utf8")!==s))throw new Error("Configuration changed concurrently; refusing to overwrite newer content");let m=u.realpathSync(g),C=u.statSync(m);if(m!==c||C.dev!==j.dev||C.ino!==j.ino)throw new Error("Configuration directory changed while writing");u.renameSync(d,p)}catch(a){try{u.existsSync(d)&&u.unlinkSync(d)}catch{}throw a}}async function G(e={}){let t=e.platform||_.platform(),r=e.homeDir||_.homedir(),n=e.appData||process.env.APPDATA,s=e.localAppData||process.env.LOCALAPPDATA,p=!!e.dryRun,g=!!e.remove,c=!!e.bun,j=e.target?e.target.toLowerCase():null,l=c?"bunx":"npx",f=["-y","superpowers-mcp"],S=[];if(!j)throw new Error(`No target client specified. Please specify which client to configure using --target <${Object.keys(A).join("|")}>.`);let k=Object.keys(A).find(w=>w===j||A[w].aliases.includes(j));if(!k)throw new Error(`Unknown harness target: "${j}". Supported targets: ${Object.keys(A).join(", ")}`);let y=[k];for(let w of y){let h=A[w],i=h.getConfigPath(t,r,n,s),d=u.existsSync(i);if(g&&!d){S.push({target:w,name:h.name,path:i,status:"up-to-date",message:"Already not configured (file does not exist)"});continue}try{let a="";d&&(a=u.readFileSync(i,"utf8"));let m="";if(h.type==="yaml")m=U(a,l,f,g,h.yamlProfile);else if(h.type==="toml")m=q(a,l,f,g);else{let C=typeof h.defaultConfig=="function"?h.defaultConfig(l,f):void 0;m=H(a,h.type,l,f,g,C,h.serverPath)}if(a.trim()===m.trim()&&d){S.push({target:w,name:h.name,path:i,status:"up-to-date",message:g?"Already not configured":"Already configured and up-to-date"});continue}p||z(i,m,!!e.backup,[r,n||"",s||""],d?a:null),S.push({target:w,name:h.name,path:i,status:g?"removed":d?"updated":"created",message:p?`[Dry Run] Would ${g?"remove from":d?"update":"create"} ${i}`:`Successfully ${g?"removed from":d?"updated":"configured"}!`})}catch(a){let m=a instanceof Error?a.message:String(a);S.push({target:w,name:h.name,path:i,status:"error",message:m})}}return S}async function ae(e=process.argv.slice(2)){let t=!1,r={dryRun:!1,remove:!1,bun:!1,backup:!1,target:null};for(let n=0;n<e.length;n++){let s=e[n];if(!(s==="setup"||s==="install"||s==="--setup"))if(s==="--print-config")t=!0;else if(s==="--dry-run")r.dryRun=!0;else if(s==="--remove"||s==="--uninstall")r.remove=!0;else if(s==="--bun")r.bun=!0;else if(s==="--backup")r.backup=!0;else if(s==="--target"||s==="-t"){let p=e[n+1];if(!p||p.startsWith("-")){console.error(`\u274C Error: Missing value for --target flag.
27
- `),process.exitCode=1;return}r.target=e[++n]}else if(s.startsWith("--target=")){let p=s.split("=")[1];if(!p){console.error(`\u274C Error: Missing value for --target flag.
28
- `),process.exitCode=1;return}r.target=p}else if(s==="--help"||s==="-h"){pe();return}else if(s.startsWith("-")){console.error(`\u274C Error: Unknown option "${s}". Use --help for usage.
29
- `),process.exitCode=1;return}else if(!r.target)r.target=s;else{console.error(`\u274C Error: Unexpected argument "${s}". Use --help for usage.
30
- `),process.exitCode=1;return}}if(t){if(r.target||r.remove||r.backup||r.dryRun){console.error("--print-config supports only --bun; omit target and file-operation flags."),process.exitCode=1;return}console.log(JSON.stringify({mcpServers:{superpowers:{command:r.bun?"bunx":"npx",args:["-y","superpowers-mcp"]}}},null,2));return}if(console.log(`
25
+ ${a}`}let j=c[0],b=p(j),P=b;for(let a=j+1;a<b;a++)if(G(s[a])){P=a;break}let m=null,w=null,S={};for(let a=j+1;a<P;a++){let[o,u]=F(s[a]),f=ye(o);if(f){if(Se(f.value))throw new Error(`Cannot safely update TOML: ${f.key} under [mcp_servers.superpowers] spans multiple lines. Put it on a single line and re-run.`);f.key==="command"?m===null&&(m=h(f.value)):w===null&&(w=h(f.value)),f.key in S||(S[f.key]=u)}}if(m===h(JSON.stringify(t))&&w===h(JSON.stringify(n)))return e;let y=[`${v}${S.command??""}`,`${d}${S.args??""}`],C=s.slice(0,j+1),k=!1;for(let a=j+1;a<P;a++){let[o]=F(s[a]);if(we.test(o)){k||(C.push(...y),k=!0);continue}C.push(s[a])}return k||C.push(...y),C.push(...s.slice(P,b)),C.push(...s.slice(b)),C.join(`
26
+ `)}function B(e,t,n){if(!I(e))return t;let r={...e,...t};return(e.enabled!==void 0||e.disabled!==void 0)&&(e.enabled!==void 0?r.enabled=e.enabled:delete r.enabled),n==="json-mcp"&&Array.isArray(r.command)&&delete r.args,r}function ne(e,t,n,r,s=!1,c,g){let p={},v=!1;e.charCodeAt(0)===65279&&(e=e.slice(1));let d=null;if(e&&e.trim()!==""){try{let m=JSON.parse(e);if(!I(m))throw new Error("Existing JSON root must be an object");p=m}catch(m){try{let w=X(e,!0),S=JSON.parse(w);if(!I(S))throw new Error("Existing JSON root must be an object");p=S,v=w!==e}catch(w){let S=w instanceof Error?w.message:String(w),y=m instanceof Error?m.message:String(m);throw new Error(`Failed to parse existing JSON: ${S} (raw JSON error: ${y})`)}}d=JSON.stringify(p)}let h=t==="json-servers"?"servers":t==="json-mcp"?"mcp":"mcpServers";if(g&&g.length>0){let m=g.join(".");for(let y of g){if(typeof y!="string"||y.length===0)throw new Error(`Invalid JSON field "${m}"`);if(y==="__proto__"||y==="constructor"||y==="prototype")throw new Error(`Refusing to use unsafe JSON field "${m}"`);if(!/^[A-Za-z0-9_-]+$/.test(y))throw new Error(`Invalid JSON field "${m}"`)}let w=p;for(let y of g){if(y==="__proto__"||y==="constructor"||y==="prototype")throw new Error(`Refusing to use unsafe JSON field "${m}"`);let C=w[y];if(C===void 0){if(s)return e;w[y]={}}else if(!I(C))throw new Error(`Existing JSON field "${m}" must be an object`);w=w[y]}if(s){let y=w.superpowers!==void 0;if(delete w.superpowers,!y)return e}else{let y=c?{...c}:{command:n,args:r};w.superpowers=B(w.superpowers,y,t)}let S=JSON.stringify(p,null,2)+`
27
+ `;return d!==null&&JSON.stringify(p)===d?e:(v&&S!==e&&process.stderr.write(`[superpowers-mcp] Warning: JSONC comments/trailing commas in the existing config were removed while updating it (the file is rewritten as plain JSON).
28
+ `),S)}let j=Z.find(m=>I(p[m])&&p[m].superpowers!==void 0)??h;if(p[j]!==void 0&&!I(p[j]))throw new Error(`Existing JSON field "${j}" must be an object`);p[j]===void 0&&(p[j]={});let b=p[j];if(s){let m=b.superpowers!==void 0;if(delete b.superpowers,!m)return e}else{let m;c?m={...c}:t==="json-servers"?m={command:n,args:r,type:"stdio"}:t==="json-mcp"?m={type:"local",command:[n,...r],enabled:!0}:m={command:n,args:r},b.superpowers=B(b.superpowers,m,t)}let P=JSON.stringify(p,null,2)+`
29
+ `;return d!==null&&JSON.stringify(p)===d?e:(v&&P!==e&&process.stderr.write(`[superpowers-mcp] Warning: JSONC comments/trailing commas in the existing config were removed while updating it (the file is rewritten as plain JSON).
30
+ `),P)}function je(e,t=10){try{let n=i.dirname(e),r=`${i.basename(e)}.`,s=".bak",c=l.readdirSync(n).filter(g=>{if(!g.startsWith(r)||!g.endsWith(s))return!1;let p=g.slice(r.length,g.length-s.length);return/^\d+$/.test(p)}).map(g=>{let p=i.join(n,g);try{return{full:p,mtimeMs:l.statSync(p).mtimeMs}}catch{return{full:p,mtimeMs:0}}}).sort((g,p)=>p.mtimeMs-g.mtimeMs);for(let g of c.slice(t))try{l.unlinkSync(g.full)}catch{}}catch{}}function re(e,t,n=!1,r=[],s){if(r.length===0)throw new Error("safeWriteConfig requires at least one allowed destination root");let c=e,g=!1;try{let a=l.lstatSync(e,{throwIfNoEntry:!1});if(a&&a.isSymbolicLink()){g=!0;try{c=l.realpathSync(e)}catch{let R=l.readlinkSync(e);c=i.resolve(i.dirname(e),R)}let o=i.normalize(i.resolve(c)).toLowerCase(),u=i.normalize(i.resolve(T.tmpdir())).toLowerCase();if(!(o===u||o.startsWith(u+i.sep))&&(["/etc","/bin","/sbin","/usr","/root","/sys","/proc","/dev","/private/etc","c:\\windows"].some(A=>o===A||o.startsWith(A+i.sep))||o==="/var"||o.startsWith("/var"+i.sep)&&!o.startsWith("/var/folders"+i.sep)||o==="/private/var"||o.startsWith("/private/var"+i.sep)&&!o.startsWith("/private/var/folders"+i.sep)))throw new Error(`Refusing to write to unsafe symlink target: ${c}`)}}catch(a){if(a instanceof Error&&a.message.includes("Refusing to write to unsafe symlink target"))throw a;if(g){let o=a instanceof Error?a.message:String(a);throw new Error(`Cannot safely resolve symlink target for ${e}: ${o}`)}}let p=i.dirname(c);l.existsSync(p)||l.mkdirSync(p,{recursive:!0,mode:448});let v=l.realpathSync(p),d=l.statSync(v);c=i.join(v,i.basename(c));let h=i.normalize(i.resolve(c)).toLowerCase(),j=i.normalize(i.resolve(T.tmpdir())).toLowerCase(),b=h===j||h.startsWith(j+i.sep),m=["/etc","/bin","/sbin","/usr","/root","/sys","/proc","/dev","/private/etc","c:\\windows"].some(a=>h===a||h.startsWith(a+i.sep))||h==="/var"||h.startsWith("/var"+i.sep)&&!h.startsWith("/var/folders"+i.sep)||h==="/private/var"||h.startsWith("/private/var"+i.sep)&&!h.startsWith("/private/var/folders"+i.sep);if(!b&&m)throw new Error(`Refusing to write to unsafe configuration target: ${c}`);if(!r.some(a=>{if(!a)return!1;let o=i.resolve(a);try{o=l.realpathSync(o)}catch{}let u=i.relative(o,c);return u!==".."&&!u.startsWith(`..${i.sep}`)&&!i.isAbsolute(u)}))throw new Error(`Refusing to write configuration outside allowed roots: ${c}`);let S=384,y=l.existsSync(c);if(y)try{S=l.statSync(c).mode}catch{}let C=Q.randomBytes(8).toString("hex"),k=i.join(v,`.tmp.${i.basename(c)}.${process.pid}.${C}`);try{l.writeFileSync(k,t,{encoding:"utf8",mode:S,flag:"wx"});let a=l.existsSync(c);if(s===null&&a)throw new Error("Configuration changed concurrently before it could be created");if(s!=null&&(!a||l.readFileSync(c,"utf8")!==s))throw new Error("Configuration changed concurrently; refusing to overwrite newer content");let o=l.realpathSync(p),u=l.statSync(o);if(o!==v||u.dev!==d.dev||u.ino!==d.ino)throw new Error("Configuration directory changed while writing");if(n&&y){let f=l.readFileSync(c,"utf8"),E=`${c}.${Date.now()}.bak`;try{l.writeFileSync(E,f,{encoding:"utf8",mode:S})}catch(A){let R=A instanceof Error?A.message:String(A);throw new Error(`Failed to create safe backup before write: ${R}`)}je(c)}l.renameSync(k,c)}catch(a){try{l.existsSync(k)&&l.unlinkSync(k)}catch{}throw a}}async function se(e={}){let t=e.platform||T.platform(),n=e.homeDir||T.homedir(),r=e.appData||process.env.APPDATA,s=e.localAppData||process.env.LOCALAPPDATA,c=!!e.dryRun,g=!!e.remove,p=!!e.bun,v=e.target?e.target.toLowerCase():null,d=p?"bunx":"npx",h=["-y","superpowers-mcp"],j=[];if(!v)throw new Error(`No target client specified. Please specify which client to configure using --target <${Object.keys(W).join("|")}>.`);let b=Object.keys(W).find(m=>m===v||W[m].aliases.includes(v));if(!b)throw new Error(`Unknown harness target: "${v}". Supported targets: ${Object.keys(W).join(", ")}`);let P=[b];for(let m of P){let w=W[m],S=w.getConfigPath(t,n,r,s),y=l.existsSync(S);if(g&&!y){j.push({target:m,name:w.name,path:S,status:"up-to-date",message:"Already not configured (file does not exist)"});continue}try{let C="";y&&(C=l.readFileSync(S,"utf8"));let k="";if(w.type==="yaml")k=ee(C,d,h,g,w.yamlProfile);else if(w.type==="toml")k=te(C,d,h,g);else{let a=typeof w.defaultConfig=="function"?w.defaultConfig(d,h):void 0;k=ne(C,w.type,d,h,g,a,w.serverPath)}if(C.trim()===k.trim()&&y){j.push({target:m,name:w.name,path:S,status:"up-to-date",message:g?"Already not configured":"Already configured and up-to-date"});continue}c||re(S,k,!!e.backup,[n,r||"",s||""],y?C:null),j.push({target:m,name:w.name,path:S,status:g?"removed":y?"updated":"created",message:c?`[Dry Run] Would ${g?"remove from":y?"update":"create"} ${S}`:`Successfully ${g?"removed from":y?"updated":"configured"}!`})}catch(C){let k=C instanceof Error?C.message:String(C);j.push({target:m,name:w.name,path:S,status:"error",message:k})}}return j}async function Ce(e=process.argv.slice(2)){let t=!1,n={dryRun:!1,remove:!1,bun:!1,backup:!1,target:null};for(let r=0;r<e.length;r++){let s=e[r];if(!(s==="setup"||s==="install"||s==="--setup"))if(s==="--print-config")t=!0;else if(s==="--dry-run")n.dryRun=!0;else if(s==="--remove"||s==="--uninstall")n.remove=!0;else if(s==="--bun")n.bun=!0;else if(s==="--backup")n.backup=!0;else if(s==="--target"||s==="-t"){let c=e[r+1];if(!c||c.startsWith("-")){console.error(`\u274C Error: Missing value for --target flag.
31
+ `),process.exitCode=1;return}if(n.target!==null){console.error(`\u274C Error: --target was specified more than once. Configure one client per invocation.
32
+ `),process.exitCode=1;return}n.target=e[++r]}else if(s.startsWith("--target=")){let c=s.split("=")[1];if(!c){console.error(`\u274C Error: Missing value for --target flag.
33
+ `),process.exitCode=1;return}if(n.target!==null){console.error(`\u274C Error: --target was specified more than once. Configure one client per invocation.
34
+ `),process.exitCode=1;return}n.target=c}else if(s==="--help"||s==="-h"){ve();return}else if(s.startsWith("-")){console.error(`\u274C Error: Unknown option "${s}". Use --help for usage.
35
+ `),process.exitCode=1;return}else if(!n.target)n.target=s;else{console.error(`\u274C Error: Unexpected argument "${s}". Use --help for usage.
36
+ `),process.exitCode=1;return}}if(t){if(n.target||n.remove||n.backup||n.dryRun){console.error("--print-config supports only --bun; omit target and file-operation flags."),process.exitCode=1;return}console.log(JSON.stringify({mcpServers:{superpowers:{command:n.bun?"bunx":"npx",args:["-y","superpowers-mcp"]}}},null,2));return}if(console.log(`
31
37
  ========================================================`),console.log("\u26A1 Superpowers MCP - Targeted Client Setup"),console.log(`========================================================
32
- `),!r.target){console.log(`Please select which AI Agent client you would like to configure:
38
+ `),!n.target){console.log(`Please select which AI Agent client you would like to configure:
33
39
  `),console.log(" npx -y superpowers-mcp setup --target lmstudio # LM Studio (~/.lmstudio/mcp.json)"),console.log(" npx -y superpowers-mcp setup --target roo # Roo Code in VS Code Desktop"),console.log(" npx -y superpowers-mcp setup --print-config # JSON for desktop app import"),console.log(" npx -y superpowers-mcp setup --target antigravity # Antigravity (~/.gemini/config/mcp_config.json)"),console.log(" npx -y superpowers-mcp setup --target pi-desktop # Pi Desktop / Pi Agent (~/.pi/agent/mcp.json)"),console.log(" npx -y superpowers-mcp setup --target cursor # Cursor (~/.cursor/mcp.json)"),console.log(" npx -y superpowers-mcp setup --target copilot # GitHub Copilot (VS Code mcp.json)"),console.log(" npx -y superpowers-mcp setup --target copilot-insiders # GitHub Copilot (VS Code Insiders mcp.json)"),console.log(" npx -y superpowers-mcp setup --target hermes # Hermes Desktop / Agent"),console.log(" npx -y superpowers-mcp setup --target kimi # Kimi Work / Kimi Code"),console.log(" npx -y superpowers-mcp setup --target claude # Claude Desktop"),console.log(" npx -y superpowers-mcp setup --target devin # Devin Desktop (formerly Windsurf)"),console.log(" npx -y superpowers-mcp setup --target qwenpaw # QwenPaw / CoPaw (~/.qwenpaw/config.json)"),console.log(" npx -y superpowers-mcp setup --target cline # Cline (~/.../cline_mcp_settings.json)"),console.log(" npx -y superpowers-mcp setup --target kilo # Kilo Code (~/.config/kilo/kilo.jsonc)"),console.log(" npx -y superpowers-mcp setup --target qoder # Qoder (~/.qoder/settings.json)"),console.log(" npx -y superpowers-mcp setup --target kiro # Kiro (~/.kiro/settings/mcp.json)"),console.log(" npx -y superpowers-mcp setup --target trae # Trae (~/.../Trae/User/mcp.json)"),console.log(" npx -y superpowers-mcp setup --target codex # Codex (~/.codex/config.toml)"),console.log(" npx -y superpowers-mcp setup --target openclaw # OpenClaw (~/.openclaw/openclaw.json)"),console.log(` npx -y superpowers-mcp setup --target goose # Goose (~/.config/goose/config.yaml)
34
40
  `),console.log("\u{1F4A1} Tip:"),console.log(" You can run this setup command from ANY folder on your system."),console.log(` It automatically targets your global config files (~/...) without needing to clone this repo.
35
41
  `),console.log("\u{1F4A1} Privacy & Safety:"),console.log(" Superpowers MCP only configures the specific client you explicitly choose."),console.log(` It will NEVER silently scan or modify unselected environments.
36
- `),process.exitCode=1;return}try{let n=await G(r),s=0,p=0,g=0;for(let c of n){let j=c.status==="created"||c.status==="updated"||c.status==="removed"?"\u2705":c.status==="up-to-date"?"\u2728":c.status==="skipped"?"\u23ED\uFE0F ":"\u274C";console.log(`${j} [${c.name}] (${c.status})`),console.log(` Path: ${c.path}`),console.log(` Info: ${c.message}
37
- `),c.status==="created"||c.status==="updated"||c.status==="up-to-date"||c.status==="removed"?s++:c.status==="skipped"?p++:c.status==="error"&&g++}if(console.log("--------------------------------------------------------"),g>0){console.error(`\u26A0\uFE0F Setup finished with errors: ${g} failure(s), ${s} succeeded.`),process.exitCode=1;return}console.log(`\u{1F389} Setup complete! ${s} environment(s) ready.`)}catch(n){let s=n instanceof Error?n.message:String(n);console.error(`\u274C Setup failed: ${s}
38
- `),process.exitCode=1}}function pe(){console.log(`
42
+ `),process.exitCode=1;return}try{let r=await se(n),s=0,c=0,g=0;for(let p of r){let v=p.status==="created"||p.status==="updated"||p.status==="removed"?"\u2705":p.status==="up-to-date"?"\u2728":p.status==="skipped"?"\u23ED\uFE0F ":"\u274C";console.log(`${v} [${p.name}] (${p.status})`),console.log(` Path: ${p.path}`),console.log(` Info: ${p.message}
43
+ `),p.status==="created"||p.status==="updated"||p.status==="up-to-date"||p.status==="removed"?s++:p.status==="skipped"?c++:p.status==="error"&&g++}if(console.log("--------------------------------------------------------"),g>0){console.error(`\u26A0\uFE0F Setup finished with errors: ${g} failure(s), ${s} succeeded.`),process.exitCode=1;return}console.log(`\u{1F389} Setup complete! ${s} environment(s) ready.`)}catch(r){let s=r instanceof Error?r.message:String(r);console.error(`\u274C Setup failed: ${s}
44
+ `),process.exitCode=1}}function ve(){console.log(`
39
45
  Superpowers MCP - Targeted Global Setup
40
46
 
41
47
  Usage:
package/out/setup.js CHANGED
@@ -1,42 +1,48 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var V=Object.create;var R=Object.defineProperty;var Y=Object.getOwnPropertyDescriptor;var B=Object.getOwnPropertyNames;var Q=Object.getPrototypeOf,Z=Object.prototype.hasOwnProperty;var X=(e,t)=>{for(var r in t)R(e,r,{get:t[r],enumerable:!0})},I=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of B(t))!Z.call(e,s)&&s!==r&&R(e,s,{get:()=>t[s],enumerable:!(n=Y(t,s))||n.enumerable});return e};var O=(e,t,r)=>(r=e!=null?V(Q(e)):{},I(t||!e||!e.__esModule?R(r,"default",{value:e,enumerable:!0}):r,e)),ee=e=>I(R({},"__esModule",{value:!0}),e);var ce={};X(ce,{HARNESS_CONFIGS:()=>A,JSON_SERVER_ROOT_KEYS:()=>L,isPlainObject:()=>P,runSetup:()=>G,runSetupCli:()=>T,safeWriteConfig:()=>F,stripJsonComments:()=>U,updateJsonConfig:()=>z,updateTomlConfig:()=>H,updateYamlConfig:()=>q});module.exports=ee(ce);var u=O(require("fs")),o=O(require("path")),_=O(require("os")),K=O(require("crypto")),A={lmstudio:{name:"LM Studio",aliases:["lmstudio","lm-studio"],getConfigPath:(e,t)=>o.join(t,".lmstudio","mcp.json"),type:"json-mcpServers",defaultConfig:(e,t)=>({command:e,args:t})},roo:{name:"Roo Code (VS Code Desktop)",aliases:["roo","roo-code","roocode"],getConfigPath:(e,t,r)=>{let n=e==="win32"?r||o.join(t,"AppData","Roaming"):e==="darwin"?o.join(t,"Library","Application Support"):o.join(t,".config");return o.join(n,"Code","User","globalStorage","rooveterinaryinc.roo-cline","settings","mcp_settings.json")},type:"json-mcpServers",defaultConfig:(e,t)=>({command:e,args:t})},copilot:{name:"GitHub Copilot (VS Code)",aliases:["vscode","code","copilot"],getConfigPath:(e,t,r,n)=>e==="win32"?o.join(r||o.join(t,"AppData","Roaming"),"Code","User","mcp.json"):e==="darwin"?o.join(t,"Library","Application Support","Code","User","mcp.json"):o.join(t,".config","Code","User","mcp.json"),type:"json-servers",defaultConfig:(e,t)=>({command:e,args:t,type:"stdio"})},"copilot-insiders":{name:"GitHub Copilot (VS Code Insiders)",aliases:["vscode-insiders","code-insiders","insiders","insider","vscode-insider","code-insider","copilot-insider"],getConfigPath:(e,t,r,n)=>e==="win32"?o.join(r||o.join(t,"AppData","Roaming"),"Code - Insiders","User","mcp.json"):e==="darwin"?o.join(t,"Library","Application Support","Code - Insiders","User","mcp.json"):o.join(t,".config","Code - Insiders","User","mcp.json"),type:"json-servers",defaultConfig:(e,t)=>({command:e,args:t,type:"stdio"})},cursor:{name:"Cursor",aliases:["cursor"],getConfigPath:(e,t)=>o.join(t,".cursor","mcp.json"),type:"json-mcpServers",defaultConfig:(e,t)=>({command:e,args:t})},hermes:{name:"Hermes Desktop / Agent",aliases:["hermes","hermes-desktop"],getConfigPath:(e,t,r,n)=>{if(e==="win32"){let s=n||o.join(t,"AppData","Local");return o.join(s,"hermes","config.yaml")}return o.join(t,".hermes","config.yaml")},type:"yaml",defaultConfig:(e,t)=>({command:e,args:t})},kimi:{name:"Kimi Work / Kimi Code",aliases:["kimi","kimi-work","kimi-code"],getConfigPath:(e,t)=>o.join(t,".kimi-code","mcp.json"),type:"json-mcpServers",defaultConfig:(e,t)=>({command:e,args:t})},claude:{name:"Claude Desktop",aliases:["claude","claude-desktop"],getConfigPath:(e,t,r)=>e==="win32"?o.join(r||o.join(t,"AppData","Roaming"),"Claude","claude_desktop_config.json"):e==="darwin"?o.join(t,"Library","Application Support","Claude","claude_desktop_config.json"):o.join(t,".config","Claude","claude_desktop_config.json"),type:"json-mcpServers",defaultConfig:(e,t)=>({command:e,args:t})},devin:{name:"Devin Desktop (formerly Windsurf)",aliases:["devin","devin-desktop","windsurf","codeium"],getConfigPath:(e,t,r)=>{let n=e==="win32"&&r?r:o.join(t,".config"),s=o.join(n,"devin","mcp_config.json");return u.existsSync(s)?s:o.join(t,".codeium","windsurf","mcp_config.json")},type:"json-mcpServers",defaultConfig:(e,t)=>({command:e,args:t})},antigravity:{name:"Antigravity (Google DeepMind)",aliases:["antigravity","agy","gemini"],getConfigPath:(e,t)=>o.join(t,".gemini","config","mcp_config.json"),type:"json-mcpServers",defaultConfig:(e,t)=>({command:e,args:t})},"pi-desktop":{name:"Pi Desktop / Pi Agent",aliases:["pi-desktop","pi","pi-agent"],getConfigPath:(e,t,r)=>{if(e==="win32"){let p=o.join(r||o.join(t,"AppData","Roaming"),".pi","agent","mcp.json");if(u.existsSync(p))return p;let g=o.join(t,".pi","agent","mcp.json");if(u.existsSync(g))return g;let c=o.join(t,".pi","mcp.json");return u.existsSync(c)?c:g}let n=o.join(t,".pi","agent","mcp.json");if(u.existsSync(n))return n;let s=o.join(t,".pi","mcp.json");return u.existsSync(s)?s:n},type:"json-mcpServers",defaultConfig:(e,t)=>({command:e,args:t})},qwenpaw:{name:"QwenPaw (Personal Agent Workstation)",aliases:["qwenpaw","qwen-paw","copaw"],getConfigPath:(e,t)=>{let r=o.join(t,".qwenpaw","config.json");if(u.existsSync(r))return r;let n=o.join(t,".copaw","config.json");return u.existsSync(n)?n:r},type:"json-mcpServers",defaultConfig:(e,t)=>({command:e,args:t})},cline:{name:"Cline (VS Code / CLI)",aliases:["cline","claude-dev"],getConfigPath:(e,t,r)=>{let n="";if(e==="win32"?n=o.join(r||o.join(t,"AppData","Roaming"),"Code","User","globalStorage","saoudrizwan.claude-dev","settings","cline_mcp_settings.json"):e==="darwin"?n=o.join(t,"Library","Application Support","Code","User","globalStorage","saoudrizwan.claude-dev","settings","cline_mcp_settings.json"):n=o.join(t,".config","Code","User","globalStorage","saoudrizwan.claude-dev","settings","cline_mcp_settings.json"),u.existsSync(n))return n;let s=o.join(t,".cline","data","settings","cline_mcp_settings.json");return u.existsSync(s)?s:n},type:"json-mcpServers",defaultConfig:(e,t)=>({command:e,args:t})},kilo:{name:"Kilo Code",aliases:["kilo","kilocode","kilo-code"],getConfigPath:(e,t)=>{let r=o.join(t,".config","kilo","kilo.jsonc");if(u.existsSync(r))return r;let n=o.join(t,".config","kilo","kilo.json");return u.existsSync(n)?n:r},type:"json-mcp",defaultConfig:(e,t)=>({type:"local",command:[e,...t],enabled:!0})},qoder:{name:"Qoder",aliases:["qoder"],getConfigPath:(e,t)=>o.join(t,".qoder","settings.json"),type:"json-mcpServers",defaultConfig:(e,t)=>({command:e,args:t})},kiro:{name:"Kiro",aliases:["kiro","kiro-code"],getConfigPath:(e,t)=>o.join(t,".kiro","settings","mcp.json"),type:"json-mcpServers",defaultConfig:(e,t)=>({command:e,args:t})},trae:{name:"Trae",aliases:["trae"],getConfigPath:(e,t,r)=>{if(e==="win32"){let n=o.join(r||o.join(t,"AppData","Roaming"),"Trae","User","mcp.json");if(u.existsSync(n))return n;let s=o.join(r||o.join(t,"AppData","Roaming"),"Trae CN","User","mcp.json");return u.existsSync(s)?s:n}else if(e==="darwin"){let n=o.join(t,"Library","Application Support","Trae","User","mcp.json");if(u.existsSync(n))return n;let s=o.join(t,"Library","Application Support","Trae CN","User","mcp.json");return u.existsSync(s)?s:n}else{let n=o.join(t,".config","Trae","User","mcp.json");if(u.existsSync(n))return n;let s=o.join(t,".config","Trae CN","User","mcp.json");return u.existsSync(s)?s:n}},type:"json-mcpServers",defaultConfig:(e,t)=>({command:e,args:t})},codex:{name:"Codex",aliases:["codex"],getConfigPath:(e,t)=>o.join(t,".codex","config.toml"),type:"toml",defaultConfig:(e,t)=>({command:e,args:t})},openclaw:{name:"OpenClaw",aliases:["openclaw","open-claw"],getConfigPath:(e,t)=>o.join(t,".openclaw","openclaw.json"),type:"json-mcpServers",serverPath:["mcp","servers"],defaultConfig:(e,t)=>({command:e,args:t})},goose:{name:"Goose",aliases:["goose"],getConfigPath:(e,t,r)=>e==="win32"?o.join(r||o.join(t,"AppData","Roaming"),"Block","goose","config","config.yaml"):o.join(t,".config","goose","config.yaml"),type:"yaml",yamlProfile:"goose",defaultConfig:(e,t)=>({cmd:e,args:t})}},L=["mcpServers","servers","mcp"];function P(e){return Object.prototype.toString.call(e)==="[object Object]"}function U(e,t=!1){if(!e)return"";if(!t)try{return JSON.parse(e),e}catch{}let r=e.length,n=[],s=!1,p=!1,g=!1,c=!1,j=-1;for(let l=0;l<r;l++){let f=e[l],S=l+1<r?e[l+1]:"";if(g){(f===`
3
- `||f==="\r")&&(g=!1,n.push(f));continue}if(c){f==="*"&&S==="/"&&(c=!1,l++);continue}if(s){n.push(f),p?p=!1:f==="\\"?p=!0:f==='"'&&(s=!1);continue}if(f==='"'){s=!0,p=!1,j=-1,n.push(f);continue}if(f==="/"&&S==="/"){g=!0,l++;continue}if(f==="/"&&S==="*"){c=!0,l++;continue}if(f===","){j=n.length,n.push(f);continue}if(f==="}"||f==="]"){j!==-1&&(n[j]=" ",j=-1),n.push(f);continue}f!==" "&&f!==" "&&f!==`
4
- `&&f!=="\r"&&(j=-1),n.push(f)}return n.join("")}var W=/\s/;function te(e){for(let t=1;t<e.length;t++){if(e[t]!=="#"||!W.test(e[t-1]))continue;let r=t-1;for(;r>0&&W.test(e[r-1]);)r--;return e.slice(r)}return""}function q(e,t,r,n=!1,s="mcp"){let p=s==="goose"?{rootKey:"extensions",ownedKeys:["cmd","args","type"],freshEntry:(i,d,a)=>[`${i}superpowers:`,`${i}${i}name: "Superpowers"`,`${i}${i}cmd: ${JSON.stringify(d)}`,`${i}${i}args: ${JSON.stringify(a)}`,`${i}${i}enabled: true`,`${i}${i}type: stdio`,`${i}${i}timeout: 300`]}:{rootKey:"mcp_servers",ownedKeys:["command","args"],freshEntry:(i,d,a)=>[`${i}superpowers:`,`${i}${i}command: ${JSON.stringify(d)}`,`${i}${i}args: ${JSON.stringify(a)}`]};if(!/^[A-Za-z0-9_-]+$/.test(p.rootKey))throw new Error("Invalid YAML root key");let g=new RegExp(`^(\\s*)${p.rootKey}\\s*:`),c=new RegExp(`^(\\s*)${p.rootKey}\\s*:\\s*(?:#.*)?$`),j=new RegExp(`^\\s*["']?(?:${p.ownedKeys.join("|")})["']?\\s*:`),l=e?e.split(/\r?\n/):[],f=l.map((i,d)=>{let a=i.match(g);return a?{index:d,indent:a[1],tail:i.slice(a[0].length).trim()}:null}).filter(i=>i!==null),S=f.filter(i=>i.indent==="");if(S.length>1)throw new Error(`Cannot safely update YAML with duplicate ${p.rootKey} keys`);if(S.length===1){let i=S[0];if(i.tail!==""&&!i.tail.startsWith("#"))throw new Error(`Cannot safely update YAML unless ${p.rootKey} is a root-level block mapping`)}else if(f.length>0)throw new Error(`Cannot safely update YAML unless ${p.rootKey} is a root-level block mapping`);let k=" ";if(S.length===1)for(let i=S[0].index+1;i<l.length;i++){if(l[i].trim()===""||l[i].trimStart().startsWith("#"))continue;if(/^[^\s]/.test(l[i]))break;let d=l[i].match(/^(\s+)\S/);d&&(k=d[1]);break}if(n){let i=[],d=!1,a=0,m=!1,C=0;for(let x=0;x<l.length;x++){let v=l[x],b=v.match(c);if(b){d=!0,a=b[1].length,i.push(v);continue}if(d){let $=v.match(/^(\s*)/)?.[1].length||0;if(v.trimStart().startsWith("#")){i.push(v);continue}if(v.trim()!==""&&$<=a)d=!1,m=!1;else{let N=v.match(/^(\s*)superpowers:\s*(?:#.*)?$/);if(N&&N[1]===k){m=!0,C=N[1].length;continue}if(m){if($>C||v.trim()==="")continue;m=!1}}}i.push(v)}return i.join(`
5
- `)}let y=p.freshEntry(k,t,r);if(!e||e.trim()==="")return`${p.rootKey}:
2
+ "use strict";var ie=Object.create;var L=Object.defineProperty;var ae=Object.getOwnPropertyDescriptor;var ce=Object.getOwnPropertyNames;var pe=Object.getPrototypeOf,le=Object.prototype.hasOwnProperty;var ue=(e,t)=>{for(var n in t)L(e,n,{get:t[n],enumerable:!0})},z=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of ce(t))!le.call(e,s)&&s!==n&&L(e,s,{get:()=>t[s],enumerable:!(r=ae(t,s))||r.enumerable});return e};var D=(e,t,n)=>(n=e!=null?ie(pe(e)):{},z(t||!e||!e.__esModule?L(n,"default",{value:e,enumerable:!0}):n,e)),fe=e=>z(L({},"__esModule",{value:!0}),e);var ke={};ue(ke,{HARNESS_CONFIGS:()=>W,JSON_SERVER_ROOT_KEYS:()=>X,isPlainObject:()=>I,runSetup:()=>oe,runSetupCli:()=>V,safeWriteConfig:()=>se,stripJsonComments:()=>ee,updateJsonConfig:()=>re,updateTomlConfig:()=>ne,updateYamlConfig:()=>te});module.exports=fe(ke);var l=D(require("fs")),i=D(require("path")),T=D(require("os")),Z=D(require("crypto")),W={lmstudio:{name:"LM Studio",aliases:["lmstudio","lm-studio"],getConfigPath:(e,t)=>i.join(t,".lmstudio","mcp.json"),type:"json-mcpServers",defaultConfig:(e,t)=>({command:e,args:t})},roo:{name:"Roo Code (VS Code Desktop)",aliases:["roo","roo-code","roocode"],getConfigPath:(e,t,n)=>{let r=e==="win32"?n||i.join(t,"AppData","Roaming"):e==="darwin"?i.join(t,"Library","Application Support"):i.join(t,".config");return i.join(r,"Code","User","globalStorage","rooveterinaryinc.roo-cline","settings","mcp_settings.json")},type:"json-mcpServers",defaultConfig:(e,t)=>({command:e,args:t})},copilot:{name:"GitHub Copilot (VS Code)",aliases:["vscode","code","copilot"],getConfigPath:(e,t,n,r)=>e==="win32"?i.join(n||i.join(t,"AppData","Roaming"),"Code","User","mcp.json"):e==="darwin"?i.join(t,"Library","Application Support","Code","User","mcp.json"):i.join(t,".config","Code","User","mcp.json"),type:"json-servers",defaultConfig:(e,t)=>({command:e,args:t,type:"stdio"})},"copilot-insiders":{name:"GitHub Copilot (VS Code Insiders)",aliases:["vscode-insiders","code-insiders","insiders","insider","vscode-insider","code-insider","copilot-insider"],getConfigPath:(e,t,n,r)=>e==="win32"?i.join(n||i.join(t,"AppData","Roaming"),"Code - Insiders","User","mcp.json"):e==="darwin"?i.join(t,"Library","Application Support","Code - Insiders","User","mcp.json"):i.join(t,".config","Code - Insiders","User","mcp.json"),type:"json-servers",defaultConfig:(e,t)=>({command:e,args:t,type:"stdio"})},cursor:{name:"Cursor",aliases:["cursor"],getConfigPath:(e,t)=>i.join(t,".cursor","mcp.json"),type:"json-mcpServers",defaultConfig:(e,t)=>({command:e,args:t})},hermes:{name:"Hermes Desktop / Agent",aliases:["hermes","hermes-desktop"],getConfigPath:(e,t,n,r)=>{if(e==="win32"){let s=r||i.join(t,"AppData","Local");return i.join(s,"hermes","config.yaml")}return i.join(t,".hermes","config.yaml")},type:"yaml",defaultConfig:(e,t)=>({command:e,args:t})},kimi:{name:"Kimi Work / Kimi Code",aliases:["kimi","kimi-work","kimi-code"],getConfigPath:(e,t)=>i.join(t,".kimi-code","mcp.json"),type:"json-mcpServers",defaultConfig:(e,t)=>({command:e,args:t})},claude:{name:"Claude Desktop",aliases:["claude","claude-desktop"],getConfigPath:(e,t,n)=>e==="win32"?i.join(n||i.join(t,"AppData","Roaming"),"Claude","claude_desktop_config.json"):e==="darwin"?i.join(t,"Library","Application Support","Claude","claude_desktop_config.json"):i.join(t,".config","Claude","claude_desktop_config.json"),type:"json-mcpServers",defaultConfig:(e,t)=>({command:e,args:t})},devin:{name:"Devin Desktop (formerly Windsurf)",aliases:["devin","devin-desktop","windsurf","codeium"],getConfigPath:(e,t,n)=>{let r=e==="win32"&&n?n:i.join(t,".config"),s=i.join(r,"devin","mcp_config.json");return l.existsSync(s)?s:i.join(t,".codeium","windsurf","mcp_config.json")},type:"json-mcpServers",defaultConfig:(e,t)=>({command:e,args:t})},antigravity:{name:"Antigravity (Google DeepMind)",aliases:["antigravity","agy","gemini"],getConfigPath:(e,t)=>i.join(t,".gemini","config","mcp_config.json"),type:"json-mcpServers",defaultConfig:(e,t)=>({command:e,args:t})},"pi-desktop":{name:"Pi Desktop / Pi Agent",aliases:["pi-desktop","pi","pi-agent"],getConfigPath:(e,t,n)=>{if(e==="win32"){let c=i.join(n||i.join(t,"AppData","Roaming"),".pi","agent","mcp.json");if(l.existsSync(c))return c;let g=i.join(t,".pi","agent","mcp.json");if(l.existsSync(g))return g;let p=i.join(t,".pi","mcp.json");return l.existsSync(p)?p:g}let r=i.join(t,".pi","agent","mcp.json");if(l.existsSync(r))return r;let s=i.join(t,".pi","mcp.json");return l.existsSync(s)?s:r},type:"json-mcpServers",defaultConfig:(e,t)=>({command:e,args:t})},qwenpaw:{name:"QwenPaw (Personal Agent Workstation)",aliases:["qwenpaw","qwen-paw","copaw"],getConfigPath:(e,t)=>{let n=i.join(t,".qwenpaw","config.json");if(l.existsSync(n))return n;let r=i.join(t,".copaw","config.json");return l.existsSync(r)?r:n},type:"json-mcpServers",defaultConfig:(e,t)=>({command:e,args:t})},cline:{name:"Cline (VS Code / CLI)",aliases:["cline","claude-dev"],getConfigPath:(e,t,n)=>{let r="";if(e==="win32"?r=i.join(n||i.join(t,"AppData","Roaming"),"Code","User","globalStorage","saoudrizwan.claude-dev","settings","cline_mcp_settings.json"):e==="darwin"?r=i.join(t,"Library","Application Support","Code","User","globalStorage","saoudrizwan.claude-dev","settings","cline_mcp_settings.json"):r=i.join(t,".config","Code","User","globalStorage","saoudrizwan.claude-dev","settings","cline_mcp_settings.json"),l.existsSync(r))return r;let s=i.join(t,".cline","data","settings","cline_mcp_settings.json");return l.existsSync(s)?s:r},type:"json-mcpServers",defaultConfig:(e,t)=>({command:e,args:t})},kilo:{name:"Kilo Code",aliases:["kilo","kilocode","kilo-code"],getConfigPath:(e,t)=>{let n=i.join(t,".config","kilo","kilo.jsonc");if(l.existsSync(n))return n;let r=i.join(t,".config","kilo","kilo.json");return l.existsSync(r)?r:n},type:"json-mcp",defaultConfig:(e,t)=>({type:"local",command:[e,...t],enabled:!0})},qoder:{name:"Qoder",aliases:["qoder"],getConfigPath:(e,t)=>i.join(t,".qoder","settings.json"),type:"json-mcpServers",defaultConfig:(e,t)=>({command:e,args:t})},kiro:{name:"Kiro",aliases:["kiro","kiro-code"],getConfigPath:(e,t)=>i.join(t,".kiro","settings","mcp.json"),type:"json-mcpServers",defaultConfig:(e,t)=>({command:e,args:t})},trae:{name:"Trae",aliases:["trae"],getConfigPath:(e,t,n)=>{if(e==="win32"){let r=i.join(n||i.join(t,"AppData","Roaming"),"Trae","User","mcp.json");if(l.existsSync(r))return r;let s=i.join(n||i.join(t,"AppData","Roaming"),"Trae CN","User","mcp.json");return l.existsSync(s)?s:r}else if(e==="darwin"){let r=i.join(t,"Library","Application Support","Trae","User","mcp.json");if(l.existsSync(r))return r;let s=i.join(t,"Library","Application Support","Trae CN","User","mcp.json");return l.existsSync(s)?s:r}else{let r=i.join(t,".config","Trae","User","mcp.json");if(l.existsSync(r))return r;let s=i.join(t,".config","Trae CN","User","mcp.json");return l.existsSync(s)?s:r}},type:"json-mcpServers",defaultConfig:(e,t)=>({command:e,args:t})},codex:{name:"Codex",aliases:["codex"],getConfigPath:(e,t)=>i.join(t,".codex","config.toml"),type:"toml",defaultConfig:(e,t)=>({command:e,args:t})},openclaw:{name:"OpenClaw",aliases:["openclaw","open-claw"],getConfigPath:(e,t)=>i.join(t,".openclaw","openclaw.json"),type:"json-mcpServers",serverPath:["mcp","servers"],defaultConfig:(e,t)=>({command:e,args:t})},goose:{name:"Goose",aliases:["goose"],getConfigPath:(e,t,n)=>e==="win32"?i.join(n||i.join(t,"AppData","Roaming"),"Block","goose","config","config.yaml"):i.join(t,".config","goose","config.yaml"),type:"yaml",yamlProfile:"goose",defaultConfig:(e,t)=>({cmd:e,args:t})}},X=["mcpServers","servers","mcp"];function I(e){return Object.prototype.toString.call(e)==="[object Object]"}function ee(e,t=!1){if(!e)return"";if(!t)try{return JSON.parse(e),e}catch{}let n=e.length,r=[],s=!1,c=!1,g=!1,p=!1,v=-1;for(let d=0;d<n;d++){let h=e[d],j=d+1<n?e[d+1]:"";if(g){(h===`
3
+ `||h==="\r")&&(g=!1,r.push(h));continue}if(p){h==="*"&&j==="/"&&(p=!1,d++);continue}if(s){r.push(h),c?c=!1:h==="\\"?c=!0:h==='"'&&(s=!1);continue}if(h==='"'){s=!0,c=!1,v=-1,r.push(h);continue}if(h==="/"&&j==="/"){g=!0,d++;continue}if(h==="/"&&j==="*"){p=!0,d++;continue}if(h===","){v=r.length,r.push(h);continue}if(h==="}"||h==="]"){v!==-1&&(r[v]=" ",v=-1),r.push(h);continue}h!==" "&&h!==" "&&h!==`
4
+ `&&h!=="\r"&&(v=-1),r.push(h)}return r.join("")}var H=/\s/;function K(e){for(let t=1;t<e.length;t++){if(e[t]!=="#"||!H.test(e[t-1]))continue;let n=t-1;for(;n>0&&H.test(e[n-1]);)n--;return e.slice(n)}return""}var F=/\s+/y;function U(e,t){F.lastIndex=t;let n=F.exec(e);return n===null?t:t+n[0].length}var ge=/[\n\r\u2028\u2029]/;function Y(e){let t=U(e,0),n=t;if((e[n]==='"'||e[n]==="'")&&n++,!e.startsWith("superpowers",n)||(n+=11,(e[n]==='"'||e[n]==="'")&&n++,n=U(e,n),e[n]!==":"))return null;if(n=U(e,n+1),e[n]==="{"){let r=n+1;for(;e[r]===" "||e[r]===" ";)r++;if(e[r]!=="}")return null;n=U(e,r+1)}return n!==e.length&&(e[n]!=="#"||ge.test(e.slice(n+1)))?null:e.slice(0,t)}function te(e,t,n,r=!1,s="mcp"){let c=s==="goose"?{rootKey:"extensions",ownedKeys:["cmd","args","type"],freshEntry:(o,u,f)=>[`${o}superpowers:`,`${o}${o}cmd: ${JSON.stringify(u)}`,`${o}${o}args: ${JSON.stringify(f)}`,`${o}${o}type: stdio`,`${o}${o}name: "Superpowers"`,`${o}${o}enabled: true`,`${o}${o}timeout: 300`]}:{rootKey:"mcp_servers",ownedKeys:["command","args"],freshEntry:(o,u,f)=>[`${o}superpowers:`,`${o}${o}command: ${JSON.stringify(u)}`,`${o}${o}args: ${JSON.stringify(f)}`]};if(!/^[A-Za-z0-9_-]+$/.test(c.rootKey))throw new Error("Invalid YAML root key");let g=new RegExp(`^(\\s*)["']?${c.rootKey}["']?\\s*:`),p=new RegExp(`^(\\s*)["']?${c.rootKey}["']?\\s*:\\s*(?:#.*)?$`),v=new RegExp(`^\\s*["']?(?:${c.ownedKeys.join("|")})["']?\\s*:`),d=e?e.split(/\r?\n/):[],h=e.includes(`\r
5
+ `)?`\r
6
+ `:`
7
+ `,j=(o,u)=>{let f=o.length,E=0;for(;f>0&&o[f-1]===`
8
+ `&&(u<0||E<u);)f--,f>0&&o[f-1]==="\r"&&f--,E++;return o.slice(0,f)},b=o=>{let u=e.endsWith(`
9
+ `),f=o.split(`
10
+ `).join(h);return u?j(f,1)+h:j(f,-1)},P=d.map((o,u)=>{let f=o.match(g);return f?{index:u,indent:f[1],tail:o.slice(f[0].length).trim()}:null}).filter(o=>o!==null),m=P.filter(o=>o.indent==="");if(m.length>1)throw new Error(`Cannot safely update YAML with duplicate ${c.rootKey} keys`);let w=o=>(K(` ${o}`)?o.slice(0,o.length-K(` ${o}`).length):o).trim();if(m.length===1){let o=m[0],u=w(o.tail),f=u==="{}"||u==="{ }";if(o.tail!==""&&!o.tail.startsWith("#")&&!f)throw new Error(`Cannot safely update YAML unless ${c.rootKey} is a root-level block mapping`)}else if(P.length>0)throw new Error(`Cannot safely update YAML unless ${c.rootKey} is a root-level block mapping`);let S=" ";if(m.length===1)for(let o=m[0].index+1;o<d.length;o++){if(d[o].trim()===""||d[o].trimStart().startsWith("#"))continue;if(/^[^\s]/.test(d[o]))break;let u=d[o].match(/^(\s+)\S/);u&&(S=u[1]);break}if(r){let o=[],u=!1,f=0,E=!1,A=0,R=!1,$=-1;for(let _=0;_<d.length;_++){let x=d[_],M=x.match(p);if(M){u=!0,f=M[1].length,f===0&&($=o.length),o.push(x);continue}if(u){let J=x.match(/^(\s*)/)?.[1].length||0;if(x.trimStart().startsWith("#")){o.push(x);continue}if(x.trim()!==""&&J<=f)u=!1,E=!1;else{let N=Y(x);if(N!==null&&N===S){E=!0,A=N.length,R=!0;continue}if(E){if(J>A||x.trim()==="")continue;E=!1}}}o.push(x)}if(R&&$>=0&&$<o.length){let _=o[$],x=_.match(p);if(x){let M=x[1].length,J=!1;for(let N=$+1;N<o.length;N++){let q=o[N];if(q.trim()===""||q.trimStart().startsWith("#"))continue;if((q.match(/^(\s*)/)?.[1].length??0)<=M)break;J=!0;break}J||(o[$]=_.replace(p,`${x[1]}${c.rootKey}: {}`)+K(_))}}return b(o.join(`
11
+ `))}let y=c.freshEntry(S,t,n);if(!e||e.trim()==="")return b(`${c.rootKey}:
6
12
  ${y.join(`
7
- `)}
8
- `;let w=S.length===1?S[0].index:-1;if(w===-1)return`${e.trimEnd()}
13
+ `)}`);let C=m.length===1?m[0].index:-1;if(C===-1)return b(`${e.trimEnd()}
9
14
 
10
- ${p.rootKey}:
15
+ ${c.rootKey}:
11
16
  ${y.join(`
12
- `)}
13
- `;let h=-1;for(let i=w+1;i<l.length;i++){let d=l[i];if(/^[^\s#]/.test(d))break;if((d.match(/^(\s*)/)?.[1]||"")===k&&/^\s+["']?superpowers["']?\s*:\s*(?:#.*)?$/.test(d)){h=i;break}}if(h!==-1){let i=l[h].match(/^(\s*)/)?.[1].length||2,d=h+1;for(;d<l.length;){let v=l[d];if((v.match(/^(\s*)/)?.[1].length||0)>i||v.trim()==="")d++;else break}let a=[],m=-1,C=i+k.length;for(let v=h+1;v<d;v++){let b=l[v];if(b.trim()==="")continue;let $=b.match(/^(\s*)/)?.[1].length??0;if(!(m!==-1&&$>m)){if(m=-1,$===C&&j.test(b)){m=$;continue}a.push(b)}}y[0]+=te(l[h]);let x=y.filter((v,b)=>{if(b===0)return!0;let $=v.match(/^\s*["']?([A-Za-z0-9_-]+)["']?\s*:/);return!$||p.ownedKeys.includes($[1])});return l.splice(h,d-h,...x,...a),l.join(`
14
- `)}else return l.splice(w+1,0,...y),l.join(`
15
- `)}function J(e){let t=null;for(let r=0;r<e.length;r++){let n=e[r];if(t){if(t==='"'&&n==="\\"&&r+1<e.length){r++;continue}n===t&&(t=null);continue}if(n==='"'||n==="'"){t=n;continue}if(n==="#"){let s=r;for(;s>0&&W.test(e[s-1]);)s--;return[e.slice(0,s),e.slice(s)]}}return[e,""]}var ne=/^\s*\[\s*mcp_servers\s*\.\s*superpowers\s*\]\s*(?:#.*)?$/;function E(e){return e===" "||e===" "||e===`
16
- `||e==="\r"||e==="\f"||e==="\v"}function D(e){let t=0;for(;t<e.length&&E(e[t]);)t++;if(t>=e.length||e[t]!=="[")return!1;let r=e.lastIndexOf("]");if(r<=t)return!1;let n=r+1;for(;n<e.length&&E(e[n]);)n++;return n>=e.length?!0:e[n]==="#"}var se=/^\s*\[\s*mcp_servers\s*\.\s*superpowers\s*\./;function re(e){let t=0;for(;t<e.length&&E(e[t]);)t++;if(t>=e.length||e[t]!=="[")return!1;let r=e.lastIndexOf("]");if(r<=t)return!1;let n=r+1;for(;n<e.length&&E(e[n]);)n++;if(n<e.length&&e[n]!=="#")return!1;let s=e.slice(t+1,r);return!s.includes("mcp_servers")||!s.includes("superpowers")?!1:s.includes('"')||s.includes("'")}function oe(e){let t=0;for(;t<e.length&&E(e[t]);)t++;let r=null;if(e.startsWith("command",t))r="command",t+=7;else if(e.startsWith("args",t))r="args",t+=4;else return null;for(;t<e.length&&E(e[t]);)t++;if(t>=e.length||e[t]!=="=")return null;for(t++;t<e.length&&E(e[t]);)t++;let n=e.length;for(;n>t&&E(e[n-1]);)n--;return{key:r,value:e.slice(t,n)}}var ie=/^\s*(command|args)\s*=/;function H(e,t,r,n=!1){let s=e?e.split(/\r?\n/):[];for(let a of s)if(/^\s*mcp_servers(?:\s*\.\s*[A-Za-z0-9_-]+)*\s*=/.test(a))throw new Error("Cannot safely update TOML with inline mcp_servers assignment (expected [mcp_servers.superpowers] table)");let p=[];for(let a=0;a<s.length;a++){if(re(s[a]))throw new Error("Cannot safely update TOML with quoted mcp_servers.superpowers table names");ne.test(s[a])&&p.push(a)}if(p.length>1)throw new Error("Cannot safely update TOML with duplicate mcp_servers.superpowers tables");let g=`command = ${JSON.stringify(t)}`,c=`args = ${JSON.stringify(r)}`,j=a=>a.replace(/'/g,'"').replace(/\s+/g,"");if(p.length===0){if(n)return e;let a=`[mcp_servers.superpowers]
17
- ${g}
18
- ${c}
17
+ `)}`);let k=m.length===1?w(m[0].tail):"";if(k==="{}"||k==="{ }"){let o=d[C],u=o.match(g)?.[0].length??0,f=o.slice(u);d[C]=(o.slice(0,u)+f.slice(f.indexOf(k)+k.length)).trimEnd()}let a=-1;for(let o=C+1;o<d.length;o++){let u=d[o];if(/^[^\s#]/.test(u))break;if((u.match(/^(\s*)/)?.[1]||"")===S&&Y(u)!==null){a=o;break}}if(a!==-1){let o=d[a].match(/^(\s*)/)?.[1].length||2,u=a+1;for(;u<d.length;){let $=d[u];if(($.match(/^(\s*)/)?.[1].length||0)>o||$.trim()==="")u++;else break}let f=[],E=-1,A=o+S.length;for(let $=a+1;$<u;$++){let _=d[$];if(_.trim()==="")continue;let x=_.match(/^(\s*)/)?.[1].length??0;if(!(E!==-1&&x>E)){if(E=-1,x===A&&v.test(_)){E=x;continue}f.push(_)}}y[0]+=K(d[a]);let R=y.filter(($,_)=>{if(_===0)return!0;let x=$.match(/^\s*["']?([A-Za-z0-9_-]+)["']?\s*:/);return!x||c.ownedKeys.includes(x[1])});return d.splice(a,u-a,...R,...f),b(d.join(`
18
+ `))}else return d.splice(C+1,0,...y),b(d.join(`
19
+ `))}function G(e){let t=null;for(let n=0;n<e.length;n++){let r=e[n];if(t){if(t==='"'&&r==="\\"&&n+1<e.length){n++;continue}r===t&&(t=null);continue}if(r==='"'||r==="'"){t=r;continue}if(r==="#"){let s=n;for(;s>0&&H.test(e[s-1]);)s--;return[e.slice(0,s),e.slice(s)]}}return[e,""]}var de=/^\s*\[\s*mcp_servers\s*\.\s*superpowers\s*\]\s*(?:#.*)?$/;function O(e){return e===" "||e===" "||e===`
20
+ `||e==="\r"||e==="\f"||e==="\v"}function B(e){let t=0;for(;t<e.length&&O(e[t]);)t++;if(t>=e.length||e[t]!=="[")return!1;let n=e.lastIndexOf("]");if(n<=t)return!1;let r=n+1;for(;r<e.length&&O(e[r]);)r++;return r>=e.length?!0:e[r]==="#"}var me=/^\s*\[\s*mcp_servers\s*\.\s*superpowers\s*\./,he=/^\s*\[\[\s*mcp_servers\s*\.\s*superpowers\s*\]\]/;function ye(e){let t=0;for(;t<e.length&&O(e[t]);)t++;if(t>=e.length||e[t]!=="[")return!1;let n=e.lastIndexOf("]");if(n<=t)return!1;let r=n+1;for(;r<e.length&&O(e[r]);)r++;if(r<e.length&&e[r]!=="#")return!1;let s=e.slice(t+1,n);return!s.includes("mcp_servers")||!s.includes("superpowers")?!1:s.includes('"')||s.includes("'")}function we(e){let t=0;for(;t<e.length&&O(e[t]);)t++;let n=null;if(e.startsWith("command",t))n="command",t+=7;else if(e.startsWith("args",t))n="args",t+=4;else return null;for(;t<e.length&&O(e[t]);)t++;if(t>=e.length||e[t]!=="=")return null;for(t++;t<e.length&&O(e[t]);)t++;let r=e.length;for(;r>t&&O(e[r-1]);)r--;return{key:n,value:e.slice(t,r)}}var Se=/^\s*(command|args)\s*=/;function je(e){let t=0,n=null;for(let r=0;r<e.length;r++){let s=e[r];if(n){if(n==='"'&&s==="\\"&&r+1<e.length){r++;continue}s===n&&(n=null);continue}if(s==='"'||s==="'"){n=s;continue}s==="["||s==="{"?t++:(s==="]"||s==="}")&&t--}return t>0||n!==null}function ne(e,t,n,r=!1){let s=e?e.split(/\r?\n/):[];for(let a of s)if(/^\s*mcp_servers(?:\s*\.\s*[A-Za-z0-9_-]+)*\s*=/.test(a))throw new Error("Cannot safely update TOML with inline mcp_servers assignment (expected [mcp_servers.superpowers] table)");let c=[],g=-1;for(let a=0;a<s.length;a++){if(ye(s[a]))throw new Error("Cannot safely update TOML with quoted mcp_servers.superpowers table names");he.test(s[a])&&(g=a),de.test(s[a])&&c.push(a)}if(c.length>1)throw new Error("Cannot safely update TOML with duplicate mcp_servers.superpowers tables");let p=a=>{let o=a+1;for(;o<s.length&&!(B(s[o])&&!me.test(s[o]));)o++;return o};if(r){let a=[...c,...g===-1?[]:[g]].map(u=>[u,p(u)]).sort((u,f)=>u[0]-f[0]);if(a.length===0)return e;let o=new Set;for(let[u,f]of a)for(let E=u;E<f;E++)o.add(E);return s.filter((u,f)=>!o.has(f)).join(`
21
+ `)}if(g!==-1)throw new Error("Cannot safely update TOML: [[mcp_servers.superpowers]] is an array-of-tables, which cannot coexist with a [mcp_servers.superpowers] table. Remove it first.");let v=`command = ${JSON.stringify(t)}`,d=`args = ${JSON.stringify(n)}`,h=a=>a.replace(/'/g,'"').replace(/\s+/g,"");if(c.length===0){let a=`[mcp_servers.superpowers]
22
+ ${v}
23
+ ${d}
19
24
  `;return!e||e.trim()===""?a:`${e.trimEnd()}
20
25
 
21
- ${a}`}let l=p[0],f=l+1;for(;f<s.length&&!(D(s[f])&&!se.test(s[f]));)f++;let S=f;for(let a=l+1;a<f;a++)if(D(s[a])){S=a;break}if(n)return s.slice(0,l).concat(s.slice(f)).join(`
22
- `);let k=null,y=null,w={};for(let a=l+1;a<S;a++){let[m,C]=J(s[a]),x=oe(m);x&&(x.key==="command"?k===null&&(k=j(x.value)):y===null&&(y=j(x.value)),x.key in w||(w[x.key]=C))}if(k===j(JSON.stringify(t))&&y===j(JSON.stringify(r)))return e;let h=[`${g}${w.command??""}`,`${c}${w.args??""}`],i=s.slice(0,l+1),d=!1;for(let a=l+1;a<S;a++){let[m]=J(s[a]);if(ie.test(m)){d||(i.push(...h),d=!0);continue}i.push(s[a])}return d||i.push(...h),i.push(...s.slice(S,f)),i.push(...s.slice(f)),i.join(`
23
- `)}function M(e,t,r){if(!P(e))return t;let n={...e,...t};return(e.enabled!==void 0||e.disabled!==void 0)&&(e.enabled!==void 0?n.enabled=e.enabled:delete n.enabled),r==="json-mcp"&&Array.isArray(n.command)&&delete n.args,n}function z(e,t,r,n,s=!1,p,g){let c={},j=!1;if(e&&e.trim()!=="")try{let y=JSON.parse(e);if(!P(y))throw new Error("Existing JSON root must be an object");c=y}catch(y){try{let w=U(e,!0),h=JSON.parse(w);if(!P(h))throw new Error("Existing JSON root must be an object");c=h,j=w!==e}catch(w){let h=w instanceof Error?w.message:String(w),i=y instanceof Error?y.message:String(y);throw new Error(`Failed to parse existing JSON: ${h} (raw JSON error: ${i})`)}}let l=t==="json-servers"?"servers":t==="json-mcp"?"mcp":"mcpServers";if(g&&g.length>0){let y=g.join(".");for(let i of g){if(typeof i!="string"||i.length===0)throw new Error(`Invalid JSON field "${y}"`);if(i==="__proto__"||i==="constructor"||i==="prototype")throw new Error(`Refusing to use unsafe JSON field "${y}"`);if(!/^[A-Za-z0-9_-]+$/.test(i))throw new Error(`Invalid JSON field "${y}"`)}let w=c;for(let i of g){if(i==="__proto__"||i==="constructor"||i==="prototype")throw new Error(`Refusing to use unsafe JSON field "${y}"`);let d=w[i];if(d===void 0){if(s)return e;w[i]={}}else if(!P(d))throw new Error(`Existing JSON field "${y}" must be an object`);w=w[i]}if(s)delete w.superpowers;else{let i=p?{...p}:{command:r,args:n};w.superpowers=M(w.superpowers,i,t)}let h=JSON.stringify(c,null,2)+`
24
- `;return j&&h!==e&&process.stderr.write(`[superpowers-mcp] Warning: JSONC comments/trailing commas in the existing config were removed while updating it (the file is rewritten as plain JSON).
25
- `),h}let f=L.find(y=>P(c[y])&&c[y].superpowers!==void 0)??l;if(c[f]!==void 0&&!P(c[f]))throw new Error(`Existing JSON field "${f}" must be an object`);c[f]===void 0&&(c[f]={});let S=c[f];if(s)delete S.superpowers;else{let y;p?y={...p}:t==="json-servers"?y={command:r,args:n,type:"stdio"}:t==="json-mcp"?y={type:"local",command:[r,...n],enabled:!0}:y={command:r,args:n},S.superpowers=M(S.superpowers,y,t)}let k=JSON.stringify(c,null,2)+`
26
- `;return j&&k!==e&&process.stderr.write(`[superpowers-mcp] Warning: JSONC comments/trailing commas in the existing config were removed while updating it (the file is rewritten as plain JSON).
27
- `),k}function ae(e,t=10){try{let r=o.dirname(e),n=`${o.basename(e)}.`,s=".bak",p=u.readdirSync(r).filter(g=>{if(!g.startsWith(n)||!g.endsWith(s))return!1;let c=g.slice(n.length,g.length-s.length);return/^\d+$/.test(c)}).map(g=>{let c=o.join(r,g);try{return{full:c,mtimeMs:u.statSync(c).mtimeMs}}catch{return{full:c,mtimeMs:0}}}).sort((g,c)=>c.mtimeMs-g.mtimeMs);for(let g of p.slice(t))try{u.unlinkSync(g.full)}catch{}}catch{}}function F(e,t,r=!1,n=[],s){if(n.length===0)throw new Error("safeWriteConfig requires at least one allowed destination root");let p=e;try{let a=u.lstatSync(e,{throwIfNoEntry:!1});if(a&&a.isSymbolicLink()){try{p=u.realpathSync(e)}catch{let $=u.readlinkSync(e);p=o.resolve(o.dirname(e),$)}let m=o.normalize(o.resolve(p)).toLowerCase(),C=o.normalize(o.resolve(_.tmpdir())).toLowerCase();if(!(m===C||m.startsWith(C+o.sep))&&(["/etc","/bin","/sbin","/usr","/root","/sys","/proc","/dev","/private/etc","c:\\windows"].some(b=>m===b||m.startsWith(b+o.sep))||m==="/var"||m.startsWith("/var"+o.sep)&&!m.startsWith("/var/folders"+o.sep)||m==="/private/var"||m.startsWith("/private/var"+o.sep)&&!m.startsWith("/private/var/folders"+o.sep)))throw new Error(`Refusing to write to unsafe symlink target: ${p}`)}}catch(a){if(a instanceof Error&&a.message.includes("Refusing to write to unsafe symlink target"))throw a}let g=o.dirname(p);u.existsSync(g)||u.mkdirSync(g,{recursive:!0,mode:448});let c=u.realpathSync(g),j=u.statSync(c);p=o.join(c,o.basename(p));let l=o.normalize(o.resolve(p)).toLowerCase(),f=o.normalize(o.resolve(_.tmpdir())).toLowerCase(),S=l===f||l.startsWith(f+o.sep),y=["/etc","/bin","/sbin","/usr","/root","/sys","/proc","/dev","/private/etc","c:\\windows"].some(a=>l===a||l.startsWith(a+o.sep))||l==="/var"||l.startsWith("/var"+o.sep)&&!l.startsWith("/var/folders"+o.sep)||l==="/private/var"||l.startsWith("/private/var"+o.sep)&&!l.startsWith("/private/var/folders"+o.sep);if(!S&&y)throw new Error(`Refusing to write to unsafe configuration target: ${p}`);if(!n.some(a=>{if(!a)return!1;let m=o.resolve(a);try{m=u.realpathSync(m)}catch{}let C=o.relative(m,p);return C!==".."&&!C.startsWith(`..${o.sep}`)&&!o.isAbsolute(C)}))throw new Error(`Refusing to write configuration outside allowed roots: ${p}`);let h=384;if(u.existsSync(p)){try{h=u.statSync(p).mode}catch{}if(r){let a=u.readFileSync(p,"utf8"),m=`${p}.${Date.now()}.bak`;try{u.writeFileSync(m,a,{encoding:"utf8",mode:h})}catch(C){let x=C instanceof Error?C.message:String(C);throw new Error(`Failed to create safe backup before write: ${x}`)}ae(p)}}let i=K.randomBytes(8).toString("hex"),d=o.join(c,`.tmp.${o.basename(p)}.${process.pid}.${i}`);try{u.writeFileSync(d,t,{encoding:"utf8",mode:h,flag:"wx"});let a=u.existsSync(p);if(s===null&&a)throw new Error("Configuration changed concurrently before it could be created");if(s!=null&&(!a||u.readFileSync(p,"utf8")!==s))throw new Error("Configuration changed concurrently; refusing to overwrite newer content");let m=u.realpathSync(g),C=u.statSync(m);if(m!==c||C.dev!==j.dev||C.ino!==j.ino)throw new Error("Configuration directory changed while writing");u.renameSync(d,p)}catch(a){try{u.existsSync(d)&&u.unlinkSync(d)}catch{}throw a}}async function G(e={}){let t=e.platform||_.platform(),r=e.homeDir||_.homedir(),n=e.appData||process.env.APPDATA,s=e.localAppData||process.env.LOCALAPPDATA,p=!!e.dryRun,g=!!e.remove,c=!!e.bun,j=e.target?e.target.toLowerCase():null,l=c?"bunx":"npx",f=["-y","superpowers-mcp"],S=[];if(!j)throw new Error(`No target client specified. Please specify which client to configure using --target <${Object.keys(A).join("|")}>.`);let k=Object.keys(A).find(w=>w===j||A[w].aliases.includes(j));if(!k)throw new Error(`Unknown harness target: "${j}". Supported targets: ${Object.keys(A).join(", ")}`);let y=[k];for(let w of y){let h=A[w],i=h.getConfigPath(t,r,n,s),d=u.existsSync(i);if(g&&!d){S.push({target:w,name:h.name,path:i,status:"up-to-date",message:"Already not configured (file does not exist)"});continue}try{let a="";d&&(a=u.readFileSync(i,"utf8"));let m="";if(h.type==="yaml")m=q(a,l,f,g,h.yamlProfile);else if(h.type==="toml")m=H(a,l,f,g);else{let C=typeof h.defaultConfig=="function"?h.defaultConfig(l,f):void 0;m=z(a,h.type,l,f,g,C,h.serverPath)}if(a.trim()===m.trim()&&d){S.push({target:w,name:h.name,path:i,status:"up-to-date",message:g?"Already not configured":"Already configured and up-to-date"});continue}p||F(i,m,!!e.backup,[r,n||"",s||""],d?a:null),S.push({target:w,name:h.name,path:i,status:g?"removed":d?"updated":"created",message:p?`[Dry Run] Would ${g?"remove from":d?"update":"create"} ${i}`:`Successfully ${g?"removed from":d?"updated":"configured"}!`})}catch(a){let m=a instanceof Error?a.message:String(a);S.push({target:w,name:h.name,path:i,status:"error",message:m})}}return S}async function T(e=process.argv.slice(2)){let t=!1,r={dryRun:!1,remove:!1,bun:!1,backup:!1,target:null};for(let n=0;n<e.length;n++){let s=e[n];if(!(s==="setup"||s==="install"||s==="--setup"))if(s==="--print-config")t=!0;else if(s==="--dry-run")r.dryRun=!0;else if(s==="--remove"||s==="--uninstall")r.remove=!0;else if(s==="--bun")r.bun=!0;else if(s==="--backup")r.backup=!0;else if(s==="--target"||s==="-t"){let p=e[n+1];if(!p||p.startsWith("-")){console.error(`\u274C Error: Missing value for --target flag.
28
- `),process.exitCode=1;return}r.target=e[++n]}else if(s.startsWith("--target=")){let p=s.split("=")[1];if(!p){console.error(`\u274C Error: Missing value for --target flag.
29
- `),process.exitCode=1;return}r.target=p}else if(s==="--help"||s==="-h"){pe();return}else if(s.startsWith("-")){console.error(`\u274C Error: Unknown option "${s}". Use --help for usage.
30
- `),process.exitCode=1;return}else if(!r.target)r.target=s;else{console.error(`\u274C Error: Unexpected argument "${s}". Use --help for usage.
31
- `),process.exitCode=1;return}}if(t){if(r.target||r.remove||r.backup||r.dryRun){console.error("--print-config supports only --bun; omit target and file-operation flags."),process.exitCode=1;return}console.log(JSON.stringify({mcpServers:{superpowers:{command:r.bun?"bunx":"npx",args:["-y","superpowers-mcp"]}}},null,2));return}if(console.log(`
26
+ ${a}`}let j=c[0],b=p(j),P=b;for(let a=j+1;a<b;a++)if(B(s[a])){P=a;break}let m=null,w=null,S={};for(let a=j+1;a<P;a++){let[o,u]=G(s[a]),f=we(o);if(f){if(je(f.value))throw new Error(`Cannot safely update TOML: ${f.key} under [mcp_servers.superpowers] spans multiple lines. Put it on a single line and re-run.`);f.key==="command"?m===null&&(m=h(f.value)):w===null&&(w=h(f.value)),f.key in S||(S[f.key]=u)}}if(m===h(JSON.stringify(t))&&w===h(JSON.stringify(n)))return e;let y=[`${v}${S.command??""}`,`${d}${S.args??""}`],C=s.slice(0,j+1),k=!1;for(let a=j+1;a<P;a++){let[o]=G(s[a]);if(Se.test(o)){k||(C.push(...y),k=!0);continue}C.push(s[a])}return k||C.push(...y),C.push(...s.slice(P,b)),C.push(...s.slice(b)),C.join(`
27
+ `)}function Q(e,t,n){if(!I(e))return t;let r={...e,...t};return(e.enabled!==void 0||e.disabled!==void 0)&&(e.enabled!==void 0?r.enabled=e.enabled:delete r.enabled),n==="json-mcp"&&Array.isArray(r.command)&&delete r.args,r}function re(e,t,n,r,s=!1,c,g){let p={},v=!1;e.charCodeAt(0)===65279&&(e=e.slice(1));let d=null;if(e&&e.trim()!==""){try{let m=JSON.parse(e);if(!I(m))throw new Error("Existing JSON root must be an object");p=m}catch(m){try{let w=ee(e,!0),S=JSON.parse(w);if(!I(S))throw new Error("Existing JSON root must be an object");p=S,v=w!==e}catch(w){let S=w instanceof Error?w.message:String(w),y=m instanceof Error?m.message:String(m);throw new Error(`Failed to parse existing JSON: ${S} (raw JSON error: ${y})`)}}d=JSON.stringify(p)}let h=t==="json-servers"?"servers":t==="json-mcp"?"mcp":"mcpServers";if(g&&g.length>0){let m=g.join(".");for(let y of g){if(typeof y!="string"||y.length===0)throw new Error(`Invalid JSON field "${m}"`);if(y==="__proto__"||y==="constructor"||y==="prototype")throw new Error(`Refusing to use unsafe JSON field "${m}"`);if(!/^[A-Za-z0-9_-]+$/.test(y))throw new Error(`Invalid JSON field "${m}"`)}let w=p;for(let y of g){if(y==="__proto__"||y==="constructor"||y==="prototype")throw new Error(`Refusing to use unsafe JSON field "${m}"`);let C=w[y];if(C===void 0){if(s)return e;w[y]={}}else if(!I(C))throw new Error(`Existing JSON field "${m}" must be an object`);w=w[y]}if(s){let y=w.superpowers!==void 0;if(delete w.superpowers,!y)return e}else{let y=c?{...c}:{command:n,args:r};w.superpowers=Q(w.superpowers,y,t)}let S=JSON.stringify(p,null,2)+`
28
+ `;return d!==null&&JSON.stringify(p)===d?e:(v&&S!==e&&process.stderr.write(`[superpowers-mcp] Warning: JSONC comments/trailing commas in the existing config were removed while updating it (the file is rewritten as plain JSON).
29
+ `),S)}let j=X.find(m=>I(p[m])&&p[m].superpowers!==void 0)??h;if(p[j]!==void 0&&!I(p[j]))throw new Error(`Existing JSON field "${j}" must be an object`);p[j]===void 0&&(p[j]={});let b=p[j];if(s){let m=b.superpowers!==void 0;if(delete b.superpowers,!m)return e}else{let m;c?m={...c}:t==="json-servers"?m={command:n,args:r,type:"stdio"}:t==="json-mcp"?m={type:"local",command:[n,...r],enabled:!0}:m={command:n,args:r},b.superpowers=Q(b.superpowers,m,t)}let P=JSON.stringify(p,null,2)+`
30
+ `;return d!==null&&JSON.stringify(p)===d?e:(v&&P!==e&&process.stderr.write(`[superpowers-mcp] Warning: JSONC comments/trailing commas in the existing config were removed while updating it (the file is rewritten as plain JSON).
31
+ `),P)}function Ce(e,t=10){try{let n=i.dirname(e),r=`${i.basename(e)}.`,s=".bak",c=l.readdirSync(n).filter(g=>{if(!g.startsWith(r)||!g.endsWith(s))return!1;let p=g.slice(r.length,g.length-s.length);return/^\d+$/.test(p)}).map(g=>{let p=i.join(n,g);try{return{full:p,mtimeMs:l.statSync(p).mtimeMs}}catch{return{full:p,mtimeMs:0}}}).sort((g,p)=>p.mtimeMs-g.mtimeMs);for(let g of c.slice(t))try{l.unlinkSync(g.full)}catch{}}catch{}}function se(e,t,n=!1,r=[],s){if(r.length===0)throw new Error("safeWriteConfig requires at least one allowed destination root");let c=e,g=!1;try{let a=l.lstatSync(e,{throwIfNoEntry:!1});if(a&&a.isSymbolicLink()){g=!0;try{c=l.realpathSync(e)}catch{let R=l.readlinkSync(e);c=i.resolve(i.dirname(e),R)}let o=i.normalize(i.resolve(c)).toLowerCase(),u=i.normalize(i.resolve(T.tmpdir())).toLowerCase();if(!(o===u||o.startsWith(u+i.sep))&&(["/etc","/bin","/sbin","/usr","/root","/sys","/proc","/dev","/private/etc","c:\\windows"].some(A=>o===A||o.startsWith(A+i.sep))||o==="/var"||o.startsWith("/var"+i.sep)&&!o.startsWith("/var/folders"+i.sep)||o==="/private/var"||o.startsWith("/private/var"+i.sep)&&!o.startsWith("/private/var/folders"+i.sep)))throw new Error(`Refusing to write to unsafe symlink target: ${c}`)}}catch(a){if(a instanceof Error&&a.message.includes("Refusing to write to unsafe symlink target"))throw a;if(g){let o=a instanceof Error?a.message:String(a);throw new Error(`Cannot safely resolve symlink target for ${e}: ${o}`)}}let p=i.dirname(c);l.existsSync(p)||l.mkdirSync(p,{recursive:!0,mode:448});let v=l.realpathSync(p),d=l.statSync(v);c=i.join(v,i.basename(c));let h=i.normalize(i.resolve(c)).toLowerCase(),j=i.normalize(i.resolve(T.tmpdir())).toLowerCase(),b=h===j||h.startsWith(j+i.sep),m=["/etc","/bin","/sbin","/usr","/root","/sys","/proc","/dev","/private/etc","c:\\windows"].some(a=>h===a||h.startsWith(a+i.sep))||h==="/var"||h.startsWith("/var"+i.sep)&&!h.startsWith("/var/folders"+i.sep)||h==="/private/var"||h.startsWith("/private/var"+i.sep)&&!h.startsWith("/private/var/folders"+i.sep);if(!b&&m)throw new Error(`Refusing to write to unsafe configuration target: ${c}`);if(!r.some(a=>{if(!a)return!1;let o=i.resolve(a);try{o=l.realpathSync(o)}catch{}let u=i.relative(o,c);return u!==".."&&!u.startsWith(`..${i.sep}`)&&!i.isAbsolute(u)}))throw new Error(`Refusing to write configuration outside allowed roots: ${c}`);let S=384,y=l.existsSync(c);if(y)try{S=l.statSync(c).mode}catch{}let C=Z.randomBytes(8).toString("hex"),k=i.join(v,`.tmp.${i.basename(c)}.${process.pid}.${C}`);try{l.writeFileSync(k,t,{encoding:"utf8",mode:S,flag:"wx"});let a=l.existsSync(c);if(s===null&&a)throw new Error("Configuration changed concurrently before it could be created");if(s!=null&&(!a||l.readFileSync(c,"utf8")!==s))throw new Error("Configuration changed concurrently; refusing to overwrite newer content");let o=l.realpathSync(p),u=l.statSync(o);if(o!==v||u.dev!==d.dev||u.ino!==d.ino)throw new Error("Configuration directory changed while writing");if(n&&y){let f=l.readFileSync(c,"utf8"),E=`${c}.${Date.now()}.bak`;try{l.writeFileSync(E,f,{encoding:"utf8",mode:S})}catch(A){let R=A instanceof Error?A.message:String(A);throw new Error(`Failed to create safe backup before write: ${R}`)}Ce(c)}l.renameSync(k,c)}catch(a){try{l.existsSync(k)&&l.unlinkSync(k)}catch{}throw a}}async function oe(e={}){let t=e.platform||T.platform(),n=e.homeDir||T.homedir(),r=e.appData||process.env.APPDATA,s=e.localAppData||process.env.LOCALAPPDATA,c=!!e.dryRun,g=!!e.remove,p=!!e.bun,v=e.target?e.target.toLowerCase():null,d=p?"bunx":"npx",h=["-y","superpowers-mcp"],j=[];if(!v)throw new Error(`No target client specified. Please specify which client to configure using --target <${Object.keys(W).join("|")}>.`);let b=Object.keys(W).find(m=>m===v||W[m].aliases.includes(v));if(!b)throw new Error(`Unknown harness target: "${v}". Supported targets: ${Object.keys(W).join(", ")}`);let P=[b];for(let m of P){let w=W[m],S=w.getConfigPath(t,n,r,s),y=l.existsSync(S);if(g&&!y){j.push({target:m,name:w.name,path:S,status:"up-to-date",message:"Already not configured (file does not exist)"});continue}try{let C="";y&&(C=l.readFileSync(S,"utf8"));let k="";if(w.type==="yaml")k=te(C,d,h,g,w.yamlProfile);else if(w.type==="toml")k=ne(C,d,h,g);else{let a=typeof w.defaultConfig=="function"?w.defaultConfig(d,h):void 0;k=re(C,w.type,d,h,g,a,w.serverPath)}if(C.trim()===k.trim()&&y){j.push({target:m,name:w.name,path:S,status:"up-to-date",message:g?"Already not configured":"Already configured and up-to-date"});continue}c||se(S,k,!!e.backup,[n,r||"",s||""],y?C:null),j.push({target:m,name:w.name,path:S,status:g?"removed":y?"updated":"created",message:c?`[Dry Run] Would ${g?"remove from":y?"update":"create"} ${S}`:`Successfully ${g?"removed from":y?"updated":"configured"}!`})}catch(C){let k=C instanceof Error?C.message:String(C);j.push({target:m,name:w.name,path:S,status:"error",message:k})}}return j}async function V(e=process.argv.slice(2)){let t=!1,n={dryRun:!1,remove:!1,bun:!1,backup:!1,target:null};for(let r=0;r<e.length;r++){let s=e[r];if(!(s==="setup"||s==="install"||s==="--setup"))if(s==="--print-config")t=!0;else if(s==="--dry-run")n.dryRun=!0;else if(s==="--remove"||s==="--uninstall")n.remove=!0;else if(s==="--bun")n.bun=!0;else if(s==="--backup")n.backup=!0;else if(s==="--target"||s==="-t"){let c=e[r+1];if(!c||c.startsWith("-")){console.error(`\u274C Error: Missing value for --target flag.
32
+ `),process.exitCode=1;return}if(n.target!==null){console.error(`\u274C Error: --target was specified more than once. Configure one client per invocation.
33
+ `),process.exitCode=1;return}n.target=e[++r]}else if(s.startsWith("--target=")){let c=s.split("=")[1];if(!c){console.error(`\u274C Error: Missing value for --target flag.
34
+ `),process.exitCode=1;return}if(n.target!==null){console.error(`\u274C Error: --target was specified more than once. Configure one client per invocation.
35
+ `),process.exitCode=1;return}n.target=c}else if(s==="--help"||s==="-h"){ve();return}else if(s.startsWith("-")){console.error(`\u274C Error: Unknown option "${s}". Use --help for usage.
36
+ `),process.exitCode=1;return}else if(!n.target)n.target=s;else{console.error(`\u274C Error: Unexpected argument "${s}". Use --help for usage.
37
+ `),process.exitCode=1;return}}if(t){if(n.target||n.remove||n.backup||n.dryRun){console.error("--print-config supports only --bun; omit target and file-operation flags."),process.exitCode=1;return}console.log(JSON.stringify({mcpServers:{superpowers:{command:n.bun?"bunx":"npx",args:["-y","superpowers-mcp"]}}},null,2));return}if(console.log(`
32
38
  ========================================================`),console.log("\u26A1 Superpowers MCP - Targeted Client Setup"),console.log(`========================================================
33
- `),!r.target){console.log(`Please select which AI Agent client you would like to configure:
39
+ `),!n.target){console.log(`Please select which AI Agent client you would like to configure:
34
40
  `),console.log(" npx -y superpowers-mcp setup --target lmstudio # LM Studio (~/.lmstudio/mcp.json)"),console.log(" npx -y superpowers-mcp setup --target roo # Roo Code in VS Code Desktop"),console.log(" npx -y superpowers-mcp setup --print-config # JSON for desktop app import"),console.log(" npx -y superpowers-mcp setup --target antigravity # Antigravity (~/.gemini/config/mcp_config.json)"),console.log(" npx -y superpowers-mcp setup --target pi-desktop # Pi Desktop / Pi Agent (~/.pi/agent/mcp.json)"),console.log(" npx -y superpowers-mcp setup --target cursor # Cursor (~/.cursor/mcp.json)"),console.log(" npx -y superpowers-mcp setup --target copilot # GitHub Copilot (VS Code mcp.json)"),console.log(" npx -y superpowers-mcp setup --target copilot-insiders # GitHub Copilot (VS Code Insiders mcp.json)"),console.log(" npx -y superpowers-mcp setup --target hermes # Hermes Desktop / Agent"),console.log(" npx -y superpowers-mcp setup --target kimi # Kimi Work / Kimi Code"),console.log(" npx -y superpowers-mcp setup --target claude # Claude Desktop"),console.log(" npx -y superpowers-mcp setup --target devin # Devin Desktop (formerly Windsurf)"),console.log(" npx -y superpowers-mcp setup --target qwenpaw # QwenPaw / CoPaw (~/.qwenpaw/config.json)"),console.log(" npx -y superpowers-mcp setup --target cline # Cline (~/.../cline_mcp_settings.json)"),console.log(" npx -y superpowers-mcp setup --target kilo # Kilo Code (~/.config/kilo/kilo.jsonc)"),console.log(" npx -y superpowers-mcp setup --target qoder # Qoder (~/.qoder/settings.json)"),console.log(" npx -y superpowers-mcp setup --target kiro # Kiro (~/.kiro/settings/mcp.json)"),console.log(" npx -y superpowers-mcp setup --target trae # Trae (~/.../Trae/User/mcp.json)"),console.log(" npx -y superpowers-mcp setup --target codex # Codex (~/.codex/config.toml)"),console.log(" npx -y superpowers-mcp setup --target openclaw # OpenClaw (~/.openclaw/openclaw.json)"),console.log(` npx -y superpowers-mcp setup --target goose # Goose (~/.config/goose/config.yaml)
35
41
  `),console.log("\u{1F4A1} Tip:"),console.log(" You can run this setup command from ANY folder on your system."),console.log(` It automatically targets your global config files (~/...) without needing to clone this repo.
36
42
  `),console.log("\u{1F4A1} Privacy & Safety:"),console.log(" Superpowers MCP only configures the specific client you explicitly choose."),console.log(` It will NEVER silently scan or modify unselected environments.
37
- `),process.exitCode=1;return}try{let n=await G(r),s=0,p=0,g=0;for(let c of n){let j=c.status==="created"||c.status==="updated"||c.status==="removed"?"\u2705":c.status==="up-to-date"?"\u2728":c.status==="skipped"?"\u23ED\uFE0F ":"\u274C";console.log(`${j} [${c.name}] (${c.status})`),console.log(` Path: ${c.path}`),console.log(` Info: ${c.message}
38
- `),c.status==="created"||c.status==="updated"||c.status==="up-to-date"||c.status==="removed"?s++:c.status==="skipped"?p++:c.status==="error"&&g++}if(console.log("--------------------------------------------------------"),g>0){console.error(`\u26A0\uFE0F Setup finished with errors: ${g} failure(s), ${s} succeeded.`),process.exitCode=1;return}console.log(`\u{1F389} Setup complete! ${s} environment(s) ready.`)}catch(n){let s=n instanceof Error?n.message:String(n);console.error(`\u274C Setup failed: ${s}
39
- `),process.exitCode=1}}function pe(){console.log(`
43
+ `),process.exitCode=1;return}try{let r=await oe(n),s=0,c=0,g=0;for(let p of r){let v=p.status==="created"||p.status==="updated"||p.status==="removed"?"\u2705":p.status==="up-to-date"?"\u2728":p.status==="skipped"?"\u23ED\uFE0F ":"\u274C";console.log(`${v} [${p.name}] (${p.status})`),console.log(` Path: ${p.path}`),console.log(` Info: ${p.message}
44
+ `),p.status==="created"||p.status==="updated"||p.status==="up-to-date"||p.status==="removed"?s++:p.status==="skipped"?c++:p.status==="error"&&g++}if(console.log("--------------------------------------------------------"),g>0){console.error(`\u26A0\uFE0F Setup finished with errors: ${g} failure(s), ${s} succeeded.`),process.exitCode=1;return}console.log(`\u{1F389} Setup complete! ${s} environment(s) ready.`)}catch(r){let s=r instanceof Error?r.message:String(r);console.error(`\u274C Setup failed: ${s}
45
+ `),process.exitCode=1}}function ve(){console.log(`
40
46
  Superpowers MCP - Targeted Global Setup
41
47
 
42
48
  Usage:
@@ -84,4 +90,4 @@ Any Directory:
84
90
  Privacy & Safety:
85
91
  Superpowers MCP only touches the client you explicitly choose.
86
92
  It never bulk-modifies your environment without your consent.
87
- `)}T().catch(e=>{let t=e instanceof Error?e.message:String(e);console.error(`\u274C Fatal error: ${t}`),process.exitCode=1});0&&(module.exports={HARNESS_CONFIGS,JSON_SERVER_ROOT_KEYS,isPlainObject,runSetup,runSetupCli,safeWriteConfig,stripJsonComments,updateJsonConfig,updateTomlConfig,updateYamlConfig});
93
+ `)}V().catch(e=>{let t=e instanceof Error?e.message:String(e);console.error(`\u274C Fatal error: ${t}`),process.exitCode=1});0&&(module.exports={HARNESS_CONFIGS,JSON_SERVER_ROOT_KEYS,isPlainObject,runSetup,runSetupCli,safeWriteConfig,stripJsonComments,updateJsonConfig,updateTomlConfig,updateYamlConfig});
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "superpowers-mcp",
3
3
  "displayName": "Superpowers MCP",
4
4
  "description": "Superpowers skills library (TDD, debugging, collaboration workflows) as an MCP server for VSCode and Antigravity",
5
- "version": "6.4.5",
5
+ "version": "6.4.7",
6
6
  "engines": {
7
7
  "node": ">=18"
8
8
  },
@@ -41,19 +41,20 @@
41
41
  "@hono/node-server": "^2.1.1",
42
42
  "fast-uri": "^4.2.1",
43
43
  "hono": "^4.13.7",
44
+ "proxy-addr": "^2.0.8",
44
45
  "qs": "^6.16.0"
45
46
  },
46
47
  "scripts": {
47
48
  "build": "node esbuild.js --production",
48
49
  "watch": "node esbuild.js --watch",
49
50
  "pretest": "npm run build",
50
- "test": "node tests/edge_cases_test.js && node tests/run_test.js && node tests/brainstorm_server_test.js && node tests/prompts_compositions_test.js && node tests/upstream_sync_test.js && node tests/mcp_coverage_test.js && node tests/drift_test.js && node tests/setup_test.js && bash tests/executing-plans/test-task-start.sh && bash tests/executing-plans/test-task-done.sh",
51
+ "test": "node scripts/run-tests.js",
51
52
  "drift": "node scripts/upstream-drift.js --fetch",
52
53
  "drift:record": "node scripts/upstream-drift.js --record",
53
54
  "prepublishOnly": "npm run build"
54
55
  },
55
56
  "devDependencies": {
56
- "@modelcontextprotocol/sdk": "^1.5.0",
57
+ "@modelcontextprotocol/sdk": "^1.32.1",
57
58
  "@types/node": "^20.0.0",
58
59
  "esbuild": "^0.28.1",
59
60
  "typescript": "^5.6.0"
@@ -0,0 +1,51 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Runs every test suite and reports all failures, not just the first.
4
+ *
5
+ * The previous `test` script chained the suites with `&&`, so a failure in an early
6
+ * suite skipped every later one — a green-to-red signal depended on which suite
7
+ * broke first, and a single regression could hide most of the suite.
8
+ */
9
+
10
+ const { spawnSync } = require("child_process");
11
+ const path = require("path");
12
+
13
+ const SUITES = [
14
+ "tests/edge_cases_test.js",
15
+ "tests/run_test.js",
16
+ "tests/brainstorm_server_test.js",
17
+ "tests/prompts_compositions_test.js",
18
+ "tests/upstream_sync_test.js",
19
+ "tests/mcp_coverage_test.js",
20
+ "tests/drift_test.js",
21
+ "tests/setup_test.js",
22
+ "tests/executing-plans/test-task-start.sh",
23
+ "tests/executing-plans/test-task-done.sh",
24
+ ];
25
+
26
+ const results = [];
27
+
28
+ for (const suite of SUITES) {
29
+ const started = process.hrtime.bigint();
30
+ const run = suite.endsWith(".sh")
31
+ ? spawnSync("bash", [suite], { cwd: path.join(__dirname, ".."), stdio: "inherit" })
32
+ : spawnSync("node", [suite], { cwd: path.join(__dirname, ".."), stdio: "inherit" });
33
+ const ms = Number(process.hrtime.bigint() - started) / 1e6;
34
+ const code = run.status === null ? 1 : run.status;
35
+ results.push({ suite, code, ms });
36
+ if (code !== 0) {
37
+ console.error(`\n✗ ${suite} exited ${code} — continuing so every suite still runs\n`);
38
+ }
39
+ }
40
+
41
+ console.log("\n================ test summary ================");
42
+ for (const { suite, code, ms } of results) {
43
+ console.log(` ${code === 0 ? "PASS" : "FAIL"} ${suite.padEnd(48)} ${ms.toFixed(0)}ms`);
44
+ }
45
+ const failed = results.filter((r) => r.code !== 0);
46
+ console.log(`==============================================`);
47
+ console.log(` ${results.length - failed.length}/${results.length} suites passed`);
48
+ if (failed.length > 0) {
49
+ console.error(` failing: ${failed.map((f) => f.suite).join(", ")}`);
50
+ process.exit(1);
51
+ }