infra-kit 0.44.0 → 0.45.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,5 +1,5 @@
1
- import{k as m,ka as E}from"./chunk-DVMV3WJZ.js";import{p as w}from"./chunk-RVMKL6T4.js";import i from"node:fs/promises";import o from"node:path";import{z as a}from"zod";var c=class extends Error{env;constructor(e,r=null){super(e),this.name="EnvAuthError",this.env=r}};var x="tokens.json",d=1,k=384,u=448,y=a.object({version:a.literal(d).default(d),envs:a.record(a.string().min(1),a.string().min(1))}).strict(),l=async()=>{let t=await E();return o.join(o.dirname(t.userProject),x)},h=async()=>{let t=await l(),e;try{e=await i.readFile(t,"utf-8")}catch{return null}let r;try{r=JSON.parse(e)}catch(s){throw new c(`Invalid JSON in the token store at ${m(t)}: ${s.message}
1
+ import{k as m,ka as E}from"./chunk-DIGPYEFM.js";import{p as w}from"./chunk-RVMKL6T4.js";import i from"node:fs/promises";import o from"node:path";import{z as a}from"zod";var c=class extends Error{env;constructor(e,r=null){super(e),this.name="EnvAuthError",this.env=r}};var x="tokens.json",d=1,k=384,u=448,y=a.object({version:a.literal(d).default(d),envs:a.record(a.string().min(1),a.string().min(1))}).strict(),l=async()=>{let t=await E();return o.join(o.dirname(t.userProject),x)},h=async()=>{let t=await l(),e;try{e=await i.readFile(t,"utf-8")}catch{return null}let r;try{r=JSON.parse(e)}catch(s){throw new c(`Invalid JSON in the token store at ${m(t)}: ${s.message}
2
2
  Fix or delete the file, then re-add the token with \`infra-kit env-token-set <env>\`.`)}let n=y.safeParse(r);if(!n.success)throw new c(`Invalid token store at ${m(t)}: ${a.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},v=async t=>{let e=await l(),r=o.dirname(e),n=o.dirname(r),s=o.dirname(n);for(let f of[s,n,r])await i.mkdir(f,{recursive:!0,mode:u}),await i.chmod(f,u);w(e,`${JSON.stringify(t,null,2)}
4
4
  `,k),await i.chmod(e,k)},P=async()=>{let t=await l().catch(()=>null);if(t===null)return null;let e=o.dirname(t),r=o.dirname(e),s=[[o.dirname(r),u],[r,u],[e,u],[t,k]];if(!await i.stat(t).then(()=>!0,()=>!1))return null;let g=[];for(let[p,S]of s){let T=(await i.stat(p)).mode&511;T!==S&&(await i.chmod(p,S),g.push(`${m(p)} was 0${T.toString(8)}`))}return g};var j=async t=>{let e=await h();await v({version:d,envs:{...e?.envs,...t}})},O=async t=>{let e=await h();if(!e||!(t in e.envs))return;let r={...e.envs};delete r[t],await v({version:d,envs:r})};var D=(t,e,r)=>t.map(({env:n,source:s})=>({env:n,source:s,hasToken:!!(r||e[n])}));export{c as a,D as b,l as c,h as d,P as e,j as f,O as g};
5
- //# sourceMappingURL=chunk-NJ22P2UB.js.map
5
+ //# sourceMappingURL=chunk-BRAJBMCQ.js.map
@@ -1,2 +1,2 @@
1
- var i={name:"infra-kit",type:"module",version:"0.44.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","generate-config-schema":"pnpm exec vitest run src/lib/infra-kit-config/__tests__/json-schema.test.ts --update=all","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:{"@inquirer/checkbox":"^5.2.8","@inquirer/confirm":"^6.3.5","@inquirer/input":"^5.1.9","@inquirer/password":"^5.2.5","@inquirer/select":"^5.2.8","@slip-stream-kit/config":"workspace:^",chalk:"^6.0.1",chokidar:"^6.0.0",commander:"^15.0.0",fastify:"^5.12.7",ink:"^8.0.0",pino:"^10.4.0","pino-pretty":"^13.2.0",portless:"^0.15.12",react:"19.3.1",yaml:"^2.9.1",zod:"^4.6.7",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-D7C4NYQA.js.map
1
+ var i={name:"infra-kit",type:"module",version:"0.45.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","generate-config-schema":"pnpm exec vitest run src/lib/infra-kit-config/__tests__/json-schema.test.ts --update=all","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:{"@inquirer/checkbox":"^5.2.8","@inquirer/confirm":"^6.3.5","@inquirer/input":"^5.1.9","@inquirer/password":"^5.2.5","@inquirer/select":"^5.2.8","@slip-stream-kit/config":"workspace:^",chalk:"^6.0.1",chokidar:"^6.0.0",commander:"^15.0.0",fastify:"^5.12.7",ink:"^8.0.0",pino:"^10.4.0","pino-pretty":"^13.2.0",portless:"^0.15.12",react:"19.3.1",yaml:"^2.9.1",zod:"^4.6.7",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-CHFSRDQE.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.44.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 \"generate-config-schema\": \"pnpm exec vitest run src/lib/infra-kit-config/__tests__/json-schema.test.ts --update=all\",\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 \"@inquirer/checkbox\": \"^5.2.8\",\n \"@inquirer/confirm\": \"^6.3.5\",\n \"@inquirer/input\": \"^5.1.9\",\n \"@inquirer/password\": \"^5.2.5\",\n \"@inquirer/select\": \"^5.2.8\",\n \"@slip-stream-kit/config\": \"workspace:^\",\n \"chalk\": \"^6.0.1\",\n \"chokidar\": \"^6.0.0\",\n \"commander\": \"^15.0.0\",\n \"fastify\": \"^5.12.7\",\n \"ink\": \"^8.0.0\",\n \"pino\": \"^10.4.0\",\n \"pino-pretty\": \"^13.2.0\",\n \"portless\": \"^0.15.12\",\n \"react\": \"19.3.1\",\n \"yaml\": \"^2.9.1\",\n \"zod\": \"^4.6.7\",\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.45.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 \"generate-config-schema\": \"pnpm exec vitest run src/lib/infra-kit-config/__tests__/json-schema.test.ts --update=all\",\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 \"@inquirer/checkbox\": \"^5.2.8\",\n \"@inquirer/confirm\": \"^6.3.5\",\n \"@inquirer/input\": \"^5.1.9\",\n \"@inquirer/password\": \"^5.2.5\",\n \"@inquirer/select\": \"^5.2.8\",\n \"@slip-stream-kit/config\": \"workspace:^\",\n \"chalk\": \"^6.0.1\",\n \"chokidar\": \"^6.0.0\",\n \"commander\": \"^15.0.0\",\n \"fastify\": \"^5.12.7\",\n \"ink\": \"^8.0.0\",\n \"pino\": \"^10.4.0\",\n \"pino-pretty\": \"^13.2.0\",\n \"portless\": \"^0.15.12\",\n \"react\": \"19.3.1\",\n \"yaml\": \"^2.9.1\",\n \"zod\": \"^4.6.7\",\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,yBAA0B,2FAC1B,SAAU,qMACV,GAAM,gHACN,IAAO,6DACT,EACA,aAAgB,CACd,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,WACZ,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{a as ke}from"./chunk-MFAFQVTW.js";import{a as ye}from"./chunk-D7C4NYQA.js";import{e as G,q,s as J}from"./chunk-RVMKL6T4.js";import mt from"node:process";import pt from"pino";import dt from"pino-pretty";var gt=["token","*.token","serviceToken","*.serviceToken","DOPPLER_TOKEN","*.DOPPLER_TOKEN","INFRA_KIT_ENV_TOKEN","*.INFRA_KIT_ENV_TOKEN"],ft=()=>{let e=mt.argv.includes("--debug")?"debug":"info",t=["time","pid","hostname"];return e==="debug"&&t.push("level"),pt({level:e,redact:gt},dt({destination:2,ignore:t.join(","),colorize:!0,sync:!0}))},B=ft();var E=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}},ht=(e,t)=>{let r=t.stderrExcerpt??E(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 ")},d=class extends Error{operation;remediation;stderrExcerpt;constructor(t,r){super(ht(t,r),{cause:t}),this.name="OperationError",this.operation=r.operation,this.remediation=r.remediation,this.stderrExcerpt=r.stderrExcerpt??E(t)}};import yt from"node:process";import{z as ve}from"zod";var H=1,kt={schemaVersion:ve.literal(H),command:ve.string().describe("The grouped command path that ran, e.g. `release create`")},M={enabled:!1,command:""},vt=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),we=e=>vt(e)?{schemaVersion:H,command:M.command,...e}:e,wt=(e,t=r=>{yt.stdout.write(r)})=>(M.enabled&&e&&e.structuredContent!=null&&t(`${JSON.stringify(we(e.structuredContent),null,2)}
1
+ import{a as ke}from"./chunk-MFAFQVTW.js";import{a as ye}from"./chunk-CHFSRDQE.js";import{e as G,q,s as J}from"./chunk-RVMKL6T4.js";import mt from"node:process";import pt from"pino";import dt from"pino-pretty";var gt=["token","*.token","serviceToken","*.serviceToken","DOPPLER_TOKEN","*.DOPPLER_TOKEN","INFRA_KIT_ENV_TOKEN","*.INFRA_KIT_ENV_TOKEN"],ft=()=>{let e=mt.argv.includes("--debug")?"debug":"info",t=["time","pid","hostname"];return e==="debug"&&t.push("level"),pt({level:e,redact:gt},dt({destination:2,ignore:t.join(","),colorize:!0,sync:!0}))},B=ft();var E=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}},ht=(e,t)=>{let r=t.stderrExcerpt??E(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 ")},d=class extends Error{operation;remediation;stderrExcerpt;constructor(t,r){super(ht(t,r),{cause:t}),this.name="OperationError",this.operation=r.operation,this.remediation=r.remediation,this.stderrExcerpt=r.stderrExcerpt??E(t)}};import yt from"node:process";import{z as ve}from"zod";var H=1,kt={schemaVersion:ve.literal(H),command:ve.string().describe("The grouped command path that ran, e.g. `release create`")},M={enabled:!1,command:""},vt=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),we=e=>vt(e)?{schemaVersion:H,command:M.command,...e}:e,wt=(e,t=r=>{yt.stdout.write(r)})=>(M.enabled&&e&&e.structuredContent!=null&&t(`${JSON.stringify(we(e.structuredContent),null,2)}
2
2
  `),e),be=e=>{e.options.some(r=>r.long==="--json")||e.option("--json","Output the structured result as JSON on stdout (human logs stay on stderr)");for(let r of e.commands)be(r)};import bt from"node:process";var O={source:null},b=()=>O.source!==null,xt=()=>b()||M.enabled,z=()=>!!bt.env.CI,Rt=({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};import Et from"node:fs/promises";import Mt from"node:os";var St=async e=>{try{return await Et.access(e),!0}catch{return!1}},U=e=>{let t=Mt.homedir();return e.startsWith(t)?`~${e.slice(t.length)}`:e};var P=class extends d{structuredContent;exitCode;constructor(t,r,n){super(void 0,n),this.name="StructuredRefusalError",this.structuredContent=t,this.exitCode=r}};import x from"node:path";import Ce from"node:process";import{$ as g}from"zx";var Ct=/^v?(\d+)\.(\d+)\.(\d+)$/,$t=/^(\d+)\.(\d+)\.(\d+)$/,jt=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,T="release/",X="release/v",xe="refs/heads/",It="next";var Re=new Set(["dev","main","next","hotfix","regular","release"]),k=class extends Error{constructor(t){super(t),this.name="InvalidReleaseNameError"}},v=class extends Error{constructor(t){super(t),this.name="InvalidReleaseRefError"}},Me=e=>e.startsWith(xe)?e.slice(xe.length):e,Se=(e,t,r)=>({kind:"version",semver:{major:e,minor:t,patch:r},raw:`${e}.${t}.${r}`}),Y=e=>{if(e.length===0)throw new k('Release name is empty. Provide a kebab-case name like "checkout-redesign".');if(e.length>50)throw new k(`Release name "${e}" is ${e.length} characters; the maximum is 50.`);if(!jt.test(e))throw new k(`Release name "${e}" is not kebab-case. Use lowercase letters, digits, and single hyphens, e.g. "checkout-redesign".`);if(Re.has(e))throw new k(`Release name "${e}" is reserved. Reserved names: ${[...Re].join(", ")}.`)},Z=e=>{let t=Me(e.trim());if(!t.startsWith(T))return null;if(t.startsWith(X)){let n=t.slice(X.length),o=$t.exec(n);if(o)return Se(Number(o[1]),Number(o[2]),Number(o[3]))}let r=t.slice(T.length);try{Y(r)}catch{return null}return{kind:"name",name:r,raw:r}},Ot=e=>{let t=e.trim();if(Me(t).startsWith(T)){let o=Z(t);if(!o)throw new v(`"${e}" looks like a release branch but is not a valid release/v<semver> or release/<name> ref.`);return o}let n=Ct.exec(t);if(n)return Se(Number(n[1]),Number(n[2]),Number(n[3]));if(t.toLowerCase()===It)throw new v('The "next" token must be resolved to a concrete version (via computeNextVersion) before parsing a release ref.');if(t.includes("@"))throw new v(`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{Y(t)}catch(o){let s=o instanceof Error?o.message:String(o);throw new v(`Cannot parse "${e}" as a release ref: ${s}`)}return{kind:"name",name:t,raw:t}},Pt=e=>e.kind==="version"?`${X}${e.raw}`:`${T}${e.name}`,Tt=(e,t)=>{let r=t==="hotfix"?"Hotfix":"Release";return e.kind==="version"?`${r} v${e.raw}`:`${r} ${e.name}`},At=e=>e.kind==="version"?`Release v${e.raw} (RC)`:`Release ${e.name} (RC)`,Nt=e=>e.kind==="version"?`v${e.raw}`:e.name,Lt=e=>e.raw,Q=e=>e==null?!1:Z(e)!==null,Ee=e=>{if(e===void 0)return null;let t=e instanceof Date?e.getTime():new Date(e).getTime();return Number.isNaN(t)?null:t},_t=(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=Ee(r?.a),o=Ee(r?.b);return n!==null&&o!==null&&n!==o?n-o:e.name<t.name?-1:e.name>t.name?1:0};var $e=async e=>{let t=await g({cwd:e})`git worktree list --porcelain`,r=[],n=null;for(let o of t.stdout.split(`
3
3
  `)){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},Kt=async e=>{let t=await $e(Ce.cwd()),r=n=>e==="release"?Q(n):n.startsWith("feature/");return t.map(n=>n.branch).filter(n=>n!==null&&r(n))},Ft=e=>{let t=E(e);return t&&/not a git repository/i.test(t)?"not a git repository":void 0},Dt=({hasStderr:e})=>{if(b())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},S=async()=>{try{return(await g({quiet:!0})`git rev-parse --show-toplevel`).stdout.trim()}catch(e){let t=Ft(e)??E(e);throw new d(e,{operation:`resolve the project root from ${Ce.cwd()}`,stderrExcerpt:t,remediation:Dt({hasStderr:t!==void 0})})}},ee=async e=>{let t=e??await S(),r=(await g({cwd:t,quiet:!0})`git rev-parse --git-common-dir`).stdout.trim(),n=x.resolve(t,r);return n.includes(`${x.sep}.git${x.sep}modules${x.sep}`)?t:x.dirname(n)},je=async()=>(await g`git rev-parse --abbrev-ref HEAD`).stdout.trim(),Ie=async()=>(await g`git status --porcelain`).stdout.split(`
4
4
  `).map(t=>t.trimEnd()).filter(t=>t.trim().length>0),Wt=async()=>(await Ie()).length===0,Vt=async()=>{let e=await S(),[t,r]=await Promise.all([g({cwd:e})`git rev-parse --absolute-git-dir`,g({cwd:e})`git rev-parse --git-common-dir`]),n=t.stdout.trim(),o=x.resolve(e,r.stdout.trim());return n!==o};var Gt=async e=>(await g`git branch --list ${e}`).stdout.trim().length>0,qt=async e=>{(await g`git branch --list ${e}`).stdout.trim().length!==0&&await je()!==e&&await g`git branch -D ${e}`},Jt=async e=>{(await g`git ls-remote --heads origin ${e}`).stdout.trim().length!==0&&await g`git push origin --delete ${e}`};import{$ as A}from"zx";var Bt=async(e,t)=>{let r=`${t}^{commit}`;try{return(await A({cwd:e,quiet:!0})`git rev-parse --verify --quiet ${r}`).stdout.trim()||null}catch{return null}},Ht=async(e,t,r)=>{try{return await A({cwd:e,quiet:!0})`git merge-base --is-ancestor ${t} ${r}`,!0}catch(n){if(n.exitCode===1)return!1;throw new d(n,{operation:`test whether ${t} is contained in ${r}`,remediation:"both refs must exist \u2014 verify them with rev-parse first"})}},zt=async(e,t)=>{let n=(await A({cwd:e,quiet:!0})`git ls-remote --heads origin ${t}`).stdout.trim().split(`
@@ -18,4 +18,4 @@ A retired key on this branch \u2014 run \`infra-kit setup --skip-tools\` in this
18
18
  `),Gr=e=>[`"gitFlow" is not allowed in ${e.label} (${e.path}): it decides which branch every teammate's releases are cut from and delivered through, so a per-machine copy would ship this clone's releases down a different branch than everyone else's.`,"Move it to the project infra-kit.json and commit it there."].join(`
19
19
  `),qr={aliasRepo:Vr,configVersion:Wr,gitFlow:Gr,mcp:_r,vendorSource:Kr,vendorTarget:Fr,audit:Dr},Jr=(e,t)=>{let{configVersion:r}=e;if(!(typeof r!="number"||r<=V))throw new P({status:"refused",reason:"config-version-unsupported",configVersion:r,supportedConfigVersion:V,agentMode:O.source},2,{operation:"load infra-kit.json",remediation:"update the infra-kit CLI: `pnpm add -g infra-kit@<version>` with the version `pnpm view infra-kit version` prints, then re-run",stderrExcerpt:`${t} declares configVersion ${r}; this CLI reads up to ${V}`})},Br=(e,t)=>{for(let[r,n]of Object.entries(qr))if(r in t)throw new Error(n(e))},W=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Hr=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(`
20
20
  `);export{M as a,wt as b,be as c,O as d,b as e,xt as f,Rt as g,ne as h,B as i,St as j,U as k,We as l,Je as m,Be as n,nr as o,K as p,ze as q,Ue as r,mr as s,E as t,d as u,P as v,k as w,Y as x,Z as y,Ot as z,Pt as A,Tt as B,At as C,Nt as D,Lt as E,Q as F,_t as G,$e as H,Kt as I,S as J,ee as K,je as L,Ie as M,Wt as N,Vt as O,Gt as P,qt as Q,Jt as R,Bt as S,Ht as T,zt as U,Ut as V,Pe as W,Xt as X,re as Y,Yt as Z,Zt as _,Qt as $,tt as aa,rt as ba,V as ca,$r as da,fe as ea,jr as fa,ot as ga,de as ha,Ir as ia,ct as ja,ut as ka,Or as la,Pr as ma,Tr as na};
21
- //# sourceMappingURL=chunk-DVMV3WJZ.js.map
21
+ //# sourceMappingURL=chunk-DIGPYEFM.js.map
@@ -1,4 +1,4 @@
1
- import{a as x,b as E}from"./chunk-QWVLAZ6N.js";import{d as l,f as u,i as v,v as c}from"./chunk-DVMV3WJZ.js";var A=()=>{let e="",n=[],t=!1;return{start(r){e=r,n=[],t=!1},setInteractive(){t=!0},addOption(r,o){n.push({flag:r,value:o})},formatOptions(){return n.map(r=>typeof r.value=="boolean"?r.value?r.flag:"":Array.isArray(r.value)?`${r.flag} "${r.value.join(", ")}"`:`${r.flag} "${r.value}"`).filter(Boolean).join(" ")},snapshot(){return n.length===0?null:{formattedOptions:this.formatOptions()}},print(){!t||n.length===0||!e||v.info(`\u{1F4DF} Equivalent command:
1
+ import{a as x,b as E}from"./chunk-QWVLAZ6N.js";import{d as l,f as u,i as v,v as c}from"./chunk-DIGPYEFM.js";var A=()=>{let e="",n=[],t=!1;return{start(r){e=r,n=[],t=!1},setInteractive(){t=!0},addOption(r,o){n.push({flag:r,value:o})},formatOptions(){return n.map(r=>typeof r.value=="boolean"?r.value?r.flag:"":Array.isArray(r.value)?`${r.flag} "${r.value.join(", ")}"`:`${r.flag} "${r.value}"`).filter(Boolean).join(" ")},snapshot(){return n.length===0?null:{formattedOptions:this.formatOptions()}},print(){!t||n.length===0||!e||v.info(`\u{1F4DF} Equivalent command:
2
2
  pnpm exec infra-kit ${e} ${this.formatOptions()}
3
3
  `)},reset(){e="",n=[],t=!1}}},f=A();import{isAbsolute as w,resolve as y}from"node:path";import T from"node:process";var m=null,p=null,P=e=>{m=[...e],p=T.cwd()},S=new Set(["--yes","-y"]),$=(e,n)=>{let t=[...e];for(let[r,o]of t.entries())o==="-C"&&t[r+1]!==void 0&&!w(t[r+1])?t[r+1]=y(n,t[r+1]):o.startsWith("-C")&&o.length>2&&!o.startsWith("--")&&!w(o.slice(2))&&(t[r]=`-C${y(n,o.slice(2))}`);return t},g=()=>{if(m===null||p===null)return["--yes"];let e=m.slice(2),n=e.indexOf("--"),t=n===-1?e.length:n,r=$(e.slice(0,t),p),o=e.slice(t);return r.some(s=>S.has(s))?[...r,...o]:[...r,"--yes",...o]};import b from"node:process";var H=27,D=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`,j=e=>`${e===void 0?"pass the value explicitly instead of relying on the prompt":`pass --${e}`} on the re-run`,I=e=>{if(typeof e=="object"&&"value"in e)return e.value;let n=typeof e=="object"?e.refuse:void 0,{source:t}=l;throw new c(n===void 0?{status:"refused",agentMode:t}:{status:"argument_required",argument:n,agentMode:t},2,{operation:"interactive prompt",remediation:j(n),stderrExcerpt:D(t)})},C=async(e,n)=>{let t=new AbortController,{whenHeadless:r="refuse",...o}=n??{},d={...o,signal:t.signal};if(u())return I(r);if(!b.stdin.isTTY)return e(d);let s=b.stdin,h=a=>{a.length===1&&a[0]===H&&t.abort()};x();try{let a=e(d);return s.isPaused()&&s.resume(),s.on("data",h),await a}finally{s.removeListener("data",h),E()}};import M from"@inquirer/confirm";var i=class extends Error{constructor(n="Operation cancelled by the operator"){super(n),this.name="CommandDeclinedError"}},z=e=>e instanceof i;var O=(e,n,t=g())=>{let{source:r}=l;throw new c({status:"confirmation_required",message:e,plan:n,rerun:t,agentMode:r},2,{operation:"confirm before running",remediation:r===null?"pass `--yes` to confirm, or drop `--json` to be prompted":`show the plan to the human, then re-run \`infra-kit ${t.join(" ")}\` to confirm`,stderrExcerpt:"confirmation required and nobody to ask"})},k=async(e,n,t={})=>{!e&&u()&&O(n,t.plan,t.rerun);let r=e?!0:await C(o=>M({message:n},o),{whenHeadless:"refuse"});if(e||f.setInteractive(),!r)throw new i};export{f as a,z as b,P as c,g as d,C as e,O as f,k as g};
4
- //# sourceMappingURL=chunk-DQSVQO2S.js.map
4
+ //# sourceMappingURL=chunk-HOEKJOZE.js.map
@@ -1,6 +1,6 @@
1
- import{a as c,c as v,d as m}from"./chunk-NJ22P2UB.js";import{k as g,la as E,t as p}from"./chunk-DVMV3WJZ.js";import{Buffer as b}from"node:buffer";import K from"node:process";import{$ as d}from"zx";var y="Could not find requested project",N="Could not find requested config",h="Invalid Auth token",D="does not have access to requested config",a=e=>e.includes(h)||e.includes(D)?"auth":e.includes(y)?"project":e.includes(N)?"config":"unknown",u=e=>e.includes(D)?"mis-scoped":e.includes(h)?"revoked":null;var A=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 c,c as v,d as m}from"./chunk-BRAJBMCQ.js";import{k as g,la as E,t as p}from"./chunk-DIGPYEFM.js";import{Buffer as b}from"node:buffer";import K from"node:process";import{$ as d}from"zx";var y="Could not find requested project",N="Could not find requested config",h="Invalid Auth token",D="does not have access to requested config",a=e=>e.includes(h)||e.includes(D)?"auth":e.includes(y)?"project":e.includes(N)?"config":"unknown",u=e=>e.includes(D)?"mis-scoped":e.includes(h)?"revoked":null;var A=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
  `),i=class extends c{authKind;constructor(r,t=null,o){super(o??A(r),r),this.name="DopplerAuthError",this.authKind=t}};var k=({kind:e,project:r,config:t,available:o})=>{let n=e==="project"?[`Doppler project "${r}" not found (set in infra-kit.json \u2192 envManagement.config.name).`]:[`Doppler config "${t}" not found in project "${r}".`];if(o&&o.length>0){let s=e==="project"?"Available projects":`Available configs in "${r}"`;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 l}from"zx";var x=5e3,F="DOPPLER_CONFIG",w=async()=>{let{envManagement:e}=await E();return e.config.name},X=async({childEnv:e,project:r,config:t})=>{let o=l.quiet;l.quiet=!0;try{let s=(await l({env:e})`doppler secrets get ${F} --plain --project ${r} --config ${t}`.timeout(x)).stdout.trim();return s!==t?{outcome:"mis-scoped",scopedTo:s}:{outcome:"valid",scopedTo:s}}catch(n){return{outcome:R(n)}}finally{l.quiet=o}},R=e=>{let r=p(e)??(e instanceof Error?e.message:String(e));return a(r)!=="auth"?"unreachable":u(r)??"unreachable"};import $ from"node:process";var P="INFRA_KIT_ENV_TOKEN",O=async e=>{let r=$.env[P];if(r)return{token:r,source:"env"};let o=(await m())?.envs[e];if(o)return{token:o,source:"store"};throw new c(S(e,await v()),e)},S=(e,r)=>[`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 ${g(r)} (mode 0600, never in the repo).`,`CI / agents: set ${P} instead \u2014 it takes precedence and needs no home config.`].join(`
4
4
  `);var j="DOPPLER_CONFIG",T=1024*1024,M=3e4,I=["DOPPLER_TOKEN","DOPPLER_PROJECT","DOPPLER_CONFIG"],C=(e,r=K.env)=>{let t={...r};for(let o of I)delete t[o];return t.DOPPLER_TOKEN=e,t},de=async e=>new Map(await L(await w(),e)),L=async(e,r)=>{let{token:t}=await O(r),o=C(t),n=d.quiet;d.quiet=!0;try{let s;try{s=await d({env:o})`doppler secrets download --no-file --format json --project ${e} --config ${r}`.timeout(M)}catch(_){throw q(_,e,r)}V(s.stdout);let f=U(s.stdout);return J(f,r),f}finally{d.quiet=n}},J=(e,r)=>{let t=e.find(([o])=>o===j)?.[1];if(!(t===void 0||t===r))throw new i(r,null,`Doppler returned secrets for config "${t}" but "${r}" was requested \u2014 the service token for env "${r}" is scoped to the wrong config. Refusing to load another environment's secrets.
5
5
  Fix: run \`infra-kit env-token-set ${r}\` with a token scoped to "${r}".`)},q=(e,r,t)=>{let o=p(e)??(e instanceof Error?e.message:String(e)),n=a(o);return n==="auth"?new i(t,u(o)):n==="unknown"?e instanceof Error?e:new Error(String(e)):new Error(k({kind:n,project:r,config:t,available:null}))},V=e=>{let r=b.byteLength(e,"utf-8");if(r>T)throw new Error(`doppler returned unexpectedly large output (${r} bytes > ${T}) \u2014 refusing to write to disk`)},G=/^[A-Z_]\w*$/i,U=e=>{let r;try{r=JSON.parse(e)}catch{throw new Error(`doppler returned non-JSON output for env-load (got: ${JSON.stringify(e.slice(0,80))})`)}if(r===null||typeof r!="object"||Array.isArray(r))throw new Error("doppler returned unexpected JSON shape for env-load (expected an object of KEY: value pairs)");let t=[];for(let[o,n]of Object.entries(r)){if(!G.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})`);t.push([o,n])}if(t.length===0)throw new Error("doppler returned empty output for env-load");return t};export{a,u as b,w as c,X as d,P as e,O as f,T as g,C as h,de as i,L as j,J as k,q as l,V as m,U as n};
6
- //# sourceMappingURL=chunk-3DAG53TI.js.map
6
+ //# sourceMappingURL=chunk-XCH7QCPN.js.map
@@ -1,4 +1,4 @@
1
- import{E as F,i as f,y as $}from"./chunk-DVMV3WJZ.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{E as F,i as f,y as $}from"./chunk-DIGPYEFM.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{d as a,p as b,ve as c,$e as d,M as e,Ue as f,Le as g,Ce as h,Ie as i,ee as j,je as k,qe as l,Yr as m,Qr as n,Zr as o,er as p,z as q,or as r,N as s,cr as t,ur as u};
10
- //# sourceMappingURL=chunk-GIF2JMAW.js.map
10
+ //# sourceMappingURL=chunk-YCGNUKU2.js.map
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{a as Yg}from"./chunk-V2ZLQPLI.js";import{a as fn,b as Ng,c as rr,d as Ki,e as _g,f as Mg,g as jg,h as Fg,i as Lg,j as Bg,k as Ug,l as Vg,o as Ol,p as qg,s as zg,u as Me}from"./chunk-GIF2JMAW.js";import{a as Vf,b as Je,c as Wf,d as cl,e as Gf,f as Jf,g as Kf,h as Hf,i as Co,j as qf,k as zf,l as Yf,m as Xf,n as Zf,o as $o,p as Qf,q as eg,r as tg,s as rg,t as ll,u as _i,v as Dt,w as ng,x as Mi,y as og}from"./chunk-VZAXKGEY.js";import{a as me,b as Z,c as er,d as Do,e as hl,f as Vi,g as Wi,h as yl,i as Io,j as Er,k as vl,l as Gi,m as Og,n as at,o as _o,p as Tl,q as Cl,r as $l,s as Wg,u as Al}from"./chunk-HIGOL4H4.js";import{b as ln,c as Ii,d as al,e as jf,f as Ni,g as Ff,i as Lf,k as Bf,m as Se,o as Uf}from"./chunk-REDCBY4O.js";import{a as wl,b as kl,c as He,d as bl,e as De,f as Sl,h as No,j as El,k as Pl,n as xl}from"./chunk-3DAG53TI.js";import{a as y,b as xe,c as Gg,d as Jg,e as _,f as Hi,g as q}from"./chunk-DQSVQO2S.js";import{a as Kg,b as Hg}from"./chunk-QWVLAZ6N.js";import{b as Ji,c as tr,d as fe,e as Dg,f as Rl,g as Ig}from"./chunk-NJ22P2UB.js";import{$ as Rg,A as Ae,B as mg,C as pl,D as pe,E as ae,F as un,G as fg,H as gt,I as Pe,J as $,K as _e,L as dn,M as gg,N as hg,O as yg,P as vg,Q as Li,R as Bi,S as Oe,T as Ao,U as pn,V as Ui,W as wg,X as kg,Y as bg,Z as ml,_ as fl,a as Xt,aa as Eg,b as I,ba as Pg,c as sg,ca as mn,d as N,da as xg,e as te,ea as Tg,f as H,fa as Zt,g as ji,ga as Cg,h as Ke,ha as gl,i as d,ia as $g,j as ie,ja as Ag,k as w,ka as X,l as it,la as L,m as ig,ma as Oo,n as ag,na as Qt,o as cg,p as lg,q as ul,r as dl,s as ug,t as dg,u as g,v as A,w as pg,x as Fi,y as re,z as Ee}from"./chunk-DVMV3WJZ.js";import{a as Sg}from"./chunk-MFAFQVTW.js";import{a as U}from"./chunk-D7C4NYQA.js";import{a as qt,b as Ai,c as nn,d as ft,e as If,f as zt,g as on,h as sn,i as Oi,j as an,k as Di,l as Nf,m as _f,n as Ot,o as Yt,p as st,q as le,r as Mf,s as cn}from"./chunk-RVMKL6T4.js";import wB,{Separator as OS}from"@inquirer/select";import{existsSync as kB,realpathSync as bB}from"node:fs";import{homedir as RB}from"node:os";import Ge from"node:process";import{fileURLToPath as IS}from"node:url";import ty from"node:path";import ry from"node:process";import{z as Ce}from"zod";import sh from"node:fs";import hn from"node:path";var Pr=async()=>{try{return(await L()).audit?.exclude??[]}catch(e){return d.debug({err:e,msg:"audit.exclude unreadable \u2014 no workspace package is excluded"}),[]}};import{packageConfigSchema as Qg}from"@slip-stream-kit/config/internal";import eh from"node:fs/promises";import qi from"node:path";import{pathToFileURL as VS}from"node:url";import{z as th}from"zod";import Xg from"node:path";var Mo=["frontend","backend","lib","e2e","mobile"],MS={ui:"frontend",api:"backend",tests:"e2e"},jS="mobile-app",FS=[{type:"e2e",packages:["@playwright/test"]},{type:"mobile",packages:["@capacitor/core","@capacitor/cli"]},{type:"backend",packages:["serverless"]}],LS=(e,t)=>{let r=Xg.relative(t,e).split(Xg.sep).filter(s=>s!==""&&s!=="."),[n,,o]=r;if(r.length===3&&n==="apps"&&o!==void 0){let s=MS[o];if(s)return s}return r.at(-1)===jS?"mobile":null},BS=e=>{let t=new Set([...Object.keys(e.dependencies??{}),...Object.keys(e.devDependencies??{}),...Object.keys(e.peerDependencies??{})]);for(let n of FS)if(n.packages.some(o=>t.has(o)))return n.type;return t.has("vite")&&t.has("react")&&!!e.scripts?.dev?"frontend":null},jo=({packageDir:e,repoRoot:t,pkgJson:r,declaredType:n})=>n??LS(e,t)??BS(r)??"lib";var ht={requiredScripts:["build","ts-check","eslint-check","prettier-check","test"],requiredFiles:["tsconfig.json","eslint.config.js","readme.md"],turboTasks:[]},Zg=2e3,Dl={"e2e-test":"pnpm exec playwright test","e2e-test-ui":"pnpm exec playwright test --ui","e2e-test-ui-demo":`E2E_SLOW_MO=\${E2E_SLOW_MO:-${Zg}} pnpm exec playwright test --ui --headed --workers=1`,"e2e-test-chrome":"pnpm exec playwright test --project=chromium","e2e-test-debug":"pnpm exec playwright test --debug","e2e-test-codegen":"pnpm exec playwright codegen","playwright-install":"pnpm exec playwright install --with-deps"},xr={requiredScripts:["build","test","qa","infra-kit-check","fix"],requiredFiles:["turbo.json","pnpm-workspace.yaml"],turboTasks:["build","test","ts-check","eslint-check","prettier-check","infra-kit-check"]},Fo=(e,t=ht)=>({requiredScripts:e.requiredScripts??[...t.requiredScripts],requiredFiles:e.requiredFiles??[...t.requiredFiles],turboTasks:e.turbo?.requiredTasks??[...t.turboTasks]});import US from"node:fs/promises";var je=async e=>{try{return await US.access(e),!0}catch{return!1}};var ge="infra-kit.config.ts",Tr=async e=>{try{let t=await eh.readFile(qi.join(e,"package.json"),"utf-8");return JSON.parse(t)}catch{return{}}},Il=async e=>{let t=await eh.stat(e),o=(await import(`${VS(e).href}?mtime=${Number(t.mtimeMs)}`)).default;if(o===void 0)throw new Error(`${ge} at ${e} has no default export`);return typeof o=="function"?await o():o},It=async e=>{let t=qi.join(e,ge);if(await je(t))try{let n=(await Il(t))?.type;return Mo.find(o=>o===n)}catch{return}},rh=e=>e,Lo=async(e,t=ht)=>{let r=qi.join(e,ge);if(!await je(r))throw new Error(`${ge} not found at ${r}`);let n=await Il(r),o=Qg.safeParse(n);if(!o.success)throw new Error(`Invalid ${ge} at ${r}: ${th.prettifyError(o.error)}`);return Fo(rh(o.data),t)},yt=async e=>{let t=qi.join(e,ge);if(!await je(t))return;let r=Qg.safeParse(await Il(t));if(!r.success)throw new Error(`Invalid ${ge} at ${t}: ${th.prettifyError(r.error)}`);return rh(r.data)};import nh from"node:fs/promises";import zi from"node:path";import WS from"yaml";var GS="pnpm-workspace.yaml",JS=async e=>(await nh.readdir(e,{withFileTypes:!0}).catch(()=>[])).filter(r=>r.isDirectory()).map(r=>zi.join(e,r.name)),KS=async(e,t)=>{let r=[];for(let n of e){if(t==="*"){r.push(...await JS(n));continue}let o=zi.join(n,t);await je(o)&&r.push(o)}return r},oh=async(e,t)=>{let r=[e];for(let n of t.split("/"))r=await KS(r,n);return r},vt=async e=>{let t=await nh.readFile(zi.join(e,GS),"utf-8"),n=((WS.parse(t)??{}).packages??[]).filter(s=>!s.startsWith("!")&&!s.startsWith("vendor")),o=new Set;for(let s of n){let i=await oh(e,s);for(let a of i)await je(zi.join(a,"package.json"))&&o.add(a)}return[...o].sort()},Cr=async(e,t)=>{let r=await vt(e),n=new Set;for(let o of t)for(let s of await oh(e,o.endsWith("/")?o.slice(0,-1):o))n.add(s);return{packages:r.filter(o=>!n.has(o)),excluded:r.filter(o=>n.has(o))}};import Bo from"node:path";var Uo=async e=>{let t=Bo.resolve(e);for(;t!==Bo.dirname(t);){if(await je(Bo.join(t,"package.json")))return t;t=Bo.dirname(t)}if(await je(Bo.join(t,"package.json")))return t;throw new Error(`No package.json found in or above ${e} \u2014 cd into a package directory, or pass --root to audit a monorepo root`)};var qe=(e,t,r)=>{let n=e.indexOf(t),o=e.indexOf(r);return n!==-1&&o!==-1&&o>=n},nr=(e,t,r)=>{let n=e.indexOf(t),o=e.indexOf(r);if(n===-1||o===-1||o<n)return null;let s=e.slice(0,n).replace(/\n+$/,""),i=e.slice(o+r.length).replace(/^\n+/,"");return s+(i?`
2
+ import{a as Yg}from"./chunk-V2ZLQPLI.js";import{a as fn,b as Ng,c as rr,d as Ki,e as _g,f as Mg,g as jg,h as Fg,i as Lg,j as Bg,k as Ug,l as Vg,o as Ol,p as qg,s as zg,u as Me}from"./chunk-YCGNUKU2.js";import{a as Vf,b as Je,c as Wf,d as cl,e as Gf,f as Jf,g as Kf,h as Hf,i as Co,j as qf,k as zf,l as Yf,m as Xf,n as Zf,o as $o,p as Qf,q as eg,r as tg,s as rg,t as ll,u as _i,v as Dt,w as ng,x as Mi,y as og}from"./chunk-VZAXKGEY.js";import{a as me,b as Z,c as er,d as Do,e as hl,f as Vi,g as Wi,h as yl,i as Io,j as Er,k as vl,l as Gi,m as Og,n as at,o as _o,p as Tl,q as Cl,r as $l,s as Wg,u as Al}from"./chunk-HIGOL4H4.js";import{b as ln,c as Ii,d as al,e as jf,f as Ni,g as Ff,i as Lf,k as Bf,m as Se,o as Uf}from"./chunk-REDCBY4O.js";import{a as wl,b as kl,c as He,d as bl,e as De,f as Sl,h as No,j as El,k as Pl,n as xl}from"./chunk-XCH7QCPN.js";import{a as y,b as xe,c as Gg,d as Jg,e as _,f as Hi,g as q}from"./chunk-HOEKJOZE.js";import{a as Kg,b as Hg}from"./chunk-QWVLAZ6N.js";import{b as Ji,c as tr,d as fe,e as Dg,f as Rl,g as Ig}from"./chunk-BRAJBMCQ.js";import{$ as Rg,A as Ae,B as mg,C as pl,D as pe,E as ae,F as un,G as fg,H as gt,I as Pe,J as $,K as _e,L as dn,M as gg,N as hg,O as yg,P as vg,Q as Li,R as Bi,S as Oe,T as Ao,U as pn,V as Ui,W as wg,X as kg,Y as bg,Z as ml,_ as fl,a as Xt,aa as Eg,b as I,ba as Pg,c as sg,ca as mn,d as N,da as xg,e as te,ea as Tg,f as H,fa as Zt,g as ji,ga as Cg,h as Ke,ha as gl,i as d,ia as $g,j as ie,ja as Ag,k as w,ka as X,l as it,la as L,m as ig,ma as Oo,n as ag,na as Qt,o as cg,p as lg,q as ul,r as dl,s as ug,t as dg,u as g,v as A,w as pg,x as Fi,y as re,z as Ee}from"./chunk-DIGPYEFM.js";import{a as Sg}from"./chunk-MFAFQVTW.js";import{a as U}from"./chunk-CHFSRDQE.js";import{a as qt,b as Ai,c as nn,d as ft,e as If,f as zt,g as on,h as sn,i as Oi,j as an,k as Di,l as Nf,m as _f,n as Ot,o as Yt,p as st,q as le,r as Mf,s as cn}from"./chunk-RVMKL6T4.js";import wB,{Separator as OS}from"@inquirer/select";import{existsSync as kB,realpathSync as bB}from"node:fs";import{homedir as RB}from"node:os";import Ge from"node:process";import{fileURLToPath as IS}from"node:url";import ty from"node:path";import ry from"node:process";import{z as Ce}from"zod";import sh from"node:fs";import hn from"node:path";var Pr=async()=>{try{return(await L()).audit?.exclude??[]}catch(e){return d.debug({err:e,msg:"audit.exclude unreadable \u2014 no workspace package is excluded"}),[]}};import{packageConfigSchema as Qg}from"@slip-stream-kit/config/internal";import eh from"node:fs/promises";import qi from"node:path";import{pathToFileURL as VS}from"node:url";import{z as th}from"zod";import Xg from"node:path";var Mo=["frontend","backend","lib","e2e","mobile"],MS={ui:"frontend",api:"backend",tests:"e2e"},jS="mobile-app",FS=[{type:"e2e",packages:["@playwright/test"]},{type:"mobile",packages:["@capacitor/core","@capacitor/cli"]},{type:"backend",packages:["serverless"]}],LS=(e,t)=>{let r=Xg.relative(t,e).split(Xg.sep).filter(s=>s!==""&&s!=="."),[n,,o]=r;if(r.length===3&&n==="apps"&&o!==void 0){let s=MS[o];if(s)return s}return r.at(-1)===jS?"mobile":null},BS=e=>{let t=new Set([...Object.keys(e.dependencies??{}),...Object.keys(e.devDependencies??{}),...Object.keys(e.peerDependencies??{})]);for(let n of FS)if(n.packages.some(o=>t.has(o)))return n.type;return t.has("vite")&&t.has("react")&&!!e.scripts?.dev?"frontend":null},jo=({packageDir:e,repoRoot:t,pkgJson:r,declaredType:n})=>n??LS(e,t)??BS(r)??"lib";var ht={requiredScripts:["build","ts-check","eslint-check","prettier-check","test"],requiredFiles:["tsconfig.json","eslint.config.js","readme.md"],turboTasks:[]},Zg=2e3,Dl={"e2e-test":"pnpm exec playwright test","e2e-test-ui":"pnpm exec playwright test --ui","e2e-test-ui-demo":`E2E_SLOW_MO=\${E2E_SLOW_MO:-${Zg}} pnpm exec playwright test --ui --headed --workers=1`,"e2e-test-chrome":"pnpm exec playwright test --project=chromium","e2e-test-debug":"pnpm exec playwright test --debug","e2e-test-codegen":"pnpm exec playwright codegen","playwright-install":"pnpm exec playwright install --with-deps"},xr={requiredScripts:["build","test","qa","infra-kit-check","fix"],requiredFiles:["turbo.json","pnpm-workspace.yaml"],turboTasks:["build","test","ts-check","eslint-check","prettier-check","infra-kit-check"]},Fo=(e,t=ht)=>({requiredScripts:e.requiredScripts??[...t.requiredScripts],requiredFiles:e.requiredFiles??[...t.requiredFiles],turboTasks:e.turbo?.requiredTasks??[...t.turboTasks]});import US from"node:fs/promises";var je=async e=>{try{return await US.access(e),!0}catch{return!1}};var ge="infra-kit.config.ts",Tr=async e=>{try{let t=await eh.readFile(qi.join(e,"package.json"),"utf-8");return JSON.parse(t)}catch{return{}}},Il=async e=>{let t=await eh.stat(e),o=(await import(`${VS(e).href}?mtime=${Number(t.mtimeMs)}`)).default;if(o===void 0)throw new Error(`${ge} at ${e} has no default export`);return typeof o=="function"?await o():o},It=async e=>{let t=qi.join(e,ge);if(await je(t))try{let n=(await Il(t))?.type;return Mo.find(o=>o===n)}catch{return}},rh=e=>e,Lo=async(e,t=ht)=>{let r=qi.join(e,ge);if(!await je(r))throw new Error(`${ge} not found at ${r}`);let n=await Il(r),o=Qg.safeParse(n);if(!o.success)throw new Error(`Invalid ${ge} at ${r}: ${th.prettifyError(o.error)}`);return Fo(rh(o.data),t)},yt=async e=>{let t=qi.join(e,ge);if(!await je(t))return;let r=Qg.safeParse(await Il(t));if(!r.success)throw new Error(`Invalid ${ge} at ${t}: ${th.prettifyError(r.error)}`);return rh(r.data)};import nh from"node:fs/promises";import zi from"node:path";import WS from"yaml";var GS="pnpm-workspace.yaml",JS=async e=>(await nh.readdir(e,{withFileTypes:!0}).catch(()=>[])).filter(r=>r.isDirectory()).map(r=>zi.join(e,r.name)),KS=async(e,t)=>{let r=[];for(let n of e){if(t==="*"){r.push(...await JS(n));continue}let o=zi.join(n,t);await je(o)&&r.push(o)}return r},oh=async(e,t)=>{let r=[e];for(let n of t.split("/"))r=await KS(r,n);return r},vt=async e=>{let t=await nh.readFile(zi.join(e,GS),"utf-8"),n=((WS.parse(t)??{}).packages??[]).filter(s=>!s.startsWith("!")&&!s.startsWith("vendor")),o=new Set;for(let s of n){let i=await oh(e,s);for(let a of i)await je(zi.join(a,"package.json"))&&o.add(a)}return[...o].sort()},Cr=async(e,t)=>{let r=await vt(e),n=new Set;for(let o of t)for(let s of await oh(e,o.endsWith("/")?o.slice(0,-1):o))n.add(s);return{packages:r.filter(o=>!n.has(o)),excluded:r.filter(o=>n.has(o))}};import Bo from"node:path";var Uo=async e=>{let t=Bo.resolve(e);for(;t!==Bo.dirname(t);){if(await je(Bo.join(t,"package.json")))return t;t=Bo.dirname(t)}if(await je(Bo.join(t,"package.json")))return t;throw new Error(`No package.json found in or above ${e} \u2014 cd into a package directory, or pass --root to audit a monorepo root`)};var qe=(e,t,r)=>{let n=e.indexOf(t),o=e.indexOf(r);return n!==-1&&o!==-1&&o>=n},nr=(e,t,r)=>{let n=e.indexOf(t),o=e.indexOf(r);if(n===-1||o===-1||o<n)return null;let s=e.slice(0,n).replace(/\n+$/,""),i=e.slice(o+r.length).replace(/^\n+/,"");return s+(i?`
3
3
  ${i}`:"")},$r=(e,t)=>{let r=e.indexOf(t);if(r===-1)return null;let o=e.slice(r+t.length).match(/^([^\s>]+)/);return o?o[1]:null},Yi=(e,t,r)=>`${e}
4
4
  ${t}
5
5
  ${r}`,gn=({content:e,body:t,startMarker:r,endMarker:n,placement:o="replace-in-place"})=>{let s=Yi(r,t,n),i=qe(e,r,n);if(o==="replace-in-place"&&i){let l=e.indexOf(r),u=e.indexOf(n)+n.length;return e.slice(0,l)+s+e.slice(u)}let c=(i?nr(e,r,n)??e:e).replace(/\n+$/,"");return c.length>0?`${c}
@@ -1,4 +1,4 @@
1
- import{b as C,c as Me,g as He,i as je,m as We,n as Ge,o as Ve,p as oe,q as I,r as M,s as Ke,t as H,u as Je}from"./chunk-GIF2JMAW.js";import{d as ne,l as ie,o as Ie,p as Le,v as Ne}from"./chunk-VZAXKGEY.js";import"./chunk-REDCBY4O.js";import{a as _,b as rt}from"./chunk-UTQ4KTO6.js";import{a as L,b as j,c as ze,d as qe,e as W,f as Ye,g as N,h as Xe,i as Qe,j as Ze,k as et,l as tt}from"./chunk-55F372Z7.js";import{K as Fe,d as _e,fa as Be,i as T,u as se,v as Ue}from"./chunk-DVMV3WJZ.js";import"./chunk-MFAFQVTW.js";import"./chunk-D7C4NYQA.js";import{d as $e,f as Oe,n as Ce}from"./chunk-RVMKL6T4.js";import{Command as ri}from"commander";import k from"node:process";import{pathToFileURL as ni}from"node:url";import ae from"node:process";var le=n=>{try{ae.stderr.write(n)}catch{}},U=(n,e,t=!0)=>{let r=e instanceof Error?`${e.message}
1
+ import{b as C,c as Me,g as He,i as je,m as We,n as Ge,o as Ve,p as oe,q as I,r as M,s as Ke,t as H,u as Je}from"./chunk-YCGNUKU2.js";import{d as ne,l as ie,o as Ie,p as Le,v as Ne}from"./chunk-VZAXKGEY.js";import"./chunk-REDCBY4O.js";import{a as _,b as rt}from"./chunk-UTQ4KTO6.js";import{a as L,b as j,c as ze,d as qe,e as W,f as Ye,g as N,h as Xe,i as Qe,j as Ze,k as et,l as tt}from"./chunk-55F372Z7.js";import{K as Fe,d as _e,fa as Be,i as T,u as se,v as Ue}from"./chunk-DIGPYEFM.js";import"./chunk-MFAFQVTW.js";import"./chunk-CHFSRDQE.js";import{d as $e,f as Oe,n as Ce}from"./chunk-RVMKL6T4.js";import{Command as ri}from"commander";import k from"node:process";import{pathToFileURL as ni}from"node:url";import ae from"node:process";var le=n=>{try{ae.stderr.write(n)}catch{}},U=(n,e,t=!0)=>{let r=e instanceof Error?`${e.message}
2
2
  ${e.stack??"(no stack)"}`:String(e);return`
3
3
  \u26A0\uFE0F ${n}: ${r}
4
4
  ${t?` dev-server kept alive (likely a bug in a handler's async path); restart if it misbehaves.
@@ -35,5 +35,5 @@ Received ${t}, closing Orca tab "${e}"...`),await ir(n)}})},sr=async n=>{let e=L
35
35
  `);let l=r(()=>{e(),t(Ee)},i);a.shutdown().finally(()=>{l(),t(Ee)}).catch(()=>{})}},di=["SIGINT","SIGTERM"],pi=({forceReap:n=I,exit:e=i=>{k.exit(i)},register:t=(i,s)=>{k.on(i,s)},unregister:r=(i,s)=>{k.off(i,s)}}={})=>{let i=new Map;for(let s of di){let o=()=>{ur(n,e,Ke(s))};i.set(s,o),t(s,o)}return{remove:()=>{for(let[s,o]of i)r(s,o)}}},xe=async n=>{let e=ai(n);if(e.orca){let l=await sr(e);if(l==="ran")return;k.stdout.write(`Orca: ${l.fallback}; falling back to single-terminal dev
36
36
  `)}let t=null,r=li(),i=ui({getRunner:()=>t,setTimer:r}),s=bt({onDeath:(l,u)=>{i(`stdio unwritable: ${l} ${u.code}`)}}),o=pi();try{t=await rr({...e,onExitRequest:l=>{k.exit(l)}},si)}finally{o.remove()}let a=t;nt({onFault:(l,u)=>{a.reportFault(U(l,u))},isTerminalDead:s.isDead,fileFault:(l,u)=>{a.fileFault(U(l,u,!1))},onFatal:i}),H({onSignal:async l=>{ce(`
37
37
  Received ${l}, shutting down dev-server...
38
- `),await a.shutdown()},describeStall:()=>a.shutdownStage,fileReport:l=>{a.fileFault(l)},setTimer:r})},ci=(n,e,t)=>!n.appName&&!n.app&&!n.self&&!n.orca&&n.watch==null&&!n.verbose&&!n.routes&&!n.reuse&&e&&!t,hi=(n,e)=>({watch:n.watch,orca:n.orca,include:n.include??null,presetDef:n.presetDef,self:!1,verbose:!1,routes:!1,uiHealth:e.uiHealth??!0}),co=async(n,e,t)=>{if(ci(n,e,t)){let{runDevWizard:r}=await import("./dev-wizard-run-6ITNKISE.js"),i=Promise.all([import("./persistent-ink-dev-ui-HHTHZ24S.js"),import("./safe-stderr-ECYA6DRR.js")]).catch(()=>{}),s;try{s=await r()}catch(o){if(Je(o))return;throw o}if(s==null)return;await i,await xe({...hi(s,n),tty:e,json:t});return}await xe({...ar(n),tty:e,json:t})},gi=async n=>{let e=new ri;e.name("infra-kit-dev-server").description("Run local dev servers for an app (or all apps)").argument("[app]","An app \u2014 its api/ui plus the backends its routes can run locally (omit to run every app)").option("-w, --watch","Rebuild and restart on file save (the default)").option("--no-watch","Build once and never restart on save").option("--app <names>","Further narrow to these app folder names (comma-separated)").option("--orca","Run each app in its own Orca pane (one tab, N panes; falls back to single terminal when Orca is not running)").option("--self","Run only the app of the current directory (infer from cwd; use inside apps/<app>/\u2026)").option("-V, --verbose","Print full boot narration (default: quiet; full detail always in the session log)").option("--routes","Print each app\u2019s registered METHOD /path routes at startup (default: off)"),e.parse(n),await xe(ar({...e.opts(),appName:e.args[0]}))};import.meta.url===ni(k.argv[1]??"").href&&gi(k.argv).catch(n=>{console.error(n instanceof Error?n.message:String(n)),k.exit(1)});export{ui as createFatalHandler,li as createSharedDeadlineTimer,pi as installBootSignalGuard,xe as runDevServer,co as runDevServerCli,ci as shouldRunWizard,ar as toDevServerOptions};
38
+ `),await a.shutdown()},describeStall:()=>a.shutdownStage,fileReport:l=>{a.fileFault(l)},setTimer:r})},ci=(n,e,t)=>!n.appName&&!n.app&&!n.self&&!n.orca&&n.watch==null&&!n.verbose&&!n.routes&&!n.reuse&&e&&!t,hi=(n,e)=>({watch:n.watch,orca:n.orca,include:n.include??null,presetDef:n.presetDef,self:!1,verbose:!1,routes:!1,uiHealth:e.uiHealth??!0}),co=async(n,e,t)=>{if(ci(n,e,t)){let{runDevWizard:r}=await import("./dev-wizard-run-C6FND2PR.js"),i=Promise.all([import("./persistent-ink-dev-ui-HHTHZ24S.js"),import("./safe-stderr-ECYA6DRR.js")]).catch(()=>{}),s;try{s=await r()}catch(o){if(Je(o))return;throw o}if(s==null)return;await i,await xe({...hi(s,n),tty:e,json:t});return}await xe({...ar(n),tty:e,json:t})},gi=async n=>{let e=new ri;e.name("infra-kit-dev-server").description("Run local dev servers for an app (or all apps)").argument("[app]","An app \u2014 its api/ui plus the backends its routes can run locally (omit to run every app)").option("-w, --watch","Rebuild and restart on file save (the default)").option("--no-watch","Build once and never restart on save").option("--app <names>","Further narrow to these app folder names (comma-separated)").option("--orca","Run each app in its own Orca pane (one tab, N panes; falls back to single terminal when Orca is not running)").option("--self","Run only the app of the current directory (infer from cwd; use inside apps/<app>/\u2026)").option("-V, --verbose","Print full boot narration (default: quiet; full detail always in the session log)").option("--routes","Print each app\u2019s registered METHOD /path routes at startup (default: off)"),e.parse(n),await xe(ar({...e.opts(),appName:e.args[0]}))};import.meta.url===ni(k.argv[1]??"").href&&gi(k.argv).catch(n=>{console.error(n instanceof Error?n.message:String(n)),k.exit(1)});export{ui as createFatalHandler,li as createSharedDeadlineTimer,pi as installBootSignalGuard,xe as runDevServer,co as runDevServerCli,ci as shouldRunWizard,ar as toDevServerOptions};
39
39
  //# sourceMappingURL=dev-server.js.map
@@ -1,2 +1,2 @@
1
- import{a as m,e as h}from"./chunk-DQSVQO2S.js";import"./chunk-QWVLAZ6N.js";import{a as v,b as k,d as w,m as x}from"./chunk-55F372Z7.js";import{d as b}from"./chunk-NJ22P2UB.js";import{i as u}from"./chunk-DVMV3WJZ.js";import"./chunk-MFAFQVTW.js";import"./chunk-D7C4NYQA.js";import{f as P}from"./chunk-RVMKL6T4.js";import N from"@inquirer/checkbox";import E from"@inquirer/confirm";import O from"@inquirer/select";import{loadDev as B,loadPackageConfig as j}from"@slip-stream-kit/config/internal";import z from"node:path";import g from"node:process";var C=e=>e.split("/")[0],R=e=>new Map(e.apps.map(r=>[r.name,r])),S=e=>e.localCapable&&e.cloudCapable,A=(e,r,a)=>S(r)?a[`${e} ${r.path}`]??(r.cloudCapable?"cloud":"local"):r.localCapable?"local":"cloud",D=(e,r,a)=>{let o=new Set,t=new Map;for(let n of e){let s=r.get(C(n));for(let i of s?.backends??[]){t.set(i.packageName,i.ownerApp);for(let p of i.routes)A(n,p,a)==="local"&&o.add(i.packageName)}}return{localPkgs:o,ownerByPkg:t}},$=(e,r)=>{let a={},o=!1;for(let t of e?.backends??[]){let n=r.has(t.packageName);for(let s of t.routes){let i=s.localCapable&&n?"local":"cloud";a[s.path]=i,i==="cloud"&&(o=!0)}}return{overrides:a,anyCloud:o}},W=(e,r)=>{let a=R(r),o=e.targets.filter(l=>l.endsWith("/ui")),t=e.targets.filter(l=>l.endsWith("/api")),{localPkgs:n,ownerByPkg:s}=D(o,a,e.sources),i={},p=!1;for(let l of o){let{overrides:c,anyCloud:f}=$(a.get(C(l)),n);f&&(p=!0),i[l]=Object.keys(c).length>0?{proxy:c}:{}}for(let l of t)i[l]??={};for(let l of n){let c=s.get(l);c!=null&&(i[`${c}/api`]??={})}return{presetDef:{apps:i},anyCloudRoute:p,targetKeys:Object.keys(i).sort()}},M=(e,r)=>{let a=[`--target=${e.targetKeys.join(",")}`];return r.watch||a.push("--no-watch"),r.orca&&a.push("--orca"),{flags:a.join(" ")}};var y={output:g.stderr,clearPromptOnDone:!0},U={select:e=>h(r=>O({message:e.message,choices:e.choices,default:e.default},r),{...y,whenHeadless:"refuse"}),checkbox:e=>h(r=>N({message:e.message,choices:e.choices},r),{...y,whenHeadless:"refuse"}),confirm:e=>h(r=>E({message:e.message,default:e.default},r),{...y,whenHeadless:"refuse"})},V=(e,r)=>{let a=new Map;for(let[o,t]of Object.entries(e)){let n={path:o,localCapable:t.from.includes("local"),cloudCapable:t.from.includes("cloud"),default:t.default},s=a.get(t.packageName);s?(s.routes.push(n),s.localCapable=s.localCapable||n.localCapable,s.cloudCapable=s.cloudCapable||n.cloudCapable):a.set(t.packageName,{packageName:t.packageName,routes:[n],localCapable:n.localCapable,cloudCapable:n.cloudCapable,ownerApp:r.get(t.packageName)})}return[...a.values()]},K=async(e,r,a)=>{try{let o=(await B(e))?.proxy?.routes;return o?V(o,a):[]}catch(o){return u.warn(`\u26A0\uFE0F Skipping ${r}: its dev config failed to load \u2014 ${o instanceof Error?o.message:String(o)}`),[]}},_=async e=>{let r=k(e),a=w(e),o=new Map(r.map(c=>[c.packageName,c.name])),t=new Map(r.map(c=>[c.name,c.packageName])),n=new Set(a.map(c=>c.name)),s=new Set(r.map(c=>c.name)),i=[...new Set([...s,...n])].sort(),p=await Promise.all(i.map(async c=>{let f=n.has(c);return{name:c,hasApi:s.has(c),hasUi:f,apiPackage:t.get(c),backends:f?await K(z.join(e,"apps",c,"ui"),c,o):[],deployedUrlEnv:f?(await j(z.join(e,"apps",c,"ui")).catch(()=>{}))?.deployedUrlEnv:void 0}})),l=await b();return{apps:p,environments:Object.keys(l?.envs??{}).sort()}},q=e=>{let r=[];for(let a of e.apps){if(a.hasUi){let o=a.backends.flatMap(n=>n.routes.map(s=>s.path)),t=o.length>0?`frontend \u2014 proxies ${[...o].sort().join(", ")}`:"frontend";r.push({name:`${a.name}/ui`,value:`${a.name}/ui`,description:t})}a.hasApi&&!a.hasUi&&r.push({name:`${a.name}/api`,value:`${a.name}/api`,description:"backend"})}return r},I=e=>{let r={api:e.apps.filter(t=>t.hasApi).map(t=>t.name),ui:e.apps.filter(t=>t.hasUi).map(t=>t.name)},a={},o=new Map;for(let t of e.apps){t.apiPackage!=null&&(a[t.name]=t.apiPackage);for(let n of t.backends)for(let s of n.routes)o.set(`${t.name} ${s.path}`,n.packageName)}return{discovered:r,apiPkgByApp:a,routePkg:(t,n)=>o.get(`${t} ${n}`)}},L=(e,r)=>x(e,I(r)).map(a=>a.message),T="INFRA_KIT_DEV_WIZARD_ORCA",F=()=>g.env[T]==="1",H=async(e,r,a)=>{let o=new Map(r.apps.map(n=>[n.name,n])),t={};for(let n of a){let s=o.get(n.split("/")[0]);for(let i of s?.backends??[])for(let p of i.routes){if(!p.localCapable||!p.cloudCapable)continue;let l=await e.select({message:`\u{1F500} ${n} ${p.path} \u2192 local or cloud?`,choices:[{name:"local (this machine)",value:"local"},{name:"cloud",value:"cloud"}],default:p.default??"local"});t[`${n} ${p.path}`]=l}}return t},Z=(e,r,a)=>e.apps.find(o=>o.name===r)?.backends.flatMap(o=>o.routes).find(o=>o.path===a),G=(e,r)=>{let a=[];for(let[o,t]of Object.entries(e.presetDef.apps??{})){if(!o.endsWith("/ui")||!t.proxy)continue;let n=o.split("/")[0];for(let[s,i]of Object.entries(t.proxy)){let p=Z(r,n,s),l=p&&p.localCapable&&p.cloudCapable?"":" (only option)";a.push(` ${o} ${s} \u2192 ${i}${l}`)}}if(a.length!==0){u.info("Resolved routes:");for(let o of[...a].sort())u.info(o)}},J=async(e,r)=>{let{downloadEnvSecrets:a}=await import("./secrets-download-EQ7N4XMQ.js"),o=await a(e);return new Map(r.flatMap(t=>{let n=o.get(t);return n===void 0?[]:[[t,n]]}))},Q=async(e,r,a,o)=>{let t=r.flatMap(s=>{let i=a.apps.find(p=>`${p.name}/ui`===s);return i?.deployedUrlEnv?[i.deployedUrlEnv]:[]}),n=t.length>0?await o(e,t):new Map;g.env[P]=e;for(let s of t){let i=n.get(s);i?g.env[s]=i:(delete g.env[s],u.warn(`\u2601\uFE0F "${e}" holds no ${s}; routes that go to the deployed app will fail until it does.`))}},X=async(e,r,a)=>{if(r.apps.length===0)return u.warn("No apps discovered to run."),null;let o=await e.checkbox({message:"\u{1F4E6} Which packages?",choices:q(r)});if(o.length===0)return u.warn("No packages selected."),null;let t=o.filter(d=>d.endsWith("/ui")),n=await H(e,r,t),s=await e.confirm({message:"\u{1F440} Rebuild & restart on save (watch)?",default:!0}),i=F()?await e.confirm({message:"\u{1F9E9} Run each app in its own Orca pane?",default:!1}):!1,p={targets:o,sources:n,watch:s,orca:i},l=W(p,r);if(l.anyCloudRoute){if(r.environments.length===0)return u.warn("\u2601\uFE0F This selection routes to a cloud environment, but no environment token is loaded."),u.warn(" Run `infra-kit env-load` to add one, then re-run the wizard."),null;p.env=await e.select({message:"\u2601\uFE0F Point cloud routes at which environment?",choices:r.environments.map(d=>({name:d,value:d}))}),await Q(p.env,t,r,a)}let c=L(l.presetDef,r);if(c.length>0){u.warn("\u26A0\uFE0F Proxy audit found issues with this selection:");for(let d of c)u.warn(` \u2022 ${d}`);return null}G(l,r),Y(l,p);let f=l.targetKeys.filter(d=>d.endsWith("/api")).map(d=>d.split("/")[0]);return i&&f.length>0?{include:f,presetDef:l.presetDef,watch:s,orca:!0}:(i&&u.info("\u2139\uFE0F Orca needs at least one local backend (panes are backend-only) \u2014 running in-process instead."),{presetDef:l.presetDef,watch:s,orca:!1})},Y=(e,r)=>{m.setInteractive();let a=M(e,r);m.addOption(a.flags,!0),m.print()},ee=async(e,r,a=J)=>X(e,r,a),he=async(e=U,r=v(g.cwd()))=>ee(e,await _(r));export{T as WIZARD_ORCA_VAR,L as auditManualPlan,U as defaultPrompts,_ as gatherWizardModel,K as loadBackends,he as runDevWizard,ee as runWizardFlow};
2
- //# sourceMappingURL=dev-wizard-run-6ITNKISE.js.map
1
+ import{a as m,e as h}from"./chunk-HOEKJOZE.js";import"./chunk-QWVLAZ6N.js";import{a as v,b as k,d as w,m as x}from"./chunk-55F372Z7.js";import{d as b}from"./chunk-BRAJBMCQ.js";import{i as u}from"./chunk-DIGPYEFM.js";import"./chunk-MFAFQVTW.js";import"./chunk-CHFSRDQE.js";import{f as P}from"./chunk-RVMKL6T4.js";import N from"@inquirer/checkbox";import E from"@inquirer/confirm";import O from"@inquirer/select";import{loadDev as B,loadPackageConfig as j}from"@slip-stream-kit/config/internal";import z from"node:path";import g from"node:process";var C=e=>e.split("/")[0],R=e=>new Map(e.apps.map(r=>[r.name,r])),S=e=>e.localCapable&&e.cloudCapable,A=(e,r,a)=>S(r)?a[`${e} ${r.path}`]??(r.cloudCapable?"cloud":"local"):r.localCapable?"local":"cloud",D=(e,r,a)=>{let o=new Set,t=new Map;for(let n of e){let s=r.get(C(n));for(let i of s?.backends??[]){t.set(i.packageName,i.ownerApp);for(let p of i.routes)A(n,p,a)==="local"&&o.add(i.packageName)}}return{localPkgs:o,ownerByPkg:t}},$=(e,r)=>{let a={},o=!1;for(let t of e?.backends??[]){let n=r.has(t.packageName);for(let s of t.routes){let i=s.localCapable&&n?"local":"cloud";a[s.path]=i,i==="cloud"&&(o=!0)}}return{overrides:a,anyCloud:o}},W=(e,r)=>{let a=R(r),o=e.targets.filter(l=>l.endsWith("/ui")),t=e.targets.filter(l=>l.endsWith("/api")),{localPkgs:n,ownerByPkg:s}=D(o,a,e.sources),i={},p=!1;for(let l of o){let{overrides:c,anyCloud:f}=$(a.get(C(l)),n);f&&(p=!0),i[l]=Object.keys(c).length>0?{proxy:c}:{}}for(let l of t)i[l]??={};for(let l of n){let c=s.get(l);c!=null&&(i[`${c}/api`]??={})}return{presetDef:{apps:i},anyCloudRoute:p,targetKeys:Object.keys(i).sort()}},M=(e,r)=>{let a=[`--target=${e.targetKeys.join(",")}`];return r.watch||a.push("--no-watch"),r.orca&&a.push("--orca"),{flags:a.join(" ")}};var y={output:g.stderr,clearPromptOnDone:!0},U={select:e=>h(r=>O({message:e.message,choices:e.choices,default:e.default},r),{...y,whenHeadless:"refuse"}),checkbox:e=>h(r=>N({message:e.message,choices:e.choices},r),{...y,whenHeadless:"refuse"}),confirm:e=>h(r=>E({message:e.message,default:e.default},r),{...y,whenHeadless:"refuse"})},V=(e,r)=>{let a=new Map;for(let[o,t]of Object.entries(e)){let n={path:o,localCapable:t.from.includes("local"),cloudCapable:t.from.includes("cloud"),default:t.default},s=a.get(t.packageName);s?(s.routes.push(n),s.localCapable=s.localCapable||n.localCapable,s.cloudCapable=s.cloudCapable||n.cloudCapable):a.set(t.packageName,{packageName:t.packageName,routes:[n],localCapable:n.localCapable,cloudCapable:n.cloudCapable,ownerApp:r.get(t.packageName)})}return[...a.values()]},K=async(e,r,a)=>{try{let o=(await B(e))?.proxy?.routes;return o?V(o,a):[]}catch(o){return u.warn(`\u26A0\uFE0F Skipping ${r}: its dev config failed to load \u2014 ${o instanceof Error?o.message:String(o)}`),[]}},_=async e=>{let r=k(e),a=w(e),o=new Map(r.map(c=>[c.packageName,c.name])),t=new Map(r.map(c=>[c.name,c.packageName])),n=new Set(a.map(c=>c.name)),s=new Set(r.map(c=>c.name)),i=[...new Set([...s,...n])].sort(),p=await Promise.all(i.map(async c=>{let f=n.has(c);return{name:c,hasApi:s.has(c),hasUi:f,apiPackage:t.get(c),backends:f?await K(z.join(e,"apps",c,"ui"),c,o):[],deployedUrlEnv:f?(await j(z.join(e,"apps",c,"ui")).catch(()=>{}))?.deployedUrlEnv:void 0}})),l=await b();return{apps:p,environments:Object.keys(l?.envs??{}).sort()}},q=e=>{let r=[];for(let a of e.apps){if(a.hasUi){let o=a.backends.flatMap(n=>n.routes.map(s=>s.path)),t=o.length>0?`frontend \u2014 proxies ${[...o].sort().join(", ")}`:"frontend";r.push({name:`${a.name}/ui`,value:`${a.name}/ui`,description:t})}a.hasApi&&!a.hasUi&&r.push({name:`${a.name}/api`,value:`${a.name}/api`,description:"backend"})}return r},I=e=>{let r={api:e.apps.filter(t=>t.hasApi).map(t=>t.name),ui:e.apps.filter(t=>t.hasUi).map(t=>t.name)},a={},o=new Map;for(let t of e.apps){t.apiPackage!=null&&(a[t.name]=t.apiPackage);for(let n of t.backends)for(let s of n.routes)o.set(`${t.name} ${s.path}`,n.packageName)}return{discovered:r,apiPkgByApp:a,routePkg:(t,n)=>o.get(`${t} ${n}`)}},L=(e,r)=>x(e,I(r)).map(a=>a.message),T="INFRA_KIT_DEV_WIZARD_ORCA",F=()=>g.env[T]==="1",H=async(e,r,a)=>{let o=new Map(r.apps.map(n=>[n.name,n])),t={};for(let n of a){let s=o.get(n.split("/")[0]);for(let i of s?.backends??[])for(let p of i.routes){if(!p.localCapable||!p.cloudCapable)continue;let l=await e.select({message:`\u{1F500} ${n} ${p.path} \u2192 local or cloud?`,choices:[{name:"local (this machine)",value:"local"},{name:"cloud",value:"cloud"}],default:p.default??"local"});t[`${n} ${p.path}`]=l}}return t},Z=(e,r,a)=>e.apps.find(o=>o.name===r)?.backends.flatMap(o=>o.routes).find(o=>o.path===a),G=(e,r)=>{let a=[];for(let[o,t]of Object.entries(e.presetDef.apps??{})){if(!o.endsWith("/ui")||!t.proxy)continue;let n=o.split("/")[0];for(let[s,i]of Object.entries(t.proxy)){let p=Z(r,n,s),l=p&&p.localCapable&&p.cloudCapable?"":" (only option)";a.push(` ${o} ${s} \u2192 ${i}${l}`)}}if(a.length!==0){u.info("Resolved routes:");for(let o of[...a].sort())u.info(o)}},J=async(e,r)=>{let{downloadEnvSecrets:a}=await import("./secrets-download-54WMD4IC.js"),o=await a(e);return new Map(r.flatMap(t=>{let n=o.get(t);return n===void 0?[]:[[t,n]]}))},Q=async(e,r,a,o)=>{let t=r.flatMap(s=>{let i=a.apps.find(p=>`${p.name}/ui`===s);return i?.deployedUrlEnv?[i.deployedUrlEnv]:[]}),n=t.length>0?await o(e,t):new Map;g.env[P]=e;for(let s of t){let i=n.get(s);i?g.env[s]=i:(delete g.env[s],u.warn(`\u2601\uFE0F "${e}" holds no ${s}; routes that go to the deployed app will fail until it does.`))}},X=async(e,r,a)=>{if(r.apps.length===0)return u.warn("No apps discovered to run."),null;let o=await e.checkbox({message:"\u{1F4E6} Which packages?",choices:q(r)});if(o.length===0)return u.warn("No packages selected."),null;let t=o.filter(d=>d.endsWith("/ui")),n=await H(e,r,t),s=await e.confirm({message:"\u{1F440} Rebuild & restart on save (watch)?",default:!0}),i=F()?await e.confirm({message:"\u{1F9E9} Run each app in its own Orca pane?",default:!1}):!1,p={targets:o,sources:n,watch:s,orca:i},l=W(p,r);if(l.anyCloudRoute){if(r.environments.length===0)return u.warn("\u2601\uFE0F This selection routes to a cloud environment, but no environment token is loaded."),u.warn(" Run `infra-kit env-load` to add one, then re-run the wizard."),null;p.env=await e.select({message:"\u2601\uFE0F Point cloud routes at which environment?",choices:r.environments.map(d=>({name:d,value:d}))}),await Q(p.env,t,r,a)}let c=L(l.presetDef,r);if(c.length>0){u.warn("\u26A0\uFE0F Proxy audit found issues with this selection:");for(let d of c)u.warn(` \u2022 ${d}`);return null}G(l,r),Y(l,p);let f=l.targetKeys.filter(d=>d.endsWith("/api")).map(d=>d.split("/")[0]);return i&&f.length>0?{include:f,presetDef:l.presetDef,watch:s,orca:!0}:(i&&u.info("\u2139\uFE0F Orca needs at least one local backend (panes are backend-only) \u2014 running in-process instead."),{presetDef:l.presetDef,watch:s,orca:!1})},Y=(e,r)=>{m.setInteractive();let a=M(e,r);m.addOption(a.flags,!0),m.print()},ee=async(e,r,a=J)=>X(e,r,a),he=async(e=U,r=v(g.cwd()))=>ee(e,await _(r));export{T as WIZARD_ORCA_VAR,L as auditManualPlan,U as defaultPrompts,_ as gatherWizardModel,K as loadBackends,he as runDevWizard,ee as runWizardFlow};
2
+ //# sourceMappingURL=dev-wizard-run-C6FND2PR.js.map
@@ -1,2 +1,2 @@
1
- import{g as a,h as b,i as c,j as d,k as e,l as f,m as g,n as h}from"./chunk-3DAG53TI.js";import"./chunk-NJ22P2UB.js";import"./chunk-DVMV3WJZ.js";import"./chunk-MFAFQVTW.js";import"./chunk-D7C4NYQA.js";import"./chunk-RVMKL6T4.js";export{a as DOPPLER_MAX_OUTPUT_BYTES,g as assertDopplerOutputSize,e as assertTokenScope,b as buildDopplerChildEnv,d as downloadDopplerSecrets,c as downloadEnvSecrets,h as parseDopplerSecretsJson,f as translateDopplerDownloadError};
2
- //# sourceMappingURL=secrets-download-EQ7N4XMQ.js.map
1
+ import{g as a,h as b,i as c,j as d,k as e,l as f,m as g,n as h}from"./chunk-XCH7QCPN.js";import"./chunk-BRAJBMCQ.js";import"./chunk-DIGPYEFM.js";import"./chunk-MFAFQVTW.js";import"./chunk-CHFSRDQE.js";import"./chunk-RVMKL6T4.js";export{a as DOPPLER_MAX_OUTPUT_BYTES,g as assertDopplerOutputSize,e as assertTokenScope,b as buildDopplerChildEnv,d as downloadDopplerSecrets,c as downloadEnvSecrets,h as parseDopplerSecretsJson,f as translateDopplerDownloadError};
2
+ //# sourceMappingURL=secrets-download-54WMD4IC.js.map
@@ -1,2 +1,2 @@
1
- import{t as i}from"./chunk-HIGOL4H4.js";import"./chunk-REDCBY4O.js";import{a as t}from"./chunk-D7C4NYQA.js";import"./chunk-RVMKL6T4.js";import a from"node:fs";import o from"node:process";import{fileURLToPath as s}from"node:url";var m=r=>{let n=r.indexOf("--parent-pid");if(n===-1)return;let e=Number(r[n+1]);return Number.isInteger(e)&&e>0?e:void 0},p=()=>a.realpathSync(s(new URL("./cli.js",import.meta.url))),d=async()=>{await i(t.version,{selfRealPath:p(),parentPid:m(o.argv)})};d().catch(()=>{o.exitCode=0});
1
+ import{t as i}from"./chunk-HIGOL4H4.js";import"./chunk-REDCBY4O.js";import{a as t}from"./chunk-CHFSRDQE.js";import"./chunk-RVMKL6T4.js";import a from"node:fs";import o from"node:process";import{fileURLToPath as s}from"node:url";var m=r=>{let n=r.indexOf("--parent-pid");if(n===-1)return;let e=Number(r[n+1]);return Number.isInteger(e)&&e>0?e:void 0},p=()=>a.realpathSync(s(new URL("./cli.js",import.meta.url))),d=async()=>{await i(t.version,{selfRealPath:p(),parentPid:m(o.argv)})};d().catch(()=>{o.exitCode=0});
2
2
  //# sourceMappingURL=update-check.js.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "infra-kit",
3
3
  "type": "module",
4
- "version": "0.44.0",
4
+ "version": "0.45.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/ArthurSaenz/infra-kit.git",
@@ -25,7 +25,7 @@
25
25
  "@inquirer/input": "^5.1.9",
26
26
  "@inquirer/password": "^5.2.5",
27
27
  "@inquirer/select": "^5.2.8",
28
- "@slip-stream-kit/config": "^0.44.0",
28
+ "@slip-stream-kit/config": "^0.45.0",
29
29
  "chalk": "^6.0.1",
30
30
  "chokidar": "^6.0.0",
31
31
  "commander": "^15.0.0",
@@ -40,7 +40,7 @@
40
40
  "zx": "^8.8.5"
41
41
  },
42
42
  "devDependencies": {
43
- "@slip-stream-kit/eslint-plugin": "0.44.0",
43
+ "@slip-stream-kit/eslint-plugin": "0.45.0",
44
44
  "@types/aws-lambda": "^8.10.164",
45
45
  "@types/react": "19.3.0",
46
46
  "@wl/eslint-config": "0.1.0",