infra-kit 0.3.12 → 0.3.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-LJVPQQ75.js → chunk-DPCWCXJD.js} +2 -2
- package/dist/{chunk-LJVPQQ75.js.map → chunk-DPCWCXJD.js.map} +2 -2
- package/dist/chunk-LMAO6FEM.js +238 -0
- package/dist/chunk-LMAO6FEM.js.map +7 -0
- package/dist/{chunk-VISEADOF.js → chunk-QLAQ7F4M.js} +2 -2
- package/dist/{chunk-VISEADOF.js.map → chunk-QLAQ7F4M.js.map} +2 -2
- package/dist/{chunk-ADCSGQAU.js → chunk-SHFPI4QA.js} +2 -2
- package/dist/{chunk-ADCSGQAU.js.map → chunk-SHFPI4QA.js.map} +1 -1
- package/dist/{chunk-DWZSB6O6.js → chunk-SSBYKOHY.js} +4 -4
- package/dist/{chunk-DWZSB6O6.js.map → chunk-SSBYKOHY.js.map} +3 -3
- package/dist/cli.js +2 -2
- package/dist/cli.js.map +2 -2
- package/dist/dev-server.js +30 -30
- package/dist/dev-server.js.map +4 -4
- package/dist/{dev-wizard-run-4SVW4W3I.js → dev-wizard-run-XM5L23UP.js} +2 -2
- package/dist/mcp.js +1 -1
- package/dist/mcp.js.map +2 -2
- package/dist/update-check.js +1 -1
- package/package.json +5 -5
- package/dist/chunk-M5FC2MOJ.js +0 -220
- package/dist/chunk-M5FC2MOJ.js.map +0 -7
- /package/dist/{dev-wizard-run-4SVW4W3I.js.map → dev-wizard-run-XM5L23UP.js.map} +0 -0
package/dist/cli.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{$ as $t,A as pt,B as ft,C as gt,D as te,E as ht,F as I,G as d,H as vt,I as yt,J as wt,K as St,L as kt,M as Rt,N as Et,O as xt,P as Tt,Q as bt,R as At,S as oe,T as Pt,U as Ct,V as It,W as Nt,X as Lt,Y as _t,Z as Dt,_ as Ot,a as D,b as De,ba as Ft,c as Oe,ca as Mt,da as Gt,e as Me,f as Ue,g as Ge,h as O,i as Xe,j,k as Qe,l as Ze,m as et,n as tt,o as ot,p as nt,q as it,r as at,s as Z,t as st,u as ct,v as ee,w as lt,x as mt,y as dt,z as ut}from"./chunk-
|
|
2
|
+
import{$ as $t,A as pt,B as ft,C as gt,D as te,E as ht,F as I,G as d,H as vt,I as yt,J as wt,K as St,L as kt,M as Rt,N as Et,O as xt,P as Tt,Q as bt,R as At,S as oe,T as Pt,U as Ct,V as It,W as Nt,X as Lt,Y as _t,Z as Dt,_ as Ot,a as D,b as De,ba as Ft,c as Oe,ca as Mt,da as Gt,e as Me,f as Ue,g as Ge,h as O,i as Xe,j,k as Qe,l as Ze,m as et,n as tt,o as ot,p as nt,q as it,r as at,s as Z,t as st,u as ct,v as ee,w as lt,x as mt,y as dt,z as ut}from"./chunk-LMAO6FEM.js";import{u as re}from"./chunk-SHFPI4QA.js";import{a as jt,b as U,c as Ut,d as A,e as ne,f as ie,g as ae}from"./chunk-2QJAIOPI.js";import{a as rt}from"./chunk-DPCWCXJD.js";import{a as $e,b as Fe}from"./chunk-LKKKDB6V.js";import{b as je,c as T,d as h,e as F,f as He,g as Ye,h as ze,i as b,j as M}from"./chunk-QLAQ7F4M.js";import{B as l,W as X,X as Le,Z as _e,a as Ie,r as Ne}from"./chunk-SSBYKOHY.js";import{a as $,b as qe,d as Ve,f as We,g as Je,j as Q,k as Ke,n as v,q as Be}from"./chunk-CHETBZ6M.js";import"./chunk-X46DP23W.js";import tn,{Separator as xo}from"@inquirer/select";import{realpathSync as on}from"node:fs";import g from"node:process";import{fileURLToPath as bo}from"node:url";var Po=(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},qt=e=>Ot.flatMap(({key:t,label:o})=>Ft(t).flatMap(r=>{let n=Po(e,r.groupPath);return n?[{name:r.groupPath.join(" "),description:n.description(),group:o}]:[]}));import{Command as mr}from"commander";import Y from"node:process";import Vt from"node:process";import{$ as Co}from"zx";var se=async()=>{let e=await X(),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 lt(e.userProject,o),n=o?mt(r):"";l.info(`Project name: ${e.projectName}
|
|
3
3
|
`),l.info(`Config merge chain (later overrides earlier):
|
|
4
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}},ce=async()=>{let e=await X(),t=Vt.env.EDITOR||Vt.env.VISUAL||"vi",o=await nt(e);o.createdConfig&&l.info(it(o)),l.info(`Opening ${h(e.userProject)} in ${t}`),await Co({stdio:"inherit"})`${t} ${e.userProject}`,_e();let r={path:e.userProject,editor:t};return{content:[{type:"text",text:JSON.stringify(r,null,2)}],structuredContent:r}};var le=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 Io="autoload-warn-fail.flag",me="autoload-warn-auth-fail.flag",de="autoload-fail.flag",ue="autoload-auth-fail.json",No=3e4,Jt=async(e=!0)=>{let t;try{t=await Le()}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 Xe(o.config))return r}catch{return r}return Bt({config:o.config,reason:`No Doppler service token for env "${o.config}"`,at:Date.now()}),e&&G(N(o.config),me),null},Kt=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=je})=>{let n=e==="cli-invocation";n&&q();let a=null;try{if(a=await Jt(n),!a||Kt({trigger:a.trigger,expectedTrigger:e,targetConfig:a.config,targetProject:a.project,env:Do(),force:o})==="skip"||Wt()||Fo())return null;let i=Oo(),c=await Qe({config:a.config,autoLoaded:!0,projectDir:t,beforeWrite:()=>!Wt()&&!$o(i)});return c?(jo(),_o(),c.filePath):null}catch(s){let i=s.message,c=r(s);return Mo(),c&&a&&Bt({config:a.config,reason:i,at:Date.now()}),n&&c&&a?(G(N(a.config),me),l.debug(`env auto-load auth failure: ${i}`)):n?G(`infra-kit: env auto-load failed \u2014 ${i} (will retry later)`,Io):l.debug(`env auto-load skipped: ${i}`),null}},q=()=>{let e=Lo();e&&(G(N(e.config),me),l.debug(`env auto-load auth failure (recorded ${new Date(e.at).toISOString()}): ${e.reason}`))},Lo=()=>{try{let e=f.readFileSync(y.join(v(),ue),"utf-8");return le(JSON.parse(e))}catch{return null}},Bt=e=>{try{let t=v();f.mkdirSync(t,{recursive:!0,mode:448}),Be(y.join(t,ue),JSON.stringify(e),384)}catch{}},_o=()=>{try{f.rmSync(y.join(v(),ue),{force:!0})}catch{}},Do=()=>({session:L.env[Ve],cleared:L.env[Ke],currentConfig:L.env[We],currentProject:L.env[Je],autoLoadedMarker:L.env[Q]}),Oo=()=>{try{return f.statSync(y.join(v(),$)).mtimeMs}catch{return null}},$o=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 ${Q}$`,"m").test(f.readFileSync(t,"utf-8"))}catch{return!1}},Wt=()=>{try{let e=v(),t=y.join(e,qe);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}},Fo=()=>{try{let e=y.join(v(),de);return f.existsSync(e)?Date.now()-f.statSync(e).mtimeMs<No:!1}catch{return!1}},Mo=()=>{try{let e=v();f.mkdirSync(e,{recursive:!0,mode:448}),f.writeFileSync(y.join(e,de),"",{mode:384})}catch{}},jo=()=>{try{f.rmSync(y.join(v(),de),{force:!0})}catch{}},G=(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 pe=async({projectDir:e}={})=>{await _({expectedTrigger:"shell-startup",projectDir:e,force:!0})};var Ht="https://dashboard.doppler.com/workplace/projects",Uo=(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}"): ${Ht}/${e}`],fe=async({env:e})=>{let o=!!(await He())?.envs[e];await ze(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 Uo(n,e))l.warn(i);let s={env:e,removed:o,storePath:a,warmCachesPurged:r.length,revokeUrl:`${Ht}/${n}`};return{content:D(JSON.stringify(s,null,2)),structuredContent:s}};import Go from"@inquirer/password";import W from"node:process";import{$ as V}from"zx";var qo=async({stdin:e,fromEnv:t})=>{if(e)return{token:await Vo(),source:"stdin"};if(t){let r=W.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=>Go({message:"Paste the Doppler service token (input is hidden)",mask:!0},r),{output:W.stderr})).trim(),source:"prompt"}},Vo=async()=>{let e=[];W.stdin.setEncoding("utf8");for await(let t of W.stdin)e.push(t);return e.join("").trim()},ge="DOPPLER_CONFIG",Wo=3e4,Jo=async(e,t,o)=>{let r=V.quiet;V.quiet=!0;let n;try{n=(await V({env:et(e)})`doppler secrets download --no-file --format json --project ${t} --config ${o}`.timeout(Wo)).stdout}catch(a){throw Ko(a,o)}finally{V.quiet=r}return ot(n)},Ko=(e,t)=>{let o=Ie(e)??(e instanceof Error?e.message:String(e));if(Ue(o)!=="auth")return e instanceof Error?e:new Error(String(e));let r=Ge(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
5
|
`))},Bo=e=>[`Could not verify this token's scope: the Doppler payload for "${e}" carries no ${ge}.`,"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
6
|
`),he=async({env:e,stdin:t,fromEnv:o,force:r})=>{let n=await O(),{token:a,source:s}=await qo({stdin:t,fromEnv:o});if(!a)throw new Error("No token provided \u2014 nothing was written.");let i=await Jo(a,n,e);tt(i,e);let c=i.some(([k])=>k===ge);if(!c&&!r)throw new Error(Bo(e));await Ye(e,a);let m=await j(),u=await F();l.info(`Stored the "${e}" service token (${te(a)}) in ${h(u)} (mode 0600).`),c||l.warn(`Scope was NOT verified (no ${ge} 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:te(a),storePath:u,scopeVerified:c,warmCachesPurged:m.length};return b.print(),{content:D(JSON.stringify(p,null,2)),structuredContent:p}};import{spawn as Ho}from"node:child_process";import J from"node:process";import{fileURLToPath as Yo}from"node:url";var zo=["SIGINT","SIGTERM"],Yt=()=>Yo(new URL("./mcp.js",import.meta.url)),ve=(e={})=>{let t=e.spawn??Ho,o=e.exit??(s=>J.exit(s)),r=e.env??J.env,n=e.onError??(s=>l.error(s)),a=t(J.execPath,[Yt()],{stdio:"inherit",env:$e(r)});a.on("error",s=>{n(`failed to launch the MCP server: ${s.message}`),o(1)}),zo.forEach(s=>{J.on(s,()=>{a.kill(s)})}),a.on("exit",(s,i)=>{o(i?1:s??1)})};import{spawnSync as Xo}from"node:child_process";import{realpathSync as Qo}from"node:fs";import{homedir as Zo}from"node:os";import ye from"node:process";import{fileURLToPath as er}from"node:url";var tr=()=>Qo(er(import.meta.url)),or=(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),we=({dryRun:e},t={})=>{let o=t.spawnSync??Xo,r=t.print??(R=>l.info(R)),n=t.exit??(R=>ye.exit(R)),a=t.env??ye.env,s=t.selfRealPath??tr(),i=t.lazyNpmRoot??Ut,{manager:c,updateCommand:m,canSelfSpawn:u}=jt({selfRealPath:s,env:a,realpath:A,lazyNpmRoot:i}),p=m.join(" ");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:ye.platform==="win32",cwd:Zo(),env:Fe(a)});or(k,c,r,n)};import{VENDOR_CONFIG_FILE as Xt}from"@slip-stream-kit/config/internal";import Se from"node:fs/promises";import ke from"node:path";import zt from"node:process";import{pathToFileURL as rr}from"node:url";var Qt="~/projects",Re=async(e={})=>{if(e.init){await ir(e.cwd);return}await nr()},nr=async()=>{let e=Z(),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."),zt.exitCode=1;return}let{workspaceDir:o,targets:r}=await ct(),n=st(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=ke.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||(zt.exitCode=1)},ir=async e=>{let t=Z();if(await T(t)){l.info(`Factory config already exists at ${h(t)} \u2014 leaving it untouched.`);return}let o=e??await Ne(),r=await ar(o);await Se.mkdir(ke.dirname(t),{recursive:!0}),await Se.writeFile(t,sr(r),"utf-8"),l.info(`\u2713 Created ${h(t)}`),r.length>0&&l.info(` Seeded ${r.length} target(s) from the source ${Xt}.`),l.info(` Edit \`workspaceDir\` (placeholder: ${Qt}) 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.")},ar=async e=>{try{let t=ke.join(e,Xt),o=await Se.stat(t),a=(await import(`${rr(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[]},sr=e=>`${JSON.stringify({workspaceDir:Qt,targets:e},null,2)}
|
|
7
|
-
`;var K=(e,t=!0)=>({line:e,reproducible:t});import B from"node:fs";import cr from"node:os";import lr from"node:path";import oo from"node:process";var H="INFRA_KIT_SESSION_REPORT",Ee=null,Zt=!1,eo=[],ro=(e=oo.env)=>{Zt||(Ee=e[H]??null,Zt=!0,delete e[H])};var no=(e,t)=>{if(!Ee)return;let o=e.summary??(eo.length>0?[...eo]:void 0),r={...e,...o?{summary:o}:{}},n=t?.write??((a,s)=>{B.writeFileSync(a,s)});try{n(Ee,JSON.stringify(r))}catch{}},to=0,io=e=>{let t=e?.tmpdir?.()??cr.tmpdir(),o=e?.pid??oo.pid;return to+=1,lr.join(t,`infra-kit-session-${o}-${to}.json`)},ao=(e,t)=>{if(!(t?.exists??(s=>B.existsSync(s)))(e))return null;let r=t?.read??(s=>B.readFileSync(s,"utf-8")),n=t?.unlink??(s=>B.unlinkSync(s)),a;try{a=r(e)}catch{return null}finally{try{n(e)}catch{}}try{return JSON.parse(a)}catch{return null}};var dr=(e,t)=>[...t,e],so=(e,t)=>{if(!(typeof e>"u")){if(e===!0)return"workspace";if(e===!1)return"none";if(typeof e=="string"&&oe.includes(e))return e;throw new Error(`Invalid ${t} value "${String(e)}". Expected one of: ${oe.join(", ")}.`)}},ur=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 yt({all:t.all,confirmedCommand:t.yes}))}),pr=e=>e.description("List all release branches").action(async()=>{d(await Rt())}),fr=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".',dr,[]).option("-y, --yes","Skip confirmation prompt").action(async t=>{let r=t.release.map(Tt),n=r.length>0?r:void 0;d(await bt({releases:n,confirmedCommand:t.yes}))}),gr=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 At({version:t.version,description:t.description,confirmedCommand:t.yes}))}),hr=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 St({version:t.version,env:t.env,skipTerraform:t.skipTerraform,confirmedCommand:t.yes}))}),vr=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 kt({version:t.version,env:t.env,services:t.services,skipTerraform:t.skipTerraform,confirmedCommand:t.yes}))}),yr=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 wt({version:t.version,confirmedCommand:t.yes}))}),wr=e=>e.description("Remove release worktrees whose PRs are no longer open").option("-y, --yes","Skip confirmation prompt").action(async t=>{d(await Dt({confirmedCommand:t.yes}))}),Sr=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=so(t.ide,"--ide")??so(t.cursor,"--cursor");d(await Nt({confirmedCommand:t.yes,all:t.all,versions:t.versions,ide:o,githubDesktop:t.githubDesktop,cmux:t.cmux}))}),kr=e=>e.description("List all git worktrees with detailed information").action(async()=>{d(await Lt())}),Rr=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 _t({confirmedCommand:t.yes,all:t.all,versions:t.versions}))}),Er=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 Pt({all:t.all,project:t.project,root:t.root,releaseOnly:t.releaseOnly,force:t.force,dryRun:t.dryRun}))}),xr=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 Re({init:t.init}))}),Tr=e=>e.description("Verify vendor/ matches vendor/.sync-manifest.json (self-contained; for any consumer repo)").action(async()=>{let t=await Ct();d(t),t.structuredContent.ok||(Y.exitCode=1)}),br=e=>e.description("Show the resolved config merge chain and file paths").action(async()=>{d(await se())}),Ar=e=>e.description("Open the user-scope per-project override file in $EDITOR").action(async()=>{d(await ce())}),Pr=new Set(["init","doctor","version","dev","self-update","mcp"]),Cr=e=>e.startsWith("env-")||Pr.has(e),Ir=new Set(["env-autoload","mcp","version","self-update"]),z=e=>{let t=[];for(let o=e;o&&o.parent;o=o.parent)t.unshift(o.name());return t.join(" ")},xe=()=>{let e=new mr,t=e.command("release").description("Release management commands");ur(t.command("merge-dev")),pr(t.command("list")),fr(t.command("create")),gr(t.command("desc-edit")),hr(t.command("deploy-all")),vr(t.command("deploy-selected")),yr(t.command("deliver"));let o=e.command("worktrees").description("Git worktree management commands");Sr(o.command("add")),kr(o.command("list")),Rr(o.command("remove")),wr(o.command("sync")),Er(e.command("reopen"));let r=e.command("config").description("Manage infra-kit configuration files");br(r.command("path")),Ar(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 Oe())});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 or prod");a(n.command("deploy-all")).description("Deploy every service enabled for the environment, from this machine").action(async i=>{d(await Et({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 xt({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 De({all:i.all,root:i.root});d(c),c.structuredContent.allPassed||(Y.exitCode=1)});let s=e.command("vendor").description("Verify the mirrored vendor/ tree");return Tr(s.command("check")),xr(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 dt({fix:!!i.fix});I.enabled||ut(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=>{we({dryRun:!!i.dryRun})}),e.command("mcp").description("Run the infra-kit MCP server (stdio transport)").action(()=>{ve()}),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=!!(Y.stdout.isTTY&&Y.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 Me())}),e.command("version").description("Print the installed infra-kit CLI version").action(async()=>{d(await It())}),e.command("env-status").description("Show which env is loaded in this session (local introspection; no Doppler call)").action(async()=>{d(await gt())}),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 ft())}),e.command("init").description("Inject shell integration into .zshrc and sync repo agent-instruction files").action(async()=>{d(await ee())}),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 Ze({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 pt({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 he({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 ht({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 fe({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 pe({projectDir:i.projectDir})}),e.commands.forEach(vt),e.hook("preAction",async(i,c)=>{b.start(z(c)),I.enabled=!!c.optsWithGlobals().json,I.enabled&&(l.level="warn"),Ir.has(z(c))||await at(),q(),Cr(c.name())||await _({expectedTrigger:"cli-invocation"})}),e.hook("postAction",(i,c)=>{let m=z(c);if(Mt(m))return;let p=b.snapshot()?.formattedOptions??"",k=p?` ${p}`:"",R=`infra-kit ${m}${k}`;no({equivalent:K(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 jr}from"chalk";import{spawn as Ur}from"node:child_process";import S from"node:process";import{Chalk as Nr}from"chalk";var P=new Nr({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."},co={ok:{unicode:"\u2713",ascii:"[ok]"},findings:{unicode:"\u26A0",ascii:"[!]"},failed:{unicode:"\u2717",ascii:"[x]"},cancelled:{unicode:"\u2298",ascii:"[-]"}},lo={unicode:"\u2500",ascii:"-"},Lr=3,be=e=>e,_r={ok:e=>P.green(e),findings:e=>P.yellow(e),failed:e=>P.red(e),cancelled:e=>P.gray(e)},uo=e=>e?{dim:t=>P.dim(t),bold:t=>P.bold(t)}:{dim:be,bold:be},Dr=(e,t)=>e?_r[t]:be,mo=e=>[...e].length,po=(e,t={})=>{let o=uo(t.color===!0);return`${o.dim(w.reproPrefix.trim())} ${o.bold(e)}`},Or=e=>e<1e3?`${Math.round(e)}ms`:`${(e/1e3).toFixed(1)}s`,$r=(e,t)=>e==="findings"?t!=null?`${t} ${w.findingsSuffix}`:w.findingsPlain:{ok:w.ok,failed:w.failed,cancelled:w.cancelled}[e],Fr=(e,t,o,r)=>{if(t==null)return"";let n=t-2-e;return n<Lr?"":` ${r(o.repeat(n))}`},fo=e=>{let t=e.color===!0,o=uo(t),r=Dr(t,e.outcome),n=e.ascii===!0,a=e.equivalent.reproducible?w.reproPrefix:w.nonReproPrefix,s=n?co[e.outcome].ascii:co[e.outcome].unicode,i=$r(e.outcome,e.findingsCount),c=[Or(e.durationMs)],m=e.summary?.[0]?.split(`
|
|
7
|
+
`;var K=(e,t=!0)=>({line:e,reproducible:t});import B from"node:fs";import cr from"node:os";import lr from"node:path";import oo from"node:process";var H="INFRA_KIT_SESSION_REPORT",Ee=null,Zt=!1,eo=[],ro=(e=oo.env)=>{Zt||(Ee=e[H]??null,Zt=!0,delete e[H])};var no=(e,t)=>{if(!Ee)return;let o=e.summary??(eo.length>0?[...eo]:void 0),r={...e,...o?{summary:o}:{}},n=t?.write??((a,s)=>{B.writeFileSync(a,s)});try{n(Ee,JSON.stringify(r))}catch{}},to=0,io=e=>{let t=e?.tmpdir?.()??cr.tmpdir(),o=e?.pid??oo.pid;return to+=1,lr.join(t,`infra-kit-session-${o}-${to}.json`)},ao=(e,t)=>{if(!(t?.exists??(s=>B.existsSync(s)))(e))return null;let r=t?.read??(s=>B.readFileSync(s,"utf-8")),n=t?.unlink??(s=>B.unlinkSync(s)),a;try{a=r(e)}catch{return null}finally{try{n(e)}catch{}}try{return JSON.parse(a)}catch{return null}};var dr=(e,t)=>[...t,e],so=(e,t)=>{if(!(typeof e>"u")){if(e===!0)return"workspace";if(e===!1)return"none";if(typeof e=="string"&&oe.includes(e))return e;throw new Error(`Invalid ${t} value "${String(e)}". Expected one of: ${oe.join(", ")}.`)}},ur=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 yt({all:t.all,confirmedCommand:t.yes}))}),pr=e=>e.description("List all release branches").action(async()=>{d(await Rt())}),fr=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".',dr,[]).option("-y, --yes","Skip confirmation prompt").action(async t=>{let r=t.release.map(Tt),n=r.length>0?r:void 0;d(await bt({releases:n,confirmedCommand:t.yes}))}),gr=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 At({version:t.version,description:t.description,confirmedCommand:t.yes}))}),hr=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 St({version:t.version,env:t.env,skipTerraform:t.skipTerraform,confirmedCommand:t.yes}))}),vr=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 kt({version:t.version,env:t.env,services:t.services,skipTerraform:t.skipTerraform,confirmedCommand:t.yes}))}),yr=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 wt({version:t.version,confirmedCommand:t.yes}))}),wr=e=>e.description("Remove release worktrees whose PRs are no longer open").option("-y, --yes","Skip confirmation prompt").action(async t=>{d(await Dt({confirmedCommand:t.yes}))}),Sr=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=so(t.ide,"--ide")??so(t.cursor,"--cursor");d(await Nt({confirmedCommand:t.yes,all:t.all,versions:t.versions,ide:o,githubDesktop:t.githubDesktop,cmux:t.cmux}))}),kr=e=>e.description("List all git worktrees with detailed information").action(async()=>{d(await Lt())}),Rr=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 _t({confirmedCommand:t.yes,all:t.all,versions:t.versions}))}),Er=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 Pt({all:t.all,project:t.project,root:t.root,releaseOnly:t.releaseOnly,force:t.force,dryRun:t.dryRun}))}),xr=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 Re({init:t.init}))}),Tr=e=>e.description("Verify vendor/ matches vendor/.sync-manifest.json (self-contained; for any consumer repo)").action(async()=>{let t=await Ct();d(t),t.structuredContent.ok||(Y.exitCode=1)}),br=e=>e.description("Show the resolved config merge chain and file paths").action(async()=>{d(await se())}),Ar=e=>e.description("Open the user-scope per-project override file in $EDITOR").action(async()=>{d(await ce())}),Pr=new Set(["init","doctor","version","dev","self-update","mcp"]),Cr=e=>e.startsWith("env-")||Pr.has(e),Ir=new Set(["env-autoload","mcp","version","self-update"]),z=e=>{let t=[];for(let o=e;o&&o.parent;o=o.parent)t.unshift(o.name());return t.join(" ")},xe=()=>{let e=new mr,t=e.command("release").description("Release management commands");ur(t.command("merge-dev")),pr(t.command("list")),fr(t.command("create")),gr(t.command("desc-edit")),hr(t.command("deploy-all")),vr(t.command("deploy-selected")),yr(t.command("deliver"));let o=e.command("worktrees").description("Git worktree management commands");Sr(o.command("add")),kr(o.command("list")),Rr(o.command("remove")),wr(o.command("sync")),Er(e.command("reopen"));let r=e.command("config").description("Manage infra-kit configuration files");br(r.command("path")),Ar(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 Oe())});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 Et({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 xt({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 De({all:i.all,root:i.root});d(c),c.structuredContent.allPassed||(Y.exitCode=1)});let s=e.command("vendor").description("Verify the mirrored vendor/ tree");return Tr(s.command("check")),xr(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 dt({fix:!!i.fix});I.enabled||ut(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=>{we({dryRun:!!i.dryRun})}),e.command("mcp").description("Run the infra-kit MCP server (stdio transport)").action(()=>{ve()}),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=!!(Y.stdout.isTTY&&Y.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 Me())}),e.command("version").description("Print the installed infra-kit CLI version").action(async()=>{d(await It())}),e.command("env-status").description("Show which env is loaded in this session (local introspection; no Doppler call)").action(async()=>{d(await gt())}),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 ft())}),e.command("init").description("Inject shell integration into .zshrc and sync repo agent-instruction files").action(async()=>{d(await ee())}),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 Ze({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 pt({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 he({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 ht({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 fe({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 pe({projectDir:i.projectDir})}),e.commands.forEach(vt),e.hook("preAction",async(i,c)=>{b.start(z(c)),I.enabled=!!c.optsWithGlobals().json,I.enabled&&(l.level="warn"),Ir.has(z(c))||await at(),q(),Cr(c.name())||await _({expectedTrigger:"cli-invocation"})}),e.hook("postAction",(i,c)=>{let m=z(c);if(Mt(m))return;let p=b.snapshot()?.formattedOptions??"",k=p?` ${p}`:"",R=`infra-kit ${m}${k}`;no({equivalent:K(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 jr}from"chalk";import{spawn as Ur}from"node:child_process";import S from"node:process";import{Chalk as Nr}from"chalk";var P=new Nr({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."},co={ok:{unicode:"\u2713",ascii:"[ok]"},findings:{unicode:"\u26A0",ascii:"[!]"},failed:{unicode:"\u2717",ascii:"[x]"},cancelled:{unicode:"\u2298",ascii:"[-]"}},lo={unicode:"\u2500",ascii:"-"},Lr=3,be=e=>e,_r={ok:e=>P.green(e),findings:e=>P.yellow(e),failed:e=>P.red(e),cancelled:e=>P.gray(e)},uo=e=>e?{dim:t=>P.dim(t),bold:t=>P.bold(t)}:{dim:be,bold:be},Dr=(e,t)=>e?_r[t]:be,mo=e=>[...e].length,po=(e,t={})=>{let o=uo(t.color===!0);return`${o.dim(w.reproPrefix.trim())} ${o.bold(e)}`},Or=e=>e<1e3?`${Math.round(e)}ms`:`${(e/1e3).toFixed(1)}s`,$r=(e,t)=>e==="findings"?t!=null?`${t} ${w.findingsSuffix}`:w.findingsPlain:{ok:w.ok,failed:w.failed,cancelled:w.cancelled}[e],Fr=(e,t,o,r)=>{if(t==null)return"";let n=t-2-e;return n<Lr?"":` ${r(o.repeat(n))}`},fo=e=>{let t=e.color===!0,o=uo(t),r=Dr(t,e.outcome),n=e.ascii===!0,a=e.equivalent.reproducible?w.reproPrefix:w.nonReproPrefix,s=n?co[e.outcome].ascii:co[e.outcome].unicode,i=$r(e.outcome,e.findingsCount),c=[Or(e.durationMs)],m=e.summary?.[0]?.split(`
|
|
8
8
|
`)[0];m!=null&&m.length>0&&c.push(m);let u=`${s} ${i}`,p=`${w.sep}${c.join(w.sep)}`,k=mo(u)+mo(p),R=Fr(k,e.width,n?lo.ascii:lo.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
9
|
`)};var Mr=new Set([130,143]),go=(e,t,o,r=!1)=>o?t!=null||e===0?"ok":"findings":r&&e!=null&&Mr.has(e)||t==="SIGINT"||e===0?"cancelled":"failed";import ho 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"},vo=(e,t)=>{let o=t?.write??(a=>{ho.stderr.write(a)}),r=t?.stdin??ho.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 yo=e=>`infra-kit ${e.groupPath.join(" ")}`,Gr=()=>{let e=S.stderr.columns;return e!=null&&e>0?e:void 0},qr=e=>new Promise(t=>{e.on("exit",(o,r)=>{t({code:o,signal:r})}),e.on("error",()=>{t({code:1,signal:null})})}),Vr=async(e,t,o)=>{let r=io(),n={...t.env,[H]: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 qr(p)}catch{s={code:1,signal:null}}finally{t.resetTerminal({entersAltScreen:e.entersAltScreen})}let i=ao(r),c=go(s.code,s.signal,i!=null,e.longRunning),m=yo(e),u=i?.equivalent??K(m,!0);return fo({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)})},Wr=1e3,Jr=(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<=Wr||(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}},wo=(e,t)=>!!(t.stdoutIsTTY&&t.stdinIsTTY&&t.stderrIsTTY&&e.TERM!=="dumb"&&!e.INFRA_KIT_NO_SESSION&&!e.INFRA_KIT_SESSION_REPORT),So=async(e,t)=>{let o={spawn:t.spawn??Ur,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??jr.level>0,columns:t.columns??Gr,resetTerminal:t.resetTerminal??(c=>{vo(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:Jr(()=>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=po(yo(m),{color:o.color});r(`
|
|
10
10
|
${u}
|