infra-kit 0.11.0 → 0.11.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
- import{N as g,Q as x,Z as A,d as f,f as p,i as b}from"./chunk-F656FWV5.js";import{n as P}from"./chunk-RZF36IGQ.js";import{a as _,b as D}from"./chunk-QWVLAZ6N.js";import h from"node:fs/promises";import l from"node:path";import{z as s}from"zod";var c=class extends Error{env;constructor(r,t=null){super(r),this.name="EnvAuthError",this.env=t}};var M="tokens.json",v=1,$=384,R=448,q=s.object({version:s.literal(v).default(v),envs:s.record(s.string().min(1),s.string().min(1))}).strict(),w=async()=>{let e=await A();return l.join(l.dirname(e.userProject),M)},E=async()=>{let e=await w(),r;try{r=await h.readFile(e,"utf-8")}catch{return null}let t;try{t=JSON.parse(r)}catch(o){throw new c(`Invalid JSON in the token store at ${x(e)}: ${o.message}
1
+ import{N as g,Q as x,Z as A,d as f,f as p,i as b}from"./chunk-J6BHN362.js";import{o as P}from"./chunk-ZZ7HCY2S.js";import{a as _,b as D}from"./chunk-QWVLAZ6N.js";import h from"node:fs/promises";import l from"node:path";import{z as s}from"zod";var c=class extends Error{env;constructor(r,t=null){super(r),this.name="EnvAuthError",this.env=t}};var M="tokens.json",v=1,$=384,R=448,q=s.object({version:s.literal(v).default(v),envs:s.record(s.string().min(1),s.string().min(1))}).strict(),w=async()=>{let e=await A();return l.join(l.dirname(e.userProject),M)},E=async()=>{let e=await w(),r;try{r=await h.readFile(e,"utf-8")}catch{return null}let t;try{t=JSON.parse(r)}catch(o){throw new c(`Invalid JSON in the token store at ${x(e)}: ${o.message}
2
2
  Fix or delete the file, then re-add the token with \`infra-kit env-token-set <env>\`.`)}let n=q.safeParse(t);if(!n.success)throw new c(`Invalid token store at ${x(e)}: ${s.prettifyError(n.error)}
3
3
  Fix or delete the file, then re-add the token with \`infra-kit env-token-set <env>\`.`);return n.data},y=async e=>{let r=await w(),t=l.dirname(r),n=l.dirname(t),o=l.dirname(n);for(let a of[o,n,t])await h.mkdir(a,{recursive:!0,mode:R}),await h.chmod(a,R);P(r,`${JSON.stringify(e,null,2)}
4
4
  `,$),await h.chmod(r,$)},K=async(e,r)=>{let t=await E();await y({version:v,envs:{...t?.envs,[e]:r}})},B=async e=>{let r=await E();if(!r||!(e in r.envs))return;let t={...r.envs};delete t[e],await y({version:v,envs:t})};var J=()=>{let e="",r=[],t=!1;return{start(n){e=n,r=[],t=!1},setInteractive(){t=!0},addOption(n,o){r.push({flag:n,value:o})},formatOptions(){return r.map(n=>typeof n.value=="boolean"?n.value?n.flag:"":Array.isArray(n.value)?`${n.flag} "${n.value.join(", ")}"`:`${n.flag} "${n.value}"`).filter(Boolean).join(" ")},snapshot(){return r.length===0?null:{formattedOptions:this.formatOptions()}},print(){!t||r.length===0||!e||g.info(`\u{1F4DF} Equivalent command:
5
5
  pnpm exec infra-kit ${e} ${this.formatOptions()}
6
6
  `)},reset(){e="",r=[],t=!1}}},S=J();import{isAbsolute as I,resolve as j}from"node:path";import L from"node:process";var k=null,O=null,W=e=>{k=[...e],O=L.cwd()},z=new Set(["--yes","-y"]),U=(e,r)=>{let t=[...e];for(let[n,o]of t.entries())o==="-C"&&t[n+1]!==void 0&&!I(t[n+1])?t[n+1]=j(r,t[n+1]):o.startsWith("-C")&&o.length>2&&!o.startsWith("--")&&!I(o.slice(2))&&(t[n]=`-C${j(r,o.slice(2))}`);return t},T=()=>{if(k===null||O===null)return["--yes"];let e=U(k.slice(2),O);return e.some(t=>z.has(t))?e:[...e,"--yes"]};import N from"node:process";var i=class extends b{structuredContent;exitCode;constructor(r,t,n){super(void 0,n),this.name="StructuredRefusalError",this.structuredContent=r,this.exitCode=t}};var Y=27,G=e=>e===null?"an interactive prompt was reached under --json, which never prompts":`an interactive prompt was reached in agent mode (${e==="flag"?"--agent":"INFRA_KIT_AGENT / CLAUDECODE"}), where there is no human to answer it`,V=e=>`${e===void 0?"pass the value explicitly instead of relying on the prompt":`pass --${e}`} on the re-run`,Q=e=>{if(typeof e=="object"&&"value"in e)return e.value;let r=typeof e=="object"?e.refuse:void 0,{source:t}=f;throw new i(r===void 0?{status:"refused",agentMode:t}:{status:"argument_required",argument:r,agentMode:t},2,{operation:"interactive prompt",remediation:V(r),stderrExcerpt:G(t)})},F=async(e,r)=>{let t=new AbortController,{whenHeadless:n="refuse",...o}=r??{},a={...o,signal:t.signal};if(p())return Q(n);if(!N.stdin.isTTY)return e(a);let m=N.stdin,C=d=>{d.length===1&&d[0]===Y&&t.abort()};_();try{let d=e(a);return m.isPaused()&&m.resume(),m.on("data",C),await d}finally{m.removeListener("data",C),D()}};import X from"@inquirer/confirm";import Z from"node:process";var u=class extends Error{constructor(r="Operation cancelled by the operator"){super(r),this.name="CommandDeclinedError"}},Ce=e=>e instanceof u;var H=(e,r)=>{let{source:t}=f,n=T();throw new i({status:"confirmation_required",message:e,plan:r,rerun:n,agentMode:t},2,{operation:"confirm before running",remediation:t===null?"pass `--yes` to confirm, or drop `--json` to be prompted":`show the plan to the human, then re-run \`infra-kit ${n.join(" ")}\` to confirm`,stderrExcerpt:"confirmation required and nobody to ask"})},ee=async(e,r,t={})=>{!e&&p()&&H(r,t.plan);let n=e?!0:await F(o=>X({message:r},o),{whenHeadless:"refuse"});if(e||S.setInteractive(),!n){if(t.throwOnDecline)throw new u;g.info("Operation cancelled. Exiting..."),Z.exit(0)}};export{c as a,w as b,E as c,K as d,B as e,i as f,S as g,Ce as h,W as i,F as j,H as k,ee as l};
7
- //# sourceMappingURL=chunk-2H6VQIGT.js.map
7
+ //# sourceMappingURL=chunk-ATGBWGER.js.map
@@ -1,3 +1,3 @@
1
- import{a as P,h as _,l as b,m as A,n as M,o as L}from"./chunk-AWFGP6GY.js";import{l as f,n as N}from"./chunk-RZF36IGQ.js";import{spawnSync as Q}from"node:child_process";import{homedir as X}from"node:os";import y from"node:process";import u from"node:fs";import j from"node:path";import oe from"node:process";var se="update-check.lock",ie=1800*1e3,le=()=>j.join(f(),se),ae=(t,e)=>{try{e-u.statSync(t).mtimeMs>ie&&u.rmSync(t,{force:!0})}catch{}},T=(t={})=>{let e=t.nowMs??Date.now(),n=t.lockPath??le();try{u.mkdirSync(j.dirname(n),{recursive:!0})}catch{return null}let r=()=>{try{return u.openSync(n,"wx",384)}catch{return null}},o=r();if(o===null&&(ae(n,e),o=r()),o===null)return null;try{u.writeFileSync(o,String(oe.pid))}catch{}return()=>{try{u.closeSync(o)}catch{}try{u.rmSync(n,{force:!0})}catch{}}};var ce="https://registry.npmjs.org",ue=5e3,pe=t=>Object.entries(t).find(([n,r])=>/^npm_config_registry$/i.test(n)&&r!=null&&r!=="")?.[1],de=t=>{let e=pe(t),n=e!=null&&e!==""?e:ce;for(;n.endsWith("/");)n=n.slice(0,-1);return n},D=async(t,e=fetch)=>{let n=new AbortController,r=setTimeout(()=>{n.abort()},ue);try{let o=await e(`${de(t)}/${P}/latest`,{signal:n.signal,headers:{accept:"application/json"}});if(!o.ok)return null;let i=(await o.json())?.version;return typeof i=="string"&&i!==""?i:null}catch{return null}finally{clearTimeout(r)}};var me=/^(\d+)\.(\d+)\.(\d+)$/,O=t=>{let[e=""]=t.trim().split("+"),[n="",...r]=e.split("-"),o=me.exec(n);if(!o)return null;let[s,i,l]=[o[1],o[2],o[3]].map(Number);return{release:[s,i,l],prerelease:r.length>0?r.join("-").split("."):[]}},V=/^\d+$/,fe=(t,e)=>{let n=V.test(t),r=V.test(e);return n&&r?Number(t)-Number(e):n!==r?n?-1:1:t<e?-1:1},ge=(t,e)=>{for(let n=0;n<Math.max(t.length,e.length);n+=1){let r=t[n],o=e[n];if(r===void 0)return-1;if(o===void 0)return 1;if(r!==o)return fe(r,o)}return 0},U=(t,e)=>{let n=O(t),r=O(e);if(!n||!r)return!1;for(let i=0;i<3;i+=1){let l=n.release[i],h=r.release[i];if(l!==h)return l>h}let o=n.prerelease.length===0,s=r.prerelease.length===0;return o!==s?o:ge(n.prerelease,r.prerelease)>0};import G from"node:fs";import F from"node:path";var J="update-check.json",he=1200*1e3,Pe=()=>F.join(f(),J),ke=t=>Array.isArray(t)&&t.every(e=>typeof e=="string"),Ce=t=>{if(typeof t!="object"||t===null)return!1;let{outcome:e,checkedMs:n}=t;return typeof e=="string"&&typeof n=="number"&&Number.isFinite(n)},we=t=>{if(typeof t!="object"||t===null)return!1;let{lastCheckMs:e,latestVersion:n,updateCommand:r,outcome:o,plugin:s}=t;return typeof e=="number"&&Number.isFinite(e)&&(n===null||typeof n=="string")&&(r===null||ke(r))&&(o==null||typeof o=="string")&&(s===void 0||Ce(s))},st=(t=e=>G.readFileSync(e,"utf8"))=>{try{let e=JSON.parse(t(Pe()));return we(e)?e:null}catch{return null}},S=t=>{let e=f();G.mkdirSync(e,{recursive:!0}),N(F.join(e,J),JSON.stringify(t),384)},it=(t,e)=>{if(!t)return!0;let n=e-t.lastCheckMs;return n<0?!0:n>=he};import{spawnSync as Re}from"node:child_process";import Ne from"node:fs";import q from"node:process";import{spawnSync as ye}from"node:child_process";var k="infra-kit",g="infra-kit@infra-kit",at="ArthurSaenz/infra-kit";var I="claude",Ee=12e4,K=["--version"],$=["plugin","update",g,"--scope","project","-y"],H=t=>{let e=ye(I,[...t.args],{cwd:t.cwd,encoding:"utf-8",stdio:["ignore","pipe","pipe"],timeout:Ee});if(e.error!==void 0)return{ok:!1,output:e.error.message};let n=`${e.stderr??""}
1
+ import{a as P,h as _,l as b,m as A,n as M,o as L}from"./chunk-AWFGP6GY.js";import{m as f,o as N}from"./chunk-ZZ7HCY2S.js";import{spawnSync as Q}from"node:child_process";import{homedir as X}from"node:os";import y from"node:process";import u from"node:fs";import j from"node:path";import oe from"node:process";var se="update-check.lock",ie=1800*1e3,le=()=>j.join(f(),se),ae=(t,e)=>{try{e-u.statSync(t).mtimeMs>ie&&u.rmSync(t,{force:!0})}catch{}},T=(t={})=>{let e=t.nowMs??Date.now(),n=t.lockPath??le();try{u.mkdirSync(j.dirname(n),{recursive:!0})}catch{return null}let r=()=>{try{return u.openSync(n,"wx",384)}catch{return null}},o=r();if(o===null&&(ae(n,e),o=r()),o===null)return null;try{u.writeFileSync(o,String(oe.pid))}catch{}return()=>{try{u.closeSync(o)}catch{}try{u.rmSync(n,{force:!0})}catch{}}};var ce="https://registry.npmjs.org",ue=5e3,pe=t=>Object.entries(t).find(([n,r])=>/^npm_config_registry$/i.test(n)&&r!=null&&r!=="")?.[1],de=t=>{let e=pe(t),n=e!=null&&e!==""?e:ce;for(;n.endsWith("/");)n=n.slice(0,-1);return n},D=async(t,e=fetch)=>{let n=new AbortController,r=setTimeout(()=>{n.abort()},ue);try{let o=await e(`${de(t)}/${P}/latest`,{signal:n.signal,headers:{accept:"application/json"}});if(!o.ok)return null;let i=(await o.json())?.version;return typeof i=="string"&&i!==""?i:null}catch{return null}finally{clearTimeout(r)}};var me=/^(\d+)\.(\d+)\.(\d+)$/,O=t=>{let[e=""]=t.trim().split("+"),[n="",...r]=e.split("-"),o=me.exec(n);if(!o)return null;let[s,i,l]=[o[1],o[2],o[3]].map(Number);return{release:[s,i,l],prerelease:r.length>0?r.join("-").split("."):[]}},V=/^\d+$/,fe=(t,e)=>{let n=V.test(t),r=V.test(e);return n&&r?Number(t)-Number(e):n!==r?n?-1:1:t<e?-1:1},ge=(t,e)=>{for(let n=0;n<Math.max(t.length,e.length);n+=1){let r=t[n],o=e[n];if(r===void 0)return-1;if(o===void 0)return 1;if(r!==o)return fe(r,o)}return 0},U=(t,e)=>{let n=O(t),r=O(e);if(!n||!r)return!1;for(let i=0;i<3;i+=1){let l=n.release[i],h=r.release[i];if(l!==h)return l>h}let o=n.prerelease.length===0,s=r.prerelease.length===0;return o!==s?o:ge(n.prerelease,r.prerelease)>0};import G from"node:fs";import F from"node:path";var J="update-check.json",he=1200*1e3,Pe=()=>F.join(f(),J),ke=t=>Array.isArray(t)&&t.every(e=>typeof e=="string"),Ce=t=>{if(typeof t!="object"||t===null)return!1;let{outcome:e,checkedMs:n}=t;return typeof e=="string"&&typeof n=="number"&&Number.isFinite(n)},we=t=>{if(typeof t!="object"||t===null)return!1;let{lastCheckMs:e,latestVersion:n,updateCommand:r,outcome:o,plugin:s}=t;return typeof e=="number"&&Number.isFinite(e)&&(n===null||typeof n=="string")&&(r===null||ke(r))&&(o==null||typeof o=="string")&&(s===void 0||Ce(s))},st=(t=e=>G.readFileSync(e,"utf8"))=>{try{let e=JSON.parse(t(Pe()));return we(e)?e:null}catch{return null}},S=t=>{let e=f();G.mkdirSync(e,{recursive:!0}),N(F.join(e,J),JSON.stringify(t),384)},it=(t,e)=>{if(!t)return!0;let n=e-t.lastCheckMs;return n<0?!0:n>=he};import{spawnSync as Re}from"node:child_process";import Ne from"node:fs";import q from"node:process";import{spawnSync as ye}from"node:child_process";var k="infra-kit",g="infra-kit@infra-kit",at="ArthurSaenz/infra-kit";var I="claude",Ee=12e4,K=["--version"],$=["plugin","update",g,"--scope","project","-y"],H=t=>{let e=ye(I,[...t.args],{cwd:t.cwd,encoding:"utf-8",stdio:["ignore","pipe","pipe"],timeout:Ee});if(e.error!==void 0)return{ok:!1,output:e.error.message};let n=`${e.stderr??""}
2
2
  ${e.stdout??""}`.trim();return{ok:e.status===0,output:n}};import z from"node:fs";import Ue from"node:os";import C from"node:path";var Se=[".claude","plugins"],w=t=>{try{return JSON.parse(z.readFileSync(t,"utf-8"))}catch{return}},d=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),p=(t,e)=>{let n=t[e];return typeof n=="string"?n:null},v=(t,e=Ue.homedir())=>C.join(e,...Se,t),Pt=t=>{let e=w(v("known_marketplaces.json",t));return d(e)&&k in e},Ie=t=>d(t)?{scope:p(t,"scope"),projectPath:p(t,"projectPath"),installPath:p(t,"installPath"),version:p(t,"version")}:null,B=t=>{let e=w(v("installed_plugins.json",t));if(!d(e)||!d(e.plugins))return[];let n=e.plugins[g];return Array.isArray(n)?n.flatMap(r=>{let o=Ie(r);return o===null?[]:[o]}):[]},x=t=>{try{return z.realpathSync(t)}catch{return C.resolve(t)}},ve=(t,e)=>t.scope==="user"?!0:e===null||t.projectPath===null?!1:x(t.projectPath)===e,kt=(t={})=>{let e=B(t.home);if(e.length===0)return{kind:"absent"};let n=t.projectPath===void 0?null:x(t.projectPath),r=e.find(o=>ve(o,n));return r===void 0?{kind:"elsewhere",installations:e}:{kind:"installed",installation:r}},W=t=>{let e=new Set;return B(t).filter(n=>{if(n.scope==="user"||n.projectPath===null)return!1;let r=x(n.projectPath);return e.has(r)?!1:(e.add(r),!0)})},Ct=t=>{if(t.installPath===null)return t.version;let e=w(C.join(t.installPath,".claude-plugin","plugin.json"));return(d(e)?p(e,"version"):null)??t.version},[xe=k]=g.split("@"),wt=({home:t}={})=>{let e=v(C.join("marketplaces",k,"plugins",xe,".claude-plugin","plugin.json"),t),n=w(e);return d(n)?p(n,"version"):null};var _e=300*1e3,be=6e4,Ae=t=>{let e=M(t);return delete e.CLAUDECODE,e},Me=t=>t.code==="ENOENT",Le=(t,e)=>{let n=t.projectPath;if(n===null||!e.pathExists(n))return"skipped";let r=e.deadlineMs-e.clock();if(r<=0)return"failed";let o=e.spawn(I,[...$],{cwd:n,stdio:"ignore",shell:q.platform==="win32",env:e.env,timeout:Math.min(be,r),windowsHide:!0});return o.error?Me(o.error)?"skipped":"failed":o.signal===null&&o.status===0?"ok":"failed"},je=t=>{let e=t.clock??Date.now,n=e()+_e;if(!(t.runClaude??H)({args:K}).ok)return"claude-missing";let o=(t.listPluginInstallations??W)();if(o.length===0)return"skipped";let s={spawn:t.spawnPluginUpdate??Re,env:Ae(t.env??q.env),clock:e,deadlineMs:n,pathExists:t.pathExists??Ne.existsSync},i=o.map(l=>Le(l,s));return i.includes("failed")?"failed":i.includes("ok")?"updated":"skipped"},Y=(t={})=>{try{return je(t)}catch{return"failed"}};var Te=200,De=300*1e3,Oe=15e3,Ve=t=>{let e=Q(P,["version","--json"],{stdio:["ignore","pipe","ignore"],shell:y.platform==="win32",cwd:X(),env:t,timeout:Oe,windowsHide:!0,encoding:"utf8"});if(e.error||e.signal||e.status!==0)return null;try{let r=JSON.parse(e.stdout)?.version;return typeof r=="string"&&r!==""?r:null}catch{return null}},Ge=t=>{try{return y.kill(t,0),!0}catch{return!1}},Fe=t=>new Promise(e=>{setTimeout(e,t)}),Je=async(t,e)=>{let n=e.clock()+De;for(;e.clock()<n;){if(!e.isProcessAlive(t))return!0;await e.sleep(Te)}return!e.isProcessAlive(t)},Vt=async(t,e)=>{let n=e.acquireLock??T,r=e.writeCache??S,o=n();if(!o)return"already-running";let s={last:null},i=l=>{s.last=l,r(l)};try{let l=await He(t,{...e,writeCache:i});return $e(e,s.last,t,r),l}finally{o()}},Ke=(t,e)=>t!==null&&U(t,e),$e=(t,e,n,r)=>{let o=Ke(e?.latestVersion??null,n)?"skipped-cli-stale":Y(t),s=(t.clock??Date.now)();if(e!==null)try{r({...e,plugin:{outcome:o,checkedMs:s}})}catch{}},He=async(t,e)=>{let n=e.env??y.env,r=e.nowMs??Date.now(),o=e.fetchLatest??D,s=e.writeCache??S,i=e.isProcessAlive??Ge,l=e.sleep??Fe,h=e.clock??Date.now,Z=e.lazyNpmRoot??b,ee=e.spawnSync??Q,te=e.installedVersion??Ve,a=await o(n),c=(R,re)=>(s({lastCheckMs:r,...re,outcome:R}),R);if(a===null)return c("fetch-failed",{latestVersion:null,updateCommand:null});if(!U(a,t))return c("up-to-date",{latestVersion:a,updateCommand:null});let{canSelfSpawn:ne,updateCommand:m}=_({selfRealPath:e.selfRealPath,env:n,realpath:A,lazyNpmRoot:Z,version:a});if(!ne)return c("cannot-self-spawn",{latestVersion:a,updateCommand:m});if(e.parentPid==null)return c("parent-unknown",{latestVersion:a,updateCommand:null});if(s({lastCheckMs:r,latestVersion:a,updateCommand:null,outcome:"installing"}),!await Je(e.parentPid,{isProcessAlive:i,sleep:l,clock:h}))return c("parent-still-running",{latestVersion:a,updateCommand:null});let E=ee(m[0],m.slice(1),{stdio:"ignore",shell:y.platform==="win32",cwd:X(),env:L(n),windowsHide:!0});return E.error||E.signal||E.status!==0?c("install-failed",{latestVersion:a,updateCommand:m}):te(n)!==a?c("install-stale",{latestVersion:a,updateCommand:m}):c("installed",{latestVersion:null,updateCommand:null})};export{k as a,g as b,at as c,I as d,K as e,$ as f,H as g,Pt as h,kt as i,Ct as j,wt as k,U as l,st as m,it as n,D as o,Vt as p,Ke as q};
3
- //# sourceMappingURL=chunk-R2SZWOPC.js.map
3
+ //# sourceMappingURL=chunk-GBPW4ERM.js.map
@@ -1,4 +1,4 @@
1
- import{a as ie}from"./chunk-MFAFQVTW.js";import{a as oe}from"./chunk-6UJQB36N.js";import{d as _}from"./chunk-RZF36IGQ.js";import We from"node:process";import Ge from"pino";import ze from"pino-pretty";var Be=["token","*.token","serviceToken","*.serviceToken","DOPPLER_TOKEN","*.DOPPLER_TOKEN","INFRA_KIT_ENV_TOKEN","*.INFRA_KIT_ENV_TOKEN"],Ve=()=>{let e=We.argv.includes("--debug")?"debug":"info",t=["time","pid","hostname"];return e==="debug"&&t.push("level"),Ge({level:e,redact:Be},ze({destination:2,ignore:t.join(","),colorize:!0}))},L=Ve();import te from"node:fs/promises";import Ie from"node:os";import j from"node:path";import _t from"node:process";import{z as s}from"zod";import He from"node:process";import qe from"node:process";var $={enabled:!1},Ue=(e,t=r=>{qe.stdout.write(r)})=>($.enabled&&e&&e.structuredContent!=null&&t(`${JSON.stringify(e.structuredContent,null,2)}
1
+ import{a as ie}from"./chunk-MFAFQVTW.js";import{a as oe}from"./chunk-LAHHNH3T.js";import{d as _}from"./chunk-ZZ7HCY2S.js";import We from"node:process";import Ge from"pino";import ze from"pino-pretty";var Be=["token","*.token","serviceToken","*.serviceToken","DOPPLER_TOKEN","*.DOPPLER_TOKEN","INFRA_KIT_ENV_TOKEN","*.INFRA_KIT_ENV_TOKEN"],Ve=()=>{let e=We.argv.includes("--debug")?"debug":"info",t=["time","pid","hostname"];return e==="debug"&&t.push("level"),Ge({level:e,redact:Be},ze({destination:2,ignore:t.join(","),colorize:!0}))},L=Ve();import te from"node:fs/promises";import Ie from"node:os";import j from"node:path";import _t from"node:process";import{z as s}from"zod";import He from"node:process";import qe from"node:process";var $={enabled:!1},Ue=(e,t=r=>{qe.stdout.write(r)})=>($.enabled&&e&&e.structuredContent!=null&&t(`${JSON.stringify(e.structuredContent,null,2)}
2
2
  `),e),se=e=>{e.options.some(r=>r.long==="--json")||e.option("--json","Output the structured result as JSON on stdout (human logs stay on stderr)"),e.commands.forEach(se)};var ae={source:null},P=()=>ae.source!==null,Je=()=>P()||$.enabled,K=()=>!!He.env.CI,Xe=({env:e,stdinIsTTY:t,flag:r})=>{if(r)return"flag";let n=e.INFRA_KIT_AGENT;return n==="1"||e.CLAUDECODE!==void 0&&!t&&n!=="0"?"env":null};var F=e=>{throw new Error(`Unexpected value: ${JSON.stringify(e)}`)};var w=(e,t)=>Object.fromEntries(Object.entries(e).filter(([r])=>r!==t));var E=({key:e,id:t,note:r})=>({id:t,note:r,apply:n=>e in n?{changed:!0,result:w(n,e)}:{changed:!1,result:n}});var ce=E({key:"devProxy",id:"drop-dev-proxy-key",note:'the retired "devProxy" key (dev URLs are port-free https://<release>.<package>.localhost)'});var pe=E({key:"envAutoLoad",id:"drop-env-auto-load-key",note:'the retired "envAutoLoad" key (env auto-load is gone \u2014 run `env-load -c <config>` in the terminal)'});var ue=E({key:"environments",id:"drop-environments-key",note:`the retired "environments" key (deploy targets now come from each workflow's workflow_dispatch options, auth from the token store)`});var Ye=e=>{let t=e.ide;if(t===null||typeof t!="object")return{changed:!1,result:e};let r=!1,n=i=>{if(i===null||typeof i!="object"||!("config"in i))return i;let a=i.config;return a===null||typeof a!="object"||!("mode"in a)?i:(r=!0,{...i,config:w(a,"mode")})},o=Array.isArray(t)?t.map(n):n(t);return r?{changed:!0,result:{...e,ide:o}}:{changed:!1,result:e}},le={id:"strip-legacy-ide-mode",note:'legacy "mode"',apply:Ye};var Ze="zed",de=e=>e!==null&&typeof e=="object"&&e.provider===Ze,Qe=e=>{let t=e.ide;if(Array.isArray(t)){let r=t.filter(n=>!de(n));return r.length===t.length?{changed:!1,result:e}:{changed:!0,result:r.length>0?{...e,ide:r}:w(e,"ide")}}return de(t)?{changed:!0,result:w(e,"ide")}:{changed:!1,result:e}},fe={id:"strip-retired-zed-ide",note:'the retired "zed" provider',apply:Qe};var W=[le,fe,ue,ce,pe];var S=e=>W.reduce((t,r)=>{let n=r.apply(t.result);return n.changed?{changed:!0,result:n.result,notes:[...t.notes,r.note]}:t},{changed:!1,result:e,notes:[]});import et from"node:fs/promises";import tt from"node:os";var rt=async e=>{try{return await et.access(e),!0}catch{return!1}},G=e=>{let t=tt.homedir();return e.startsWith(t)?`~${e.slice(t.length)}`:e};import{randomBytes as nt}from"node:crypto";import v from"node:fs/promises";import z from"node:path";import ot from"node:process";var D=class extends Error{constructor(t){super(`${t} changed on disk since it was read`),this.name="ConfigFileChangedError"}},it=2,st=e=>/^([ \t]+)\S/m.exec(e)?.[1]??it,at=4095,T=async({path:e,raw:t,migrated:r,expectedMtimeMs:n})=>{let o=await v.realpath(e),i=z.dirname(o),a=z.basename(o),p=z.join(i,`.${a}.${ot.pid}.${nt(4).toString("hex")}.tmp`),l=`${JSON.stringify(r,null,st(t))}
3
3
  `;try{await v.writeFile(p,l,"utf8");let d=await v.stat(o);if(d.mtimeMs!==n)throw new D(e);await v.chmod(p,d.mode&at),await v.rename(p,o)}catch(d){throw await v.rm(p,{force:!0}),d}},ct=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),pt=async e=>{let t=await v.stat(e),r=await v.readFile(e,"utf8");if(r.trim()==="")return{changed:!1,result:{},notes:[],path:e};let n=JSON.parse(r);if(!ct(n))return{changed:!1,result:{},notes:[],path:e};let o=S(n);return o.changed&&await T({path:e,raw:r,migrated:o.result,expectedMtimeMs:t.mtimeMs}),{...o,path:e}};var B=async(e,t,r,{schema:n})=>{if(e.autoMigrate==="off")return{kind:"not-applicable"};let o=S(t);if(!o.changed)return{kind:"not-applicable"};let i=n.safeParse(o.result);if(!i.success)return{kind:"not-applicable"};if(e.required&&K())return{kind:"ci-gated"};try{await T({path:e.path,raw:r,migrated:o.result,expectedMtimeMs:e.mtimeMs})}catch(a){return L.debug(a,`auto-migration could not rewrite ${e.path}`),{kind:"not-applicable"}}return L.warn(`Migrated ${G(e.path)}: removed ${o.notes.join(" and ")} (retired by infra-kit ${oe.version})`),{kind:"migrated",data:i.data}};import C from"node:path";import ke from"node:process";import{$ as f}from"zx";var I=e=>{let t=new Set,r=e;for(;r!==null&&typeof r=="object"&&!t.has(r);){t.add(r);let{stderr:n,stderrExcerpt:o}=r;if(typeof n=="string"&&n.length>0)return n;if(typeof o=="string"&&o.length>0)return o;r=r.cause}},ut=(e,t)=>{let r=t.stderrExcerpt??I(e),n=[`failed to ${t.operation}`];return r&&n.push(`stderr: ${r.slice(0,200).trim()}`),t.remediation&&n.push(`try: ${t.remediation}`),n.join(" \u2014 ")},g=class extends Error{operation;remediation;stderrExcerpt;constructor(t,r){super(ut(t,r),{cause:t}),this.name="OperationError",this.operation=r.operation,this.remediation=r.remediation,this.stderrExcerpt=r.stderrExcerpt??I(t)}};var lt=/^v?(\d+)\.(\d+)\.(\d+)$/,dt=/^(\d+)\.(\d+)\.(\d+)$/,ft=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,N="release/",V="release/v",ge="refs/heads/",gt="next";var me=new Set(["dev","main","next","hotfix","regular","release"]),x=class extends Error{constructor(t){super(t),this.name="InvalidReleaseNameError"}},b=class extends Error{constructor(t){super(t),this.name="InvalidReleaseRefError"}},ye=e=>e.startsWith(ge)?e.slice(ge.length):e,ve=(e,t,r)=>({kind:"version",semver:{major:e,minor:t,patch:r},raw:`${e}.${t}.${r}`}),q=e=>{if(e.length===0)throw new x('Release name is empty. Provide a kebab-case name like "checkout-redesign".');if(e.length>50)throw new x(`Release name "${e}" is ${e.length} characters; the maximum is 50.`);if(!ft.test(e))throw new x(`Release name "${e}" is not kebab-case. Use lowercase letters, digits, and single hyphens, e.g. "checkout-redesign".`);if(me.has(e))throw new x(`Release name "${e}" is reserved. Reserved names: ${[...me].join(", ")}.`)},U=e=>{let t=ye(e.trim());if(!t.startsWith(N))return null;if(t.startsWith(V)){let n=t.slice(V.length),o=dt.exec(n);if(o)return ve(Number(o[1]),Number(o[2]),Number(o[3]))}let r=t.slice(N.length);try{q(r)}catch{return null}return{kind:"name",name:r,raw:r}},mt=e=>{let t=e.trim();if(ye(t).startsWith(N)){let o=U(t);if(!o)throw new b(`"${e}" looks like a release branch but is not a valid release/v<semver> or release/<name> ref.`);return o}let n=lt.exec(t);if(n)return ve(Number(n[1]),Number(n[2]),Number(n[3]));if(t.toLowerCase()===gt)throw new b('The "next" token must be resolved to a concrete version (via computeNextVersion) before parsing a release ref.');if(t.includes("@"))throw new b(`Cannot parse "${e}" as a release ref: the \`@date\` suffix belongs to \`release create\`; pass the version alone here and use \`--release-date\` on \`release edit\``);try{q(t)}catch(o){let i=o instanceof Error?o.message:String(o);throw new b(`Cannot parse "${e}" as a release ref: ${i}`)}return{kind:"name",name:t,raw:t}},ht=e=>e.kind==="version"?`${V}${e.raw}`:`${N}${e.name}`,yt=(e,t)=>{let r=t==="hotfix"?"Hotfix":"Release";return e.kind==="version"?`${r} v${e.raw}`:`${r} ${e.name}`},vt=e=>e.kind==="version"?`Release v${e.raw} (RC)`:`Release ${e.name} (RC)`,kt=e=>e.kind==="version"?`v${e.raw}`:e.name,wt=e=>e.raw,H=e=>e==null?!1:U(e)!==null,he=e=>{if(e===void 0)return null;let t=e instanceof Date?e.getTime():new Date(e).getTime();return Number.isNaN(t)?null:t},xt=(e,t,r)=>{if(e.kind==="version"&&t.kind==="version")return e.semver.major!==t.semver.major?e.semver.major-t.semver.major:e.semver.minor!==t.semver.minor?e.semver.minor-t.semver.minor:e.semver.patch-t.semver.patch;if(e.kind==="version")return-1;if(t.kind==="version")return 1;let n=he(r?.a),o=he(r?.b);return n!==null&&o!==null&&n!==o?n-o:e.name<t.name?-1:e.name>t.name?1:0};var we=async e=>{let t=await f({cwd:e})`git worktree list --porcelain`,r=[],n=null;for(let o of t.stdout.split(`
4
4
  `)){if(o.startsWith("worktree ")){n&&r.push(n),n={path:o.slice(9),branch:null,detached:!1,bare:!1,prunable:!1,locked:!1};continue}n&&(o.startsWith("branch ")?n.branch=o.slice(7).replace(/^refs\/heads\//,""):o==="detached"?n.detached=!0:o==="bare"?n.bare=!0:o==="locked"||o.startsWith("locked ")?n.locked=!0:(o==="prunable"||o.startsWith("prunable "))&&(n.prunable=!0))}return n&&r.push(n),r},bt=async e=>{let t=await we(ke.cwd()),r=n=>e==="release"?H(n):n.startsWith("feature/");return t.map(n=>n.branch).filter(n=>n!==null&&r(n))},Rt=e=>{let t=I(e);return t&&/not a git repository/i.test(t)?"not a git repository":void 0},Pt=({hasStderr:e})=>{if(P())return"infra-kit resolves its project from the working directory; run it from inside an infra-kit project repo (or one of its git worktrees), or pass `-C <dir>` naming one";let t="run infra-kit from inside an infra-kit project repo (or one of its git worktrees)";return e?`${t}; if you are already in one, the stderr in this message is the real cause`:t},A=async()=>{try{return(await f({quiet:!0})`git rev-parse --show-toplevel`).stdout.trim()}catch(e){let t=Rt(e)??I(e);throw new g(e,{operation:`resolve the project root from ${ke.cwd()}`,stderrExcerpt:t,remediation:Pt({hasStderr:t!==void 0})})}},J=async e=>{let t=e??await A(),r=(await f({cwd:t,quiet:!0})`git rev-parse --git-common-dir`).stdout.trim(),n=C.resolve(t,r);return n.includes(`${C.sep}.git${C.sep}modules${C.sep}`)?t:C.dirname(n)},xe=async()=>(await f`git rev-parse --abbrev-ref HEAD`).stdout.trim(),be=async()=>(await f`git status --porcelain`).stdout.split(`
@@ -8,4 +8,4 @@ import{a as ie}from"./chunk-MFAFQVTW.js";import{a as oe}from"./chunk-6UJQB36N.js
8
8
  A retired key on this branch \u2014 run \`infra-kit setup --skip-tools\` in this checkout and commit infra-kit.json.`),fr=async e=>{let t=await lr(e.path);if(t===null){if(e.required)throw new Error(`${e.label} not found at ${e.path}`);return null}let r;try{r=t.trim()===""?{}:JSON.parse(t)}catch(a){throw new Error(`Invalid JSON in ${e.label} at ${e.path}: ${a.message}`)}if(Q(r)&&"envTokens"in r)throw new Error(mr(e));if(!e.required&&Q(r)&&"mcp"in r)throw new Error(gr(e));let n=ee.safeParse(r);if(n.success)return n.data;let o=new Error(`Invalid ${e.label} at ${e.path}: ${s.prettifyError(n.error)}`);if(!Q(r)||e.mtimeMs===null)throw o;let i=await B({...e,mtimeMs:e.mtimeMs},r,t,{schema:ee});switch(i.kind){case"migrated":return i.data;case"ci-gated":throw Ne(o);case"not-applicable":throw o;default:return F(i)}},gr=e=>[`"mcp" is not allowed in ${e.label} (${e.path}): it feeds the committed .mcp.json, so a per-machine copy would replace the project's servers for everyone.`,"Move the block to the project infra-kit.json and run `infra-kit setup`.","For a machine-only override of one server (e.g. a local fork), use Claude Code directly:"," claude mcp add --scope local <name> -- ik-mcp --name <name> --env <VAR> ... -- <command> <args>","(local scope shadows the project entry by name; `claude mcp list` will show a same-name conflict warning, which is expected)."].join(`
9
9
  `),Q=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),mr=e=>[`Refusing to load ${e.label} \u2014 \`envTokens\` is not a config key.`,"A service token in a config file can be committed, backed up by your editor, or shared."," 1. REVOKE the token in Doppler now \u2014 treat it as compromised.",` 2. Remove the \`envTokens\` key from ${e.path}.`," 3. Re-add it privately: `infra-kit env-token-set <env>`"," (it is written to ~/.infra-kit/projects/<repo>/tokens.json, mode 0600, never to the repo)."].join(`
10
10
  `);import*as u from"node:fs";import*as c from"node:path";function hr(e){let t=e;for(let r=0;r<10;r++){let n=c.join(t,"pnpm-workspace.yaml");if(u.existsSync(n))return t;t=c.dirname(t)}throw new Error("Could not find monorepo root (pnpm-workspace.yaml)")}function _e(e,t){let r=c.join(e,"package.json");if(!u.existsSync(r))return t;try{let n=JSON.parse(u.readFileSync(r,"utf-8"));return typeof n.name=="string"?n.name:t}catch{return t}}function Ro(e){let t=c.join(e,"apps"),r=[];if(!u.existsSync(t))throw new Error(`Apps directory not found: ${t}`);let n=u.readdirSync(t,{withFileTypes:!0}).filter(o=>o.isDirectory()).map(o=>o.name);for(let o of n){let i=c.join(t,o,"api"),a=c.join(i,"serverless.yml");u.existsSync(a)&&r.push({name:o,packageName:_e(i,o),path:i})}return r}var Le=["vite.config.ts","vite.config.mts","vite.config.cts","vite.config.js","vite.config.mjs","vite.config.cjs"],yr=["@slip-stream-kit/vite","@slip-stream-kit/config/vite","infra-kit/vite"];function vr(e){for(let t of Le){let r=c.join(e,t);if(u.existsSync(r))try{let n=u.readFileSync(r,"utf-8");return yr.some(o=>n.includes(o))}catch{return!1}}return!1}function Po(e){for(let t of Le){let r=c.join(e,t);if(u.existsSync(r))try{return u.readFileSync(r,"utf-8").includes("infraKit(")}catch{return!1}}return!1}function kr(e){let t=c.join(e,"package.json");if(!u.existsSync(t))return!1;try{let r=JSON.parse(u.readFileSync(t,"utf-8"));return typeof r.scripts?.dev=="string"&&r.scripts.dev.length>0}catch{return!1}}function Eo(e){let t=c.join(e,"apps"),r=[];if(!u.existsSync(t))return r;let n=u.readdirSync(t,{withFileTypes:!0}).filter(o=>o.isDirectory()).map(o=>o.name);for(let o of n){let i=c.join(t,o,"ui");u.existsSync(i)&&kr(i)&&r.push({name:o,packageName:_e(i,o),path:i,managedPort:vr(i)})}return r}function Co(e){let t=e?.filter(Boolean)??[];return t.length>0?t:null}function So(e){let t=hr(e),r=c.relative(c.join(t,"apps"),e),n=r.split(c.sep)[0];if(r===""||r.startsWith("..")||c.isAbsolute(r)||!n)throw new Error(`--self: not inside an apps/<app> directory (cwd: ${e}). Run from an app folder or use --app=<name>.`);return n}var wr=new Set(["api","ui"]),Oe=e=>{let t=c.join(e,"dist");return u.existsSync(t)&&u.statSync(t).isDirectory()?t:void 0},ne=e=>u.existsSync(e)?u.readdirSync(e,{withFileTypes:!0}).filter(t=>t.isDirectory()).map(t=>t.name):[];function Io(e){let t=[];for(let n of ne(c.join(e,"packages"))){let o=Oe(c.join(e,"packages",n));o!==void 0&&t.push(o)}let r=c.join(e,"apps");for(let n of ne(r))for(let o of ne(c.join(r,n))){if(wr.has(o))continue;let i=c.join(r,n,o);if(!u.existsSync(c.join(i,"package.json")))continue;let a=Oe(i);a!==void 0&&t.push(a)}return t}function Ao(e){return e.map(t=>c.join(t.path,"dist")).filter(t=>u.existsSync(t))}function Mo(e,t,r){let n=c.normalize(e),o=r.find(a=>n.startsWith(c.normalize(a)));return o?{kind:"package",packageDir:o}:{kind:"app",app:t.find(a=>n.startsWith(c.normalize(a)))}}var xr={"*/api":{},"*/ui":{}},Fe=e=>{let t=e.split("/"),[r,n]=t;return t.length!==2||!r?`devServersPresets: invalid target "${e}" (expected "<app>/api" or "<app>/ui")`:n!=="api"&&n!=="ui"?`devServersPresets: invalid target part "${n}" in "${e}" (expected "api" or "ui")`:null},br=e=>{let t=Fe(e);if(t)throw new Error(t);let[r,n]=e.split("/");return{appGlob:r,part:n}},$o=e=>{let t=[];for(let[r,n]of Object.entries(e))for(let o of Object.keys(n.apps??{})){let i=Fe(o);i&&t.push({preset:r,key:o,message:`preset "${r}": ${i}`})}return t},Rr=(e,t)=>t==="api"?e.api:e.ui,Pr=e=>[...new Set([...e.api,...e.ui])].sort(),Ke=(e,t)=>`${e}/${t}`,Er=e=>e?0:1,Cr=(e,t)=>t.watchDeps===void 0?e??{watchDeps:!0,rank:t.rank,explicitValue:!1}:!e||!e.explicitValue?{watchDeps:t.watchDeps,rank:t.rank,explicitValue:!0}:t.rank>e.rank?{watchDeps:t.watchDeps,rank:t.rank,explicitValue:!0}:e,Sr=(e,t,r)=>{let{app:n,part:o,watchDeps:i,isGlob:a}=r;if(!Rr(t,o).includes(n)){a||e.unmatched.push(Ke(n,o));return}let p=Ke(n,o),l=Cr(e.targets.get(p),{watchDeps:i,rank:Er(a)});e.targets.set(p,{app:n,part:o,...l})},Ir=(e,t)=>{let r=Object.entries(e.apps??xr),n={targets:new Map,proxy:{},unmatched:[]};for(let[a,p]of r){let{appGlob:l,part:d}=br(a),m=l==="*",y=m?Pr(t):[l];for(let R of y)Sr(n,t,{app:R,part:d,watchDeps:p.watchDeps,isGlob:m}),p.proxy&&(n.proxy[R]={...n.proxy[R]??{},...p.proxy})}let o=[...n.targets.values()].map(({app:a,part:p,watchDeps:l})=>({app:a,part:p,watchDeps:l})),i=[...new Set(o.filter(a=>a.part==="api").map(a=>a.app))];return{targets:o,orca:e.orca??!1,proxy:n.proxy,localApps:i,unmatched:n.unmatched}},Do=e=>{if(e.preset!=null)return e.preset;if(e.running.length===0)return"nothing";let t=new Set(e.running);return e.discovered.every(n=>t.has(n))?"*":[...t].sort().join(" + ")},Ar=(e,t)=>Object.keys(e).find(r=>e[r]===t),Mr=({preset:e,app:t,route:r,launchedPkgs:n,ctx:o})=>{let i=o.routePkg(t,r);if(i===void 0)return{preset:e,app:t,route:r,kind:"unknown-route",message:`preset "${e}": proxy override "${r}" on "${t}" names a route not declared in ${t}'s infra-kit.config.ts dev.proxy.routes`};if(n.has(i))return null;let a=Ar(o.apiPkgByApp,i),p=a?`add "${a}/api" to the preset`:`launch the api whose package is "${i}"`;return{preset:e,app:t,route:r,pkg:i,kind:"backend-not-launched",message:`preset "${e}": proxy override "${r}" \u2192 "local" requires backend "${i}" to run locally, but the preset does not launch it \u2014 ${p}, or set "${r}" to "cloud"`}},To=(e,t)=>{let r=[];for(let[n,o]of Object.entries(e)){let i=Ir(o,t.discovered),a=new Set(i.localApps.map(p=>t.apiPkgByApp[p]).filter(p=>p!==void 0));for(let[p,l]of Object.entries(i.proxy))for(let[d,m]of Object.entries(l)){if(m!=="local")continue;let y=Mr({preset:n,app:p,route:d,launchedPkgs:a,ctx:t});y&&r.push(y)}}return r};export{$ as a,Ue as b,se as c,ae as d,P as e,Je as f,Xe as g,I as h,g as i,x as j,q as k,U as l,mt as m,ht as n,yt as o,vt as p,kt as q,wt as r,H as s,xt as t,we as u,bt as v,A as w,J as x,xe as y,be as z,Et as A,Ct as B,St as C,It as D,At as E,Mt as F,jt as G,$t as H,Dt as I,Y as J,Tt as K,Nt as L,Ot as M,L as N,F as O,rt as P,G as Q,D as R,pt as S,ir as T,Ae as U,ee as V,sr as W,ar as X,De as Y,Te as Z,cr as _,pr as $,ur as aa,hr as ba,Ro as ca,Po as da,Eo as ea,Co as fa,So as ga,Io as ha,Ao as ia,Mo as ja,Fe as ka,$o as la,Ir as ma,Do as na,To as oa};
11
- //# sourceMappingURL=chunk-F656FWV5.js.map
11
+ //# sourceMappingURL=chunk-J6BHN362.js.map
@@ -1,3 +1,3 @@
1
- import{j as C,m as O,n as D}from"./chunk-AWFGP6GY.js";import{d as S}from"./chunk-RZF36IGQ.js";import k from"node:fs";import{homedir as Te}from"node:os";import{dirname as _,join as W}from"node:path";import d from"node:process";import{fileURLToPath as Fe}from"node:url";import{execFile as re}from"node:child_process";import{createHash as ne}from"node:crypto";import{existsSync as F,readFileSync as h}from"node:fs";import oe from"node:http";import se from"node:https";import ie from"node:net";import{homedir as le}from"node:os";import{dirname as N,join as p}from"node:path";import f from"node:process";import ae from"node:tls";import{fileURLToPath as ce}from"node:url";import{promisify as ue}from"node:util";var ee=/^[\w@%+=:,./-]+$/,te="'\\''",T=e=>ee.test(e)?e:`'${e.replaceAll("'",te)}'`,x=e=>e.map(T).join(" ");var de=ue(re),me=e=>{let t=JSON.parse(h(e,"utf-8")),r=typeof t.bin=="string"?t.bin:t.bin?.portless;return r==null||r===""?null:r},E=()=>{try{let e=N(ce(import.meta.url));for(;;){let t=p(e,"node_modules","portless","package.json");if(F(t)){let n=me(t);return n==null?null:p(N(t),n)}let r=N(e);if(r===e)return null;e=r}}catch{return null}},v,M=()=>(v===void 0&&(v=E()),v),U=(e,t)=>{let r=[t.execPath??f.execPath,t.bin,...e];return(t.sudo===!0?"sudo ":"")+x(r)},pe=1500,L=1500,fe="x-portless",I="127.0.0.1",ge="localhost",Pe="sh.portless.proxy",he=`/Library/LaunchDaemons/${Pe}.plist`,ye="/etc/systemd/system/portless.service",it="portless",Se=(e=F)=>{try{return f.platform==="darwin"?e(he)?"yes":"no":f.platform==="linux"?e(ye)?"yes":"no":"unknown"}catch{return"unknown"}},ke=e=>new Promise(t=>{let r=ie.connect({host:I,port:e}),n=o=>{r.destroy(),t(o)};r.setTimeout(L),r.once("connect",()=>{n(!0)}),r.once("timeout",()=>{n(!1)}),r.once("error",()=>{n(!1)})}),be=(e,t)=>new Promise(r=>{let o=(t?se.request:oe.request)({host:I,port:e,method:"HEAD",path:"/",timeout:L,...t?{rejectUnauthorized:!1,servername:ge}:{}},s=>{s.resume(),r(s.headers[fe]==="1")});o.on("error",()=>{r(!1)}),o.on("timeout",()=>{o.destroy(),r(!1)}),o.end()}),xe=async(e,{timeoutMs:t})=>{let r=M();if(r==null)throw new Error("portless is not installed (not resolvable from node_modules)");await de(f.execPath,[r,...e],{signal:AbortSignal.timeout(t),encoding:"utf-8",env:D(f.env)})},w=()=>f.env.PORTLESS_STATE_DIR??p(le(),".portless"),Ne="ca.pem",ve="ca.trusted",B=()=>p(w(),Ne),lt=()=>{try{let e=h(p(w(),ve),"utf-8").trim();return e===""?!1:ne("sha256").update(h(B())).digest("hex")===e.toLowerCase()}catch{return!1}},at=(e,t)=>new Promise(r=>{let n;try{n=h(B())}catch{r({ok:!1,code:"ENOENT"});return}let o=ae.connect({host:I,port:e,servername:t,ca:[n],rejectUnauthorized:!0},()=>{let s=o.authorizationError,i=o.authorized;o.destroy(),r(i?{ok:!0}:{ok:!1,code:s?.code??s?.message??"UNKNOWN"})});o.setTimeout(L),o.once("timeout",()=>{o.destroy(),r({ok:!1,code:"ETIMEDOUT"})}),o.once("error",s=>{o.destroy(),r({ok:!1,code:s.code??"UNKNOWN"})})}),ct=()=>{try{let e=JSON.parse(h(p(w(),"routes.json"),"utf-8"));return Array.isArray(e)?e.flatMap(t=>{let{hostname:r,port:n}=t??{};return typeof r!="string"||r===""||typeof n!="number"?[]:[{name:r,port:n}]}):[]}catch{return[]}},ut=(e={})=>{let t=e.bin===void 0?M():e.bin,r=e.run??xe,n=e.isListening??ke,o=e.isProxyServing??be,s=e.isServiceInstalled??Se,i=e.timeoutMs??pe,a=null,l=async u=>{try{return await r(u,{timeoutMs:i}),!0}catch{return!1}},c=async()=>(a??=await l(["--version"]),a);return{binPath:()=>t,isAvailable:c,isProxyServing:async(u,P)=>!await c()||!await n(u)?!1:o(u,P),probeProxy:async(u,P)=>await n(u)?await o(u,P)?"serving":"not-portless":"daemon-down",isServiceInstalled:s,registerAlias:async(u,P)=>await c()?l(["alias",u,String(P)]):!1,removeAlias:async u=>{await c()&&await l(["alias","--remove",u])}}};import y from"node:fs";import{basename as z,dirname as $,join as j}from"node:path";import G from"node:process";var R=e=>j(e,S,"node"),H=e=>`${R(e)}.source.json`,Ee=e=>{if(typeof e!="object"||e===null)return!1;let t=e,r=["version","arch","platform","source","refreshedAt","versionChangedAt"];return(t.method==="hardlink"||t.method==="copy")&&r.every(n=>typeof t[n]=="string")&&(t.sourceSize===void 0||typeof t.sourceSize=="number")},Le=y.constants.COPYFILE_FICLONE|y.constants.COPYFILE_EXCL,Ie=493,we=(e,t=y)=>{try{let r=JSON.parse(t.readFileSync(H(e),"utf8"));return Ee(r)?r:null}catch{return null}},J=(e,t)=>e.ino===t.ino&&e.dev===t.dev,K=e=>{let{home:t,execPath:r,fs:n=y}=e,o=R(t);try{let s=n.lstatSync(o,{throwIfNoEntry:!1}),i=n.statSync(r,{throwIfNoEntry:!1});return s===void 0||i===void 0||!s.isFile()?null:J(s,i)?o:null}catch{return null}},Y=(e,t)=>e.version===t.version&&e.arch===t.arch&&e.platform===t.platform,Re=(e,t,r,n)=>Y(r,n)?J(e,t)?!0:r.method==="copy"&&r.sourceSize===t.size:!1,A=(e,t)=>{try{t.unlinkSync(e)}catch{}},Ae=(e,t,r)=>{let n;try{n=r.readdirSync(e)}catch{return}for(let o of n)t.some(i=>o.startsWith(i))&&A(j(e,o),r)},_e=(e,t,r)=>{try{return r.linkSync(e,t),"hardlink"}catch{return r.copyFileSync(e,t,Le),r.chmodSync(t,Ie),"copy"}},Ce=(e,t,r)=>{let n=`${t}.tmp-${G.pid}`;try{let o=_e(e,n,r);return r.renameSync(n,t),o}catch(o){throw A(n,r),o}},Oe=(e,t,r)=>{let n=`${e}.tmp-${G.pid}`;try{r.writeFileSync(n,`${JSON.stringify(t,null,2)}
1
+ import{j as C,m as O,n as D}from"./chunk-AWFGP6GY.js";import{d as S}from"./chunk-ZZ7HCY2S.js";import k from"node:fs";import{homedir as Te}from"node:os";import{dirname as _,join as W}from"node:path";import d from"node:process";import{fileURLToPath as Fe}from"node:url";import{execFile as re}from"node:child_process";import{createHash as ne}from"node:crypto";import{existsSync as F,readFileSync as h}from"node:fs";import oe from"node:http";import se from"node:https";import ie from"node:net";import{homedir as le}from"node:os";import{dirname as N,join as p}from"node:path";import f from"node:process";import ae from"node:tls";import{fileURLToPath as ce}from"node:url";import{promisify as ue}from"node:util";var ee=/^[\w@%+=:,./-]+$/,te="'\\''",T=e=>ee.test(e)?e:`'${e.replaceAll("'",te)}'`,x=e=>e.map(T).join(" ");var de=ue(re),me=e=>{let t=JSON.parse(h(e,"utf-8")),r=typeof t.bin=="string"?t.bin:t.bin?.portless;return r==null||r===""?null:r},E=()=>{try{let e=N(ce(import.meta.url));for(;;){let t=p(e,"node_modules","portless","package.json");if(F(t)){let n=me(t);return n==null?null:p(N(t),n)}let r=N(e);if(r===e)return null;e=r}}catch{return null}},v,M=()=>(v===void 0&&(v=E()),v),U=(e,t)=>{let r=[t.execPath??f.execPath,t.bin,...e];return(t.sudo===!0?"sudo ":"")+x(r)},pe=1500,L=1500,fe="x-portless",I="127.0.0.1",ge="localhost",Pe="sh.portless.proxy",he=`/Library/LaunchDaemons/${Pe}.plist`,ye="/etc/systemd/system/portless.service",it="portless",Se=(e=F)=>{try{return f.platform==="darwin"?e(he)?"yes":"no":f.platform==="linux"?e(ye)?"yes":"no":"unknown"}catch{return"unknown"}},ke=e=>new Promise(t=>{let r=ie.connect({host:I,port:e}),n=o=>{r.destroy(),t(o)};r.setTimeout(L),r.once("connect",()=>{n(!0)}),r.once("timeout",()=>{n(!1)}),r.once("error",()=>{n(!1)})}),be=(e,t)=>new Promise(r=>{let o=(t?se.request:oe.request)({host:I,port:e,method:"HEAD",path:"/",timeout:L,...t?{rejectUnauthorized:!1,servername:ge}:{}},s=>{s.resume(),r(s.headers[fe]==="1")});o.on("error",()=>{r(!1)}),o.on("timeout",()=>{o.destroy(),r(!1)}),o.end()}),xe=async(e,{timeoutMs:t})=>{let r=M();if(r==null)throw new Error("portless is not installed (not resolvable from node_modules)");await de(f.execPath,[r,...e],{signal:AbortSignal.timeout(t),encoding:"utf-8",env:D(f.env)})},w=()=>f.env.PORTLESS_STATE_DIR??p(le(),".portless"),Ne="ca.pem",ve="ca.trusted",B=()=>p(w(),Ne),lt=()=>{try{let e=h(p(w(),ve),"utf-8").trim();return e===""?!1:ne("sha256").update(h(B())).digest("hex")===e.toLowerCase()}catch{return!1}},at=(e,t)=>new Promise(r=>{let n;try{n=h(B())}catch{r({ok:!1,code:"ENOENT"});return}let o=ae.connect({host:I,port:e,servername:t,ca:[n],rejectUnauthorized:!0},()=>{let s=o.authorizationError,i=o.authorized;o.destroy(),r(i?{ok:!0}:{ok:!1,code:s?.code??s?.message??"UNKNOWN"})});o.setTimeout(L),o.once("timeout",()=>{o.destroy(),r({ok:!1,code:"ETIMEDOUT"})}),o.once("error",s=>{o.destroy(),r({ok:!1,code:s.code??"UNKNOWN"})})}),ct=()=>{try{let e=JSON.parse(h(p(w(),"routes.json"),"utf-8"));return Array.isArray(e)?e.flatMap(t=>{let{hostname:r,port:n}=t??{};return typeof r!="string"||r===""||typeof n!="number"?[]:[{name:r,port:n}]}):[]}catch{return[]}},ut=(e={})=>{let t=e.bin===void 0?M():e.bin,r=e.run??xe,n=e.isListening??ke,o=e.isProxyServing??be,s=e.isServiceInstalled??Se,i=e.timeoutMs??pe,a=null,l=async u=>{try{return await r(u,{timeoutMs:i}),!0}catch{return!1}},c=async()=>(a??=await l(["--version"]),a);return{binPath:()=>t,isAvailable:c,isProxyServing:async(u,P)=>!await c()||!await n(u)?!1:o(u,P),probeProxy:async(u,P)=>await n(u)?await o(u,P)?"serving":"not-portless":"daemon-down",isServiceInstalled:s,registerAlias:async(u,P)=>await c()?l(["alias",u,String(P)]):!1,removeAlias:async u=>{await c()&&await l(["alias","--remove",u])}}};import y from"node:fs";import{basename as z,dirname as $,join as j}from"node:path";import G from"node:process";var R=e=>j(e,S,"node"),H=e=>`${R(e)}.source.json`,Ee=e=>{if(typeof e!="object"||e===null)return!1;let t=e,r=["version","arch","platform","source","refreshedAt","versionChangedAt"];return(t.method==="hardlink"||t.method==="copy")&&r.every(n=>typeof t[n]=="string")&&(t.sourceSize===void 0||typeof t.sourceSize=="number")},Le=y.constants.COPYFILE_FICLONE|y.constants.COPYFILE_EXCL,Ie=493,we=(e,t=y)=>{try{let r=JSON.parse(t.readFileSync(H(e),"utf8"));return Ee(r)?r:null}catch{return null}},J=(e,t)=>e.ino===t.ino&&e.dev===t.dev,K=e=>{let{home:t,execPath:r,fs:n=y}=e,o=R(t);try{let s=n.lstatSync(o,{throwIfNoEntry:!1}),i=n.statSync(r,{throwIfNoEntry:!1});return s===void 0||i===void 0||!s.isFile()?null:J(s,i)?o:null}catch{return null}},Y=(e,t)=>e.version===t.version&&e.arch===t.arch&&e.platform===t.platform,Re=(e,t,r,n)=>Y(r,n)?J(e,t)?!0:r.method==="copy"&&r.sourceSize===t.size:!1,A=(e,t)=>{try{t.unlinkSync(e)}catch{}},Ae=(e,t,r)=>{let n;try{n=r.readdirSync(e)}catch{return}for(let o of n)t.some(i=>o.startsWith(i))&&A(j(e,o),r)},_e=(e,t,r)=>{try{return r.linkSync(e,t),"hardlink"}catch{return r.copyFileSync(e,t,Le),r.chmodSync(t,Ie),"copy"}},Ce=(e,t,r)=>{let n=`${t}.tmp-${G.pid}`;try{let o=_e(e,n,r);return r.renameSync(n,t),o}catch(o){throw A(n,r),o}},Oe=(e,t,r)=>{let n=`${e}.tmp-${G.pid}`;try{r.writeFileSync(n,`${JSON.stringify(t,null,2)}
2
2
  `),r.renameSync(n,e)}catch(o){throw A(n,r),o}},De=(e,t,r,n,o)=>{let s=e!==null&&Y(e,n)&&(e.sourceSize===void 0||e.sourceSize===r.size);return{method:t,version:n.version,arch:n.arch,platform:n.platform,source:n.execPath,...t==="copy"?{sourceSize:r.size}:{},refreshedAt:o,versionChangedAt:s?e.versionChangedAt:o}},q=e=>{let{home:t,execPath:r,version:n,fs:o=y,now:s=()=>new Date}=e,i=R(t),a=H(t),l=(c,m)=>({kind:"node",outcome:c,node:i,source:r,version:n,method:m});if(e.platform!=="darwin"&&e.platform!=="linux")return l("skipped-platform",null);if(!e.isGlobal())return l("skipped-local",null);try{o.mkdirSync($(i),{recursive:!0});let c=o.lstatSync(i,{throwIfNoEntry:!1});if(c!==void 0&&!c.isFile())return l("failed",null);let m=o.statSync(r,{throwIfNoEntry:!1});if(m===void 0)return l("failed",null);let g=we(t,o);if(c!==void 0&&g!==null&&Re(c,m,g,e))return l("unchanged",g.method);Ae($(i),[`${z(i)}.tmp-`,`${z(a)}.tmp-`],o);let b=Ce(r,i,o);return Oe(a,De(g,b,m,e,s().toISOString()),o),l(c===void 0?"created":"refreshed",b)}catch{return l("failed",null)}};var Q=e=>W(e,S,"portless"),Me=(e,t=k.existsSync)=>{let r=W(Q(e),"dist","cli.js");return t(r)?r:null},Lt=(e,t)=>{let r=t.execPath??d.execPath,n=t.stableNode===void 0?K({home:t.home,execPath:r}):t.stableNode;return U(["service","install"],{sudo:!0,bin:Me(t.home,t.exists)??e,execPath:n??r})},X=Symbol("absent"),Z=Symbol("not-a-symlink"),Ue=(e,t)=>{let r=t.lstatSync(e,{throwIfNoEntry:!1});return r===void 0?X:r.isSymbolicLink()?t.readlinkSync(e):Z},Be=(e,t,r)=>{let n=`${t}.tmp-${d.pid}`;try{r.unlinkSync(n)}catch{}r.symlinkSync(e,n);try{r.renameSync(n,t)}catch(o){try{r.unlinkSync(n)}catch{}throw o}},ze=e=>{let{resolveBin:t,isGlobal:r,home:n,fs:o=k}=e,s=Q(n),i=t();if(i===null)return{kind:"link",outcome:"skipped-unresolved",target:null,link:s};let a=_(_(i));if(!r())return{kind:"link",outcome:"skipped-local",target:a,link:s};try{o.mkdirSync(_(s),{recursive:!0});let l=Ue(s,o);return l===a?{kind:"link",outcome:"unchanged",target:a,link:s}:l===Z?{kind:"link",outcome:"failed",target:a,link:s}:(Be(a,s,o),{kind:"link",outcome:l===X?"created":"repointed",target:a,link:s})}catch{return{kind:"link",outcome:"failed",target:a,link:s}}},$e=()=>{let e=Te(),t,r=()=>(t??=C({selfRealPath:k.realpathSync(Fe(import.meta.url)),env:d.env,realpath:O,home:e,exists:k.existsSync}),t);return{link:{resolveBin:E,isGlobal:r,home:e},node:{isGlobal:r,home:e,execPath:d.execPath,version:d.version,arch:d.arch,platform:d.platform}}},V=(e,t,r)=>{try{e(r(),t)}catch{}},It=(e,t)=>{let r=t??$e();V(e,"portless link",()=>ze(r.link)),V(e,"portless node",()=>q(r.node))};export{x as a,E as b,U as c,Pe as d,he as e,ye as f,it as g,ke as h,be as i,w as j,B as k,lt as l,at as m,ct as n,ut as o,R as p,we as q,q as r,Q as s,Me as t,Lt as u,ze as v,$e as w,It as x};
3
- //# sourceMappingURL=chunk-AG7XWZNT.js.map
3
+ //# sourceMappingURL=chunk-KPRFMZCX.js.map
@@ -0,0 +1,2 @@
1
+ var i={name:"infra-kit",type:"module",version:"0.11.10",files:["dist"],description:"infra-kit",bin:{"infra-kit":"dist/cli.js",ik:"dist/cli.js","ik-mcp":"dist/mcp-proxy.js"},engines:{node:">=24.x"},scripts:{build:"pnpm run clean-artifacts && node ./scripts/build.js",prepack:"pnpm run build","infra-kit-check":"pnpm exec infra-kit audit","clean-artifacts":"rm -rf dist","clean-cache":"rm -rf node_modules/.cache .eslintcache tsconfig.tsbuildinfo .turbo .swc","prettier-fix":"pnpm exec prettier **/* --write --no-error-on-unmatched-pattern --log-level silent --ignore-path ../../../.prettierignore","prettier-check":"pnpm exec prettier **/* --check --no-error-on-unmatched-pattern --log-level silent --ignore-path ../../../.prettierignore","eslint-check":"pnpm exec eslint --cache --report-unused-disable-directives ./src","eslint-fix":"pnpm exec eslint --cache --quiet --report-unused-disable-directives ./src --fix","ts-check":"tsc --noEmit",test:"pnpm exec vitest run --reporter=minimal","test-watch":"pnpm exec vitest --watch --silent passed-only","test-ui":"pnpm exec vitest --ui --silent passed-only","test-report":"pnpm exec vitest run --coverage --silent passed-only","qa:pty":"INFRA_KIT_REQUIRE_PTY=1 pnpm exec vitest run --reporter=minimal src/tui/__tests__/stdin-pause-pty.test.ts src/entry/__tests__/quit-keys-pty.test.ts src/entry/__tests__/post-run-pause-pty.test.ts",qa:"pnpm run prettier-check && pnpm run eslint-check && pnpm run ts-check && pnpm run test && echo \u2705 Success",fix:"pnpm run prettier-fix && pnpm run eslint-fix && pnpm run qa"},dependencies:{"@aws-lambda-powertools/logger":"^2.35.0","@inquirer/checkbox":"^5.2.5","@inquirer/confirm":"^6.3.2","@inquirer/input":"^5.1.6","@inquirer/password":"^5.2.2","@inquirer/select":"^5.2.5","@slip-stream-kit/config":"^0.11.10",chalk:"^6.0.0",chokidar:"^5.0.0",commander:"^15.0.0",fastify:"^5.12.4",ink:"^7.1.1",pino:"^10.3.1","pino-pretty":"^13.1.3",portless:"^0.15.6",react:"19.3.0",yaml:"^2.9.1",zod:"^4.6.2",zx:"^8.8.5"},devDependencies:{"@slip-stream-kit/eslint-plugin":"workspace:*","@types/aws-lambda":"catalog:","@types/react":"catalog:","@wl/eslint-config":"workspace:*","@wl/vitest-config":"workspace:*",esbuild:"^0.28.2","ink-testing-library":"^4.0.0",typescript:"^6.0.3"}};export{i as a};
2
+ //# sourceMappingURL=chunk-LAHHNH3T.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../package.json"],
4
+ "sourcesContent": ["{\n \"name\": \"infra-kit\",\n \"type\": \"module\",\n \"version\": \"0.11.10\",\n \"files\": [\n \"dist\"\n ],\n \"description\": \"infra-kit\",\n \"bin\": {\n \"infra-kit\": \"dist/cli.js\",\n \"ik\": \"dist/cli.js\",\n \"ik-mcp\": \"dist/mcp-proxy.js\"\n },\n \"engines\": {\n \"node\": \">=24.x\"\n },\n \"scripts\": {\n \"build\": \"pnpm run clean-artifacts && node ./scripts/build.js\",\n \"prepack\": \"pnpm run build\",\n \"infra-kit-check\": \"pnpm exec infra-kit audit\",\n \"clean-artifacts\": \"rm -rf dist\",\n \"clean-cache\": \"rm -rf node_modules/.cache .eslintcache tsconfig.tsbuildinfo .turbo .swc\",\n \"prettier-fix\": \"pnpm exec prettier **/* --write --no-error-on-unmatched-pattern --log-level silent --ignore-path ../../../.prettierignore\",\n \"prettier-check\": \"pnpm exec prettier **/* --check --no-error-on-unmatched-pattern --log-level silent --ignore-path ../../../.prettierignore\",\n \"eslint-check\": \"pnpm exec eslint --cache --report-unused-disable-directives ./src\",\n \"eslint-fix\": \"pnpm exec eslint --cache --quiet --report-unused-disable-directives ./src --fix\",\n \"ts-check\": \"tsc --noEmit\",\n \"test\": \"pnpm exec vitest run --reporter=minimal\",\n \"test-watch\": \"pnpm exec vitest --watch --silent passed-only\",\n \"test-ui\": \"pnpm exec vitest --ui --silent passed-only\",\n \"test-report\": \"pnpm exec vitest run --coverage --silent passed-only\",\n \"qa:pty\": \"INFRA_KIT_REQUIRE_PTY=1 pnpm exec vitest run --reporter=minimal src/tui/__tests__/stdin-pause-pty.test.ts src/entry/__tests__/quit-keys-pty.test.ts src/entry/__tests__/post-run-pause-pty.test.ts\",\n \"qa\": \"pnpm run prettier-check && pnpm run eslint-check && pnpm run ts-check && pnpm run test && echo \u2705 Success\",\n \"fix\": \"pnpm run prettier-fix && pnpm run eslint-fix && pnpm run qa\"\n },\n \"dependencies\": {\n \"@aws-lambda-powertools/logger\": \"^2.35.0\",\n \"@inquirer/checkbox\": \"^5.2.5\",\n \"@inquirer/confirm\": \"^6.3.2\",\n \"@inquirer/input\": \"^5.1.6\",\n \"@inquirer/password\": \"^5.2.2\",\n \"@inquirer/select\": \"^5.2.5\",\n \"@slip-stream-kit/config\": \"^0.11.10\",\n \"chalk\": \"^6.0.0\",\n \"chokidar\": \"^5.0.0\",\n \"commander\": \"^15.0.0\",\n \"fastify\": \"^5.12.4\",\n \"ink\": \"^7.1.1\",\n \"pino\": \"^10.3.1\",\n \"pino-pretty\": \"^13.1.3\",\n \"portless\": \"^0.15.6\",\n \"react\": \"19.3.0\",\n \"yaml\": \"^2.9.1\",\n \"zod\": \"^4.6.2\",\n \"zx\": \"^8.8.5\"\n },\n \"devDependencies\": {\n \"@slip-stream-kit/eslint-plugin\": \"workspace:*\",\n \"@types/aws-lambda\": \"catalog:\",\n \"@types/react\": \"catalog:\",\n \"@wl/eslint-config\": \"workspace:*\",\n \"@wl/vitest-config\": \"workspace:*\",\n \"esbuild\": \"^0.28.2\",\n \"ink-testing-library\": \"^4.0.0\",\n \"typescript\": \"^6.0.3\"\n }\n}\n"],
5
+ "mappings": "AAAA,IAAAA,EAAA,CACE,KAAQ,YACR,KAAQ,SACR,QAAW,UACX,MAAS,CACP,MACF,EACA,YAAe,YACf,IAAO,CACL,YAAa,cACb,GAAM,cACN,SAAU,mBACZ,EACA,QAAW,CACT,KAAQ,QACV,EACA,QAAW,CACT,MAAS,sDACT,QAAW,iBACX,kBAAmB,4BACnB,kBAAmB,cACnB,cAAe,2EACf,eAAgB,4HAChB,iBAAkB,4HAClB,eAAgB,oEAChB,aAAc,kFACd,WAAY,eACZ,KAAQ,0CACR,aAAc,gDACd,UAAW,6CACX,cAAe,uDACf,SAAU,qMACV,GAAM,gHACN,IAAO,6DACT,EACA,aAAgB,CACd,gCAAiC,UACjC,qBAAsB,SACtB,oBAAqB,SACrB,kBAAmB,SACnB,qBAAsB,SACtB,mBAAoB,SACpB,0BAA2B,WAC3B,MAAS,SACT,SAAY,SACZ,UAAa,UACb,QAAW,UACX,IAAO,SACP,KAAQ,UACR,cAAe,UACf,SAAY,UACZ,MAAS,SACT,KAAQ,SACR,IAAO,SACP,GAAM,QACR,EACA,gBAAmB,CACjB,iCAAkC,cAClC,oBAAqB,WACrB,eAAgB,WAChB,oBAAqB,cACrB,oBAAqB,cACrB,QAAW,UACX,sBAAuB,SACvB,WAAc,QAChB,CACF",
6
+ "names": ["package_default"]
7
+ }
@@ -1,4 +1,4 @@
1
- import{N as f,l as D,ma as W,r as G}from"./chunk-F656FWV5.js";import{execFile as re,execFileSync as te}from"node:child_process";import w from"node:process";var oe=5e3,ne=100,$=2e3,F="/bin/ps",ae=1e3,U=["-eo","pid=,ppid=,pgid=,lstart="],V=8<<20,B=r=>r.split(`
1
+ import{N as f,l as D,ma as W,r as G}from"./chunk-J6BHN362.js";import{execFile as re,execFileSync as te}from"node:child_process";import w from"node:process";var oe=5e3,ne=100,$=2e3,F="/bin/ps",ae=1e3,U=["-eo","pid=,ppid=,pgid=,lstart="],V=8<<20,B=r=>r.split(`
2
2
  `).flatMap(e=>{let[t,o,n,...a]=e.trim().split(/\s+/);if(t==null||o==null||n==null)return[];let c=Number(t),s=Number(o),l=Number(n);return!Number.isInteger(c)||!Number.isInteger(s)||!Number.isInteger(l)?[]:[{pid:c,ppid:s,pgid:l,lstart:a.join(" ")}]}),j=r=>{let e=new Map;for(let t of r)t.pid===t.pgid&&e.set(t.pgid,t.lstart);return e},se=(r,e,t)=>{let o=j(e);return H(r,e,t).flatMap(n=>{let a=o.get(n);return a==null||a===""?[]:[{pgid:n,leaderStart:a}]})},K=(r,e)=>{let t=j(e);return r.flatMap(({pgid:o,leaderStart:n})=>t.get(o)===n?[o]:[])},J=(r,e)=>K(r,e).flatMap(t=>{try{w.kill(-t,"SIGKILL")}catch{return[]}return[t]}),H=(r,e,t)=>{let o=new Map;for(let s of e){let l=o.get(s.ppid);l?l.push(s):o.set(s.ppid,[s])}let n=new Set([r]),a=new Set([r]),c=[r];for(let s=0;s<c.length;s+=1)for(let l of o.get(c[s]??-1)??[])a.has(l.pid)||(a.add(l.pid),n.add(l.pgid),c.push(l.pid));return[...n].filter(s=>s>1&&s!==t)},L=()=>{try{return B(te(F,[...U],{encoding:"utf8",maxBuffer:V}))}catch{return[]}},ie=async()=>new Promise(r=>{re(F,[...U],{encoding:"utf8",maxBuffer:V},(e,t)=>{r(e?[]:B(t))})}),ce=(r,e,t)=>t.some(o=>o.pid===r&&o.ppid===e),_=(r,e)=>{let t=e.find(o=>o.pid===w.pid)?.pgid;return H(r,e,t)},q=r=>{try{return w.kill(-r,0),!0}catch{return!1}},C=(r,e)=>{for(let t of r)try{w.kill(-t,e)}catch{}},P=new Set,le=(r,e,t)=>{let o=_(r,e),n=t.flatMap(a=>K(a,e));return[...new Set([...o,...n])]},z=()=>{let r=L(),e=[...P].map(t=>t());C(le(w.pid,r,e),"SIGKILL")},ue=async r=>new Promise(e=>{setTimeout(e,r)}),v=async(r,e)=>{let t=Date.now()+e,o=r;for(;o.length>0&&Date.now()<t&&(o=o.filter(q),o.length!==0);)await ue(ne);return o};function er(r,e=oe,t,o=L){r.unref();let n=!1,a=!1,c=[],s=null,l=()=>c;P.add(l);let m=()=>{s&&clearInterval(s),s=null},b=async()=>{await v(c.map(i=>i.pgid),$),P.delete(l)},y=i=>{let u=r.pid;if(u==null||a||n||i.length===0)return;let T=i.find(E=>E.pid===w.pid)?.pgid,S=se(u,i,T);S.length>0&&(c=S)},h=async()=>{r.pid==null||a||n||y(await ie())};y(L()),s=setInterval(()=>{h()},ae),s.unref();let R=i=>{n||t?.(i)};return r.on("exit",(i,u)=>{a=!0,m(),n||(J(c,o()),b()),R(`exited unexpectedly (code=${i??"null"}, signal=${u??"null"})`)}),r.on("error",i=>{R(`failed to spawn: ${i.message}`)}),{kill:async()=>{n=!0,m();let i=r.pid;if(i==null){P.delete(l);return}if(r.exitCode!==null||r.signalCode!==null){J(c,o()),await b();return}let u=o();if(u.length>0&&!ce(i,w.pid,u))return;let T=_(i,u);C(T,"SIGTERM");let S=await v(T,e);if(S.length===0){P.delete(l);return}let E=_(i,o()),M=[...new Set([...S,...E])].filter(q);C(M,"SIGKILL"),await v(M,$),P.delete(l)}}}import{constants as pe}from"node:os";import k from"node:process";var de=["SIGINT","SIGTERM","SIGHUP"],me=pe.signals,fe=2,N=r=>128+(me[r]??fe),ge=2e4,Oe=r=>{k.exit(r)},we=(r,e)=>{k.on(r,e)},be=(r,e)=>{k.off(r,e)},ye=(r,e)=>{let t=setTimeout(r,e);return t.unref(),()=>{clearTimeout(t)}},A=r=>{try{k.stderr.write(r)}catch{}},he=(r,e)=>{let t=e instanceof Error?`${e.message}
3
3
  ${e.stack??"(no stack)"}`:String(e);A(`
4
4
  \u2717 Teardown failed while handling ${r}: ${t}
@@ -7,4 +7,4 @@ ${e.stack??"(no stack)"}`:String(e);A(`
7
7
  `),b?.(),n(),h(),e(N(i));return}m=i,b=c(()=>{let u=`
8
8
  \u26A0 Teardown deadline exceeded at stage=${s()} after ${a}ms \u2014 force-quitting.
9
9
  `;A(u),l(u),n(),h(),e(N(i))},a),(async()=>{try{await r(i)}catch(u){he(i,u)}finally{b?.(),h(),e(N(i))}})()};for(let i of de){let u=()=>R(i);y.set(i,u),t(i,u)}return h};var Pe=new Set(["ExitPromptError","AbortPromptError","PromptCancelledError"]),X=r=>r instanceof Error&&Pe.has(r.name),ir=r=>{if(X(r))return!0;let e=r?.cause;return X(e)};import{loadDev as xe}from"@slip-stream-kit/config/internal";import Se from"node:path";var Re=(r,e)=>{let t=new Set;for(let o of Object.values(r))for(let n of Object.keys(W(o,e).proxy))t.add(n);return[...t]},Te=async(r,e)=>{let t={},o=[];return await Promise.all(e.map(async n=>{try{let c=(await xe(Se.join(r,"apps",n,"ui")))?.proxy?.routes;if(!c)return;t[n]=Object.fromEntries(Object.entries(c).map(([s,l])=>[s,l.packageName]))}catch(a){o.push({app:n,message:a instanceof Error?a.message:String(a)})}})),{routePkg:(n,a)=>t[n]?.[a],loadErrors:o}},dr=async(r,e,t,o)=>{let{routePkg:n,loadErrors:a}=await Te(r,Re(e,t));return{ctx:{discovered:t,apiPkgByApp:Object.fromEntries(o.map(c=>[c.name,c.packageName])),routePkg:n},loadErrors:a}};import{$ as ke}from"zx";var d=class extends Error{code;data;constructor(e){super(e.message),this.name="OrcaError",this.code=e.code,this.data=e.data}},x=class extends Error{exitCode;stderrTail;constructor(e,t){super(`orca: stdout is not a JSON envelope (exit ${e??"signal"})`),this.name="OrcaMalformedError",this.exitCode=e,this.stderrTail=t}},g=class extends Error{constructor(){super("orca: command not found \u2014 the CLI is registered from Orca \u2192 Settings \u2192 Experimental \u2192 CLI"),this.name="OrcaAbsentError"}},Ee=400,ve=127,Le=r=>typeof r=="object"&&r!==null&&r.code==="ENOENT",_e=async r=>{try{return await ke({nothrow:!0,quiet:!0})`orca ${r} --json`}catch(e){throw Le(e)?new g:e}},Ce=r=>{try{let e=JSON.parse(r);return typeof e=="object"&&e!==null&&typeof e.ok=="boolean"?e:null}catch{return null}},p=async r=>{let e=await _e(r),t=Ce(e.stdout);if(f.debug({argv:r,ok:t?.ok,code:t?.error?.code,exitCode:e.exitCode},"orca"),!t)throw e.exitCode===ve?new g:new x(e.exitCode,e.stderr.slice(-Ee));if(!t.ok)throw new d(t.error??{code:"unknown",message:"orca: ok:false without an error payload"});return t.result};var Ne=async()=>{try{let r=await p(["status"]);return f.debug({appVersion:r.runtime?.appVersion},"orca: status"),r.app?.running===!0&&r.runtime?.reachable===!0?"ready":"unreachable"}catch(r){return r instanceof g?"absent":(f.debug({error:r},"orca: status probe failed"),"unreachable")}};import{realpath as Ae}from"node:fs/promises";var O=async r=>{try{return await Ae(r)}catch{return r}};var Ie=async r=>{let[{repos:e=[]},t]=await Promise.all([p(["repo","list"]),O(r)]);for(let o of e)if(await O(o.path)===t)return{registered:!0,visibility:o.externalWorktreeVisibility};return{registered:!1}},Me=async r=>{let{repo:e}=await p(["repo","add","--path",r]);return{visibility:e?.externalWorktreeVisibility}};var De="500",Ge=async(r,e)=>{let[{worktrees:t=[]},o]=await Promise.all([p(["worktree","list","--repo",`path:${r}`,"--limit",De]),O(e)]);for(let n of t)if(await O(n.path)===o)return!0;return!1};import We from"node:process";var Y="::",$e=r=>{let e=r.ORCA_WORKTREE_ID;if(!e)return null;let t=e.indexOf(Y);if(t<0)return null;let o=e.slice(t+Y.length);return o.length>0?o:null},Je=async(r,e=We.env)=>{let t=$e(e);if(t===null)return null;let o=await O(t);for(let n of r)if(await O(n)===o)return n;return null};var Q="200",I=async r=>{try{let e=await p(["terminal","list","--worktree",`path:${r}`,"--limit",Q]),t=e.truncated===!0;return t&&f.debug({cwd:r,limit:Q},"orca: terminal list truncated"),{terminals:e.terminals??[],truncated:t}}catch(e){if(e instanceof d&&e.code==="selector_not_found")return{terminals:[],truncated:!1};throw e}};var Fe=async r=>{try{return await p(["terminal","close","--worktree",`path:${r}`,"--all"]),"retired"}catch(e){if(e instanceof d&&e.code==="selector_not_found")return"not_found";if(e instanceof d&&e.code==="terminal_close_incomplete")return f.debug({cwd:r,error:e},"orca: surfaces not retired"),"retired";throw e}},Ue=async r=>{let{terminals:e}=await I(r);for(let o of e)await p(["terminal","close","--terminal",o.handle]);let t=await Fe(r);return e.length===0&&t==="not_found"?{closed:!1,skipped:"not_found"}:{closed:!0,count:e.length}},Ve=(r,e)=>e instanceof g?{closed:!1,skipped:"absent"}:e instanceof d?{closed:!1,error:e}:e instanceof x?{closed:!1,error:new d({code:"orca_malformed_output",message:e.message,data:{exitCode:e.exitCode,stderrTail:e.stderrTail}})}:(f.debug({cwd:r,error:e},"orca: close failed outside the Orca contract"),{closed:!1,error:new d({code:"orca_close_failed",message:e instanceof Error?e.message:String(e)})}),Be=async(r,e)=>{if(e!=="ready")return{closed:!1,skipped:e};try{return await Ue(r)}catch(t){return Ve(r,t)}};import{setTimeout as je}from"node:timers/promises";var Ke=3,He=300,ee=(r={})=>({attempts:r.attempts??Ke,delayMs:r.delayMs??He,exhausted:!1}),qe=async r=>{try{return{created:await p(r)}}catch(e){if(e instanceof d&&e.code==="selector_not_found")return{notSelectable:e};throw e}},ze=async(r,e,t)=>{let o=t.exhausted?1:t.attempts,n=Array.from({length:o},(c,s)=>s+1),a;for(let c of n){let s=await qe(r);if("created"in s)return s.created.terminal.handle;a=s.notSelectable,c<o&&await je(t.delayMs)}throw t.exhausted=!0,new d({code:"orca_worktree_not_selectable",message:`orca: worktree ${e} is not selectable after ${o} attempt(s): ${a?.message??""}`,data:{cwd:e,attempts:o,cause:a?.data}})},Z=async(r,e)=>(await p(["terminal","split","--terminal",r,"--direction",e])).split.handle,Xe=async r=>{let{cwd:e,title:t,focus:o,layout:n,panes:a,poll:c=ee()}=r,s=["terminal","create","--worktree",`path:${e}`,"--title",t,...o?["--focus"]:[]],l=await ze(s,e,c),m=[l];return n==="full"&&(m.push(await Z(l,"horizontal")),a==="three-pane"&&m.push(await Z(l,"vertical"))),{handles:m,layout:n}};var Ye=r=>{let{branch:e}=r,t=D(e);return t?G(t):e};export{dr as a,d as b,p as c,Ne as d,Je as e,I as f,Be as g,Ie as h,Me as i,Ge as j,ee as k,Xe as l,Ye as m,z as n,er as o,N as p,ar as q,ir as r};
10
- //# sourceMappingURL=chunk-OWX4O3IS.js.map
10
+ //# sourceMappingURL=chunk-SREJWU57.js.map
@@ -0,0 +1,4 @@
1
+ import R from"node:fs";import u from"node:os";import I from"node:path";import F from"node:process";var h="env-load.sh",O="env-clear.sh",A="INFRA_KIT_SESSION",S=".infra-kit",f="INFRA_KIT_ENV",x="INFRA_KIT_ENV_CONFIG",d="INFRA_KIT_ENV_PROJECT",v="INFRA_KIT_ENV_PROJECT_ROOT",C="INFRA_KIT_ENV_LOADED_AT",V=/^([A-Z_]\w*)=/i,K=/^unset ([A-Z_]\w*)$/i,c=(t,n)=>{let s=n;for(let e=0;e<t.length;e++){if(!s&&t[e]==="\\"){e++;continue}t[e]==="'"&&(s=!s)}return s},D=t=>{let n=t.startsWith("'")?t.slice(1):t;return(n.endsWith("'")?n.slice(0,-1):n).split("'\\''").join("'")},p=t=>{try{return R.readFileSync(t,"utf-8")}catch{return""}},g=(t,n,s)=>{let e=t.split(`
2
+ `).map(o=>o.endsWith("\r")?o.slice(0,-1):o),r=0,i=!1;for(;r<e.length;){let o=e[r];if(i){i=c(o,i),r+=1;continue}let N=V.exec(o);if(!N){let _=K.exec(o);_&&s?.(_[1]),i=c(o,!1),r+=1;continue}let l=N[1],E=o.slice(N[0].length);if(!E.startsWith("'")){n({name:l,value:E}),i=c(o,!1),r+=1;continue}let T=[E],a=c(E,!1);for(;a&&r+1<e.length;){r+=1;let _=e[r];T.push(_),a=c(_,!0)}n({name:l,value:D(T.join(`
3
+ `))}),i=a,r+=1}},L=t=>{let n=[];return g(p(t),({name:s})=>{n.push(s)}),n},y=t=>{let n={};return g(p(t),({name:s,value:e})=>{n[s]=e}),n},P=t=>{let n=[];return g(p(t),()=>{},s=>{n.push(s)}),n},m=()=>{let t=F.env.XDG_CACHE_HOME,n=t&&t.length>0?t:I.join(u.homedir(),".cache");return I.join(n,"infra-kit")},w=()=>{let t=F.env[A];if(!t)throw new Error(`${A} is not set. Run \`infra-kit setup --skip-tools\` then \`source ~/.zshrc\`.`);return I.join(m(),t)},W=(t,n,s)=>{let e=`${t}.tmp.${F.pid}`;R.writeFileSync(e,n,{mode:s});try{R.renameSync(e,t)}catch(r){throw R.rmSync(e,{force:!0}),r}},U="-worktrees";export{h as a,O as b,A as c,S as d,f as e,x as f,d as g,v as h,C as i,L as j,y as k,P as l,m,w as n,W as o,U as p};
4
+ //# sourceMappingURL=chunk-ZZ7HCY2S.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/lib/constants/constants.ts"],
4
4
  "sourcesContent": ["import fs from 'node:fs'\nimport os from 'node:os'\nimport path from 'node:path'\nimport process from 'node:process'\n\nexport const ENV_LOAD_FILE = 'env-load.sh'\nexport const ENV_CLEAR_FILE = 'env-clear.sh'\n\nexport const INFRA_KIT_SESSION_VAR = 'INFRA_KIT_SESSION'\n/**\n * Directory under the user's home that holds all machine-local infra-kit config:\n * the runtime `infra-kit.json` merge layer, per-project overrides, the factory\n * registry (`vendor.json`), and the `portless` package link. Single source of\n * truth for `.infra-kit`.\n *\n * Defined HERE, not in `lib/infra-kit-config`, because that module pulls in zod\n * and the `ik-mcp` proxy bundle must stay Node-builtins-only (guarded in\n * `entry/__tests__/dist-shebang.test.ts`); `lib/infra-kit-config` re-exports it\n * for its existing consumers.\n */\nexport const USER_CONFIG_DIR_NAME = '.infra-kit'\n/**\n * The active environment/config NAME (e.g. `dev`, `arthur`), exported plainly so\n * non-shell consumers can read it from `process.env`. Notably `infra-kit/vite`'s\n * `infraKitDev()` reads this to interpolate the `<env>` placeholder in cloud proxy\n * targets. Mirrors {@link INFRA_KIT_ENV_CONFIG_VAR} (same value) but is the stable,\n * purpose-named handle for tooling rather than the shell session-metadata var.\n */\nexport const INFRA_KIT_ENV_VAR = 'INFRA_KIT_ENV'\nexport const INFRA_KIT_ENV_CONFIG_VAR = 'INFRA_KIT_ENV_CONFIG'\nexport const INFRA_KIT_ENV_PROJECT_VAR = 'INFRA_KIT_ENV_PROJECT'\n/**\n * Absolute project root (git top-level) the loaded env belongs to, so a shell can\n * tell whose secrets it is carrying after a `cd` into another project.\n */\nexport const INFRA_KIT_ENV_PROJECT_ROOT_VAR = 'INFRA_KIT_ENV_PROJECT_ROOT'\nexport const INFRA_KIT_ENV_LOADED_AT_VAR = 'INFRA_KIT_ENV_LOADED_AT'\n\n/**\n * Matches a line of the form `KEY=...` where KEY is an env-var identifier\n * (letter or underscore, then word chars). Capture group 1 is the name. Shared\n * between env-load (validation, var counting) and parseVarNamesFromEnvFile.\n */\nexport const ENV_VAR_LINE_PATTERN = /^([A-Z_]\\w*)=/i\n\n/**\n * The `unset NAME` line env-clear.sh is made of. Anchored at both ends so a value that merely\n * starts with the word is not a match.\n */\nconst UNSET_LINE_PATTERN = /^unset ([A-Z_]\\w*)$/i\n\n/**\n * Track whether a physical line leaves us inside an open single-quoted value,\n * mirroring how `shellSingleQuote` emits values (`'\u2026'`, with literal quotes as\n * `'\\''`). Outside a quote a backslash escapes the next char; inside a quote a\n * `'` closes it. Lets the parser skip the continuation lines of a multiline value.\n */\nconst advanceSingleQuoteState = (line: string, startInQuote: boolean): boolean => {\n let inQuote = startInQuote\n\n for (let i = 0; i < line.length; i++) {\n if (!inQuote && line[i] === '\\\\') {\n i++\n continue\n }\n\n if (line[i] === \"'\") {\n inQuote = !inQuote\n }\n }\n\n return inQuote\n}\n\n/** One `KEY=value` assignment recovered from an env file, value already unescaped. */\nexport interface EnvAssignment {\n name: string\n value: string\n}\n\n/**\n * Undo {@link shellSingleQuote}: drop the wrapping quotes, then turn each `'\\''`\n * back into a literal `'`. Order matters \u2014 unescaping first would let an embedded\n * `'\\''` be mistaken for the closing quote.\n */\nconst decodeSingleQuoted = (raw: string): string => {\n const withoutOpen = raw.startsWith(\"'\") ? raw.slice(1) : raw\n const body = withoutOpen.endsWith(\"'\") ? withoutOpen.slice(0, -1) : withoutOpen\n\n return body.split(\"'\\\\''\").join(\"'\")\n}\n\n/** File contents, or '' when the path is absent, a directory, or unreadable. */\nconst readEnvFileContent = (filePath: string): string => {\n try {\n return fs.readFileSync(filePath, 'utf-8')\n } catch {\n return ''\n }\n}\n\n/**\n * Walk every assignment in an env-load.sh body, skipping the continuation lines of\n * multiline values. {@link parseVarNamesFromEnvFile}, {@link parseVarsFromEnvFile}\n * and {@link parseUnsetNamesFromEnvFile} all go through here, so they can never\n * disagree about where a value ends \u2014 an `unset X` inside a quoted value is a\n * continuation line to every one of them.\n */\nconst forEachAssignment = (\n content: string,\n visit: (assignment: EnvAssignment) => void,\n visitUnset?: (name: string) => void,\n): void => {\n // A trailing CR is stripped per line: a CRLF file would otherwise hand back values\n // ending in '\\r' \u2014 a token that looks right in a diff and fails every request.\n const lines = content.split('\\n').map((line) => {\n return line.endsWith('\\r') ? line.slice(0, -1) : line\n })\n let index = 0\n let inQuote = false\n\n while (index < lines.length) {\n const line = lines[index]!\n\n // Only a line that starts OUTSIDE a quoted value can be a real assignment;\n // continuation lines of a multiline secret value are skipped.\n if (inQuote) {\n inQuote = advanceSingleQuoteState(line, inQuote)\n index += 1\n continue\n }\n\n const match = ENV_VAR_LINE_PATTERN.exec(line)\n\n if (!match) {\n const unset = UNSET_LINE_PATTERN.exec(line)\n\n if (unset) visitUnset?.(unset[1]!)\n\n inQuote = advanceSingleQuoteState(line, false)\n index += 1\n continue\n }\n\n const name = match[1]!\n const rest = line.slice(match[0].length)\n\n // An unquoted value cannot span lines (`CONNECTION_STRING=host=db;user=admin`).\n if (!rest.startsWith(\"'\")) {\n visit({ name, value: rest })\n inQuote = advanceSingleQuoteState(line, false)\n index += 1\n continue\n }\n\n const parts = [rest]\n let open = advanceSingleQuoteState(rest, false)\n\n while (open && index + 1 < lines.length) {\n index += 1\n const continuation = lines[index]!\n\n parts.push(continuation)\n open = advanceSingleQuoteState(continuation, true)\n }\n\n visit({ name, value: decodeSingleQuoted(parts.join('\\n')) })\n inQuote = open\n index += 1\n }\n}\n\nexport const parseVarNamesFromEnvFile = (filePath: string): string[] => {\n const names: string[] = []\n\n forEachAssignment(readEnvFileContent(filePath), ({ name }) => {\n names.push(name)\n })\n\n return names\n}\n\n/**\n * Same walk as {@link parseVarNamesFromEnvFile}, but keeping the values. Later\n * assignments win, matching what `source`ing the file would do.\n */\nexport const parseVarsFromEnvFile = (filePath: string): Record<string, string> => {\n const vars: Record<string, string> = {}\n\n forEachAssignment(readEnvFileContent(filePath), ({ name, value }) => {\n vars[name] = value\n })\n\n return vars\n}\n\n/**\n * The names the file `unset`s \u2014 everything env-clear.sh does. Absent file \u2192 `[]`, like\n * its siblings.\n */\nexport const parseUnsetNamesFromEnvFile = (filePath: string): string[] => {\n const names: string[] = []\n\n forEachAssignment(\n readEnvFileContent(filePath),\n () => {},\n (name) => {\n names.push(name)\n },\n )\n\n return names\n}\n\n/**\n * Root cache dir for infra-kit across all sessions. Resolved from\n * $XDG_CACHE_HOME when set, falling back to ~/.cache/infra-kit. Keep in sync\n * with the shell block emitted by `infra-kit setup` (src/commands/init/init.ts).\n */\nexport const getCacheRoot = (): string => {\n const xdg = process.env.XDG_CACHE_HOME\n const base = xdg && xdg.length > 0 ? xdg : path.join(os.homedir(), '.cache')\n\n return path.join(base, 'infra-kit')\n}\n\nexport const getSessionCacheDir = (): string => {\n const session = process.env[INFRA_KIT_SESSION_VAR]\n\n if (!session) {\n throw new Error(\n `${INFRA_KIT_SESSION_VAR} is not set. Run \\`infra-kit setup --skip-tools\\` then \\`source ~/.zshrc\\`.`,\n )\n }\n\n return path.join(getCacheRoot(), session)\n}\n\n/**\n * Write content atomically: write to a pid-suffixed temp file in the same\n * directory, then rename. fs.renameSync is atomic on a single filesystem, so\n * concurrent writers can't produce a half-written secret file.\n */\nexport const atomicWriteFileSync = (filePath: string, content: string, mode: number): void => {\n const tmpPath = `${filePath}.tmp.${process.pid}`\n\n fs.writeFileSync(tmpPath, content, { mode })\n\n try {\n fs.renameSync(tmpPath, filePath)\n } catch (error) {\n fs.rmSync(tmpPath, { force: true })\n throw error\n }\n}\n\nexport const WORKTREES_DIR_SUFFIX = '-worktrees'\n"],
5
- "mappings": "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",
6
- "names": ["fs", "os", "path", "process", "ENV_LOAD_FILE", "ENV_CLEAR_FILE", "INFRA_KIT_SESSION_VAR", "USER_CONFIG_DIR_NAME", "INFRA_KIT_ENV_VAR", "INFRA_KIT_ENV_CONFIG_VAR", "INFRA_KIT_ENV_PROJECT_VAR", "INFRA_KIT_ENV_PROJECT_ROOT_VAR", "INFRA_KIT_ENV_LOADED_AT_VAR", "ENV_VAR_LINE_PATTERN", "UNSET_LINE_PATTERN", "advanceSingleQuoteState", "line", "startInQuote", "inQuote", "i", "decodeSingleQuoted", "raw", "withoutOpen", "readEnvFileContent", "filePath", "forEachAssignment", "content", "visit", "visitUnset", "lines", "index", "match", "unset", "name", "rest", "parts", "open", "continuation", "parseVarNamesFromEnvFile", "names", "parseVarsFromEnvFile", "vars", "value", "getCacheRoot", "xdg", "process", "base", "path", "os", "getSessionCacheDir", "session", "INFRA_KIT_SESSION_VAR", "atomicWriteFileSync", "filePath", "content", "mode", "tmpPath", "fs", "error", "WORKTREES_DIR_SUFFIX"]
5
+ "mappings": "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",
6
+ "names": ["fs", "os", "path", "process", "ENV_LOAD_FILE", "ENV_CLEAR_FILE", "INFRA_KIT_SESSION_VAR", "USER_CONFIG_DIR_NAME", "INFRA_KIT_ENV_VAR", "INFRA_KIT_ENV_CONFIG_VAR", "INFRA_KIT_ENV_PROJECT_VAR", "INFRA_KIT_ENV_PROJECT_ROOT_VAR", "INFRA_KIT_ENV_LOADED_AT_VAR", "ENV_VAR_LINE_PATTERN", "UNSET_LINE_PATTERN", "advanceSingleQuoteState", "line", "startInQuote", "inQuote", "i", "decodeSingleQuoted", "raw", "withoutOpen", "readEnvFileContent", "filePath", "forEachAssignment", "content", "visit", "visitUnset", "lines", "index", "match", "unset", "name", "rest", "parts", "open", "continuation", "parseVarNamesFromEnvFile", "names", "parseVarsFromEnvFile", "vars", "value", "parseUnsetNamesFromEnvFile", "getCacheRoot", "xdg", "base", "getSessionCacheDir", "session", "atomicWriteFileSync", "mode", "tmpPath", "error", "WORKTREES_DIR_SUFFIX"]
7
7
  }