infra-kit 0.23.0 → 0.27.0

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,2 +1,2 @@
1
- var i={name:"infra-kit",type:"module",version:"0.23.0",repository:{type:"git",url:"git+https://github.com/ArthurSaenz/infra-kit.git",directory:"apps/infra-kit/cli"},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.6","@inquirer/confirm":"^6.3.3","@inquirer/input":"^5.1.7","@inquirer/password":"^5.2.3","@inquirer/select":"^5.2.6","@slip-stream-kit/config":"workspace:^",chalk:"^6.0.1",chokidar:"^5.0.0",commander:"^15.0.0",fastify:"^5.12.5",ink:"^8.0.0",pino:"^10.4.0","pino-pretty":"^13.2.0",portless:"^0.15.7",react:"19.3.0",yaml:"^2.9.1",zod:"^4.6.5",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-GAFG2JPV.js.map
1
+ var i={name:"infra-kit",type:"module",version:"0.27.0",repository:{type:"git",url:"git+https://github.com/ArthurSaenz/infra-kit.git",directory:"apps/infra-kit/cli"},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.6","@inquirer/confirm":"^6.3.3","@inquirer/input":"^5.1.7","@inquirer/password":"^5.2.3","@inquirer/select":"^5.2.6","@slip-stream-kit/config":"workspace:^",chalk:"^6.0.1",chokidar:"^5.0.0",commander:"^15.0.0",fastify:"^5.12.5",ink:"^8.0.0",pino:"^10.4.0","pino-pretty":"^13.2.0",portless:"^0.15.7",react:"19.3.0",yaml:"^2.9.1",zod:"^4.6.5",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-53KLNCP2.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../package.json"],
4
- "sourcesContent": ["{\n \"name\": \"infra-kit\",\n \"type\": \"module\",\n \"version\": \"0.23.0\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/ArthurSaenz/infra-kit.git\",\n \"directory\": \"apps/infra-kit/cli\"\n },\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.6\",\n \"@inquirer/confirm\": \"^6.3.3\",\n \"@inquirer/input\": \"^5.1.7\",\n \"@inquirer/password\": \"^5.2.3\",\n \"@inquirer/select\": \"^5.2.6\",\n \"@slip-stream-kit/config\": \"workspace:^\",\n \"chalk\": \"^6.0.1\",\n \"chokidar\": \"^5.0.0\",\n \"commander\": \"^15.0.0\",\n \"fastify\": \"^5.12.5\",\n \"ink\": \"^8.0.0\",\n \"pino\": \"^10.4.0\",\n \"pino-pretty\": \"^13.2.0\",\n \"portless\": \"^0.15.7\",\n \"react\": \"19.3.0\",\n \"yaml\": \"^2.9.1\",\n \"zod\": \"^4.6.5\",\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"],
4
+ "sourcesContent": ["{\n \"name\": \"infra-kit\",\n \"type\": \"module\",\n \"version\": \"0.27.0\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/ArthurSaenz/infra-kit.git\",\n \"directory\": \"apps/infra-kit/cli\"\n },\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.6\",\n \"@inquirer/confirm\": \"^6.3.3\",\n \"@inquirer/input\": \"^5.1.7\",\n \"@inquirer/password\": \"^5.2.3\",\n \"@inquirer/select\": \"^5.2.6\",\n \"@slip-stream-kit/config\": \"workspace:^\",\n \"chalk\": \"^6.0.1\",\n \"chokidar\": \"^5.0.0\",\n \"commander\": \"^15.0.0\",\n \"fastify\": \"^5.12.5\",\n \"ink\": \"^8.0.0\",\n \"pino\": \"^10.4.0\",\n \"pino-pretty\": \"^13.2.0\",\n \"portless\": \"^0.15.7\",\n \"react\": \"19.3.0\",\n \"yaml\": \"^2.9.1\",\n \"zod\": \"^4.6.5\",\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
5
  "mappings": "AAAA,IAAAA,EAAA,CACE,KAAQ,YACR,KAAQ,SACR,QAAW,SACX,WAAc,CACZ,KAAQ,MACR,IAAO,mDACP,UAAa,oBACf,EACA,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,cAC3B,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
6
  "names": ["package_default"]
7
7
  }
@@ -1,4 +1,4 @@
1
- import{P as f,l as $,r as F}from"./chunk-5KUIGRG5.js";import{execFile as te,execFileSync as oe}from"node:child_process";import b from"node:process";var ne=5e3,ae=100,W=2e3,U="/bin/ps",se=1e3,J=["-eo","pid=,ppid=,pgid=,lstart="],V=8<<20,B=e=>e.split(`
1
+ import{P as f,l as $,r as F}from"./chunk-MUYD4QA4.js";import{execFile as te,execFileSync as oe}from"node:child_process";import b from"node:process";var ne=5e3,ae=100,W=2e3,U="/bin/ps",se=1e3,J=["-eo","pid=,ppid=,pgid=,lstart="],V=8<<20,B=e=>e.split(`
2
2
  `).flatMap(r=>{let[t,o,n,...i]=r.trim().split(/\s+/);if(t==null||o==null||n==null)return[];let l=Number(t),s=Number(o),c=Number(n);return!Number.isInteger(l)||!Number.isInteger(s)||!Number.isInteger(c)?[]:[{pid:l,ppid:s,pgid:c,lstart:i.join(" ")}]}),H=e=>{let r=new Map;for(let t of e)t.pid===t.pgid&&r.set(t.pgid,t.lstart);return r},ie=(e,r,t)=>{let o=H(r);return j(e,r,t).flatMap(n=>{let i=o.get(n);return i==null||i===""?[]:[{pgid:n,leaderStart:i}]})},K=(e,r)=>{let t=H(r);return e.flatMap(({pgid:o,leaderStart:n})=>t.get(o)===n?[o]:[])},D=(e,r)=>K(e,r).flatMap(t=>{try{b.kill(-t,"SIGKILL")}catch{return[]}return[t]}),j=(e,r,t)=>{let o=new Map;for(let s of r){let c=o.get(s.ppid);c?c.push(s):o.set(s.ppid,[s])}let n=new Set([e]),i=new Set([e]),l=[e];for(let s=0;s<l.length;s+=1)for(let c of o.get(l[s]??-1)??[])i.has(c.pid)||(i.add(c.pid),n.add(c.pgid),l.push(c.pid));return[...n].filter(s=>s>1&&s!==t)},A=()=>{try{return B(oe(U,[...J],{encoding:"utf8",maxBuffer:V}))}catch{return[]}},ce=async()=>new Promise(e=>{te(U,[...J],{encoding:"utf8",maxBuffer:V},(r,t)=>{e(r?[]:B(t))})}),le=(e,r,t)=>t.some(o=>o.pid===e&&o.ppid===r),L=(e,r)=>{let t=r.find(o=>o.pid===b.pid)?.pgid;return j(e,r,t)},q=e=>{try{return b.kill(-e,0),!0}catch{return!1}},C=(e,r)=>{for(let t of e)try{b.kill(-t,r)}catch{}},S=new Set,ue=(e,r,t)=>{let o=L(e,r),n=t.flatMap(i=>K(i,r));return[...new Set([...o,...n])]},z=()=>{let e=A(),r=[...S].map(t=>t());C(ue(b.pid,e,r),"SIGKILL")},pe=async e=>new Promise(r=>{setTimeout(r,e)}),v=async(e,r)=>{let t=Date.now()+r,o=e;for(;o.length>0&&Date.now()<t&&(o=o.filter(q),o.length!==0);)await pe(ae);return o};function or(e,r=ne,t,o=A){e.unref();let n=!1,i=!1,l=[],s=null,c=()=>l;S.add(c);let m=()=>{s&&clearInterval(s),s=null},w=async()=>{await v(l.map(a=>a.pgid),W),S.delete(c)},h=a=>{let u=e.pid;if(u==null||i||n||a.length===0)return;let R=a.find(_=>_.pid===b.pid)?.pgid,x=ie(u,a,R);x.length>0&&(l=x)},y=async()=>{e.pid==null||i||n||h(await ce())};h(A()),s=setInterval(()=>{y()},se),s.unref();let T=a=>{n||t?.(a)};return e.on("exit",(a,u)=>{i=!0,m(),n||(D(l,o()),w()),T(`exited unexpectedly (code=${a??"null"}, signal=${u??"null"})`)}),e.on("error",a=>{T(`failed to spawn: ${a.message}`)}),{kill:async()=>{n=!0,m();let a=e.pid;if(a==null){S.delete(c);return}if(e.exitCode!==null||e.signalCode!==null){D(l,o()),await w();return}let u=o();if(u.length>0&&!le(a,b.pid,u))return;let R=L(a,u);C(R,"SIGTERM");let x=await v(R,r);if(x.length===0){S.delete(c);return}let _=L(a,o()),G=[...new Set([...x,..._])].filter(q);C(G,"SIGKILL"),await v(G,W),S.delete(c)}}}import{constants as de}from"node:os";import k from"node:process";var me=["SIGINT","SIGTERM","SIGHUP"],fe=de.signals,ge=2,N=e=>128+(fe[e]??ge),Oe=2e4,be=e=>{k.exit(e)},we=(e,r)=>{k.on(e,r)},he=(e,r)=>{k.off(e,r)},ye=(e,r)=>{let t=setTimeout(e,r);return t.unref(),()=>{clearTimeout(t)}},I=e=>{try{k.stderr.write(e)}catch{}},Se=(e,r)=>{let t=r instanceof Error?`${r.message}
3
3
  ${r.stack??"(no stack)"}`:String(r);I(`
4
4
  \u2717 Teardown failed while handling ${e}: ${t}
@@ -7,4 +7,4 @@ ${r.stack??"(no stack)"}`:String(r);I(`
7
7
  `),w?.(),n(),y(),r(N(a));return}m=a,w=l(()=>{let u=`
8
8
  \u26A0 Teardown deadline exceeded at stage=${s()} after ${i}ms \u2014 force-quitting.
9
9
  `;I(u),c(u),n(),y(),r(N(a))},i),(async()=>{try{await e(a)}catch(u){Se(a,u)}finally{w?.(),y(),r(N(a))}})()};for(let a of me){let u=()=>T(a);h.set(a,u),t(a,u)}return y};var Pe=new Set(["ExitPromptError","AbortPromptError","PromptCancelledError"]),X=e=>e instanceof Error&&Pe.has(e.name),ur=e=>{if(X(e))return!0;let r=e?.cause;return X(r)};import{$ as xe}from"zx";var d=class extends Error{code;data;constructor(r){super(r.message),this.name="OrcaError",this.code=r.code,this.data=r.data}},P=class extends Error{exitCode;stderrTail;constructor(r,t){super(`orca: stdout is not a JSON envelope (exit ${r??"signal"})`),this.name="OrcaMalformedError",this.exitCode=r,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"}},Te=400,Re=127,ke=e=>typeof e=="object"&&e!==null&&e.code==="ENOENT",Ee=async e=>{try{return await xe({nothrow:!0,quiet:!0})`orca ${e} --json`}catch(r){throw ke(r)?new g:r}},_e=e=>{try{let r=JSON.parse(e);return typeof r=="object"&&r!==null&&typeof r.ok=="boolean"?r:null}catch{return null}},p=async e=>{let r=await Ee(e),t=_e(r.stdout);if(f.debug({argv:e,ok:t?.ok,code:t?.error?.code,exitCode:r.exitCode},"orca"),!t)throw r.exitCode===Re?new g:new P(r.exitCode,r.stderr.slice(-Te));if(!t.ok)throw new d(t.error??{code:"unknown",message:"orca: ok:false without an error payload"});return t.result};var ve=async()=>{try{let e=await p(["status"]);return f.debug({appVersion:e.runtime?.appVersion},"orca: status"),e.app?.running===!0&&e.runtime?.reachable===!0?"ready":"unreachable"}catch(e){return e instanceof g?"absent":(f.debug({error:e},"orca: status probe failed"),"unreachable")}};import{realpath as Ae}from"node:fs/promises";var O=async e=>{try{return await Ae(e)}catch{return e}};var Le=async e=>{let[{repos:r=[]},t]=await Promise.all([p(["repo","list"]),O(e)]);for(let o of r)if(await O(o.path)===t)return{registered:!0,visibility:o.externalWorktreeVisibility};return{registered:!1}},Ce=async e=>{let{repo:r}=await p(["repo","add","--path",e]);return{visibility:r?.externalWorktreeVisibility}};var Ne="500",Ie=async(e,r)=>{let[{worktrees:t=[]},o]=await Promise.all([p(["worktree","list","--repo",`path:${e}`,"--limit",Ne]),O(r)]);for(let n of t)if(await O(n.path)===o)return!0;return!1};import Me from"node:process";var Y="::",Ge=e=>{let r=e.ORCA_WORKTREE_ID;if(!r)return null;let t=r.indexOf(Y);if(t<0)return null;let o=r.slice(t+Y.length);return o.length>0?o:null},$e=async(e,r=Me.env)=>{let t=Ge(r);if(t===null)return null;let o=await O(t);for(let n of e)if(await O(n)===o)return n;return null};var Q="200",M=async e=>{try{let r=await p(["terminal","list","--worktree",`path:${e}`,"--limit",Q]),t=r.truncated===!0;return t&&f.debug({cwd:e,limit:Q},"orca: terminal list truncated"),{terminals:r.terminals??[],truncated:t}}catch(r){if(r instanceof d&&r.code==="selector_not_found")return{terminals:[],truncated:!1};throw r}};var Fe=async e=>{try{return await p(["terminal","close","--worktree",`path:${e}`,"--all"]),"retired"}catch(r){if(r instanceof d&&r.code==="selector_not_found")return"not_found";if(r instanceof d&&r.code==="terminal_close_incomplete")return f.debug({cwd:e,error:r},"orca: surfaces not retired"),"retired";throw r}},We=async e=>{let{terminals:r}=await M(e);for(let o of r)await p(["terminal","close","--terminal",o.handle]);let t=await Fe(e);return r.length===0&&t==="not_found"?{closed:!1,skipped:"not_found"}:{closed:!0,count:r.length}},De=(e,r)=>r instanceof g?{closed:!1,skipped:"absent"}:r instanceof d?{closed:!1,error:r}:r instanceof P?{closed:!1,error:new d({code:"orca_malformed_output",message:r.message,data:{exitCode:r.exitCode,stderrTail:r.stderrTail}})}:(f.debug({cwd:e,error:r},"orca: close failed outside the Orca contract"),{closed:!1,error:new d({code:"orca_close_failed",message:r instanceof Error?r.message:String(r)})}),Ue=async(e,r)=>{if(r!=="ready")return{closed:!1,skipped:r};try{return await We(e)}catch(t){return De(e,t)}};import{setTimeout as Je}from"node:timers/promises";var Ve=3,Be=300,ee=(e={})=>({attempts:e.attempts??Ve,delayMs:e.delayMs??Be,exhausted:!1}),He=async e=>{try{return{created:await p(e)}}catch(r){if(r instanceof d&&r.code==="selector_not_found")return{notSelectable:r};throw r}},Ke=async(e,r,t)=>{let o=t.exhausted?1:t.attempts,n=Array.from({length:o},(l,s)=>s+1),i;for(let l of n){let s=await He(e);if("created"in s)return s.created.terminal.handle;i=s.notSelectable,l<o&&await Je(t.delayMs)}throw t.exhausted=!0,new d({code:"orca_worktree_not_selectable",message:`orca: worktree ${r} is not selectable after ${o} attempt(s): ${i?.message??""}`,data:{cwd:r,attempts:o,cause:i?.data}})},Z=async(e,r)=>(await p(["terminal","split","--terminal",e,"--direction",r])).split.handle,je=async e=>{let{cwd:r,title:t,focus:o,layout:n,panes:i,poll:l=ee()}=e,s=["terminal","create","--worktree",`path:${r}`,"--title",t,...o?["--focus"]:[]],c=await Ke(s,r,l),m=[c];return n==="full"&&(m.push(await Z(c,"horizontal")),i==="three-pane"&&m.push(await Z(c,"vertical"))),{handles:m,layout:n}};var qe=e=>{let{branch:r}=e,t=$(r);return t?F(t):r};var Yr=e=>typeof e=="object",E=async e=>(await e.body?.cancel(),{kind:"foreign",status:e.status,contentType:e.headers.get("content-type")}),Qr=(e,r)=>{let t=r.contentType?.split(";")[0]?.trim(),o=t==null||t===""?`${r.status}`:`${r.status} ${t}`;return`port ${e} answered ${o}, not vite's ping \u2014 liveness cannot be verified`};var re={accept:"text/x-vite-ping"},ze=e=>e.kind==="api"?`http://127.0.0.1:${e.port}/__health`:`http://127.0.0.1:${e.port}/`,Xe=(e,r)=>{try{return new URL(e,r)}catch{return null}},Ye=async(e,r)=>{let t=await fetch(e,{signal:r});return t.ok?(await t.body?.cancel(),"ok"):E(t)},Qe=async(e,r)=>{let t=await fetch(e,{headers:re,redirect:"manual",signal:r});if(t.status===204)return"ok";if(t.status<300||t.status>=400)return E(t);let o=t.headers.get("location"),n=o==null?null:Xe(o,e);if(n==null||n.origin!==new URL(e).origin)return E(t);await t.body?.cancel();let i=await fetch(n,{headers:re,redirect:"manual",signal:r});return i.status!==204?E(i):(await i.body?.cancel(),"ok")},Zr=async e=>{let r=ze(e),t=AbortSignal.timeout(1500);try{return e.kind==="api"?await Ye(r,t):await Qe(r,t)}catch{return"refused"}};import{readRelease as Ze}from"@slip-stream-kit/config/internal";var er=e=>Ze(e);export{z as a,or as b,N as c,cr as d,d as e,p as f,ve as g,$e as h,M as i,Ue as j,Le as k,Ce as l,Ie as m,ee as n,je as o,qe as p,Yr as q,Qr as r,Zr as s,er as t,ur as u};
10
- //# sourceMappingURL=chunk-H7QCR3CG.js.map
10
+ //# sourceMappingURL=chunk-JZ7P52FQ.js.map
@@ -1,4 +1,4 @@
1
- import{a as N,e as ie,h as O,i as ae,j as u}from"./chunk-QVVWUZON.js";import{P as a,S as se,d as f,da as m,e as b,f as x,ga as g,h as S,i as ne,w as A}from"./chunk-5KUIGRG5.js";import{a as G,c as B,d as P,f as Y,g as Q,h as X,i as ee,j as te,o as re,p as L,q as oe}from"./chunk-I23MDR4X.js";import Ye from"@inquirer/select";import{readRepoIdentity as Qe}from"@slip-stream-kit/config/internal";import{Buffer as Xe}from"node:buffer";import et from"node:fs";import U from"node:path";import C from"node:process";import{z as d}from"zod";import{$ as K}from"zx";var be="Could not find requested project",xe="Could not find requested config",ce="Invalid Auth token",le="does not have access to requested config",D=e=>e.includes(ce)||e.includes(le)?"auth":e.includes(be)?"project":e.includes(xe)?"config":"unknown",R=e=>e.includes(le)?"mis-scoped":e.includes(ce)?"revoked":null;var pe=e=>[`Doppler rejected the service token for env "${e}" \u2014 it is invalid, revoked, or scoped to a different config.`,`Fix: run \`infra-kit env-token-set ${e}\` with a token scoped to that config.`,"CI / agents: set INFRA_KIT_ENV_TOKEN to a token scoped to that config."].join(`
1
+ import{a as N,e as ie,h as O,i as ae,j as u}from"./chunk-Q32KHZHK.js";import{P as a,S as se,d as f,e as b,ea as m,f as x,h as S,ha as g,i as ne,w as A}from"./chunk-MUYD4QA4.js";import{a as G,c as B,d as P,f as Y,g as Q,h as X,i as ee,j as te,o as re,p as L,q as oe}from"./chunk-I23MDR4X.js";import Ye from"@inquirer/select";import{readRepoIdentity as Qe}from"@slip-stream-kit/config/internal";import{Buffer as Xe}from"node:buffer";import et from"node:fs";import U from"node:path";import C from"node:process";import{z as d}from"zod";import{$ as K}from"zx";var be="Could not find requested project",xe="Could not find requested config",ce="Invalid Auth token",le="does not have access to requested config",D=e=>e.includes(ce)||e.includes(le)?"auth":e.includes(be)?"project":e.includes(xe)?"config":"unknown",R=e=>e.includes(le)?"mis-scoped":e.includes(ce)?"revoked":null;var pe=e=>[`Doppler rejected the service token for env "${e}" \u2014 it is invalid, revoked, or scoped to a different config.`,`Fix: run \`infra-kit env-token-set ${e}\` with a token scoped to that config.`,"CI / agents: set INFRA_KIT_ENV_TOKEN to a token scoped to that config."].join(`
2
2
  `),v=class extends O{authKind;constructor(t,r=null,o){super(o??pe(t),t),this.name="DopplerAuthError",this.authKind=r}};var M=({kind:e,project:t,config:r,available:o})=>{let n=e==="project"?[`Doppler project "${t}" not found (set in infra-kit.json \u2192 envManagement.config.name).`]:[`Doppler config "${r}" not found in project "${t}".`];if(o&&o.length>0){let s=e==="project"?"Available projects":`Available configs in "${t}"`;n.push(`${s}: ${o.join(", ")}.`)}return n.push(e==="project"?"Fix: update envManagement.config.name to an existing project, or create it in Doppler.":"Fix: pass an existing config, or create it in Doppler."),n.join(`
3
3
  `)};import{$ as j}from"zx";var Se=5e3,Ne="DOPPLER_CONFIG",h=async()=>{let{envManagement:e}=await m();return e.config.name},Oe=async({childEnv:e,project:t,config:r})=>{let o=j.quiet;j.quiet=!0;try{let s=(await j({env:e})`doppler secrets get ${Ne} --plain --project ${t} --config ${r}`.timeout(Se)).stdout.trim();return s!==r?{outcome:"mis-scoped",scopedTo:s}:{outcome:"valid",scopedTo:s}}catch(n){return{outcome:je(n)}}finally{j.quiet=o}},je=e=>{let t=S(e)??(e instanceof Error?e.message:String(e));return D(t)!=="auth"?"unreachable":R(t)??"unreachable"};import Fe from"node:process";var l="INFRA_KIT_ENV_TOKEN",V=async e=>{let t=Fe.env[l];if(t)return{token:t,source:"env"};let o=(await u())?.envs[e];if(o)return{token:o,source:"store"};throw new O(Ie(e,await ae()),e)},Ie=(e,t)=>[`No Doppler service token for env "${e}".`,`Mint one at https://dashboard.doppler.com \u2014 this project \u2192 config "${e}" \u2192 Access tab \u2192 "Generate Service Token".`,`Fix: run \`infra-kit env-token-set ${e}\` and paste it.`,`It is stored in ${se(t)} (mode 0600, never in the repo).`,`CI / agents: set ${l} instead \u2014 it takes precedence and needs no home config.`].join(`
4
4
  `);import ke from"node:process";import{z as Ee}from"zod";import We from"node:process";import{z as p}from"zod";var _=async()=>{try{return(await m()).defaultEnv??null}catch{return null}};var ue=["prod"],E={allowed:!1,reason:"disallow"},w=e=>ue.includes(e),$e=["dev","stage"],Ke=e=>$e.includes(e)||w(e),Ce=(e,t=E)=>t.allowed?e:e.filter(r=>!w(r)),Le=(e,t,r=E)=>{if(!r.allowed&&w(e))throw r.reason==="agent-blocked"?new g({status:"refused",env:e,agentMode:f.source},2,{operation:t,remediation:'a human runs it from their own terminal \u2014 this project sets `protectedEnvs: "cli-only"`',stderrExcerpt:`"${e}" is withheld from agents in this project (protectedEnvs: "cli-only")`}):new ne(void 0,{operation:t,remediation:`use \`infra-kit release deliver\` \u2014 it merges the release to main, opens the RC PR, deploys from main, and releases the Jira version. To allow ad-hoc deploys to "${e}" in this project, set \`protectedEnvs\` to "allow" or "cli-only" in infra-kit.json`,stderrExcerpt:`"${e}" is delivered, not deployed ad-hoc`})};var Me=async()=>{let e;try{e=(await m()).protectedEnvs??"disallow"}catch{return E}return e==="disallow"?E:e==="cli-only"&&b()?{allowed:!1,reason:"agent-blocked"}:{allowed:!0,reason:"allowed"}};var Ve=e=>{let{env:t,branch:r}=e;w(t)&&a.warn([`\u26A0\uFE0F "${t}" is a delivery target \u2014 this project allows dispatching to it directly, but this is NOT the delivery flow.`,`Dispatching from "${r}" ships ${t} from a ref that is not merged to main, and skips:`," \u2022 the squash-merge of the release branch into main"," \u2022 the RC pull request"," \u2022 the Jira fix-version release","Run `infra-kit release deliver` instead if you want those."].join(`
@@ -9,4 +9,4 @@ import{a as N,e as ie,h as O,i as ae,j as u}from"./chunk-QVVWUZON.js";import{P a
9
9
  `)}
10
10
  `,384),L(H,i,384),{filePath:H,variableCount:o.length,project:t,config:e}},De=J(),at=async e=>{let{config:t}=e,r=t?null:await _();if(!t&&r&&x())return Z(r,"default");if(await ye({provider:De,params:e,operation:"env-load",argument:"config"}),t)return Z(t,"argument");if(b())throw new g({status:"argument_required",argument:"config",agentMode:f.source},2,{operation:"env-load",remediation:'call env-list, ask the human which environment, and re-call env-load with "config"'});let o=await W();N.setInteractive();let n=await ie(s=>Ye({message:"Select environment config",choices:ct(o,r),...r?{default:r}:{}},s),{output:C.stderr,whenHeadless:"refuse"});return Z(n,"picker")},ct=(e,t)=>(t&&!e.includes(t)?[t,...e]:e).map(o=>({name:o===t?`${o} (default)`:o,value:o})),Z=async(e,t)=>{N.addOption("--config",e);let r=await it({config:e});N.print();let o={filePath:r.filePath,variableCount:r.variableCount,project:r.project,config:r.config,configSource:t,sessionId:C.env[P]??null};return{content:F(JSON.stringify(o,null,2)),structuredContent:o}},Ae=1024*1024,lt=3e4,pt=["DOPPLER_TOKEN","DOPPLER_PROJECT","DOPPLER_CONFIG"],ut=(e,t=C.env)=>{let r={...t};for(let o of pt)delete r[o];return r.DOPPLER_TOKEN=e,r},io=async e=>new Map(await Re(await h(),e)),Re=async(e,t)=>{let{token:r}=await V(t),o=ut(r),n=K.quiet;K.quiet=!0;try{let s;try{s=await K({env:o})`doppler secrets download --no-file --format json --project ${e} --config ${t}`.timeout(lt)}catch(c){throw ft(c,e,t)}mt(s.stdout);let i=vt(s.stdout);return dt(i,t),i}finally{K.quiet=n}},dt=(e,t)=>{let r=e.find(([o])=>o===tt)?.[1];if(!(r===void 0||r===t))throw new v(t,null,`Doppler returned secrets for config "${r}" but "${t}" was requested \u2014 the service token for env "${t}" is scoped to the wrong config. Refusing to load another environment's secrets.
11
11
  Fix: run \`infra-kit env-token-set ${t}\` with a token scoped to "${t}".`)},ft=(e,t,r)=>{let o=S(e)??(e instanceof Error?e.message:String(e)),n=D(o);return n==="auth"?new v(r,R(o)):n==="unknown"?e instanceof Error?e:new Error(String(e)):new Error(M({kind:n,project:t,config:r,available:null}))},mt=e=>{let t=Xe.byteLength(e,"utf-8");if(t>Ae)throw new Error(`doppler returned unexpectedly large output (${t} bytes > ${Ae}) \u2014 refusing to write to disk`)},T=e=>`'${e.replaceAll("'","'\\''")}'`,gt=/^[A-Z_]\w*$/i,vt=e=>{let t;try{t=JSON.parse(e)}catch{throw new Error(`doppler returned non-JSON output for env-load (got: ${JSON.stringify(e.slice(0,80))})`)}if(t===null||typeof t!="object"||Array.isArray(t))throw new Error("doppler returned unexpected JSON shape for env-load (expected an object of KEY: value pairs)");let r=[];for(let[o,n]of Object.entries(t)){if(!gt.test(o))throw new Error(`doppler returned an invalid env var name for env-load (got: ${JSON.stringify(o.slice(0,80))})`);if(typeof n!="string")throw new TypeError(`doppler returned a non-string value for "${o}" (got ${typeof n})`);r.push([o,n])}if(r.length===0)throw new Error("doppler returned empty output for env-load");return r},ao=I({name:"env-load",description:'Download the env vars for a Doppler config and write them to a temporary shell script. Does NOT mutate the calling process \u2014 returns the path to a script that must be sourced ("source <filePath>") for the vars to take effect. The infra-kit shell wrapper auto-sources; direct MCP callers must handle sourcing themselves or surface filePath to the user. This server picks the file up on its next tool call, so a tool that needs the variables can be called right after. Omit "config" and this server offers the human a form listing every environment env-list knows, token-less ones marked; a client that cannot render one gets a refusal naming the missing field \u2014 call env-list and ask the human, never guess. When the project config sets "defaultEnv", omitting "config" headless loads that environment instead of refusing, and "configSource" reports "default".',inputSchema:{config:d.string().optional().describe('Doppler config / environment name to load (e.g. "dev", "arthur"). Omit it to load the configured "defaultEnv", or, with none set, to have the human choose from a form.')},formProvider:De,outputSchema:{filePath:d.string().describe("Path to the file that must be sourced to apply variables"),variableCount:d.number().describe("Number of variables loaded"),project:d.string().describe("Doppler project name"),config:d.string().describe("Doppler config name"),configSource:d.enum(["argument","default","picker"]).describe('How the config was chosen: passed as "config", the configured "defaultEnv", or the terminal picker'),sessionId:d.string().nullable().describe("The INFRA_KIT_SESSION the file was written for; null when the process had no session")},handler:at});export{F as a,I as b,D as c,R as d,h as e,Oe as f,l as g,V as h,w as i,Ke as j,Ce as k,Le as l,Me as m,Ve as n,qe as o,y as p,W as q,he as r,Ze as s,ye as t,ot as u,st as v,it as w,at as x,ct as y,Ae as z,ut as A,io as B,dt as C,ft as D,mt as E,T as F,vt as G,ao as H};
12
- //# sourceMappingURL=chunk-TL3DOKIW.js.map
12
+ //# sourceMappingURL=chunk-L6NGDZWU.js.map
@@ -0,0 +1,15 @@
1
+ import{a as ie}from"./chunk-MFAFQVTW.js";import{a as ne}from"./chunk-53KLNCP2.js";import{e as T,q as N,s as _}from"./chunk-I23MDR4X.js";import ze from"node:process";import Ge from"node:process";var C={enabled:!1},Be=(e,t=r=>{Ge.stdout.write(r)})=>(C.enabled&&e&&e.structuredContent!=null&&t(`${JSON.stringify(e.structuredContent,null,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},w=()=>ae.source!==null,He=()=>w()||C.enabled,L=()=>!!ze.env.CI,Ve=({env:e,stdinIsTTY:t,flag:r})=>{if(r)return"flag";let o=e.INFRA_KIT_AGENT;return o==="1"||e.CLAUDECODE!==void 0&&!t&&o!=="0"?"env":null};var v=e=>{let t=new Set,r=e;for(;r!==null&&typeof r=="object"&&!t.has(r);){t.add(r);let{stderr:o,stderrExcerpt:n}=r;if(typeof o=="string"&&o.length>0)return o;if(typeof n=="string"&&n.length>0)return n;r=r.cause}},Ue=(e,t)=>{let r=t.stderrExcerpt??v(e),o=[`failed to ${t.operation}`];return r&&o.push(`stderr: ${r.slice(0,200).trim()}`),t.remediation&&o.push(`try: ${t.remediation}`),o.join(" \u2014 ")},u=class extends Error{operation;remediation;stderrExcerpt;constructor(t,r){super(Ue(t,r),{cause:t}),this.name="OperationError",this.operation=r.operation,this.remediation=r.remediation,this.stderrExcerpt=r.stderrExcerpt??v(t)}};import k from"node:path";import le from"node:process";import{$ as m}from"zx";var Je=/^v?(\d+)\.(\d+)\.(\d+)$/,Xe=/^(\d+)\.(\d+)\.(\d+)$/,Ye=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,S="release/",K="release/v",ce="refs/heads/",Ze="next";var ue=new Set(["dev","main","next","hotfix","regular","release"]),h=class extends Error{constructor(t){super(t),this.name="InvalidReleaseNameError"}},y=class extends Error{constructor(t){super(t),this.name="InvalidReleaseRefError"}},de=e=>e.startsWith(ce)?e.slice(ce.length):e,pe=(e,t,r)=>({kind:"version",semver:{major:e,minor:t,patch:r},raw:`${e}.${t}.${r}`}),W=e=>{if(e.length===0)throw new h('Release name is empty. Provide a kebab-case name like "checkout-redesign".');if(e.length>50)throw new h(`Release name "${e}" is ${e.length} characters; the maximum is 50.`);if(!Ye.test(e))throw new h(`Release name "${e}" is not kebab-case. Use lowercase letters, digits, and single hyphens, e.g. "checkout-redesign".`);if(ue.has(e))throw new h(`Release name "${e}" is reserved. Reserved names: ${[...ue].join(", ")}.`)},D=e=>{let t=de(e.trim());if(!t.startsWith(S))return null;if(t.startsWith(K)){let o=t.slice(K.length),n=Xe.exec(o);if(n)return pe(Number(n[1]),Number(n[2]),Number(n[3]))}let r=t.slice(S.length);try{W(r)}catch{return null}return{kind:"name",name:r,raw:r}},Qe=e=>{let t=e.trim();if(de(t).startsWith(S)){let n=D(t);if(!n)throw new y(`"${e}" looks like a release branch but is not a valid release/v<semver> or release/<name> ref.`);return n}let o=Je.exec(t);if(o)return pe(Number(o[1]),Number(o[2]),Number(o[3]));if(t.toLowerCase()===Ze)throw new y('The "next" token must be resolved to a concrete version (via computeNextVersion) before parsing a release ref.');if(t.includes("@"))throw new y(`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{W(t)}catch(n){let s=n instanceof Error?n.message:String(n);throw new y(`Cannot parse "${e}" as a release ref: ${s}`)}return{kind:"name",name:t,raw:t}},et=e=>e.kind==="version"?`${K}${e.raw}`:`${S}${e.name}`,tt=(e,t)=>{let r=t==="hotfix"?"Hotfix":"Release";return e.kind==="version"?`${r} v${e.raw}`:`${r} ${e.name}`},rt=e=>e.kind==="version"?`Release v${e.raw} (RC)`:`Release ${e.name} (RC)`,ot=e=>e.kind==="version"?`v${e.raw}`:e.name,nt=e=>e.raw,F=e=>e==null?!1:D(e)!==null,me=e=>{if(e===void 0)return null;let t=e instanceof Date?e.getTime():new Date(e).getTime();return Number.isNaN(t)?null:t},it=(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 o=me(r?.a),n=me(r?.b);return o!==null&&n!==null&&o!==n?o-n:e.name<t.name?-1:e.name>t.name?1:0};var ge=async e=>{let t=await m({cwd:e})`git worktree list --porcelain`,r=[],o=null;for(let n of t.stdout.split(`
3
+ `)){if(n.startsWith("worktree ")){o&&r.push(o),o={path:n.slice(9),branch:null,detached:!1,bare:!1,prunable:!1,locked:!1};continue}o&&(n.startsWith("branch ")?o.branch=n.slice(7).replace(/^refs\/heads\//,""):n==="detached"?o.detached=!0:n==="bare"?o.bare=!0:n==="locked"||n.startsWith("locked ")?o.locked=!0:(n==="prunable"||n.startsWith("prunable "))&&(o.prunable=!0))}return o&&r.push(o),r},st=async e=>{let t=await ge(le.cwd()),r=o=>e==="release"?F(o):o.startsWith("feature/");return t.map(o=>o.branch).filter(o=>o!==null&&r(o))},at=e=>{let t=v(e);return t&&/not a git repository/i.test(t)?"not a git repository":void 0},ct=({hasStderr:e})=>{if(w())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},R=async()=>{try{return(await m({quiet:!0})`git rev-parse --show-toplevel`).stdout.trim()}catch(e){let t=at(e)??v(e);throw new u(e,{operation:`resolve the project root from ${le.cwd()}`,stderrExcerpt:t,remediation:ct({hasStderr:t!==void 0})})}},q=async e=>{let t=e??await R(),r=(await m({cwd:t,quiet:!0})`git rev-parse --git-common-dir`).stdout.trim(),o=k.resolve(t,r);return o.includes(`${k.sep}.git${k.sep}modules${k.sep}`)?t:k.dirname(o)},fe=async()=>(await m`git rev-parse --abbrev-ref HEAD`).stdout.trim(),he=async()=>(await m`git status --porcelain`).stdout.split(`
4
+ `).map(t=>t.trimEnd()).filter(t=>t.trim().length>0),ut=async()=>(await he()).length===0,mt=async()=>{let e=await R(),[t,r]=await Promise.all([m({cwd:e})`git rev-parse --absolute-git-dir`,m({cwd:e})`git rev-parse --git-common-dir`]),o=t.stdout.trim(),n=k.resolve(e,r.stdout.trim());return o!==n};var dt=async e=>(await m`git branch --list ${e}`).stdout.trim().length>0,pt=async e=>{(await m`git branch --list ${e}`).stdout.trim().length!==0&&await fe()!==e&&await m`git branch -D ${e}`},lt=async e=>{(await m`git ls-remote --heads origin ${e}`).stdout.trim().length!==0&&await m`git push origin --delete ${e}`};import{$ as P}from"zx";var gt=async(e,t)=>{let r=`${t}^{commit}`;try{return(await P({cwd:e,quiet:!0})`git rev-parse --verify --quiet ${r}`).stdout.trim()||null}catch{return null}},ft=async(e,t,r)=>{try{return await P({cwd:e,quiet:!0})`git merge-base --is-ancestor ${t} ${r}`,!0}catch(o){if(o.exitCode===1)return!1;throw new u(o,{operation:`test whether ${t} is contained in ${r}`,remediation:"both refs must exist \u2014 verify them with rev-parse first"})}},ht=async(e,t)=>{let o=(await P({cwd:e,quiet:!0})`git ls-remote --heads origin ${t}`).stdout.trim().split(`
5
+ `)[0];return o?o.split(/\s+/)[0]??null:null},yt=async(e,t)=>{let r=t.map(o=>`${o.sha}:refs/heads/${o.branch}`);if(r.length===0)return{refspecs:r,pushed:!1};try{return await P({cwd:e,quiet:!0})`git push --atomic origin ${r}`,{refspecs:r,pushed:!0}}catch(o){return{refspecs:r,pushed:!1,stderr:o.stderr}}};import j from"node:path";import G from"node:process";import{$ as p}from"zx";var ye=async e=>{let t=e??G.cwd(),r=(await p({cwd:t,quiet:!0})`git rev-parse --git-common-dir`).stdout.trim(),o=j.dirname(j.resolve(t,r)),n=G.env.INFRA_KIT_SESSION||String(G.pid);return j.join(`${o}${N}`,_.mergeDev,`.scratch-${n}`)},we=e=>e.replace(/[^\w-]+/g,"-"),wt=(e,t)=>j.join(`${e}${N}`,_.mergeDev,we(t)),B=async e=>{try{return await p({cwd:e,quiet:!0})`git rev-parse -q --verify MERGE_HEAD`,!0}catch{return!1}},kt=async e=>{if(await B(e))throw new u(void 0,{operation:"reuse the scratch worktree",stderrExcerpt:"a merge is still in progress in the scratch worktree",remediation:"this is an infra-kit bug \u2014 the previous branch iteration did not clean up"});let t=(await p({cwd:e,quiet:!0})`git status --porcelain`).stdout.trim();if(t.length>0)throw new u(void 0,{operation:"reuse the scratch worktree",stderrExcerpt:`scratch worktree is dirty: ${t.split(`
6
+ `)[0]}`,remediation:"this is an infra-kit bug \u2014 the previous branch iteration did not clean up"})},vt=async e=>{let t=async r=>{try{await r()}catch{}};await B(e)&&await t(()=>p({cwd:e,quiet:!0})`git merge --abort`),await t(()=>p({cwd:e,quiet:!0})`git reset --hard`),await t(()=>p({cwd:e,quiet:!0})`git clean -fdx -e node_modules`)},Rt=async(e,t)=>{let{cwd:r,anchor:o="origin/dev"}=e,n=await ye(r),s=async()=>{await p({cwd:r,quiet:!0})`git worktree add --detach ${n} ${o}`};try{await s()}catch(c){try{await p({cwd:r,quiet:!0})`git worktree prune`,await s()}catch{throw new u(c,{operation:"create the scratch worktree for the merge",remediation:`remove any stale checkout at ${n}, then retry`})}}let d={path:n,remove:async()=>{try{await p({cwd:r,quiet:!0})`git worktree remove --force ${n}`}catch{}}};try{return await t(d)}finally{await d.remove()}};import xt from"node:process";import bt from"pino";import Et from"pino-pretty";var Mt=["token","*.token","serviceToken","*.serviceToken","DOPPLER_TOKEN","*.DOPPLER_TOKEN","INFRA_KIT_ENV_TOKEN","*.INFRA_KIT_ENV_TOKEN"],Ct=()=>{let e=xt.argv.includes("--debug")?"debug":"info",t=["time","pid","hostname"];return e==="debug"&&t.push("level"),bt({level:e,redact:Mt},Et({destination:2,ignore:t.join(","),colorize:!0,sync:!0}))},z=Ct();var ke=class extends u{structuredContent;exitCode;constructor(t,r,o){super(void 0,o),this.name="StructuredRefusalError",this.structuredContent=t,this.exitCode=r}};import St from"node:fs/promises";import Pt from"node:os";var jt=async e=>{try{return await St.access(e),!0}catch{return!1}},H=e=>{let t=Pt.homedir();return e.startsWith(t)?`~${e.slice(t.length)}`:e};import te from"node:fs/promises";import Ae from"node:os";import E from"node:path";import Lt from"node:process";import{z as i}from"zod";var V=e=>{throw new Error(`Unexpected value: ${JSON.stringify(e)}`)};var ve=(e,t)=>Object.fromEntries(Object.entries(e).filter(([r])=>r!==t));var a=({key:e,id:t,note:r})=>({id:t,note:r,apply:o=>e in o?{changed:!0,result:ve(o,e)}:{changed:!1,result:o}});var Re=a({key:"dev",id:"drop-dev-key",note:'the unused "dev" key (a dev server port comes from <APP>_PORT / PORT, else the built-in default)'});var xe=a({key:"devServersPresets",id:"drop-dev-presets-key",note:'the unused "devServersPresets" key (run `infra-kit dev <app>` instead of a preset name)'});var be=a({key:"devProxy",id:"drop-dev-proxy-key",note:'the retired "devProxy" key (dev URLs are port-free https://<release>.<package>.localhost)'});var Ee=a({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 Me=a({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 Ce=a({key:"ide",id:"drop-ide-key",note:'the unused "ide" key (worktrees add/remove no longer edit a Cursor .code-workspace)'});var Se=a({key:"taskManager",id:"drop-task-manager-key",note:'the unused "taskManager" key (Jira is configured by the JIRA_BASE_URL / JIRA_PROJECT_ID env vars in Doppler)'});var U=[Ce,Me,be,Ee,Se,xe,Re];var x=e=>U.reduce((t,r)=>{let o=r.apply(t.result);return o.changed?{changed:!0,result:o.result,notes:[...t.notes,r.note]}:t},{changed:!1,result:e,notes:[]});var Pe={withheld:!1},J=()=>Pe.withheld||L();import{randomBytes as It}from"node:crypto";import g from"node:fs/promises";import X from"node:path";import $t from"node:process";var I=class extends Error{constructor(t){super(`${t} changed on disk since it was read`),this.name="ConfigFileChangedError"}},At=2,Ot=e=>/^([ \t]+)\S/m.exec(e)?.[1]??At,Tt=4095,$=async({path:e,raw:t,migrated:r,expectedMtimeMs:o})=>{let n=await g.realpath(e),s=X.dirname(n),d=X.basename(n),c=X.join(s,`.${d}.${$t.pid}.${It(4).toString("hex")}.tmp`),A=`${JSON.stringify(r,null,Ot(t))}
7
+ `;try{await g.writeFile(c,A,"utf8");let l=await g.stat(n);if(l.mtimeMs!==o)throw new I(e);await g.chmod(c,l.mode&Tt),await g.rename(c,n)}catch(l){throw await g.rm(c,{force:!0}),l}},Nt=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),_t=async e=>{let t=await g.stat(e),r=await g.readFile(e,"utf8");if(r.trim()==="")return{changed:!1,result:{},notes:[],path:e};let o=JSON.parse(r);if(!Nt(o))return{changed:!1,result:{},notes:[],path:e};let n=x(o);return n.changed&&await $({path:e,raw:r,migrated:n.result,expectedMtimeMs:t.mtimeMs}),{...n,path:e}};var Y=async(e,t,r,{schema:o})=>{if(e.autoMigrate==="off")return{kind:"not-applicable"};let n=x(t);if(!n.changed)return{kind:"not-applicable"};let s=o.safeParse(n.result);if(!s.success)return{kind:"not-applicable"};if(e.required&&J())return{kind:"ci-gated"};try{await $({path:e.path,raw:r,migrated:n.result,expectedMtimeMs:e.mtimeMs})}catch(d){return z.debug(d,`auto-migration could not rewrite ${e.path}`),{kind:"not-applicable"}}return z.warn(`Migrated ${H(e.path)}: removed ${n.notes.join(" and ")} (retired by infra-kit ${ne.version})`),{kind:"migrated",data:s.data}};var je="infra-kit.json";var Kt="infra-kit.json",Wt="projects",Dt=i.object({provider:i.literal("doppler"),config:i.object({name:i.string().min(1)})}),Ft=i.discriminatedUnion("provider",[Dt]),qt=["two-columns","three-pane"],Gt=i.object({layout:i.enum(qt).optional()}).strict(),Bt=i.object({openInGithubDesktop:i.boolean().optional(),openInOrca:i.boolean().optional(),orca:Gt.optional()}).strict(),zt=i.enum(["disallow","allow","cli-only"]),Ie=i.string().regex(/^[A-Z_]\w*$/i,"must be a POSIX environment-variable name"),Ht=i.object({command:i.string().min(1),args:i.array(i.string()).default([]),env:i.array(Ie).min(1),unset:i.array(Ie).default([])}).strict().superRefine((e,t)=>{for(let r of e.env)ie.has(r)&&t.addIssue({code:"custom",path:["env"],message:`"${r}" is process plumbing the proxy never strips or injects \u2014 it cannot be a credential name`})}),Vt=i.record(i.string().regex(/^[a-z][a-z0-9-]*$/,"must be lowercase letters, digits and hyphens, starting with a letter").refine(e=>!e.includes("infra-kit"),{message:'"infra-kit" is reserved: it is the .mcp.json key of the retired infra-kit MCP server \u2014 pick another name'}),Ht),$e=i.string().min(1).superRefine((e,t)=>{if(e.startsWith("/")||e.startsWith("\\")||/^[a-z]:/i.test(e)){t.addIssue({code:"custom",message:`"${e}" must be relative to the repository root`});return}let r=e.split(/[/\\]/).filter(n=>n!==""&&n!==".");r.includes("..")&&t.addIssue({code:"custom",message:`"${e}" must not contain a ".." segment`}),r[0]===".git"&&t.addIssue({code:"custom",message:`"${e}" must not be .git or a path inside it`}),e.includes("\\")&&t.addIssue({code:"custom",message:`"${e}" must use "/" as the separator, not "\\"`});let o=e.split("/");o.includes("")&&t.addIssue({code:"custom",message:`"${e}" must not have a trailing or doubled "/"`}),o.includes(".")&&t.addIssue({code:"custom",message:`"${e}" must not contain a "." segment; write it from the repository root, e.g. "vendor/configs"`})}),Oe=i.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/,'must be kebab-case: a-z, 0-9 and inner "-"'),Ut=i.object({path:$e,target:$e.optional(),module:Oe.optional()}).strict(),Te=i.object({copy:i.array(Ut).min(1),exclude:i.array(i.string().regex(/^[^/\\]+$/,'must be a single path segment, without "/"')).optional()}).strict(),Ne=i.object({modules:i.array(Oe)}).strict(),Jt=i.object({requiredScripts:i.array(i.string().min(1)).optional(),requiredFiles:i.array(i.string().min(1)).optional(),turbo:i.object({requiredTasks:i.array(i.string().min(1)).optional()}).strict().optional()}).strict(),Xt=i.string().regex(/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/,'must be a DNS label: a-z, 0-9 and inner "-", at most 63 characters'),Yt=i.string().min(1),re=i.object({envManagement:Ft,defaultEnv:Yt.optional(),worktrees:Bt.optional(),protectedEnvs:zt.optional(),mcp:Vt.optional(),vendorSource:Te.nullable().optional(),vendorTarget:Ne.optional(),audit:Jt.optional(),aliasRepo:Xt.optional()}).strict(),Zt=443,_e=re,ee=re.partial(),Le="two-columns",Qt=e=>e.worktrees?.orca?.layout??Le,f=null,b=null,Ke=()=>`${Lt.cwd()} ${Ae.homedir()}`,We=()=>E.join(Ae.homedir(),T),De=()=>E.join(We(),Kt),Fe=async()=>{let e=Ke();if(b&&b.key===e)return b.value;let t=await R(),r=await q(t),o=E.basename(r),n={main:E.join(t,je),userGlobal:De(),userProject:E.join(We(),Wt,o,je),projectName:o};return b={key:e,value:n},n},er=async(e={})=>{let t=e.autoMigrate??"write",r=Ke(),o=await Fe(),n;try{n=await te.stat(o.main)}catch{f=null;let O=o.main.replace(/\.json$/,".yml");throw await Z(O)?new Error(`infra-kit.json not found at ${o.main}. A legacy infra-kit.yml exists \u2014 run \`infra-kit setup --skip-tools\` to convert it.`):new Error(w()?`infra-kit.json not found at ${o.main} \u2014 the working directory is not an infra-kit project. Run infra-kit from inside an infra-kit project repo, or pass \`-C <dir>\` naming one.`:`infra-kit.json not found at ${o.main} \u2014 this git repo is not an infra-kit project. Run \`infra-kit setup --skip-tools\` here to create it, cd into an infra-kit project repo, or check out a branch that has infra-kit.json.`)}let[s,d]=await Promise.all([Z(o.userGlobal),Z(o.userProject)]),c={main:Number(n.mtimeMs),userGlobal:s?Number(s.mtimeMs):null,userProject:d?Number(d.mtimeMs):null};if(f&&f.key===r&&nr(f.mtimes,c))return f.value;let A=[{label:"infra-kit.json",path:o.main,required:!0,autoMigrate:t,mtimeMs:c.main},{label:"~/.infra-kit/infra-kit.json",path:o.userGlobal,required:!1,autoMigrate:t,mtimeMs:c.userGlobal},{label:`~/.infra-kit/projects/${o.projectName}/infra-kit.json`,path:o.userProject,required:!1,autoMigrate:t,mtimeMs:c.userProject}],l={};for(let O of A){let oe=await ir(O);oe!==null&&(l={...l,...oe})}let M=_e.safeParse(l);if(!M.success)throw new Error(`Invalid merged infra-kit config: ${i.prettifyError(M.error)}`);return f={key:r,mtimes:c,value:M.data},M.data},tr=()=>{f=null},rr=()=>{f=null,b=null},Z=async e=>{try{return await te.stat(e)}catch{return null}},or=async e=>{try{return await te.readFile(e,"utf-8")}catch{return null}},nr=(e,t)=>{let r=Object.keys(e);return r.length!==Object.keys(t).length?!1:r.every(o=>e[o]===t[o])},qe=e=>new Error(`${e.message}
8
+ A retired key on this branch \u2014 run \`infra-kit setup --skip-tools\` in this checkout and commit infra-kit.json.`),ir=async e=>{let t=await or(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(d){throw new Error(`Invalid JSON in ${e.label} at ${e.path}: ${d.message}`)}if(Q(r)&&"envTokens"in r)throw new Error(lr(e));!e.required&&Q(r)&&pr(e,r);let o=ee.safeParse(r);if(o.success)return o.data;let n=new Error(`Invalid ${e.label} at ${e.path}: ${i.prettifyError(o.error)}`);if(!Q(r)||e.mtimeMs===null)throw n;let s=await Y({...e,mtimeMs:e.mtimeMs},r,t,{schema:ee});switch(s.kind){case"migrated":return s.data;case"ci-gated":throw qe(n);case"not-applicable":throw n;default:return V(s)}},sr=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
+ `),ar=e=>[`"vendorSource" is not allowed in ${e.label} (${e.path}): only the committed project file may mark a repository as the \`vendor sync\` source. In the machine-wide file it would make every repository on this machine a source; in a per-project override it would make this machine disagree with every other clone.`,"Move the block to the source repository's own infra-kit.json and commit it there."].join(`
10
+ `),cr=e=>[`"vendorTarget" is not allowed in ${e.label} (${e.path}): \`vendor sync\` reads it from the target repository's committed infra-kit.json only, so a per-machine copy would never be seen and would only make this clone disagree with the others.`,"Move the block to the target repository's own infra-kit.json and commit it there."].join(`
11
+ `),ur=e=>[`"audit" is not allowed in ${e.label} (${e.path}): the root audit gates CI, so a per-machine copy would make this machine pass or fail a different check list than CI.`,"Move the block to the project infra-kit.json and commit it there."].join(`
12
+ `),mr=e=>[`"aliasRepo" is not allowed in ${e.label} (${e.path}): the vite and Playwright helpers read it from the project infra-kit.json only, so a per-machine copy would register a dev host they never aim at.`,"Move it to the project infra-kit.json and commit it there."].join(`
13
+ `),dr={aliasRepo:mr,mcp:sr,vendorSource:ar,vendorTarget:cr,audit:ur},pr=(e,t)=>{for(let[r,o]of Object.entries(dr))if(r in t)throw new Error(o(e))},Q=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),lr=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(`
14
+ `);export{C as a,Be as b,se as c,ae as d,w as e,He as f,Ve as g,v as h,u as i,h as j,W as k,D as l,Qe as m,et as n,tt as o,rt as p,ot as q,nt as r,F as s,it as t,ge as u,st as v,R as w,q as x,fe as y,he as z,ut as A,mt as B,dt as C,pt as D,lt as E,gt as F,ft as G,ht as H,yt as I,we as J,wt as K,B as L,kt as M,vt as N,Rt as O,z as P,V as Q,jt as R,H as S,Pe as T,I as U,$ as V,_t as W,Te as X,Ne as Y,re as Z,Zt as _,_e as $,ee as aa,Qt as ba,De as ca,Fe as da,er as ea,tr as fa,rr as ga,ke as ha};
15
+ //# sourceMappingURL=chunk-MUYD4QA4.js.map