infra-kit 0.7.12 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-75BE6MSY.js +7 -0
- package/dist/chunk-75BE6MSY.js.map +7 -0
- package/dist/chunk-FWINBDB5.js +444 -0
- package/dist/chunk-FWINBDB5.js.map +7 -0
- package/dist/{chunk-6OFUVD7F.js → chunk-GRWUCPQL.js} +1 -1
- package/dist/chunk-GRWUCPQL.js.map +7 -0
- package/dist/chunk-H5AAXCRJ.js +9 -0
- package/dist/chunk-H5AAXCRJ.js.map +7 -0
- package/dist/chunk-IXWQ7EQT.js +3 -0
- package/dist/chunk-IXWQ7EQT.js.map +7 -0
- package/dist/chunk-X2HFNQRU.js +10 -0
- package/dist/{chunk-T2WBH6YO.js.map → chunk-X2HFNQRU.js.map} +4 -4
- package/dist/cli.js +13 -13
- package/dist/cli.js.map +4 -4
- package/dist/dev-server.js +19 -19
- package/dist/dev-server.js.map +4 -4
- package/dist/dev-wizard-run-643QKSR3.js +2 -0
- package/dist/{dev-wizard-run-DRBMPH2O.js.map → dev-wizard-run-643QKSR3.js.map} +3 -3
- package/dist/mcp-proxy.js +1 -1
- package/dist/mcp.js +2 -2
- package/dist/mcp.js.map +3 -3
- package/dist/update-check.js +1 -1
- package/package.json +3 -3
- package/readme.md +1 -2
- package/dist/chunk-5FYZAIFC.js +0 -8
- package/dist/chunk-5FYZAIFC.js.map +0 -7
- package/dist/chunk-6OFUVD7F.js.map +0 -7
- package/dist/chunk-GFKYWEPW.js +0 -7
- package/dist/chunk-GFKYWEPW.js.map +0 -7
- package/dist/chunk-R6AYBYV6.js +0 -443
- package/dist/chunk-R6AYBYV6.js.map +0 -7
- package/dist/chunk-T2WBH6YO.js +0 -10
- package/dist/chunk-UNAV7SP4.js +0 -3
- package/dist/chunk-UNAV7SP4.js.map +0 -7
- package/dist/dev-wizard-run-DRBMPH2O.js +0 -2
package/dist/cli.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{$ as
|
|
2
|
+
import{$ as Ht,A as St,B as kt,C as Rt,D as Pt,E as ee,F as xt,G as Et,H as Ct,I as At,J as Tt,K as Dt,L as It,M as Lt,N as Nt,O as Ot,P as _t,Q as $t,S as Ft,T as Mt,V as te,W as jt,X as qt,Y as Ut,Z as Wt,_ as Gt,a as N,aa as Jt,b as Je,ba as Bt,c as Be,ca as Kt,da as Yt,e as Ke,f as Ye,fa as Vt,g as ze,ga as zt,h as Xe,ha as Xt,i as O,j as tt,k as st,l as F,m as at,n as ct,o as lt,p as dt,q as ut,r as mt,s as pt,t as ft,u as gt,v as Z,w as ht,x as vt,y as yt,z as wt}from"./chunk-FWINBDB5.js";import{b as Ve,c as _,d as Qe,e as Ze,f as et,g as P,i as ot,j as rt,k as $}from"./chunk-75BE6MSY.js";import{r as M}from"./chunk-X2HFNQRU.js";import{$ as Ge,P as l,Q as b,R as h,_ as Q,a as A,b as u,ba as He,c as Me,d as X,g as je,h as qe,w as Ue}from"./chunk-H5AAXCRJ.js";import{u as Fe}from"./chunk-GRWUCPQL.js";import"./chunk-MFAFQVTW.js";import{l as We}from"./chunk-IXWQ7EQT.js";import{k as Oe,m as _e,n as $e}from"./chunk-HHWP3YXW.js";import{a as L,b as Ae,d as Te,g as De,h as Ie,k as z,l as Le,q as y,t as Ne}from"./chunk-75URROMU.js";import{a as bt}from"./chunk-TVG47UHG.js";import{a as nt,b as it}from"./chunk-QWVLAZ6N.js";import Pn,{Separator as jo}from"@inquirer/select";import{existsSync as xn,realpathSync as bn}from"node:fs";import{homedir as En}from"node:os";import g from"node:process";import{fileURLToPath as Uo}from"node:url";var Ho=(e,t)=>{let o=e,r;for(let n of t){if(r=o.find(s=>s.name()===n),!r)return;o=r.commands}return r},Qt=e=>Kt.flatMap(({key:t,label:o})=>Vt(t).flatMap(r=>{let n=Ho(e,r.groupPath);return n?[{name:r.groupPath.join(" "),description:n.description(),group:o}]:[]}));import{Command as Sr}from"commander";import{resolve as kr}from"node:path";import S from"node:process";import{cd as Rr}from"zx";import Zt from"node:process";import{$ as Jo}from"zx";var oe=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 a=>({...a,exists:await b(a.path)}))),o=t.at(-1)?.exists===!0,r=await yt(e.userProject,o),n=o?wt(r):"";l.info(`Project name: ${e.projectName}
|
|
3
3
|
`),l.info(`Config merge chain (later overrides earlier):
|
|
4
|
-
`);for(let a of t){let i=a.exists?" [\u2713]":" [ ]",c=a.path===e.userProject&&n!==""?` ${n}`:"";l.info(`${i} ${a.label.padEnd(22)} ${h(a.path)}${c}`)}let s={projectName:e.projectName,layers:t.map(a=>({label:a.label,path:a.path,exists:a.exists})),hasOverrides:r.hasOverrides,overrideKeys:r.overrideKeys};return{content:[{type:"text",text:JSON.stringify(s,null,2)}],structuredContent:s}},
|
|
5
|
-
`))},
|
|
6
|
-
`),
|
|
7
|
-
`;var J=(e,t=!0)=>({line:e,reproducible:t});import
|
|
8
|
-
`),u(e)),yr=e=>e.description("List all release branches").action(async()=>{u(await Dt())}),wr=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".',hr,[]).option("-y, --yes","Skip confirmation prompt").action(async t=>{let r=t.release.map(gt),n=r.length>0?r:void 0;u(await Nt({releases:n,confirmedCommand:t.yes}))}),Sr=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=>{u(await Ot({version:t.version,description:t.description,confirmedCommand:t.yes}))}),vo=e=>e.option("-f, --from <where>",`Where the deploy runs: ${bt.join(" | ")} (required)`).option("-v, --version <version>",'With --from ci: version (e.g. 1.2.5) or release name to deploy; "dev" deploys from the dev branch. Prompts when omitted').option("-e, --env <env>","Specify the environment to deploy to, e.g. dev").option("-y, --yes","Skip confirmation prompt").option("--skip-terraform","With --from ci: skip the terraform deployment step").option("--dry-run","With --from local: resolve target, contract and commands without deploying").option("--print-env","With --from local: print the resolved build contract"),kr=e=>vo(e).description("Deploy every service to any environment, in CI or from this machine").action(async t=>{u(await pe({from:t.from,version:t.version,env:t.env,skipTerraform:t.skipTerraform,yes:t.yes,dryRun:t.dryRun,printEnv:t.printEnv}))}),Rr=e=>vo(e).description("Deploy selected services to any environment, in CI or from this machine").option("-s, --services <services...>","Specify services to deploy, e.g. client-be client-fe").action(async t=>{u(await fe({from:t.from,version:t.version,env:t.env,services:t.services,skipTerraform:t.skipTerraform,yes:t.yes,dryRun:t.dryRun,printEnv:t.printEnv}))}),Pr=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=>{u(await xt({version:t.version,confirmedCommand:t.yes}))}),xr=e=>e.description("Tear down a release: worktree, PR, branches, and the Jira fix version").option("-v, --version <version>","Version (e.g. 1.2.5) or release name (e.g. checkout-redesign) to remove").option("--move-issues-to <version>","Reassign issues carrying the fix version to this version before removing it").option("--skip-jira","Remove everything except the Jira fix version").option("-y, --yes","Skip confirmation prompt").action(async t=>{u(await _t({version:t.version,moveIssuesTo:t.moveIssuesTo,skipJira:t.skipJira,confirmedCommand:t.yes}))}),br=e=>e.description("Remove release worktrees whose PRs are no longer open").option("-y, --yes","Skip confirmation prompt").action(async t=>{u(await Gt({confirmedCommand:t.yes}))}),Cr=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=go(t.ide,"--ide")??go(t.cursor,"--cursor");u(await qt({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()=>{u(await Ut())}),Ar=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=>{u(await Wt({confirmedCommand:t.yes,all:t.all,versions:t.versions}))}),Tr=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=>{u(await $t({all:t.all,project:t.project,root:t.root,releaseOnly:t.releaseOnly,force:t.force,dryRun:t.dryRun}))}),Dr=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=>{u(await ve({init:t.init}))}),Ir=e=>e.description("Verify vendor/ matches vendor/.sync-manifest.json (self-contained; for any consumer repo)").action(async()=>{let t=await jt();u(t),t.structuredContent.ok||(P.exitCode=1)}),Lr=e=>e.description("Show the resolved config merge chain and file paths").action(async()=>{u(await te())}),Nr=e=>e.description("Open the user-scope per-project override file in $EDITOR").action(async()=>{u(await oe())}),Or=new Set(["setup","doctor","version","dev","mcp"]),_r=e=>e.startsWith("env-")||Or.has(e),$r=new Set(["env-autoload","mcp","version"]),H=e=>{let t=[];for(let o=e;o&&o.parent;o=o.parent)t.unshift(o.name());return t.join(" ")},Se=()=>{let e=new gr,t=e.command("release").description("Release management commands");vr(t.command("merge-dev")),yr(t.command("list")),wr(t.command("create")),Sr(t.command("desc-edit")),kr(t.command("deploy-all")),Rr(t.command("deploy-selected")),Pr(t.command("deliver")),xr(t.command("remove"));let o=e.command("worktrees").description("Git worktree management commands");Cr(o.command("add")),Er(o.command("list")),Ar(o.command("remove")),br(o.command("sync")),Tr(e.command("reopen"));let r=e.command("config").description("Manage infra-kit configuration files");Lr(r.command("path")),Nr(r.command("edit")),e.command("config-get").description("Print the fully merged infra-kit config (project + user-global + per-project override layers)").action(async()=>{u(await Ge())});let n=e.command("local").description("Deprecated \u2014 use `release deploy-all|deploy-selected --from local`"),s=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");s(n.command("deploy-all")).description("Deprecated \u2014 use `release deploy-all --from local`").action(async i=>{u(await G({env:i.env,yes:i.yes,dryRun:i.dryRun,printEnv:i.printEnv},"all"))}),s(n.command("deploy-selected")).description("Deprecated \u2014 use `release deploy-selected --from local`").option("-s, --service <name...>","Service name(s), as in deploy-<name>.sh (prompts when omitted)").action(async i=>{u(await G({env:i.env,services:i.service,yes:i.yes,dryRun:i.dryRun,printEnv:i.printEnv},"selected"))}),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)").option("--fix","Write the infra-kit guidance block into CLAUDE.md for the audited scope before checking (CLI-only)").option("--design","With --fix: scaffold DESIGN.md for frontend/mobile packages that lack one").action(async i=>{if(i.design&&!i.fix){l.error("--design requires --fix (it scaffolds DESIGN.md; there is nothing to scaffold without a fix run)"),P.exitCode=1;return}let c=await We({all:i.all,root:i.root,fix:i.fix,design:i.design});u(c);let{allPassed:m,fixed:d}=c.structuredContent,p=(d??[]).some(k=>k.action==="failed");(!m||p)&&(P.exitCode=1)});let a=e.command("vendor").description("Verify the mirrored vendor/ tree");return Ir(a.command("check")),Dr(a.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 ht({fix:!!i.fix});A.enabled||Ke(c.structuredContent.checks,{ascii:!!i.ascii}),c.structuredContent.checks.some(d=>d.name==="plugin installed"&&d.status==="fail")&&(P.exitCode=1),u(c)}),e.command("mcp").description("Run the infra-kit MCP server (stdio transport)").action(()=>{ue()}),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"),d=!!(P.stdout.isTTY&&P.stdin.isTTY);await m({...c,preset:i},d,A.enabled)}),e.command("dev-status").description("Show what `infra-kit dev` currently has running (reads dev-context fragments; starts nothing)").action(async()=>{u(await Je())}),e.command("setup").description("Set this machine up: shell integration, agent files, MCP server, then the external tools").option("--tools <ids...>","Limit to these tools (brew, aws, gh, doppler, portless)").option("--update [ids...]","Update what is already installed; never install a missing tool").option("--skip-tools","Do the local setup only, then REPORT what each tool needs \u2014 installs nothing").action(async i=>{u(await Ft({tools:i.tools,update:i.update,skipTools:i.skipTools}))}),e.command("version").description("Print the installed infra-kit CLI version").action(async()=>{u(await Mt())}),e.command("env-status").description("Show which env is loaded in this session (local introspection; no Doppler call)").action(async()=>{u(await yt())}),e.command("env-list").description("List available Doppler configs for the detected project, and whether a service token resolves for each").action(async()=>{u(await tt())}),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=>{ho(await rt({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=>{ho(await vt({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)=>{u(await de({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=>{u(await wt({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=>{u(await ce({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 ae({projectDir:i.projectDir})}),e.commands.forEach(St),we(e),e.hook("preAction",async(i,c)=>{R.start(H(c)),A.enabled=!!c.optsWithGlobals().json,A.enabled&&(l.level="warn"),$r.has(H(c))||await lt(),M(),_r(c.name())||await I({expectedTrigger:"cli-invocation"})}),e.hook("postAction",(i,c)=>{let m=H(c);if(Ht(m))return;let p=R.snapshot()?.formattedOptions??"",k=p?` ${p}`:"",E=`infra-kit ${m}${k}`;mo({equivalent:J(E,!0)})}),e};var ke=(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 rn}from"chalk";import{spawn as nn}from"node:child_process";import v from"node:process";import{Chalk as Fr}from"chalk";var C=new Fr({level:1}),S={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."},jr={suspend:{unicode:"any key commands \xB7 Esc / Ctrl-C quit \xB7 Ctrl-Z suspend",ascii:"any key commands - Esc / Ctrl-C quit - Ctrl-Z suspend"},plain:{unicode:"any key commands \xB7 Esc / Ctrl-C quit",ascii:"any key commands - Esc / Ctrl-C quit"}},yo={ok:{unicode:"\u2713",ascii:"[ok]"},findings:{unicode:"\u26A0",ascii:"[!]"},failed:{unicode:"\u2717",ascii:"[x]"},cancelled:{unicode:"\u2298",ascii:"[-]"}},wo={unicode:"\u2500",ascii:"-"},Mr=3,Re=e=>e,qr={ok:e=>C.green(e),findings:e=>C.yellow(e),failed:e=>C.red(e),cancelled:e=>C.gray(e)},xe=e=>e?{dim:t=>C.dim(t),bold:t=>C.bold(t)}:{dim:Re,bold:Re},Ur=(e,t)=>e?qr[t]:Re,Pe=e=>[...e].length,Wr=(e,t)=>{if(t==null)return e;let o=Math.max(0,t-1);return Pe(e)<=o?e:[...e].slice(0,o).join("")},So=e=>{let t=xe(e.color===!0).dim,o=jr[e.canSuspend?"suspend":"plain"],r=e.ascii===!0?o.ascii:o.unicode;return t(Wr(r,e.width))},ko=(e,t={})=>{let o=xe(t.color===!0);return`${o.dim(S.reproPrefix.trim())} ${o.bold(e)}`},Gr=e=>e<1e3?`${Math.round(e)}ms`:`${(e/1e3).toFixed(1)}s`,Jr=(e,t)=>e==="findings"?t!=null?`${t} ${S.findingsSuffix}`:S.findingsPlain:{ok:S.ok,failed:S.failed,cancelled:S.cancelled}[e],Kr=(e,t,o,r)=>{if(t==null)return"";let n=t-2-e;return n<Mr?"":` ${r(o.repeat(n))}`},Ro=e=>{let t=e.color===!0,o=xe(t),r=Ur(t,e.outcome),n=e.ascii===!0,s=e.equivalent.reproducible?S.reproPrefix:S.nonReproPrefix,a=n?yo[e.outcome].ascii:yo[e.outcome].unicode,i=Jr(e.outcome,e.findingsCount),c=[Gr(e.durationMs)],m=e.summary?.[0]?.split(`
|
|
9
|
-
`)[0];m!=null&&m.length>0&&c.push(m);let d=`${a} ${i}`,p=`${
|
|
10
|
-
`)};var
|
|
11
|
-
`,
|
|
12
|
-
${
|
|
13
|
-
`),i.childStarted();let
|
|
14
|
-
${
|
|
15
|
-
`),await m(c)==="quit")return}}finally{i.dispose()}};
|
|
4
|
+
`);for(let a of t){let i=a.exists?" [\u2713]":" [ ]",c=a.path===e.userProject&&n!==""?` ${n}`:"";l.info(`${i} ${a.label.padEnd(22)} ${h(a.path)}${c}`)}let s={projectName:e.projectName,layers:t.map(a=>({label:a.label,path:a.path,exists:a.exists})),hasOverrides:r.hasOverrides,overrideKeys:r.overrideKeys};return{content:[{type:"text",text:JSON.stringify(s,null,2)}],structuredContent:s}},re=async()=>{let e=await Q(),t=Zt.env.EDITOR||Zt.env.VISUAL||"vi",o=await mt(e);o.createdConfig&&l.info(pt(o)),l.info(`Opening ${h(e.userProject)} in ${t} (per-machine override \u2014 every key except "mcp")`),await Jo({stdio:"inherit"})`${t} ${e.userProject}`,He();let r={path:e.userProject,editor:t};return{content:[{type:"text",text:JSON.stringify(r,null,2)}],structuredContent:r}};var ne=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}},T=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 w from"node:path";import D from"node:process";var Bo="autoload-warn-fail.flag",ie="autoload-warn-auth-fail.flag",se="autoload-fail.flag",ae="autoload-auth-fail.json",Ko=3e4,to=async(e=!0)=>{let t;try{t=await Ge()}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 tt(o.config))return r}catch{return r}return ro({config:o.config,reason:`No Doppler service token for env "${o.config}"`,at:Date.now()}),e&&j(T(o.config),ie),null},oo=e=>{let{trigger:t,expectedTrigger:o,targetConfig:r,targetProject:n,env:s,force:a}=e;return t!==o||!s.session||s.cleared||s.currentConfig&&!s.autoLoadedMarker||!a&&s.autoLoadedMarker&&s.currentConfig===r&&s.currentProject===n?"skip":"load"},I=async({expectedTrigger:e,projectDir:t,force:o,isAuthFailure:r=Ve})=>{let n=e==="cli-invocation";n&&q();let s=null;try{if(s=await to(n),!s||oo({trigger:s.trigger,expectedTrigger:e,targetConfig:s.config,targetProject:s.project,env:zo(),force:o})==="skip"||eo()||Zo())return null;let i=Xo(),c=await at({config:s.config,autoLoaded:!0,projectDir:t,beforeWrite:()=>!eo()&&!Qo(i)});return c?(tr(),Vo(),c.filePath):null}catch(a){let i=a.message,c=r(a);return er(),c&&s&&ro({config:s.config,reason:i,at:Date.now()}),n&&c&&s?(j(T(s.config),ie),l.debug(`env auto-load auth failure: ${i}`)):n?j(`infra-kit: env auto-load failed \u2014 ${i} (will retry later)`,Bo):l.debug(`env auto-load skipped: ${i}`),null}},q=()=>{let e=Yo();e&&(j(T(e.config),ie),l.debug(`env auto-load auth failure (recorded ${new Date(e.at).toISOString()}): ${e.reason}`))},Yo=()=>{try{let e=f.readFileSync(w.join(y(),ae),"utf-8");return ne(JSON.parse(e))}catch{return null}},ro=e=>{try{let t=y();f.mkdirSync(t,{recursive:!0,mode:448}),Ne(w.join(t,ae),JSON.stringify(e),384)}catch{}},Vo=()=>{try{f.rmSync(w.join(y(),ae),{force:!0})}catch{}},zo=()=>({session:D.env[Te],cleared:D.env[Le],currentConfig:D.env[De],currentProject:D.env[Ie],autoLoadedMarker:D.env[z]}),Xo=()=>{try{return f.statSync(w.join(y(),L)).mtimeMs}catch{return null}},Qo=e=>{try{let t=w.join(y(),L);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}},eo=()=>{try{let e=y(),t=w.join(e,Ae);if(!f.existsSync(t))return!1;let o=w.join(e,L);return f.existsSync(o)?f.statSync(t).mtimeMs>=f.statSync(o).mtimeMs:!0}catch{return!1}},Zo=()=>{try{let e=w.join(y(),se);return f.existsSync(e)?Date.now()-f.statSync(e).mtimeMs<Ko:!1}catch{return!1}},er=()=>{try{let e=y();f.mkdirSync(e,{recursive:!0,mode:448}),f.writeFileSync(w.join(e,se),"",{mode:384})}catch{}},tr=()=>{try{f.rmSync(w.join(y(),se),{force:!0})}catch{}},j=(e,t)=>{try{let o=y(),r=w.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 ce=async({projectDir:e}={})=>{await I({expectedTrigger:"shell-startup",projectDir:e,force:!0})};var no="https://dashboard.doppler.com/workplace/projects",or=(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}"): ${no}/${e}`],le=async({env:e})=>{let o=!!(await Qe())?.envs[e];await et(e);let r=await F(),n=await O(),s=await _();o?l.info(`Removed the "${e}" service token from ${h(s)}.`):l.info(`No "${e}" service token was stored in ${h(s)} \u2014 nothing to remove.`),r.length>0&&l.info(`Purged ${r.length} warm cache(s) across this repo's worktrees.`);for(let i of or(n,e))l.warn(i);let a={env:e,removed:o,storePath:s,warmCachesPurged:r.length,revokeUrl:`${no}/${n}`};return{content:N(JSON.stringify(a,null,2)),structuredContent:a}};import rr from"@inquirer/password";import W from"node:process";import{$ as U}from"zx";var nr=async({stdin:e,fromEnv:t})=>{if(e)return{token:await ir(),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 P.setInteractive(),{token:(await $(r=>rr({message:"Paste the Doppler service token (input is hidden)",mask:!0},r),{output:W.stderr})).trim(),source:"prompt"}},ir=async()=>{let e=[];W.stdin.setEncoding("utf8");for await(let t of W.stdin)e.push(t);return e.join("").trim()},de="DOPPLER_CONFIG",sr=3e4,ar=async(e,t,o)=>{let r=U.quiet;U.quiet=!0;let n;try{n=(await U({env:lt(e)})`doppler secrets download --no-file --format json --project ${t} --config ${o}`.timeout(sr)).stdout}catch(s){throw cr(s,o)}finally{U.quiet=r}return ut(n)},cr=(e,t)=>{let o=qe(e)??(e instanceof Error?e.message:String(e));if(ze(o)!=="auth")return e instanceof Error?e:new Error(String(e));let r=Xe(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
|
+
`))},lr=e=>[`Could not verify this token's scope: the Doppler payload for "${e}" carries no ${de}.`,"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
|
+
`),ue=async({env:e,stdin:t,fromEnv:o,force:r})=>{let n=await O(),{token:s,source:a}=await nr({stdin:t,fromEnv:o});if(!s)throw new Error("No token provided \u2014 nothing was written.");let i=await ar(s,n,e);dt(i,e);let c=i.some(([R])=>R===de);if(!c&&!r)throw new Error(lr(e));await Ze(e,s);let m=await F(),d=await _();l.info(`Stored the "${e}" service token (${ee(s)}) in ${h(d)} (mode 0600).`),c||l.warn(`Scope was NOT verified (no ${de} 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:a,redactedToken:ee(s),storePath:d,scopeVerified:c,warmCachesPurged:m.length};return P.print(),{content:N(JSON.stringify(p,null,2)),structuredContent:p}};import{spawn as dr}from"node:child_process";import G from"node:process";import{fileURLToPath as ur}from"node:url";var mr=["SIGINT","SIGTERM"],io=()=>ur(new URL("./mcp.js",import.meta.url)),me=(e={})=>{let t=e.spawn??dr,o=e.exit??(a=>G.exit(a)),r=e.env??G.env,n=e.onError??(a=>l.error(a)),s=t(G.execPath,[io()],{stdio:"inherit",env:$e(r)});s.on("error",a=>{n(`failed to launch the MCP server: ${a.message}`),o(1)}),mr.forEach(a=>{G.on(a,()=>{s.kill(a)})}),s.on("exit",(a,i)=>{o(i?1:a??1)})};var pe=async(e,t,o=!0)=>{let{from:r,version:n,env:s,services:a,skipTerraform:i,yes:c,dryRun:m,printEnv:d}=e,p=await It(r);return o&&P.addOption("--from",p),Dt(p,{"--version":n,"--skip-terraform":i,"--dry-run":m,"--print-env":d}),p==="local"?t==="all"?_t({env:s,confirmedCommand:c,dryRun:m,printEnv:d}):$t({env:s,service:a,confirmedCommand:c,dryRun:m,printEnv:d}):t==="all"?Lt({version:n,env:s,skipTerraform:i,confirmedCommand:c}):Nt({version:n,env:s,services:a,skipTerraform:i,confirmedCommand:c})},fe=async e=>pe(e,"all"),ge=async e=>pe(e,"selected"),H=async(e,t)=>{let o=`release deploy-${t} --from local`;return l.warn(`\`local deploy-${t}\` is deprecated and will be removed \u2014 use \`${o}\` instead.`),pe({...e,from:"local"},t,!1)};import{VENDOR_CONFIG_FILE as ao}from"@slip-stream-kit/config/internal";import he from"node:fs/promises";import ve from"node:path";import so from"node:process";import{pathToFileURL as pr}from"node:url";var co="~/projects",ye=async(e={})=>{if(e.init){await gr(e.cwd);return}await fr()},fr=async()=>{let e=Z(),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."),so.exitCode=1;return}let{workspaceDir:o,targets:r}=await vt(),n=ht(o),s=await b(n);l.info(`workspaceDir: ${o} (resolved: ${n}) ${s?"[\u2713 exists]":"[ ] not found"}`),l.info("Targets:");let a=s;for(let i of r){let c=ve.join(n,i),m=await b(c);m||(a=!1);let d=m?"[\u2713]":"[ ]",p=m?"":" (not found \u2014 clone or remove)";l.info(` ${d} ${i} ${h(c)}${p}`)}a||(so.exitCode=1)},gr=async e=>{let t=Z();if(await b(t)){l.info(`Factory config already exists at ${h(t)} \u2014 leaving it untouched.`);return}let o=e??await Ue(),r=await hr(o);await he.mkdir(ve.dirname(t),{recursive:!0}),await he.writeFile(t,vr(r),"utf-8"),l.info(`\u2713 Created ${h(t)}`),r.length>0&&l.info(` Seeded ${r.length} target(s) from the source ${ao}.`),l.info(` Edit \`workspaceDir\` (placeholder: ${co}) 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.")},hr=async e=>{try{let t=ve.join(e,ao),o=await he.stat(t),s=(await import(`${pr(t).href}?mtime=${Number(o.mtimeMs)}`)).default,a=typeof s=="function"?await s():s;if(a&&typeof a=="object"&&"targets"in a){let i=a.targets;if(Array.isArray(i)&&i.every(c=>typeof c=="string"))return i}}catch{}return[]},vr=e=>`${JSON.stringify({workspaceDir:co,targets:e},null,2)}
|
|
7
|
+
`;var J=(e,t=!0)=>({line:e,reproducible:t});import B from"node:fs";import yr from"node:os";import wr from"node:path";import po from"node:process";var K="INFRA_KIT_SESSION_REPORT",we=null,lo=!1,uo=[],fo=(e=po.env)=>{lo||(we=e[K]??null,lo=!0,delete e[K])};var go=(e,t)=>{if(!we)return;let o=e.summary??(uo.length>0?[...uo]:void 0),r={...e,...o?{summary:o}:{}},n=t?.write??((s,a)=>{B.writeFileSync(s,a)});try{n(we,JSON.stringify(r))}catch{}},mo=0,ho=e=>{let t=e?.tmpdir?.()??yr.tmpdir(),o=e?.pid??po.pid;return mo+=1,wr.join(t,`infra-kit-session-${o}-${mo}.json`)},vo=(e,t)=>{if(!(t?.exists??(a=>B.existsSync(a)))(e))return null;let r=t?.read??(a=>B.readFileSync(a,"utf-8")),n=t?.unlink??(a=>B.unlinkSync(a)),s;try{s=r(e)}catch{return null}finally{try{n(e)}catch{}}try{return JSON.parse(s)}catch{return null}};var Se=e=>{e.options.some(o=>o.long==="--agent")||e.option("--agent","Run as an agent: never prompt; refuse with a structured payload (under --json) naming what to pass instead"),e.commands.forEach(Se)};var ke=e=>{e.options.some(o=>o.long==="--debug")||e.option("--debug","Raise the log level to debug (logs stay on stderr)"),e.commands.forEach(ke)};var Pr=(e,t)=>[...t,e],yo=(e,t)=>{if(!(typeof e>"u")){if(e===!0)return"workspace";if(e===!1)return"none";if(typeof e=="string"&&te.includes(e))return e;throw new Error(`Invalid ${t} value "${String(e)}". Expected one of: ${te.join(", ")}.`)}},xr=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 Et(()=>Ct({all:t.all,versions:t.versions,dryRun:t.dryRun,verify:t.verify,confirmedCommand:t.yes}));u(o),o.structuredContent.failedMerges>0&&(S.exitCode=1)}),wo=e=>(S.stdout.write(`${e.structuredContent.filePath}
|
|
8
|
+
`),u(e)),br=e=>e.description("List all release branches").action(async()=>{u(await Ot())}),Er=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(St),n=r.length>0?r:void 0;u(await Ft({releases:n,confirmedCommand:t.yes}))}),Cr=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=>{u(await Mt({version:t.version,description:t.description,confirmedCommand:t.yes}))}),So=e=>e.option("-f, --from <where>",`Where the deploy runs: ${Tt.join(" | ")} (required)`).option("-v, --version <version>",'With --from ci: version (e.g. 1.2.5) or release name to deploy; "dev" deploys from the dev branch. Prompts when omitted').option("-e, --env <env>","Specify the environment to deploy to, e.g. dev").option("-y, --yes","Skip confirmation prompt").option("--skip-terraform","With --from ci: skip the terraform deployment step").option("--dry-run","With --from local: resolve target, contract and commands without deploying").option("--print-env","With --from local: print the resolved build contract"),Ar=e=>So(e).description("Deploy every service to any environment, in CI or from this machine").action(async t=>{u(await fe({from:t.from,version:t.version,env:t.env,skipTerraform:t.skipTerraform,yes:t.yes,dryRun:t.dryRun,printEnv:t.printEnv}))}),Tr=e=>So(e).description("Deploy selected services to any environment, in CI or from this machine").option("-s, --services <services...>","Specify services to deploy, e.g. client-be client-fe").action(async t=>{u(await ge({from:t.from,version:t.version,env:t.env,services:t.services,skipTerraform:t.skipTerraform,yes:t.yes,dryRun:t.dryRun,printEnv:t.printEnv}))}),Dr=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=>{u(await At({version:t.version,confirmedCommand:t.yes}))}),Ir=e=>e.description("Tear down a release: worktree, PR, branches, and the Jira fix version").option("-v, --version <version>","Version (e.g. 1.2.5) or release name (e.g. checkout-redesign) to remove").option("--move-issues-to <version>","Reassign issues carrying the fix version to this version before removing it").option("--skip-jira","Remove everything except the Jira fix version").option("-y, --yes","Skip confirmation prompt").action(async t=>{u(await jt({version:t.version,moveIssuesTo:t.moveIssuesTo,skipJira:t.skipJira,confirmedCommand:t.yes}))}),Lr=e=>e.description("Remove release worktrees whose PRs are no longer open").option("-y, --yes","Skip confirmation prompt").action(async t=>{u(await Bt({confirmedCommand:t.yes}))}),Nr=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("--orca","Open created worktrees in Orca (pane layout from worktrees.orca.layout)").option("--no-orca","Skip the Orca prompt").action(async t=>{let o=yo(t.ide,"--ide")??yo(t.cursor,"--cursor");u(await Gt({confirmedCommand:t.yes,all:t.all,versions:t.versions,ide:o,githubDesktop:t.githubDesktop,orca:t.orca}))}),Or=e=>e.description("List all git worktrees with detailed information").action(async()=>{u(await Ht())}),_r=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=>{u(await Jt({confirmedCommand:t.yes,all:t.all,versions:t.versions}))}),$r=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=>{u(await ye({init:t.init}))}),Fr=e=>e.description("Verify vendor/ matches vendor/.sync-manifest.json (self-contained; for any consumer repo)").action(async()=>{let t=await Ut();u(t),t.structuredContent.ok||(S.exitCode=1)}),Mr=e=>e.description("Show the resolved config merge chain and file paths").action(async()=>{u(await oe())}),jr=e=>e.description("Open the user-scope per-project override file in $EDITOR").action(async()=>{u(await re())}),qr=new Set(["setup","doctor","version","dev","mcp"]),Ur=e=>e.startsWith("env-")||qr.has(e),Wr=new Set(["env-autoload","mcp","version"]),Y=e=>{let t=[];for(let o=e;o&&o.parent;o=o.parent)t.unshift(o.name());return t.join(" ")},Re=()=>{let e=new Sr().option("-C <dir>","Run as if infra-kit was started in <dir> instead of the current working directory"),t=e.command("release").description("Release management commands");xr(t.command("merge-dev")),br(t.command("list")),Er(t.command("create")),Cr(t.command("desc-edit")),Ar(t.command("deploy-all")),Tr(t.command("deploy-selected")),Dr(t.command("deliver")),Ir(t.command("remove"));let o=e.command("worktrees").description("Git worktree management commands");Nr(o.command("add")),Or(o.command("list")),_r(o.command("remove")),Lr(o.command("sync"));let r=e.command("config").description("Manage infra-kit configuration files");Mr(r.command("path")),jr(r.command("edit")),e.command("config-get").description("Print the fully merged infra-kit config (project + user-global + per-project override layers)").action(async()=>{u(await Be())});let n=e.command("local").description("Deprecated \u2014 use `release deploy-all|deploy-selected --from local`"),s=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");s(n.command("deploy-all")).description("Deprecated \u2014 use `release deploy-all --from local`").action(async i=>{u(await H({env:i.env,yes:i.yes,dryRun:i.dryRun,printEnv:i.printEnv},"all"))}),s(n.command("deploy-selected")).description("Deprecated \u2014 use `release deploy-selected --from local`").option("-s, --service <name...>","Service name(s), as in deploy-<name>.sh (prompts when omitted)").action(async i=>{u(await H({env:i.env,services:i.service,yes:i.yes,dryRun:i.dryRun,printEnv:i.printEnv},"selected"))}),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)").option("--fix","Write the infra-kit guidance block into CLAUDE.md for the audited scope before checking (CLI-only)").option("--design","With --fix: scaffold DESIGN.md for frontend/mobile packages that lack one").action(async i=>{if(i.design&&!i.fix){l.error("--design requires --fix (it scaffolds DESIGN.md; there is nothing to scaffold without a fix run)"),S.exitCode=1;return}let c=await Je({all:i.all,root:i.root,fix:i.fix,design:i.design});u(c);let{allPassed:m,fixed:d}=c.structuredContent,p=(d??[]).some(R=>R.action==="failed");(!m||p)&&(S.exitCode=1)});let a=e.command("vendor").description("Verify the mirrored vendor/ tree");return Fr(a.command("check")),$r(a.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 kt({fix:!!i.fix});A.enabled||Ye(c.structuredContent.checks,{ascii:!!i.ascii}),c.structuredContent.checks.some(d=>d.name==="plugin installed"&&d.status==="fail")&&(S.exitCode=1),u(c)}),e.command("mcp").description("Run the infra-kit MCP server (stdio transport)").action(()=>{me()}),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("--orca","Run each app in its own Orca pane (one tab, N panes; falls back to single terminal when Orca is not running)").option("--self","Run only the app of the current directory (infer from cwd; use inside apps/<app>/\u2026)").option("-V, --verbose","Print full boot narration (default: quiet; full detail always in the session log)").option("--routes","Print each app\u2019s registered METHOD /path routes at startup (default: off)").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"),d=!!(S.stdout.isTTY&&S.stdin.isTTY);await m({...c,preset:i},d,A.enabled)}),e.command("dev-status").description("Show what `infra-kit dev` currently has running (reads dev-context fragments; starts nothing)").action(async()=>{u(await Ke())}),e.command("setup").description("Set this machine up: shell integration, agent files, the Claude Code skills plugin, then the external tools").option("--tools <ids...>","Limit to these tools (brew, aws, gh, doppler, portless)").option("--update [ids...]","Update what is already installed; never install a missing tool").option("--skip-tools","Do the local setup only, then REPORT what each tool needs \u2014 installs nothing").action(async i=>{u(await qt({tools:i.tools,update:i.update,skipTools:i.skipTools}))}),e.command("version").description("Print the installed infra-kit CLI version").action(async()=>{u(await Wt())}),e.command("env-status").description("Show which env is loaded in this session (local introspection; no Doppler call)").action(async()=>{u(await Pt())}),e.command("env-list").description("List available Doppler configs for the detected project, and whether a service token resolves for each").action(async()=>{u(await st())}),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=>{wo(await ct({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=>{wo(await Rt({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)=>{u(await ue({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=>{u(await xt({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=>{u(await le({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 ce({projectDir:i.projectDir})}),e.commands.forEach(Me),Se(e),ke(e),e.hook("preAction",async(i,c)=>{let{C:m}=e.opts();m!==void 0&&Rr(kr(S.cwd(),m)),P.start(Y(c)),A.enabled=!!c.optsWithGlobals().json,A.enabled&&(l.level="warn"),X.source!=="mcp"&&(X.source=je({env:S.env,stdinIsTTY:S.stdin.isTTY===!0,flag:!!c.optsWithGlobals().agent})),Wr.has(Y(c))||await ft(),q(),Ur(c.name())||await I({expectedTrigger:"cli-invocation"})}),e.hook("postAction",(i,c)=>{let m=Y(c);if(zt(m))return;let p=P.snapshot()?.formattedOptions??"",R=p?` ${p}`:"",C=`infra-kit ${m}${R}`;go({equivalent:J(C,!0)})}),e};import Gr from"node:process";var Hr={exit:Gr.exit,emit:u,logger:l},ko=(e,t=Hr)=>M(e)?(t.logger.info("Operation cancelled."),t.exit(0)):e instanceof ot?(t.emit({structuredContent:e.structuredContent}),t.logger.error(e.message),t.exit(e.exitCode)):(t.logger.error(e instanceof Error?e.message:String(e)),t.exit(1));var Pe=(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 mn}from"chalk";import{spawn as pn}from"node:child_process";import v from"node:process";import{Chalk as Jr}from"chalk";var E=new Jr({level:1}),k={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."},Br={suspend:{unicode:"any key commands \xB7 Esc / Ctrl-C quit \xB7 Ctrl-Z suspend",ascii:"any key commands - Esc / Ctrl-C quit - Ctrl-Z suspend"},plain:{unicode:"any key commands \xB7 Esc / Ctrl-C quit",ascii:"any key commands - Esc / Ctrl-C quit"}},Ro={ok:{unicode:"\u2713",ascii:"[ok]"},findings:{unicode:"\u26A0",ascii:"[!]"},failed:{unicode:"\u2717",ascii:"[x]"},cancelled:{unicode:"\u2298",ascii:"[-]"}},Po={unicode:"\u2500",ascii:"-"},Kr=3,xe=e=>e,Yr={ok:e=>E.green(e),findings:e=>E.yellow(e),failed:e=>E.red(e),cancelled:e=>E.gray(e)},Ee=e=>e?{dim:t=>E.dim(t),bold:t=>E.bold(t)}:{dim:xe,bold:xe},Vr=(e,t)=>e?Yr[t]:xe,be=e=>[...e].length,zr=(e,t)=>{if(t==null)return e;let o=Math.max(0,t-1);return be(e)<=o?e:[...e].slice(0,o).join("")},xo=e=>{let t=Ee(e.color===!0).dim,o=Br[e.canSuspend?"suspend":"plain"],r=e.ascii===!0?o.ascii:o.unicode;return t(zr(r,e.width))},bo=(e,t={})=>{let o=Ee(t.color===!0);return`${o.dim(k.reproPrefix.trim())} ${o.bold(e)}`},Xr=e=>e<1e3?`${Math.round(e)}ms`:`${(e/1e3).toFixed(1)}s`,Qr=(e,t)=>e==="findings"?t!=null?`${t} ${k.findingsSuffix}`:k.findingsPlain:{ok:k.ok,failed:k.failed,cancelled:k.cancelled}[e],Zr=(e,t,o,r)=>{if(t==null)return"";let n=t-2-e;return n<Kr?"":` ${r(o.repeat(n))}`},Eo=e=>{let t=e.color===!0,o=Ee(t),r=Vr(t,e.outcome),n=e.ascii===!0,s=e.equivalent.reproducible?k.reproPrefix:k.nonReproPrefix,a=n?Ro[e.outcome].ascii:Ro[e.outcome].unicode,i=Qr(e.outcome,e.findingsCount),c=[Xr(e.durationMs)],m=e.summary?.[0]?.split(`
|
|
9
|
+
`)[0];m!=null&&m.length>0&&c.push(m);let d=`${a} ${i}`,p=`${k.sep}${c.join(k.sep)}`,R=be(d)+be(p),C=Zr(R,e.width,n?Po.ascii:Po.unicode,o.dim),V=[`${r(d)}${o.dim(p)}${C}`];return e.showEquivalent!==!1&&V.unshift(`${o.dim(s.trim())} ${o.bold(e.equivalent.line)}`),e.envNotice===!0&&V.push(o.dim(k.envNotice)),V.join(`
|
|
10
|
+
`)};var en=new Set([130,143]),Co=(e,t,o,r=!1)=>o?t!=null||e===0?"ok":"findings":r&&e!=null&&en.has(e)||t==="SIGINT"||e===0?"cancelled":"failed";import tn from"node:process";var on={3:"quit",4:"quit",26:"suspend",27:"quit"},rn=e=>{if(e.length!==1)return"continue";let t=typeof e=="string"?e.charCodeAt(0):e[0];return t===void 0||Number.isNaN(t)?"continue":on[t]??"continue"},nn=150,sn="\r\x1B[2K",an=`\r
|
|
11
|
+
`,Ao=(e,t)=>{To(e),e.stdin.on("data",t),e.listener=t},To=e=>{e.listener!==null&&(e.stdin.off("data",e.listener),e.listener=null)},Do=(e,t)=>{nt(),e.stdin.setRawMode(!0),e.stdin.isPaused()&&e.stdin.resume(),Ao(e,t)},Io=e=>{e.hintOnScreen&&(e.hintOnScreen=!1,e.deps.write(sn)),To(e),e.stdin.isTTY===!0&&e.stdin.isRaw===!0&&e.stdin.setRawMode(!1),it()},cn=e=>{e.settled||(e.settled=!0,Io(e))},Lo=(e,t)=>{let o=xo({canSuspend:e.deps.suspend!==void 0,ascii:e.deps.ascii,color:e.deps.color,width:e.deps.columns()});e.deps.write(t+o),e.hintOnScreen=!0},ln=async e=>{await new Promise(t=>{setTimeout(t,e)})},dn=(e,t,o)=>{Io(e),t(),Do(e,o),Lo(e,an)},un=async e=>new Promise(t=>{let o=r=>{let n=rn(r),s=e.deps.suspend;if(n==="quit"){t("quit");return}if(n==="suspend"&&s!==void 0){dn(e,s,o);return}t("palette")};Ao(e,o),Lo(e,"")}),No=async(e,t)=>{if(e.quitRequested())return"quit";let o=t.stdin??tn.stdin;if(o.isTTY!==!0)return"palette";let r={deps:t,stdin:o,listener:null,hintOnScreen:!1,settled:!1};try{return Do(r,()=>{}),e.armed(),await ln(t.drainMs??nn),await un(r)}finally{cn(r)}};import Oo from"node:process";var x={column:"\r",sgr:"\x1B[0m",cursor:"\x1B[?25h",wrap:"\x1B[?7h",saveCursor:"\x1B7",restoreCursor:"\x1B8",scrollRegion:"\x1B[r",primaryBuffer:"\x1B[?1049l"},_o=(e,t)=>{let o=t?.write??(s=>{Oo.stderr.write(s)}),r=t?.stdin??Oo.stdin,n=[x.saveCursor,x.scrollRegion,x.restoreCursor,x.column,x.sgr,x.cursor,x.wrap];e.entersAltScreen===!0&&n.push(x.primaryBuffer),o(n.join("")),r.isTTY===!0&&r.isRaw===!0&&r.setRawMode?.(!1)};var $o=e=>`infra-kit ${e.groupPath.join(" ")}`,fn=()=>{gn();let e=v.stderr.columns;return e!=null&&e>0?e:void 0},gn=()=>{let e=v.stderr;typeof e._refreshSize=="function"&&e._refreshSize()},hn=e=>new Promise(t=>{e.on("exit",(o,r)=>{t({code:o,signal:r})}),e.on("error",()=>{t({code:1,signal:null})})}),vn=async(e,t,o)=>{let r=ho(),n={...t.env,[K]:r,INFRA_KIT_NO_AUTO_UPDATE:"1"},s=t.now(),a={code:1,signal:null};o();try{let p=t.spawn(v.execPath,[t.cliPath,...e.groupPath],{stdio:"inherit",env:n});a=await hn(p)}catch{a={code:1,signal:null}}finally{t.resetTerminal({entersAltScreen:e.entersAltScreen})}let i=vo(r),c=Co(a.code,a.signal,i!=null,e.longRunning),m=$o(e),d=i?.equivalent??J(m,!0);return Eo({equivalent:d,outcome:c,durationMs:t.now()-s,summary:i?.summary,envNotice:e.sessionEnvNotice,ascii:t.ascii,color:t.color,width:t.columns(),showEquivalent:!(d.reproducible&&d.line===m)})},yn=1e3,wn=(e,t)=>e!=null&&t-e<=yn,Ce=e=>{e.resetTerminal(),e.exit(0)},Sn=(e,t)=>{let o=null,r=!1,n=()=>{let c=e();if(c==="child"){o=t.now();return}c!=="pause"&&Ce(t)},s=()=>{let c=e();if(c==="palette"){Ce(t);return}if(!wn(o,t.now())){if(c==="pause"){Ce(t);return}r=!0}},a=()=>{t.exit(129)},i=()=>{e()==="child"&&t.raise("SIGSTOP")};return t.register("SIGINT",n),t.register("SIGTERM",s),t.register("SIGHUP",a),t.register("SIGTSTP",i),{dispose:()=>{t.unregister("SIGINT",n),t.unregister("SIGTERM",s),t.unregister("SIGHUP",a),t.unregister("SIGTSTP",i)},childStarted:()=>{o=null},quitRequested:()=>r}},Fo=(e,t)=>!!(t.stdoutIsTTY&&t.stdinIsTTY&&t.stderrIsTTY&&e.TERM!=="dumb"&&!e.INFRA_KIT_NO_SESSION&&!e.INFRA_KIT_SESSION_REPORT),kn=v.platform==="win32"?void 0:()=>{bt()},Rn=(e,t)=>o=>No(o,{write:e,columns:t.columns,ascii:t.ascii,color:t.color,suspend:kn}),Mo=async(e,t)=>{let o={spawn:t.spawn??pn,now:t.now??(()=>Date.now()),env:t.env??v.env,cliPath:t.cliPath,ascii:t.ascii??!(v.stdout.isTTY&&v.env.TERM!=="dumb"),color:t.color??mn.level>0,columns:t.columns??fn,resetTerminal:t.resetTerminal??(d=>{_o(d)})},r=t.write??(d=>v.stderr.write(d)),n="palette",s=t.signals??{register:(d,p)=>{v.on(d,p)},unregister:(d,p)=>{v.off(d,p)},exit:d=>{v.exit(d)},raise:d=>{v.kill(v.pid,d)},now:()=>Date.now(),resetTerminal:()=>{n==="pause"&&r("\r\x1B[2K"),o.resetTerminal({entersAltScreen:!1})}},a={dispose:()=>{},childStarted:()=>{},quitRequested:()=>!1},i=t.installSignals===!1?a:Sn(()=>n,s),c={armed:()=>{n="pause"},quitRequested:()=>i.quitRequested()},m=t.afterRun??Rn(r,o);try{for(;;){if(i.quitRequested())return;n="palette";let d=await t.renderPalette(e);if(d==null)return;let p=t.resolveCommand(d);if(!p)continue;let R=bo($o(p),{color:o.color});r(`
|
|
12
|
+
${R}
|
|
13
|
+
`),i.childStarted();let C=await vn(p,o,()=>{n="child"});if(r(`
|
|
14
|
+
${C}
|
|
15
|
+
`),await m(c)==="quit")return}}finally{i.dispose()}};Xt();fo();var Wo=Re(),qo=async(e=g.argv)=>{rt(e);try{await Wo.parseAsync(e)}catch(t){ko(t)}},Cn=()=>{try{if(g.env.INFRA_KIT_NO_LOCATION_WARN||g.argv.includes("--json")||g.argv[2]==="mcp")return;Oe({selfRealPath:bn(Uo(import.meta.url)),cwd:g.cwd(),env:g.env,realpath:_e,home:En(),exists:xn})&&l.info("Running from a project-local node_modules. Install globally for faster startup: npm i -g infra-kit")}catch{}};Cn();Fe((e,t)=>{l.debug(e,t)});gt(We.version);var Go=()=>Qt(Wo.commands),An=async()=>{let e=Go(),t=null;try{if(g.stdout.isTTY&&g.stdin.isTTY){let{runCommandPalette:o}=await import("./boot-BL4EQMZV.js");t=await o(e)}else{let o=Pe(e.map(n=>[n.name,n.description])),r=e.flatMap((n,s)=>[...e[s-1]?.group===n.group?[]:[new jo(" "),new jo(`\u2014 ${n.group} \u2014`)],{name:o[s]??n.name,value:n.name}]);t=await $(n=>Pn({message:"Select a command to run",choices:r},n),{output:g.stderr})}}catch(o){if(!M(o))throw o}return t},Tn=async()=>{let{runCommandPalette:e}=await import("./boot-BL4EQMZV.js"),t=Uo(import.meta.url),o=new Map(Yt.map(r=>[r.groupPath.join(" "),r]));await Mo(Go(),{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(Fo(g.env,e))await Tn();else{let t=await An();t&&await qo(["node","infra-kit",...t.split(" ")])}}else await qo();
|
|
16
16
|
//# sourceMappingURL=cli.js.map
|