superclawd 0.1.131 → 0.1.132

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,29 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __cr } from 'module'; const require = __cr(import.meta.url);
3
- var Xe=["opus","fable","sonnet","haiku"],Un={opus:"claude-opus-5-5",fable:"claude-fable-5-1",sonnet:"claude-sonnet-5-5",haiku:"claude-haiku-5-5"},Wn=/^claude-(opus|fable|sonnet|haiku)-latest$/,Fn=/^claude-[a-z0-9][a-z0-9.-]{0,80}(\[1m\])?$/,Nn=/^claude-(opus|fable|sonnet|haiku)-\d[\w.-]*(\[1m\])?$/i;function jn(e){let t=e.trim().toLowerCase(),n=Wn.exec(t);return n?n[1]:Xe.includes(t)?t:null}function ze(e){let t={};if(!e||typeof e!="object")return t;for(let n of Xe){let r=e[n];typeof r=="string"&&Fn.test(r)&&(t[n]=r)}return t}function oe(e,t={},n={}){let r=(e??"").trim();if(!r||r==="default")return null;let o=n.pinnedToFamily?Nn.exec(r):null,s=o?o[1].toLowerCase():jn(r);return s?t[s]??Un[s]:r}import{spawn as Ln,spawnSync as Do,execSync as Uo}from"node:child_process";import{fileURLToPath as In}from"node:url";import{existsSync as Tn,readFileSync as Wo}from"node:fs";import{resolve as Fo,dirname as No,join as jo}from"node:path";import{homedir as Gn}from"node:os";import{join as ie}from"node:path";import{randomBytes as Yn}from"node:crypto";import{readFileSync as Kn,writeFileSync as Qe,mkdirSync as Ze,chmodSync as Bn,existsSync as et}from"node:fs";var z=(process.env.SUPERCLAWD_BACKEND||"real").toLowerCase(),_=z==="mock",V=process.env.SUPERCLAWD_MCP_API_URL||"https://mcp-api.superclawd.com",ae=process.env.SUPERCLAWD_API_URL||"https://api.superclawd.com",T=process.env.SUPERCLAWD_HOME||ie(Gn(),".superclawd"),le=ie(T,"sessions"),se=ie(T,"config.json");function Hn(e){if(!e||typeof e!="object")return{};let t=e,n=t.credentials??{...typeof t.keyId=="string"?{keyId:t.keyId}:{},...typeof t.secret=="string"?{secret:t.secret}:{},...typeof t.workspace=="string"?{workspace:t.workspace}:{}},r=t.preferences??{...typeof t.skipPermissions=="boolean"?{skipPermissions:t.skipPermissions}:{},...typeof t.notifications=="boolean"?{notifications:t.notifications}:{},...typeof t.chooseWorkspaceAtStartup=="boolean"?{chooseWorkspaceAtStartup:t.chooseWorkspaceAtStartup}:{},...typeof t.experimental=="boolean"?{experimental:t.experimental}:{}},o={};return Object.keys(n).length&&(o.credentials=n),Object.keys(r).length&&(o.preferences=r),typeof t.machineId=="string"&&(o.machineId=t.machineId),o}function tt(){let e=L()??{};if(e.machineId)return e.machineId;let t=Yn(16).toString("hex");return Y({...e,machineId:t}),t}function L(){try{return Hn(JSON.parse(Kn(se,"utf8")))}catch{return null}}function Y(e){Ze(T,{recursive:!0}),Qe(se,`${JSON.stringify(e,null,2)}
4
- `,{mode:384});try{Bn(se,384)}catch{}}function nt(){return L()?.preferences?.skipPermissions===!0}function qn(){return L()?.preferences?.notifications===!0}function rt(){return L()?.preferences?.chooseWorkspaceAtStartup!==!1}function Pe(e){let t=L()??{};Y({...t,credentials:{...t.credentials,workspace:e}})}function ce(){let e=L();e?.credentials?.workspace&&Y({...e,credentials:{...e.credentials,workspace:""}})}function ot(){return L()?.preferences?.experimental===!0}function st(){return L()?.preferences?.keepAwake===!0}function it(){return L()?.preferences?.privateMemory!==!1}function at(){return L()?.preferences?.pipelinesMcp===!0}function lt(e){return ie(e,"config.json")}function Jn(e,t){try{Ze(e,{recursive:!0}),Qe(lt(e),`${JSON.stringify(t,null,2)}
5
- `)}catch{}}function ct(e,t,n=!1){et(lt(e))||Jn(e,{notifications:n?!1:qn(),...t?{workspace:t}:{}})}function ut(){et(se)||Y({credentials:{keyId:"",secret:"",workspace:""},preferences:{notifications:!1,skipPermissions:!1,chooseWorkspaceAtStartup:!0,privateMemory:!0}})}var dt=1e3*60*60*24*3;function pt(){if(_)return{ok:!0,session:{keyId:process.env.SUPERCLAWD_MCP_KEY||"mock-key",secret:process.env.SUPERCLAWD_MCP_SECRET||"mock-secret",workspace:process.env.SUPERCLAWD_MCP_WORKSPACE||"mock-workspace",apiUrl:V}};let e=L()?.credentials??{},t=process.env.SUPERCLAWD_MCP_KEY||e.keyId,n=process.env.SUPERCLAWD_MCP_SECRET||e.secret,r=process.env.SUPERCLAWD_MCP_WORKSPACE||e.workspace||"";return!t||!n?{ok:!1,error:"Not authenticated. Run `superclawd login` (or set SUPERCLAWD_MCP_KEY + SUPERCLAWD_MCP_SECRET)."}:{ok:!0,session:{keyId:t,secret:n,workspace:r,apiUrl:V}}}import{spawn as Me}from"node:child_process";var ft=e=>{process.env.SUPERCLAWD_DEBUG&&process.stderr.write(`keep-awake: ${e}
6
- `)};function Vn(){try{switch(process.platform){case"darwin":return Me("caffeinate",["-i","-w",String(process.pid)],{stdio:"ignore"});case"linux":return Me("systemd-inhibit",["--what=sleep:idle","--who=SuperClawd","--why=SuperClawd session running","--mode=block","cat"],{stdio:["pipe","ignore","ignore"]});case"win32":{let e=[`$p = Add-Type -MemberDefinition '[DllImport("kernel32.dll")] public static extern uint SetThreadExecutionState(uint e);' -Name P -Namespace W -PassThru;`,"$p::SetThreadExecutionState(0x80000000 -bor 0x00000001) | Out-Null;","[void][Console]::In.ReadToEnd();"].join(" ");return Me("powershell",["-NoProfile","-NonInteractive","-Command",e],{stdio:["pipe","ignore","ignore"]})}default:return null}}catch{return null}}function mt(){let e=Vn();if(!e)return ft(`unsupported platform ${process.platform}`),null;e.unref(),e.on("error",n=>ft(n.message));let t=!1;return{stop(){if(!t){t=!0;try{e.kill()}catch{}}}}}import{spawnSync as gt}from"node:child_process";import Xn from"node:readline/promises";import{readFileSync as zn,writeFileSync as Qn,mkdirSync as Zn}from"node:fs";import{join as er}from"node:path";var tr=1500,ht=24*60*60*1e3,wt=er(T,"update-state.json");function nr(e,t){let n=s=>s.split("-")[0].split(".").map(i=>parseInt(i,10)||0),r=n(e),o=n(t);for(let s=0;s<3;s++){let i=r[s]??0,l=o[s]??0;if(i!==l)return i>l}return!1}async function rr(e){let t=new AbortController,n=setTimeout(()=>t.abort(),tr);try{let r=await fetch(`https://registry.npmjs.org/${e}`,{headers:{accept:"application/vnd.npm.install-v1+json"},signal:t.signal});return r.ok?(await r.json())["dist-tags"]?.latest??null:null}catch{return null}finally{clearTimeout(n)}}function St(){try{return JSON.parse(zn(wt,"utf8"))}catch{return{}}}function or(e){try{Zn(T,{recursive:!0}),Qn(wt,JSON.stringify(e,null,2))}catch{}}function yt(e,t){let n=St();n[e]={...n[e],...t},or(n)}async function be(e,t,n=Date.now()){let r=St()[e]??{},o=r.latest??null;return(!r.checkedAt||n-r.checkedAt>=ht)&&(o=await rr(e),yt(e,{latest:o??void 0,checkedAt:n})),!o||!nr(o,t)||r.dismissed===o||r.notifiedAt&&n-r.notifiedAt<ht?null:{latest:o}}function sr(e){return!(e.includes("-p")||e.includes("--print"))&&!!process.stdin.isTTY}function Ae(e,t,n,r){process.stderr.write(`\u26A0 ${e} ${t} is outdated (latest ${n}). Update with: ${r}
7
- `)}async function xe(e,t,n){let r=Xn.createInterface({input:process.stdin,output:process.stderr});try{process.stderr.write(`
8
- ${e} ${t} is outdated \u2014 ${n} is available.
9
- `);let o=(await r.question(" [U] Update now (default) [R] Run anyway > ")).trim().toLowerCase();return o==="r"||o==="run"?"run":"update"}finally{r.close()}}function H(e,t){yt(e,{notifiedAt:Date.now(),...t?{dismissed:t}:{}})}async function kt(e,t){if(process.env.SUPERCLAWD_NO_UPDATE||process.env.SUPERCLAWD_BACKEND==="mock"||process.env.SUPERCLAWD_UPDATED)return{};let n=await be("superclawd",e);if(!n)return{};let{latest:r}=n;if(!sr(t))return Ae("SuperClawd",e,r,"superclawd update"),H("superclawd"),{};if(await xe("SuperClawd",e,r)==="run")return H("superclawd",r),{};H("superclawd"),process.stderr.write(`Updating (npm i -g superclawd@latest) \u2026
10
- `);let s=gt("npm install -g superclawd@latest",{stdio:"inherit",shell:!0});if(s.status!==0)return process.stderr.write(`\u2717 Update failed (npm exited ${s.status??"?"}). Running ${e} for now.
11
- `),{};let i=gt("superclawd",t,{stdio:"inherit",env:{...process.env,SUPERCLAWD_UPDATED:"1"}});return i.error?(process.stderr.write(`\u2713 Updated to ${r}. Re-run your command.
12
- `),{exitCode:0}):{exitCode:i.status??0}}import{randomUUID as Et}from"node:crypto";function Rt(e){let t={"content-type":"application/json","x-mcp-key-id":e.keyId,"x-mcp-secret":e.secret,"x-workspace-slug":e.workspace,"x-request-id":Et()};return process.env.SUPERCLAWD_EXPERIMENTAL==="true"&&(t["x-experimental"]="true"),process.env.SUPERCLAWD_MEMORY_OFF==="1"&&(t["x-superclawd-memory"]="off"),t}async function ue(e,t,n){let r=`${e.apiUrl}${t}`;if(n){let i=new URLSearchParams;for(let[u,a]of Object.entries(n))a!==void 0&&a!==""&&i.set(u,a);let l=i.toString();l&&(r+=(r.includes("?")?"&":"?")+l)}let o=await fetch(r,{headers:Rt(e)}),s=await o.json().catch(()=>null);return{status:o.status,ok:o.ok,body:s}}async function Ct(e,t,n){try{let r=await fetch(`${e}/api/prompt/workspaces`,{headers:{"content-type":"application/json","x-mcp-key-id":t,"x-mcp-secret":n,"x-request-id":Et()}}),o=await r.json().catch(()=>null);return{ok:r.ok,status:r.status,workspaces:o?.workspaces??[]}}catch{return{ok:!1,status:0,workspaces:[]}}}async function _t(e,t,n,r={}){let o=await fetch(`${e.apiUrl}${t}`,{method:"POST",headers:{...Rt(e),...r},body:JSON.stringify(n)}),s=await o.json().catch(()=>null);return{status:o.status,ok:o.ok,body:s}}async function $e(e,t){e.message("Loading your workspaces\u2026");let n=await Ct(V,t.keyId,t.secret);if(!n.ok||n.workspaces.length===0)return{};let r=new Set(n.workspaces.map(i=>i.slug)),o=t.workspace&&r.has(t.workspace)?t.workspace:void 0;if(t.workspace&&!r.has(t.workspace)&&ce(),n.workspaces.length===1){let i=n.workspaces[0].slug;return i!==o&&Pe(i),{workspace:i}}let s=await e.selectWorkspace(n.workspaces,{currentSlug:o,defaultSlug:o,onSetDefault:i=>Pe(i)});return s===null?{cancelled:!0}:{workspace:s}}async function Oe(e){if(_)return{ok:!0};try{let t=await ue(e,"/api/prompt/catalog");return t.ok?{ok:!0}:t.status===401?{ok:!1,kind:"credentials",error:"Your credentials are invalid or expired. Run `superclawd login` again."}:t.status===404?{ok:!1,workspaceInvalid:!0,kind:"workspace",error:"Workspace not found. Run `superclawd` and pick a workspace."}:t.status===403?{ok:!1,workspaceInvalid:!0,kind:"workspace",error:"You are not a member of this workspace."}:t.status===502||t.status===503||t.status===504?{ok:!1,kind:"unreachable",error:`SuperClawd backend is unreachable or starting up (HTTP ${t.status}). Try again in a moment.`}:{ok:!1,kind:"other",error:`Auth check failed (HTTP ${t.status}).`}}catch(t){return{ok:!1,kind:"unreachable",error:`Cannot reach SuperClawd backend (${String(t)}).`}}}var Ie=[{id:"skill-backend-001",name:"backend-api-conventions",action:"code",executionMode:"auto",description:"writing, creating, modifying, or reviewing backend API code \u2014 HTTP endpoints, routes, controllers, request handlers, or server-side validation and security",categories:[{name:"endpoint-design",instructions:["Name routes with plural nouns and kebab-case (e.g. /user-profiles).","Return RFC-7807 problem+json on errors, never bare strings.","Validate and sanitize every request body against a schema before use."]},{name:"security",instructions:["Use parameterized queries only; never string-concatenate SQL.","Rate-limit auth endpoints to 5 requests/minute per IP."]}]},{id:"skill-testing-001",name:"testing-standards",action:"test",executionMode:"auto",description:"writing or updating automated tests \u2014 unit tests, integration tests, test files, assertions, mocks, or test coverage",categories:[{name:"unit",instructions:["One behavioral assertion per test; name tests as should_<expectation>.","Mock only at process boundaries (network, fs, clock)."]}]},{id:"skill-always-001",name:"repo-foundations",action:"behave",executionMode:"always",description:"foundational rules that always apply in this repository",categories:[{name:"house-rules",instructions:["Every source file must start with a one-line header comment describing its purpose.","Prefer clarity over cleverness; match the surrounding code's style."]}]}];var vt=[{id:"guardrail-no-rm-rf",match:{tools:["Bash"],commandPatterns:["\\brm\\s+-rf\\b","\\brm\\s+-fr\\b"]},action:"deny",message:"Destructive 'rm -rf' is blocked by a workspace guardrail. Remove paths explicitly and deliberately instead."},{id:"guardrail-payments-edits",match:{tools:["Edit","Write","MultiEdit","NotebookEdit"],pathGlobs:["**/payments/**"]},action:"ask",message:"Edits under payments/ touch billing-critical code \u2014 confirm before proceeding (workspace guardrail)."}],Pt=[{id:"agent-reviewer-001",name:"code-reviewer",description:"Reviews a diff for correctness and security issues. Use after writing code.",vendor:"anthropic",model:"claude-sonnet-4-6",prompt:"You are a meticulous senior code reviewer. Examine the change for correctness, security, and clarity. Report concrete findings with file:line; do not rewrite the code unless asked.",mode:"subagent",tools:{read:"allow",glob:"allow",grep:"allow",edit:"deny",write:"deny",bash:"deny",webfetch:"deny",task:"deny"},steps:null,inheritWorkspaceContext:!1},{id:"agent-orchestrator-001",name:"orchestrator",description:"Coordinates multi-step coding tasks and delegates focused work. Use when a task spans several files or steps.",vendor:"anthropic",model:"claude-sonnet-4-6",prompt:"You are an orchestrator. Break the request into concrete steps, perform the edits directly, and keep changes minimal and focused on what was asked.",mode:"subagent",tools:{read:"allow",glob:"allow",grep:"allow",edit:"allow",write:"allow",bash:"deny",webfetch:"deny",task:"allow"},steps:null,inheritWorkspaceContext:!0}],Mt=[{name:"ship-checklist",description:"Run this team's pre-merge checklist.",arguments:[{name:"scope",description:"what is being shipped",required:!1}],content:`Pre-merge checklist for $ARGUMENTS:
13
- 1. Tests pass and cover new behavior.
14
- 2. No secrets or debug logging left in.
15
- 3. Public APIs documented.
16
- 4. Changelog updated.`}],bt=[{name:"error-codes",description:"Canonical list of this platform's error codes.",content:`E1001 invalid_input
17
- E1002 unauthorized
18
- E1003 rate_limited
19
- E2001 upstream_unavailable`}];var At=[{id:"workflow-deploy-001",name:"production-deploy",description:"deploying to production, cutting a release, or shipping to prod",itemCount:6,content:`Production deploy workflow:
20
- 1. Confirm CI is green on main.
21
- 2. Bump version + update changelog.
22
- 3. Tag the release.
23
- 4. Run db migrations.
24
- 5. Deploy and watch error rate for 10m.
25
- 6. Announce in #releases.`}];function ir(){let e=Ie.filter(n=>n.executionMode==="auto").map(n=>({id:n.id,name:n.name,action:n.action,executionMode:n.executionMode,description:n.description,userInvocable:n.userInvocable})),t=Ie.filter(n=>n.executionMode==="always").flatMap(n=>n.categories.flatMap(r=>r.instructions)).map((n,r)=>`${r+1}. ${n}`).join(`
26
- `);return{skills:e,agents:Pt,agentTeams:[],commands:Mt.map(({name:n,description:r,arguments:o,team:s})=>({name:n,description:r,arguments:o,team:s??null})),resources:bt.map(({name:n,description:r})=>({name:n,description:r})),workflows:At.map(({id:n,name:r,description:o})=>({id:n,name:r,description:o})),mcpServers:[],guardrails:vt,policyGuardrails:[],foundational:{text:t},teamMemoryEnabled:!0,repoMemoryEnabled:!0,agentMemoryEnabled:!0}}async function Le(e){if(_)return ir();let t=await ue(e,"/api/prompt/catalog",{repoFingerprint:process.env.SUPERCLAWD_REPO_FINGERPRINT});if(!t.ok||!t.body)throw new Error(`Failed to fetch catalog (HTTP ${t.status}).`);return{skills:(t.body.skills??[]).filter(r=>r.executionMode==="auto"),agents:(t.body.agents??[]).map(r=>({...r,learnedMemories:r.learnedMemories??[]})),agentTeams:(t.body.agentTeams??[]).map(r=>({...r,linkedWorkflows:r.linkedWorkflows??[]})),commands:t.body.commands??[],resources:t.body.resources??[],workflows:t.body.workflows??[],mcpServers:t.body.mcpServers??[],guardrails:t.body.guardrails??[],policyGuardrails:t.body.policyGuardrails??[],foundational:{text:t.body.foundational?.text??""},teamMemoryEnabled:t.body.teamMemoryEnabled??!0,repoMemoryEnabled:t.body.repoMemoryEnabled??!0,agentMemoryEnabled:t.body.agentMemoryEnabled??!0,modelFamilies:ze(t.body.modelFamilies)}}var ar=["PRIORITY RULE: The user's request always takes priority over the team memories","MORE MEMORIES (titles only"];function xt(e){let t=e.foundational.text??"",n=ar.map(r=>t.indexOf(r)).filter(r=>r>=0).reduce((r,o)=>Math.min(r,o),Number.POSITIVE_INFINITY);return{...e,foundational:{...e.foundational,text:Number.isFinite(n)?t.slice(0,n).trimEnd():t},agents:e.agents.map(r=>({...r,learnedMemories:[]})),teamMemoryEnabled:!1,repoMemoryEnabled:!1,agentMemoryEnabled:!1}}async function $t(e,t,n=!0){if(_)return!0;try{return(await _t(e,"/api/prompt/inspector",{ide:!0,platform:"claude-code",llm_model:"claude",x_session_request_id:t,notify_on_checkpoint:n,enable_session_files:!1},{"x-session-request-id":t})).ok}catch{return!1}}import{mkdirSync as oo,writeFileSync as so,chmodSync as io}from"node:fs";import{dirname as mn,join as gn}from"node:path";function U(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,64)||"skill"}function lr(e){return`${(e.description??e.name).trim().replace(/\.$/,"")}.`}function cr(e){return`# ${e.name} (SuperClawd-managed)
3
+ var Ze=["opus","fable","sonnet","haiku"],Jn={opus:"claude-opus-5-5",fable:"claude-fable-5-1",sonnet:"claude-sonnet-5-5",haiku:"claude-haiku-5-5"},qn=/^claude-(opus|fable|sonnet|haiku)-latest$/,Vn=/^claude-[a-z0-9][a-z0-9.-]{0,80}(\[1m\])?$/,zn=/^claude-(opus|fable|sonnet|haiku)-\d[\w.-]*(\[1m\])?$/i;function ie(e){let t=e.trim().toLowerCase(),n=qn.exec(t);return n?n[1]:Ze.includes(t)?t:null}function et(e){let t={};if(!e||typeof e!="object")return t;for(let n of Ze){let r=e[n];typeof r=="string"&&Vn.test(r)&&(t[n]=r)}return t}function ae(e,t={},n={}){let r=(e??"").trim();if(!r||r==="default")return null;let o=n.pinnedToFamily?zn.exec(r):null,s=o?o[1].toLowerCase():ie(r);return s?t[s]??Jn[s]:r}import{homedir as Xn}from"node:os";import{join as ce}from"node:path";import{randomBytes as Qn}from"node:crypto";import{readFileSync as Zn,writeFileSync as tt,mkdirSync as nt,chmodSync as er,existsSync as rt}from"node:fs";var Z=(process.env.SUPERCLAWD_BACKEND||"real").toLowerCase(),A=Z==="mock",V=process.env.SUPERCLAWD_MCP_API_URL||"https://mcp-api.superclawd.com",ue=process.env.SUPERCLAWD_API_URL||"https://api.superclawd.com",T=process.env.SUPERCLAWD_HOME||ce(Xn(),".superclawd"),de=ce(T,"sessions"),le=ce(T,"config.json");function tr(e){if(!e||typeof e!="object")return{};let t=e,n=t.credentials??{...typeof t.keyId=="string"?{keyId:t.keyId}:{},...typeof t.secret=="string"?{secret:t.secret}:{},...typeof t.workspace=="string"?{workspace:t.workspace}:{}},r=t.preferences??{...typeof t.skipPermissions=="boolean"?{skipPermissions:t.skipPermissions}:{},...typeof t.notifications=="boolean"?{notifications:t.notifications}:{},...typeof t.chooseWorkspaceAtStartup=="boolean"?{chooseWorkspaceAtStartup:t.chooseWorkspaceAtStartup}:{},...typeof t.experimental=="boolean"?{experimental:t.experimental}:{}},o={};return Object.keys(n).length&&(o.credentials=n),Object.keys(r).length&&(o.preferences=r),typeof t.machineId=="string"&&(o.machineId=t.machineId),o}function ot(){let e=I()??{};if(e.machineId)return e.machineId;let t=Qn(16).toString("hex");return j({...e,machineId:t}),t}function I(){try{return tr(JSON.parse(Zn(le,"utf8")))}catch{return null}}function j(e){nt(T,{recursive:!0}),tt(le,`${JSON.stringify(e,null,2)}
4
+ `,{mode:384});try{er(le,384)}catch{}}function st(){return I()?.preferences?.skipPermissions===!0}function nr(){return I()?.preferences?.notifications===!0}function it(){return I()?.preferences?.chooseWorkspaceAtStartup!==!1}function Ae(e){let t=I()??{};j({...t,credentials:{...t.credentials,workspace:e}})}function pe(){let e=I();e?.credentials?.workspace&&j({...e,credentials:{...e.credentials,workspace:""}})}function at(){return I()?.preferences?.experimental===!0}function lt(){return I()?.preferences?.keepAwake===!0}function ct(){return I()?.preferences?.privateMemory!==!1}function ut(){return I()?.preferences?.pipelinesMcp===!0}function dt(e){return ce(e,"config.json")}function rr(e,t){try{nt(e,{recursive:!0}),tt(dt(e),`${JSON.stringify(t,null,2)}
5
+ `)}catch{}}function pt(e,t,n=!1){rt(dt(e))||rr(e,{notifications:n?!1:nr(),...t?{workspace:t}:{}})}function ft(){rt(le)||j({credentials:{keyId:"",secret:"",workspace:""},preferences:{notifications:!1,skipPermissions:!1,chooseWorkspaceAtStartup:!0,privateMemory:!0}})}var mt=1e3*60*60*24*3;function gt(){if(A)return{ok:!0,session:{keyId:process.env.SUPERCLAWD_MCP_KEY||"mock-key",secret:process.env.SUPERCLAWD_MCP_SECRET||"mock-secret",workspace:process.env.SUPERCLAWD_MCP_WORKSPACE||"mock-workspace",apiUrl:V}};let e=I()?.credentials??{},t=process.env.SUPERCLAWD_MCP_KEY||e.keyId,n=process.env.SUPERCLAWD_MCP_SECRET||e.secret,r=process.env.SUPERCLAWD_MCP_WORKSPACE||e.workspace||"";return!t||!n?{ok:!1,error:"Not authenticated. Run `superclawd login` (or set SUPERCLAWD_MCP_KEY + SUPERCLAWD_MCP_SECRET)."}:{ok:!0,session:{keyId:t,secret:n,workspace:r,apiUrl:V}}}var or="https://openrouter.ai/api",ht=new Set(["~anthropic/claude-opus-latest","~anthropic/claude-sonnet-latest","~anthropic/claude-haiku-latest","~anthropic/claude-fable-latest","~deepseek/deepseek-flash-latest","~google/gemini-flash-latest","~z-ai/glm-flash-latest","~moonshotai/kimi-latest","~x-ai/grok-latest"]),St=/^~([a-z0-9][a-z0-9-]{0,40})\/[a-z0-9][a-z0-9.-]{0,80}-latest$/,sr=new Set(["unbiased","openrouter"]);function Me(e){let t=St.exec((e??"").trim());return!!t&&!sr.has(t[1])}var ir={anthropic:"~anthropic/claude-haiku-latest",openai:"~openai/gpt-mini-latest",google:"~google/gemini-flash-latest",deepseek:"~deepseek/deepseek-flash-latest","z-ai":"~z-ai/glm-flash-latest"};function ar(e){let t=St.exec(e)?.[1];return t&&ir[t]||e}function wt(e){return`~anthropic/claude-${e}-latest`}function yt(e){let t=(e.model??"").trim(),n=null;if(Me(t))n=t;else if(e.agent?.vendor==="openrouter"&&Me(e.agent.model)){let r=t?ie(t):null;n=r?wt(r):e.agent.model.trim()}return n?{kind:"openrouter",model:n,fast:ar(n)}:{kind:"anthropic"}}function kt(e=process.env){let t=e.OPENROUTER_API_KEY?.trim();return t||I()?.credentials?.openrouterKey?.trim()||null}function be(e){let t=I()??{},n={...t.credentials??{}};e?n.openrouterKey=e:delete n.openrouterKey,j({...t,credentials:n})}function Et(e,t,n=process.env){return e.kind!=="openrouter"?{}:{ANTHROPIC_BASE_URL:n.SUPERCLAWD_OPENROUTER_BASE_URL?.trim()||or,ANTHROPIC_AUTH_TOKEN:t,ANTHROPIC_API_KEY:"",ANTHROPIC_DEFAULT_OPUS_MODEL:e.model,ANTHROPIC_DEFAULT_FABLE_MODEL:e.model,ANTHROPIC_DEFAULT_SONNET_MODEL:e.model,ANTHROPIC_DEFAULT_HAIKU_MODEL:e.fast,CLAUDE_CODE_SUBAGENT_MODEL:e.model,SUPERCLAWD_PROVIDER:"openrouter"}}function Rt(e,t,n){if(t.kind==="anthropic")return e.vendor==="anthropic"?n(e.model):null;if(e.vendor==="openrouter")return Me(e.model)?e.model.trim():null;if(e.vendor==="anthropic"){let r=/^claude-(opus|fable|sonnet|haiku)-/i.exec(e.model.trim()),o=ie(e.model)??(r?r[1].toLowerCase():null);return o?wt(o):null}return null}function U(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,64)||"skill"}function lr(e){return`${(e.description??e.name).trim().replace(/\.$/,"")}.`}function cr(e){return`# ${e.name} (SuperClawd-managed)
27
6
 
28
7
  The authoritative instructions for this skill are managed in SuperClawd and
29
8
  are **not** included here. You must fetch them before acting.
@@ -43,7 +22,7 @@ description: "${t}"
43
22
  user-invocable: ${n}
44
23
  ---
45
24
 
46
- `}function Ot(e,t){let n=new Set(t),r=[];for(let o of e){let s=U(o.name),i=2;for(;n.has(s);)s=`${U(o.name)}-${i++}`;n.add(s),r.push({relPath:`skills/${s}/SKILL.md`,content:ur(o)+cr(o)})}return r}var It=`SUPERCLAWD \u2014 operating manual (always in effect):
25
+ `}function _t(e,t){let n=new Set(t),r=[];for(let o of e){let s=U(o.name),i=2;for(;n.has(s);)s=`${U(o.name)}-${i++}`;n.add(s),r.push({relPath:`skills/${s}/SKILL.md`,content:ur(o)+cr(o)})}return r}var vt=`SUPERCLAWD \u2014 operating manual (always in effect):
47
26
  - The ALWAYS rules below are ALREADY LOADED and active for this entire session.
48
27
  Apply them directly to all work. Do NOT call any tool to fetch them \u2014 you
49
28
  already have them in full.
@@ -65,39 +44,60 @@ user-invocable: ${n}
65
44
  \`record_memory\` for it; never claim a preference is "already" a saved convention, or
66
45
  that it "will persist", unless you just recorded it (or confirmed it via
67
46
  \`list_memories\`). A background pass also captures durable facts at session end as a
68
- backstop \u2014 but never rely on it for an explicit request; record that now.`;function Te(e){let t=process.env.SUPERCLAWD_MEMORY_OFF==="1"?It:`${It}
47
+ backstop \u2014 but never rely on it for an explicit request; record that now.`;function xe(e){let t=process.env.SUPERCLAWD_MEMORY_OFF==="1"?vt:`${vt}
69
48
  ${dr}`,n=(e||"").trim();return n&&(t+=`
70
49
 
71
50
  ALWAYS \u2014 foundational rules (already loaded & active for this whole session; apply directly, never fetch):
72
- ${n}`),t}function pr(e){return e.inheritWorkspaceContext!==!1}function fr(e){return Te(e).trim()}function mr(e){return process.env.SUPERCLAWD_MEMORY_OFF==="1"?`You are SuperClawd agent \`${e.id}\`.`:`You are SuperClawd agent \`${e.id}\`. SuperClawd automatically remembers the durable, reusable lessons from your work and applies them on your future runs \u2014 you do NOT need to save anything yourself.`}function gr(e){let t=(e.learnedMemories??[]).filter(r=>r.trim());return t.length===0?"":`AGENT MEMORY \u2014 lessons you've learned in past work (apply by default; a more specific instruction wins):
51
+ ${n}`),t}function pr(e){return e.inheritWorkspaceContext!==!1}function fr(e){return xe(e).trim()}function mr(e){return process.env.SUPERCLAWD_MEMORY_OFF==="1"?`You are SuperClawd agent \`${e.id}\`.`:`You are SuperClawd agent \`${e.id}\`. SuperClawd automatically remembers the durable, reusable lessons from your work and applies them on your future runs \u2014 you do NOT need to save anything yourself.`}function gr(e){let t=(e.learnedMemories??[]).filter(r=>r.trim());return t.length===0?"":`AGENT MEMORY \u2014 lessons you've learned in past work (apply by default; a more specific instruction wins):
73
52
  `+t.map(r=>`- ${r.trim()}`).join(`
74
- `)}function De(e,t){let n=[];if(pr(e)){let o=fr(t);o&&n.push(o)}n.push(mr(e));let r=gr(e);return r&&n.push(r),n.push(e.prompt),n.join(`
53
+ `)}function Oe(e,t){let n=[];if(pr(e)){let o=fr(t);o&&n.push(o)}n.push(mr(e));let r=gr(e);return r&&n.push(r),n.push(e.prompt),n.join(`
75
54
 
76
55
  ---
77
56
 
78
- `)}var X="superclawd",Q="core",de=`mcp__plugin_${X}_${Q}__`,Ue=e=>`${de}${e}`,Lt=`${de}*`,hr=`${X}:`,pe=e=>`${hr}${e}`,Tt=e=>`mcp__plugin_${X}_${e}`;var fe={read:"Read",glob:"Glob",grep:"Grep",edit:"Edit",write:"Write",bash:"Bash",webfetch:"WebFetch",task:"Task"};function wr(e){return e==="allow"||e==="ask"||e===!0}var We=Ue("get_workflow"),Dt=Ue("get_directives"),Sr=e=>pe(e);function yr(e,t=!1,n=!1,r=!1,o=[]){let s=e.tools??{},i=Object.keys(fe).filter(l=>wr(s[l])).map(l=>fe[l]);t&&!i.includes(fe.task)&&i.push(fe.task),n&&!i.includes(We)&&i.push(We),r&&!i.includes(Dt)&&i.push(Dt);for(let l of o)i.includes(l)||i.push(l);return i}function kr(e,t,n=!1,r=!1,o=[],s={}){let i=[`name: ${t}`,`description: "${(e.description??e.name).replace(/"/g,'\\"')}"`],l=e.vendor==="anthropic"?oe(e.model,s,{pinnedToFamily:!0}):null;l&&i.push(`model: ${JSON.stringify(l)}`);let u=(e.skills?.length??0)>0,a=yr(e,n,r,u,o);return a.length&&i.push(`tools: ${a.join(", ")}`),e.skills?.length&&i.push(`skills: ${e.skills.join(", ")}`),`---
79
- ${i.join(`
57
+ `)}var z="superclawd",ee="core",fe=`mcp__plugin_${z}_${ee}__`,Ie=e=>`${fe}${e}`,Pt=`${fe}*`,hr=`${z}:`,me=e=>`${hr}${e}`,Ct=e=>`mcp__plugin_${z}_${e}`;var ge={read:"Read",glob:"Glob",grep:"Grep",edit:"Edit",write:"Write",bash:"Bash",webfetch:"WebFetch",task:"Task"};function Sr(e){return e==="allow"||e==="ask"||e===!0}var Le=Ie("get_workflow"),At=Ie("get_directives"),wr=e=>me(e);function yr(e,t=!1,n=!1,r=!1,o=[]){let s=e.tools??{},i=Object.keys(ge).filter(l=>Sr(s[l])).map(l=>ge[l]);t&&!i.includes(ge.task)&&i.push(ge.task),n&&!i.includes(Le)&&i.push(Le),r&&!i.includes(At)&&i.push(At);for(let l of o)i.includes(l)||i.push(l);return i}function kr(e,t,n=!1,r=!1,o=[],s={},i={kind:"anthropic"}){let l=[`name: ${t}`,`description: "${(e.description??e.name).replace(/"/g,'\\"')}"`],u=Rt(e,i,y=>ae(y,s,{pinnedToFamily:!0}));u&&l.push(`model: ${JSON.stringify(u)}`);let a=(e.skills?.length??0)>0,f=yr(e,n,r,a,o);return f.length&&l.push(`tools: ${f.join(", ")}`),e.skills?.length&&l.push(`skills: ${e.skills.join(", ")}`),`---
58
+ ${l.join(`
80
59
  `)}
81
60
  ---
82
61
 
83
- `}function me(e){let t=new Set;return e.map(n=>{let r=U(n.name),o=2;for(;t.has(r);)r=`${U(n.name)}-${o++}`;return t.add(r),{slug:r,agent:n}})}function Ut(e){let t={};for(let{slug:n,agent:r}of me(e))t[n]=r.id;return t}function Er(e,t){let n=t.map(s=>`- \`${Sr(s.slug)}\` \u2014 ${s.description??s.slug}`).join(`
62
+ `}function X(e){let t=new Set;return e.map(n=>{let r=U(n.name),o=2;for(;t.has(r);)r=`${U(n.name)}-${o++}`;return t.add(r),{slug:r,agent:n}})}function Mt(e){let t={};for(let{slug:n,agent:r}of X(e))t[n]=r.id;return t}function Er(e,t){let n=t.map(s=>`- \`${wr(s.slug)}\` \u2014 ${s.description??s.slug}`).join(`
84
63
  `),r=`## Team Lead \u2014 ${e.name}
85
64
  You lead the **${e.name}** agent team. When given a task, decompose it and **delegate to your team members via the Agent tool** \u2014 then **synthesize** their outputs into one consolidated answer. Delegate using the EXACT agent name shown below (including the \`superclawd:\` prefix). Call the Agent tool and use the result it returns directly \u2014 it returns the member's full output when that member finishes. To run members in parallel, issue multiple Agent calls in a single step; they run concurrently and each returns its own result. Do NOT run members as background agents, and NEVER poll for a "\`.done\`"/completion file or run a \`sleep\`/\`until\` wait loop \u2014 there is no such marker, so it will hang forever; just read the Agent tool's returned result. Your members:
86
65
  ${n}`,o=e.linkedWorkflows??[];if(o.length){let s=o.map(i=>`- ${i.name} (workflowId: ${i.id}) \u2014 ${i.description??""}`).join(`
87
66
  `);r+=`
88
67
 
89
68
  ### Linked workflows
90
- You **MAY** run any of these linked workflows if (and only if) one is relevant to the task \u2014 there is **no obligation** to run any. To run one, call the \`${We}\` MCP tool with its \`workflowId\`, then follow the returned steps in order.
91
- ${s}`}return r}function Wt(e,t={},n=[]){let r=t.foundationalText??"",o=me(e),s=new Map;for(let{slug:u,agent:a}of o)s.set(a.id,{slug:u,description:a.description});let i=new Map,l=new Set;for(let u of n){let a=u.memberAgentIds.map(y=>s.get(y)).filter(y=>!!y),f=Er(u,a),S=i.get(u.leadAgentId)??[];S.push(f),i.set(u.leadAgentId,S),u.linkedWorkflows?.length&&l.add(u.leadAgentId)}return o.map(({slug:u,agent:a})=>{let f=i.get(a.id),S=!!f&&f.length>0,y=l.has(a.id),b=S?[De(a,r),...f].join(`
69
+ You **MAY** run any of these linked workflows if (and only if) one is relevant to the task \u2014 there is **no obligation** to run any. To run one, call the \`${Le}\` MCP tool with its \`workflowId\`, then follow the returned steps in order.
70
+ ${s}`}return r}function bt(e,t={},n=[]){let r=t.foundationalText??"",o=X(e),s=new Map;for(let{slug:u,agent:a}of o)s.set(a.id,{slug:u,description:a.description});let i=new Map,l=new Set;for(let u of n){let a=u.memberAgentIds.map(R=>s.get(R)).filter(R=>!!R),f=Er(u,a),y=i.get(u.leadAgentId)??[];y.push(f),i.set(u.leadAgentId,y),u.linkedWorkflows?.length&&l.add(u.leadAgentId)}return o.map(({slug:u,agent:a})=>{let f=i.get(a.id),y=!!f&&f.length>0,R=l.has(a.id),_=y?[Oe(a,r),...f].join(`
92
71
 
93
72
  ---
94
73
 
95
- `):De(a,r);return{relPath:`agents/${u}.md`,content:kr(a,u,S,y,t.extraTools,t.modelFamilies)+b}})}function Rr(e){return e.arguments.length?e.arguments.map(t=>t.required?`<${t.name}>`:`[${t.name}]`).join(" "):""}function Cr(e){let t=[`description: "${e.description.replace(/"/g,'\\"')}"`],n=Rr(e);return n&&t.push(`argument-hint: ${n}`),`---
74
+ `):Oe(a,r);return{relPath:`agents/${u}.md`,content:kr(a,u,y,R,t.extraTools,t.modelFamilies,t.provider)+_}})}import{spawn as Yn,spawnSync as Vo,execSync as zo}from"node:child_process";import{fileURLToPath as Kn}from"node:url";import{existsSync as Bn,readFileSync as Xo}from"node:fs";import{resolve as Qo,dirname as Zo,join as es}from"node:path";import{spawn as $e}from"node:child_process";var xt=e=>{process.env.SUPERCLAWD_DEBUG&&process.stderr.write(`keep-awake: ${e}
75
+ `)};function Rr(){try{switch(process.platform){case"darwin":return $e("caffeinate",["-i","-w",String(process.pid)],{stdio:"ignore"});case"linux":return $e("systemd-inhibit",["--what=sleep:idle","--who=SuperClawd","--why=SuperClawd session running","--mode=block","cat"],{stdio:["pipe","ignore","ignore"]});case"win32":{let e=[`$p = Add-Type -MemberDefinition '[DllImport("kernel32.dll")] public static extern uint SetThreadExecutionState(uint e);' -Name P -Namespace W -PassThru;`,"$p::SetThreadExecutionState(0x80000000 -bor 0x00000001) | Out-Null;","[void][Console]::In.ReadToEnd();"].join(" ");return $e("powershell",["-NoProfile","-NonInteractive","-Command",e],{stdio:["pipe","ignore","ignore"]})}default:return null}}catch{return null}}function Ot(){let e=Rr();if(!e)return xt(`unsupported platform ${process.platform}`),null;e.unref(),e.on("error",n=>xt(n.message));let t=!1;return{stop(){if(!t){t=!0;try{e.kill()}catch{}}}}}import{spawnSync as It}from"node:child_process";import _r from"node:readline/promises";import{readFileSync as vr,writeFileSync as Pr,mkdirSync as Cr}from"node:fs";import{join as Ar}from"node:path";var Mr=1500,Lt=24*60*60*1e3,$t=Ar(T,"update-state.json");function br(e,t){let n=s=>s.split("-")[0].split(".").map(i=>parseInt(i,10)||0),r=n(e),o=n(t);for(let s=0;s<3;s++){let i=r[s]??0,l=o[s]??0;if(i!==l)return i>l}return!1}async function xr(e){let t=new AbortController,n=setTimeout(()=>t.abort(),Mr);try{let r=await fetch(`https://registry.npmjs.org/${e}`,{headers:{accept:"application/vnd.npm.install-v1+json"},signal:t.signal});return r.ok?(await r.json())["dist-tags"]?.latest??null:null}catch{return null}finally{clearTimeout(n)}}function Tt(){try{return JSON.parse(vr($t,"utf8"))}catch{return{}}}function Or(e){try{Cr(T,{recursive:!0}),Pr($t,JSON.stringify(e,null,2))}catch{}}function Dt(e,t){let n=Tt();n[e]={...n[e],...t},Or(n)}async function Te(e,t,n=Date.now()){let r=Tt()[e]??{},o=r.latest??null;return(!r.checkedAt||n-r.checkedAt>=Lt)&&(o=await xr(e),Dt(e,{latest:o??void 0,checkedAt:n})),!o||!br(o,t)||r.dismissed===o||r.notifiedAt&&n-r.notifiedAt<Lt?null:{latest:o}}function Ir(e){return!(e.includes("-p")||e.includes("--print"))&&!!process.stdin.isTTY}function De(e,t,n,r){process.stderr.write(`\u26A0 ${e} ${t} is outdated (latest ${n}). Update with: ${r}
76
+ `)}async function Ue(e,t,n){let r=_r.createInterface({input:process.stdin,output:process.stderr});try{process.stderr.write(`
77
+ ${e} ${t} is outdated \u2014 ${n} is available.
78
+ `);let o=(await r.question(" [U] Update now (default) [R] Run anyway > ")).trim().toLowerCase();return o==="r"||o==="run"?"run":"update"}finally{r.close()}}function H(e,t){Dt(e,{notifiedAt:Date.now(),...t?{dismissed:t}:{}})}async function Ut(e,t){if(process.env.SUPERCLAWD_NO_UPDATE||process.env.SUPERCLAWD_BACKEND==="mock"||process.env.SUPERCLAWD_UPDATED)return{};let n=await Te("superclawd",e);if(!n)return{};let{latest:r}=n;if(!Ir(t))return De("SuperClawd",e,r,"superclawd update"),H("superclawd"),{};if(await Ue("SuperClawd",e,r)==="run")return H("superclawd",r),{};H("superclawd"),process.stderr.write(`Updating (npm i -g superclawd@latest) \u2026
79
+ `);let s=It("npm install -g superclawd@latest",{stdio:"inherit",shell:!0});if(s.status!==0)return process.stderr.write(`\u2717 Update failed (npm exited ${s.status??"?"}). Running ${e} for now.
80
+ `),{};let i=It("superclawd",t,{stdio:"inherit",env:{...process.env,SUPERCLAWD_UPDATED:"1"}});return i.error?(process.stderr.write(`\u2713 Updated to ${r}. Re-run your command.
81
+ `),{exitCode:0}):{exitCode:i.status??0}}import{randomUUID as Wt}from"node:crypto";function Ft(e){let t={"content-type":"application/json","x-mcp-key-id":e.keyId,"x-mcp-secret":e.secret,"x-workspace-slug":e.workspace,"x-request-id":Wt()};return process.env.SUPERCLAWD_EXPERIMENTAL==="true"&&(t["x-experimental"]="true"),process.env.SUPERCLAWD_MEMORY_OFF==="1"&&(t["x-superclawd-memory"]="off"),t}async function he(e,t,n){let r=`${e.apiUrl}${t}`;if(n){let i=new URLSearchParams;for(let[u,a]of Object.entries(n))a!==void 0&&a!==""&&i.set(u,a);let l=i.toString();l&&(r+=(r.includes("?")?"&":"?")+l)}let o=await fetch(r,{headers:Ft(e)}),s=await o.json().catch(()=>null);return{status:o.status,ok:o.ok,body:s}}async function Nt(e,t,n){try{let r=await fetch(`${e}/api/prompt/workspaces`,{headers:{"content-type":"application/json","x-mcp-key-id":t,"x-mcp-secret":n,"x-request-id":Wt()}}),o=await r.json().catch(()=>null);return{ok:r.ok,status:r.status,workspaces:o?.workspaces??[]}}catch{return{ok:!1,status:0,workspaces:[]}}}async function jt(e,t,n,r={}){let o=await fetch(`${e.apiUrl}${t}`,{method:"POST",headers:{...Ft(e),...r},body:JSON.stringify(n)}),s=await o.json().catch(()=>null);return{status:o.status,ok:o.ok,body:s}}async function We(e,t){e.message("Loading your workspaces\u2026");let n=await Nt(V,t.keyId,t.secret);if(!n.ok||n.workspaces.length===0)return{};let r=new Set(n.workspaces.map(i=>i.slug)),o=t.workspace&&r.has(t.workspace)?t.workspace:void 0;if(t.workspace&&!r.has(t.workspace)&&pe(),n.workspaces.length===1){let i=n.workspaces[0].slug;return i!==o&&Ae(i),{workspace:i}}let s=await e.selectWorkspace(n.workspaces,{currentSlug:o,defaultSlug:o,onSetDefault:i=>Ae(i)});return s===null?{cancelled:!0}:{workspace:s}}async function Fe(e){if(A)return{ok:!0};try{let t=await he(e,"/api/prompt/catalog");return t.ok?{ok:!0}:t.status===401?{ok:!1,kind:"credentials",error:"Your credentials are invalid or expired. Run `superclawd login` again."}:t.status===404?{ok:!1,workspaceInvalid:!0,kind:"workspace",error:"Workspace not found. Run `superclawd` and pick a workspace."}:t.status===403?{ok:!1,workspaceInvalid:!0,kind:"workspace",error:"You are not a member of this workspace."}:t.status===502||t.status===503||t.status===504?{ok:!1,kind:"unreachable",error:`SuperClawd backend is unreachable or starting up (HTTP ${t.status}). Try again in a moment.`}:{ok:!1,kind:"other",error:`Auth check failed (HTTP ${t.status}).`}}catch(t){return{ok:!1,kind:"unreachable",error:`Cannot reach SuperClawd backend (${String(t)}).`}}}var Ne=[{id:"skill-backend-001",name:"backend-api-conventions",action:"code",executionMode:"auto",description:"writing, creating, modifying, or reviewing backend API code \u2014 HTTP endpoints, routes, controllers, request handlers, or server-side validation and security",categories:[{name:"endpoint-design",instructions:["Name routes with plural nouns and kebab-case (e.g. /user-profiles).","Return RFC-7807 problem+json on errors, never bare strings.","Validate and sanitize every request body against a schema before use."]},{name:"security",instructions:["Use parameterized queries only; never string-concatenate SQL.","Rate-limit auth endpoints to 5 requests/minute per IP."]}]},{id:"skill-testing-001",name:"testing-standards",action:"test",executionMode:"auto",description:"writing or updating automated tests \u2014 unit tests, integration tests, test files, assertions, mocks, or test coverage",categories:[{name:"unit",instructions:["One behavioral assertion per test; name tests as should_<expectation>.","Mock only at process boundaries (network, fs, clock)."]}]},{id:"skill-always-001",name:"repo-foundations",action:"behave",executionMode:"always",description:"foundational rules that always apply in this repository",categories:[{name:"house-rules",instructions:["Every source file must start with a one-line header comment describing its purpose.","Prefer clarity over cleverness; match the surrounding code's style."]}]}];var Gt=[{id:"guardrail-no-rm-rf",match:{tools:["Bash"],commandPatterns:["\\brm\\s+-rf\\b","\\brm\\s+-fr\\b"]},action:"deny",message:"Destructive 'rm -rf' is blocked by a workspace guardrail. Remove paths explicitly and deliberately instead."},{id:"guardrail-payments-edits",match:{tools:["Edit","Write","MultiEdit","NotebookEdit"],pathGlobs:["**/payments/**"]},action:"ask",message:"Edits under payments/ touch billing-critical code \u2014 confirm before proceeding (workspace guardrail)."}],Kt=[{id:"agent-reviewer-001",name:"code-reviewer",description:"Reviews a diff for correctness and security issues. Use after writing code.",vendor:"anthropic",model:"claude-sonnet-4-6",prompt:"You are a meticulous senior code reviewer. Examine the change for correctness, security, and clarity. Report concrete findings with file:line; do not rewrite the code unless asked.",mode:"subagent",tools:{read:"allow",glob:"allow",grep:"allow",edit:"deny",write:"deny",bash:"deny",webfetch:"deny",task:"deny"},steps:null,inheritWorkspaceContext:!1},{id:"agent-orchestrator-001",name:"orchestrator",description:"Coordinates multi-step coding tasks and delegates focused work. Use when a task spans several files or steps.",vendor:"anthropic",model:"claude-sonnet-4-6",prompt:"You are an orchestrator. Break the request into concrete steps, perform the edits directly, and keep changes minimal and focused on what was asked.",mode:"subagent",tools:{read:"allow",glob:"allow",grep:"allow",edit:"allow",write:"allow",bash:"deny",webfetch:"deny",task:"allow"},steps:null,inheritWorkspaceContext:!0}],Yt=[{name:"ship-checklist",description:"Run this team's pre-merge checklist.",arguments:[{name:"scope",description:"what is being shipped",required:!1}],content:`Pre-merge checklist for $ARGUMENTS:
82
+ 1. Tests pass and cover new behavior.
83
+ 2. No secrets or debug logging left in.
84
+ 3. Public APIs documented.
85
+ 4. Changelog updated.`}],Bt=[{name:"error-codes",description:"Canonical list of this platform's error codes.",content:`E1001 invalid_input
86
+ E1002 unauthorized
87
+ E1003 rate_limited
88
+ E2001 upstream_unavailable`}];var Ht=[{id:"workflow-deploy-001",name:"production-deploy",description:"deploying to production, cutting a release, or shipping to prod",itemCount:6,content:`Production deploy workflow:
89
+ 1. Confirm CI is green on main.
90
+ 2. Bump version + update changelog.
91
+ 3. Tag the release.
92
+ 4. Run db migrations.
93
+ 5. Deploy and watch error rate for 10m.
94
+ 6. Announce in #releases.`}];function Lr(){let e=Ne.filter(n=>n.executionMode==="auto").map(n=>({id:n.id,name:n.name,action:n.action,executionMode:n.executionMode,description:n.description,userInvocable:n.userInvocable})),t=Ne.filter(n=>n.executionMode==="always").flatMap(n=>n.categories.flatMap(r=>r.instructions)).map((n,r)=>`${r+1}. ${n}`).join(`
95
+ `);return{skills:e,agents:Kt,agentTeams:[],commands:Yt.map(({name:n,description:r,arguments:o,team:s})=>({name:n,description:r,arguments:o,team:s??null})),resources:Bt.map(({name:n,description:r})=>({name:n,description:r})),workflows:Ht.map(({id:n,name:r,description:o})=>({id:n,name:r,description:o})),mcpServers:[],guardrails:Gt,policyGuardrails:[],foundational:{text:t},teamMemoryEnabled:!0,repoMemoryEnabled:!0,agentMemoryEnabled:!0}}async function je(e){if(A)return Lr();let t=await he(e,"/api/prompt/catalog",{repoFingerprint:process.env.SUPERCLAWD_REPO_FINGERPRINT});if(!t.ok||!t.body)throw new Error(`Failed to fetch catalog (HTTP ${t.status}).`);return{skills:(t.body.skills??[]).filter(r=>r.executionMode==="auto"),agents:(t.body.agents??[]).map(r=>({...r,learnedMemories:r.learnedMemories??[]})),agentTeams:(t.body.agentTeams??[]).map(r=>({...r,linkedWorkflows:r.linkedWorkflows??[]})),commands:t.body.commands??[],resources:t.body.resources??[],workflows:t.body.workflows??[],mcpServers:t.body.mcpServers??[],guardrails:t.body.guardrails??[],policyGuardrails:t.body.policyGuardrails??[],foundational:{text:t.body.foundational?.text??""},teamMemoryEnabled:t.body.teamMemoryEnabled??!0,repoMemoryEnabled:t.body.repoMemoryEnabled??!0,agentMemoryEnabled:t.body.agentMemoryEnabled??!0,modelFamilies:et(t.body.modelFamilies)}}var $r=["PRIORITY RULE: The user's request always takes priority over the team memories","MORE MEMORIES (titles only"];function Jt(e){let t=e.foundational.text??"",n=$r.map(r=>t.indexOf(r)).filter(r=>r>=0).reduce((r,o)=>Math.min(r,o),Number.POSITIVE_INFINITY);return{...e,foundational:{...e.foundational,text:Number.isFinite(n)?t.slice(0,n).trimEnd():t},agents:e.agents.map(r=>({...r,learnedMemories:[]})),teamMemoryEnabled:!1,repoMemoryEnabled:!1,agentMemoryEnabled:!1}}async function qt(e,t,n=!0){if(A)return!0;try{return(await jt(e,"/api/prompt/inspector",{ide:!0,platform:"claude-code",llm_model:"claude",x_session_request_id:t,notify_on_checkpoint:n,enable_session_files:!1},{"x-session-request-id":t})).ok}catch{return!1}}import{mkdirSync as wo,writeFileSync as yo,chmodSync as ko}from"node:fs";import{dirname as vn,join as Pn}from"node:path";function Tr(e){return e.arguments.length?e.arguments.map(t=>t.required?`<${t.name}>`:`[${t.name}]`).join(" "):""}function Dr(e){let t=[`description: "${e.description.replace(/"/g,'\\"')}"`],n=Tr(e);return n&&t.push(`argument-hint: ${n}`),`---
96
96
  ${t.join(`
97
97
  `)}
98
98
  ---
99
99
 
100
- `}function _r(e,t){let n=`This is the SuperClawd command **${e.name}**. Its content is managed in
100
+ `}function Ur(e,t){let n=`This is the SuperClawd command **${e.name}**. Its content is managed in
101
101
  SuperClawd and fetched on use.
102
102
 
103
103
  **REQUIRED \u2014 do this now:**
@@ -107,11 +107,11 @@ SuperClawd and fetched on use.
107
107
 
108
108
  Do not improvise the command from this description.
109
109
  `,r=e.team;if(r&&t.has(r.leadAgentId)){let o=t.get(r.leadAgentId);return`## Team: ${r.name}
110
- Run this command WITH the **${r.name}** agent team. Delegate the task to its lead \`${pe(o)}\` via the Agent tool \u2014 the lead will decompose it, fan out to its members, and synthesize \u2014 then return the lead's result. Do the work through the team rather than alone. Call the Agent tool and use the result it returns directly; do NOT run the lead as a background agent or poll for a "\`.done\`"/completion file (there is none \u2014 it will hang).
110
+ Run this command WITH the **${r.name}** agent team. Delegate the task to its lead \`${me(o)}\` via the Agent tool \u2014 the lead will decompose it, fan out to its members, and synthesize \u2014 then return the lead's result. Do the work through the team rather than alone. Call the Agent tool and use the result it returns directly; do NOT run the lead as a background agent or poll for a "\`.done\`"/completion file (there is none \u2014 it will hang).
111
111
 
112
112
  ---
113
113
 
114
- `+n}return n}function Ft(e,t){let n=new Map(me(t).map(({slug:s,agent:i})=>[i.id,s])),r=new Set,o=[];for(let s of e){let i=U(s.name),l=2;for(;r.has(i);)i=`${U(s.name)}-${l++}`;r.add(i),o.push({relPath:`commands/${i}.md`,content:Cr(s)+_r(s,n)})}return o}function vr(e,t){let n=e.mode==="reference",r=(e.description??e.name).trim().replace(/\.$/,""),o=(n?`${r}. Read the '${e.name}' SuperClawd reference workflow to understand how this works (do not execute it).`:`${r}. Runs the '${e.name}' SuperClawd workflow.`).replace(/"/g,'\\"'),s=n?`# ${e.name} (SuperClawd workflow \u2014 REFERENCE)
114
+ `+n}return n}function Vt(e,t){let n=new Map(X(t).map(({slug:s,agent:i})=>[i.id,s])),r=new Set,o=[];for(let s of e){let i=U(s.name),l=2;for(;r.has(i);)i=`${U(s.name)}-${l++}`;r.add(i),o.push({relPath:`commands/${i}.md`,content:Dr(s)+Ur(s,n)})}return o}function Wr(e,t){let n=e.mode==="reference",r=(e.description??e.name).trim().replace(/\.$/,""),o=(n?`${r}. Read the '${e.name}' SuperClawd reference workflow to understand how this works (do not execute it).`:`${r}. Runs the '${e.name}' SuperClawd workflow.`).replace(/"/g,'\\"'),s=n?`# ${e.name} (SuperClawd workflow \u2014 REFERENCE)
115
115
 
116
116
  This is a **structured explanation** of how a system or flow works \u2014 NOT a procedure to run.
117
117
 
@@ -135,7 +135,7 @@ description: "${o}"
135
135
  user-invocable: false
136
136
  ---
137
137
 
138
- ${s}`}}function Pr(e,t){let n=e.mode==="reference",r=n?`Read the SuperClawd reference workflow **${e.name}** to understand how it works:
138
+ ${s}`}}function Fr(e,t){let n=e.mode==="reference",r=n?`Read the SuperClawd reference workflow **${e.name}** to understand how it works:
139
139
 
140
140
  1. Call the \`get_workflow\` tool with \`workflowId\`: \`${e.id}\`.
141
141
  2. **Read** the returned steps to understand the flow \u2014 do not execute them.
@@ -147,7 +147,7 @@ ${s}`}}function Pr(e,t){let n=e.mode==="reference",r=n?`Read the SuperClawd refe
147
147
  description: "${o}"
148
148
  ---
149
149
 
150
- ${r}`}}function Nt(e){let t=new Set,n=[];for(let r of e){let o=U(r.name),s=2;for(;t.has(o);)o=`${U(r.name)}-${s++}`;t.add(o),n.push(vr(r,o)),r.userInvocable===!0&&n.push(Pr(r,o))}return n}var Mr=`---
150
+ ${r}`}}function zt(e){let t=new Set,n=[];for(let r of e){let o=U(r.name),s=2;for(;t.has(o);)o=`${U(r.name)}-${s++}`;t.add(o),n.push(Wr(r,o)),r.userInvocable===!0&&n.push(Fr(r,o))}return n}var Nr=`---
151
151
  description: Audit this session against your active SuperClawd directives.
152
152
  ---
153
153
 
@@ -159,7 +159,7 @@ Audit the work done so far in this session against your active SuperClawd direct
159
159
  4. Flag anything relevant you may have skipped \u2014 and if so, fetch and apply/run it now.
160
160
 
161
161
  Be concise; this is a compliance check, not a code review.
162
- `,br=`---
162
+ `,jr=`---
163
163
  description: Show SuperClawd service status, workspace info, and credit balance.
164
164
  ---
165
165
 
@@ -170,14 +170,14 @@ Give me a concise SuperClawd status overview. Call these tools and summarize the
170
170
  3. \`check_balance\` \u2014 current credit balance.
171
171
 
172
172
  Present it as a tidy summary; do not take any other action.
173
- `,Ar=`---
173
+ `,Gr=`---
174
174
  description: Toggle SuperClawd notifications for this session.
175
175
  ---
176
176
 
177
177
  The user wants to flip SuperClawd notifications for this session.
178
178
 
179
179
  Call the \`notifications\` tool (no arguments \u2014 it toggles the current on/off state), then report the resulting state in one short line. Do not take any other action.
180
- `,xr=`---
180
+ `,Kr=`---
181
181
  description: Apply maximum extended thinking (ultrathink) to the work at hand.
182
182
  argument-hint: "[task or question]"
183
183
  ---
@@ -185,65 +185,65 @@ argument-hint: "[task or question]"
185
185
  To perform this work, please ultrathink \u2014 reason as deeply and carefully as you can before acting. Surface edge cases, weigh alternatives, and check your assumptions.
186
186
 
187
187
  $ARGUMENTS
188
- `;function jt(){return[{relPath:"commands/audit-work.md",content:Mr},{relPath:"commands/status.md",content:br},{relPath:"commands/notifications.md",content:Ar},{relPath:"commands/ultrathink.md",content:xr}]}import{existsSync as $r,readFileSync as Or,writeFileSync as Ir,chmodSync as Lr,mkdirSync as Tr}from"node:fs";import{execSync as Dr}from"node:child_process";import{dirname as Ur,join as Gt}from"node:path";function Bt(e){let t="hooks/foundational-fallback.txt",n=`${e.pluginDir}/${t}`,r=`${e.pluginDir}/hooks/reminder-context.txt`,o=`${e.pluginDir}/stepcount`,s=w=>({type:"command",command:`node "${e.helperPath}" ${w}`}),i=w=>({...s(w),async:!0}),l={SessionStart:[{hooks:[s(`foundational "${n}" SessionStart`)]}],Notification:[{matcher:"permission_prompt|elicitation_dialog|elicitation_complete|elicitation_response|auth_success",hooks:[i(`notify-local attention "${e.launchId}"`),i(`notify attention "${e.launchId}"`)]}],Stop:[{hooks:[i(`notify-local stop "${e.launchId}"`)]}],SessionEnd:[{hooks:[i(`notify completion "${e.launchId}"`)]}]},u=[{relPath:t,content:e.foundational.text??""}],a=Number(process.env.SUPERCLAWD_REMIND_EVERY??8),f=process.env.SUPERCLAWD_REPO_MEMORY!=="0",S=process.env.SUPERCLAWD_AGENT_MEMORY!=="0",y=process.env.SUPERCLAWD_PRIVATE_MEMORY==="1",b=process.env.SUPERCLAWD_NO_CAPTURE==="1",P=!b&&!!process.env.SUPERCLAWD_REPO_FINGERPRINT&&(f||y),E=(e.foundational.text??"").trim(),h=E?`REMINDER \u2014 these SuperClawd always-rules remain in effect:
189
- ${E}`:"";if(a>0&&h&&(l.PostToolUse=[{matcher:"*",hooks:[s(`remind "${r}" "${o}"`)]}],u.push({relPath:"hooks/reminder-context.txt",content:h})),P){let w={hooks:[i(`capture "${e.launchId}"`)]};l.Stop.push(w),l.SessionEnd.push(w)}let d=e.agents??[];if(!b&&S&&d.length){let w="hooks/agent-map.json",m=`${e.pluginDir}/${w}`;u.push({relPath:w,content:JSON.stringify(Ut(d))}),l.SubagentStop=[{hooks:[i(`capture-agent "${m}" "${e.launchId}"`)]}]}let c=[];if(e.gate&&c.push({matcher:`${de}.*`,hooks:[s("gate")]}),e.guardrails?.length){let w="hooks/guardrails.json",m=`${e.pluginDir}/${w}`;u.push({relPath:w,content:JSON.stringify(e.guardrails,null,2)}),c.push({matcher:"*",hooks:[s(`guardrails "${m}"`)]})}if(e.policyGuardrails?.length){let w="hooks/policy-guardrails.json",m=`${e.pluginDir}/${w}`;u.push({relPath:w,content:JSON.stringify(e.policyGuardrails,null,2)}),c.push({matcher:"Bash",hooks:[s(`policy "${m}"`)]})}return process.env.SUPERCLAWD_AUTO_RETRIEVE!=="0"&&(l.UserPromptSubmit=[{hooks:[s("retrieve prompt")]}],c.push({matcher:"Read",hooks:[s("retrieve file")]})),c.length&&(l.PreToolUse=c),u.push({relPath:"hooks/hooks.json",content:JSON.stringify({hooks:l},null,2)}),u}var Yt="# superclawd-report-commit";function Kt(e){return`'${String(e).replace(/'/g,"'\\''")}'`}function Ht(e){let{cwd:t,helperPath:n,env:r}=e,o="";try{let a=Dr("git rev-parse --git-path hooks",{cwd:t,encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim();a&&(o=a.startsWith("/")?a:Gt(t,a))}catch{return{installed:!1,reason:"not a git repo"}}if(!o)return{installed:!1,reason:"no hooks dir"};let s=Gt(o,"post-commit");if($r(s)){let a="";try{a=Or(s,"utf8")}catch{return{installed:!1,reason:"post-commit unreadable; skipped"}}if(!a.includes(Yt))return{installed:!1,reason:"existing user post-commit hook; skipped"}}let l=["SUPERCLAWD_BACKEND","SUPERCLAWD_MCP_API_URL","SUPERCLAWD_REPO_FINGERPRINT","SUPERCLAWD_MCP_KEY","SUPERCLAWD_MCP_SECRET","SUPERCLAWD_MCP_WORKSPACE","NODE_EXTRA_CA_CERTS","SUPERCLAWD_HOME","SUPERCLAWD_CLAUDE_BIN","SUPERCLAWD_POLICY_MODEL"].filter(a=>r[a]!==void 0&&r[a]!=="").map(a=>`export ${a}=${Kt(r[a])}`).join(`
188
+ `;function Xt(){return[{relPath:"commands/audit-work.md",content:Nr},{relPath:"commands/status.md",content:jr},{relPath:"commands/notifications.md",content:Gr},{relPath:"commands/ultrathink.md",content:Kr}]}import{existsSync as Yr,readFileSync as Br,writeFileSync as Hr,chmodSync as Jr,mkdirSync as qr}from"node:fs";import{execSync as Vr}from"node:child_process";import{dirname as zr,join as Qt}from"node:path";function tn(e){let t="hooks/foundational-fallback.txt",n=`${e.pluginDir}/${t}`,r=`${e.pluginDir}/hooks/reminder-context.txt`,o=`${e.pluginDir}/stepcount`,s=m=>({type:"command",command:`node "${e.helperPath}" ${m}`}),i=m=>({...s(m),async:!0}),l={SessionStart:[{hooks:[s(`foundational "${n}" SessionStart`)]}],Notification:[{matcher:"permission_prompt|elicitation_dialog|elicitation_complete|elicitation_response|auth_success",hooks:[i(`notify-local attention "${e.launchId}"`),i(`notify attention "${e.launchId}"`)]}],Stop:[{hooks:[i(`notify-local stop "${e.launchId}"`)]}],SessionEnd:[{hooks:[i(`notify completion "${e.launchId}"`)]}]},u=[{relPath:t,content:e.foundational.text??""}],a=Number(process.env.SUPERCLAWD_REMIND_EVERY??8),f=process.env.SUPERCLAWD_REPO_MEMORY!=="0",y=process.env.SUPERCLAWD_AGENT_MEMORY!=="0",R=process.env.SUPERCLAWD_PRIVATE_MEMORY==="1",_=process.env.SUPERCLAWD_NO_CAPTURE==="1",v=!_&&!!process.env.SUPERCLAWD_REPO_FINGERPRINT&&(f||R),w=(e.foundational.text??"").trim(),h=w?`REMINDER \u2014 these SuperClawd always-rules remain in effect:
189
+ ${w}`:"";if(a>0&&h&&(l.PostToolUse=[{matcher:"*",hooks:[s(`remind "${r}" "${o}"`)]}],u.push({relPath:"hooks/reminder-context.txt",content:h})),v){let m={hooks:[i(`capture "${e.launchId}"`)]};l.Stop.push(m),l.SessionEnd.push(m)}let d=e.agents??[];if(!_&&y&&d.length){let m="hooks/agent-map.json",c=`${e.pluginDir}/${m}`;u.push({relPath:m,content:JSON.stringify(Mt(d))}),l.SubagentStop=[{hooks:[i(`capture-agent "${c}" "${e.launchId}"`)]}]}let g=[];if(e.gate&&g.push({matcher:`${fe}.*`,hooks:[s("gate")]}),e.guardrails?.length){let m="hooks/guardrails.json",c=`${e.pluginDir}/${m}`;u.push({relPath:m,content:JSON.stringify(e.guardrails,null,2)}),g.push({matcher:"*",hooks:[s(`guardrails "${c}"`)]})}if(e.policyGuardrails?.length){let m="hooks/policy-guardrails.json",c=`${e.pluginDir}/${m}`;u.push({relPath:m,content:JSON.stringify(e.policyGuardrails,null,2)}),g.push({matcher:"Bash",hooks:[s(`policy "${c}"`)]})}return process.env.SUPERCLAWD_AUTO_RETRIEVE!=="0"&&(l.UserPromptSubmit=[{hooks:[s("retrieve prompt")]}],g.push({matcher:"Read",hooks:[s("retrieve file")]})),g.length&&(l.PreToolUse=g),u.push({relPath:"hooks/hooks.json",content:JSON.stringify({hooks:l},null,2)}),u}var Zt="# superclawd-report-commit";function en(e){return`'${String(e).replace(/'/g,"'\\''")}'`}function nn(e){let{cwd:t,helperPath:n,env:r}=e,o="";try{let a=Vr("git rev-parse --git-path hooks",{cwd:t,encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim();a&&(o=a.startsWith("/")?a:Qt(t,a))}catch{return{installed:!1,reason:"not a git repo"}}if(!o)return{installed:!1,reason:"no hooks dir"};let s=Qt(o,"post-commit");if(Yr(s)){let a="";try{a=Br(s,"utf8")}catch{return{installed:!1,reason:"post-commit unreadable; skipped"}}if(!a.includes(Zt))return{installed:!1,reason:"existing user post-commit hook; skipped"}}let l=["SUPERCLAWD_BACKEND","SUPERCLAWD_MCP_API_URL","SUPERCLAWD_REPO_FINGERPRINT","SUPERCLAWD_MCP_KEY","SUPERCLAWD_MCP_SECRET","SUPERCLAWD_MCP_WORKSPACE","NODE_EXTRA_CA_CERTS","SUPERCLAWD_HOME","SUPERCLAWD_CLAUDE_BIN","SUPERCLAWD_POLICY_MODEL"].filter(a=>r[a]!==void 0&&r[a]!=="").map(a=>`export ${a}=${en(r[a])}`).join(`
190
190
  `),u=`#!/bin/sh
191
- ${Yt}
191
+ ${Zt}
192
192
  # Auto-generated by superclawd \u2014 reports Learned Memory staleness after each
193
193
  # commit. Safe to delete; superclawd will not recreate it if you replace it.
194
194
  ${l}
195
- node ${Kt(n)} report-commit >/dev/null 2>&1 &
196
- `;try{Tr(Ur(s),{recursive:!0}),Ir(s,u),Lr(s,493)}catch(a){return{installed:!1,reason:`write failed: ${String(a)}`}}return{installed:!0,reason:"installed"}}import{spawn as Fe,spawnSync as Zt}from"node:child_process";import O from"node:fs";import $ from"node:path";import{fileURLToPath as Wr}from"node:url";import{createRequire as Fr}from"node:module";var K="@superclawd-ai/pipelines",je=$.join(T,"pipelines.pid"),Ge=$.join(T,"pipelines.port"),qt=$.join(T,"pipelines.log"),Nr=$.join(T,"pipelines-mcp.json"),en=63210,tn=2e4;function jr(e){let t="",n=null,r=!1;for(let o=0;o<e.length;o++){let s=e[o],i=e[o+1];if(s==="--port"||s==="-p"){let l=Number(i);i&&Number.isInteger(l)&&l>0&&l<65536&&(n=l,o++)}else s==="-d"||s==="--detach"?r=!0:!s.startsWith("-")&&!t&&(t=s)}return{sub:t,port:n,detach:r}}function Ne(e){try{return process.kill(e,0),!0}catch(t){return t.code==="EPERM"}}function Jt(e){try{let t=Number(O.readFileSync(e,"utf8").trim());return Number.isInteger(t)&&t>0?t:null}catch{return null}}function ge(){let e=Jt(je),t=Jt(Ge);return{pid:e,port:t,alive:e!==null&&Ne(e)}}function Gr(){try{let e=JSON.parse(O.readFileSync(Nr,"utf8"));return e&&typeof e=="object"?e:null}catch{return null}}function nn(){if(!at())return null;let e=Gr(),t=e?.port??en,n=e?.token;return{name:"pipelines",type:"http",url:`http://127.0.0.1:${t}/mcp`,...n?{headers:{Authorization:`Bearer ${n}`}}:{}}}function Vt(e,t){O.mkdirSync(T,{recursive:!0}),O.writeFileSync(je,String(e)),O.writeFileSync(Ge,String(t))}function Z(){for(let e of[je,Ge])try{O.unlinkSync(e)}catch{}}function rn(){let e=process.env.SUPERCLAWD_PIPELINES_DIR;if(e)return O.existsSync(e)?e:null;let t=$.dirname(Wr(import.meta.url));for(let n=0;n<8;n++){let r=$.join(t,"apps","pipelines");if(O.existsSync($.join(r,"server","index.ts"))||O.existsSync($.join(r,"dist-server","index.mjs")))return r;let o=$.dirname(t);if(o===t)break;t=o}try{let n=Fr(import.meta.url),r=$.dirname(n.resolve("@superclawd-ai/pipelines/package.json"));if(O.existsSync($.join(r,"dist-server","index.mjs")))return r}catch{}return null}function Yr(e){let t=[$.join(e,"node_modules",".bin","tsx"),$.join(e,"..","..","node_modules",".bin","tsx")];for(let n of t)if(O.existsSync(n))return n;return"tsx"}function Kr(){let e=rn();if(!e)return null;let t=$.join(e,"dist-server","index.mjs");if(O.existsSync(t))return{cmd:process.execPath,args:[t],cwd:e};let n=$.join(e,"server","index.ts");return O.existsSync(n)?{cmd:Yr(e),args:[n],cwd:e}:null}async function Xt(e,t=tn){let n=Date.now()+t;for(;Date.now()<n;){if(await on(e))return!0;await new Promise(r=>setTimeout(r,250))}return!1}async function on(e){let t=new AbortController,n=setTimeout(()=>t.abort(),1e3);try{return(await fetch(`http://localhost:${e}/api/session`,{signal:t.signal})).ok}catch{return!1}finally{clearTimeout(n)}}function zt(e){let t=process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open";try{Fe(t,[e],{stdio:"ignore",detached:!0,shell:process.platform==="win32"}).unref()}catch{}}function D(e){process.stdout.write(e+`
195
+ node ${en(n)} report-commit >/dev/null 2>&1 &
196
+ `;try{qr(zr(s),{recursive:!0}),Hr(s,u),Jr(s,493)}catch(a){return{installed:!1,reason:`write failed: ${String(a)}`}}return{installed:!0,reason:"installed"}}import{spawn as Ge,spawnSync as un}from"node:child_process";import $ from"node:fs";import L from"node:path";import{fileURLToPath as Xr}from"node:url";import{createRequire as Qr}from"node:module";var Y="@superclawd-ai/pipelines",Ye=L.join(T,"pipelines.pid"),Be=L.join(T,"pipelines.port"),rn=L.join(T,"pipelines.log"),Zr=L.join(T,"pipelines-mcp.json"),dn=63210,pn=2e4;function eo(e){let t="",n=null,r=!1;for(let o=0;o<e.length;o++){let s=e[o],i=e[o+1];if(s==="--port"||s==="-p"){let l=Number(i);i&&Number.isInteger(l)&&l>0&&l<65536&&(n=l,o++)}else s==="-d"||s==="--detach"?r=!0:!s.startsWith("-")&&!t&&(t=s)}return{sub:t,port:n,detach:r}}function Ke(e){try{return process.kill(e,0),!0}catch(t){return t.code==="EPERM"}}function on(e){try{let t=Number($.readFileSync(e,"utf8").trim());return Number.isInteger(t)&&t>0?t:null}catch{return null}}function Se(){let e=on(Ye),t=on(Be);return{pid:e,port:t,alive:e!==null&&Ke(e)}}function to(){try{let e=JSON.parse($.readFileSync(Zr,"utf8"));return e&&typeof e=="object"?e:null}catch{return null}}function fn(){if(!ut())return null;let e=to(),t=e?.port??dn,n=e?.token;return{name:"pipelines",type:"http",url:`http://127.0.0.1:${t}/mcp`,...n?{headers:{Authorization:`Bearer ${n}`}}:{}}}function sn(e,t){$.mkdirSync(T,{recursive:!0}),$.writeFileSync(Ye,String(e)),$.writeFileSync(Be,String(t))}function te(){for(let e of[Ye,Be])try{$.unlinkSync(e)}catch{}}function mn(){let e=process.env.SUPERCLAWD_PIPELINES_DIR;if(e)return $.existsSync(e)?e:null;let t=L.dirname(Xr(import.meta.url));for(let n=0;n<8;n++){let r=L.join(t,"apps","pipelines");if($.existsSync(L.join(r,"server","index.ts"))||$.existsSync(L.join(r,"dist-server","index.mjs")))return r;let o=L.dirname(t);if(o===t)break;t=o}try{let n=Qr(import.meta.url),r=L.dirname(n.resolve("@superclawd-ai/pipelines/package.json"));if($.existsSync(L.join(r,"dist-server","index.mjs")))return r}catch{}return null}function no(e){let t=[L.join(e,"node_modules",".bin","tsx"),L.join(e,"..","..","node_modules",".bin","tsx")];for(let n of t)if($.existsSync(n))return n;return"tsx"}function ro(){let e=mn();if(!e)return null;let t=L.join(e,"dist-server","index.mjs");if($.existsSync(t))return{cmd:process.execPath,args:[t],cwd:e};let n=L.join(e,"server","index.ts");return $.existsSync(n)?{cmd:no(e),args:[n],cwd:e}:null}async function an(e,t=pn){let n=Date.now()+t;for(;Date.now()<n;){if(await gn(e))return!0;await new Promise(r=>setTimeout(r,250))}return!1}async function gn(e){let t=new AbortController,n=setTimeout(()=>t.abort(),1e3);try{return(await fetch(`http://localhost:${e}/api/session`,{signal:t.signal})).ok}catch{return!1}finally{clearTimeout(n)}}function ln(e){let t=process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open";try{Ge(t,[e],{stdio:"ignore",detached:!0,shell:process.platform==="win32"}).unref()}catch{}}function D(e){process.stdout.write(e+`
197
197
  `)}function B(e){process.stderr.write(e+`
198
- `)}async function Br(e){let t=ge(),n=l=>`http://localhost:${l}`;if(t.alive&&t.port)return D(`Pipelines is already running (pid ${t.pid}) at ${n(t.port)}`),e.detach||zt(n(t.port)),0;t.pid&&!t.alive&&Z(),await Vr(!!process.stdin.isTTY&&!e.detach);let r=Kr();if(!r)return B(`\u2717 Couldn't locate the Pipelines app.
199
- Set SUPERCLAWD_PIPELINES_DIR to its directory (the one containing server/index.ts).`),1;let o=e.port??en,s={...process.env,PIPELINES_PORT:String(o)};if(e.detach){O.mkdirSync(T,{recursive:!0});let l=O.openSync(qt,"a"),u=Fe(r.cmd,r.args,{cwd:r.cwd,env:s,detached:!0,stdio:["ignore",l,l]});return u.unref(),u.pid?(Vt(u.pid,o),await Xt(o)?(D(`\u2713 Pipelines started (pid ${u.pid}) at ${n(o)}`),0):(B(`\u2717 Daemon didn't become ready within ${tn/1e3}s. See ${qt}`),1)):(B("\u2717 Failed to spawn the Pipelines daemon."),1)}D(`Starting Pipelines at ${n(o)} \u2026 (Ctrl-C to stop)`);let i=Fe(r.cmd,r.args,{cwd:r.cwd,env:s,stdio:"inherit"});return i.pid&&Vt(i.pid,o),Xt(o).then(l=>{l&&zt(n(o))}),await new Promise(l=>{i.on("error",u=>{B(`\u2717 Could not launch the daemon: ${u.message}`),Z(),l(1)}),i.on("close",u=>{Z(),l(u??0)})})}async function Hr(){let e=ge();if(!e.pid||!e.alive)return D("Pipelines is not running."),Z(),0;let t=n=>{try{process.kill(-e.pid,n)}catch{try{process.kill(e.pid,n)}catch{}}};t("SIGTERM");for(let n=0;n<40&&Ne(e.pid);n++)await new Promise(r=>setTimeout(r,100));return Ne(e.pid)&&t("SIGKILL"),Z(),D("\u2713 Pipelines stopped."),0}async function qr(){let e=ge();if(!e.alive)return D("Pipelines: stopped."),0;let t=e.port?await on(e.port):!1;return D(`Pipelines: running (pid ${e.pid}) on port ${e.port??"?"} \u2014 `+(t?"responding \u2713":"not responding yet")),0}function Jr(e){try{return JSON.parse(O.readFileSync($.join(e,"package.json"),"utf8")).version??null}catch{return null}}async function Vr(e){if(process.env.SUPERCLAWD_NO_UPDATE||process.env.SUPERCLAWD_BACKEND==="mock")return;let t=rn(),n=t?Jr(t):null;if(!n)return;let r=await be(K,n);if(!r)return;let{latest:o}=r;if(!e){Ae("Pipelines",n,o,"superclawd pipelines update"),H(K);return}if(await xe("Pipelines",n,o)==="run"){H(K,o);return}H(K),D(`Updating Pipelines (npm i -g ${K}@latest) \u2026`);let i=Zt(`npm install -g ${K}@latest`,{stdio:"inherit",shell:!0});i.status!==0?B(`\u2717 Update failed (npm exited ${i.status??"?"}). Starting ${n} for now.`):D(`\u2713 Updated to ${o}.`)}function Xr(){if(ge().alive)return B("\u2717 Stop the daemon first: superclawd pipelines stop"),1;D(`Updating Pipelines (npm i -g ${K}@latest) \u2026`);let t=Zt(`npm install -g ${K}@latest`,{stdio:"inherit",shell:!0});return t.status!==0?(B(`\u2717 Update failed (npm exited ${t.status??"?"}).`),t.status??1):(D("\u2713 Updated. Start again with: superclawd pipelines start"),0)}function Qt(){return["superclawd pipelines \u2014 run the local Pipelines app",""," start [--port <n>] [-d] Start the daemon (foreground; -d detaches). Opens the browser."," stop Stop the running daemon."," status Show whether the daemon is running."," update Update the Pipelines app (daemon must be stopped)."].join(`
200
- `)}async function sn(e){let t=jr(e);switch(t.sub){case"start":return Br(t);case"stop":return Hr();case"status":return qr();case"update":return Xr();case"":case"help":return D(Qt()),0;default:return B(`Unknown pipelines command: ${t.sub}`),D(Qt()),1}}import{spawn as zr}from"node:child_process";import G from"node:fs";import Qr from"node:os";import W from"node:path";import{fileURLToPath as Zr}from"node:url";import{createRequire as eo}from"node:module";var ln="@superclawd-ai/fda",to={badFlags:64,claudeMissing:69,cloudUnavailable:75,agentNotFound:76,credentials:77,workspaceInvalid:78};function he(e,t){return process.stderr.write(`${JSON.stringify({fda_error:{class:e,message:t}})}
201
- `),to[e]}var Ye=new Set(["fda","fda-browser","fda-calendar"]);function cn(e){if(!e)return null;let t;try{t=JSON.parse(G.readFileSync(e,"utf8"))}catch{return null}if(!t||typeof t!="object"||Array.isArray(t))return null;let n={};for(let[r,o]of Object.entries(t)){if(!Ye.has(r))continue;let s=un(o);s&&(n[r]=s)}return Object.keys(n).length?n:null}function un(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e;if(t.type==="http"&&typeof t.url=="string"){let n={type:"http",url:t.url};return an(t.headers)&&(n.headers=t.headers),n}if(typeof t.command=="string"){let n={command:t.command};return Array.isArray(t.args)&&t.args.every(r=>typeof r=="string")&&(n.args=t.args),an(t.env)&&(n.env=t.env),n}return null}function dn(e){let t;try{t=JSON.parse(G.readFileSync(W.join(e,".mcp.json"),"utf8"))}catch{return[]}let n=t&&typeof t=="object"&&!Array.isArray(t)?t.mcpServers:null;return!n||typeof n!="object"||Array.isArray(n)?[]:Object.entries(n).filter(([r,o])=>/^[\w.-]+$/.test(r)&&!Ye.has(r)&&r!=="core"&&r!=="superclawd"&&!!un(o)).map(([r])=>r)}function an(e){return!!e&&typeof e=="object"&&!Array.isArray(e)&&Object.values(e).every(t=>typeof t=="string")}function pn(e,t){let n={},r=[];for(let o of e.names)Ye.has(o)||!e.map[o]||(n[o]=e.map[o],r.push(o));for(let[o,s]of Object.entries(t))n[o]=s,r.push(o);return{map:n,names:r}}function Ke(e,t=["SIGINT","SIGTERM","SIGHUP"]){let n=o=>{try{e.kill(o)}catch{}};for(let o of t)process.on(o,n);let r=()=>{for(let o of t)process.off(o,n)};return e.once("close",r),r}function Be(e){return e?128+(Qr.constants.signals[e]??9):1}function no(){let e=process.env.SUPERCLAWD_FDA_DIR;if(e)return G.existsSync(e)?e:null;let t=W.dirname(Zr(import.meta.url));for(let n=0;n<8;n++){let r=W.join(t,"apps","fda");if(G.existsSync(W.join(r,"server","cli.ts"))||G.existsSync(W.join(r,"dist-server","cli.mjs")))return r;let o=W.dirname(t);if(o===t)break;t=o}try{let n=eo(import.meta.url),r=W.dirname(n.resolve(`${ln}/package.json`));if(G.existsSync(W.join(r,"dist-server","cli.mjs")))return r}catch{}return null}function ro(e){let t=W.join(e,"dist-server","cli.mjs");if(G.existsSync(t))return{cmd:process.execPath,args:[t]};let n=W.join(e,"server","cli.ts");if(!G.existsSync(n))return null;for(let r of[W.join(e,"node_modules",".bin","tsx"),W.join(e,"..","..","node_modules",".bin","tsx")])if(G.existsSync(r))return{cmd:r,args:[n]};return{cmd:"tsx",args:[n]}}function fn(e){let t=no(),n=t?ro(t):null;return!t||!n?(process.stderr.write(`SuperClawd FDA isn't installed.
202
- Install it with: npm i -g ${ln}
203
- `),Promise.resolve(1)):new Promise(r=>{let o=zr(n.cmd,[...n.args,...e],{stdio:"inherit",cwd:process.cwd()});Ke(o),o.on("error",s=>{process.stderr.write(`\u2717 Could not start SuperClawd FDA: ${s.message}
204
- `),r(127)}),o.on("close",(s,i)=>r(s??Be(i)))})}function ao(e){let t={},n=[];for(let r of e){if(!r.name||r.name===Q||r.name===X||t[r.name])continue;let o={};r.type==="http"?(o.type="http",o.url=r.url,r.headers&&Object.keys(r.headers).length&&(o.headers=r.headers)):(o.command=r.command,r.args&&r.args.length&&(o.args=r.args)),r.env&&Object.keys(r.env).length&&(o.env=r.env),t[r.name]=o,n.push(r.name)}return{map:t,names:n}}function lo(e,t,n,r,o){let s={SUPERCLAWD_BACKEND:z,SUPERCLAWD_MCP_API_URL:V,SUPERCLAWD_SESSION_ID:n};return _||(s.SUPERCLAWD_MCP_KEY=e.keyId,s.SUPERCLAWD_MCP_SECRET=e.secret,s.SUPERCLAWD_MCP_WORKSPACE=e.workspace),process.env.NODE_EXTRA_CA_CERTS&&(s.NODE_EXTRA_CA_CERTS=process.env.NODE_EXTRA_CA_CERTS),process.env.SUPERCLAWD_HOME&&(s.SUPERCLAWD_HOME=process.env.SUPERCLAWD_HOME),process.env.SUPERCLAWD_LOG_FILE&&(s.SUPERCLAWD_LOG_FILE=process.env.SUPERCLAWD_LOG_FILE),process.env.SUPERCLAWD_DEBUG&&(s.SUPERCLAWD_DEBUG=process.env.SUPERCLAWD_DEBUG),process.env.SUPERCLAWD_MOCK_TIER&&(s.SUPERCLAWD_MOCK_TIER=process.env.SUPERCLAWD_MOCK_TIER),process.env.SUPERCLAWD_MOCK_BALANCE&&(s.SUPERCLAWD_MOCK_BALANCE=process.env.SUPERCLAWD_MOCK_BALANCE),process.env.SUPERCLAWD_EXPERIMENTAL&&(s.SUPERCLAWD_EXPERIMENTAL=process.env.SUPERCLAWD_EXPERIMENTAL),process.env.SUPERCLAWD_REPO_FINGERPRINT&&(s.SUPERCLAWD_REPO_FINGERPRINT=process.env.SUPERCLAWD_REPO_FINGERPRINT),process.env.SUPERCLAWD_TEAM_MEMORY&&(s.SUPERCLAWD_TEAM_MEMORY=process.env.SUPERCLAWD_TEAM_MEMORY),process.env.SUPERCLAWD_REPO_MEMORY&&(s.SUPERCLAWD_REPO_MEMORY=process.env.SUPERCLAWD_REPO_MEMORY),process.env.SUPERCLAWD_AGENT_MEMORY&&(s.SUPERCLAWD_AGENT_MEMORY=process.env.SUPERCLAWD_AGENT_MEMORY),process.env.SUPERCLAWD_PRIVATE_MEMORY&&(s.SUPERCLAWD_PRIVATE_MEMORY=process.env.SUPERCLAWD_PRIVATE_MEMORY),process.env.SUPERCLAWD_MEMORY_OFF&&(s.SUPERCLAWD_MEMORY_OFF=process.env.SUPERCLAWD_MEMORY_OFF),process.env.SUPERCLAWD_PIPELINES_TOOLS&&(s.SUPERCLAWD_PIPELINES_TOOLS=process.env.SUPERCLAWD_PIPELINES_TOOLS),process.env.SUPERCLAWD_PIPELINES_URL&&(s.SUPERCLAWD_PIPELINES_URL=process.env.SUPERCLAWD_PIPELINES_URL),process.env.SUPERCLAWD_PIPELINES_TICKET&&(s.SUPERCLAWD_PIPELINES_TICKET=process.env.SUPERCLAWD_PIPELINES_TICKET),r.length&&(s.SUPERCLAWD_RESOURCES=JSON.stringify(r.map(l=>({name:l.name,description:l.description})))),{relPath:".claude-plugin/plugin.json",content:JSON.stringify({name:X,description:"SuperClawd skills + live, metered directives for Claude Code.",mcpServers:{[Q]:{command:"node",args:[t],env:s},...o}},null,2)}}function hn(e){let{pluginDir:t,session:n,catalog:r,serverPath:o,launchId:s,fda:i}=e,l=gn(mn(o),"hook-helper.mjs"),u=process.env.SUPERCLAWD_GATE==="1",a=ao(r.mcpServers),f=i?null:nn();if(f&&!a.map[f.name]){let h={type:"http",url:f.url};f.headers&&(h.headers=f.headers),a.map[f.name]=h,a.names.push(f.name)}i&&e.fdaServers&&(a=pn(a,e.fdaServers));let S=[...Wt(r.agents,{foundationalText:r.foundational.text,modelFamilies:r.modelFamilies,extraTools:i&&e.fdaServers?[...[Q,...a.names].map(Tt),...dn(process.cwd()).map(h=>`mcp__${h}`),"ToolSearch","Skill","WebSearch","TodoWrite"]:[]},r.agentTeams),...Ft(r.commands,r.agents),...Nt(r.workflows),...jt()],y=new Set;for(let h of S){let d=/^commands\/(.+)\.md$/.exec(h.relPath),c=/^skills\/(.+)\/SKILL\.md$/.exec(h.relPath);d&&y.add(d[1]),c&&y.add(c[1])}let b=[lo(n,o,s,r.resources,a.map),...Ot(r.skills,y),...S,...Bt({foundational:r.foundational,helperPath:l,pluginDir:t,launchId:s,gate:u,guardrails:r.guardrails,policyGuardrails:r.policyGuardrails,agents:r.agents})],P=[],E=[];for(let h of b){let d=gn(t,h.relPath);oo(mn(d),{recursive:!0,mode:448}),so(d,h.content,{mode:384}),h.executable&&io(d,448),P.push(h.relPath);let c=/^agents\/(.+)\.md$/.exec(h.relPath);c&&E.push(c[1])}return{pluginDir:t,skillCount:r.skills.length,agentCount:r.agents.length,commandCount:r.commands.length,workflowCount:r.workflows.length,mcpServerNames:a.names,agentSlugs:E,files:P}}function wn(e,t){let n=["--allowedTools",Lt];for(let r of e)t.planOnly&&r!=="fda"||n.push("--allowedTools",`mcp__plugin_superclawd_${r}__*`);return t.planOnly?(n.push("--permission-mode","plan"),n.push("--disallowedTools","Edit","Write","NotebookEdit","Bash","Agent","Task","WebFetch","WebSearch","mcp__plugin_superclawd_fda-browser","mcp__plugin_superclawd_fda-calendar"),n.push("--setting-sources","user")):t.permissionMode?n.push("--permission-mode",t.permissionMode):t.skipPermissions&&n.push("--dangerously-skip-permissions"),n}import{mkdirSync as co,rmSync as Sn,readdirSync as uo,statSync as po}from"node:fs";import{join as He}from"node:path";import{randomBytes as fo}from"node:crypto";function yn(){let e=`${Date.now().toString(36)}-${fo(4).toString("hex")}`,t=He(le,e),n=He(t,"plugin");return co(n,{recursive:!0,mode:448}),{id:e,dir:t,pluginDir:n}}function we(e){try{Sn(e.dir,{recursive:!0,force:!0})}catch{}}function kn(e=Date.now()){let t=0,n=[];try{n=uo(le)}catch{return 0}for(let r of n){let o=He(le,r);try{e-po(o).mtimeMs>dt&&(Sn(o,{recursive:!0,force:!0}),t++)}catch{}}return t}import{hostname as mo}from"node:os";import{spawn as go}from"node:child_process";var ho=e=>new Promise(t=>setTimeout(t,e));function wo(e){try{let t=process.platform,o=go(t==="darwin"?"open":t==="win32"?"cmd":"xdg-open",t==="win32"?["/c","start","",e]:[e],{stdio:"ignore",detached:!0});o.on("error",()=>{}),o.unref()}catch{}}async function En(){if(_)return process.stdout.write(`Mock mode \u2014 login is not needed.
205
- `),{ok:!0};let e=tt(),t=mo()||"Unknown device",n;try{let a=await fetch(`${ae}/api/auth/cli/device/start`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({machineId:e,hostname:t})});if(!a.ok)return{ok:!1,error:`Couldn't start login (HTTP ${a.status}).`};n=await a.json()}catch{return{ok:!1,error:`Couldn't reach ${ae}.`}}let r=n.verification_uri_complete||n.verification_uri;process.stdout.write(`
198
+ `)}async function oo(e){let t=Se(),n=l=>`http://localhost:${l}`;if(t.alive&&t.port)return D(`Pipelines is already running (pid ${t.pid}) at ${n(t.port)}`),e.detach||ln(n(t.port)),0;t.pid&&!t.alive&&te(),await lo(!!process.stdin.isTTY&&!e.detach);let r=ro();if(!r)return B(`\u2717 Couldn't locate the Pipelines app.
199
+ Set SUPERCLAWD_PIPELINES_DIR to its directory (the one containing server/index.ts).`),1;let o=e.port??dn,s={...process.env,PIPELINES_PORT:String(o)};if(e.detach){$.mkdirSync(T,{recursive:!0});let l=$.openSync(rn,"a"),u=Ge(r.cmd,r.args,{cwd:r.cwd,env:s,detached:!0,stdio:["ignore",l,l]});return u.unref(),u.pid?(sn(u.pid,o),await an(o)?(D(`\u2713 Pipelines started (pid ${u.pid}) at ${n(o)}`),0):(B(`\u2717 Daemon didn't become ready within ${pn/1e3}s. See ${rn}`),1)):(B("\u2717 Failed to spawn the Pipelines daemon."),1)}D(`Starting Pipelines at ${n(o)} \u2026 (Ctrl-C to stop)`);let i=Ge(r.cmd,r.args,{cwd:r.cwd,env:s,stdio:"inherit"});return i.pid&&sn(i.pid,o),an(o).then(l=>{l&&ln(n(o))}),await new Promise(l=>{i.on("error",u=>{B(`\u2717 Could not launch the daemon: ${u.message}`),te(),l(1)}),i.on("close",u=>{te(),l(u??0)})})}async function so(){let e=Se();if(!e.pid||!e.alive)return D("Pipelines is not running."),te(),0;let t=n=>{try{process.kill(-e.pid,n)}catch{try{process.kill(e.pid,n)}catch{}}};t("SIGTERM");for(let n=0;n<40&&Ke(e.pid);n++)await new Promise(r=>setTimeout(r,100));return Ke(e.pid)&&t("SIGKILL"),te(),D("\u2713 Pipelines stopped."),0}async function io(){let e=Se();if(!e.alive)return D("Pipelines: stopped."),0;let t=e.port?await gn(e.port):!1;return D(`Pipelines: running (pid ${e.pid}) on port ${e.port??"?"} \u2014 `+(t?"responding \u2713":"not responding yet")),0}function ao(e){try{return JSON.parse($.readFileSync(L.join(e,"package.json"),"utf8")).version??null}catch{return null}}async function lo(e){if(process.env.SUPERCLAWD_NO_UPDATE||process.env.SUPERCLAWD_BACKEND==="mock")return;let t=mn(),n=t?ao(t):null;if(!n)return;let r=await Te(Y,n);if(!r)return;let{latest:o}=r;if(!e){De("Pipelines",n,o,"superclawd pipelines update"),H(Y);return}if(await Ue("Pipelines",n,o)==="run"){H(Y,o);return}H(Y),D(`Updating Pipelines (npm i -g ${Y}@latest) \u2026`);let i=un(`npm install -g ${Y}@latest`,{stdio:"inherit",shell:!0});i.status!==0?B(`\u2717 Update failed (npm exited ${i.status??"?"}). Starting ${n} for now.`):D(`\u2713 Updated to ${o}.`)}function co(){if(Se().alive)return B("\u2717 Stop the daemon first: superclawd pipelines stop"),1;D(`Updating Pipelines (npm i -g ${Y}@latest) \u2026`);let t=un(`npm install -g ${Y}@latest`,{stdio:"inherit",shell:!0});return t.status!==0?(B(`\u2717 Update failed (npm exited ${t.status??"?"}).`),t.status??1):(D("\u2713 Updated. Start again with: superclawd pipelines start"),0)}function cn(){return["superclawd pipelines \u2014 run the local Pipelines app",""," start [--port <n>] [-d] Start the daemon (foreground; -d detaches). Opens the browser."," stop Stop the running daemon."," status Show whether the daemon is running."," update Update the Pipelines app (daemon must be stopped)."].join(`
200
+ `)}async function hn(e){let t=eo(e);switch(t.sub){case"start":return oo(t);case"stop":return so();case"status":return io();case"update":return co();case"":case"help":return D(cn()),0;default:return B(`Unknown pipelines command: ${t.sub}`),D(cn()),1}}import{spawn as uo}from"node:child_process";import K from"node:fs";import po from"node:os";import W from"node:path";import{fileURLToPath as fo}from"node:url";import{createRequire as mo}from"node:module";var wn="@superclawd-ai/fda",go={badFlags:64,claudeMissing:69,cloudUnavailable:75,agentNotFound:76,credentials:77,workspaceInvalid:78,openrouterKeyMissing:79,modelNotApproved:80};function we(e,t){return process.stderr.write(`${JSON.stringify({fda_error:{class:e,message:t}})}
201
+ `),go[e]}var He=new Set(["fda","fda-browser","fda-calendar"]);function yn(e){if(!e)return null;let t;try{t=JSON.parse(K.readFileSync(e,"utf8"))}catch{return null}if(!t||typeof t!="object"||Array.isArray(t))return null;let n={};for(let[r,o]of Object.entries(t)){if(!He.has(r))continue;let s=kn(o);s&&(n[r]=s)}return Object.keys(n).length?n:null}function kn(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e;if(t.type==="http"&&typeof t.url=="string"){let n={type:"http",url:t.url};return Sn(t.headers)&&(n.headers=t.headers),n}if(typeof t.command=="string"){let n={command:t.command};return Array.isArray(t.args)&&t.args.every(r=>typeof r=="string")&&(n.args=t.args),Sn(t.env)&&(n.env=t.env),n}return null}function En(e){let t;try{t=JSON.parse(K.readFileSync(W.join(e,".mcp.json"),"utf8"))}catch{return[]}let n=t&&typeof t=="object"&&!Array.isArray(t)?t.mcpServers:null;return!n||typeof n!="object"||Array.isArray(n)?[]:Object.entries(n).filter(([r,o])=>/^[\w.-]+$/.test(r)&&!He.has(r)&&r!=="core"&&r!=="superclawd"&&!!kn(o)).map(([r])=>r)}function Sn(e){return!!e&&typeof e=="object"&&!Array.isArray(e)&&Object.values(e).every(t=>typeof t=="string")}function Rn(e,t){let n={},r=[];for(let o of e.names)He.has(o)||!e.map[o]||(n[o]=e.map[o],r.push(o));for(let[o,s]of Object.entries(t))n[o]=s,r.push(o);return{map:n,names:r}}function Je(e,t=["SIGINT","SIGTERM","SIGHUP"]){let n=o=>{try{e.kill(o)}catch{}};for(let o of t)process.on(o,n);let r=()=>{for(let o of t)process.off(o,n)};return e.once("close",r),r}function qe(e){return e?128+(po.constants.signals[e]??9):1}function ho(){let e=process.env.SUPERCLAWD_FDA_DIR;if(e)return K.existsSync(e)?e:null;let t=W.dirname(fo(import.meta.url));for(let n=0;n<8;n++){let r=W.join(t,"apps","fda");if(K.existsSync(W.join(r,"server","cli.ts"))||K.existsSync(W.join(r,"dist-server","cli.mjs")))return r;let o=W.dirname(t);if(o===t)break;t=o}try{let n=mo(import.meta.url),r=W.dirname(n.resolve(`${wn}/package.json`));if(K.existsSync(W.join(r,"dist-server","cli.mjs")))return r}catch{}return null}function So(e){let t=W.join(e,"dist-server","cli.mjs");if(K.existsSync(t))return{cmd:process.execPath,args:[t]};let n=W.join(e,"server","cli.ts");if(!K.existsSync(n))return null;for(let r of[W.join(e,"node_modules",".bin","tsx"),W.join(e,"..","..","node_modules",".bin","tsx")])if(K.existsSync(r))return{cmd:r,args:[n]};return{cmd:"tsx",args:[n]}}function _n(e){let t=ho(),n=t?So(t):null;return!t||!n?(process.stderr.write(`SuperClawd FDA isn't installed.
202
+ Install it with: npm i -g ${wn}
203
+ `),Promise.resolve(1)):new Promise(r=>{let o=uo(n.cmd,[...n.args,...e],{stdio:"inherit",cwd:process.cwd()});Je(o),o.on("error",s=>{process.stderr.write(`\u2717 Could not start SuperClawd FDA: ${s.message}
204
+ `),r(127)}),o.on("close",(s,i)=>r(s??qe(i)))})}function Eo(e){let t={},n=[];for(let r of e){if(!r.name||r.name===ee||r.name===z||t[r.name])continue;let o={};r.type==="http"?(o.type="http",o.url=r.url,r.headers&&Object.keys(r.headers).length&&(o.headers=r.headers)):(o.command=r.command,r.args&&r.args.length&&(o.args=r.args)),r.env&&Object.keys(r.env).length&&(o.env=r.env),t[r.name]=o,n.push(r.name)}return{map:t,names:n}}function Ro(e,t,n,r,o){let s={SUPERCLAWD_BACKEND:Z,SUPERCLAWD_MCP_API_URL:V,SUPERCLAWD_SESSION_ID:n};return A||(s.SUPERCLAWD_MCP_KEY=e.keyId,s.SUPERCLAWD_MCP_SECRET=e.secret,s.SUPERCLAWD_MCP_WORKSPACE=e.workspace),process.env.NODE_EXTRA_CA_CERTS&&(s.NODE_EXTRA_CA_CERTS=process.env.NODE_EXTRA_CA_CERTS),process.env.SUPERCLAWD_HOME&&(s.SUPERCLAWD_HOME=process.env.SUPERCLAWD_HOME),process.env.SUPERCLAWD_LOG_FILE&&(s.SUPERCLAWD_LOG_FILE=process.env.SUPERCLAWD_LOG_FILE),process.env.SUPERCLAWD_DEBUG&&(s.SUPERCLAWD_DEBUG=process.env.SUPERCLAWD_DEBUG),process.env.SUPERCLAWD_MOCK_TIER&&(s.SUPERCLAWD_MOCK_TIER=process.env.SUPERCLAWD_MOCK_TIER),process.env.SUPERCLAWD_MOCK_BALANCE&&(s.SUPERCLAWD_MOCK_BALANCE=process.env.SUPERCLAWD_MOCK_BALANCE),process.env.SUPERCLAWD_EXPERIMENTAL&&(s.SUPERCLAWD_EXPERIMENTAL=process.env.SUPERCLAWD_EXPERIMENTAL),process.env.SUPERCLAWD_REPO_FINGERPRINT&&(s.SUPERCLAWD_REPO_FINGERPRINT=process.env.SUPERCLAWD_REPO_FINGERPRINT),process.env.SUPERCLAWD_TEAM_MEMORY&&(s.SUPERCLAWD_TEAM_MEMORY=process.env.SUPERCLAWD_TEAM_MEMORY),process.env.SUPERCLAWD_REPO_MEMORY&&(s.SUPERCLAWD_REPO_MEMORY=process.env.SUPERCLAWD_REPO_MEMORY),process.env.SUPERCLAWD_AGENT_MEMORY&&(s.SUPERCLAWD_AGENT_MEMORY=process.env.SUPERCLAWD_AGENT_MEMORY),process.env.SUPERCLAWD_PRIVATE_MEMORY&&(s.SUPERCLAWD_PRIVATE_MEMORY=process.env.SUPERCLAWD_PRIVATE_MEMORY),process.env.SUPERCLAWD_MEMORY_OFF&&(s.SUPERCLAWD_MEMORY_OFF=process.env.SUPERCLAWD_MEMORY_OFF),process.env.SUPERCLAWD_PIPELINES_TOOLS&&(s.SUPERCLAWD_PIPELINES_TOOLS=process.env.SUPERCLAWD_PIPELINES_TOOLS),process.env.SUPERCLAWD_PIPELINES_URL&&(s.SUPERCLAWD_PIPELINES_URL=process.env.SUPERCLAWD_PIPELINES_URL),process.env.SUPERCLAWD_PIPELINES_TICKET&&(s.SUPERCLAWD_PIPELINES_TICKET=process.env.SUPERCLAWD_PIPELINES_TICKET),r.length&&(s.SUPERCLAWD_RESOURCES=JSON.stringify(r.map(l=>({name:l.name,description:l.description})))),{relPath:".claude-plugin/plugin.json",content:JSON.stringify({name:z,description:"SuperClawd skills + live, metered directives for Claude Code.",mcpServers:{[ee]:{command:"node",args:[t],env:s},...o}},null,2)}}function Cn(e){let{pluginDir:t,session:n,catalog:r,serverPath:o,launchId:s,fda:i}=e,l=Pn(vn(o),"hook-helper.mjs"),u=process.env.SUPERCLAWD_GATE==="1",a=Eo(r.mcpServers),f=i?null:fn();if(f&&!a.map[f.name]){let h={type:"http",url:f.url};f.headers&&(h.headers=f.headers),a.map[f.name]=h,a.names.push(f.name)}i&&e.fdaServers&&(a=Rn(a,e.fdaServers));let y=[...bt(r.agents,{foundationalText:r.foundational.text,modelFamilies:r.modelFamilies,provider:e.provider,extraTools:i&&e.fdaServers?[...[ee,...a.names].map(Ct),...En(process.cwd()).map(h=>`mcp__${h}`),"ToolSearch","Skill","WebSearch","TodoWrite"]:[]},r.agentTeams),...Vt(r.commands,r.agents),...zt(r.workflows),...Xt()],R=new Set;for(let h of y){let d=/^commands\/(.+)\.md$/.exec(h.relPath),g=/^skills\/(.+)\/SKILL\.md$/.exec(h.relPath);d&&R.add(d[1]),g&&R.add(g[1])}let _=[Ro(n,o,s,r.resources,a.map),..._t(r.skills,R),...y,...tn({foundational:r.foundational,helperPath:l,pluginDir:t,launchId:s,gate:u,guardrails:r.guardrails,policyGuardrails:r.policyGuardrails,agents:r.agents})],v=[],w=[];for(let h of _){let d=Pn(t,h.relPath);wo(vn(d),{recursive:!0,mode:448}),yo(d,h.content,{mode:384}),h.executable&&ko(d,448),v.push(h.relPath);let g=/^agents\/(.+)\.md$/.exec(h.relPath);g&&w.push(g[1])}return{pluginDir:t,skillCount:r.skills.length,agentCount:r.agents.length,commandCount:r.commands.length,workflowCount:r.workflows.length,mcpServerNames:a.names,agentSlugs:w,files:v}}function An(e,t){let n=["--allowedTools",Pt];for(let r of e)t.planOnly&&r!=="fda"||n.push("--allowedTools",`mcp__plugin_superclawd_${r}__*`);return t.planOnly?(n.push("--permission-mode","plan"),n.push("--disallowedTools","Edit","Write","NotebookEdit","Bash","Agent","Task","WebFetch","WebSearch","mcp__plugin_superclawd_fda-browser","mcp__plugin_superclawd_fda-calendar"),n.push("--setting-sources","user")):t.permissionMode?n.push("--permission-mode",t.permissionMode):t.skipPermissions&&n.push("--dangerously-skip-permissions"),n}import{mkdirSync as _o,rmSync as Mn,readdirSync as vo,statSync as Po}from"node:fs";import{join as Ve}from"node:path";import{randomBytes as Co}from"node:crypto";function bn(){let e=`${Date.now().toString(36)}-${Co(4).toString("hex")}`,t=Ve(de,e),n=Ve(t,"plugin");return _o(n,{recursive:!0,mode:448}),{id:e,dir:t,pluginDir:n}}function Q(e){try{Mn(e.dir,{recursive:!0,force:!0})}catch{}}function xn(e=Date.now()){let t=0,n=[];try{n=vo(de)}catch{return 0}for(let r of n){let o=Ve(de,r);try{e-Po(o).mtimeMs>mt&&(Mn(o,{recursive:!0,force:!0}),t++)}catch{}}return t}import{hostname as Ao}from"node:os";import{spawn as Mo}from"node:child_process";var bo=e=>new Promise(t=>setTimeout(t,e));function xo(e){try{let t=process.platform,o=Mo(t==="darwin"?"open":t==="win32"?"cmd":"xdg-open",t==="win32"?["/c","start","",e]:[e],{stdio:"ignore",detached:!0});o.on("error",()=>{}),o.unref()}catch{}}async function On(){if(A)return process.stdout.write(`Mock mode \u2014 login is not needed.
205
+ `),{ok:!0};let e=ot(),t=Ao()||"Unknown device",n;try{let a=await fetch(`${ue}/api/auth/cli/device/start`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({machineId:e,hostname:t})});if(!a.ok)return{ok:!1,error:`Couldn't start login (HTTP ${a.status}).`};n=await a.json()}catch{return{ok:!1,error:`Couldn't reach ${ue}.`}}let r=n.verification_uri_complete||n.verification_uri;process.stdout.write(`
206
206
  To authorize this machine, open:
207
207
  ${r}
208
208
 
209
209
  and confirm this code matches: ${n.user_code}
210
210
 
211
- `),wo(r),process.stdout.write(`Waiting for approval\u2026 (Ctrl-C to cancel)
212
- `);let o=(n.interval||5)*1e3,s=Date.now()+(n.expires_in||600)*1e3,i,l;for(;Date.now()<s;){await ho(o);let a;try{a=await(await fetch(`${ae}/api/auth/cli/device/token`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({deviceCode:n.device_code})})).json()}catch{continue}if(a.status==="approved"){i=a.key_id,l=a.secret;break}if(a.status==="denied")return{ok:!1,error:"Request was denied in the browser."};if(a.status==="expired")return{ok:!1,error:"Login request expired. Run `superclawd login` again."}}if(!i||!l)return{ok:!1,error:"Login timed out. Run `superclawd login` again."};process.stdout.write(`\u2713 Authorized.
211
+ `),xo(r),process.stdout.write(`Waiting for approval\u2026 (Ctrl-C to cancel)
212
+ `);let o=(n.interval||5)*1e3,s=Date.now()+(n.expires_in||600)*1e3,i,l;for(;Date.now()<s;){await bo(o);let a;try{a=await(await fetch(`${ue}/api/auth/cli/device/token`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({deviceCode:n.device_code})})).json()}catch{continue}if(a.status==="approved"){i=a.key_id,l=a.secret;break}if(a.status==="denied")return{ok:!1,error:"Request was denied in the browser."};if(a.status==="expired")return{ok:!1,error:"Login request expired. Run `superclawd login` again."}}if(!i||!l)return{ok:!1,error:"Login timed out. Run `superclawd login` again."};process.stdout.write(`\u2713 Authorized.
213
213
 
214
- `);let u=L()??{};return Y({...u,credentials:{...u.credentials,keyId:i,secret:l}}),process.stdout.write("\u2713 Logged in. Run `superclawd` to choose a workspace and start.\n\n"),{ok:!0}}var M="\x1B",Se=[{key:"notifications",label:"Notifications",description:"Default for new sessions \u2014 ping when Claude needs you or finishes",defaultOn:!1},{key:"skipPermissions",label:"Dangerously skip permissions",description:"Launch Claude Code with --dangerously-skip-permissions (no approval prompts)",defaultOn:!1},{key:"chooseWorkspaceAtStartup",label:"Choose workspace at startup",description:"Pick the workspace to boot into each time you run superclawd",defaultOn:!0},{key:"experimental",label:"Experimental mode",description:"Run the latest unpublished (draft) versions instead of the stable release",defaultOn:!1},{key:"keepAwake",label:"Keep Awake",description:"Prevent your computer from sleeping while a session is running",defaultOn:!1},{key:"privateMemory",label:"Private Memory",description:"Remember your personal preferences across all your sessions (private to you, never shared)",defaultOn:!0},{key:"pipelinesMcp",label:"Pipelines MCP",description:"Let Claude Code drive your Pipelines board (requires SuperClawd Pipelines running)",defaultOn:!1}].sort((e,t)=>e.label.localeCompare(t.label)),qe=(e,t)=>e.preferences?.[t.key]??t.defaultOn;async function Rn(){let e=L()??{},t=process.stdin;if(!t.isTTY){process.stdout.write(`SuperClawd options:
215
- `);for(let n of Se)process.stdout.write(` ${qe(e,n)?"on ":"off"} ${n.label}
216
- `);return}await new Promise(n=>{let r=Se.length,o=r+2,s=0,i=P=>{P||process.stdout.write(`${M}[${o}A`);for(let E=0;E<r;E++){let h=Se[E],d=E===s?`${M}[38;5;208m\u276F `:" ",c=qe(e,h)?`${M}[38;5;208m[\u2713]${M}[0m`:"[ ]";process.stdout.write(`${M}[2K${d}${c} ${h.label}${M}[0m ${M}[2m${h.description}${M}[0m
217
- `)}process.stdout.write(`${M}[2K
218
- `),process.stdout.write(`${M}[2K${M}[2mPress Esc (or Ctrl-C) to exit${M}[0m
214
+ `);let u=I()??{};return j({...u,credentials:{...u.credentials,keyId:i,secret:l}}),process.stdout.write("\u2713 Logged in. Run `superclawd` to choose a workspace and start.\n\n"),{ok:!0}}var x="\x1B",ye=[{key:"notifications",label:"Notifications",description:"Default for new sessions \u2014 ping when Claude needs you or finishes",defaultOn:!1},{key:"skipPermissions",label:"Dangerously skip permissions",description:"Launch Claude Code with --dangerously-skip-permissions (no approval prompts)",defaultOn:!1},{key:"chooseWorkspaceAtStartup",label:"Choose workspace at startup",description:"Pick the workspace to boot into each time you run superclawd",defaultOn:!0},{key:"experimental",label:"Experimental mode",description:"Run the latest unpublished (draft) versions instead of the stable release",defaultOn:!1},{key:"keepAwake",label:"Keep Awake",description:"Prevent your computer from sleeping while a session is running",defaultOn:!1},{key:"privateMemory",label:"Private Memory",description:"Remember your personal preferences across all your sessions (private to you, never shared)",defaultOn:!0},{key:"pipelinesMcp",label:"Pipelines MCP",description:"Let Claude Code drive your Pipelines board (requires SuperClawd Pipelines running)",defaultOn:!1}].sort((e,t)=>e.label.localeCompare(t.label)),ze=(e,t)=>e.preferences?.[t.key]??t.defaultOn;async function In(){let e=I()??{},t=process.stdin;if(!t.isTTY){process.stdout.write(`SuperClawd options:
215
+ `);for(let n of ye)process.stdout.write(` ${ze(e,n)?"on ":"off"} ${n.label}
216
+ `);return}await new Promise(n=>{let r=ye.length,o=r+2,s=0,i=v=>{v||process.stdout.write(`${x}[${o}A`);for(let w=0;w<r;w++){let h=ye[w],d=w===s?`${x}[38;5;208m\u276F `:" ",g=ze(e,h)?`${x}[38;5;208m[\u2713]${x}[0m`:"[ ]";process.stdout.write(`${x}[2K${d}${g} ${h.label}${x}[0m ${x}[2m${h.description}${x}[0m
217
+ `)}process.stdout.write(`${x}[2K
218
+ `),process.stdout.write(`${x}[2K${x}[2mPress Esc (or Ctrl-C) to exit${x}[0m
219
219
  `)};process.stdout.write(`
220
- SuperClawd options ${M}[2m(\u2191/\u2193 move \xB7 Space/Enter to toggle)${M}[0m
221
- ${M}[?7l${M}[?25l`),i(!0),t.setRawMode(!0),t.resume();let l=!1,u=()=>{if(!l){l=!0;try{t.setRawMode(!1)}catch{}process.stdout.write(`${M}[?7h${M}[?25h`)}},a=["SIGINT","SIGTERM","SIGHUP"],f=()=>u(),S=P=>{u(),process.kill(process.pid,P)};process.once("exit",f);for(let P of a)process.once(P,S);let y=()=>{t.off("data",b),process.off("exit",f);for(let P of a)process.off(P,S);t.pause(),u(),process.stdout.write(`
222
- `)},b=P=>{let E=P.toString();if(E===""||E===M)y(),n();else if(E==="\r"||E===`
223
- `||E===" "){let h=Se[s];e.preferences={...e.preferences,[h.key]:!qe(e,h)},Y(e),i(!1)}else E===`${M}[A`||E==="k"?(s=(s-1+r)%r,i(!1)):(E===`${M}[B`||E==="j")&&(s=(s+1)%r,i(!1))};t.on("data",b)})}import{execSync as Mn}from"node:child_process";var v="\x1B",j=`${v}[38;5;208m`,J=`${v}[2m`,Ee=`${v}[31m`,A=`${v}[0m`,So=`${v}[?1049h`,Cn=`${v}[?1049l`,yo=`${v}[?25l`,Je=`${v}[?25h`,ko=`${v}[?1007l`,_n=`${v}[?1007h`,Eo=`${v}[?1000l${v}[?1002l${v}[?1003l${v}[?1004l${v}[?1006l${v}[?1015l`,Ve=`${v}[2J${v}[H`,ye=[" _ _"," ____ _ _ __ ___ _ _ __| |__ ___ __ ____| |","(_-< || | '_ \\/ -_) '_/ _| / _` \\ V V / _` |","/__/\\_,_| .__/\\___|_| \\__|_\\__,_|\\_/\\_/\\__,_|"," |_|"],vn=45,ee=36,Ro=140,Co=350,F=e=>void process.stdout.write(e),_o=e=>new Promise(t=>setTimeout(t,e)),q=e=>e>0?" ".repeat(e):"",bn=process.platform!=="win32";function vo(){if(!bn)return null;try{return Mn("stty -g </dev/tty",{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim()}catch{return null}}function Pn(e){if(bn)try{Mn(`stty ${e} </dev/tty`,{stdio:"ignore"})}catch{}}var ke=null;function An(e){ke?.(),ke=null,process.stderr.write(`${Ee}\u2717 ${e}${A}
224
- `)}function Po(e,t){return F(`${j}${ye.join(`
225
- `)}${A} ${J}v${t}${A}
226
-
227
- `),{async phase(n,r){F(`${J} \xB7 ${r}${A}
228
- `)},message(n){F(`${J} \xB7 ${n}${A}
229
- `)},async selectWorkspace(n,r){return r?.currentSlug??n[0]?.slug??null},async ready(n){F(`${j} \u2713 ${n}${A}
230
- `)},fail(n){F(`${Ee} \u2717 ${n}${A}
220
+ SuperClawd options ${x}[2m(\u2191/\u2193 move \xB7 Space/Enter to toggle)${x}[0m
221
+ ${x}[?7l${x}[?25l`),i(!0),t.setRawMode(!0),t.resume();let l=!1,u=()=>{if(!l){l=!0;try{t.setRawMode(!1)}catch{}process.stdout.write(`${x}[?7h${x}[?25h`)}},a=["SIGINT","SIGTERM","SIGHUP"],f=()=>u(),y=v=>{u(),process.kill(process.pid,v)};process.once("exit",f);for(let v of a)process.once(v,y);let R=()=>{t.off("data",_),process.off("exit",f);for(let v of a)process.off(v,y);t.pause(),u(),process.stdout.write(`
222
+ `)},_=v=>{let w=v.toString();if(w===""||w===x)R(),n();else if(w==="\r"||w===`
223
+ `||w===" "){let h=ye[s];e.preferences={...e.preferences,[h.key]:!ze(e,h)},j(e),i(!1)}else w===`${x}[A`||w==="k"?(s=(s-1+r)%r,i(!1)):(w===`${x}[B`||w==="j")&&(s=(s+1)%r,i(!1))};t.on("data",_)})}import{execSync as Un}from"node:child_process";var M="\x1B",G=`${M}[38;5;208m`,q=`${M}[2m`,Re=`${M}[31m`,O=`${M}[0m`,Oo=`${M}[?1049h`,Ln=`${M}[?1049l`,Io=`${M}[?25l`,Xe=`${M}[?25h`,Lo=`${M}[?1007l`,$n=`${M}[?1007h`,$o=`${M}[?1000l${M}[?1002l${M}[?1003l${M}[?1004l${M}[?1006l${M}[?1015l`,Qe=`${M}[2J${M}[H`,ke=[" _ _"," ____ _ _ __ ___ _ _ __| |__ ___ __ ____| |","(_-< || | '_ \\/ -_) '_/ _| / _` \\ V V / _` |","/__/\\_,_| .__/\\___|_| \\__|_\\__,_|\\_/\\_/\\__,_|"," |_|"],Tn=45,ne=36,To=140,Do=350,F=e=>void process.stdout.write(e),Uo=e=>new Promise(t=>setTimeout(t,e)),J=e=>e>0?" ".repeat(e):"",Wn=process.platform!=="win32";function Wo(){if(!Wn)return null;try{return Un("stty -g </dev/tty",{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim()}catch{return null}}function Dn(e){if(Wn)try{Un(`stty ${e} </dev/tty`,{stdio:"ignore"})}catch{}}var Ee=null;function Fn(e){Ee?.(),Ee=null,process.stderr.write(`${Re}\u2717 ${e}${O}
224
+ `)}function Fo(e,t){return F(`${G}${ke.join(`
225
+ `)}${O} ${q}v${t}${O}
226
+
227
+ `),{async phase(n,r){F(`${q} \xB7 ${r}${O}
228
+ `)},message(n){F(`${q} \xB7 ${n}${O}
229
+ `)},async selectWorkspace(n,r){return r?.currentSlug??n[0]?.slug??null},async ready(n){F(`${G} \u2713 ${n}${O}
230
+ `)},fail(n){F(`${Re} \u2717 ${n}${O}
231
231
  `)},note(n){F(` ${n}
232
- `)},handoff(){},finish(){}}}function Mo(e,t){let n=vo(),r=0,o=!0,s=!1,i=d=>{d.includes(3)&&f()},l=()=>{let d=process.stdin;if(d.isTTY){try{d.setRawMode(!0)}catch{}d.resume(),d.on("data",i),s=!0}},u=()=>{if(!s)return;let d=process.stdin;d.off("data",i);try{d.setRawMode(!1)}catch{}d.pause(),s=!1},a=()=>{u();try{process.stdin.isTTY&&process.stdin.setRawMode(!1)}catch{}F(Je+_n+Cn),n&&Pn(n)},f=()=>{o&&a(),o=!1,process.exit(130)},S=()=>{u(),o&&F(Je+_n+Cn)},y=()=>{process.off("SIGINT",f),process.off("SIGTERM",f),process.off("exit",S),ke=null};Pn("-echo"),F(So+yo+ko+Eo),l(),process.on("SIGINT",f),process.on("SIGTERM",f),process.on("exit",S),ke=a;let b=(d,c)=>{let R=process.stdout.columns||80,w=process.stdout.rows||24,m=Math.floor(d*ee/e);m<0&&(m=0),m>ee&&(m=ee);let I="\u2588".repeat(m)+"\u2591".repeat(ee-m),x=Math.floor(d*100/e),k=ee+6,p=Math.max(0,Math.floor((w-9)/2)),g=Ve+`
233
- `.repeat(p),C=Math.max(0,Math.floor((R-vn)/2));for(let Dn of ye)g+=`${q(C)}${j}${Dn}${A}
234
- `;g+=`
235
- `;let N=Math.max(0,Math.floor((R-c.length)/2));g+=`${q(N)}${J}${c}${A}
236
-
237
- `;let ne=Math.max(0,Math.floor((R-k)/2));g+=`${q(ne)}${j}${I}${A} ${String(x).padStart(3)}%
238
- `;let re=`v${t}`,_e=Math.max(1,w-1),ve=Math.max(1,R-re.length-1);g+=`${v}[${_e};${ve}H${j}${re}${A}`,F(g)},P=async(d,c,R)=>{let w=R-(Date.now()-r);w>0&&await _o(w),b(d,c),r=Date.now()},E=d=>{let c=process.stdout.columns||80,R=process.stdout.rows||24,w=Math.max(0,Math.floor((R-(ye.length+1+d.length))/2)),m=Ve+`
239
- `.repeat(w),I=Math.max(0,Math.floor((c-vn)/2));for(let k of ye)m+=`${q(I)}${j}${k}${A}
240
- `;m+=`
241
- `;for(let k of d)m+=`${k}
242
- `;let x=`v${t}`;m+=`${v}[${Math.max(1,R-1)};${Math.max(1,c-x.length-1)}H${j}${x}${A}`,F(m)},h=(d,c,R)=>{let w=process.stdout.columns||80,m="Select your workspace \u2191/\u2193 \xB7 enter launches \xB7 d sets default \xB7 esc cancels",I=Math.max(0,Math.floor((w-m.length)/2)),x=C=>` ${C.name} ${C.slug} \xB7 ${C.role}`,k=Math.max(...d.map(C=>x(C).length)),p=Math.max(0,Math.floor((w-k)/2)),g=[`${q(I)}${J}${m}${A}`,""];for(let C=0;C<d.length;C++){let N=d[C],ne=C===c,re=ne?`${j}\u276F `:" ",_e=ne?`${j}${N.name}${A}`:N.name,ve=N.slug===R?` ${j}\u2605 default${A}`:"";g.push(`${q(p)}${re}${_e} ${J}${N.slug} \xB7 ${N.role}${A}${ve}`)}E(g)};return{phase:(d,c)=>P(d-1,c,Ro),ready:d=>P(e,d,Co),message(d){let c=process.stdout.columns||80,R=Math.max(0,Math.floor((c-d.length)/2));E([`${q(R)}${J}${d}${A}`]),r=Date.now()},selectWorkspace(d,c){return new Promise(R=>{let w=c?.currentSlug?d.findIndex(k=>k.slug===c.currentSlug):-1,m=w>=0?w:0,I=c?.defaultSlug;s&&process.stdin.off("data",i),h(d,m,I);let x=k=>{let p=k.toString();p===""||p===v?(process.stdin.off("data",x),R(null)):p==="\r"||p===`
243
- `?(process.stdin.off("data",x),process.stdin.on("data",i),R(d[m].slug)):p==="d"||p==="D"?(I=d[m].slug,c?.onSetDefault?.(I),h(d,m,I)):p===`${v}[A`||p==="k"?(m=(m-1+d.length)%d.length,h(d,m,I)):(p===`${v}[B`||p==="j")&&(m=(m+1)%d.length,h(d,m,I))};process.stdin.on("data",x)})},fail(d){o&&a(),o=!1,y(),process.stderr.write(`${Ee}\u2717 ${d}${A}
244
- `)},note(){},handoff(){s&&(process.stdin.off("data",i),process.stdin.pause(),s=!1),F(Ve+Je),process.off("SIGINT",f),process.off("SIGTERM",f)},finish(){o&&a(),o=!1,y()}}}function bo(){return process.platform!=="win32"?!0:!!(process.env.WT_SESSION||process.env.TERM_PROGRAM||process.env.TERM)}function Ao(){return{async phase(){},message(){},async selectWorkspace(e,t){return t?.currentSlug??e[0]?.slug??null},async ready(){},fail(e){process.stderr.write(`${Ee}\u2717 ${e}${A}
245
- `)},note(){},handoff(){},finish(){}}}function xn(e){if(e.quiet)return Ao();let t=process.stdout.isTTY===!0,n=e.version??"";return e.plain||!t||!bo()?Po(e.total,n):Mo(e.total,n)}var xo=["text","json","stream-json"],$o=["auto"],Oo=/^(?:0*[1-9]\d*(?:\.\d+)?|0*\.\d*[1-9]\d*|0+\.\d*[1-9]\d*)$/,Io=/^[1-9]\d*$/,Lo=["low","medium","high","xhigh","max"];function $n(e){let t=!1,n="",r=null,o=!1,s=!1,i=!1,l=null,u=!1,a=!1,f="board",S=null,y=null,b=null,P=!1,E=null,h=null,d=null,c=null,R=!1,w=null,m=null,I=[],x=(k,p,g)=>p!==void 0&&!p.startsWith("--")&&g(p)?p:(I.push(k),null);for(let k=0;k<e.length;k++){let p=e[k],g=e[k+1];if(p==="-p"||p==="--print")t=!0,g&&!g.startsWith("-")&&(n=g,k++);else if(p==="--workspace"||p==="-w")g&&!g.startsWith("-")&&(r=g,k++);else if(p==="--no-capture")o=!0;else if(p==="--no-memory")s=!0;else if(p==="--resume"||p==="-r")i=!0,g&&!g.startsWith("-")&&(l=g,k++);else if(p==="--pipelines")u=!0;else if(p==="--pipelines-tools")a=!0;else if(p.startsWith("--pipelines-tools="))a=!0,f=p.slice(18)==="restricted"?"restricted":"board";else if(p==="--session-id")g&&!g.startsWith("-")&&(S=g,k++);else if(p==="--model")g&&!g.startsWith("-")&&(y=g,k++);else if(p==="--fda")P=!0;else if(p==="--plan-only")R=!0;else if(p==="--agent")E=x(p,g,C=>!C.startsWith("-")),E!==null&&k++;else if(p==="--prompt-file")h=x(p,g,C=>!C.startsWith("-")),h!==null&&k++;else if(p==="--output-format"){let C=x(p,g,N=>xo.includes(N));C!==null&&(d=C,k++)}else if(p==="--permission-mode"){let C=x(p,g,N=>$o.includes(N));C!==null&&(c=C,k++)}else p==="--max-budget-usd"?(w=x(p,g,C=>Oo.test(C)),w!==null&&k++):p==="--max-turns"?(m=x(p,g,C=>Io.test(C)),m!==null&&k++):p==="--effort"&&g&&Lo.includes(g)&&(b=g,k++)}return{printMode:t,printPrompt:n,workspace:r,noCapture:o,noMemory:s,resume:i,resumeSessionId:l,pipelines:u,pipelinesTools:a,pipelinesToolsMode:f,sessionId:S,model:y,effort:b,fda:P,agent:E,promptFile:h,outputFormat:d,permissionMode:c,planOnly:R,maxBudgetUsd:w,maxTurns:m,invalid:I}}var On={name:"superclawd",version:"0.1.131",description:"Claude Code, supercharged \u2014 your team's standards, every session. The superclawd CLI loads your workspace's skills, agents, commands, workflows, and live directives into Claude Code as a plugin.",author:"SuperClawd <support@superclawd.com>",license:"SEE LICENSE IN LICENSE",homepage:"https://superclawd.com",repository:{type:"git",url:"git+https://github.com/superclawd-ai/superclawd.git"},bugs:{url:"https://github.com/superclawd-ai/superclawd/issues"},keywords:["superclawd","claude-code","claude","plugin","skills","agents","mcp","ai-assistant","coding-standards","model-context-protocol"],engines:{node:">=20"},type:"module",main:"dist/index.js",bin:{superclawd:"dist/index.js"},files:["dist","README.md","LICENSE"],scripts:{build:"node build.mjs",dev:"node build.mjs && tsx src/index.ts",typecheck:"tsc --noEmit",lint:"eslint 'src/**/*.{ts,tsx}'","lint:fix":"eslint 'src/**/*.{ts,tsx}' --fix",format:"prettier --check 'src/**/*.{ts,tsx}'","format:fix":"prettier --write 'src/**/*.{ts,tsx}'",selftest:"tsx test/mcp-selftest.ts","test:guardrails":"tsx test/guardrails-eval.test.ts",test:"node build.mjs && tsx test/mcp-selftest.ts && tsx test/pipelines-tools.test.ts && tsx test/guardrails-eval.test.ts && tsx test/hooks-capture.test.ts && tsx test/translator-teams.test.ts && tsx test/run-args.test.ts && tsx test/pipelines.test.ts && tsx test/update-check.test.ts && tsx test/retrieve.test.ts && tsx test/config-private-memory.test.ts && tsx test/config-choose-workspace.test.ts && tsx test/config.test.ts && tsx test/translator-basics.test.ts && tsx test/hook-helper-guardrails.test.ts && tsx test/capture-prompts.test.ts && tsx test/mcp-backend-real.test.ts && tsx test/catalog.test.ts && tsx test/fda.test.ts && tsx test/models.test.ts",prepublishOnly:"npm run build","publish:npm":"npm publish","version:bump":"npm version patch --no-git-tag-version"},dependencies:{"@modelcontextprotocol/sdk":"^1.7.0",zod:"^3.24.2"},devDependencies:{"@eslint/js":"^9.39.1","@types/node":"^22.10.0","@typescript-eslint/eslint-plugin":"^8.44.1","@typescript-eslint/parser":"^8.44.1",esbuild:"^0.24.0",eslint:"^9.36.0","eslint-config-prettier":"^10.1.8","eslint-plugin-prettier":"^5.5.4",prettier:"^3.6.2",tsx:"^4.19.0",typescript:"^5.7.0"}};var Go=Date.now();function te(e){process.env.SUPERCLAWD_TIMING==="1"&&process.stderr.write(`[timing] ${Date.now()-Go} ms ${e}
246
- `)}var Ce=On.version,Re=process.env.SUPERCLAWD_DRY_RUN==="1"||process.argv.includes("--dry-run");function Yo(){try{let e=Uo("git remote get-url origin",{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim();if(e)return e.replace(/\.git$/,"").toLowerCase()}catch{}return`dir:${Fo(process.cwd())}`}function Ko(){if(process.env.SUPERCLAWD_MCP_SERVER_PATH)return process.env.SUPERCLAWD_MCP_SERVER_PATH;let e=In(new URL("./mcp-server.mjs",import.meta.url));return Tn(e)?e:In(new URL("../dist/mcp-server.mjs",import.meta.url))}function Bo(){return`superclawd \u2014 Claude Code, supercharged with your SuperClawd workspace.
232
+ `)},handoff(){},finish(){}}}function No(e,t){let n=Wo(),r=0,o=!0,s=!1,i=d=>{d.includes(3)&&f()},l=()=>{let d=process.stdin;if(d.isTTY){try{d.setRawMode(!0)}catch{}d.resume(),d.on("data",i),s=!0}},u=()=>{if(!s)return;let d=process.stdin;d.off("data",i);try{d.setRawMode(!1)}catch{}d.pause(),s=!1},a=()=>{u();try{process.stdin.isTTY&&process.stdin.setRawMode(!1)}catch{}F(Xe+$n+Ln),n&&Dn(n)},f=()=>{o&&a(),o=!1,process.exit(130)},y=()=>{u(),o&&F(Xe+$n+Ln)},R=()=>{process.off("SIGINT",f),process.off("SIGTERM",f),process.off("exit",y),Ee=null};Dn("-echo"),F(Oo+Io+Lo+$o),l(),process.on("SIGINT",f),process.on("SIGTERM",f),process.on("exit",y),Ee=a;let _=(d,g)=>{let b=process.stdout.columns||80,m=process.stdout.rows||24,c=Math.floor(d*ne/e);c<0&&(c=0),c>ne&&(c=ne);let P="\u2588".repeat(c)+"\u2591".repeat(ne-c),C=Math.floor(d*100/e),k=ne+6,p=Math.max(0,Math.floor((m-9)/2)),S=Qe+`
233
+ `.repeat(p),E=Math.max(0,Math.floor((b-Tn)/2));for(let Hn of ke)S+=`${J(E)}${G}${Hn}${O}
234
+ `;S+=`
235
+ `;let N=Math.max(0,Math.floor((b-g.length)/2));S+=`${J(N)}${q}${g}${O}
236
+
237
+ `;let oe=Math.max(0,Math.floor((b-k)/2));S+=`${J(oe)}${G}${P}${O} ${String(C).padStart(3)}%
238
+ `;let se=`v${t}`,Pe=Math.max(1,m-1),Ce=Math.max(1,b-se.length-1);S+=`${M}[${Pe};${Ce}H${G}${se}${O}`,F(S)},v=async(d,g,b)=>{let m=b-(Date.now()-r);m>0&&await Uo(m),_(d,g),r=Date.now()},w=d=>{let g=process.stdout.columns||80,b=process.stdout.rows||24,m=Math.max(0,Math.floor((b-(ke.length+1+d.length))/2)),c=Qe+`
239
+ `.repeat(m),P=Math.max(0,Math.floor((g-Tn)/2));for(let k of ke)c+=`${J(P)}${G}${k}${O}
240
+ `;c+=`
241
+ `;for(let k of d)c+=`${k}
242
+ `;let C=`v${t}`;c+=`${M}[${Math.max(1,b-1)};${Math.max(1,g-C.length-1)}H${G}${C}${O}`,F(c)},h=(d,g,b)=>{let m=process.stdout.columns||80,c="Select your workspace \u2191/\u2193 \xB7 enter launches \xB7 d sets default \xB7 esc cancels",P=Math.max(0,Math.floor((m-c.length)/2)),C=E=>` ${E.name} ${E.slug} \xB7 ${E.role}`,k=Math.max(...d.map(E=>C(E).length)),p=Math.max(0,Math.floor((m-k)/2)),S=[`${J(P)}${q}${c}${O}`,""];for(let E=0;E<d.length;E++){let N=d[E],oe=E===g,se=oe?`${G}\u276F `:" ",Pe=oe?`${G}${N.name}${O}`:N.name,Ce=N.slug===b?` ${G}\u2605 default${O}`:"";S.push(`${J(p)}${se}${Pe} ${q}${N.slug} \xB7 ${N.role}${O}${Ce}`)}w(S)};return{phase:(d,g)=>v(d-1,g,To),ready:d=>v(e,d,Do),message(d){let g=process.stdout.columns||80,b=Math.max(0,Math.floor((g-d.length)/2));w([`${J(b)}${q}${d}${O}`]),r=Date.now()},selectWorkspace(d,g){return new Promise(b=>{let m=g?.currentSlug?d.findIndex(k=>k.slug===g.currentSlug):-1,c=m>=0?m:0,P=g?.defaultSlug;s&&process.stdin.off("data",i),h(d,c,P);let C=k=>{let p=k.toString();p===""||p===M?(process.stdin.off("data",C),b(null)):p==="\r"||p===`
243
+ `?(process.stdin.off("data",C),process.stdin.on("data",i),b(d[c].slug)):p==="d"||p==="D"?(P=d[c].slug,g?.onSetDefault?.(P),h(d,c,P)):p===`${M}[A`||p==="k"?(c=(c-1+d.length)%d.length,h(d,c,P)):(p===`${M}[B`||p==="j")&&(c=(c+1)%d.length,h(d,c,P))};process.stdin.on("data",C)})},fail(d){o&&a(),o=!1,R(),process.stderr.write(`${Re}\u2717 ${d}${O}
244
+ `)},note(){},handoff(){s&&(process.stdin.off("data",i),process.stdin.pause(),s=!1),F(Qe+Xe),process.off("SIGINT",f),process.off("SIGTERM",f)},finish(){o&&a(),o=!1,R()}}}function jo(){return process.platform!=="win32"?!0:!!(process.env.WT_SESSION||process.env.TERM_PROGRAM||process.env.TERM)}function Go(){return{async phase(){},message(){},async selectWorkspace(e,t){return t?.currentSlug??e[0]?.slug??null},async ready(){},fail(e){process.stderr.write(`${Re}\u2717 ${e}${O}
245
+ `)},note(){},handoff(){},finish(){}}}function Nn(e){if(e.quiet)return Go();let t=process.stdout.isTTY===!0,n=e.version??"";return e.plain||!t||!jo()?Fo(e.total,n):No(e.total,n)}var Ko=["text","json","stream-json"],Yo=["auto"],Bo=/^(?:0*[1-9]\d*(?:\.\d+)?|0*\.\d*[1-9]\d*|0+\.\d*[1-9]\d*)$/,Ho=/^[1-9]\d*$/,Jo=["low","medium","high","xhigh","max"];function jn(e){let t=!1,n="",r=null,o=!1,s=!1,i=!1,l=null,u=!1,a=!1,f="board",y=null,R=null,_=null,v=!1,w=null,h=null,d=null,g=null,b=!1,m=null,c=null,P=[],C=(k,p,S)=>p!==void 0&&!p.startsWith("--")&&S(p)?p:(P.push(k),null);for(let k=0;k<e.length;k++){let p=e[k],S=e[k+1];if(p==="-p"||p==="--print")t=!0,S&&!S.startsWith("-")&&(n=S,k++);else if(p==="--workspace"||p==="-w")S&&!S.startsWith("-")&&(r=S,k++);else if(p==="--no-capture")o=!0;else if(p==="--no-memory")s=!0;else if(p==="--resume"||p==="-r")i=!0,S&&!S.startsWith("-")&&(l=S,k++);else if(p==="--pipelines")u=!0;else if(p==="--pipelines-tools")a=!0;else if(p.startsWith("--pipelines-tools="))a=!0,f=p.slice(18)==="restricted"?"restricted":"board";else if(p==="--session-id")S&&!S.startsWith("-")&&(y=S,k++);else if(p==="--model")S&&!S.startsWith("-")&&(R=S,k++);else if(p==="--fda")v=!0;else if(p==="--plan-only")b=!0;else if(p==="--agent")w=C(p,S,E=>!E.startsWith("-")),w!==null&&k++;else if(p==="--prompt-file")h=C(p,S,E=>!E.startsWith("-")),h!==null&&k++;else if(p==="--output-format"){let E=C(p,S,N=>Ko.includes(N));E!==null&&(d=E,k++)}else if(p==="--permission-mode"){let E=C(p,S,N=>Yo.includes(N));E!==null&&(g=E,k++)}else p==="--max-budget-usd"?(m=C(p,S,E=>Bo.test(E)),m!==null&&k++):p==="--max-turns"?(c=C(p,S,E=>Ho.test(E)),c!==null&&k++):p==="--effort"&&S&&Jo.includes(S)&&(_=S,k++)}return{printMode:t,printPrompt:n,workspace:r,noCapture:o,noMemory:s,resume:i,resumeSessionId:l,pipelines:u,pipelinesTools:a,pipelinesToolsMode:f,sessionId:y,model:R,effort:_,fda:v,agent:w,promptFile:h,outputFormat:d,permissionMode:g,planOnly:b,maxBudgetUsd:m,maxTurns:c,invalid:P}}var Gn={name:"superclawd",version:"0.1.132",description:"Claude Code, supercharged \u2014 your team's standards, every session. The superclawd CLI loads your workspace's skills, agents, commands, workflows, and live directives into Claude Code as a plugin.",author:"SuperClawd <support@superclawd.com>",license:"SEE LICENSE IN LICENSE",homepage:"https://superclawd.com",repository:{type:"git",url:"git+https://github.com/superclawd-ai/superclawd.git"},bugs:{url:"https://github.com/superclawd-ai/superclawd/issues"},keywords:["superclawd","claude-code","claude","plugin","skills","agents","mcp","ai-assistant","coding-standards","model-context-protocol"],engines:{node:">=20"},type:"module",main:"dist/index.js",bin:{superclawd:"dist/index.js"},files:["dist","README.md","LICENSE"],scripts:{build:"node build.mjs",dev:"node build.mjs && tsx src/index.ts",typecheck:"tsc --noEmit",lint:"eslint 'src/**/*.{ts,tsx}'","lint:fix":"eslint 'src/**/*.{ts,tsx}' --fix",format:"prettier --check 'src/**/*.{ts,tsx}'","format:fix":"prettier --write 'src/**/*.{ts,tsx}'",selftest:"tsx test/mcp-selftest.ts","test:guardrails":"tsx test/guardrails-eval.test.ts",test:"node build.mjs && tsx test/mcp-selftest.ts && tsx test/pipelines-tools.test.ts && tsx test/guardrails-eval.test.ts && tsx test/hooks-capture.test.ts && tsx test/translator-teams.test.ts && tsx test/run-args.test.ts && tsx test/pipelines.test.ts && tsx test/update-check.test.ts && tsx test/retrieve.test.ts && tsx test/config-private-memory.test.ts && tsx test/config-choose-workspace.test.ts && tsx test/config.test.ts && tsx test/translator-basics.test.ts && tsx test/hook-helper-guardrails.test.ts && tsx test/capture-prompts.test.ts && tsx test/mcp-backend-real.test.ts && tsx test/catalog.test.ts && tsx test/fda.test.ts && tsx test/models.test.ts && tsx test/provider.test.ts",prepublishOnly:"npm run build","publish:npm":"npm publish","version:bump":"npm version patch --no-git-tag-version"},dependencies:{"@modelcontextprotocol/sdk":"^1.7.0",zod:"^3.24.2"},devDependencies:{"@eslint/js":"^9.39.1","@types/node":"^22.10.0","@typescript-eslint/eslint-plugin":"^8.44.1","@typescript-eslint/parser":"^8.44.1",esbuild:"^0.24.0",eslint:"^9.36.0","eslint-config-prettier":"^10.1.8","eslint-plugin-prettier":"^5.5.4",prettier:"^3.6.2",tsx:"^4.19.0",typescript:"^5.7.0"}};var ts=Date.now();function re(e){process.env.SUPERCLAWD_TIMING==="1"&&process.stderr.write(`[timing] ${Date.now()-ts} ms ${e}
246
+ `)}var ve=Gn.version,_e=process.env.SUPERCLAWD_DRY_RUN==="1"||process.argv.includes("--dry-run");function ns(){try{let e=zo("git remote get-url origin",{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim();if(e)return e.replace(/\.git$/,"").toLowerCase()}catch{}return`dir:${Qo(process.cwd())}`}function rs(){if(process.env.SUPERCLAWD_MCP_SERVER_PATH)return process.env.SUPERCLAWD_MCP_SERVER_PATH;let e=Kn(new URL("./mcp-server.mjs",import.meta.url));return Bn(e)?e:Kn(new URL("../dist/mcp-server.mjs",import.meta.url))}function os(){return`superclawd \u2014 Claude Code, supercharged with your SuperClawd workspace.
247
247
 
248
248
  Usage:
249
249
  superclawd Launch Claude with your skills/agents/directives loaded
@@ -268,16 +268,17 @@ Print-mode flags (with -p):
268
268
  --no-memory No SuperClawd memory for this run (nothing loaded, no memory tools, no capture)
269
269
 
270
270
  Not authenticated yet? Run \`superclawd login\` first.
271
- `}function Ho(){try{return!Do("claude",["--version"],{stdio:"ignore"}).error}catch{return!1}}function qo(e,t=[],n,r,o,s,i,l={}){let u=["--plugin-dir",e.pluginDir];u.push(...wn(t,{planOnly:l.planOnly,permissionMode:l.permissionMode,skipPermissions:nt()||!!n})),l.agent&&u.push("--agent",l.agent),l.outputFormat&&(u.push("--output-format",l.outputFormat),l.outputFormat==="stream-json"&&u.push("--verbose")),l.maxBudgetUsd&&u.push("--max-budget-usd",l.maxBudgetUsd),l.maxTurns&&u.push("--max-turns",l.maxTurns),r?(u.push("--resume"),r.sessionId&&u.push(r.sessionId)):o&&u.push("--session-id",o),s&&u.push("--model",s),i&&u.push("--effort",i);let a=n&&l.promptOnStdin?n.prompt:null;return n&&(u.push("-p"),a===null&&u.push(n.prompt)),new Promise(f=>{let S=Ln("claude",u,{stdio:a!==null?["pipe","inherit","inherit"]:"inherit",env:process.env.SUPERCLAWD_MEMORY_OFF==="1"?{...process.env}:{...process.env,CLAUDE_CODE_DISABLE_AUTO_MEMORY:"1"}});a!==null&&S.stdin&&(S.stdin.on("error",()=>{}),S.stdin.end(a)),l.fda&&Ke(S),S.on("error",y=>f({code:127,error:`Could not launch claude: ${y.message}. Is Claude Code installed and on PATH?`})),S.on("close",(y,b)=>f({code:y??Be(b)}))})}function Jo(){return process.stdout.write(`Updating superclawd (npm i -g superclawd@latest)\u2026
272
- `),new Promise(e=>{let t=Ln("npm install -g superclawd@latest",{stdio:"inherit",shell:!0});t.on("error",n=>{process.stderr.write(`\u2717 Could not run npm: ${n.message}. Is npm on your PATH?
271
+ `}function ss(){try{return!Vo("claude",["--version"],{stdio:"ignore"}).error}catch{return!1}}function is(e,t=[],n,r,o,s,i,l={}){let u=["--plugin-dir",e.pluginDir];u.push(...An(t,{planOnly:l.planOnly,permissionMode:l.permissionMode,skipPermissions:st()||!!n})),l.agent&&u.push("--agent",l.agent),l.outputFormat&&(u.push("--output-format",l.outputFormat),l.outputFormat==="stream-json"&&u.push("--verbose")),l.maxBudgetUsd&&u.push("--max-budget-usd",l.maxBudgetUsd),l.maxTurns&&u.push("--max-turns",l.maxTurns),r?(u.push("--resume"),r.sessionId&&u.push(r.sessionId)):o&&u.push("--session-id",o),s&&u.push("--model",s),i&&u.push("--effort",i);let a=n&&l.promptOnStdin?n.prompt:null;return n&&(u.push("-p"),a===null&&u.push(n.prompt)),new Promise(f=>{let y=Yn("claude",u,{stdio:a!==null?["pipe","inherit","inherit"]:"inherit",env:{...process.env,...process.env.SUPERCLAWD_MEMORY_OFF==="1"?{}:{CLAUDE_CODE_DISABLE_AUTO_MEMORY:"1"},...l.providerEnv??{}}});a!==null&&y.stdin&&(y.stdin.on("error",()=>{}),y.stdin.end(a)),l.fda&&Je(y),y.on("error",R=>f({code:127,error:`Could not launch claude: ${R.message}. Is Claude Code installed and on PATH?`})),y.on("close",(R,_)=>f({code:R??qe(_)}))})}function as(){return process.stdout.write(`Updating superclawd (npm i -g superclawd@latest)\u2026
272
+ `),new Promise(e=>{let t=Yn("npm install -g superclawd@latest",{stdio:"inherit",shell:!0});t.on("error",n=>{process.stderr.write(`\u2717 Could not run npm: ${n.message}. Is npm on your PATH?
273
273
  `),e(127)}),t.on("close",n=>{n===0?process.stdout.write("\u2713 Updated. Run `superclawd version` to confirm.\n"):process.stderr.write(`\u2717 Update failed (npm exited ${n}).
274
- `),e(n??1)})})}async function Vo(e){let t=null,n=(c,R)=>(t?.(),t=null,e.fda?he(c,R):(process.stderr.write(`${R}
275
- `),1)),r;if(e.fda){if(e.invalid.length)return n("badFlags",`Invalid value for: ${[...new Set(e.invalid)].join(", ")}`);if(!e.promptFile)return n("badFlags","--fda requires --prompt-file (the prompt never goes on the command line).");if(e.printPrompt)return n("badFlags","Use either -p <prompt> or --prompt-file, not both.");if(e.planOnly&&e.permissionMode)return n("badFlags","--plan-only and --permission-mode are exclusive.");let c=cn(process.env.SUPERCLAWD_FDA_MCP_FILE);if(!c)return n("badFlags","SUPERCLAWD_FDA_MCP_FILE is missing, unreadable, or has no FDA server.");r=c}if(e.promptFile)try{e={...e,printMode:!0,printPrompt:Wo(e.promptFile,"utf8")}}catch(c){return n("badFlags",`Cannot read --prompt-file: ${String(c)}`)}if(e.printMode&&!e.printPrompt.trim())return n("badFlags",'Provide a prompt: superclawd -p "<your prompt>"');if((e.pipelines||e.fda)&&(process.env.SUPERCLAWD_NO_UPDATE="1"),e.pipelinesTools&&(process.env.SUPERCLAWD_PIPELINES_TOOLS=e.pipelinesToolsMode),!Re&&!e.fda){let c=await kt(Ce,process.argv.slice(2));if(c.exitCode!==void 0)return c.exitCode}if(e.noCapture&&(process.env.SUPERCLAWD_NO_CAPTURE="1"),e.noMemory&&(process.env.SUPERCLAWD_MEMORY_OFF="1",process.env.SUPERCLAWD_NO_CAPTURE="1"),!Re&&!Ho())return e.fda?n("claudeMissing","Claude Code isn't installed or isn't on PATH."):(process.stderr.write(`\u2717 Claude Code isn't installed (or isn't on your PATH).
274
+ `),e(n??1)})})}async function ls(e){let t=null,n=(c,P)=>(t?.(),t=null,e.fda?we(c,P):(process.stderr.write(`${P}
275
+ `),1)),r;if(e.fda){if(e.invalid.length)return n("badFlags",`Invalid value for: ${[...new Set(e.invalid)].join(", ")}`);if(!e.promptFile)return n("badFlags","--fda requires --prompt-file (the prompt never goes on the command line).");if(e.printPrompt)return n("badFlags","Use either -p <prompt> or --prompt-file, not both.");if(e.planOnly&&e.permissionMode)return n("badFlags","--plan-only and --permission-mode are exclusive.");let c=yn(process.env.SUPERCLAWD_FDA_MCP_FILE);if(!c)return n("badFlags","SUPERCLAWD_FDA_MCP_FILE is missing, unreadable, or has no FDA server.");r=c}if(e.promptFile)try{e={...e,printMode:!0,printPrompt:Xo(e.promptFile,"utf8")}}catch(c){return n("badFlags",`Cannot read --prompt-file: ${String(c)}`)}if(e.printMode&&!e.printPrompt.trim())return n("badFlags",'Provide a prompt: superclawd -p "<your prompt>"');if((e.pipelines||e.fda)&&(process.env.SUPERCLAWD_NO_UPDATE="1"),e.pipelinesTools&&(process.env.SUPERCLAWD_PIPELINES_TOOLS=e.pipelinesToolsMode),!_e&&!e.fda){let c=await Ut(ve,process.argv.slice(2));if(c.exitCode!==void 0)return c.exitCode}if(e.noCapture&&(process.env.SUPERCLAWD_NO_CAPTURE="1"),e.noMemory&&(process.env.SUPERCLAWD_MEMORY_OFF="1",process.env.SUPERCLAWD_NO_CAPTURE="1"),!_e&&!ss())return e.fda?n("claudeMissing","Claude Code isn't installed or isn't on PATH."):(process.stderr.write(`\u2717 Claude Code isn't installed (or isn't on your PATH).
276
276
 
277
277
  SuperClawd supercharges Claude Code, so you'll need it first:
278
278
  \u2192 https://claude.com/code
279
279
 
280
280
  Once it's installed, run \`superclawd\` again.
281
- `),1);_||ut(),!_&&ot()&&(process.env.SUPERCLAWD_EXPERIMENTAL="true"),process.env.SUPERCLAWD_REPO_FINGERPRINT=Yo();let o=pt();if(!o.ok&&!_)return n("credentials",o.error??"Could not resolve credentials.");let s=o.session;e.workspace&&(s={...s,workspace:e.workspace});let i=xn({total:5,plain:Re,quiet:e.printMode,version:Ce});if(t=()=>i.finish(),!_&&!e.printMode&&!e.workspace&&process.stdin.isTTY&&(!s.workspace||rt())){let c=await $e(i,s);if(c.cancelled)return i.finish(),130;c.workspace&&(s={...s,workspace:c.workspace})}if(!_&&!s.workspace)return n("workspaceInvalid","No workspace selected. Pass --workspace <id>, set SUPERCLAWD_MCP_WORKSPACE, or run `superclawd` interactively once to pick a default.");await i.phase(1,"Resolving credentials\u2026"),await i.phase(2,"Authenticating\u2026");let l=e.fda?Le(s).then(c=>({c}),c=>({e:c})):null;te("start \u2192 auth");let u=await Oe(s);if(te("auth done"),u.workspaceInvalid&&!_&&!e.printMode&&!e.workspace&&process.stdin.isTTY){ce();let c=await $e(i,{...s,workspace:""});if(c.cancelled)return i.finish(),130;c.workspace&&(s={...s,workspace:c.workspace},await i.phase(2,"Authenticating\u2026"),u=await Oe(s))}if(!u.ok)return e.fda?n(u.kind==="credentials"?"credentials":u.kind==="workspace"?"workspaceInvalid":"cloudUnavailable",u.error??"Authentication failed."):(i.fail(u.error??"Authentication failed."),1);await i.phase(3,_?"Loading mock catalog\u2026":"Fetching your workspace\u2026");let a;try{if(l){let c=await l;if("e"in c)throw c.e;a=c.c}else a=await Le(s);te("catalog done")}catch(c){return e.fda?n("cloudUnavailable",`Catalog fetch failed: ${String(c)}`):(i.fail(`Catalog fetch failed: ${String(c)}`),1)}if(e.noMemory&&(a=xt(a)),process.env.SUPERCLAWD_TEAM_MEMORY=a.teamMemoryEnabled?"1":"0",process.env.SUPERCLAWD_REPO_MEMORY=a.repoMemoryEnabled?"1":"0",process.env.SUPERCLAWD_AGENT_MEMORY=a.agentMemoryEnabled?"1":"0",process.env.SUPERCLAWD_PRIVATE_MEMORY=_||it()?"1":"0",e.noMemory)for(let c of["SUPERCLAWD_TEAM_MEMORY","SUPERCLAWD_REPO_MEMORY","SUPERCLAWD_AGENT_MEMORY","SUPERCLAWD_PRIVATE_MEMORY"])process.env[c]="0";await i.phase(4,"Establishing session\u2026"),kn();let f=yn();ct(f.dir,s.workspace,e.pipelines===!0||e.fda);let S=Ko();if(!Tn(S)){we(f);let c=`Bundled MCP server not found at ${S}. Run \`npm run build\` first.`;return e.fda?n("badFlags",c):(i.fail(c),1)}await $t(s,f.id,e.pipelines!==!0&&!e.fda),te("session established"),e.fda&&(process.env.SUPERCLAWD_FOUNDATIONAL_FROM_LAUNCH="1"),await i.phase(5,"Generating plugin\u2026");let y=hn({pluginDir:f.pluginDir,session:s,catalog:a,serverPath:S,launchId:f.id,fda:e.fda,fdaServers:r}),b=e.agent?.startsWith("superclawd:")?e.agent.slice(11):null;if(b!==null&&!y.agentSlugs.includes(b))return we(f),n("agentNotFound",`Agent "${b}" isn't available in this workspace (deleted or disabled?).`);if(!_&&!e.fda)try{let c=jo(No(S),"hook-helper.mjs"),R=Ht({cwd:process.cwd(),helperPath:c,env:{SUPERCLAWD_BACKEND:z,SUPERCLAWD_MCP_API_URL:s.apiUrl,SUPERCLAWD_REPO_FINGERPRINT:process.env.SUPERCLAWD_REPO_FINGERPRINT,SUPERCLAWD_MCP_KEY:s.keyId,SUPERCLAWD_MCP_SECRET:s.secret,SUPERCLAWD_MCP_WORKSPACE:s.workspace,NODE_EXTRA_CA_CERTS:process.env.NODE_EXTRA_CA_CERTS,SUPERCLAWD_HOME:process.env.SUPERCLAWD_HOME,SUPERCLAWD_CLAUDE_BIN:process.env.SUPERCLAWD_CLAUDE_BIN,SUPERCLAWD_POLICY_MODEL:process.env.SUPERCLAWD_POLICY_MODEL}});!R.installed&&R.reason!=="not a git repo"&&i.note(`Post-commit hook: ${R.reason}`)}catch{}let P=_?"mock":s.workspace;if(await i.ready(`${P} \xB7 ${y.skillCount} skills \xB7 ${y.commandCount} commands \xB7 ${y.workflowCount} workflows`),Re){i.note("Dry run \u2014 not launching Claude. Generated files:");for(let c of y.files)i.note(` ${c}`);return 0}i.handoff();let E=!_&&st()?mt():null;te("spawning claude");let{code:h,error:d}=await qo(f,y.mcpServerNames,e.printMode?{prompt:e.printPrompt}:void 0,e.resume?{sessionId:e.resumeSessionId}:void 0,e.sessionId,oe(e.model,a.modelFamilies),e.effort,{agent:e.agent,outputFormat:e.outputFormat,permissionMode:e.permissionMode,planOnly:e.planOnly,maxBudgetUsd:e.maxBudgetUsd,maxTurns:e.maxTurns,promptOnStdin:!!e.promptFile,fda:e.fda});return E?.stop(),i.finish(),we(f),d&&e.fda?he("claudeMissing",d):(d&&process.stderr.write(`${d}
282
- `),d?127:h)}async function Xo(){let e=await En();return e.cancelled||e.ok?0:(process.stderr.write(`\u2717 ${e.error??"Login failed."}
283
- `),1)}async function zo(){let[e]=process.argv.slice(2).filter(t=>t!=="--dry-run");switch(e){case"login":process.exit(await Xo());return;case"config":await Rn(),process.exit(0);return;case"update":process.exit(await Jo());return;case"pipelines":{let t=process.argv.slice(2).filter(n=>n!=="--dry-run");process.exit(await sn(t.slice(t.indexOf("pipelines")+1)));return}case"fda":{let t=process.argv.slice(2);process.exit(await fn(t.slice(t.indexOf("fda")+1)));return}case"version":case"--version":case"-v":process.argv.includes("--json")?console.log(JSON.stringify({version:Ce,features:["fda-1","no-memory"]})):console.log(Ce);return;case"help":case"--help":case"-h":console.log(Bo());return;default:process.exit(await Vo($n(process.argv.slice(2))))}}zo().catch(e=>{process.argv.includes("--fda")&&process.exit(he("badFlags",`Unexpected error: ${String(e)}`)),An(String(e)),process.exit(1)});
281
+ `),1);A||ft(),!A&&at()&&(process.env.SUPERCLAWD_EXPERIMENTAL="true"),process.env.SUPERCLAWD_REPO_FINGERPRINT=ns();let o=gt();if(!o.ok&&!A)return n("credentials",o.error??"Could not resolve credentials.");let s=o.session;e.workspace&&(s={...s,workspace:e.workspace});let i=Nn({total:5,plain:_e,quiet:e.printMode,version:ve});if(t=()=>i.finish(),!A&&!e.printMode&&!e.workspace&&process.stdin.isTTY&&(!s.workspace||it())){let c=await We(i,s);if(c.cancelled)return i.finish(),130;c.workspace&&(s={...s,workspace:c.workspace})}if(!A&&!s.workspace)return n("workspaceInvalid","No workspace selected. Pass --workspace <id>, set SUPERCLAWD_MCP_WORKSPACE, or run `superclawd` interactively once to pick a default.");await i.phase(1,"Resolving credentials\u2026"),await i.phase(2,"Authenticating\u2026");let l=e.fda?je(s).then(c=>({c}),c=>({e:c})):null;re("start \u2192 auth");let u=await Fe(s);if(re("auth done"),u.workspaceInvalid&&!A&&!e.printMode&&!e.workspace&&process.stdin.isTTY){pe();let c=await We(i,{...s,workspace:""});if(c.cancelled)return i.finish(),130;c.workspace&&(s={...s,workspace:c.workspace},await i.phase(2,"Authenticating\u2026"),u=await Fe(s))}if(!u.ok)return e.fda?n(u.kind==="credentials"?"credentials":u.kind==="workspace"?"workspaceInvalid":"cloudUnavailable",u.error??"Authentication failed."):(i.fail(u.error??"Authentication failed."),1);await i.phase(3,A?"Loading mock catalog\u2026":"Fetching your workspace\u2026");let a;try{if(l){let c=await l;if("e"in c)throw c.e;a=c.c}else a=await je(s);re("catalog done")}catch(c){return e.fda?n("cloudUnavailable",`Catalog fetch failed: ${String(c)}`):(i.fail(`Catalog fetch failed: ${String(c)}`),1)}if(e.noMemory&&(a=Jt(a)),process.env.SUPERCLAWD_TEAM_MEMORY=a.teamMemoryEnabled?"1":"0",process.env.SUPERCLAWD_REPO_MEMORY=a.repoMemoryEnabled?"1":"0",process.env.SUPERCLAWD_AGENT_MEMORY=a.agentMemoryEnabled?"1":"0",process.env.SUPERCLAWD_PRIVATE_MEMORY=A||ct()?"1":"0",e.noMemory)for(let c of["SUPERCLAWD_TEAM_MEMORY","SUPERCLAWD_REPO_MEMORY","SUPERCLAWD_AGENT_MEMORY","SUPERCLAWD_PRIVATE_MEMORY"])process.env[c]="0";await i.phase(4,"Establishing session\u2026"),xn();let f=bn();pt(f.dir,s.workspace,e.pipelines===!0||e.fda);let y=rs();if(!Bn(y)){Q(f);let c=`Bundled MCP server not found at ${y}. Run \`npm run build\` first.`;return e.fda?n("badFlags",c):(i.fail(c),1)}await qt(s,f.id,e.pipelines!==!0&&!e.fda),re("session established"),e.fda&&(process.env.SUPERCLAWD_FOUNDATIONAL_FROM_LAUNCH="1");let R=e.agent?.startsWith("superclawd:")?X(a.agents).find(c=>c.slug===e.agent.slice(11))?.agent??null:null,_=yt({model:e.model,agent:R}),v={};if(_.kind==="openrouter"){let c=kt();if(!c){Q(f);let C=`This session runs on OpenRouter (${_.model}) but no OpenRouter key is set on this machine. Set OPENROUTER_API_KEY or run \`superclawd config openrouter-key\`.`;return e.fda?n("openrouterKeyMissing",C):(i.fail(C),1)}if(e.fda&&!ht.has(_.model)&&process.env.SUPERCLAWD_FDA_ALLOW_UNVERIFIED!=="1")return Q(f),n("modelNotApproved",`${_.model} isn't approved for FDAs yet (it hasn't passed the secrets tests). Pick an approved model, or allow untested models in the FDA's settings.`);v=Et(_,c);let P=process.env.ANTHROPIC_API_KEY?.trim();if(P){v.SUPERCLAWD_JUDGE_ANTHROPIC_KEY=P;let C=process.env.ANTHROPIC_BASE_URL?.trim();C&&(v.SUPERCLAWD_JUDGE_ANTHROPIC_BASE_URL=C)}}await i.phase(5,"Generating plugin\u2026");let w=Cn({provider:_,pluginDir:f.pluginDir,session:s,catalog:a,serverPath:y,launchId:f.id,fda:e.fda,fdaServers:r}),h=e.agent?.startsWith("superclawd:")?e.agent.slice(11):null;if(h!==null&&!w.agentSlugs.includes(h))return Q(f),n("agentNotFound",`Agent "${h}" isn't available in this workspace (deleted or disabled?).`);if(!A&&!e.fda)try{let c=es(Zo(y),"hook-helper.mjs"),P=nn({cwd:process.cwd(),helperPath:c,env:{SUPERCLAWD_BACKEND:Z,SUPERCLAWD_MCP_API_URL:s.apiUrl,SUPERCLAWD_REPO_FINGERPRINT:process.env.SUPERCLAWD_REPO_FINGERPRINT,SUPERCLAWD_MCP_KEY:s.keyId,SUPERCLAWD_MCP_SECRET:s.secret,SUPERCLAWD_MCP_WORKSPACE:s.workspace,NODE_EXTRA_CA_CERTS:process.env.NODE_EXTRA_CA_CERTS,SUPERCLAWD_HOME:process.env.SUPERCLAWD_HOME,SUPERCLAWD_CLAUDE_BIN:process.env.SUPERCLAWD_CLAUDE_BIN,SUPERCLAWD_POLICY_MODEL:process.env.SUPERCLAWD_POLICY_MODEL}});!P.installed&&P.reason!=="not a git repo"&&i.note(`Post-commit hook: ${P.reason}`)}catch{}let d=A?"mock":s.workspace;if(await i.ready(`${d} \xB7 ${w.skillCount} skills \xB7 ${w.commandCount} commands \xB7 ${w.workflowCount} workflows`),_e){i.note("Dry run \u2014 not launching Claude. Generated files:");for(let c of w.files)i.note(` ${c}`);return 0}i.handoff();let g=!A&&lt()?Ot():null;re("spawning claude");let{code:b,error:m}=await is(f,w.mcpServerNames,e.printMode?{prompt:e.printPrompt}:void 0,e.resume?{sessionId:e.resumeSessionId}:void 0,e.sessionId,_.kind==="openrouter"?_.model:ae(e.model,a.modelFamilies),e.effort,{agent:e.agent,providerEnv:v,outputFormat:e.outputFormat,permissionMode:e.permissionMode,planOnly:e.planOnly,maxBudgetUsd:e.maxBudgetUsd,maxTurns:e.maxTurns,promptOnStdin:!!e.promptFile,fda:e.fda});return g?.stop(),i.finish(),Q(f),m&&e.fda?we("claudeMissing",m):(m&&process.stderr.write(`${m}
282
+ `),m?127:b)}async function cs(){let e=await On();return e.cancelled||e.ok?0:(process.stderr.write(`\u2717 ${e.error??"Login failed."}
283
+ `),1)}async function us(e){if(e)return be(null),console.log("OpenRouter key removed."),0;let t="";if(process.stdin.isTTY){let{createInterface:n}=await import("node:readline"),r=n({input:process.stdin,output:process.stdout,terminal:!0});r._writeToOutput=()=>{},process.stdout.write("OpenRouter API key (input hidden): "),t=await new Promise(o=>r.question("",o)),r.close(),process.stdout.write(`
284
+ `)}else for await(let n of process.stdin)t+=String(n);return t=t.trim(),/^sk-or-[A-Za-z0-9_-]{10,}$/.test(t)?(be(t),console.log(`OpenRouter key saved (\u2026${t.slice(-4)}). OPENROUTER_API_KEY, when set, takes precedence.`),0):(console.error("That doesn't look like an OpenRouter key (sk-or-\u2026). Nothing was saved."),64)}async function ds(){let[e]=process.argv.slice(2).filter(t=>t!=="--dry-run");switch(e){case"login":process.exit(await cs());return;case"config":if(process.argv.slice(2).includes("openrouter-key")){process.exit(await us(process.argv.includes("--clear")));return}await In(),process.exit(0);return;case"update":process.exit(await as());return;case"pipelines":{let t=process.argv.slice(2).filter(n=>n!=="--dry-run");process.exit(await hn(t.slice(t.indexOf("pipelines")+1)));return}case"fda":{let t=process.argv.slice(2);process.exit(await _n(t.slice(t.indexOf("fda")+1)));return}case"version":case"--version":case"-v":process.argv.includes("--json")?console.log(JSON.stringify({version:ve,features:["fda-1","no-memory","providers-1"]})):console.log(ve);return;case"help":case"--help":case"-h":console.log(os());return;default:process.exit(await ls(jn(process.argv.slice(2))))}}ds().catch(e=>{process.argv.includes("--fda")&&process.exit(we("badFlags",`Unexpected error: ${String(e)}`)),Fn(String(e)),process.exit(1)});