infra-kit 0.3.14 → 0.3.15

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.
Files changed (35) hide show
  1. package/dist/chunk-KATIE633.js +247 -0
  2. package/dist/chunk-KATIE633.js.map +7 -0
  3. package/dist/chunk-MKMT6KQT.js +10 -0
  4. package/dist/chunk-MKMT6KQT.js.map +7 -0
  5. package/dist/chunk-OKO3DKIM.js +7 -0
  6. package/dist/{chunk-QLAQ7F4M.js.map → chunk-OKO3DKIM.js.map} +4 -4
  7. package/dist/{chunk-RVTI3AL2.js → chunk-VDBJ73LS.js} +5 -5
  8. package/dist/chunk-VDBJ73LS.js.map +7 -0
  9. package/dist/{chunk-4EPUAY73.js → chunk-VFU2USJG.js} +2 -2
  10. package/dist/{chunk-4EPUAY73.js.map → chunk-VFU2USJG.js.map} +2 -2
  11. package/dist/chunk-XR6HR4LL.js +6 -0
  12. package/dist/{chunk-SSBYKOHY.js.map → chunk-XR6HR4LL.js.map} +4 -4
  13. package/dist/cli.js +9 -9
  14. package/dist/cli.js.map +3 -3
  15. package/dist/dev-server.js +24 -32
  16. package/dist/dev-server.js.map +4 -4
  17. package/dist/dev-wizard-run-AU7SZJV7.js +2 -0
  18. package/dist/{dev-wizard-run-XM5L23UP.js.map → dev-wizard-run-AU7SZJV7.js.map} +1 -1
  19. package/dist/mcp.js +1 -1
  20. package/dist/mcp.js.map +4 -4
  21. package/dist/persistent-ink-dev-ui-QNFTO2B2.js +2 -0
  22. package/dist/persistent-ink-dev-ui-QNFTO2B2.js.map +7 -0
  23. package/dist/update-check.js +1 -1
  24. package/package.json +4 -2
  25. package/readme.md +1 -1
  26. package/dist/chunk-KSSGYYS2.js +0 -238
  27. package/dist/chunk-KSSGYYS2.js.map +0 -7
  28. package/dist/chunk-QLAQ7F4M.js +0 -7
  29. package/dist/chunk-RVTI3AL2.js.map +0 -7
  30. package/dist/chunk-SHFPI4QA.js +0 -2
  31. package/dist/chunk-SHFPI4QA.js.map +0 -7
  32. package/dist/chunk-SSBYKOHY.js +0 -4
  33. package/dist/dev-wizard-run-XM5L23UP.js +0 -2
  34. package/dist/persistent-ink-dev-ui-PLLSRSGL.js +0 -2
  35. package/dist/persistent-ink-dev-ui-PLLSRSGL.js.map +0 -7
package/dist/cli.js CHANGED
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env node
2
- import{$ as Ft,A as ft,B as gt,C as ht,D as oe,E as vt,F as I,G as d,H as yt,I as wt,J as St,K as kt,L as Rt,M as Et,N as xt,O as Tt,P as bt,Q as At,R as Pt,S as re,T as Ct,U as It,V as Nt,W as Lt,X as _t,Y as Dt,Z as Ot,_ as $t,a as D,b as Oe,ba as Mt,c as $e,ca as jt,da as qt,e as je,f as Ge,g as qe,h as O,i as Qe,j,k as Ze,l as et,m as tt,n as ot,o as rt,p as it,q as at,r as st,s as ee,t as ct,u as lt,v as te,w as mt,x as dt,y as ut,z as pt}from"./chunk-KSSGYYS2.js";import{u as ne}from"./chunk-SHFPI4QA.js";import{a as U,b as Ut,c as G,d as Gt,e as A,f as ie,g as ae,h as se}from"./chunk-YDW6324A.js";import{a as nt}from"./chunk-4EPUAY73.js";import{a as Fe,b as Me}from"./chunk-LKKKDB6V.js";import{b as Ue,c as T,d as h,e as F,f as Ye,g as ze,h as Xe,i as b,j as M}from"./chunk-QLAQ7F4M.js";import{B as l,W as Q,X as _e,Z as De,a as Ne,r as Le}from"./chunk-SSBYKOHY.js";import{a as $,b as Ve,d as We,f as Je,g as Ke,j as Z,k as Be,n as v,q as He}from"./chunk-CHETBZ6M.js";import"./chunk-X46DP23W.js";import on,{Separator as To}from"@inquirer/select";import{realpathSync as rn}from"node:fs";import g from"node:process";import{fileURLToPath as Ao}from"node:url";var Co=(e,t)=>{let o=e,r;for(let n of t){if(r=o.find(a=>a.name()===n),!r)return;o=r.commands}return r},Vt=e=>$t.flatMap(({key:t,label:o})=>Mt(t).flatMap(r=>{let n=Co(e,r.groupPath);return n?[{name:r.groupPath.join(" "),description:n.description(),group:o}]:[]}));import{Command as dr}from"commander";import z from"node:process";import Wt from"node:process";import{$ as Io}from"zx";var ce=async()=>{let e=await Q(),t=await Promise.all([{label:"project (committed)",path:e.main},{label:"user global",path:e.userGlobal},{label:"user project",path:e.userProject}].map(async s=>({...s,exists:await T(s.path)}))),o=t.at(-1)?.exists===!0,r=await mt(e.userProject,o),n=o?dt(r):"";l.info(`Project name: ${e.projectName}
2
+ import{$ as Ft,A as ft,B as gt,C as ht,D as oe,E as vt,F as I,G as d,H as yt,I as wt,J as St,K as kt,L as Rt,M as Et,N as xt,O as bt,P as Tt,Q as At,R as Ct,S as Pt,T as re,U as It,V as Nt,W as Lt,X as _t,Y as Dt,Z as Ot,_ as $t,a as O,aa as Mt,b as Oe,c as $e,ca as jt,da as Ut,e as je,ea as Vt,f as Ge,g as qe,h as $,i as Qe,j as U,k as Ze,l as et,m as tt,n as ot,o as rt,p as it,q as at,r as st,s as ee,t as ct,u as lt,v as te,w as mt,x as dt,y as ut,z as pt}from"./chunk-KATIE633.js";import{y as ne}from"./chunk-MKMT6KQT.js";import{a as G,b as Gt,c as q,d as qt,e as A,f as ie,g as ae,h as se}from"./chunk-YDW6324A.js";import{a as nt}from"./chunk-VFU2USJG.js";import{a as Fe,b as Me}from"./chunk-LKKKDB6V.js";import{b as Ue,c as b,d as h,e as M,f as Ye,g as ze,h as Xe,i as T,k as j}from"./chunk-OKO3DKIM.js";import{J as l,a as Ne,ca as Q,da as _e,fa as De,r as Le}from"./chunk-XR6HR4LL.js";import{a as F,b as Ve,d as We,f as Je,g as Be,j as Z,k as Ke,n as v,q as He}from"./chunk-CHETBZ6M.js";import"./chunk-X46DP23W.js";import rn,{Separator as To}from"@inquirer/select";import{realpathSync as nn}from"node:fs";import g from"node:process";import{fileURLToPath as Co}from"node:url";var Io=(e,t)=>{let o=e,r;for(let n of t){if(r=o.find(a=>a.name()===n),!r)return;o=r.commands}return r},Wt=e=>Ft.flatMap(({key:t,label:o})=>jt(t).flatMap(r=>{let n=Io(e,r.groupPath);return n?[{name:r.groupPath.join(" "),description:n.description(),group:o}]:[]}));import{Command as ur}from"commander";import D from"node:process";import Jt from"node:process";import{$ as No}from"zx";var ce=async()=>{let e=await Q(),t=await Promise.all([{label:"project (committed)",path:e.main},{label:"user global",path:e.userGlobal},{label:"user project",path:e.userProject}].map(async s=>({...s,exists:await b(s.path)}))),o=t.at(-1)?.exists===!0,r=await mt(e.userProject,o),n=o?dt(r):"";l.info(`Project name: ${e.projectName}
3
3
  `),l.info(`Config merge chain (later overrides earlier):
4
- `);for(let s of t){let i=s.exists?" [\u2713]":" [ ]",c=s.path===e.userProject&&n!==""?` ${n}`:"";l.info(`${i} ${s.label.padEnd(22)} ${h(s.path)}${c}`)}let a={projectName:e.projectName,layers:t.map(s=>({label:s.label,path:s.path,exists:s.exists})),hasOverrides:r.hasOverrides,overrideKeys:r.overrideKeys};return{content:[{type:"text",text:JSON.stringify(a,null,2)}],structuredContent:a}},le=async()=>{let e=await Q(),t=Wt.env.EDITOR||Wt.env.VISUAL||"vi",o=await it(e);o.createdConfig&&l.info(at(o)),l.info(`Opening ${h(e.userProject)} in ${t}`),await Io({stdio:"inherit"})`${t} ${e.userProject}`,De();let r={path:e.userProject,editor:t};return{content:[{type:"text",text:JSON.stringify(r,null,2)}],structuredContent:r}};var me=e=>{if(typeof e!="object"||e===null)return null;let{config:t,reason:o,at:r}=e;return typeof t!="string"||t.length===0||typeof o!="string"||typeof r!="number"||!Number.isFinite(r)?null:{config:t,reason:o,at:r}},N=e=>`infra-kit: Doppler token for env "${e}" is missing, invalid, or unreadable \u2014 env auto-load is not running. Fix: run \`infra-kit env-token-set ${e}\` (mint one at https://dashboard.doppler.com under this config's Access tab).`;import f from"node:fs";import y from"node:path";import L from"node:process";var No="autoload-warn-fail.flag",de="autoload-warn-auth-fail.flag",ue="autoload-fail.flag",pe="autoload-auth-fail.json",Lo=3e4,Kt=async(e=!0)=>{let t;try{t=await _e()}catch{return null}let o=t.envAutoLoad;if(!o)return null;let r={trigger:o.trigger,config:o.config,project:t.envManagement.config.name};try{if(await Qe(o.config))return r}catch{return r}return Ht({config:o.config,reason:`No Doppler service token for env "${o.config}"`,at:Date.now()}),e&&q(N(o.config),de),null},Bt=e=>{let{trigger:t,expectedTrigger:o,targetConfig:r,targetProject:n,env:a,force:s}=e;return t!==o||!a.session||a.cleared||a.currentConfig&&!a.autoLoadedMarker||!s&&a.autoLoadedMarker&&a.currentConfig===r&&a.currentProject===n?"skip":"load"},_=async({expectedTrigger:e,projectDir:t,force:o,isAuthFailure:r=Ue})=>{let n=e==="cli-invocation";n&&V();let a=null;try{if(a=await Kt(n),!a||Bt({trigger:a.trigger,expectedTrigger:e,targetConfig:a.config,targetProject:a.project,env:Oo(),force:o})==="skip"||Jt()||Mo())return null;let i=$o(),c=await Ze({config:a.config,autoLoaded:!0,projectDir:t,beforeWrite:()=>!Jt()&&!Fo(i)});return c?(Uo(),Do(),c.filePath):null}catch(s){let i=s.message,c=r(s);return jo(),c&&a&&Ht({config:a.config,reason:i,at:Date.now()}),n&&c&&a?(q(N(a.config),de),l.debug(`env auto-load auth failure: ${i}`)):n?q(`infra-kit: env auto-load failed \u2014 ${i} (will retry later)`,No):l.debug(`env auto-load skipped: ${i}`),null}},V=()=>{let e=_o();e&&(q(N(e.config),de),l.debug(`env auto-load auth failure (recorded ${new Date(e.at).toISOString()}): ${e.reason}`))},_o=()=>{try{let e=f.readFileSync(y.join(v(),pe),"utf-8");return me(JSON.parse(e))}catch{return null}},Ht=e=>{try{let t=v();f.mkdirSync(t,{recursive:!0,mode:448}),He(y.join(t,pe),JSON.stringify(e),384)}catch{}},Do=()=>{try{f.rmSync(y.join(v(),pe),{force:!0})}catch{}},Oo=()=>({session:L.env[We],cleared:L.env[Be],currentConfig:L.env[Je],currentProject:L.env[Ke],autoLoadedMarker:L.env[Z]}),$o=()=>{try{return f.statSync(y.join(v(),$)).mtimeMs}catch{return null}},Fo=e=>{try{let t=y.join(v(),$);if(!f.existsSync(t))return!1;let o=f.statSync(t).mtimeMs;return e!==null&&o<=e?!1:new RegExp(`^unset ${Z}$`,"m").test(f.readFileSync(t,"utf-8"))}catch{return!1}},Jt=()=>{try{let e=v(),t=y.join(e,Ve);if(!f.existsSync(t))return!1;let o=y.join(e,$);return f.existsSync(o)?f.statSync(t).mtimeMs>=f.statSync(o).mtimeMs:!0}catch{return!1}},Mo=()=>{try{let e=y.join(v(),ue);return f.existsSync(e)?Date.now()-f.statSync(e).mtimeMs<Lo:!1}catch{return!1}},jo=()=>{try{let e=v();f.mkdirSync(e,{recursive:!0,mode:448}),f.writeFileSync(y.join(e,ue),"",{mode:384})}catch{}},Uo=()=>{try{f.rmSync(y.join(v(),ue),{force:!0})}catch{}},q=(e,t)=>{try{let o=v(),r=y.join(o,t);if(f.existsSync(r))return;f.mkdirSync(o,{recursive:!0,mode:448}),f.writeFileSync(r,"",{mode:384})}catch{}l.warn(e)};var fe=async({projectDir:e}={})=>{await _({expectedTrigger:"shell-startup",projectDir:e,force:!0})};var Yt="https://dashboard.doppler.com/workplace/projects",Go=(e,t)=>["Removing it locally does NOT revoke it \u2014 the token still works anywhere else it is stored.",`Revoke it in Doppler (project "${e}", config "${t}"): ${Yt}/${e}`],ge=async({env:e})=>{let o=!!(await Ye())?.envs[e];await Xe(e);let r=await j(),n=await O(),a=await F();o?l.info(`Removed the "${e}" service token from ${h(a)}.`):l.info(`No "${e}" service token was stored in ${h(a)} \u2014 nothing to remove.`),r.length>0&&l.info(`Purged ${r.length} warm cache(s) across this repo's worktrees.`);for(let i of Go(n,e))l.warn(i);let s={env:e,removed:o,storePath:a,warmCachesPurged:r.length,revokeUrl:`${Yt}/${n}`};return{content:D(JSON.stringify(s,null,2)),structuredContent:s}};import qo from"@inquirer/password";import J from"node:process";import{$ as W}from"zx";var Vo=async({stdin:e,fromEnv:t})=>{if(e)return{token:await Wo(),source:"stdin"};if(t){let r=J.env[t];if(!r)throw new Error(`${t} is not set (or is empty) \u2014 nothing to store.`);return{token:r,source:"env"}}return b.setInteractive(),{token:(await M(r=>qo({message:"Paste the Doppler service token (input is hidden)",mask:!0},r),{output:J.stderr})).trim(),source:"prompt"}},Wo=async()=>{let e=[];J.stdin.setEncoding("utf8");for await(let t of J.stdin)e.push(t);return e.join("").trim()},he="DOPPLER_CONFIG",Jo=3e4,Ko=async(e,t,o)=>{let r=W.quiet;W.quiet=!0;let n;try{n=(await W({env:tt(e)})`doppler secrets download --no-file --format json --project ${t} --config ${o}`.timeout(Jo)).stdout}catch(a){throw Bo(a,o)}finally{W.quiet=r}return rt(n)},Bo=(e,t)=>{let o=Ne(e)??(e instanceof Error?e.message:String(e));if(Ge(o)!=="auth")return e instanceof Error?e:new Error(String(e));let r=qe(o)==="mis-scoped"?"it is scoped to a DIFFERENT config (pasting another environment's token here is the mistake this check exists to catch).":"it is invalid or has been revoked.";return new Error([`Doppler refused this token for config "${t}" \u2014 ${r}`,"Nothing was written. Issue a service token scoped to that config and try again."].join(`
5
- `))},Ho=e=>[`Could not verify this token's scope: the Doppler payload for "${e}" carries no ${he}.`,"Refusing to store a credential whose scope is unknown (a token for the wrong environment would load","the wrong secrets into every shell).","Re-run with --force if you are certain the token is scoped to this config."].join(`
6
- `),ve=async({env:e,stdin:t,fromEnv:o,force:r})=>{let n=await O(),{token:a,source:s}=await Vo({stdin:t,fromEnv:o});if(!a)throw new Error("No token provided \u2014 nothing was written.");let i=await Ko(a,n,e);ot(i,e);let c=i.some(([k])=>k===he);if(!c&&!r)throw new Error(Ho(e));await ze(e,a);let m=await j(),u=await F();l.info(`Stored the "${e}" service token (${oe(a)}) in ${h(u)} (mode 0600).`),c||l.warn(`Scope was NOT verified (no ${he} in the payload) \u2014 written because --force was given.`),m.length>0&&l.info(`Purged ${m.length} warm cache(s) so the next shell cannot serve secrets fetched with an old token.`);let p={env:e,source:s,redactedToken:oe(a),storePath:u,scopeVerified:c,warmCachesPurged:m.length};return b.print(),{content:D(JSON.stringify(p,null,2)),structuredContent:p}};import{spawn as Yo}from"node:child_process";import K from"node:process";import{fileURLToPath as zo}from"node:url";var Xo=["SIGINT","SIGTERM"],zt=()=>zo(new URL("./mcp.js",import.meta.url)),ye=(e={})=>{let t=e.spawn??Yo,o=e.exit??(s=>K.exit(s)),r=e.env??K.env,n=e.onError??(s=>l.error(s)),a=t(K.execPath,[zt()],{stdio:"inherit",env:Fe(r)});a.on("error",s=>{n(`failed to launch the MCP server: ${s.message}`),o(1)}),Xo.forEach(s=>{K.on(s,()=>{a.kill(s)})}),a.on("exit",(s,i)=>{o(i?1:s??1)})};import{spawnSync as Qo}from"node:child_process";import{realpathSync as Zo}from"node:fs";import{homedir as er}from"node:os";import we from"node:process";import{fileURLToPath as tr}from"node:url";var or=()=>Zo(tr(import.meta.url)),rr=(e,t,o,r)=>e.error?(o(`${t} not found on PATH: ${e.error.message}`),r(1)):e.signal?(o(`update terminated by signal ${e.signal}`),r(1)):r(e.status??1),Se=({dryRun:e},t={})=>{let o=t.spawnSync??Qo,r=t.print??(R=>l.info(R)),n=t.exit??(R=>we.exit(R)),a=t.env??we.env,s=t.selfRealPath??or(),i=t.lazyNpmRoot??Gt,{manager:c,updateCommand:m,canSelfSpawn:u}=Ut({selfRealPath:s,env:a,realpath:A,lazyNpmRoot:i}),p=U(m);if(e){r(`Detected install manager: ${c}`),r(`Would run: ${p}`);return}if(!u){r(`Detected install manager: ${c}`),r(`Run this yourself: ${p}`),r(c==="homebrew"?"Not run for you: Homebrew manages this install; running a package manager would create a split-brain install.":"Not run for you: the install location is unrecognized, so the command above is a guess \u2014 a guessed global install is worse than a printed one.");return}let k=o(m[0],m.slice(1),{stdio:"inherit",shell:we.platform==="win32",cwd:er(),env:Me(a)});rr(k,c,r,n)};import{VENDOR_CONFIG_FILE as Qt}from"@slip-stream-kit/config/internal";import ke from"node:fs/promises";import Re from"node:path";import Xt from"node:process";import{pathToFileURL as nr}from"node:url";var Zt="~/projects",Ee=async(e={})=>{if(e.init){await ar(e.cwd);return}await ir()},ir=async()=>{let e=ee(),t=await T(e);if(l.info(`Factory config: ${h(e)} ${t?"[\u2713]":"[ ]"}`),!t){l.info("\nNot found \u2014 run `infra-kit vendor config --init` to scaffold it."),Xt.exitCode=1;return}let{workspaceDir:o,targets:r}=await lt(),n=ct(o),a=await T(n);l.info(`workspaceDir: ${o} (resolved: ${n}) ${a?"[\u2713 exists]":"[ ] not found"}`),l.info("Targets:");let s=a;for(let i of r){let c=Re.join(n,i),m=await T(c);m||(s=!1);let u=m?"[\u2713]":"[ ]",p=m?"":" (not found \u2014 clone or remove)";l.info(` ${u} ${i} ${h(c)}${p}`)}s||(Xt.exitCode=1)},ar=async e=>{let t=ee();if(await T(t)){l.info(`Factory config already exists at ${h(t)} \u2014 leaving it untouched.`);return}let o=e??await Le(),r=await sr(o);await ke.mkdir(Re.dirname(t),{recursive:!0}),await ke.writeFile(t,cr(r),"utf-8"),l.info(`\u2713 Created ${h(t)}`),r.length>0&&l.info(` Seeded ${r.length} target(s) from the source ${Qt}.`),l.info(` Edit \`workspaceDir\` (placeholder: ${Zt}) to point at where your repos live.`),r.length===0&&l.info(" Add at least one repo name to `targets` before running vendor sync/manifest/diff.")},sr=async e=>{try{let t=Re.join(e,Qt),o=await ke.stat(t),a=(await import(`${nr(t).href}?mtime=${Number(o.mtimeMs)}`)).default,s=typeof a=="function"?await a():a;if(s&&typeof s=="object"&&"targets"in s){let i=s.targets;if(Array.isArray(i)&&i.every(c=>typeof c=="string"))return i}}catch{}return[]},cr=e=>`${JSON.stringify({workspaceDir:Zt,targets:e},null,2)}
7
- `;var B=(e,t=!0)=>({line:e,reproducible:t});import H from"node:fs";import lr from"node:os";import mr from"node:path";import ro from"node:process";var Y="INFRA_KIT_SESSION_REPORT",xe=null,eo=!1,to=[],no=(e=ro.env)=>{eo||(xe=e[Y]??null,eo=!0,delete e[Y])};var io=(e,t)=>{if(!xe)return;let o=e.summary??(to.length>0?[...to]:void 0),r={...e,...o?{summary:o}:{}},n=t?.write??((a,s)=>{H.writeFileSync(a,s)});try{n(xe,JSON.stringify(r))}catch{}},oo=0,ao=e=>{let t=e?.tmpdir?.()??lr.tmpdir(),o=e?.pid??ro.pid;return oo+=1,mr.join(t,`infra-kit-session-${o}-${oo}.json`)},so=(e,t)=>{if(!(t?.exists??(s=>H.existsSync(s)))(e))return null;let r=t?.read??(s=>H.readFileSync(s,"utf-8")),n=t?.unlink??(s=>H.unlinkSync(s)),a;try{a=r(e)}catch{return null}finally{try{n(e)}catch{}}try{return JSON.parse(a)}catch{return null}};var ur=(e,t)=>[...t,e],co=(e,t)=>{if(!(typeof e>"u")){if(e===!0)return"workspace";if(e===!1)return"none";if(typeof e=="string"&&re.includes(e))return e;throw new Error(`Invalid ${t} value "${String(e)}". Expected one of: ${re.join(", ")}.`)}},pr=e=>e.description("Merge dev branch into every release branch").option("-a, --all","Select all active release branches").option("-y, --yes","Skip confirmation prompt").action(async t=>{d(await wt({all:t.all,confirmedCommand:t.yes}))}),fr=e=>e.description("List all release branches").action(async()=>{d(await Et())}),gr=e=>e.description("Create one or more release branches (each entry can mix regular/hotfix and its own description)").option("-r, --release <spec>",'Release spec "<version|next|name>[:type[:description]]" (repeatable). The token is a semver ("1.2.5"), the literal "next", or a kebab-case name ("checkout-redesign"). Type is regular|hotfix (default regular). Examples: "1.2.5", "1.2.5:hotfix", "next:regular:Holiday backend", "checkout-redesign:regular:Q3 redesign".',ur,[]).option("-y, --yes","Skip confirmation prompt").action(async t=>{let r=t.release.map(bt),n=r.length>0?r:void 0;d(await At({releases:n,confirmedCommand:t.yes}))}),hr=e=>e.description("Edit a release's description in Jira and in the matching GitHub PR body").option("-v, --version <version>","Release version (e.g. 1.2.5) or release name (e.g. checkout-redesign)").option("-d, --description <description>",'New description (use "" to clear)').option("-y, --yes","Skip confirmation prompt").action(async t=>{d(await Pt({version:t.version,description:t.description,confirmedCommand:t.yes}))}),vr=e=>e.description("Deploy any release branch to any environment").option("-v, --version <version>",'Version (e.g. 1.2.5) or release name (e.g. checkout-redesign) to deploy; "dev" deploys from the dev branch').option("-e, --env <env>","Specify the environment to deploy to, e.g. dev").option("--skip-terraform","Skip terraform deployment step").option("-y, --yes","Skip confirmation prompt").action(async t=>{d(await kt({version:t.version,env:t.env,skipTerraform:t.skipTerraform,confirmedCommand:t.yes}))}),yr=e=>e.description("Deploy selected services from release branch to any environment").option("-v, --version <version>",'Version (e.g. 1.2.5) or release name (e.g. checkout-redesign) to deploy; "dev" deploys from the dev branch').option("-e, --env <env>","Specify the environment to deploy to, e.g. dev").option("-s, --services <services...>","Specify services to deploy, e.g. client-be client-fe").option("--skip-terraform","Skip terraform deployment step").option("-y, --yes","Skip confirmation prompt").action(async t=>{d(await Rt({version:t.version,env:t.env,services:t.services,skipTerraform:t.skipTerraform,confirmedCommand:t.yes}))}),wr=e=>e.description("Release a new version to production").option("-v, --version <version>","Version (e.g. 1.2.5) or release name (e.g. checkout-redesign) to deliver").option("-y, --yes","Skip confirmation prompt").action(async t=>{d(await St({version:t.version,confirmedCommand:t.yes}))}),Sr=e=>e.description("Remove release worktrees whose PRs are no longer open").option("-y, --yes","Skip confirmation prompt").action(async t=>{d(await Ot({confirmedCommand:t.yes}))}),kr=e=>e.description("Add git worktrees for release branches").option("-y, --yes","Skip confirmation prompt").option("-a, --all","Select all active release branches").option("-v, --versions <versions>","Specify versions by comma, e.g. 1.2.5, 1.2.6").option("-i, --ide [mode]","Editor mode for created worktrees: workspace (default) | none").option("--no-ide","Skip the editor (alias for --ide none)").option("-c, --cursor [mode]","Deprecated alias for --ide").option("--no-cursor","Deprecated alias for --no-ide").option("-g, --github-desktop","Open created worktrees in GitHub Desktop").option("--no-github-desktop","Skip GitHub Desktop prompt").option("-m, --cmux","Open created worktrees in cmux (3-pane layout)").option("--no-cmux","Skip cmux prompt").action(async t=>{let o=co(t.ide,"--ide")??co(t.cursor,"--cursor");d(await Lt({confirmedCommand:t.yes,all:t.all,versions:t.versions,ide:o,githubDesktop:t.githubDesktop,cmux:t.cmux}))}),Rr=e=>e.description("List all git worktrees with detailed information").action(async()=>{d(await _t())}),Er=e=>e.description("Remove git worktrees for release branches").option("-y, --yes","Skip confirmation prompt").option("-a, --all","Select all active release branches").option("-v, --versions <versions>","Specify versions by comma, e.g. 1.2.5, 1.2.6").action(async t=>{d(await Dt({confirmedCommand:t.yes,all:t.all,versions:t.versions}))}),xr=e=>e.description("Reopen editor + cmux windows for every active worktree in the current project (additive, idempotent)").option("--all","Reopen across every discovered infra-kit project (Stage 3 \u2014 not yet implemented)").option("--project <names...>","Restrict --all to these project names").option("--root <paths...>","Discovery roots for --all (repeatable)").option("--release-only","Restrict to release worktrees (reproduces the legacy worktrees-reload scope)").option("--force","Close each cmux workspace first, then reopen (the legacy worktrees-reload behaviour)").option("--dry-run","Print the plan (paths + cmux titles) and spawn nothing").action(async t=>{d(await Ct({all:t.all,project:t.project,root:t.root,releaseOnly:t.releaseOnly,force:t.force,dryRun:t.dryRun}))}),Tr=e=>e.description("Show the machine-local factory config (~/.infra-kit/vendor.json) or scaffold it with --init").option("--init","Scaffold ~/.infra-kit/vendor.json (skips if it already exists)").action(async t=>{d(await Ee({init:t.init}))}),br=e=>e.description("Verify vendor/ matches vendor/.sync-manifest.json (self-contained; for any consumer repo)").action(async()=>{let t=await It();d(t),t.structuredContent.ok||(z.exitCode=1)}),Ar=e=>e.description("Show the resolved config merge chain and file paths").action(async()=>{d(await ce())}),Pr=e=>e.description("Open the user-scope per-project override file in $EDITOR").action(async()=>{d(await le())}),Cr=new Set(["init","doctor","version","dev","self-update","mcp"]),Ir=e=>e.startsWith("env-")||Cr.has(e),Nr=new Set(["env-autoload","mcp","version","self-update"]),X=e=>{let t=[];for(let o=e;o&&o.parent;o=o.parent)t.unshift(o.name());return t.join(" ")},Te=()=>{let e=new dr,t=e.command("release").description("Release management commands");pr(t.command("merge-dev")),fr(t.command("list")),gr(t.command("create")),hr(t.command("desc-edit")),vr(t.command("deploy-all")),yr(t.command("deploy-selected")),wr(t.command("deliver"));let o=e.command("worktrees").description("Git worktree management commands");kr(o.command("add")),Rr(o.command("list")),Er(o.command("remove")),Sr(o.command("sync")),xr(e.command("reopen"));let r=e.command("config").description("Manage infra-kit configuration files");Ar(r.command("path")),Pr(r.command("edit")),e.command("config-get").description("Print the fully merged infra-kit config (project + user-global + per-project override layers)").action(async()=>{d(await $e())});let n=e.command("local").description("Run deploys on this machine instead of dispatching CI"),a=i=>i.option("-e, --env <name>","Target environment (prompts when omitted)").option("-y, --yes","Skip the confirmation prompt").option("--dry-run","Resolve target, contract and commands without deploying").option("--print-env","Print the resolved build contract").option("--skip-preflight <check...>","Waive a named check (clean-tree, toolchain) \u2014 never env/account, and never clean-tree for a protected env");a(n.command("deploy-all")).description("Deploy every service enabled for the environment, from this machine").action(async i=>{d(await xt({env:i.env,yes:i.yes,dryRun:i.dryRun,printEnv:i.printEnv,skipPreflight:i.skipPreflight}))}),a(n.command("deploy-selected")).description("Deploy chosen services from this machine (prompts when --service is omitted)").option("-s, --service <name...>","Service name(s), as in deploy-<name>.sh").action(async i=>{d(await Tt({env:i.env,service:i.service,yes:i.yes,dryRun:i.dryRun,printEnv:i.printEnv,skipPreflight:i.skipPreflight}))}),e.command("audit").description("Audit against infra-kit.config.ts rules (--all for every package, --root for the monorepo root)").option("-a, --all","Audit every non-vendor workspace package").option("-r, --root","Audit the monorepo root (turbo pipeline + root commands)").action(async i=>{let c=await Oe({all:i.all,root:i.root});d(c),c.structuredContent.allPassed||(z.exitCode=1)});let s=e.command("vendor").description("Verify the mirrored vendor/ tree");return br(s.command("check")),Tr(s.command("config")),e.command("doctor").description("Check installation and authentication status of gh and doppler CLIs").option("--fix","Remove portless routes left behind by a dev-server that was killed (kill -9, OOM, force-quit). Refuses while a dev session is running, when a booting UI is indistinguishable from a dead route.").option("--ascii","Render the report with ASCII markers instead of unicode glyphs (check messages are unchanged)").action(async i=>{let c=await ut({fix:!!i.fix});I.enabled||pt(c.structuredContent.checks,{ascii:!!i.ascii}),d(c)}),e.command("self-update").description("Update this CLI using the package manager that installed it").option("--dry-run","Print the detected manager and the command that would run; install nothing").action(i=>{Se({dryRun:!!i.dryRun})}),e.command("mcp").description("Run the infra-kit MCP server (stdio transport)").action(()=>{ye()}),e.command("dev").description("Run local dev servers for a named devServersPresets preset (or all apps); api + ui").argument("[preset]","Named preset from devServersPresets (omit to run every app)").option("-w, --watch","Rebuild and restart on file save").option("--app <names>","Further narrow to these app folder names (comma-separated)").option("--target <keys>","Run exactly these <app>/api|<app>/ui packages (comma-separated); part-level, unlike --app").option("--cmux","Run each app in its own cmux pane (one workspace, N panes; falls back to single terminal if cmux is unavailable)").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)").option("--no-ui-health","Do not probe the frontends\u2019 liveness (vite\u2019s HMR ping); their rows carry no health dot (also: INFRA_KIT_NO_UI_HEALTH=1)").action(async(i,c)=>{let{runDevServerCli:m}=await import("./dev-server.js"),u=!!(z.stdout.isTTY&&z.stdin.isTTY);await m({...c,preset:i},u,I.enabled)}),e.command("dev-status").description("Show what `infra-kit dev` currently has running (reads dev-context fragments; starts nothing)").action(async()=>{d(await je())}),e.command("version").description("Print the installed infra-kit CLI version").action(async()=>{d(await Nt())}),e.command("env-status").description("Show which env is loaded in this session (local introspection; no Doppler call)").action(async()=>{d(await ht())}),e.command("env-list").description("List available Doppler configs for the detected project, and whether a service token resolves for each").action(async()=>{d(await gt())}),e.command("init").description("Inject shell integration into .zshrc and sync repo agent-instruction files").action(async()=>{d(await te())}),e.command("env-load").description("Load Doppler env vars for a config. Source the returned file path to apply.").option("-c, --config <config>","Environment config name to load (e.g. dev, arthur)").action(async i=>{d(await et({config:i.config}))}),e.command("env-clear").description("Clear loaded env vars. Source the returned file path to apply.").option("--purge","Also delete this project's warm cache outright (durable disable)").action(async i=>{d(await ft({purge:!!i.purge}))}),e.command("env-token-set").description("Store the Doppler service token for an env (masked prompt; validated against Doppler before writing)").argument("<env>","Environment / Doppler config the token is scoped to (e.g. dev)").option("--stdin","Read the token from stdin instead of prompting (e.g. from a password manager)").option("--from-env <var>","Read the token from the named environment variable (the NAME, never the value)").option("--force","Store even when the token\u2019s scope could not be verified. Never overrides a real mismatch.").action(async(i,c)=>{d(await ve({env:i,stdin:c.stdin,fromEnv:c.fromEnv,force:c.force}))}),e.command("env-token-list").description("Show which envs have a Doppler service token (redacted), and where it came from").option("--check","Also ask Doppler whether each token is valid and correctly scoped").action(async i=>{d(await vt({check:!!i.check}))}),e.command("env-token-remove").description("Delete an env\u2019s Doppler service token from the local store (does NOT revoke it in Doppler)").argument("<env>","Environment / Doppler config whose token to remove").action(async i=>{d(await ge({env:i}))}),e.command("env-autoload",{hidden:!0}).description("Internal: prime env for the shell-startup auto-load trigger").option("--project-dir <dir>","Canonical project dir for the warm-cache key (shell-startup only)").action(async i=>{await fe({projectDir:i.projectDir})}),e.commands.forEach(yt),e.hook("preAction",async(i,c)=>{b.start(X(c)),I.enabled=!!c.optsWithGlobals().json,I.enabled&&(l.level="warn"),Nr.has(X(c))||await st(),V(),Ir(c.name())||await _({expectedTrigger:"cli-invocation"})}),e.hook("postAction",(i,c)=>{let m=X(c);if(jt(m))return;let p=b.snapshot()?.formattedOptions??"",k=p?` ${p}`:"",R=`infra-kit ${m}${k}`;io({equivalent:B(R,!0)})}),e};var be=(e,t=" ")=>{let o=e.reduce((r,[n])=>Math.max(r,n.length),0);return e.map(([r,n])=>`${r.padEnd(o)}${t}${n}`)};import{chalkStderr as Ur}from"chalk";import{spawn as Gr}from"node:child_process";import S from"node:process";import{Chalk as Lr}from"chalk";var P=new Lr({level:1}),w={ok:"ok",findingsPlain:"completed with findings",failed:"failed",cancelled:"cancelled",findingsSuffix:"findings",sep:" \xB7 ",reproPrefix:"$ ",nonReproPrefix:"\u2248 ",envNotice:"Applies to your shell after you exit this session."},lo={ok:{unicode:"\u2713",ascii:"[ok]"},findings:{unicode:"\u26A0",ascii:"[!]"},failed:{unicode:"\u2717",ascii:"[x]"},cancelled:{unicode:"\u2298",ascii:"[-]"}},mo={unicode:"\u2500",ascii:"-"},_r=3,Ae=e=>e,Dr={ok:e=>P.green(e),findings:e=>P.yellow(e),failed:e=>P.red(e),cancelled:e=>P.gray(e)},po=e=>e?{dim:t=>P.dim(t),bold:t=>P.bold(t)}:{dim:Ae,bold:Ae},Or=(e,t)=>e?Dr[t]:Ae,uo=e=>[...e].length,fo=(e,t={})=>{let o=po(t.color===!0);return`${o.dim(w.reproPrefix.trim())} ${o.bold(e)}`},$r=e=>e<1e3?`${Math.round(e)}ms`:`${(e/1e3).toFixed(1)}s`,Fr=(e,t)=>e==="findings"?t!=null?`${t} ${w.findingsSuffix}`:w.findingsPlain:{ok:w.ok,failed:w.failed,cancelled:w.cancelled}[e],Mr=(e,t,o,r)=>{if(t==null)return"";let n=t-2-e;return n<_r?"":` ${r(o.repeat(n))}`},go=e=>{let t=e.color===!0,o=po(t),r=Or(t,e.outcome),n=e.ascii===!0,a=e.equivalent.reproducible?w.reproPrefix:w.nonReproPrefix,s=n?lo[e.outcome].ascii:lo[e.outcome].unicode,i=Fr(e.outcome,e.findingsCount),c=[$r(e.durationMs)],m=e.summary?.[0]?.split(`
8
- `)[0];m!=null&&m.length>0&&c.push(m);let u=`${s} ${i}`,p=`${w.sep}${c.join(w.sep)}`,k=uo(u)+uo(p),R=Mr(k,e.width,n?mo.ascii:mo.unicode,o.dim),x=[`${r(u)}${o.dim(p)}${R}`];return e.showEquivalent!==!1&&x.unshift(`${o.dim(a.trim())} ${o.bold(e.equivalent.line)}`),e.envNotice===!0&&x.push(o.dim(w.envNotice)),x.join(`
9
- `)};var jr=new Set([130,143]),ho=(e,t,o,r=!1)=>o?t!=null||e===0?"ok":"findings":r&&e!=null&&jr.has(e)||t==="SIGINT"||e===0?"cancelled":"failed";import vo from"node:process";var E={column:"\r",sgr:"\x1B[0m",cursor:"\x1B[?25h",wrap:"\x1B[?7h",saveCursor:"\x1B7",restoreCursor:"\x1B8",scrollRegion:"\x1B[r",primaryBuffer:"\x1B[?1049l"},yo=(e,t)=>{let o=t?.write??(a=>{vo.stderr.write(a)}),r=t?.stdin??vo.stdin,n=[E.saveCursor,E.scrollRegion,E.restoreCursor,E.column,E.sgr,E.cursor,E.wrap];e.entersAltScreen===!0&&n.push(E.primaryBuffer),o(n.join("")),r.isTTY===!0&&r.isRaw===!0&&r.setRawMode?.(!1)};var wo=e=>`infra-kit ${e.groupPath.join(" ")}`,qr=()=>{let e=S.stderr.columns;return e!=null&&e>0?e:void 0},Vr=e=>new Promise(t=>{e.on("exit",(o,r)=>{t({code:o,signal:r})}),e.on("error",()=>{t({code:1,signal:null})})}),Wr=async(e,t,o)=>{let r=ao(),n={...t.env,[Y]:r,INFRA_KIT_NO_AUTO_UPDATE:"1"},a=t.now(),s={code:1,signal:null};o();try{let p=t.spawn(S.execPath,[t.cliPath,...e.groupPath],{stdio:"inherit",env:n});s=await Vr(p)}catch{s={code:1,signal:null}}finally{t.resetTerminal({entersAltScreen:e.entersAltScreen})}let i=so(r),c=ho(s.code,s.signal,i!=null,e.longRunning),m=wo(e),u=i?.equivalent??B(m,!0);return go({equivalent:u,outcome:c,durationMs:t.now()-a,summary:i?.summary,envNotice:e.sessionEnvNotice,ascii:t.ascii,color:t.color,width:t.columns(),showEquivalent:!(u.reproducible&&u.line===m)})},Jr=1e3,Kr=(e,t)=>{let o=null,r=!1,n=()=>{if(e()){o=t.now();return}t.resetTerminal(),t.exit(0)},a=()=>{if(!e()){t.resetTerminal(),t.exit(0);return}o!=null&&t.now()-o<=Jr||(r=!0)},s=()=>{t.exit(129)},i=()=>{e()&&t.raise("SIGSTOP")};return t.register("SIGINT",n),t.register("SIGTERM",a),t.register("SIGHUP",s),t.register("SIGTSTP",i),{dispose:()=>{t.unregister("SIGINT",n),t.unregister("SIGTERM",a),t.unregister("SIGHUP",s),t.unregister("SIGTSTP",i)},childStarted:()=>{o=null},quitRequested:()=>r}},So=(e,t)=>!!(t.stdoutIsTTY&&t.stdinIsTTY&&t.stderrIsTTY&&e.TERM!=="dumb"&&!e.INFRA_KIT_NO_SESSION&&!e.INFRA_KIT_SESSION_REPORT),ko=async(e,t)=>{let o={spawn:t.spawn??Gr,now:t.now??(()=>Date.now()),env:t.env??S.env,cliPath:t.cliPath,ascii:t.ascii??!(S.stdout.isTTY&&S.env.TERM!=="dumb"),color:t.color??Ur.level>0,columns:t.columns??qr,resetTerminal:t.resetTerminal??(c=>{yo(c)})},r=t.write??(c=>S.stderr.write(c)),n=t.signals??{register:(c,m)=>{S.on(c,m)},unregister:(c,m)=>{S.off(c,m)},exit:c=>{S.exit(c)},raise:c=>{S.kill(S.pid,c)},now:()=>Date.now(),resetTerminal:()=>{o.resetTerminal({entersAltScreen:!1})}},a=!1,s={dispose:()=>{},childStarted:()=>{},quitRequested:()=>!1},i=t.installSignals===!1?s:Kr(()=>a,n);try{for(;;){if(i.quitRequested())return;a=!1;let c=await t.renderPalette(e);if(c==null)return;let m=t.resolveCommand(c);if(!m)continue;let u=fo(wo(m),{color:o.color});r(`
4
+ `);for(let s of t){let i=s.exists?" [\u2713]":" [ ]",c=s.path===e.userProject&&n!==""?` ${n}`:"";l.info(`${i} ${s.label.padEnd(22)} ${h(s.path)}${c}`)}let a={projectName:e.projectName,layers:t.map(s=>({label:s.label,path:s.path,exists:s.exists})),hasOverrides:r.hasOverrides,overrideKeys:r.overrideKeys};return{content:[{type:"text",text:JSON.stringify(a,null,2)}],structuredContent:a}},le=async()=>{let e=await Q(),t=Jt.env.EDITOR||Jt.env.VISUAL||"vi",o=await it(e);o.createdConfig&&l.info(at(o)),l.info(`Opening ${h(e.userProject)} in ${t}`),await No({stdio:"inherit"})`${t} ${e.userProject}`,De();let r={path:e.userProject,editor:t};return{content:[{type:"text",text:JSON.stringify(r,null,2)}],structuredContent:r}};var me=e=>{if(typeof e!="object"||e===null)return null;let{config:t,reason:o,at:r}=e;return typeof t!="string"||t.length===0||typeof o!="string"||typeof r!="number"||!Number.isFinite(r)?null:{config:t,reason:o,at:r}},N=e=>`infra-kit: Doppler token for env "${e}" is missing, invalid, or unreadable \u2014 env auto-load is not running. Fix: run \`infra-kit env-token-set ${e}\` (mint one at https://dashboard.doppler.com under this config's Access tab).`;import f from"node:fs";import y from"node:path";import L from"node:process";var Lo="autoload-warn-fail.flag",de="autoload-warn-auth-fail.flag",ue="autoload-fail.flag",pe="autoload-auth-fail.json",_o=3e4,Kt=async(e=!0)=>{let t;try{t=await _e()}catch{return null}let o=t.envAutoLoad;if(!o)return null;let r={trigger:o.trigger,config:o.config,project:t.envManagement.config.name};try{if(await Qe(o.config))return r}catch{return r}return Yt({config:o.config,reason:`No Doppler service token for env "${o.config}"`,at:Date.now()}),e&&V(N(o.config),de),null},Ht=e=>{let{trigger:t,expectedTrigger:o,targetConfig:r,targetProject:n,env:a,force:s}=e;return t!==o||!a.session||a.cleared||a.currentConfig&&!a.autoLoadedMarker||!s&&a.autoLoadedMarker&&a.currentConfig===r&&a.currentProject===n?"skip":"load"},_=async({expectedTrigger:e,projectDir:t,force:o,isAuthFailure:r=Ue})=>{let n=e==="cli-invocation";n&&W();let a=null;try{if(a=await Kt(n),!a||Ht({trigger:a.trigger,expectedTrigger:e,targetConfig:a.config,targetProject:a.project,env:$o(),force:o})==="skip"||Bt()||jo())return null;let i=Fo(),c=await Ze({config:a.config,autoLoaded:!0,projectDir:t,beforeWrite:()=>!Bt()&&!Mo(i)});return c?(Go(),Oo(),c.filePath):null}catch(s){let i=s.message,c=r(s);return Uo(),c&&a&&Yt({config:a.config,reason:i,at:Date.now()}),n&&c&&a?(V(N(a.config),de),l.debug(`env auto-load auth failure: ${i}`)):n?V(`infra-kit: env auto-load failed \u2014 ${i} (will retry later)`,Lo):l.debug(`env auto-load skipped: ${i}`),null}},W=()=>{let e=Do();e&&(V(N(e.config),de),l.debug(`env auto-load auth failure (recorded ${new Date(e.at).toISOString()}): ${e.reason}`))},Do=()=>{try{let e=f.readFileSync(y.join(v(),pe),"utf-8");return me(JSON.parse(e))}catch{return null}},Yt=e=>{try{let t=v();f.mkdirSync(t,{recursive:!0,mode:448}),He(y.join(t,pe),JSON.stringify(e),384)}catch{}},Oo=()=>{try{f.rmSync(y.join(v(),pe),{force:!0})}catch{}},$o=()=>({session:L.env[We],cleared:L.env[Ke],currentConfig:L.env[Je],currentProject:L.env[Be],autoLoadedMarker:L.env[Z]}),Fo=()=>{try{return f.statSync(y.join(v(),F)).mtimeMs}catch{return null}},Mo=e=>{try{let t=y.join(v(),F);if(!f.existsSync(t))return!1;let o=f.statSync(t).mtimeMs;return e!==null&&o<=e?!1:new RegExp(`^unset ${Z}$`,"m").test(f.readFileSync(t,"utf-8"))}catch{return!1}},Bt=()=>{try{let e=v(),t=y.join(e,Ve);if(!f.existsSync(t))return!1;let o=y.join(e,F);return f.existsSync(o)?f.statSync(t).mtimeMs>=f.statSync(o).mtimeMs:!0}catch{return!1}},jo=()=>{try{let e=y.join(v(),ue);return f.existsSync(e)?Date.now()-f.statSync(e).mtimeMs<_o:!1}catch{return!1}},Uo=()=>{try{let e=v();f.mkdirSync(e,{recursive:!0,mode:448}),f.writeFileSync(y.join(e,ue),"",{mode:384})}catch{}},Go=()=>{try{f.rmSync(y.join(v(),ue),{force:!0})}catch{}},V=(e,t)=>{try{let o=v(),r=y.join(o,t);if(f.existsSync(r))return;f.mkdirSync(o,{recursive:!0,mode:448}),f.writeFileSync(r,"",{mode:384})}catch{}l.warn(e)};var fe=async({projectDir:e}={})=>{await _({expectedTrigger:"shell-startup",projectDir:e,force:!0})};var zt="https://dashboard.doppler.com/workplace/projects",qo=(e,t)=>["Removing it locally does NOT revoke it \u2014 the token still works anywhere else it is stored.",`Revoke it in Doppler (project "${e}", config "${t}"): ${zt}/${e}`],ge=async({env:e})=>{let o=!!(await Ye())?.envs[e];await Xe(e);let r=await U(),n=await $(),a=await M();o?l.info(`Removed the "${e}" service token from ${h(a)}.`):l.info(`No "${e}" service token was stored in ${h(a)} \u2014 nothing to remove.`),r.length>0&&l.info(`Purged ${r.length} warm cache(s) across this repo's worktrees.`);for(let i of qo(n,e))l.warn(i);let s={env:e,removed:o,storePath:a,warmCachesPurged:r.length,revokeUrl:`${zt}/${n}`};return{content:O(JSON.stringify(s,null,2)),structuredContent:s}};import Vo from"@inquirer/password";import B from"node:process";import{$ as J}from"zx";var Wo=async({stdin:e,fromEnv:t})=>{if(e)return{token:await Jo(),source:"stdin"};if(t){let r=B.env[t];if(!r)throw new Error(`${t} is not set (or is empty) \u2014 nothing to store.`);return{token:r,source:"env"}}return T.setInteractive(),{token:(await j(r=>Vo({message:"Paste the Doppler service token (input is hidden)",mask:!0},r),{output:B.stderr})).trim(),source:"prompt"}},Jo=async()=>{let e=[];B.stdin.setEncoding("utf8");for await(let t of B.stdin)e.push(t);return e.join("").trim()},he="DOPPLER_CONFIG",Bo=3e4,Ko=async(e,t,o)=>{let r=J.quiet;J.quiet=!0;let n;try{n=(await J({env:tt(e)})`doppler secrets download --no-file --format json --project ${t} --config ${o}`.timeout(Bo)).stdout}catch(a){throw Ho(a,o)}finally{J.quiet=r}return rt(n)},Ho=(e,t)=>{let o=Ne(e)??(e instanceof Error?e.message:String(e));if(Ge(o)!=="auth")return e instanceof Error?e:new Error(String(e));let r=qe(o)==="mis-scoped"?"it is scoped to a DIFFERENT config (pasting another environment's token here is the mistake this check exists to catch).":"it is invalid or has been revoked.";return new Error([`Doppler refused this token for config "${t}" \u2014 ${r}`,"Nothing was written. Issue a service token scoped to that config and try again."].join(`
5
+ `))},Yo=e=>[`Could not verify this token's scope: the Doppler payload for "${e}" carries no ${he}.`,"Refusing to store a credential whose scope is unknown (a token for the wrong environment would load","the wrong secrets into every shell).","Re-run with --force if you are certain the token is scoped to this config."].join(`
6
+ `),ve=async({env:e,stdin:t,fromEnv:o,force:r})=>{let n=await $(),{token:a,source:s}=await Wo({stdin:t,fromEnv:o});if(!a)throw new Error("No token provided \u2014 nothing was written.");let i=await Ko(a,n,e);ot(i,e);let c=i.some(([k])=>k===he);if(!c&&!r)throw new Error(Yo(e));await ze(e,a);let m=await U(),u=await M();l.info(`Stored the "${e}" service token (${oe(a)}) in ${h(u)} (mode 0600).`),c||l.warn(`Scope was NOT verified (no ${he} in the payload) \u2014 written because --force was given.`),m.length>0&&l.info(`Purged ${m.length} warm cache(s) so the next shell cannot serve secrets fetched with an old token.`);let p={env:e,source:s,redactedToken:oe(a),storePath:u,scopeVerified:c,warmCachesPurged:m.length};return T.print(),{content:O(JSON.stringify(p,null,2)),structuredContent:p}};import{spawn as zo}from"node:child_process";import K from"node:process";import{fileURLToPath as Xo}from"node:url";var Qo=["SIGINT","SIGTERM"],Xt=()=>Xo(new URL("./mcp.js",import.meta.url)),ye=(e={})=>{let t=e.spawn??zo,o=e.exit??(s=>K.exit(s)),r=e.env??K.env,n=e.onError??(s=>l.error(s)),a=t(K.execPath,[Xt()],{stdio:"inherit",env:Fe(r)});a.on("error",s=>{n(`failed to launch the MCP server: ${s.message}`),o(1)}),Qo.forEach(s=>{K.on(s,()=>{a.kill(s)})}),a.on("exit",(s,i)=>{o(i?1:s??1)})};import{spawnSync as Zo}from"node:child_process";import{realpathSync as er}from"node:fs";import{homedir as tr}from"node:os";import we from"node:process";import{fileURLToPath as or}from"node:url";var rr=()=>er(or(import.meta.url)),nr=(e,t,o,r)=>e.error?(o(`${t} not found on PATH: ${e.error.message}`),r(1)):e.signal?(o(`update terminated by signal ${e.signal}`),r(1)):r(e.status??1),Se=({dryRun:e},t={})=>{let o=t.spawnSync??Zo,r=t.print??(R=>l.info(R)),n=t.exit??(R=>we.exit(R)),a=t.env??we.env,s=t.selfRealPath??rr(),i=t.lazyNpmRoot??qt,{manager:c,updateCommand:m,canSelfSpawn:u}=Gt({selfRealPath:s,env:a,realpath:A,lazyNpmRoot:i}),p=G(m);if(e){r(`Detected install manager: ${c}`),r(`Would run: ${p}`);return}if(!u){r(`Detected install manager: ${c}`),r(`Run this yourself: ${p}`),r(c==="homebrew"?"Not run for you: Homebrew manages this install; running a package manager would create a split-brain install.":"Not run for you: the install location is unrecognized, so the command above is a guess \u2014 a guessed global install is worse than a printed one.");return}let k=o(m[0],m.slice(1),{stdio:"inherit",shell:we.platform==="win32",cwd:tr(),env:Me(a)});nr(k,c,r,n)};import{VENDOR_CONFIG_FILE as Zt}from"@slip-stream-kit/config/internal";import ke from"node:fs/promises";import Re from"node:path";import Qt from"node:process";import{pathToFileURL as ir}from"node:url";var eo="~/projects",Ee=async(e={})=>{if(e.init){await sr(e.cwd);return}await ar()},ar=async()=>{let e=ee(),t=await b(e);if(l.info(`Factory config: ${h(e)} ${t?"[\u2713]":"[ ]"}`),!t){l.info("\nNot found \u2014 run `infra-kit vendor config --init` to scaffold it."),Qt.exitCode=1;return}let{workspaceDir:o,targets:r}=await lt(),n=ct(o),a=await b(n);l.info(`workspaceDir: ${o} (resolved: ${n}) ${a?"[\u2713 exists]":"[ ] not found"}`),l.info("Targets:");let s=a;for(let i of r){let c=Re.join(n,i),m=await b(c);m||(s=!1);let u=m?"[\u2713]":"[ ]",p=m?"":" (not found \u2014 clone or remove)";l.info(` ${u} ${i} ${h(c)}${p}`)}s||(Qt.exitCode=1)},sr=async e=>{let t=ee();if(await b(t)){l.info(`Factory config already exists at ${h(t)} \u2014 leaving it untouched.`);return}let o=e??await Le(),r=await cr(o);await ke.mkdir(Re.dirname(t),{recursive:!0}),await ke.writeFile(t,lr(r),"utf-8"),l.info(`\u2713 Created ${h(t)}`),r.length>0&&l.info(` Seeded ${r.length} target(s) from the source ${Zt}.`),l.info(` Edit \`workspaceDir\` (placeholder: ${eo}) to point at where your repos live.`),r.length===0&&l.info(" Add at least one repo name to `targets` before running vendor sync/manifest/diff.")},cr=async e=>{try{let t=Re.join(e,Zt),o=await ke.stat(t),a=(await import(`${ir(t).href}?mtime=${Number(o.mtimeMs)}`)).default,s=typeof a=="function"?await a():a;if(s&&typeof s=="object"&&"targets"in s){let i=s.targets;if(Array.isArray(i)&&i.every(c=>typeof c=="string"))return i}}catch{}return[]},lr=e=>`${JSON.stringify({workspaceDir:eo,targets:e},null,2)}
7
+ `;var H=(e,t=!0)=>({line:e,reproducible:t});import Y from"node:fs";import mr from"node:os";import dr from"node:path";import no from"node:process";var z="INFRA_KIT_SESSION_REPORT",xe=null,to=!1,oo=[],io=(e=no.env)=>{to||(xe=e[z]??null,to=!0,delete e[z])};var ao=(e,t)=>{if(!xe)return;let o=e.summary??(oo.length>0?[...oo]:void 0),r={...e,...o?{summary:o}:{}},n=t?.write??((a,s)=>{Y.writeFileSync(a,s)});try{n(xe,JSON.stringify(r))}catch{}},ro=0,so=e=>{let t=e?.tmpdir?.()??mr.tmpdir(),o=e?.pid??no.pid;return ro+=1,dr.join(t,`infra-kit-session-${o}-${ro}.json`)},co=(e,t)=>{if(!(t?.exists??(s=>Y.existsSync(s)))(e))return null;let r=t?.read??(s=>Y.readFileSync(s,"utf-8")),n=t?.unlink??(s=>Y.unlinkSync(s)),a;try{a=r(e)}catch{return null}finally{try{n(e)}catch{}}try{return JSON.parse(a)}catch{return null}};var pr=(e,t)=>[...t,e],lo=(e,t)=>{if(!(typeof e>"u")){if(e===!0)return"workspace";if(e===!1)return"none";if(typeof e=="string"&&re.includes(e))return e;throw new Error(`Invalid ${t} value "${String(e)}". Expected one of: ${re.join(", ")}.`)}},fr=e=>e.description("Merge dev branch into every release branch").option("-a, --all","Select all active release branches").option("-v, --versions <versions>","Specify versions by comma, e.g. 1.2.5, 1.2.6").option("-y, --yes","Skip confirmation prompt").option("--dry-run","Compute and print the merge plan without pushing anything").option("--verify [command]","Check each merge before pushing it. Bare runs `pnpm install --frozen-lockfile`; pass a command to run that instead. A branch that fails is dropped from the push, never rolled back").action(async t=>{let o=await wt(()=>St({all:t.all,versions:t.versions,dryRun:t.dryRun,verify:t.verify,confirmedCommand:t.yes}));d(o),o.structuredContent.failedMerges>0&&(D.exitCode=1)}),gr=e=>e.description("List all release branches").action(async()=>{d(await xt())}),hr=e=>e.description("Create one or more release branches (each entry can mix regular/hotfix and its own description)").option("-r, --release <spec>",'Release spec "<version|next|name>[:type[:description]]" (repeatable). The token is a semver ("1.2.5"), the literal "next", or a kebab-case name ("checkout-redesign"). Type is regular|hotfix (default regular). Examples: "1.2.5", "1.2.5:hotfix", "next:regular:Holiday backend", "checkout-redesign:regular:Q3 redesign".',pr,[]).option("-y, --yes","Skip confirmation prompt").action(async t=>{let r=t.release.map(At),n=r.length>0?r:void 0;d(await Ct({releases:n,confirmedCommand:t.yes}))}),vr=e=>e.description("Edit a release's description in Jira and in the matching GitHub PR body").option("-v, --version <version>","Release version (e.g. 1.2.5) or release name (e.g. checkout-redesign)").option("-d, --description <description>",'New description (use "" to clear)').option("-y, --yes","Skip confirmation prompt").action(async t=>{d(await Pt({version:t.version,description:t.description,confirmedCommand:t.yes}))}),yr=e=>e.description("Deploy any release branch to any environment").option("-v, --version <version>",'Version (e.g. 1.2.5) or release name (e.g. checkout-redesign) to deploy; "dev" deploys from the dev branch').option("-e, --env <env>","Specify the environment to deploy to, e.g. dev").option("--skip-terraform","Skip terraform deployment step").option("-y, --yes","Skip confirmation prompt").action(async t=>{d(await Rt({version:t.version,env:t.env,skipTerraform:t.skipTerraform,confirmedCommand:t.yes}))}),wr=e=>e.description("Deploy selected services from release branch to any environment").option("-v, --version <version>",'Version (e.g. 1.2.5) or release name (e.g. checkout-redesign) to deploy; "dev" deploys from the dev branch').option("-e, --env <env>","Specify the environment to deploy to, e.g. dev").option("-s, --services <services...>","Specify services to deploy, e.g. client-be client-fe").option("--skip-terraform","Skip terraform deployment step").option("-y, --yes","Skip confirmation prompt").action(async t=>{d(await Et({version:t.version,env:t.env,services:t.services,skipTerraform:t.skipTerraform,confirmedCommand:t.yes}))}),Sr=e=>e.description("Release a new version to production").option("-v, --version <version>","Version (e.g. 1.2.5) or release name (e.g. checkout-redesign) to deliver").option("-y, --yes","Skip confirmation prompt").action(async t=>{d(await kt({version:t.version,confirmedCommand:t.yes}))}),kr=e=>e.description("Remove release worktrees whose PRs are no longer open").option("-y, --yes","Skip confirmation prompt").action(async t=>{d(await $t({confirmedCommand:t.yes}))}),Rr=e=>e.description("Add git worktrees for release branches").option("-y, --yes","Skip confirmation prompt").option("-a, --all","Select all active release branches").option("-v, --versions <versions>","Specify versions by comma, e.g. 1.2.5, 1.2.6").option("-i, --ide [mode]","Editor mode for created worktrees: workspace (default) | none").option("--no-ide","Skip the editor (alias for --ide none)").option("-c, --cursor [mode]","Deprecated alias for --ide").option("--no-cursor","Deprecated alias for --no-ide").option("-g, --github-desktop","Open created worktrees in GitHub Desktop").option("--no-github-desktop","Skip GitHub Desktop prompt").option("-m, --cmux","Open created worktrees in cmux (3-pane layout)").option("--no-cmux","Skip cmux prompt").action(async t=>{let o=lo(t.ide,"--ide")??lo(t.cursor,"--cursor");d(await _t({confirmedCommand:t.yes,all:t.all,versions:t.versions,ide:o,githubDesktop:t.githubDesktop,cmux:t.cmux}))}),Er=e=>e.description("List all git worktrees with detailed information").action(async()=>{d(await Dt())}),xr=e=>e.description("Remove git worktrees for release branches").option("-y, --yes","Skip confirmation prompt").option("-a, --all","Select all active release branches").option("-v, --versions <versions>","Specify versions by comma, e.g. 1.2.5, 1.2.6").action(async t=>{d(await Ot({confirmedCommand:t.yes,all:t.all,versions:t.versions}))}),br=e=>e.description("Reopen editor + cmux windows for every active worktree in the current project (additive, idempotent)").option("--all","Reopen across every discovered infra-kit project (Stage 3 \u2014 not yet implemented)").option("--project <names...>","Restrict --all to these project names").option("--root <paths...>","Discovery roots for --all (repeatable)").option("--release-only","Restrict to release worktrees (reproduces the legacy worktrees-reload scope)").option("--force","Close each cmux workspace first, then reopen (the legacy worktrees-reload behaviour)").option("--dry-run","Print the plan (paths + cmux titles) and spawn nothing").action(async t=>{d(await It({all:t.all,project:t.project,root:t.root,releaseOnly:t.releaseOnly,force:t.force,dryRun:t.dryRun}))}),Tr=e=>e.description("Show the machine-local factory config (~/.infra-kit/vendor.json) or scaffold it with --init").option("--init","Scaffold ~/.infra-kit/vendor.json (skips if it already exists)").action(async t=>{d(await Ee({init:t.init}))}),Ar=e=>e.description("Verify vendor/ matches vendor/.sync-manifest.json (self-contained; for any consumer repo)").action(async()=>{let t=await Nt();d(t),t.structuredContent.ok||(D.exitCode=1)}),Cr=e=>e.description("Show the resolved config merge chain and file paths").action(async()=>{d(await ce())}),Pr=e=>e.description("Open the user-scope per-project override file in $EDITOR").action(async()=>{d(await le())}),Ir=new Set(["init","doctor","version","dev","self-update","mcp"]),Nr=e=>e.startsWith("env-")||Ir.has(e),Lr=new Set(["env-autoload","mcp","version","self-update"]),X=e=>{let t=[];for(let o=e;o&&o.parent;o=o.parent)t.unshift(o.name());return t.join(" ")},be=()=>{let e=new ur,t=e.command("release").description("Release management commands");fr(t.command("merge-dev")),gr(t.command("list")),hr(t.command("create")),vr(t.command("desc-edit")),yr(t.command("deploy-all")),wr(t.command("deploy-selected")),Sr(t.command("deliver"));let o=e.command("worktrees").description("Git worktree management commands");Rr(o.command("add")),Er(o.command("list")),xr(o.command("remove")),kr(o.command("sync")),br(e.command("reopen"));let r=e.command("config").description("Manage infra-kit configuration files");Cr(r.command("path")),Pr(r.command("edit")),e.command("config-get").description("Print the fully merged infra-kit config (project + user-global + per-project override layers)").action(async()=>{d(await $e())});let n=e.command("local").description("Run deploys on this machine instead of dispatching CI"),a=i=>i.option("-e, --env <name>","Target environment (prompts when omitted)").option("-y, --yes","Skip the confirmation prompt").option("--dry-run","Resolve target, contract and commands without deploying").option("--print-env","Print the resolved build contract").option("--skip-preflight <check...>","Waive a named check (clean-tree, toolchain) \u2014 never env/account, and never clean-tree for a protected env");a(n.command("deploy-all")).description("Deploy every service enabled for the environment, from this machine").action(async i=>{d(await bt({env:i.env,yes:i.yes,dryRun:i.dryRun,printEnv:i.printEnv,skipPreflight:i.skipPreflight}))}),a(n.command("deploy-selected")).description("Deploy chosen services from this machine (prompts when --service is omitted)").option("-s, --service <name...>","Service name(s), as in deploy-<name>.sh").action(async i=>{d(await Tt({env:i.env,service:i.service,yes:i.yes,dryRun:i.dryRun,printEnv:i.printEnv,skipPreflight:i.skipPreflight}))}),e.command("audit").description("Audit against infra-kit.config.ts rules (--all for every package, --root for the monorepo root)").option("-a, --all","Audit every non-vendor workspace package").option("-r, --root","Audit the monorepo root (turbo pipeline + root commands)").action(async i=>{let c=await Oe({all:i.all,root:i.root});d(c),c.structuredContent.allPassed||(D.exitCode=1)});let s=e.command("vendor").description("Verify the mirrored vendor/ tree");return Ar(s.command("check")),Tr(s.command("config")),e.command("doctor").description("Check installation and authentication status of gh and doppler CLIs").option("--fix","Remove portless routes left behind by a dev-server that was killed (kill -9, OOM, force-quit). Refuses while a dev session is running, when a booting UI is indistinguishable from a dead route.").option("--ascii","Render the report with ASCII markers instead of unicode glyphs (check messages are unchanged)").action(async i=>{let c=await ut({fix:!!i.fix});I.enabled||pt(c.structuredContent.checks,{ascii:!!i.ascii}),d(c)}),e.command("self-update").description("Update this CLI using the package manager that installed it").option("--dry-run","Print the detected manager and the command that would run; install nothing").action(i=>{Se({dryRun:!!i.dryRun})}),e.command("mcp").description("Run the infra-kit MCP server (stdio transport)").action(()=>{ye()}),e.command("dev").description("Run local dev servers for a named devServersPresets preset (or all apps); api + ui").argument("[preset]","Named preset from devServersPresets (omit to run every app)").option("-w, --watch","Rebuild and restart on file save").option("--app <names>","Further narrow to these app folder names (comma-separated)").option("--target <keys>","Run exactly these <app>/api|<app>/ui packages (comma-separated); part-level, unlike --app").option("--cmux","Run each app in its own cmux pane (one workspace, N panes; falls back to single terminal if cmux is unavailable)").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)").option("--no-ui-health","Do not probe the frontends\u2019 liveness (vite\u2019s HMR ping); their rows carry no health dot (also: INFRA_KIT_NO_UI_HEALTH=1)").action(async(i,c)=>{let{runDevServerCli:m}=await import("./dev-server.js"),u=!!(D.stdout.isTTY&&D.stdin.isTTY);await m({...c,preset:i},u,I.enabled)}),e.command("dev-status").description("Show what `infra-kit dev` currently has running (reads dev-context fragments; starts nothing)").action(async()=>{d(await je())}),e.command("version").description("Print the installed infra-kit CLI version").action(async()=>{d(await Lt())}),e.command("env-status").description("Show which env is loaded in this session (local introspection; no Doppler call)").action(async()=>{d(await ht())}),e.command("env-list").description("List available Doppler configs for the detected project, and whether a service token resolves for each").action(async()=>{d(await gt())}),e.command("init").description("Inject shell integration into .zshrc and sync repo agent-instruction files").action(async()=>{d(await te())}),e.command("env-load").description("Load Doppler env vars for a config. Source the returned file path to apply.").option("-c, --config <config>","Environment config name to load (e.g. dev, arthur)").action(async i=>{d(await et({config:i.config}))}),e.command("env-clear").description("Clear loaded env vars. Source the returned file path to apply.").option("--purge","Also delete this project's warm cache outright (durable disable)").action(async i=>{d(await ft({purge:!!i.purge}))}),e.command("env-token-set").description("Store the Doppler service token for an env (masked prompt; validated against Doppler before writing)").argument("<env>","Environment / Doppler config the token is scoped to (e.g. dev)").option("--stdin","Read the token from stdin instead of prompting (e.g. from a password manager)").option("--from-env <var>","Read the token from the named environment variable (the NAME, never the value)").option("--force","Store even when the token\u2019s scope could not be verified. Never overrides a real mismatch.").action(async(i,c)=>{d(await ve({env:i,stdin:c.stdin,fromEnv:c.fromEnv,force:c.force}))}),e.command("env-token-list").description("Show which envs have a Doppler service token (redacted), and where it came from").option("--check","Also ask Doppler whether each token is valid and correctly scoped").action(async i=>{d(await vt({check:!!i.check}))}),e.command("env-token-remove").description("Delete an env\u2019s Doppler service token from the local store (does NOT revoke it in Doppler)").argument("<env>","Environment / Doppler config whose token to remove").action(async i=>{d(await ge({env:i}))}),e.command("env-autoload",{hidden:!0}).description("Internal: prime env for the shell-startup auto-load trigger").option("--project-dir <dir>","Canonical project dir for the warm-cache key (shell-startup only)").action(async i=>{await fe({projectDir:i.projectDir})}),e.commands.forEach(yt),e.hook("preAction",async(i,c)=>{T.start(X(c)),I.enabled=!!c.optsWithGlobals().json,I.enabled&&(l.level="warn"),Lr.has(X(c))||await st(),W(),Nr(c.name())||await _({expectedTrigger:"cli-invocation"})}),e.hook("postAction",(i,c)=>{let m=X(c);if(Ut(m))return;let p=T.snapshot()?.formattedOptions??"",k=p?` ${p}`:"",R=`infra-kit ${m}${k}`;ao({equivalent:H(R,!0)})}),e};var Te=(e,t=" ")=>{let o=e.reduce((r,[n])=>Math.max(r,n.length),0);return e.map(([r,n])=>`${r.padEnd(o)}${t}${n}`)};import{chalkStderr as Gr}from"chalk";import{spawn as qr}from"node:child_process";import S from"node:process";import{Chalk as _r}from"chalk";var C=new _r({level:1}),w={ok:"ok",findingsPlain:"completed with findings",failed:"failed",cancelled:"cancelled",findingsSuffix:"findings",sep:" \xB7 ",reproPrefix:"$ ",nonReproPrefix:"\u2248 ",envNotice:"Applies to your shell after you exit this session."},mo={ok:{unicode:"\u2713",ascii:"[ok]"},findings:{unicode:"\u26A0",ascii:"[!]"},failed:{unicode:"\u2717",ascii:"[x]"},cancelled:{unicode:"\u2298",ascii:"[-]"}},uo={unicode:"\u2500",ascii:"-"},Dr=3,Ae=e=>e,Or={ok:e=>C.green(e),findings:e=>C.yellow(e),failed:e=>C.red(e),cancelled:e=>C.gray(e)},fo=e=>e?{dim:t=>C.dim(t),bold:t=>C.bold(t)}:{dim:Ae,bold:Ae},$r=(e,t)=>e?Or[t]:Ae,po=e=>[...e].length,go=(e,t={})=>{let o=fo(t.color===!0);return`${o.dim(w.reproPrefix.trim())} ${o.bold(e)}`},Fr=e=>e<1e3?`${Math.round(e)}ms`:`${(e/1e3).toFixed(1)}s`,Mr=(e,t)=>e==="findings"?t!=null?`${t} ${w.findingsSuffix}`:w.findingsPlain:{ok:w.ok,failed:w.failed,cancelled:w.cancelled}[e],jr=(e,t,o,r)=>{if(t==null)return"";let n=t-2-e;return n<Dr?"":` ${r(o.repeat(n))}`},ho=e=>{let t=e.color===!0,o=fo(t),r=$r(t,e.outcome),n=e.ascii===!0,a=e.equivalent.reproducible?w.reproPrefix:w.nonReproPrefix,s=n?mo[e.outcome].ascii:mo[e.outcome].unicode,i=Mr(e.outcome,e.findingsCount),c=[Fr(e.durationMs)],m=e.summary?.[0]?.split(`
8
+ `)[0];m!=null&&m.length>0&&c.push(m);let u=`${s} ${i}`,p=`${w.sep}${c.join(w.sep)}`,k=po(u)+po(p),R=jr(k,e.width,n?uo.ascii:uo.unicode,o.dim),x=[`${r(u)}${o.dim(p)}${R}`];return e.showEquivalent!==!1&&x.unshift(`${o.dim(a.trim())} ${o.bold(e.equivalent.line)}`),e.envNotice===!0&&x.push(o.dim(w.envNotice)),x.join(`
9
+ `)};var Ur=new Set([130,143]),vo=(e,t,o,r=!1)=>o?t!=null||e===0?"ok":"findings":r&&e!=null&&Ur.has(e)||t==="SIGINT"||e===0?"cancelled":"failed";import yo from"node:process";var E={column:"\r",sgr:"\x1B[0m",cursor:"\x1B[?25h",wrap:"\x1B[?7h",saveCursor:"\x1B7",restoreCursor:"\x1B8",scrollRegion:"\x1B[r",primaryBuffer:"\x1B[?1049l"},wo=(e,t)=>{let o=t?.write??(a=>{yo.stderr.write(a)}),r=t?.stdin??yo.stdin,n=[E.saveCursor,E.scrollRegion,E.restoreCursor,E.column,E.sgr,E.cursor,E.wrap];e.entersAltScreen===!0&&n.push(E.primaryBuffer),o(n.join("")),r.isTTY===!0&&r.isRaw===!0&&r.setRawMode?.(!1)};var So=e=>`infra-kit ${e.groupPath.join(" ")}`,Vr=()=>{let e=S.stderr.columns;return e!=null&&e>0?e:void 0},Wr=e=>new Promise(t=>{e.on("exit",(o,r)=>{t({code:o,signal:r})}),e.on("error",()=>{t({code:1,signal:null})})}),Jr=async(e,t,o)=>{let r=so(),n={...t.env,[z]:r,INFRA_KIT_NO_AUTO_UPDATE:"1"},a=t.now(),s={code:1,signal:null};o();try{let p=t.spawn(S.execPath,[t.cliPath,...e.groupPath],{stdio:"inherit",env:n});s=await Wr(p)}catch{s={code:1,signal:null}}finally{t.resetTerminal({entersAltScreen:e.entersAltScreen})}let i=co(r),c=vo(s.code,s.signal,i!=null,e.longRunning),m=So(e),u=i?.equivalent??H(m,!0);return ho({equivalent:u,outcome:c,durationMs:t.now()-a,summary:i?.summary,envNotice:e.sessionEnvNotice,ascii:t.ascii,color:t.color,width:t.columns(),showEquivalent:!(u.reproducible&&u.line===m)})},Br=1e3,Kr=(e,t)=>{let o=null,r=!1,n=()=>{if(e()){o=t.now();return}t.resetTerminal(),t.exit(0)},a=()=>{if(!e()){t.resetTerminal(),t.exit(0);return}o!=null&&t.now()-o<=Br||(r=!0)},s=()=>{t.exit(129)},i=()=>{e()&&t.raise("SIGSTOP")};return t.register("SIGINT",n),t.register("SIGTERM",a),t.register("SIGHUP",s),t.register("SIGTSTP",i),{dispose:()=>{t.unregister("SIGINT",n),t.unregister("SIGTERM",a),t.unregister("SIGHUP",s),t.unregister("SIGTSTP",i)},childStarted:()=>{o=null},quitRequested:()=>r}},ko=(e,t)=>!!(t.stdoutIsTTY&&t.stdinIsTTY&&t.stderrIsTTY&&e.TERM!=="dumb"&&!e.INFRA_KIT_NO_SESSION&&!e.INFRA_KIT_SESSION_REPORT),Ro=async(e,t)=>{let o={spawn:t.spawn??qr,now:t.now??(()=>Date.now()),env:t.env??S.env,cliPath:t.cliPath,ascii:t.ascii??!(S.stdout.isTTY&&S.env.TERM!=="dumb"),color:t.color??Gr.level>0,columns:t.columns??Vr,resetTerminal:t.resetTerminal??(c=>{wo(c)})},r=t.write??(c=>S.stderr.write(c)),n=t.signals??{register:(c,m)=>{S.on(c,m)},unregister:(c,m)=>{S.off(c,m)},exit:c=>{S.exit(c)},raise:c=>{S.kill(S.pid,c)},now:()=>Date.now(),resetTerminal:()=>{o.resetTerminal({entersAltScreen:!1})}},a=!1,s={dispose:()=>{},childStarted:()=>{},quitRequested:()=>!1},i=t.installSignals===!1?s:Kr(()=>a,n);try{for(;;){if(i.quitRequested())return;a=!1;let c=await t.renderPalette(e);if(c==null)return;let m=t.resolveCommand(c);if(!m)continue;let u=go(So(m),{color:o.color});r(`
10
10
  ${u}
11
- `),i.childStarted();let p=await Wr(m,o,()=>{a=!0});r(`
11
+ `),i.childStarted();let p=await Jr(m,o,()=>{a=!0});r(`
12
12
  ${p}
13
- `)}}finally{i.dispose()}};import{spawn as Yr}from"node:child_process";import Eo from"node:fs";import C from"node:process";import{fileURLToPath as xo}from"node:url";var Ro=["INFRA_KIT_NO_AUTO_UPDATE","NO_UPDATE_NOTIFIER","CI"],Br=new Set(["mcp","self-update"]),Hr=e=>e[2]!=null&&Br.has(e[2]),Pe=e=>{let{argv:t,env:o,isTty:r,selfRealPath:n,cwd:a,realpath:s}=e;return Ro.some(c=>{let m=o[c];return m!=null&&m!==""})?"opt-out":t.includes("--json")?"json":Hr(t)?"own-command":r?G(n,a,s)?"local-install":null:"not-a-tty"};var zr=e=>{Yr(C.execPath,[e,"--parent-pid",String(C.pid)],{detached:!0,stdio:"ignore",windowsHide:!0}).unref()},Xr=()=>xo(new URL("./update-check.js",import.meta.url)),Qr=()=>Eo.realpathSync(xo(new URL("./cli.js",import.meta.url))),Zr=/^[\w@./+ -]+$/i,en=e=>Zr.test(e),tn=(e,t,o)=>{!e?.latestVersion||!e.updateCommand||ie(e.latestVersion,t)&&e.updateCommand.every(en)&&o(`infra-kit ${e.latestVersion} is available (you have ${t}). Run: ${U(e.updateCommand)}`)},Ce=(e,t={})=>{try{let o=t.argv??C.argv,r=t.env??C.env,n=t.isTty??!!C.stdout.isTTY,a=t.cwd??C.cwd(),s=t.nowMs??Date.now(),i=t.selfRealPath??Qr(),c=t.readCache??ae,m=t.spawnChild??zr,u=t.fileExists??(x=>Eo.existsSync(x)),p=t.notify??(x=>{l.info(x)});if(Pe({argv:o,env:r,isTty:n,selfRealPath:i,cwd:a,realpath:A})!==null)return;let k=c();if(tn(k,e,p),!se(k,s))return;let R=t.childPath??Xr();if(!u(R))return;m(R)}catch{}};qt();no();var Ie=Te(),bo=async e=>{try{e?await Ie.parseAsync(e):await Ie.parseAsync()}catch(t){ne(t)&&(l.info("Operation cancelled."),g.exit(0));let o=t instanceof Error?t.message:String(t);l.error(o),g.exit(1)}},nn=()=>{try{if(g.env.INFRA_KIT_NO_LOCATION_WARN||g.argv.includes("--json")||g.argv[2]==="mcp")return;G(rn(Ao(import.meta.url)),g.cwd(),A)&&l.info("Running from a project-local node_modules. Install globally for faster startup: npm i -g infra-kit")}catch{}};nn();Ce(nt.version);var Po=()=>Vt(Ie.commands),an=async()=>{let e=Po(),t=null;try{if(g.stdout.isTTY&&g.stdin.isTTY){let{runCommandPalette:o}=await import("./boot-OA6HGGO6.js");t=await o(e)}else{let o=be(e.map(n=>[n.name,n.description])),r=e.flatMap((n,a)=>[...e[a-1]?.group===n.group?[]:[new To(" "),new To(`\u2014 ${n.group} \u2014`)],{name:o[a]??n.name,value:n.name}]);t=await M(n=>on({message:"Select a command to run",choices:r},n),{output:g.stderr})}}catch(o){if(!ne(o))throw o}return t},sn=async()=>{let{runCommandPalette:e}=await import("./boot-OA6HGGO6.js"),t=Ao(import.meta.url),o=new Map(Ft.map(r=>[r.groupPath.join(" "),r]));await ko(Po(),{renderPalette:e,resolveCommand:r=>{let n=o.get(r);return n?{groupPath:n.groupPath,entersAltScreen:n.entersAltScreen,sessionEnvNotice:n.sessionEnvNotice,longRunning:n.longRunning}:void 0},cliPath:t})};if(g.argv.length<=2){let e={stdoutIsTTY:!!g.stdout.isTTY,stdinIsTTY:!!g.stdin.isTTY,stderrIsTTY:!!g.stderr.isTTY};if(So(g.env,e))await sn();else{let t=await an();t&&await bo(["node","infra-kit",...t.split(" ")])}}else await bo();
13
+ `)}}finally{i.dispose()}};import{spawn as zr}from"node:child_process";import xo from"node:fs";import P from"node:process";import{fileURLToPath as bo}from"node:url";var Eo=["INFRA_KIT_NO_AUTO_UPDATE","NO_UPDATE_NOTIFIER","CI"],Hr=new Set(["mcp","self-update"]),Yr=e=>e[2]!=null&&Hr.has(e[2]),Ce=e=>{let{argv:t,env:o,isTty:r,selfRealPath:n,cwd:a,realpath:s}=e;return Eo.some(c=>{let m=o[c];return m!=null&&m!==""})?"opt-out":t.includes("--json")?"json":Yr(t)?"own-command":r?q(n,a,s)?"local-install":null:"not-a-tty"};var Xr=e=>{zr(P.execPath,[e,"--parent-pid",String(P.pid)],{detached:!0,stdio:"ignore",windowsHide:!0}).unref()},Qr=()=>bo(new URL("./update-check.js",import.meta.url)),Zr=()=>xo.realpathSync(bo(new URL("./cli.js",import.meta.url))),en=/^[\w@./+ -]+$/i,tn=e=>en.test(e),on=(e,t,o)=>{!e?.latestVersion||!e.updateCommand||ie(e.latestVersion,t)&&e.updateCommand.every(tn)&&o(`infra-kit ${e.latestVersion} is available (you have ${t}). Run: ${G(e.updateCommand)}`)},Pe=(e,t={})=>{try{let o=t.argv??P.argv,r=t.env??P.env,n=t.isTty??!!P.stdout.isTTY,a=t.cwd??P.cwd(),s=t.nowMs??Date.now(),i=t.selfRealPath??Zr(),c=t.readCache??ae,m=t.spawnChild??Xr,u=t.fileExists??(x=>xo.existsSync(x)),p=t.notify??(x=>{l.info(x)});if(Ce({argv:o,env:r,isTty:n,selfRealPath:i,cwd:a,realpath:A})!==null)return;let k=c();if(on(k,e,p),!se(k,s))return;let R=t.childPath??Qr();if(!u(R))return;m(R)}catch{}};Vt();io();var Ie=be(),Ao=async e=>{try{e?await Ie.parseAsync(e):await Ie.parseAsync()}catch(t){ne(t)&&(l.info("Operation cancelled."),g.exit(0));let o=t instanceof Error?t.message:String(t);l.error(o),g.exit(1)}},an=()=>{try{if(g.env.INFRA_KIT_NO_LOCATION_WARN||g.argv.includes("--json")||g.argv[2]==="mcp")return;q(nn(Co(import.meta.url)),g.cwd(),A)&&l.info("Running from a project-local node_modules. Install globally for faster startup: npm i -g infra-kit")}catch{}};an();Pe(nt.version);var Po=()=>Wt(Ie.commands),sn=async()=>{let e=Po(),t=null;try{if(g.stdout.isTTY&&g.stdin.isTTY){let{runCommandPalette:o}=await import("./boot-OA6HGGO6.js");t=await o(e)}else{let o=Te(e.map(n=>[n.name,n.description])),r=e.flatMap((n,a)=>[...e[a-1]?.group===n.group?[]:[new To(" "),new To(`\u2014 ${n.group} \u2014`)],{name:o[a]??n.name,value:n.name}]);t=await j(n=>rn({message:"Select a command to run",choices:r},n),{output:g.stderr})}}catch(o){if(!ne(o))throw o}return t},cn=async()=>{let{runCommandPalette:e}=await import("./boot-OA6HGGO6.js"),t=Co(import.meta.url),o=new Map(Mt.map(r=>[r.groupPath.join(" "),r]));await Ro(Po(),{renderPalette:e,resolveCommand:r=>{let n=o.get(r);return n?{groupPath:n.groupPath,entersAltScreen:n.entersAltScreen,sessionEnvNotice:n.sessionEnvNotice,longRunning:n.longRunning}:void 0},cliPath:t})};if(g.argv.length<=2){let e={stdoutIsTTY:!!g.stdout.isTTY,stdinIsTTY:!!g.stdin.isTTY,stderrIsTTY:!!g.stderr.isTTY};if(ko(g.env,e))await cn();else{let t=await sn();t&&await Ao(["node","infra-kit",...t.split(" ")])}}else await Ao();
14
14
  //# sourceMappingURL=cli.js.map