superpowers-mcp 6.4.6 → 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,45 +1,47 @@
1
- "use strict";var Z=Object.create;var T=Object.defineProperty;var X=Object.getOwnPropertyDescriptor;var ee=Object.getOwnPropertyNames;var te=Object.getPrototypeOf,ne=Object.prototype.hasOwnProperty;var se=(e,t)=>{for(var r in t)T(e,r,{get:t[r],enumerable:!0})},K=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of ee(t))!ne.call(e,s)&&s!==r&&T(e,s,{get:()=>t[s],enumerable:!(n=X(t,s))||n.enumerable});return e};var I=(e,t,r)=>(r=e!=null?Z(te(e)):{},K(t||!e||!e.__esModule?T(r,"default",{value:e,enumerable:!0}):r,e)),re=e=>K(T({},"__esModule",{value:!0}),e);var de={};se(de,{HARNESS_CONFIGS:()=>W,JSON_SERVER_ROOT_KEYS:()=>z,isPlainObject:()=>A,runSetup:()=>Q,runSetupCli:()=>fe,safeWriteConfig:()=>B,stripJsonComments:()=>G,updateJsonConfig:()=>Y,updateTomlConfig:()=>F,updateYamlConfig:()=>V});module.exports=re(de);var u=I(require("fs")),o=I(require("path")),R=I(require("os")),H=I(require("crypto")),W={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})}},z=["mcpServers","servers","mcp"];function A(e){return Object.prototype.toString.call(e)==="[object Object]"}function G(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],C=l+1<r?e[l+1]:"";if(g){(f===`
2
- `||f==="\r")&&(g=!1,n.push(f));continue}if(c){f==="*"&&C==="/"&&(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==="/"&&C==="/"){g=!0,l++;continue}if(f==="/"&&C==="*"){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 M=/\s/;function oe(e){for(let t=1;t<e.length;t++){if(e[t]!=="#"||!M.test(e[t-1]))continue;let r=t-1;for(;r>0&&M.test(e[r-1]);)r--;return e.slice(r)}return""}function V(e,t,r,n=!1,s="mcp"){let p=s==="goose"?{rootKey:"extensions",ownedKeys:["cmd","args","type"],freshEntry:(i,d,y)=>[`${i}superpowers:`,`${i}${i}name: "Superpowers"`,`${i}${i}cmd: ${JSON.stringify(d)}`,`${i}${i}args: ${JSON.stringify(y)}`,`${i}${i}enabled: true`,`${i}${i}type: stdio`,`${i}${i}timeout: 300`]}:{rootKey:"mcp_servers",ownedKeys:["command","args"],freshEntry:(i,d,y)=>[`${i}superpowers:`,`${i}${i}command: ${JSON.stringify(d)}`,`${i}${i}args: ${JSON.stringify(y)}`]};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=e.includes(`\r
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
4
  `)?`\r
5
5
  `:`
6
- `,C=(i,d)=>{let y=i.length,E=0;for(;y>0&&i[y-1]===`
7
- `&&(d<0||E<d);)y--,y>0&&i[y-1]==="\r"&&y--,E++;return i.slice(0,y)},x=i=>{let d=e.endsWith(`
8
- `),y=i.split(`
9
- `).join(f);return d?C(y,1)+f:C(y,-1)},S=l.map((i,d)=>{let y=i.match(g);return y?{index:d,indent:y[1],tail:i.slice(y[0].length).trim()}:null}).filter(i=>i!==null),h=S.filter(i=>i.indent==="");if(h.length>1)throw new Error(`Cannot safely update YAML with duplicate ${p.rootKey} keys`);if(h.length===1){let i=h[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(S.length>0)throw new Error(`Cannot safely update YAML unless ${p.rootKey} is a root-level block mapping`);let w=" ";if(h.length===1)for(let i=h[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&&(w=d[1]);break}if(n){let i=[],d=!1,y=0,E=!1,P=0,O=!1,b=-1;for(let $=0;$<l.length;$++){let k=l[$],J=k.match(c);if(J){d=!0,y=J[1].length,b=i.length,i.push(k);continue}if(d){let N=k.match(/^(\s*)/)?.[1].length||0;if(k.trimStart().startsWith("#")){i.push(k);continue}if(k.trim()!==""&&N<=y)d=!1,E=!1;else{let D=k.match(/^(\s*)["']?superpowers["']?\s*:\s*(?:#.*)?$/);if(D&&D[1]===w){E=!0,P=D[1].length,O=!0;continue}if(E){if(N>P||k.trim()==="")continue;E=!1}}}i.push(k)}if(O&&b>=0&&b<i.length){let $=i[b],k=$.match(c);k&&(i.slice(b+1).some(N=>N.trim()!==""&&!N.trimStart().startsWith("#")&&/^\s/.test(N))||(i[b]=$.replace(c,`${k[1]}${p.rootKey}: {}`)))}return x(i.join(`
10
- `))}let m=p.freshEntry(w,t,r);if(!e||e.trim()==="")return x(`${p.rootKey}:
11
- ${m.join(`
12
- `)}`);let v=h.length===1?h[0].index:-1;if(v===-1)return x(`${e.trimEnd()}
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}:
11
+ ${y.join(`
12
+ `)}`);let C=m.length===1?m[0].index:-1;if(C===-1)return b(`${e.trimEnd()}
13
13
 
14
- ${p.rootKey}:
15
- ${m.join(`
16
- `)}`);let a=-1;for(let i=v+1;i<l.length;i++){let d=l[i];if(/^[^\s#]/.test(d))break;if((d.match(/^(\s*)/)?.[1]||"")===w&&/^\s+["']?superpowers["']?\s*:\s*(?:#.*)?$/.test(d)){a=i;break}}if(a!==-1){let i=l[a].match(/^(\s*)/)?.[1].length||2,d=a+1;for(;d<l.length;){let b=l[d];if((b.match(/^(\s*)/)?.[1].length||0)>i||b.trim()==="")d++;else break}let y=[],E=-1,P=i+w.length;for(let b=a+1;b<d;b++){let $=l[b];if($.trim()==="")continue;let k=$.match(/^(\s*)/)?.[1].length??0;if(!(E!==-1&&k>E)){if(E=-1,k===P&&j.test($)){E=k;continue}y.push($)}}m[0]+=oe(l[a]);let O=m.filter((b,$)=>{if($===0)return!0;let k=b.match(/^\s*["']?([A-Za-z0-9_-]+)["']?\s*:/);return!k||p.ownedKeys.includes(k[1])});return l.splice(a,d-a,...O,...y),x(l.join(`
17
- `))}else return l.splice(v+1,0,...m),x(l.join(`
18
- `))}function L(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&&M.test(e[s-1]);)s--;return[e.slice(0,s),e.slice(s)]}}return[e,""]}var ie=/^\s*\[\s*mcp_servers\s*\.\s*superpowers\s*\]\s*(?:#.*)?$/;function _(e){return e===" "||e===" "||e===`
19
- `||e==="\r"||e==="\f"||e==="\v"}function U(e){let t=0;for(;t<e.length&&_(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[n]);)n++;return n>=e.length?!0:e[n]==="#"}var ae=/^\s*\[\s*mcp_servers\s*\.\s*superpowers\s*\./;function pe(e){let t=0;for(;t<e.length&&_(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[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 ce(e){let t=0;for(;t<e.length&&_(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[t]);)t++;if(t>=e.length||e[t]!=="=")return null;for(t++;t<e.length&&_(e[t]);)t++;let n=e.length;for(;n>t&&_(e[n-1]);)n--;return{key:r,value:e.slice(t,n)}}var le=/^\s*(command|args)\s*=/;function F(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(pe(s[a]))throw new Error("Cannot safely update TOML with quoted mcp_servers.superpowers table names");ie.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]
20
- ${g}
21
- ${c}
14
+ ${c.rootKey}:
15
+ ${y.join(`
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}
22
23
  `;return!e||e.trim()===""?a:`${e.trimEnd()}
23
24
 
24
- ${a}`}let l=p[0],f=l+1;for(;f<s.length&&!(U(s[f])&&!ae.test(s[f]));)f++;let C=f;for(let a=l+1;a<f;a++)if(U(s[a])){C=a;break}if(n)return s.slice(0,l).concat(s.slice(f)).join(`
25
- `);let x=null,S=null,h={};for(let a=l+1;a<C;a++){let[i,d]=L(s[a]),y=ce(i);y&&(y.key==="command"?x===null&&(x=j(y.value)):S===null&&(S=j(y.value)),y.key in h||(h[y.key]=d))}if(x===j(JSON.stringify(t))&&S===j(JSON.stringify(r)))return e;let w=[`${g}${h.command??""}`,`${c}${h.args??""}`],m=s.slice(0,l+1),v=!1;for(let a=l+1;a<C;a++){let[i]=L(s[a]);if(le.test(i)){v||(m.push(...w),v=!0);continue}m.push(s[a])}return v||m.push(...w),m.push(...s.slice(C,f)),m.push(...s.slice(f)),m.join(`
26
- `)}function q(e,t,r){if(!A(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 Y(e,t,r,n,s=!1,p,g){let c={},j=!1;if(e&&e.trim()!=="")try{let S=JSON.parse(e);if(!A(S))throw new Error("Existing JSON root must be an object");c=S}catch(S){try{let h=G(e,!0),w=JSON.parse(h);if(!A(w))throw new Error("Existing JSON root must be an object");c=w,j=h!==e}catch(h){let w=h instanceof Error?h.message:String(h),m=S instanceof Error?S.message:String(S);throw new Error(`Failed to parse existing JSON: ${w} (raw JSON error: ${m})`)}}let l=t==="json-servers"?"servers":t==="json-mcp"?"mcp":"mcpServers";if(g&&g.length>0){let S=g.join(".");for(let m of g){if(typeof m!="string"||m.length===0)throw new Error(`Invalid JSON field "${S}"`);if(m==="__proto__"||m==="constructor"||m==="prototype")throw new Error(`Refusing to use unsafe JSON field "${S}"`);if(!/^[A-Za-z0-9_-]+$/.test(m))throw new Error(`Invalid JSON field "${S}"`)}let h=c;for(let m of g){if(m==="__proto__"||m==="constructor"||m==="prototype")throw new Error(`Refusing to use unsafe JSON field "${S}"`);let v=h[m];if(v===void 0){if(s)return e;h[m]={}}else if(!A(v))throw new Error(`Existing JSON field "${S}" must be an object`);h=h[m]}if(s)delete h.superpowers;else{let m=p?{...p}:{command:r,args:n};h.superpowers=q(h.superpowers,m,t)}let w=JSON.stringify(c,null,2)+`
27
- `;return j&&w!==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
- `),w}let f=z.find(S=>A(c[S])&&c[S].superpowers!==void 0)??l;if(c[f]!==void 0&&!A(c[f]))throw new Error(`Existing JSON field "${f}" must be an object`);c[f]===void 0&&(c[f]={});let C=c[f];if(s)delete C.superpowers;else{let S;p?S={...p}:t==="json-servers"?S={command:r,args:n,type:"stdio"}:t==="json-mcp"?S={type:"local",command:[r,...n],enabled:!0}:S={command:r,args:n},C.superpowers=q(C.superpowers,S,t)}let x=JSON.stringify(c,null,2)+`
29
- `;return j&&x!==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
- `),x}function ue(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 B(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 O=u.readlinkSync(e);p=o.resolve(o.dirname(e),O)}let i=o.normalize(o.resolve(p)).toLowerCase(),d=o.normalize(o.resolve(R.tmpdir())).toLowerCase();if(!(i===d||i.startsWith(d+o.sep))&&(["/etc","/bin","/sbin","/usr","/root","/sys","/proc","/dev","/private/etc","c:\\windows"].some(P=>i===P||i.startsWith(P+o.sep))||i==="/var"||i.startsWith("/var"+o.sep)&&!i.startsWith("/var/folders"+o.sep)||i==="/private/var"||i.startsWith("/private/var"+o.sep)&&!i.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(R.tmpdir())).toLowerCase(),C=l===f||l.startsWith(f+o.sep),S=["/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(!C&&S)throw new Error(`Refusing to write to unsafe configuration target: ${p}`);if(!n.some(a=>{if(!a)return!1;let i=o.resolve(a);try{i=u.realpathSync(i)}catch{}let d=o.relative(i,p);return d!==".."&&!d.startsWith(`..${o.sep}`)&&!o.isAbsolute(d)}))throw new Error(`Refusing to write configuration outside allowed roots: ${p}`);let w=384;if(u.existsSync(p)){try{w=u.statSync(p).mode}catch{}if(r){let a=u.readFileSync(p,"utf8"),i=`${p}.${Date.now()}.bak`;try{u.writeFileSync(i,a,{encoding:"utf8",mode:w})}catch(d){let y=d instanceof Error?d.message:String(d);throw new Error(`Failed to create safe backup before write: ${y}`)}ue(p)}}let m=H.randomBytes(8).toString("hex"),v=o.join(c,`.tmp.${o.basename(p)}.${process.pid}.${m}`);try{u.writeFileSync(v,t,{encoding:"utf8",mode:w,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 i=u.realpathSync(g),d=u.statSync(i);if(i!==c||d.dev!==j.dev||d.ino!==j.ino)throw new Error("Configuration directory changed while writing");u.renameSync(v,p)}catch(a){try{u.existsSync(v)&&u.unlinkSync(v)}catch{}throw a}}async function Q(e={}){let t=e.platform||R.platform(),r=e.homeDir||R.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"],C=[];if(!j)throw new Error(`No target client specified. Please specify which client to configure using --target <${Object.keys(W).join("|")}>.`);let x=Object.keys(W).find(h=>h===j||W[h].aliases.includes(j));if(!x)throw new Error(`Unknown harness target: "${j}". Supported targets: ${Object.keys(W).join(", ")}`);let S=[x];for(let h of S){let w=W[h],m=w.getConfigPath(t,r,n,s),v=u.existsSync(m);if(g&&!v){C.push({target:h,name:w.name,path:m,status:"up-to-date",message:"Already not configured (file does not exist)"});continue}try{let a="";v&&(a=u.readFileSync(m,"utf8"));let i="";if(w.type==="yaml")i=V(a,l,f,g,w.yamlProfile);else if(w.type==="toml")i=F(a,l,f,g);else{let d=typeof w.defaultConfig=="function"?w.defaultConfig(l,f):void 0;i=Y(a,w.type,l,f,g,d,w.serverPath)}if(a.trim()===i.trim()&&v){C.push({target:h,name:w.name,path:m,status:"up-to-date",message:g?"Already not configured":"Already configured and up-to-date"});continue}p||B(m,i,!!e.backup,[r,n||"",s||""],v?a:null),C.push({target:h,name:w.name,path:m,status:g?"removed":v?"updated":"created",message:p?`[Dry Run] Would ${g?"remove from":v?"update":"create"} ${m}`:`Successfully ${g?"removed from":v?"updated":"configured"}!`})}catch(a){let i=a instanceof Error?a.message:String(a);C.push({target:h,name:w.name,path:m,status:"error",message:i})}}return C}async function fe(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.
31
- `),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.
32
- `),process.exitCode=1;return}r.target=p}else if(s==="--help"||s==="-h"){ge();return}else if(s.startsWith("-")){console.error(`\u274C Error: Unknown option "${s}". Use --help for usage.
33
- `),process.exitCode=1;return}else if(!r.target)r.target=s;else{console.error(`\u274C Error: Unexpected argument "${s}". Use --help for usage.
34
- `),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(`
35
37
  ========================================================`),console.log("\u26A1 Superpowers MCP - Targeted Client Setup"),console.log(`========================================================
36
- `),!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:
37
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)
38
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.
39
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.
40
- `),process.exitCode=1;return}try{let n=await Q(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}
41
- `),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}
42
- `),process.exitCode=1}}function ge(){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(`
43
45
  Superpowers MCP - Targeted Global Setup
44
46
 
45
47
  Usage:
package/out/setup.js CHANGED
@@ -1,46 +1,48 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var X=Object.create;var T=Object.defineProperty;var ee=Object.getOwnPropertyDescriptor;var te=Object.getOwnPropertyNames;var ne=Object.getPrototypeOf,se=Object.prototype.hasOwnProperty;var re=(e,t)=>{for(var r in t)T(e,r,{get:t[r],enumerable:!0})},L=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of te(t))!se.call(e,s)&&s!==r&&T(e,s,{get:()=>t[s],enumerable:!(n=ee(t,s))||n.enumerable});return e};var I=(e,t,r)=>(r=e!=null?X(ne(e)):{},L(t||!e||!e.__esModule?T(r,"default",{value:e,enumerable:!0}):r,e)),oe=e=>L(T({},"__esModule",{value:!0}),e);var de={};re(de,{HARNESS_CONFIGS:()=>W,JSON_SERVER_ROOT_KEYS:()=>F,isPlainObject:()=>A,runSetup:()=>Z,runSetupCli:()=>K,safeWriteConfig:()=>Q,stripJsonComments:()=>G,updateJsonConfig:()=>B,updateTomlConfig:()=>Y,updateYamlConfig:()=>V});module.exports=oe(de);var u=I(require("fs")),o=I(require("path")),R=I(require("os")),z=I(require("crypto")),W={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})}},F=["mcpServers","servers","mcp"];function A(e){return Object.prototype.toString.call(e)==="[object Object]"}function G(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],C=l+1<r?e[l+1]:"";if(g){(f===`
3
- `||f==="\r")&&(g=!1,n.push(f));continue}if(c){f==="*"&&C==="/"&&(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==="/"&&C==="/"){g=!0,l++;continue}if(f==="/"&&C==="*"){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 M=/\s/;function ie(e){for(let t=1;t<e.length;t++){if(e[t]!=="#"||!M.test(e[t-1]))continue;let r=t-1;for(;r>0&&M.test(e[r-1]);)r--;return e.slice(r)}return""}function V(e,t,r,n=!1,s="mcp"){let p=s==="goose"?{rootKey:"extensions",ownedKeys:["cmd","args","type"],freshEntry:(i,d,y)=>[`${i}superpowers:`,`${i}${i}name: "Superpowers"`,`${i}${i}cmd: ${JSON.stringify(d)}`,`${i}${i}args: ${JSON.stringify(y)}`,`${i}${i}enabled: true`,`${i}${i}type: stdio`,`${i}${i}timeout: 300`]}:{rootKey:"mcp_servers",ownedKeys:["command","args"],freshEntry:(i,d,y)=>[`${i}superpowers:`,`${i}${i}command: ${JSON.stringify(d)}`,`${i}${i}args: ${JSON.stringify(y)}`]};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=e.includes(`\r
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
5
  `)?`\r
6
6
  `:`
7
- `,C=(i,d)=>{let y=i.length,E=0;for(;y>0&&i[y-1]===`
8
- `&&(d<0||E<d);)y--,y>0&&i[y-1]==="\r"&&y--,E++;return i.slice(0,y)},x=i=>{let d=e.endsWith(`
9
- `),y=i.split(`
10
- `).join(f);return d?C(y,1)+f:C(y,-1)},S=l.map((i,d)=>{let y=i.match(g);return y?{index:d,indent:y[1],tail:i.slice(y[0].length).trim()}:null}).filter(i=>i!==null),h=S.filter(i=>i.indent==="");if(h.length>1)throw new Error(`Cannot safely update YAML with duplicate ${p.rootKey} keys`);if(h.length===1){let i=h[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(S.length>0)throw new Error(`Cannot safely update YAML unless ${p.rootKey} is a root-level block mapping`);let w=" ";if(h.length===1)for(let i=h[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&&(w=d[1]);break}if(n){let i=[],d=!1,y=0,E=!1,P=0,O=!1,b=-1;for(let $=0;$<l.length;$++){let k=l[$],J=k.match(c);if(J){d=!0,y=J[1].length,b=i.length,i.push(k);continue}if(d){let N=k.match(/^(\s*)/)?.[1].length||0;if(k.trimStart().startsWith("#")){i.push(k);continue}if(k.trim()!==""&&N<=y)d=!1,E=!1;else{let D=k.match(/^(\s*)["']?superpowers["']?\s*:\s*(?:#.*)?$/);if(D&&D[1]===w){E=!0,P=D[1].length,O=!0;continue}if(E){if(N>P||k.trim()==="")continue;E=!1}}}i.push(k)}if(O&&b>=0&&b<i.length){let $=i[b],k=$.match(c);k&&(i.slice(b+1).some(N=>N.trim()!==""&&!N.trimStart().startsWith("#")&&/^\s/.test(N))||(i[b]=$.replace(c,`${k[1]}${p.rootKey}: {}`)))}return x(i.join(`
11
- `))}let m=p.freshEntry(w,t,r);if(!e||e.trim()==="")return x(`${p.rootKey}:
12
- ${m.join(`
13
- `)}`);let v=h.length===1?h[0].index:-1;if(v===-1)return x(`${e.trimEnd()}
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}:
12
+ ${y.join(`
13
+ `)}`);let C=m.length===1?m[0].index:-1;if(C===-1)return b(`${e.trimEnd()}
14
14
 
15
- ${p.rootKey}:
16
- ${m.join(`
17
- `)}`);let a=-1;for(let i=v+1;i<l.length;i++){let d=l[i];if(/^[^\s#]/.test(d))break;if((d.match(/^(\s*)/)?.[1]||"")===w&&/^\s+["']?superpowers["']?\s*:\s*(?:#.*)?$/.test(d)){a=i;break}}if(a!==-1){let i=l[a].match(/^(\s*)/)?.[1].length||2,d=a+1;for(;d<l.length;){let b=l[d];if((b.match(/^(\s*)/)?.[1].length||0)>i||b.trim()==="")d++;else break}let y=[],E=-1,P=i+w.length;for(let b=a+1;b<d;b++){let $=l[b];if($.trim()==="")continue;let k=$.match(/^(\s*)/)?.[1].length??0;if(!(E!==-1&&k>E)){if(E=-1,k===P&&j.test($)){E=k;continue}y.push($)}}m[0]+=ie(l[a]);let O=m.filter((b,$)=>{if($===0)return!0;let k=b.match(/^\s*["']?([A-Za-z0-9_-]+)["']?\s*:/);return!k||p.ownedKeys.includes(k[1])});return l.splice(a,d-a,...O,...y),x(l.join(`
18
- `))}else return l.splice(v+1,0,...m),x(l.join(`
19
- `))}function U(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&&M.test(e[s-1]);)s--;return[e.slice(0,s),e.slice(s)]}}return[e,""]}var ae=/^\s*\[\s*mcp_servers\s*\.\s*superpowers\s*\]\s*(?:#.*)?$/;function _(e){return e===" "||e===" "||e===`
20
- `||e==="\r"||e==="\f"||e==="\v"}function q(e){let t=0;for(;t<e.length&&_(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[n]);)n++;return n>=e.length?!0:e[n]==="#"}var pe=/^\s*\[\s*mcp_servers\s*\.\s*superpowers\s*\./;function ce(e){let t=0;for(;t<e.length&&_(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[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 le(e){let t=0;for(;t<e.length&&_(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[t]);)t++;if(t>=e.length||e[t]!=="=")return null;for(t++;t<e.length&&_(e[t]);)t++;let n=e.length;for(;n>t&&_(e[n-1]);)n--;return{key:r,value:e.slice(t,n)}}var ue=/^\s*(command|args)\s*=/;function Y(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(ce(s[a]))throw new Error("Cannot safely update TOML with quoted mcp_servers.superpowers table names");ae.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]
21
- ${g}
22
- ${c}
15
+ ${c.rootKey}:
16
+ ${y.join(`
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}
23
24
  `;return!e||e.trim()===""?a:`${e.trimEnd()}
24
25
 
25
- ${a}`}let l=p[0],f=l+1;for(;f<s.length&&!(q(s[f])&&!pe.test(s[f]));)f++;let C=f;for(let a=l+1;a<f;a++)if(q(s[a])){C=a;break}if(n)return s.slice(0,l).concat(s.slice(f)).join(`
26
- `);let x=null,S=null,h={};for(let a=l+1;a<C;a++){let[i,d]=U(s[a]),y=le(i);y&&(y.key==="command"?x===null&&(x=j(y.value)):S===null&&(S=j(y.value)),y.key in h||(h[y.key]=d))}if(x===j(JSON.stringify(t))&&S===j(JSON.stringify(r)))return e;let w=[`${g}${h.command??""}`,`${c}${h.args??""}`],m=s.slice(0,l+1),v=!1;for(let a=l+1;a<C;a++){let[i]=U(s[a]);if(ue.test(i)){v||(m.push(...w),v=!0);continue}m.push(s[a])}return v||m.push(...w),m.push(...s.slice(C,f)),m.push(...s.slice(f)),m.join(`
27
- `)}function H(e,t,r){if(!A(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 B(e,t,r,n,s=!1,p,g){let c={},j=!1;if(e&&e.trim()!=="")try{let S=JSON.parse(e);if(!A(S))throw new Error("Existing JSON root must be an object");c=S}catch(S){try{let h=G(e,!0),w=JSON.parse(h);if(!A(w))throw new Error("Existing JSON root must be an object");c=w,j=h!==e}catch(h){let w=h instanceof Error?h.message:String(h),m=S instanceof Error?S.message:String(S);throw new Error(`Failed to parse existing JSON: ${w} (raw JSON error: ${m})`)}}let l=t==="json-servers"?"servers":t==="json-mcp"?"mcp":"mcpServers";if(g&&g.length>0){let S=g.join(".");for(let m of g){if(typeof m!="string"||m.length===0)throw new Error(`Invalid JSON field "${S}"`);if(m==="__proto__"||m==="constructor"||m==="prototype")throw new Error(`Refusing to use unsafe JSON field "${S}"`);if(!/^[A-Za-z0-9_-]+$/.test(m))throw new Error(`Invalid JSON field "${S}"`)}let h=c;for(let m of g){if(m==="__proto__"||m==="constructor"||m==="prototype")throw new Error(`Refusing to use unsafe JSON field "${S}"`);let v=h[m];if(v===void 0){if(s)return e;h[m]={}}else if(!A(v))throw new Error(`Existing JSON field "${S}" must be an object`);h=h[m]}if(s)delete h.superpowers;else{let m=p?{...p}:{command:r,args:n};h.superpowers=H(h.superpowers,m,t)}let w=JSON.stringify(c,null,2)+`
28
- `;return j&&w!==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
- `),w}let f=F.find(S=>A(c[S])&&c[S].superpowers!==void 0)??l;if(c[f]!==void 0&&!A(c[f]))throw new Error(`Existing JSON field "${f}" must be an object`);c[f]===void 0&&(c[f]={});let C=c[f];if(s)delete C.superpowers;else{let S;p?S={...p}:t==="json-servers"?S={command:r,args:n,type:"stdio"}:t==="json-mcp"?S={type:"local",command:[r,...n],enabled:!0}:S={command:r,args:n},C.superpowers=H(C.superpowers,S,t)}let x=JSON.stringify(c,null,2)+`
30
- `;return j&&x!==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
- `),x}function fe(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 Q(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 O=u.readlinkSync(e);p=o.resolve(o.dirname(e),O)}let i=o.normalize(o.resolve(p)).toLowerCase(),d=o.normalize(o.resolve(R.tmpdir())).toLowerCase();if(!(i===d||i.startsWith(d+o.sep))&&(["/etc","/bin","/sbin","/usr","/root","/sys","/proc","/dev","/private/etc","c:\\windows"].some(P=>i===P||i.startsWith(P+o.sep))||i==="/var"||i.startsWith("/var"+o.sep)&&!i.startsWith("/var/folders"+o.sep)||i==="/private/var"||i.startsWith("/private/var"+o.sep)&&!i.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(R.tmpdir())).toLowerCase(),C=l===f||l.startsWith(f+o.sep),S=["/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(!C&&S)throw new Error(`Refusing to write to unsafe configuration target: ${p}`);if(!n.some(a=>{if(!a)return!1;let i=o.resolve(a);try{i=u.realpathSync(i)}catch{}let d=o.relative(i,p);return d!==".."&&!d.startsWith(`..${o.sep}`)&&!o.isAbsolute(d)}))throw new Error(`Refusing to write configuration outside allowed roots: ${p}`);let w=384;if(u.existsSync(p)){try{w=u.statSync(p).mode}catch{}if(r){let a=u.readFileSync(p,"utf8"),i=`${p}.${Date.now()}.bak`;try{u.writeFileSync(i,a,{encoding:"utf8",mode:w})}catch(d){let y=d instanceof Error?d.message:String(d);throw new Error(`Failed to create safe backup before write: ${y}`)}fe(p)}}let m=z.randomBytes(8).toString("hex"),v=o.join(c,`.tmp.${o.basename(p)}.${process.pid}.${m}`);try{u.writeFileSync(v,t,{encoding:"utf8",mode:w,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 i=u.realpathSync(g),d=u.statSync(i);if(i!==c||d.dev!==j.dev||d.ino!==j.ino)throw new Error("Configuration directory changed while writing");u.renameSync(v,p)}catch(a){try{u.existsSync(v)&&u.unlinkSync(v)}catch{}throw a}}async function Z(e={}){let t=e.platform||R.platform(),r=e.homeDir||R.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"],C=[];if(!j)throw new Error(`No target client specified. Please specify which client to configure using --target <${Object.keys(W).join("|")}>.`);let x=Object.keys(W).find(h=>h===j||W[h].aliases.includes(j));if(!x)throw new Error(`Unknown harness target: "${j}". Supported targets: ${Object.keys(W).join(", ")}`);let S=[x];for(let h of S){let w=W[h],m=w.getConfigPath(t,r,n,s),v=u.existsSync(m);if(g&&!v){C.push({target:h,name:w.name,path:m,status:"up-to-date",message:"Already not configured (file does not exist)"});continue}try{let a="";v&&(a=u.readFileSync(m,"utf8"));let i="";if(w.type==="yaml")i=V(a,l,f,g,w.yamlProfile);else if(w.type==="toml")i=Y(a,l,f,g);else{let d=typeof w.defaultConfig=="function"?w.defaultConfig(l,f):void 0;i=B(a,w.type,l,f,g,d,w.serverPath)}if(a.trim()===i.trim()&&v){C.push({target:h,name:w.name,path:m,status:"up-to-date",message:g?"Already not configured":"Already configured and up-to-date"});continue}p||Q(m,i,!!e.backup,[r,n||"",s||""],v?a:null),C.push({target:h,name:w.name,path:m,status:g?"removed":v?"updated":"created",message:p?`[Dry Run] Would ${g?"remove from":v?"update":"create"} ${m}`:`Successfully ${g?"removed from":v?"updated":"configured"}!`})}catch(a){let i=a instanceof Error?a.message:String(a);C.push({target:h,name:w.name,path:m,status:"error",message:i})}}return C}async function K(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.
32
- `),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.
33
- `),process.exitCode=1;return}r.target=p}else if(s==="--help"||s==="-h"){ge();return}else if(s.startsWith("-")){console.error(`\u274C Error: Unknown option "${s}". Use --help for usage.
34
- `),process.exitCode=1;return}else if(!r.target)r.target=s;else{console.error(`\u274C Error: Unexpected argument "${s}". Use --help for usage.
35
- `),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(`
36
38
  ========================================================`),console.log("\u26A1 Superpowers MCP - Targeted Client Setup"),console.log(`========================================================
37
- `),!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:
38
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)
39
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.
40
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.
41
- `),process.exitCode=1;return}try{let n=await Z(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}
42
- `),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}
43
- `),process.exitCode=1}}function ge(){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(`
44
46
  Superpowers MCP - Targeted Global Setup
45
47
 
46
48
  Usage:
@@ -88,4 +90,4 @@ Any Directory:
88
90
  Privacy & Safety:
89
91
  Superpowers MCP only touches the client you explicitly choose.
90
92
  It never bulk-modifies your environment without your consent.
91
- `)}K().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.6",
5
+ "version": "6.4.7",
6
6
  "engines": {
7
7
  "node": ">=18"
8
8
  },
@@ -48,7 +48,7 @@
48
48
  "build": "node esbuild.js --production",
49
49
  "watch": "node esbuild.js --watch",
50
50
  "pretest": "npm run build",
51
- "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",
52
52
  "drift": "node scripts/upstream-drift.js --fetch",
53
53
  "drift:record": "node scripts/upstream-drift.js --record",
54
54
  "prepublishOnly": "npm run build"