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