infra-kit 0.1.97 → 0.1.98

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/cli.js CHANGED
@@ -1,49 +1,69 @@
1
- import ks,{Separator as ie}from"@inquirer/select";import{Command as Rs,Option as lt}from"commander";import Or from"node:process";import _e from"node:fs";import Dt from"node:os";import Jr from"node:path";import{z as U}from"zod/v4";import{$ as Vr}from"zx";import Ie from"node:fs";import gt from"node:os";import vt from"node:path";import dt from"node:process";import ut from"pino";import ft from"pino-pretty";var ht=()=>{let e=dt.argv.includes("--debug")?"debug":"info",r=["time","pid","hostname"];return e==="debug"&&r.push("level"),ut({level:e},ft({destination:2,ignore:r.join(","),colorize:!0}))},a=ht();var Ee="# -- infra-kit:begin --",ae="# -- infra-kit:end --",wt=[["# region infra-kit","# endregion infra-kit"]],yt="# infra-kit shell functions",ur=async()=>{let e=vt.join(gt.homedir(),".zshrc"),r=fr();if(Ie.existsSync(e)){let t=Ie.readFileSync(e,"utf-8"),s=Rt(t);Ie.writeFileSync(e,s)}Ie.appendFileSync(e,`
1
+ import an,{Separator as ge}from"@inquirer/select";import{Command as cn,Option as $t}from"commander";import Gr from"node:process";import xr from"node:fs/promises";import Qt from"node:os";import eo from"node:path";import et from"node:process";import{$ as ro}from"zx";import br from"node:fs/promises";import Nt from"node:os";import Ve from"node:path";import Ot from"yaml";import{z as v}from"zod/v4";import It from"node:path";import{$ as Hr}from"zx";var _=async e=>{let t=(await Hr`git worktree list`).stdout.split(`
2
+ `).filter(Boolean),o={release:At,feature:_t};return t.map(o[e]).filter(s=>s!==null)},Yr=e=>{let r=e.trimEnd();if(!r.endsWith("]"))return null;let t=r.lastIndexOf("[");if(t===-1)return null;let o=r.slice(t+1,-1);return o.length>0?o:null},At=e=>{let r=Yr(e);return r?.startsWith("release/v")?r:null},_t=e=>{let r=Yr(e);return r?.startsWith("feature/")?r:null},C=async()=>(await Hr`git rev-parse --show-toplevel`).stdout.trim(),N=async()=>{let e=await C();return It.basename(e)};var Xr="infra-kit.yml",Dt=".infra-kit",Ft="config.yml",jt="projects",Lt=v.object({provider:v.literal("doppler"),config:v.object({name:v.string().min(1)})}),Wt=v.discriminatedUnion("provider",[Lt]),Mt=v.object({mode:v.enum(["workspace","windows"]).default("workspace"),workspaceConfigPath:v.string().min(1).optional()}).refine(e=>e.mode!=="workspace"||!!e.workspaceConfigPath,{message:'workspaceConfigPath is required when mode is "workspace"',path:["workspaceConfigPath"]}),Vt=v.object({provider:v.literal("cursor"),config:Mt}),Jt=v.discriminatedUnion("provider",[Vt]),Bt=v.object({provider:v.literal("jira"),config:v.object({baseUrl:v.string().url(),projectId:v.number().int().positive()})}),Kt=v.discriminatedUnion("provider",[Bt]),Qr=v.object({environments:v.array(v.string().min(1)).min(1),envManagement:Wt,ide:Jt.optional(),taskManager:Kt.optional()}),qt=Qr.partial(),Y=null,q=async()=>{let e=await C(),r=await N(),t=Ve.join(Nt.homedir(),Dt);return{main:Ve.join(e,Xr),userGlobal:Ve.join(t,Ft),userProject:Ve.join(t,jt,r,Xr),projectName:r}},w=async()=>{let e=await q(),r;try{r=await br.stat(e.main)}catch{throw Y=null,new Error(`infra-kit.yml not found at ${e.main}`)}let[t,o]=await Promise.all([Zr(e.userGlobal),Zr(e.userProject)]),s={main:Number(r.mtimeMs),userGlobal:t?Number(t.mtimeMs):null,userProject:o?Number(o.mtimeMs):null};if(Y&&Gt(Y.mtimes,s))return Y.value;let n=[{label:"infra-kit.yml",path:e.main,required:!0},{label:"~/.infra-kit/config.yml",path:e.userGlobal,required:!1},{label:`~/.infra-kit/projects/${e.projectName}/infra-kit.yml`,path:e.userProject,required:!1}],i={};for(let c of n){let p=await zt(c);p!==null&&(i={...i,...p})}let l=Qr.safeParse(i);if(!l.success)throw new Error(`Invalid merged infra-kit config: ${v.prettifyError(l.error)}`);return Y={mtimes:s,value:l.data},l.data},ve=()=>{Y=null},Zr=async e=>{try{return await br.stat(e)}catch{return null}},Ut=async e=>{try{return await br.readFile(e,"utf-8")}catch{return null}},Gt=(e,r)=>{let t=Object.keys(e);return t.length!==Object.keys(r).length?!1:t.every(o=>e[o]===r[o])},zt=async e=>{let r=await Ut(e.path);if(r===null){if(e.required)throw new Error(`${e.label} not found at ${e.path}`);return null}let t=Ot.parse(r)??{},o=qt.safeParse(t);if(!o.success)throw new Error(`Invalid ${e.label} at ${e.path}: ${v.prettifyError(o.error)}`);return o.data};import Ht from"node:process";import Yt from"pino";import Xt from"pino-pretty";var Zt=()=>{let e=Ht.argv.includes("--debug")?"debug":"info",r=["time","pid","hostname"];return e==="debug"&&r.push("level"),Yt({level:e},Xt({destination:2,ignore:r.join(","),colorize:!0}))},a=Zt();var rt=async e=>{try{return await xr.access(e),!0}catch{return!1}},tt=e=>{let r=Qt.homedir();return e.startsWith(r)?`~${e.slice(r.length)}`:e},Cr=async()=>{let e=await q(),r=await Promise.all([{label:"project (committed)",path:e.main},{label:"user global",path:e.userGlobal},{label:"user project",path:e.userProject}].map(async o=>({...o,exists:await rt(o.path)})));a.info(`Project name: ${e.projectName}
3
+ `),a.info(`Config merge chain (later overrides earlier):
4
+ `);for(let o of r){let s=o.exists?" [\u2713]":" [ ]";a.info(`${s} ${o.label.padEnd(22)} ${tt(o.path)}`)}let t={projectName:e.projectName,layers:r.map(o=>({label:o.label,path:o.path,exists:o.exists}))};return{content:[{type:"text",text:JSON.stringify(t,null,2)}],structuredContent:t}},Tr=async()=>{let e=await q(),r=et.env.EDITOR||et.env.VISUAL||"vi";if(await xr.mkdir(eo.dirname(e.userProject),{recursive:!0}),!await rt(e.userProject)){let o=`# infra-kit user override for ${e.projectName}
5
+ # This file is shallow-merged on top of project infra-kit.yml.
6
+ # Top-level keys (envManagement, ide, taskManager, environments) replace wholesale.
7
+ `;await xr.writeFile(e.userProject,o,"utf-8")}a.info(`Opening ${tt(e.userProject)} in ${r}`),await ro({stdio:"inherit"})`${r} ${e.userProject}`,ve();let t={path:e.userProject,editor:r};return{content:[{type:"text",text:JSON.stringify(t,null,2)}],structuredContent:t}};import ke from"node:fs";import nt from"node:os";import it from"node:path";import{z as X}from"zod/v4";import{$ as co}from"zx";import U from"node:fs";import st from"node:os";import $r from"node:path";var Je="# -- infra-kit:begin --",we="# -- infra-kit:end --",to=[["# region infra-kit","# endregion infra-kit"]],oo="# infra-kit shell functions",so=`# infra-kit user-global config
8
+ #
9
+ # Shared across every project on this machine. Loaded after each project's
10
+ # infra-kit.yml and before ~/.infra-kit/projects/<repo-name>/infra-kit.yml.
11
+ #
12
+ # Top-level keys (envManagement, ide, taskManager, environments) replace
13
+ # wholesale when set here. Uncomment values you want to apply globally.
14
+
15
+ # Per-developer IDE config
16
+ # ide:
17
+ # provider: cursor
18
+ # config:
19
+ # mode: workspace
20
+ # workspaceConfigPath: ../Main.code-workspace
21
+ `,Pr=async()=>{let e=$r.join(st.homedir(),".zshrc"),r=Sr();if(U.existsSync(e)){let t=U.readFileSync(e,"utf-8"),o=ao(t);U.writeFileSync(e,o)}U.appendFileSync(e,`
2
22
  ${r}
3
- `),a.info(`Added infra-kit shell functions to ${e}`),a.info("Run `source ~/.zshrc` or open a new terminal to activate.")},kt=e=>e.startsWith("#")||e.startsWith("alias ")||e.startsWith("env-load")||e.startsWith("env-clear")||e.startsWith("env-status")||e.startsWith("if ")||e.startsWith(" export INFRA_KIT_SESSION")||e.startsWith("export _INFRA_KIT_")||e.startsWith(": ${_INFRA_KIT_")||e.startsWith("fi")||e.startsWith("zmodload ")||e.startsWith("autoload ")||e.startsWith("add-zsh-hook ")||e.startsWith("_infra_kit_autoload"),Fr=(e,r,t)=>{let s=e.indexOf(r),o=e.indexOf(t);if(s===-1||o===-1)return null;let n=e.slice(0,s).replace(/\n+$/,""),i=e.slice(o+t.length).replace(/^\n+/,"");return n+(i?`
4
- ${i}`:"")},Rt=e=>{let r=Fr(e,Ee,ae);if(r!==null)return r;for(let[l,c]of wt){let p=Fr(e,l,c);if(p!==null)return p}let t=e.indexOf(yt);if(t===-1)return e;let s=e.slice(0,t).replace(/\n+$/,""),o=e.slice(t).split(`
5
- `),n=0;for(;n<o.length&&kt(o[n]);)n++;let i=o.slice(n).join(`
6
- `);return s+(i?`
7
- ${i}`:"")},fr=()=>{let e="pnpm exec infra-kit";return[Ee,"zmodload zsh/stat 2>/dev/null","zmodload zsh/datetime 2>/dev/null",'if [[ -z "${INFRA_KIT_SESSION}" ]]; then'," export INFRA_KIT_SESSION=$(head -c 4 /dev/urandom | xxd -p)","fi",": ${_INFRA_KIT_LAST_LOAD_MTIME:=0}",": ${_INFRA_KIT_LAST_CLEAR_MTIME:=0}",": ${_INFRA_KIT_SHELL_STARTED:=${EPOCHSECONDS:-0}}","export _INFRA_KIT_LAST_LOAD_MTIME _INFRA_KIT_LAST_CLEAR_MTIME _INFRA_KIT_SHELL_STARTED",`env-load() { local f m; f=$(${e} env-load "$@") || return; m=$(zstat +mtime -- "$f" 2>/dev/null || echo 0); _INFRA_KIT_LAST_LOAD_MTIME=$m; source "$f"; ${e} env-status; }`,`env-clear() { local f m; f=$(${e} env-clear) || return; m=$(zstat +mtime -- "$f" 2>/dev/null || echo 0); _INFRA_KIT_LAST_CLEAR_MTIME=$m; source "$f"; ${e} env-status; }`,`env-status() { ${e} env-status; }`,`alias ik='${e}'`,"_infra_kit_autoload() {",' [[ -z "$INFRA_KIT_SESSION" ]] && return',' local cache_root="${XDG_CACHE_HOME:-$HOME/.cache}/infra-kit"',' local dir="$cache_root/$INFRA_KIT_SESSION"',' local load_file="$dir/env-load.sh"',' local clear_file="$dir/env-clear.sh"'," local mtime",' if [[ -f "$load_file" ]]; then',' mtime=$(zstat +mtime -- "$load_file" 2>/dev/null || echo 0)'," if (( mtime > _INFRA_KIT_LAST_LOAD_MTIME && mtime >= _INFRA_KIT_SHELL_STARTED )); then",' source "$load_file"'," _INFRA_KIT_LAST_LOAD_MTIME=$mtime",' print -u2 "infra-kit: auto-loaded vars for ${INFRA_KIT_ENV_CONFIG:-?}"'," fi"," fi",' if [[ -f "$clear_file" ]]; then',' mtime=$(zstat +mtime -- "$clear_file" 2>/dev/null || echo 0)'," if (( mtime > _INFRA_KIT_LAST_CLEAR_MTIME && mtime >= _INFRA_KIT_SHELL_STARTED )); then",' source "$clear_file"'," _INFRA_KIT_LAST_CLEAR_MTIME=$mtime",' print -u2 "infra-kit: auto-cleared env"'," fi"," fi","}","autoload -Uz add-zsh-hook","if (( _INFRA_KIT_SHELL_STARTED > 0 )); then"," add-zsh-hook precmd _infra_kit_autoload","fi",ae].join(`
8
- `)};import bt from"node:path";import{$ as Dr}from"zx";var _=async e=>{let t=(await Dr`git worktree list`).stdout.split(`
9
- `).filter(Boolean),s={release:Ct,feature:xt};return t.map(s[e]).filter(o=>o!==null)},Wr=e=>{let r=e.trimEnd();if(!r.endsWith("]"))return null;let t=r.lastIndexOf("[");if(t===-1)return null;let s=r.slice(t+1,-1);return s.length>0?s:null},Ct=e=>{let r=Wr(e);return r?.startsWith("release/v")?r:null},xt=e=>{let r=Wr(e);return r?.startsWith("feature/")?r:null},b=async()=>(await Dr`git rev-parse --show-toplevel`).stdout.trim(),W=async()=>{let e=await b();return bt.basename(e)};import Pe from"node:fs/promises";import Lr from"node:path";import Mr from"yaml";import{z as g}from"zod/v4";var Tt="infra-kit.yml",$t="infra-kit.local.yml",St=g.object({provider:g.literal("doppler"),config:g.object({name:g.string().min(1)})}),It=g.discriminatedUnion("provider",[St]),Et=g.object({mode:g.enum(["workspace","windows"]).default("workspace"),workspaceConfigPath:g.string().min(1).optional()}).refine(e=>e.mode!=="workspace"||!!e.workspaceConfigPath,{message:'workspaceConfigPath is required when mode is "workspace"',path:["workspaceConfigPath"]}),Pt=g.object({provider:g.literal("cursor"),config:Et}),At=g.discriminatedUnion("provider",[Pt]),_t=g.object({provider:g.literal("jira"),config:g.object({baseUrl:g.string().url(),projectId:g.number().int().positive()})}),Ot=g.discriminatedUnion("provider",[_t]),jr=g.object({environments:g.array(g.string().min(1)).min(1),envManagement:It,ide:At.optional(),taskManager:Ot.optional()}),Nt=jr.partial(),K=null,w=async()=>{let e=await b(),r=Lr.join(e,Tt),t=Lr.join(e,$t),s;try{s=await Pe.stat(r)}catch{throw K=null,new Error(`infra-kit.yml not found at ${r}`)}let o=await Ft(t),n=Number(s.mtimeMs),i=o?Number(o.mtimeMs):null;if(K&&K.mainMtimeMs===n&&K.localMtimeMs===i)return K.value;let l=await Pe.readFile(r,"utf-8"),c=Mr.parse(l),p=c;if(o){let u=await Pe.readFile(t,"utf-8"),h=Mr.parse(u)??{},f=Nt.safeParse(h);if(!f.success)throw new Error(`Invalid infra-kit.local.yml at ${t}: ${g.prettifyError(f.error)}`);p={...c,...f.data}}let d=jr.safeParse(p);if(!d.success)throw new Error(`Invalid infra-kit.yml at ${r}: ${g.prettifyError(d.error)}`);return K={mainMtimeMs:n,localMtimeMs:i,value:d.data},d.data},hr=()=>{K=null},Ft=async e=>{try{return await Pe.stat(e)}catch{return null}};var Ae="infra-kit.local.yml",ce=async(e,r,t,s)=>{try{return await Vr`${r}`,{name:e,status:"pass",message:t}}catch{return{name:e,status:"fail",message:s}}},Wt=()=>{let e="zshrc init block",r=Jr.join(Dt.homedir(),".zshrc");if(!_e.existsSync(r))return{name:e,status:"fail",message:"~/.zshrc not found. Run: infra-kit init"};let t=_e.readFileSync(r,"utf-8"),s=t.indexOf(Ee),o=t.indexOf(ae);if(s===-1||o===-1||o<s)return{name:e,status:"fail",message:"infra-kit shell block missing from ~/.zshrc. Run: infra-kit init"};let n=t.slice(s,o+ae.length).trim(),i=fr().trim();return n!==i?{name:e,status:"fail",message:"infra-kit shell block in ~/.zshrc is out of date. Run: infra-kit init"}:{name:e,status:"pass",message:"infra-kit shell block in ~/.zshrc is up to date"}},Lt=async()=>{let e="pnpm enableGlobalVirtualStore";try{let r=await b(),t=Jr.join(r,"pnpm-workspace.yaml");if(!_e.existsSync(t))return{name:e,status:"fail",message:`pnpm-workspace.yaml not found at ${t}`};let s=_e.readFileSync(t,"utf-8");return/^\s*enableGlobalVirtualStore\s*:\s*true\s*$/m.test(s)?{name:e,status:"pass",message:"enableGlobalVirtualStore: true is set"}:{name:e,status:"fail",message:"enableGlobalVirtualStore: true is missing in pnpm-workspace.yaml"}}catch(r){return{name:e,status:"fail",message:`Failed to read pnpm-workspace.yaml: ${r.message}`}}},Mt=async()=>{let e="infra-kit config valid";try{return hr(),await w(),{name:e,status:"pass",message:"infra-kit.yml is valid (infra-kit.local.yml overrides applied if present)"}}catch(r){return{name:e,status:"fail",message:r.message}}},jt=async()=>{let e="infra-kit.local.yml gitignored";try{let r=await b();return await Vr({cwd:r,nothrow:!0})`git check-ignore -q ${Ae}`.then(t=>{if(t.exitCode!==0)throw new Error("not ignored")}),{name:e,status:"pass",message:`${Ae} is covered by .gitignore`}}catch{return{name:e,status:"fail",message:`${Ae} is not gitignored. Add "${Ae}" to .gitignore.`}}},Oe=async()=>{let e=await Promise.all([ce("gh installed",["gh","--version"],"GitHub CLI is installed","GitHub CLI is not installed. Install from: https://cli.github.com/"),ce("gh authenticated",["gh","auth","status"],"GitHub CLI is authenticated","GitHub CLI is not authenticated. Run: gh auth login"),ce("doppler installed",["doppler","--version"],"Doppler CLI is installed","Doppler CLI is not installed. Install from: https://docs.doppler.com/docs/install-cli"),ce("doppler authenticated",["doppler","me"],"Doppler CLI is authenticated","Doppler CLI is not authenticated. Run: doppler login"),ce("aws installed",["aws","--version"],"AWS CLI is installed","AWS CLI is not installed. Install from: https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html"),Promise.resolve(Wt()),Lt(),Mt(),jt()]);a.info(`Doctor check results:
10
- `);for(let t of e){let s=t.status==="pass"?"[PASS]":"[FAIL]";a.info(` ${s} ${t.name}: ${t.message}`)}let r={checks:e.map(t=>({name:t.name,status:t.status,message:t.message})),allPassed:e.every(t=>t.status==="pass")};return{content:[{type:"text",text:JSON.stringify(r,null,2)}],structuredContent:r}},Jt={name:"doctor",description:"Check installation and authentication status of gh, doppler, and aws CLIs",inputSchema:{},outputSchema:{checks:U.array(U.object({name:U.string().describe("Name of the check"),status:U.enum(["pass","fail"]).describe("Check result"),message:U.string().describe("Details about the check result")})).describe("List of all check results"),allPassed:U.boolean().describe("Whether all checks passed")},handler:Oe};import wr from"node:fs";import Kr from"node:path";import Kt from"node:process";import{z as Le}from"zod/v4";import le from"node:fs";import Vt from"node:os";import gr from"node:path";import vr from"node:process";var G="env-load.sh",Br="env-clear.sh",Ne="INFRA_KIT_SESSION",H="INFRA_KIT_ENV_CONFIG",Y="INFRA_KIT_ENV_PROJECT",X="INFRA_KIT_ENV_LOADED_AT",Fe=/^([A-Z_]\w*)=/i,De=e=>{if(!le.existsSync(e))return[];let r=le.readFileSync(e,"utf-8"),t=[];for(let s of r.split(`
11
- `)){let o=Fe.exec(s);o&&t.push(o[1])}return t},Bt=()=>{let e=vr.env.XDG_CACHE_HOME,r=e&&e.length>0?e:gr.join(Vt.homedir(),".cache");return gr.join(r,"infra-kit")},Z=()=>{let e=vr.env[Ne];if(!e)throw new Error(`${Ne} is not set. Run \`infra-kit init\` then \`source ~/.zshrc\`.`);return gr.join(Bt(),e)},We=(e,r,t)=>{let s=`${e}.tmp.${vr.pid}`;le.writeFileSync(s,r,{mode:t});try{le.renameSync(s,e)}catch(o){throw le.rmSync(s,{force:!0}),o}},j="-worktrees";var Me=async()=>{let e=Z(),r=Kr.join(e,G);if(!wr.existsSync(r))throw new Error("No loaded environment found. Run `env-load` first.");let t=De(r),s=[...t.map(i=>`unset ${i}`),`unset ${H}`,`unset ${Y}`,`unset ${X}`],o=Kr.resolve(e,Br);wr.mkdirSync(e,{recursive:!0,mode:448}),We(o,`${s.join(`
23
+ `),a.info(`Added infra-kit shell functions to ${e}`),no(),a.info("Run `source ~/.zshrc` or open a new terminal to activate.")},no=()=>{let e=$r.join(st.homedir(),".infra-kit"),r=$r.join(e,"config.yml");if(U.existsSync(r)){a.info(`User-global config already present at ${r}`);return}U.mkdirSync(e,{recursive:!0}),U.writeFileSync(r,so,"utf-8"),a.info(`Wrote user-global config stub to ${r}`)},io=e=>e.startsWith("#")||e.startsWith("alias ")||e.startsWith("env-load")||e.startsWith("env-clear")||e.startsWith("env-status")||e.startsWith("if ")||e.startsWith(" export INFRA_KIT_SESSION")||e.startsWith("export _INFRA_KIT_")||e.startsWith(": ${_INFRA_KIT_")||e.startsWith("fi")||e.startsWith("zmodload ")||e.startsWith("autoload ")||e.startsWith("add-zsh-hook ")||e.startsWith("_infra_kit_autoload"),ot=(e,r,t)=>{let o=e.indexOf(r),s=e.indexOf(t);if(o===-1||s===-1)return null;let n=e.slice(0,o).replace(/\n+$/,""),i=e.slice(s+t.length).replace(/^\n+/,"");return n+(i?`
24
+ ${i}`:"")},ao=e=>{let r=ot(e,Je,we);if(r!==null)return r;for(let[l,c]of to){let p=ot(e,l,c);if(p!==null)return p}let t=e.indexOf(oo);if(t===-1)return e;let o=e.slice(0,t).replace(/\n+$/,""),s=e.slice(t).split(`
25
+ `),n=0;for(;n<s.length&&io(s[n]);)n++;let i=s.slice(n).join(`
26
+ `);return o+(i?`
27
+ ${i}`:"")},Sr=()=>{let e="pnpm exec infra-kit";return[Je,"zmodload zsh/stat 2>/dev/null","zmodload zsh/datetime 2>/dev/null",'if [[ -z "${INFRA_KIT_SESSION}" ]]; then'," export INFRA_KIT_SESSION=$(head -c 4 /dev/urandom | xxd -p)","fi",": ${_INFRA_KIT_LAST_LOAD_MTIME:=0}",": ${_INFRA_KIT_LAST_CLEAR_MTIME:=0}",": ${_INFRA_KIT_SHELL_STARTED:=${EPOCHSECONDS:-0}}","export _INFRA_KIT_LAST_LOAD_MTIME _INFRA_KIT_LAST_CLEAR_MTIME _INFRA_KIT_SHELL_STARTED",`env-load() { local f m; f=$(${e} env-load "$@") || return; m=$(zstat +mtime -- "$f" 2>/dev/null || echo 0); _INFRA_KIT_LAST_LOAD_MTIME=$m; source "$f"; ${e} env-status; }`,`env-clear() { local f m; f=$(${e} env-clear) || return; m=$(zstat +mtime -- "$f" 2>/dev/null || echo 0); _INFRA_KIT_LAST_CLEAR_MTIME=$m; source "$f"; ${e} env-status; }`,`env-status() { ${e} env-status; }`,`alias ik='${e}'`,"_infra_kit_autoload() {",' [[ -z "$INFRA_KIT_SESSION" ]] && return',' local cache_root="${XDG_CACHE_HOME:-$HOME/.cache}/infra-kit"',' local dir="$cache_root/$INFRA_KIT_SESSION"',' local load_file="$dir/env-load.sh"',' local clear_file="$dir/env-clear.sh"'," local mtime",' if [[ -f "$load_file" ]]; then',' mtime=$(zstat +mtime -- "$load_file" 2>/dev/null || echo 0)'," if (( mtime > _INFRA_KIT_LAST_LOAD_MTIME && mtime >= _INFRA_KIT_SHELL_STARTED )); then",' source "$load_file"'," _INFRA_KIT_LAST_LOAD_MTIME=$mtime",' print -u2 "infra-kit: auto-loaded vars for ${INFRA_KIT_ENV_CONFIG:-?}"'," fi"," fi",' if [[ -f "$clear_file" ]]; then',' mtime=$(zstat +mtime -- "$clear_file" 2>/dev/null || echo 0)'," if (( mtime > _INFRA_KIT_LAST_CLEAR_MTIME && mtime >= _INFRA_KIT_SHELL_STARTED )); then",' source "$clear_file"'," _INFRA_KIT_LAST_CLEAR_MTIME=$mtime",' print -u2 "infra-kit: auto-cleared env"'," fi"," fi","}","autoload -Uz add-zsh-hook","if (( _INFRA_KIT_SHELL_STARTED > 0 )); then"," add-zsh-hook precmd _infra_kit_autoload","fi",we].join(`
28
+ `)};var ye=async(e,r,t,o)=>{try{return await co`${r}`,{name:e,status:"pass",message:t}}catch{return{name:e,status:"fail",message:o}}},lo=()=>{let e="zshrc init block",r=it.join(nt.homedir(),".zshrc");if(!ke.existsSync(r))return{name:e,status:"fail",message:"~/.zshrc not found. Run: infra-kit init"};let t=ke.readFileSync(r,"utf-8"),o=t.indexOf(Je),s=t.indexOf(we);if(o===-1||s===-1||s<o)return{name:e,status:"fail",message:"infra-kit shell block missing from ~/.zshrc. Run: infra-kit init"};let n=t.slice(o,s+we.length).trim(),i=Sr().trim();return n!==i?{name:e,status:"fail",message:"infra-kit shell block in ~/.zshrc is out of date. Run: infra-kit init"}:{name:e,status:"pass",message:"infra-kit shell block in ~/.zshrc is up to date"}},po=async()=>{let e="pnpm enableGlobalVirtualStore";try{let r=await C(),t=it.join(r,"pnpm-workspace.yaml");if(!ke.existsSync(t))return{name:e,status:"fail",message:`pnpm-workspace.yaml not found at ${t}`};let o=ke.readFileSync(t,"utf-8");return/^\s*enableGlobalVirtualStore\s*:\s*true\s*$/m.test(o)?{name:e,status:"pass",message:"enableGlobalVirtualStore: true is set"}:{name:e,status:"fail",message:"enableGlobalVirtualStore: true is missing in pnpm-workspace.yaml"}}catch(r){return{name:e,status:"fail",message:`Failed to read pnpm-workspace.yaml: ${r.message}`}}},mo=async()=>{let e="infra-kit config valid";try{return ve(),await w(),{name:e,status:"pass",message:"infra-kit.yml is valid (user overrides applied if present)"}}catch(r){return{name:e,status:"fail",message:r.message}}},uo=async()=>{let e="user override path";try{let r=await q(),t=nt.homedir(),o=r.userProject.startsWith(t)?`~${r.userProject.slice(t.length)}`:r.userProject,n=ke.existsSync(r.userProject)?"(exists)":"(not yet created)";return{name:e,status:"pass",message:`${o} ${n} \u2014 project: ${r.projectName}`}}catch(r){return{name:e,status:"fail",message:r.message}}},Be=async()=>{let e=await Promise.all([ye("gh installed",["gh","--version"],"GitHub CLI is installed","GitHub CLI is not installed. Install from: https://cli.github.com/"),ye("gh authenticated",["gh","auth","status"],"GitHub CLI is authenticated","GitHub CLI is not authenticated. Run: gh auth login"),ye("doppler installed",["doppler","--version"],"Doppler CLI is installed","Doppler CLI is not installed. Install from: https://docs.doppler.com/docs/install-cli"),ye("doppler authenticated",["doppler","me"],"Doppler CLI is authenticated","Doppler CLI is not authenticated. Run: doppler login"),ye("aws installed",["aws","--version"],"AWS CLI is installed","AWS CLI is not installed. Install from: https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html"),Promise.resolve(lo()),po(),mo(),uo()]);a.info(`Doctor check results:
29
+ `);for(let t of e){let o=t.status==="pass"?"[PASS]":"[FAIL]";a.info(` ${o} ${t.name}: ${t.message}`)}let r={checks:e.map(t=>({name:t.name,status:t.status,message:t.message})),allPassed:e.every(t=>t.status==="pass")};return{content:[{type:"text",text:JSON.stringify(r,null,2)}],structuredContent:r}},fo={name:"doctor",description:"Check installation and authentication status of gh, doppler, and aws CLIs",inputSchema:{},outputSchema:{checks:X.array(X.object({name:X.string().describe("Name of the check"),status:X.enum(["pass","fail"]).describe("Check result"),message:X.string().describe("Details about the check result")})).describe("List of all check results"),allPassed:X.boolean().describe("Whether all checks passed")},handler:Be};import Ar from"node:fs";import ct from"node:path";import vo from"node:process";import{z as ze}from"zod/v4";import Re from"node:fs";import ho from"node:os";import Er from"node:path";import Ir from"node:process";var Z="env-load.sh",at="env-clear.sh",Ke="INFRA_KIT_SESSION",Q="INFRA_KIT_ENV_CONFIG",ee="INFRA_KIT_ENV_PROJECT",re="INFRA_KIT_ENV_LOADED_AT",qe=/^([A-Z_]\w*)=/i,Ue=e=>{if(!Re.existsSync(e))return[];let r=Re.readFileSync(e,"utf-8"),t=[];for(let o of r.split(`
30
+ `)){let s=qe.exec(o);s&&t.push(s[1])}return t},go=()=>{let e=Ir.env.XDG_CACHE_HOME,r=e&&e.length>0?e:Er.join(ho.homedir(),".cache");return Er.join(r,"infra-kit")},te=()=>{let e=Ir.env[Ke];if(!e)throw new Error(`${Ke} is not set. Run \`infra-kit init\` then \`source ~/.zshrc\`.`);return Er.join(go(),e)},Ge=(e,r,t)=>{let o=`${e}.tmp.${Ir.pid}`;Re.writeFileSync(o,r,{mode:t});try{Re.renameSync(o,e)}catch(s){throw Re.rmSync(o,{force:!0}),s}},M="-worktrees";var He=async()=>{let e=te(),r=ct.join(e,Z);if(!Ar.existsSync(r))throw new Error("No loaded environment found. Run `env-load` first.");let t=Ue(r),o=[...t.map(i=>`unset ${i}`),`unset ${Q}`,`unset ${ee}`,`unset ${re}`],s=ct.resolve(e,at);Ar.mkdirSync(e,{recursive:!0,mode:448}),Ge(s,`${o.join(`
12
31
  `)}
13
- `,384),Kt.stdout.write(`${o}
14
- `),wr.unlinkSync(r);let n={filePath:o,variableCount:t.length,unsetStatements:s};return{content:[{type:"text",text:JSON.stringify(n,null,2)}],structuredContent:n}},qt={name:"env-clear",description:'Generate a shell script that unsets every env var previously loaded by env-load for this session, plus the infra-kit session metadata vars. Does NOT mutate the calling process. When `infra-kit init` has installed the zsh shell integration, the user\'s terminal auto-sources the unset script on its next prompt (precmd hook) \u2014 so calling this via MCP will clear the vars in the shell that launched Claude Code automatically. Other callers must source "<filePath>" themselves or surface it to the user. Errors if no env is currently loaded.',inputSchema:{},outputSchema:{filePath:Le.string().describe("Path to the file that must be sourced to apply"),variableCount:Le.number().describe("Number of variables cleared"),unsetStatements:Le.array(Le.string()).describe("Unset statements generated")},handler:Me};import{z as yr}from"zod/v4";var pe=async()=>{let{envManagement:e}=await w();return e.config.name};var je=async()=>{let e=await pe(),{environments:r}=await w();a.info(`Doppler project: ${e}
15
- `),a.info("Available configs:");for(let s of r)a.info(` - ${s}`);let t={project:e,configs:r};return{content:[{type:"text",text:JSON.stringify(t,null,2)}],structuredContent:t}},zt={name:"env-list",description:"List the environments the project is configured to support. Returns the `environments` list declared in infra-kit.yml at the project root (not a live fetch from Doppler) plus the Doppler project name resolved from the same file. Read-only.",inputSchema:{},outputSchema:{project:yr.string().describe("Detected Doppler project name"),configs:yr.array(yr.string()).describe("Available environment configs")},handler:je};import Gt from"@inquirer/select";import{Buffer as Ht}from"node:buffer";import Yt from"node:fs";import Xt from"node:path";import zr from"node:process";import{z as de}from"zod/v4";import{$ as Je}from"zx";import{$ as qr}from"zx";var me=async()=>{try{await qr`doppler --version`}catch(e){throw new Error("Doppler CLI is not installed. Install it from: https://docs.doppler.com/docs/install-cli",{cause:e})}try{await qr`doppler me`}catch(e){throw new Error("Doppler CLI is not authenticated. Run: doppler login",{cause:e})}};var Ut=()=>{let e="",r=[],t=!1;return{start(s){e=s,r=[],t=!1},setInteractive(){t=!0},addOption(s,o){r.push({flag:s,value:o})},print(){if(!t||r.length===0)return;let s=r.map(o=>typeof o.value=="boolean"?o.value?o.flag:"":Array.isArray(o.value)?`${o.flag} "${o.value.join(", ")}"`:`${o.flag} "${o.value}"`).filter(Boolean).join(" ");a.info(`\u{1F4DF} Equivalent command:
16
- pnpm exec infra-kit ${e} ${s}
17
- `)},reset(){e="",r=[],t=!1}}},m=Ut();var Ve=async e=>{await me();let{config:r}=e;m.start("env-load");let t="";if(r)t=r;else{let{environments:u}=await w();m.setInteractive(),t=await Gt({message:"Select environment config",choices:u.map(h=>({name:h,value:h}))},{output:zr.stderr})}m.addOption("--config",t);let s=await pe(),o=await Qt(s,t);oo(o);let n=new Date().toISOString(),i=["set -a",o,`${H}=${kr(t)}`,`${Y}=${kr(s)}`,`${X}=${kr(n)}`,"set +a"],l=Z(),c=Xt.resolve(l,G);Yt.mkdirSync(l,{recursive:!0,mode:448}),We(c,`${i.join(`
32
+ `,384),vo.stdout.write(`${s}
33
+ `),Ar.unlinkSync(r);let n={filePath:s,variableCount:t.length,unsetStatements:o};return{content:[{type:"text",text:JSON.stringify(n,null,2)}],structuredContent:n}},wo={name:"env-clear",description:'Generate a shell script that unsets every env var previously loaded by env-load for this session, plus the infra-kit session metadata vars. Does NOT mutate the calling process. When `infra-kit init` has installed the zsh shell integration, the user\'s terminal auto-sources the unset script on its next prompt (precmd hook) \u2014 so calling this via MCP will clear the vars in the shell that launched Claude Code automatically. Other callers must source "<filePath>" themselves or surface it to the user. Errors if no env is currently loaded.',inputSchema:{},outputSchema:{filePath:ze.string().describe("Path to the file that must be sourced to apply"),variableCount:ze.number().describe("Number of variables cleared"),unsetStatements:ze.array(ze.string()).describe("Unset statements generated")},handler:He};import{z as _r}from"zod/v4";var be=async()=>{let{envManagement:e}=await w();return e.config.name};var Ye=async()=>{let e=await be(),{environments:r}=await w();a.info(`Doppler project: ${e}
34
+ `),a.info("Available configs:");for(let o of r)a.info(` - ${o}`);let t={project:e,configs:r};return{content:[{type:"text",text:JSON.stringify(t,null,2)}],structuredContent:t}},yo={name:"env-list",description:"List the environments the project is configured to support. Returns the `environments` list declared in infra-kit.yml at the project root (not a live fetch from Doppler) plus the Doppler project name resolved from the same file. Read-only.",inputSchema:{},outputSchema:{project:_r.string().describe("Detected Doppler project name"),configs:_r.array(_r.string()).describe("Available environment configs")},handler:Ye};import Ro from"@inquirer/select";import{Buffer as bo}from"node:buffer";import xo from"node:fs";import Co from"node:path";import pt from"node:process";import{z as Ce}from"zod/v4";import{$ as Xe}from"zx";import{$ as lt}from"zx";var xe=async()=>{try{await lt`doppler --version`}catch(e){throw new Error("Doppler CLI is not installed. Install it from: https://docs.doppler.com/docs/install-cli",{cause:e})}try{await lt`doppler me`}catch(e){throw new Error("Doppler CLI is not authenticated. Run: doppler login",{cause:e})}};var ko=()=>{let e="",r=[],t=!1;return{start(o){e=o,r=[],t=!1},setInteractive(){t=!0},addOption(o,s){r.push({flag:o,value:s})},print(){if(!t||r.length===0)return;let o=r.map(s=>typeof s.value=="boolean"?s.value?s.flag:"":Array.isArray(s.value)?`${s.flag} "${s.value.join(", ")}"`:`${s.flag} "${s.value}"`).filter(Boolean).join(" ");a.info(`\u{1F4DF} Equivalent command:
35
+ pnpm exec infra-kit ${e} ${o}
36
+ `)},reset(){e="",r=[],t=!1}}},m=ko();var Ze=async e=>{await xe();let{config:r}=e;m.start("env-load");let t="";if(r)t=r;else{let{environments:d}=await w();m.setInteractive(),t=await Ro({message:"Select environment config",choices:d.map(h=>({name:h,value:h}))},{output:pt.stderr})}m.addOption("--config",t);let o=await be(),s=await $o(o,t);Io(s);let n=new Date().toISOString(),i=["set -a",s,`${Q}=${Nr(t)}`,`${ee}=${Nr(o)}`,`${re}=${Nr(n)}`,"set +a"],l=te(),c=Co.resolve(l,Z);xo.mkdirSync(l,{recursive:!0,mode:448}),Ge(c,`${i.join(`
18
37
  `)}
19
- `,384),zr.stdout.write(`${c}
20
- `),m.print();let p=ro(o),d={filePath:c,variableCount:p,project:s,config:t};return{content:[{type:"text",text:JSON.stringify(d,null,2)}],structuredContent:d}},Ur=1024*1024,Zt=3e4,Qt=async(e,r)=>{let t=Je.quiet;Je.quiet=!0;try{let s=await Je`doppler secrets download --no-file --format env --project ${e} --config ${r}`.timeout(Zt);return eo(s.stdout),s.stdout.trim()}finally{Je.quiet=t}},eo=e=>{let r=Ht.byteLength(e,"utf-8");if(r>Ur)throw new Error(`doppler returned unexpectedly large output (${r} bytes > ${Ur}) \u2014 refusing to write to disk`)},ro=e=>e.split(`
21
- `).filter(r=>Fe.test(r)).length,to=new Set(["set -a","set +a"]),kr=e=>`'${e.replaceAll("'","'\\''")}'`,oo=e=>{if(e.trim().length===0)throw new Error("doppler returned empty output for env-load");for(let r of e.split(`
22
- `)){let t=r.trim();if(!(t.length===0||to.has(t))&&!Fe.test(t))throw new Error(`doppler returned unexpected output for env-load (expected KEY=value lines, got: ${JSON.stringify(t.slice(0,80))})`)}},so={name:"env-load",description:'Download the env vars for a Doppler config and write them to a temporary shell script. Does NOT mutate the calling process \u2014 returns the path to a script that must be sourced ("source <filePath>") for the vars to take effect. The infra-kit shell wrapper auto-sources; direct MCP callers must handle sourcing themselves or surface filePath to the user. "config" is required when invoked via MCP (the CLI interactive picker is unreachable without a TTY).',inputSchema:{config:de.string().describe('Doppler config / environment name to load (e.g. "dev", "arthur", "renana"). Required for MCP calls.')},outputSchema:{filePath:de.string().describe("Path to the file that must be sourced to apply variables"),variableCount:de.number().describe("Number of variables loaded"),project:de.string().describe("Doppler project name"),config:de.string().describe("Doppler config name")},handler:Ve};import no from"node:path";import ue from"node:process";import{z as Q}from"zod/v4";var Be=async()=>{await me(),a.info("Environment session status:");let e=Z(),r=ue.env[Ne],t=no.join(e,G),s=0,o=0,n=ue.env[H]??null,i=ue.env[Y]??null,l=ue.env[X]??null;if(n){let p=De(t);p.length>0&&(o=p.length,s=p.filter(u=>u in ue.env).length);let d=l?.replace(/\.\d{3}Z$/,"")??null;if(a.info(` ${n}: ${s} of ${o} vars loaded (project: ${i}, loadedAt: ${d}, session: ${r})
23
- `),o>0&&s<o){let u=o-s;a.warn(` ${u} cached var(s) are not present in the current process \u2014 env-load needs to be re-sourced, or vars were unset manually.`)}}else a.info(` Session ${r}: no env loaded
24
- `);let c={sessionId:r,sessionLoadedCount:s,sessionTotalCount:o,sessionConfig:n,sessionProject:i,sessionLoadedAt:l};return{content:[{type:"text",text:JSON.stringify(c,null,2)}],structuredContent:c}},io={name:"env-status",description:"Report which Doppler project/config is currently loaded in the terminal session, when it was loaded, and how many variables are cached. Read-only \u2014 use env-load / env-clear to change the terminal session.",inputSchema:{},outputSchema:{sessionId:Q.string().describe("Current terminal session ID"),sessionLoadedCount:Q.number().describe("Number of cached vars active in the current session"),sessionTotalCount:Q.number().describe("Total number of cached var names"),sessionConfig:Q.string().nullable().describe("Doppler config name of the loaded session (environment name)"),sessionProject:Q.string().nullable().describe("Doppler project name of the loaded session"),sessionLoadedAt:Q.string().nullable().describe("ISO 8601 timestamp of when the env was loaded")},handler:Be};import po from"@inquirer/checkbox";import mo from"@inquirer/confirm";import uo from"node:process";import{z as te}from"zod/v4";import{$ as O}from"zx";import{$ as ii}from"zx";import Ge from"node:process";import{$ as P}from"zx";import{$ as ge}from"zx";import fe from"node:process";var Rr=async(e,r)=>{try{let{baseUrl:t,token:s,email:o,projectId:n}=r,i={name:e.name,projectId:e.projectId||n,description:e.description||"",released:e.released||!1,archived:e.archived||!1},l=`${t}/rest/api/3/version`,c=btoa(`${o}:${s}`),p=await fetch(l,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json",Authorization:`Basic ${c}`},body:JSON.stringify(i)});if(!p.ok){let u=await p.text();throw a.error({status:p.status,statusText:p.statusText,error:u},"Failed to create Jira version"),new Error(`HTTP ${p.status}: ${p.statusText}`)}return{success:!0,version:await p.json()}}catch(t){throw a.error({error:t},"Error creating Jira version"),t}},Ke=async e=>{try{let{baseUrl:r,token:t,email:s,projectId:o}=e,n=`${r}/rest/api/3/project/${o}/versions`,i=btoa(`${s}:${t}`),l=await fetch(n,{method:"GET",headers:{Accept:"application/json",Authorization:`Basic ${i}`}});if(!l.ok){let p=await l.text();throw a.error({status:l.status,statusText:l.statusText,error:p},"Failed to get Jira project versions"),new Error(`HTTP ${l.status}: ${l.statusText}`)}return await l.json()}catch(r){throw a.error({error:r},"Error getting Jira project versions"),r}},co=async(e,r)=>{try{return(await Ke(r)).find(o=>o.name===e)||null}catch(t){throw a.error({error:t,versionName:e},"Error finding Jira version by name"),t}},lo=async(e,r)=>{try{let{baseUrl:t,token:s,email:o}=r,n={released:e.released??!0,archived:e.archived??!1};e.releaseDate?n.releaseDate=e.releaseDate:e.released!==!1&&(n.releaseDate=new Date().toISOString().split("T")[0]),e.description!==void 0&&(n.description=e.description);let i=`${t}/rest/api/3/version/${e.versionId}`,l=btoa(`${o}:${s}`),c=await fetch(i,{method:"PUT",headers:{Accept:"application/json","Content-Type":"application/json",Authorization:`Basic ${l}`},body:JSON.stringify(n)});if(!c.ok){let d=await c.text();throw a.error({status:c.status,statusText:c.statusText,error:d},"Failed to update Jira version"),new Error(`HTTP ${c.status}: ${c.statusText}`)}return{success:!0,version:await c.json()}}catch(t){throw a.error({error:t},"Error updating Jira version"),t}},br=async(e,r)=>{try{let{versionName:t}=e,s=await co(t,r);if(!s)throw a.error({versionName:t},"Jira version not found"),new Error(`Version "${t}" not found in Jira project`);return await lo({versionId:s.id,released:!0,releaseDate:new Date().toISOString().split("T")[0]},r)}catch(t){throw a.error({error:t},"Error delivering Jira release"),t}},ee=async()=>{let e=fe.env.JIRA_BASE_URL,r=fe.env.JIRA_TOKEN||fe.env.JIRA_API_TOKEN,t=fe.env.JIRA_PROJECT_ID,s=fe.env.JIRA_EMAIL,o=[];if(e||o.push("JIRA_BASE_URL (e.g., https://your-domain.atlassian.net)"),r||o.push("JIRA_TOKEN or JIRA_API_TOKEN (your Jira API token)"),t||o.push("JIRA_PROJECT_ID (numeric project ID)"),s||o.push("JIRA_EMAIL (your Jira email address)"),o.length>0){let i=["Jira configuration is required but incomplete.","Please configure the following environment variables:",...o.map(l=>` - ${l}`),"","You can set these in your .env file or as environment variables."].join(`
25
- `);throw new Error(i)}let n=Number.parseInt(t,10);if(Number.isNaN(n))throw new TypeError(`Invalid JIRA_PROJECT_ID: "${t}" must be a numeric value (e.g., 10001)`);return{baseUrl:e.replace(/\/$/,""),token:r,projectId:n,email:s}},he=async()=>{try{return await ee()}catch(e){return a.warn({error:e},"Jira configuration not available, skipping Jira integration"),null}};var qe=e=>e==="hotfix"?"main":"dev",ve=async(e="regular")=>{let r=qe(e);ge.quiet=!0,await ge`git fetch origin`,await ge`git switch ${r}`,await ge`git pull origin ${r}`,ge.quiet=!1},we=async e=>{let{version:r,jiraConfig:t,description:s,type:o="regular"}=e,n=`v${r}`,i=await Rr({name:n,projectId:t.projectId,description:s||"",released:!1,archived:!1},t),l=`${t.baseUrl}/projects/${i.version.projectId}/versions/${i.version.id}/tab/release-report-all-issues`,c=await ze({version:r,jiraVersionUrl:l,type:o,description:s});return{version:r,type:o,branchName:c.branchName,prUrl:c.prUrl,jiraVersionUrl:l}},C=async()=>{let e=new Map,r=await he();if(!r)return e;try{let t=await Ke(r);for(let s of t)s.description&&e.set(s.name,s.description)}catch{}return e},re=(e,r,t)=>{let s=t?" ".repeat(t-e.length+3):" ",o=`[${r}]`.padEnd(11);return`${e}${s}${o}`},y=e=>e.toLowerCase().startsWith("hotfix")?"hotfix":"regular",E=e=>{let{branches:r,descriptions:t,types:s}=e,o=r.map(i=>i.replace("release/v","")),n=Math.max(...o.map(i=>i.length));return r.map((i,l)=>{let c=o[l],p=s?s.get(i)||"regular":void 0,d=t.get(`v${c}`),u=" ".repeat(n-c.length+3),h=p?re(c,p,n):c;return d&&(h=p?`${h} ${d}`:`${c}${u}${d}`),{name:h,value:i}})};var Cr=e=>e.replace("release/","").slice(1).split(".").map(Number),Ue=e=>[...e].sort((r,t)=>{let[s,o,n]=Cr(r),[i,l,c]=Cr(t);return s!==i?(s??0)-(i??0):o!==l?(o??0)-(l??0):(n??0)-(c??0)});var Gr=async()=>{let e=await P`gh pr list --search "Release in:title" --base dev --json number,title,headRefName,state,baseRefName`,r=await P`gh pr list --search "Hotfix in:title" --base main --json number,title,headRefName,state,baseRefName`,t=[...JSON.parse(e.stdout),...JSON.parse(r.stdout)],s=new Set;return t.filter(o=>s.has(o.headRefName)?!1:(s.add(o.headRefName),!0))},He=async()=>{try{let e=await Gr();return e.length===0&&(a.error("\u274C No release PRs found. Check the project folder for the script. Exiting..."),Ge.exit(1)),Ue(e.map(r=>r.headRefName))}catch(e){a.error({error:e},"\u274C Error fetching release PRs"),Ge.exit(1)}},k=async()=>{try{let e=await Gr();e.length===0&&(a.error("\u274C No release PRs found. Check the project folder for the script. Exiting..."),Ge.exit(1));let r=Ue(e.map(s=>s.headRefName)),t=new Map(e.map(s=>[s.headRefName,s]));return r.map(s=>({branch:s,title:t.get(s).title}))}catch(e){a.error({error:e},"\u274C Error fetching release PRs"),Ge.exit(1)}},ze=async e=>{let{version:r,jiraVersionUrl:t,type:s,description:o}=e,n=s==="hotfix"?"Hotfix":"Release",i=qe(s),l=`release/v${r}`,c=o&&o.trim()!==""?`${t}
38
+ `,384),pt.stdout.write(`${c}
39
+ `),m.print();let p=So(s),u={filePath:c,variableCount:p,project:o,config:t};return{content:[{type:"text",text:JSON.stringify(u,null,2)}],structuredContent:u}},mt=1024*1024,To=3e4,$o=async(e,r)=>{let t=Xe.quiet;Xe.quiet=!0;try{let o=await Xe`doppler secrets download --no-file --format env --project ${e} --config ${r}`.timeout(To);return Po(o.stdout),o.stdout.trim()}finally{Xe.quiet=t}},Po=e=>{let r=bo.byteLength(e,"utf-8");if(r>mt)throw new Error(`doppler returned unexpectedly large output (${r} bytes > ${mt}) \u2014 refusing to write to disk`)},So=e=>e.split(`
40
+ `).filter(r=>qe.test(r)).length,Eo=new Set(["set -a","set +a"]),Nr=e=>`'${e.replaceAll("'","'\\''")}'`,Io=e=>{if(e.trim().length===0)throw new Error("doppler returned empty output for env-load");for(let r of e.split(`
41
+ `)){let t=r.trim();if(!(t.length===0||Eo.has(t))&&!qe.test(t))throw new Error(`doppler returned unexpected output for env-load (expected KEY=value lines, got: ${JSON.stringify(t.slice(0,80))})`)}},Ao={name:"env-load",description:'Download the env vars for a Doppler config and write them to a temporary shell script. Does NOT mutate the calling process \u2014 returns the path to a script that must be sourced ("source <filePath>") for the vars to take effect. The infra-kit shell wrapper auto-sources; direct MCP callers must handle sourcing themselves or surface filePath to the user. "config" is required when invoked via MCP (the CLI interactive picker is unreachable without a TTY).',inputSchema:{config:Ce.string().describe('Doppler config / environment name to load (e.g. "dev", "arthur", "renana"). Required for MCP calls.')},outputSchema:{filePath:Ce.string().describe("Path to the file that must be sourced to apply variables"),variableCount:Ce.number().describe("Number of variables loaded"),project:Ce.string().describe("Doppler project name"),config:Ce.string().describe("Doppler config name")},handler:Ze};import _o from"node:path";import Te from"node:process";import{z as oe}from"zod/v4";var Qe=async()=>{await xe(),a.info("Environment session status:");let e=te(),r=Te.env[Ke],t=_o.join(e,Z),o=0,s=0,n=Te.env[Q]??null,i=Te.env[ee]??null,l=Te.env[re]??null;if(n){let p=Ue(t);p.length>0&&(s=p.length,o=p.filter(d=>d in Te.env).length);let u=l?.replace(/\.\d{3}Z$/,"")??null;if(a.info(` ${n}: ${o} of ${s} vars loaded (project: ${i}, loadedAt: ${u}, session: ${r})
42
+ `),s>0&&o<s){let d=s-o;a.warn(` ${d} cached var(s) are not present in the current process \u2014 env-load needs to be re-sourced, or vars were unset manually.`)}}else a.info(` Session ${r}: no env loaded
43
+ `);let c={sessionId:r,sessionLoadedCount:o,sessionTotalCount:s,sessionConfig:n,sessionProject:i,sessionLoadedAt:l};return{content:[{type:"text",text:JSON.stringify(c,null,2)}],structuredContent:c}},No={name:"env-status",description:"Report which Doppler project/config is currently loaded in the terminal session, when it was loaded, and how many variables are cached. Read-only \u2014 use env-load / env-clear to change the terminal session.",inputSchema:{},outputSchema:{sessionId:oe.string().describe("Current terminal session ID"),sessionLoadedCount:oe.number().describe("Number of cached vars active in the current session"),sessionTotalCount:oe.number().describe("Total number of cached var names"),sessionConfig:oe.string().nullable().describe("Doppler config name of the loaded session (environment name)"),sessionProject:oe.string().nullable().describe("Doppler project name of the loaded session"),sessionLoadedAt:oe.string().nullable().describe("ISO 8601 timestamp of when the env was loaded")},handler:Qe};import Jo from"@inquirer/checkbox";import Bo from"@inquirer/confirm";import Ko from"node:process";import{z as me}from"zod/v4";import{$ as O}from"zx";import{$ as oa}from"zx";import sr from"node:process";import{$ as I}from"zx";import{$ as Pe}from"zx";import $e from"node:process";var Or=async(e,r)=>{try{let{baseUrl:t,token:o,email:s,projectId:n}=r,i={name:e.name,projectId:e.projectId||n,description:e.description||"",released:e.released||!1,archived:e.archived||!1},l=`${t}/rest/api/3/version`,c=btoa(`${s}:${o}`),p=await fetch(l,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json",Authorization:`Basic ${c}`},body:JSON.stringify(i)});if(!p.ok){let d=await p.text();throw a.error({status:p.status,statusText:p.statusText,error:d},"Failed to create Jira version"),new Error(`HTTP ${p.status}: ${p.statusText}`)}return{success:!0,version:await p.json()}}catch(t){throw a.error({error:t},"Error creating Jira version"),t}},se=async e=>{try{let{baseUrl:r,token:t,email:o,projectId:s}=e,n=`${r}/rest/api/3/project/${s}/versions`,i=btoa(`${o}:${t}`),l=await fetch(n,{method:"GET",headers:{Accept:"application/json",Authorization:`Basic ${i}`}});if(!l.ok){let p=await l.text();throw a.error({status:l.status,statusText:l.statusText,error:p},"Failed to get Jira project versions"),new Error(`HTTP ${l.status}: ${l.statusText}`)}return await l.json()}catch(r){throw a.error({error:r},"Error getting Jira project versions"),r}},Do=async(e,r)=>{try{return(await se(r)).find(s=>s.name===e)||null}catch(t){throw a.error({error:t,versionName:e},"Error finding Jira version by name"),t}},Fo=async(e,r)=>{try{let{baseUrl:t,token:o,email:s}=r,n={released:e.released??!0,archived:e.archived??!1};e.releaseDate?n.releaseDate=e.releaseDate:e.released!==!1&&(n.releaseDate=new Date().toISOString().split("T")[0]),e.description!==void 0&&(n.description=e.description);let i=`${t}/rest/api/3/version/${e.versionId}`,l=btoa(`${s}:${o}`),c=await fetch(i,{method:"PUT",headers:{Accept:"application/json","Content-Type":"application/json",Authorization:`Basic ${l}`},body:JSON.stringify(n)});if(!c.ok){let u=await c.text();throw a.error({status:c.status,statusText:c.statusText,error:u},"Failed to update Jira version"),new Error(`HTTP ${c.status}: ${c.statusText}`)}return{success:!0,version:await c.json()}}catch(t){throw a.error({error:t},"Error updating Jira version"),t}},Dr=async(e,r)=>{try{let{versionName:t}=e,o=await Do(t,r);if(!o)throw a.error({versionName:t},"Jira version not found"),new Error(`Version "${t}" not found in Jira project`);return await Fo({versionId:o.id,released:!0,releaseDate:new Date().toISOString().split("T")[0]},r)}catch(t){throw a.error({error:t},"Error delivering Jira release"),t}},ne=async()=>{let e=$e.env.JIRA_BASE_URL,r=$e.env.JIRA_TOKEN||$e.env.JIRA_API_TOKEN,t=$e.env.JIRA_PROJECT_ID,o=$e.env.JIRA_EMAIL,s=[];if(e||s.push("JIRA_BASE_URL (e.g., https://your-domain.atlassian.net)"),r||s.push("JIRA_TOKEN or JIRA_API_TOKEN (your Jira API token)"),t||s.push("JIRA_PROJECT_ID (numeric project ID)"),o||s.push("JIRA_EMAIL (your Jira email address)"),s.length>0){let i=["Jira configuration is required but incomplete.","Please configure the following environment variables:",...s.map(l=>` - ${l}`),"","You can set these in your .env file or as environment variables."].join(`
44
+ `);throw new Error(i)}let n=Number.parseInt(t,10);if(Number.isNaN(n))throw new TypeError(`Invalid JIRA_PROJECT_ID: "${t}" must be a numeric value (e.g., 10001)`);return{baseUrl:e.replace(/\/$/,""),token:r,projectId:n,email:o}},G=async()=>{try{return await ne()}catch(e){return a.warn({error:e},"Jira configuration not available, skipping Jira integration"),null}};var er=e=>e==="hotfix"?"main":"dev",Se=async(e="regular")=>{let r=er(e);Pe.quiet=!0,await Pe`git fetch origin`,await Pe`git switch ${r}`,await Pe`git pull origin ${r}`,Pe.quiet=!1},Ee=async e=>{let{version:r,jiraConfig:t,description:o,type:s="regular"}=e,n=`v${r}`,i=await Or({name:n,projectId:t.projectId,description:o||"",released:!1,archived:!1},t),l=`${t.baseUrl}/projects/${i.version.projectId}/versions/${i.version.id}/tab/release-report-all-issues`,c=await rr({version:r,jiraVersionUrl:l,type:s,description:o});return{version:r,type:s,branchName:c.branchName,prUrl:c.prUrl,jiraVersionUrl:l}},b=async()=>{let e=new Map,r=await G();if(!r)return e;try{let t=await se(r);for(let o of t)o.description&&e.set(o.name,o.description)}catch{}return e},ie=(e,r,t)=>{let o=t?" ".repeat(t-e.length+3):" ",s=`[${r}]`.padEnd(11);return`${e}${o}${s}`},y=e=>e.toLowerCase().startsWith("hotfix")?"hotfix":"regular",E=e=>{let{branches:r,descriptions:t,types:o}=e,s=r.map(i=>i.replace("release/v","")),n=Math.max(...s.map(i=>i.length));return r.map((i,l)=>{let c=s[l],p=o?o.get(i)||"regular":void 0,u=t.get(`v${c}`),d=" ".repeat(n-c.length+3),h=p?ie(c,p,n):c;return u&&(h=p?`${h} ${u}`:`${c}${d}${u}`),{name:h,value:i}})};import{$ as or}from"zx";var ae=e=>e.replace("release/","").slice(1).split(".").map(Number),ce=e=>[...e].sort((r,t)=>{let[o,s,n]=ae(r),[i,l,c]=ae(t);return o!==i?(o??0)-(i??0):s!==l?(s??0)-(l??0):(n??0)-(c??0)});var le="next",jo=/^v?(\d+)\.(\d+)\.(\d+)$/,Lo=e=>e.replace(/^.*release\//,""),dt=e=>{let r=Lo(e.trim()),t=jo.exec(r);return t?[Number(t[1]),Number(t[2]),Number(t[3])]:null},ut=e=>`${e[0]}.${e[1]}.${e[2]}`,Fr=e=>{let r=[...e.remoteBranches??[],...e.jiraVersions??[]],t=[],o=new Set;for(let s of r){let n=dt(s);if(!n)continue;let i=ut(n);o.has(i)||(o.add(i),t.push(n))}return ce(t.map(s=>ut(s))).map(s=>ae(`v${s}`))},j=class extends Error{constructor(){super("No prior release versions found from git or Jira. Specify the version explicitly."),this.name="NoPriorVersionsError"}},tr=(e,r)=>{if(e.length===0)throw new j;let t=e[e.length-1];if(r==="hotfix"){let[n,i]=t,l=e.reduce((c,p)=>p[0]===n&&p[1]===i?Math.max(c,p[2]):c,0);return`${n}.${i}.${l+1}`}let[o,s]=t;return`${o}.${s+1}.0`},Wo=e=>e.trim().toLowerCase()===le,Ie=(e,r,t)=>{let o=[...t],s=[];for(let n of e){let i=n.trim();if(i==="")continue;if(Wo(i)){let p=tr(o,r);s.push(p),o.push(ae(`v${p}`));continue}let l=dt(i);if(!l)throw new Error(`Invalid version "${i}". Expected semver like "1.2.5" or the token "next".`);let c=`${l[0]}.${l[1]}.${l[2]}`;s.push(c),o.push(l)}return s},pe=e=>e.split(",").map(r=>r.trim()).filter(Boolean);var Mo=async()=>{let e=or.quiet;try{return or.quiet=!0,(await or`git ls-remote --heads origin 'release/v*'`).stdout.split(`
45
+ `).map(o=>{let s=o.indexOf(" ");return s===-1?"":o.slice(s+1).replace(/^refs\/heads\//,"")}).filter(Boolean)}finally{or.quiet=e}},Vo=async()=>{let e=await G();return e?(await se(e)).map(t=>t.name):[]},Ae=async()=>{let[e,r]=await Promise.allSettled([Mo(),Vo()]);return e.status==="rejected"&&a.warn({error:e.reason},"Failed to list remote release branches; continuing without them"),r.status==="rejected"&&a.warn({error:r.reason},"Failed to fetch Jira versions; continuing without them"),Fr({remoteBranches:e.status==="fulfilled"?e.value:[],jiraVersions:r.status==="fulfilled"?r.value:[]})};var ft=async()=>{let e=await I`gh pr list --search "Release in:title" --base dev --json number,title,headRefName,state,baseRefName`,r=await I`gh pr list --search "Hotfix in:title" --base main --json number,title,headRefName,state,baseRefName`,t=[...JSON.parse(e.stdout),...JSON.parse(r.stdout)],o=new Set;return t.filter(s=>o.has(s.headRefName)?!1:(o.add(s.headRefName),!0))},nr=async()=>{try{let e=await ft();return e.length===0&&(a.error("\u274C No release PRs found. Check the project folder for the script. Exiting..."),sr.exit(1)),ce(e.map(r=>r.headRefName))}catch(e){a.error({error:e},"\u274C Error fetching release PRs"),sr.exit(1)}},k=async()=>{try{let e=await ft();e.length===0&&(a.error("\u274C No release PRs found. Check the project folder for the script. Exiting..."),sr.exit(1));let r=ce(e.map(o=>o.headRefName)),t=new Map(e.map(o=>[o.headRefName,o]));return r.map(o=>({branch:o,title:t.get(o).title}))}catch(e){a.error({error:e},"\u274C Error fetching release PRs"),sr.exit(1)}},rr=async e=>{let{version:r,jiraVersionUrl:t,type:o,description:s}=e,n=o==="hotfix"?"Hotfix":"Release",i=er(o),l=`release/v${r}`,c=s&&s.trim()!==""?`${t}
26
46
 
27
- ${o}`:`${t}
28
- `;try{P.quiet=!0,await P`git switch ${i}`,await P`git pull origin ${i}`,await P`git checkout -b ${l}`,await P`git push -u origin ${l}`,await P`git commit --allow-empty-message --allow-empty --message ''`,await P`git push origin ${l}`;let d=(await P`gh pr create --title "${n} v${r}" --body ${c} --base ${i} --head ${l}`).stdout.trim();return await P`git switch ${i}`,P.quiet=!1,{branchName:l,prUrl:d}}catch(p){throw a.error({error:p,branchName:l},`Error creating release branch ${l}`),p}};var Ye=async e=>{let{all:r,confirmedCommand:t}=e;m.start("merge-dev");let o=(await k()).filter(d=>y(d.title)==="regular").map(d=>d.branch);if(o.length===0)return a.info("\u2139\uFE0F No open release branches found"),m.print(),{content:[{type:"text",text:JSON.stringify({successfulMerges:0,failedMerges:0,failedBranches:[],totalBranches:0},null,2)}],structuredContent:{successfulMerges:0,failedMerges:0,failedBranches:[],totalBranches:0}};let n=[];if(r)n=o;else{m.setInteractive();let d=await C();n=await po({required:!0,message:"\u{1F33F} Select release branches",choices:E({branches:o,descriptions:d})})}n.length===o.length?m.addOption("--all",!0):m.addOption("--versions",n.map(d=>d.replace("release/v","")));let l=t?!0:await mo({message:`Are you sure you want to merge dev into these branches: ${n.join(", ")}?`});t||m.setInteractive(),l||(a.info("Operation cancelled. Exiting..."),uo.exit(0)),t||m.addOption("--yes",!0),O.quiet=!0,await O`git fetch origin`,await O`git switch dev`,await O`git pull origin dev`;let c=[];for(let d of n)await fo(d)||c.push(d);if(O.quiet=!1,c.length>0){a.info(`
47
+ ${s}`:`${t}
48
+ `;try{I.quiet=!0,await I`git switch ${i}`,await I`git pull origin ${i}`,await I`git checkout -b ${l}`,await I`git push -u origin ${l}`,await I`git commit --allow-empty-message --allow-empty --message ''`,await I`git push origin ${l}`;let u=(await I`gh pr create --title "${n} v${r}" --body ${c} --base ${i} --head ${l}`).stdout.trim();return await I`git switch ${i}`,I.quiet=!1,{branchName:l,prUrl:u}}catch(p){throw a.error({error:p,branchName:l},`Error creating release branch ${l}`),p}};var ir=async e=>{let{all:r,confirmedCommand:t}=e;m.start("merge-dev");let s=(await k()).filter(u=>y(u.title)==="regular").map(u=>u.branch);if(s.length===0)return a.info("\u2139\uFE0F No open release branches found"),m.print(),{content:[{type:"text",text:JSON.stringify({successfulMerges:0,failedMerges:0,failedBranches:[],totalBranches:0},null,2)}],structuredContent:{successfulMerges:0,failedMerges:0,failedBranches:[],totalBranches:0}};let n=[];if(r)n=s;else{m.setInteractive();let u=await b();n=await Jo({required:!0,message:"\u{1F33F} Select release branches",choices:E({branches:s,descriptions:u})})}n.length===s.length?m.addOption("--all",!0):m.addOption("--versions",n.map(u=>u.replace("release/v","")));let l=t?!0:await Bo({message:`Are you sure you want to merge dev into these branches: ${n.join(", ")}?`});t||m.setInteractive(),l||(a.info("Operation cancelled. Exiting..."),Ko.exit(0)),t||m.addOption("--yes",!0),O.quiet=!0,await O`git fetch origin`,await O`git switch dev`,await O`git pull origin dev`;let c=[];for(let u of n)await qo(u)||c.push(u);if(O.quiet=!1,c.length>0){a.info(`
29
49
  \u26A0\uFE0F ${c.length} branch(es) failed to merge automatically.
30
- `),a.info("\u{1F4CB} Manual merge script for failed branches:");for(let d of c)a.info(`# Merge dev into ${d} and resolve conflicts if any
50
+ `),a.info("\u{1F4CB} Manual merge script for failed branches:");for(let u of c)a.info(`# Merge dev into ${u} and resolve conflicts if any
31
51
 
32
- git switch ${d} && git pull origin ${d} && git merge origin/dev
33
- git push origin ${d} && git switch dev
52
+ git switch ${u} && git pull origin ${u} && git merge origin/dev
53
+ git push origin ${u} && git switch dev
34
54
  `);a.info(`\u2705 ${n.length-c.length}/${n.length} merges completed successfully.`)}else a.info(`\u2705 All merges completed successfully!
35
- `);m.print();let p={successfulMerges:n.length-c.length,failedMerges:c.length,failedBranches:c,totalBranches:n.length};return{content:[{type:"text",text:JSON.stringify(p,null,2)}],structuredContent:p}},fo=async e=>{try{return await O`git switch ${e}`,await O`git pull origin ${e}`,await O`git merge origin/dev --no-edit`,await O`git push origin ${e}`,await O`git switch dev`,a.info(`Successfully merged dev into ${e}`),!0}catch(r){return a.error({error:r,branch:e},`Error merging dev into ${e}`),await O`git reset --merge HEAD~1`,!1}},ho={name:"gh-merge-dev",description:"Merge origin/dev into every open regular (non-hotfix) release branch and push the result. Mutates local git state and the remote release branches. When invoked via MCP, pass all=true \u2014 the branch picker is unreachable without a TTY, and the confirmation prompt is auto-skipped for MCP calls, so the caller is responsible for gating. Irreversible once pushed.",inputSchema:{all:te.boolean().optional().describe("Target every open regular release branch. Must be true for MCP calls (the interactive picker is unavailable without a TTY).")},outputSchema:{successfulMerges:te.number().describe("Number of successful merges"),failedMerges:te.number().describe("Number of failed merges"),failedBranches:te.array(te.string()).describe("List of branches that failed to merge"),totalBranches:te.number().describe("Total number of branches processed")},handler:Ye};import go from"@inquirer/confirm";import vo from"@inquirer/select";import xr from"node:process";import{z as ye}from"zod/v4";import{$ as S}from"zx";var Xe=async e=>{let{version:r,confirmedCommand:t}=e;m.start("release-deliver");let s=await k(),o=s.map(u=>u.branch),n=new Map(s.map(u=>[u.branch,y(u.title)])),i="";if(r)i=`release/v${r}`;else{m.setInteractive();let u=await C();i=await vo({message:"\u{1F33F} Select release branch",choices:E({branches:o,descriptions:u,types:n})})}let l=i.replace("release/v","");m.addOption("--version",l);let c=s.find(u=>u.branch===i);c||(a.error(`\u274C Release branch ${i} not found in open PRs. Exiting...`),xr.exit(1));let p=y(c.title),d=t?!0:await go({message:`Are you sure you want to deliver version ${i} to production?`});t||m.setInteractive(),d||(a.info("Operation cancelled. Exiting..."),xr.exit(0)),m.addOption("--yes",!0);try{S.quiet=!0,p==="hotfix"?(await S`gh pr merge ${i} --squash --admin --delete-branch`,S.quiet=!1,await S`gh workflow run deploy-all.yml --ref main -f environment=prod`,S.quiet=!0,await S`git switch main && git pull && git switch dev && git pull && git merge main --no-edit && git push`):(await S`gh pr merge ${i} --squash --admin --delete-branch`,await S`gh pr create --base main --head dev --title "Release v${l} (RC)" --body ""`,await S`gh pr merge dev --squash --admin`,S.quiet=!1,await S`gh workflow run deploy-all.yml --ref main -f environment=prod`,S.quiet=!0,await S`git switch main && git pull && git switch dev && git pull && git merge main --no-edit && git push`),S.quiet=!1;let u=await he();if(u)try{let f=i.replace("release/","");await br({versionName:f},u)}catch(f){a.error({error:f},"Failed to deliver Jira release (non-blocking)")}else a.info("\u{1F514} Jira is not configured, skipping Jira release delivery");a.info(`Successfully delivered ${i} to production!`),m.print();let h={releaseBranch:i,version:i.replace("release/v",""),type:p,success:!0};return{content:[{type:"text",text:JSON.stringify(h,null,2)}],structuredContent:h}}catch(u){a.error({error:u},"\u274C Error merging release branch into dev"),xr.exit(1)}},wo={name:"gh-release-deliver",description:'Deliver a release to production. For hotfixes: squash-merges the release branch to main and dispatches the deploy-all workflow. For regular releases: squash-merges to dev, opens an RC PR, merges dev into main, dispatches the deploy-all workflow, then syncs main back to dev. Also releases the matching Jira fix version if Jira is configured. Dispatches the deploy workflow fire-and-forget \u2014 the tool returns once the workflow is accepted by GitHub, not when the deployment finishes. Irreversible production operation: the confirmation prompt is auto-skipped for MCP calls, so the caller is responsible for gating. "version" is required when invoked via MCP (the picker is unreachable without a TTY).',inputSchema:{version:ye.string().describe('Release version to deliver to production (e.g., "1.2.5"). Required for MCP calls.')},outputSchema:{releaseBranch:ye.string().describe("The release branch that was delivered"),version:ye.string().describe("The version that was delivered"),type:ye.enum(["regular","hotfix"]).describe("Release type"),success:ye.boolean().describe("Whether the delivery was successful")},handler:Xe};import Hr from"@inquirer/select";import Yr from"node:process";import{z as J}from"zod/v4";import{$ as Tr}from"zx";var Ze=async e=>{let{version:r,env:t,skipTerraform:s}=e;m.start("release-deploy-all");let o="";if(r)o=r==="dev"?"dev":`release/v${r}`;else{m.setInteractive();let p=await k(),d=p.map(f=>f.branch),u=new Map(p.map(f=>[f.branch,y(f.title)])),h=await C();o=await Hr({message:"\u{1F33F} Select release branch",choices:[{name:"dev",value:"dev"},...E({branches:d,descriptions:h,types:u})]})}let n=o==="dev"?"dev":o.replace("release/v","");m.addOption("--version",n);let{environments:i}=await w(),l="";t?l=t:(m.setInteractive(),l=await Hr({message:"\u{1F9EA} Select environment",choices:i.map(p=>({name:p,value:p}))})),m.addOption("--env",l),i.includes(l)||(a.error(`\u274C Invalid environment: ${l}. Exiting...`),Yr.exit(1));let c=s??!1;c&&m.addOption("--skip-terraform",!0);try{Tr.quiet=!0,await Tr`gh workflow run deploy-all.yml --ref ${o} -f environment=${l} ${c?["-f","skip_terraform_deploy=true"]:[]}`,Tr.quiet=!1,a.info(`Successfully launched deploy-all workflow_dispatch for release branch: ${o} and environment: ${l}`),m.print();let d={releaseBranch:o,version:o.replace("release/v",""),environment:l,skipTerraformDeploy:c,success:!0};return{content:[{type:"text",text:JSON.stringify(d,null,2)}],structuredContent:d}}catch(p){a.error({error:p},"\u274C Error launching workflow"),Yr.exit(1)}},yo={name:"gh-release-deploy-all",description:'Dispatch the deploy-all.yml GitHub Actions workflow to deploy every service from a release branch to the given environment. Fire-and-forget \u2014 returns once GitHub accepts the workflow_dispatch, NOT when the deployment finishes; watch the workflow run for completion status. Use gh-release-deploy-selected for a subset of services. Pass version="dev" to deploy from the dev branch instead of a release branch. Both "version" and "env" are required when invoked via MCP (interactive pickers are unavailable without a TTY).',inputSchema:{version:J.string().describe('Release version to deploy from (e.g. "1.2.5") \u2014 resolves to the release/vX.Y.Z branch. Pass "dev" to deploy from the dev branch instead. Required for MCP calls.'),env:J.string().describe('Target environment name \u2014 must match an env configured for the project (e.g. "dev", "renana", "oriana"). Required for MCP calls.'),skipTerraform:J.boolean().optional().describe("Skip the terraform deployment stage.")},outputSchema:{releaseBranch:J.string().describe("The release branch that was deployed"),version:J.string().describe("The version that was deployed"),environment:J.string().describe("The environment deployed to"),skipTerraformDeploy:J.boolean().describe("Whether terraform deployment was skipped"),success:J.boolean().describe("Whether the deployment was successful")},handler:Ze};import ko from"@inquirer/checkbox";import Xr from"@inquirer/select";import Ro from"node:fs/promises";import{resolve as bo}from"node:path";import ke from"node:process";import Co from"yaml";import{z as A}from"zod/v4";import{$ as $r}from"zx";var Qe=async e=>{let{version:r,env:t,services:s,skipTerraform:o}=e;m.start("release-deploy-selected");let n="";if(r)n=r==="dev"?"dev":`release/v${r}`;else{m.setInteractive();let f=await k(),R=f.map(B=>B.branch),I=new Map(f.map(B=>[B.branch,y(B.title)])),T=await C();n=await Xr({message:"\u{1F33F} Select release branch",choices:[{name:"dev",value:"dev"},...E({branches:R,descriptions:T,types:I})]})}let i=n==="dev"?"dev":n.replace("release/v","");m.addOption("--version",i);let{environments:l}=await w(),c="";t?c=t:(m.setInteractive(),c=await Xr({message:"\u{1F9EA} Select environment",choices:l.map(f=>({name:f,value:f}))})),m.addOption("--env",c),l.includes(c)||(a.error(`\u274C Invalid environment: ${c}. Exiting...`),ke.exit(1));let p=await xo();p.length===0&&(a.error("\u274C No services found in workflow file. Exiting..."),ke.exit(1));let d=[];s&&s.length>0?d=s:(m.setInteractive(),d=await ko({message:"\u{1F680} Select services to deploy (space to select, enter to confirm)",choices:p.map(f=>({name:f,value:f}))})),m.addOption("--services",d),d.length===0&&(a.error("\u274C No services selected. Exiting..."),ke.exit(1));let u=d.filter(f=>!p.includes(f));u.length>0&&(a.error(`\u274C Invalid services: ${u.join(", ")}. Available services: ${p.join(", ")}`),ke.exit(1));let h=o??!1;h&&m.addOption("--skip-terraform",!0);try{$r.quiet=!0;let f=d.flatMap(T=>["-f",`${T}=true`]);await $r`gh workflow run deploy-selected-services.yml --ref ${n} -f environment=${c} ${f} ${h?["-f","skip_terraform_deploy=true"]:[]}`,$r.quiet=!1,a.info(`Successfully launched deploy-selected-services workflow_dispatch for release branch: ${n}, environment: ${c}, services: ${d.join(", ")}`),m.print();let I={releaseBranch:n,version:n.replace("release/v",""),environment:c,services:d,skipTerraformDeploy:h,success:!0};return{content:[{type:"text",text:JSON.stringify(I,null,2)}],structuredContent:I}}catch(f){a.error({error:f},"\u274C Error launching workflow"),ke.exit(1)}},xo=async()=>{let e=await b(),r=bo(e,".github/workflows/deploy-selected-services.yml"),t=await Ro.readFile(r,"utf-8"),o=Co.parse(t).on.workflow_dispatch.inputs,n=[];for(let[i,l]of Object.entries(o))l.type==="boolean"&&i!=="skip_terraform_deploy"&&n.push(i);return n},To={name:"gh-release-deploy-selected",description:'Dispatch the deploy-selected-services.yml GitHub Actions workflow to deploy a chosen subset of services from a release branch to the given environment. Fire-and-forget \u2014 returns once GitHub accepts the workflow_dispatch, NOT when the deployment finishes; watch the workflow run for completion status. Service names are validated against the boolean inputs declared in the workflow. Use gh-release-deploy-all for every service. "version", "env", and "services" are all required when invoked via MCP (interactive pickers are unavailable without a TTY).',inputSchema:{version:A.string().describe('Release version to deploy from (e.g. "1.2.5") \u2014 resolves to the release/vX.Y.Z branch. Pass "dev" to deploy from the dev branch instead. Required for MCP calls.'),env:A.string().describe('Target environment name \u2014 must match an env configured for the project (e.g. "dev", "renana", "oriana"). Required for MCP calls.'),services:A.array(A.string()).describe('Service names to deploy. Each must match a boolean input declared in .github/workflows/deploy-selected-services.yml (e.g. "client-be", "client-fe"). Required for MCP calls.'),skipTerraform:A.boolean().optional().describe("Skip the terraform deployment stage.")},outputSchema:{releaseBranch:A.string().describe("The release branch that was deployed"),version:A.string().describe("The version that was deployed"),environment:A.string().describe("The environment deployed to"),services:A.array(A.string()).describe("The services that were deployed"),skipTerraformDeploy:A.boolean().describe("Whether terraform deployment was skipped"),success:A.boolean().describe("Whether the deployment was successful")},handler:Qe};import{z as oe}from"zod/v4";var er=async()=>{let r=(await k()).map(i=>({version:i.branch.replace("release/",""),type:y(i.title)})),t=await C(),s=Math.max(...r.map(i=>i.version.length)),o=r.map(i=>{let l=re(i.version,i.type,s),c=t.get(i.version);return c?`${l} ${c}`:l});a.info(`All release branches:
55
+ `);m.print();let p={successfulMerges:n.length-c.length,failedMerges:c.length,failedBranches:c,totalBranches:n.length};return{content:[{type:"text",text:JSON.stringify(p,null,2)}],structuredContent:p}},qo=async e=>{try{return await O`git switch ${e}`,await O`git pull origin ${e}`,await O`git merge origin/dev --no-edit`,await O`git push origin ${e}`,await O`git switch dev`,a.info(`Successfully merged dev into ${e}`),!0}catch(r){return a.error({error:r,branch:e},`Error merging dev into ${e}`),await O`git reset --merge HEAD~1`,!1}},Uo={name:"gh-merge-dev",description:"Merge origin/dev into every open regular (non-hotfix) release branch and push the result. Mutates local git state and the remote release branches. When invoked via MCP, pass all=true \u2014 the branch picker is unreachable without a TTY, and the confirmation prompt is auto-skipped for MCP calls, so the caller is responsible for gating. Irreversible once pushed.",inputSchema:{all:me.boolean().optional().describe("Target every open regular release branch. Must be true for MCP calls (the interactive picker is unavailable without a TTY).")},outputSchema:{successfulMerges:me.number().describe("Number of successful merges"),failedMerges:me.number().describe("Number of failed merges"),failedBranches:me.array(me.string()).describe("List of branches that failed to merge"),totalBranches:me.number().describe("Total number of branches processed")},handler:ir};import Go from"@inquirer/confirm";import zo from"@inquirer/select";import jr from"node:process";import{z as _e}from"zod/v4";import{$ as P}from"zx";var ar=async e=>{let{version:r,confirmedCommand:t}=e;m.start("release-deliver");let o=await k(),s=o.map(d=>d.branch),n=new Map(o.map(d=>[d.branch,y(d.title)])),i="";if(r)i=`release/v${r}`;else{m.setInteractive();let d=await b();i=await zo({message:"\u{1F33F} Select release branch",choices:E({branches:s,descriptions:d,types:n})})}let l=i.replace("release/v","");m.addOption("--version",l);let c=o.find(d=>d.branch===i);c||(a.error(`\u274C Release branch ${i} not found in open PRs. Exiting...`),jr.exit(1));let p=y(c.title),u=t?!0:await Go({message:`Are you sure you want to deliver version ${i} to production?`});t||m.setInteractive(),u||(a.info("Operation cancelled. Exiting..."),jr.exit(0)),m.addOption("--yes",!0);try{P.quiet=!0,p==="hotfix"?(await P`gh pr merge ${i} --squash --admin --delete-branch`,P.quiet=!1,await P`gh workflow run deploy-all.yml --ref main -f environment=prod`,P.quiet=!0,await P`git switch main && git pull && git switch dev && git pull && git merge main --no-edit && git push`):(await P`gh pr merge ${i} --squash --admin --delete-branch`,await P`gh pr create --base main --head dev --title "Release v${l} (RC)" --body ""`,await P`gh pr merge dev --squash --admin`,P.quiet=!1,await P`gh workflow run deploy-all.yml --ref main -f environment=prod`,P.quiet=!0,await P`git switch main && git pull && git switch dev && git pull && git merge main --no-edit && git push`),P.quiet=!1;let d=await G();if(d)try{let f=i.replace("release/","");await Dr({versionName:f},d)}catch(f){a.error({error:f},"Failed to deliver Jira release (non-blocking)")}else a.info("\u{1F514} Jira is not configured, skipping Jira release delivery");a.info(`Successfully delivered ${i} to production!`),m.print();let h={releaseBranch:i,version:i.replace("release/v",""),type:p,success:!0};return{content:[{type:"text",text:JSON.stringify(h,null,2)}],structuredContent:h}}catch(d){a.error({error:d},"\u274C Error merging release branch into dev"),jr.exit(1)}},Ho={name:"gh-release-deliver",description:'Deliver a release to production. For hotfixes: squash-merges the release branch to main and dispatches the deploy-all workflow. For regular releases: squash-merges to dev, opens an RC PR, merges dev into main, dispatches the deploy-all workflow, then syncs main back to dev. Also releases the matching Jira fix version if Jira is configured. Dispatches the deploy workflow fire-and-forget \u2014 the tool returns once the workflow is accepted by GitHub, not when the deployment finishes. Irreversible production operation: the confirmation prompt is auto-skipped for MCP calls, so the caller is responsible for gating. "version" is required when invoked via MCP (the picker is unreachable without a TTY).',inputSchema:{version:_e.string().describe('Release version to deliver to production (e.g., "1.2.5"). Required for MCP calls.')},outputSchema:{releaseBranch:_e.string().describe("The release branch that was delivered"),version:_e.string().describe("The version that was delivered"),type:_e.enum(["regular","hotfix"]).describe("Release type"),success:_e.boolean().describe("Whether the delivery was successful")},handler:ar};import ht from"@inquirer/select";import gt from"node:process";import{z as V}from"zod/v4";import{$ as Lr}from"zx";var cr=async e=>{let{version:r,env:t,skipTerraform:o}=e;m.start("release-deploy-all");let s="";if(r)s=r==="dev"?"dev":`release/v${r}`;else{m.setInteractive();let p=await k(),u=p.map(f=>f.branch),d=new Map(p.map(f=>[f.branch,y(f.title)])),h=await b();s=await ht({message:"\u{1F33F} Select release branch",choices:[{name:"dev",value:"dev"},...E({branches:u,descriptions:h,types:d})]})}let n=s==="dev"?"dev":s.replace("release/v","");m.addOption("--version",n);let{environments:i}=await w(),l="";t?l=t:(m.setInteractive(),l=await ht({message:"\u{1F9EA} Select environment",choices:i.map(p=>({name:p,value:p}))})),m.addOption("--env",l),i.includes(l)||(a.error(`\u274C Invalid environment: ${l}. Exiting...`),gt.exit(1));let c=o??!1;c&&m.addOption("--skip-terraform",!0);try{Lr.quiet=!0,await Lr`gh workflow run deploy-all.yml --ref ${s} -f environment=${l} ${c?["-f","skip_terraform_deploy=true"]:[]}`,Lr.quiet=!1,a.info(`Successfully launched deploy-all workflow_dispatch for release branch: ${s} and environment: ${l}`),m.print();let u={releaseBranch:s,version:s.replace("release/v",""),environment:l,skipTerraformDeploy:c,success:!0};return{content:[{type:"text",text:JSON.stringify(u,null,2)}],structuredContent:u}}catch(p){a.error({error:p},"\u274C Error launching workflow"),gt.exit(1)}},Yo={name:"gh-release-deploy-all",description:'Dispatch the deploy-all.yml GitHub Actions workflow to deploy every service from a release branch to the given environment. Fire-and-forget \u2014 returns once GitHub accepts the workflow_dispatch, NOT when the deployment finishes; watch the workflow run for completion status. Use gh-release-deploy-selected for a subset of services. Pass version="dev" to deploy from the dev branch instead of a release branch. Both "version" and "env" are required when invoked via MCP (interactive pickers are unavailable without a TTY).',inputSchema:{version:V.string().describe('Release version to deploy from (e.g. "1.2.5") \u2014 resolves to the release/vX.Y.Z branch. Pass "dev" to deploy from the dev branch instead. Required for MCP calls.'),env:V.string().describe('Target environment name \u2014 must match an env configured for the project (e.g. "dev", "renana", "oriana"). Required for MCP calls.'),skipTerraform:V.boolean().optional().describe("Skip the terraform deployment stage.")},outputSchema:{releaseBranch:V.string().describe("The release branch that was deployed"),version:V.string().describe("The version that was deployed"),environment:V.string().describe("The environment deployed to"),skipTerraformDeploy:V.boolean().describe("Whether terraform deployment was skipped"),success:V.boolean().describe("Whether the deployment was successful")},handler:cr};import Xo from"@inquirer/checkbox";import vt from"@inquirer/select";import Zo from"node:fs/promises";import{resolve as Qo}from"node:path";import Ne from"node:process";import es from"yaml";import{z as A}from"zod/v4";import{$ as Wr}from"zx";var lr=async e=>{let{version:r,env:t,services:o,skipTerraform:s}=e;m.start("release-deploy-selected");let n="";if(r)n=r==="dev"?"dev":`release/v${r}`;else{m.setInteractive();let f=await k(),R=f.map(K=>K.branch),S=new Map(f.map(K=>[K.branch,y(K.title)])),T=await b();n=await vt({message:"\u{1F33F} Select release branch",choices:[{name:"dev",value:"dev"},...E({branches:R,descriptions:T,types:S})]})}let i=n==="dev"?"dev":n.replace("release/v","");m.addOption("--version",i);let{environments:l}=await w(),c="";t?c=t:(m.setInteractive(),c=await vt({message:"\u{1F9EA} Select environment",choices:l.map(f=>({name:f,value:f}))})),m.addOption("--env",c),l.includes(c)||(a.error(`\u274C Invalid environment: ${c}. Exiting...`),Ne.exit(1));let p=await rs();p.length===0&&(a.error("\u274C No services found in workflow file. Exiting..."),Ne.exit(1));let u=[];o&&o.length>0?u=o:(m.setInteractive(),u=await Xo({message:"\u{1F680} Select services to deploy (space to select, enter to confirm)",choices:p.map(f=>({name:f,value:f}))})),m.addOption("--services",u),u.length===0&&(a.error("\u274C No services selected. Exiting..."),Ne.exit(1));let d=u.filter(f=>!p.includes(f));d.length>0&&(a.error(`\u274C Invalid services: ${d.join(", ")}. Available services: ${p.join(", ")}`),Ne.exit(1));let h=s??!1;h&&m.addOption("--skip-terraform",!0);try{Wr.quiet=!0;let f=u.flatMap(T=>["-f",`${T}=true`]);await Wr`gh workflow run deploy-selected-services.yml --ref ${n} -f environment=${c} ${f} ${h?["-f","skip_terraform_deploy=true"]:[]}`,Wr.quiet=!1,a.info(`Successfully launched deploy-selected-services workflow_dispatch for release branch: ${n}, environment: ${c}, services: ${u.join(", ")}`),m.print();let S={releaseBranch:n,version:n.replace("release/v",""),environment:c,services:u,skipTerraformDeploy:h,success:!0};return{content:[{type:"text",text:JSON.stringify(S,null,2)}],structuredContent:S}}catch(f){a.error({error:f},"\u274C Error launching workflow"),Ne.exit(1)}},rs=async()=>{let e=await C(),r=Qo(e,".github/workflows/deploy-selected-services.yml"),t=await Zo.readFile(r,"utf-8"),s=es.parse(t).on.workflow_dispatch.inputs,n=[];for(let[i,l]of Object.entries(s))l.type==="boolean"&&i!=="skip_terraform_deploy"&&n.push(i);return n},ts={name:"gh-release-deploy-selected",description:'Dispatch the deploy-selected-services.yml GitHub Actions workflow to deploy a chosen subset of services from a release branch to the given environment. Fire-and-forget \u2014 returns once GitHub accepts the workflow_dispatch, NOT when the deployment finishes; watch the workflow run for completion status. Service names are validated against the boolean inputs declared in the workflow. Use gh-release-deploy-all for every service. "version", "env", and "services" are all required when invoked via MCP (interactive pickers are unavailable without a TTY).',inputSchema:{version:A.string().describe('Release version to deploy from (e.g. "1.2.5") \u2014 resolves to the release/vX.Y.Z branch. Pass "dev" to deploy from the dev branch instead. Required for MCP calls.'),env:A.string().describe('Target environment name \u2014 must match an env configured for the project (e.g. "dev", "renana", "oriana"). Required for MCP calls.'),services:A.array(A.string()).describe('Service names to deploy. Each must match a boolean input declared in .github/workflows/deploy-selected-services.yml (e.g. "client-be", "client-fe"). Required for MCP calls.'),skipTerraform:A.boolean().optional().describe("Skip the terraform deployment stage.")},outputSchema:{releaseBranch:A.string().describe("The release branch that was deployed"),version:A.string().describe("The version that was deployed"),environment:A.string().describe("The environment deployed to"),services:A.array(A.string()).describe("The services that were deployed"),skipTerraformDeploy:A.boolean().describe("Whether terraform deployment was skipped"),success:A.boolean().describe("Whether the deployment was successful")},handler:lr};import{z as ue}from"zod/v4";var pr=async()=>{let r=(await k()).map(i=>({version:i.branch.replace("release/",""),type:y(i.title)})),t=await b(),o=Math.max(...r.map(i=>i.version.length)),s=r.map(i=>{let l=ie(i.version,i.type,o),c=t.get(i.version);return c?`${l} ${c}`:l});a.info(`All release branches:
36
56
  `),a.info(`
37
- ${o.join(`
57
+ ${s.join(`
38
58
  `)}
39
- `);let n={releases:r.map(i=>({version:i.version,type:i.type,description:t.get(i.version)||null})),count:r.length};return{content:[{type:"text",text:JSON.stringify(n,null,2)}],structuredContent:n}},$o={name:"gh-release-list",description:"List every open release PR with its version, type (regular / hotfix), and associated Jira fix-version description. Read-only; sourced from GitHub and Jira.",inputSchema:{},outputSchema:{releases:oe.array(oe.object({version:oe.string().describe("Release version"),type:oe.enum(["regular","hotfix"]).describe("Release type"),description:oe.string().nullable().describe("Jira version description")})).describe("List of all release branches"),count:oe.number().describe("Number of release branches")},handler:er};import Zr from"@inquirer/confirm";import So from"@inquirer/select";import Qr from"node:process";import{z as N}from"zod/v4";import{$ as Sr,question as et}from"zx";var rr=async e=>{let{version:r,description:t,type:s,confirmedCommand:o,checkout:n}=e;m.start("release-create");let i=r,l=t,c=s||"regular",p=n,d=await ee();i||(m.setInteractive(),i=await et("Enter version (e.g. 1.2.5): ")),(!i||i.trim()==="")&&(a.error("No version provided. Exiting..."),Qr.exit(1));let u=i.trim();m.addOption("--version",u),s||(m.setInteractive(),c=await So({message:"Select release type:",choices:[{name:"regular",value:"regular"},{name:"hotfix",value:"hotfix"}],default:"regular"})),m.addOption("--type",c),l===void 0&&(m.setInteractive(),l=await et("Enter description (optional, press Enter to skip): "),l.trim()===""&&(l="")),l&&m.addOption("--description",l);let h=o?!0:await Zr({message:`Are you sure you want to create release branch for version ${u}?`});o||m.setInteractive(),h||(a.info("Operation cancelled. Exiting..."),Qr.exit(0)),m.addOption("--yes",!0),await ve(c);let f=await we({version:u,jiraConfig:d,description:l,type:c});a.info(`\u2705 Successfully created release: v${u}`),a.info(`\u{1F517} GitHub PR: ${f.prUrl}`),a.info(`\u{1F517} Jira Version: ${f.jiraVersionUrl}`),p===void 0&&(m.setInteractive(),p=await Zr({message:`Do you want to checkout to the created branch ${f.branchName}?`,default:!0})),p||m.addOption("--no-checkout",!0),p&&(Sr.quiet=!0,await Sr`git switch ${f.branchName}`,Sr.quiet=!1,a.info(`\u{1F504} Switched to branch ${f.branchName}`)),m.print();let R={version:u,type:c,branchName:f.branchName,prUrl:f.prUrl,jiraVersionUrl:f.jiraVersionUrl,isCheckedOut:p};return{content:[{type:"text",text:JSON.stringify(R,null,2)}],structuredContent:R}},Io={name:"release-create",description:'Create a new release: cuts the release branch off the appropriate base (dev for regular releases, main for hotfixes), opens a GitHub release PR, creates the matching Jira fix version, and optionally checks out to the new branch. Confirmation is auto-skipped for MCP calls, so the caller is responsible for gating. "version" is required when invoked via MCP (the interactive input prompt is unreachable without a TTY); "type" / "description" / "checkout" default to regular / empty / true when omitted.',inputSchema:{version:N.string().describe('Version to create (e.g., "1.2.5"). Required for MCP calls.'),description:N.string().optional().describe("Optional description for the Jira version"),type:N.enum(["regular","hotfix"]).optional().default("regular").describe('Release type: "regular" or "hotfix" (default: "regular")'),checkout:N.boolean().optional().default(!0).describe("Checkout to the created branch (default: true)")},outputSchema:{version:N.string().describe("Version number"),type:N.enum(["regular","hotfix"]).describe("Release type"),branchName:N.string().describe("Release branch name"),prUrl:N.string().describe("GitHub PR URL"),jiraVersionUrl:N.string().describe("Jira version URL"),isCheckedOut:N.boolean().describe("Whether the branch was checked out")},handler:rr};import Eo from"@inquirer/confirm";import Po from"@inquirer/select";import rt from"node:process";import{z as x}from"zod/v4";import{question as Ao}from"zx";var _o=async e=>{let{versions:r,type:t,confirmedCommand:s}=e,o=r,n=t||"regular";o||(m.setInteractive(),o=await Ao("Enter versions by comma (e.g. 1.2.5, 1.2.6): "));let i=o.split(",").map(c=>c.trim()).filter(Boolean);m.addOption("--versions",i.join(", ")),i.length===0&&(a.error("No versions provided. Exiting..."),rt.exit(1)),t||(m.setInteractive(),n=await Po({message:"Select release type:",choices:[{name:"regular",value:"regular"},{name:"hotfix",value:"hotfix"}],default:"regular"})),m.addOption("--type",n),i.length===1&&a.warn('\u{1F4A1} You are creating only one release. Consider using "create-release" command for single releases.');let l=s?!0:await Eo({message:`Are you sure you want to create release branches for these versions: ${i.join(", ")}?`});return s||m.setInteractive(),l||(a.info("Operation cancelled. Exiting..."),rt.exit(0)),m.addOption("--yes",!0),{versionsList:i,type:n}},tr=async e=>{m.start("release-create-batch");let r=await ee(),{versionsList:t,type:s}=await _o(e);await ve(s);let o=[],n=[];for(let p of t)try{let d=await we({version:p,jiraConfig:r,type:s});o.push(d),a.info(`\u2705 Successfully created release: v${p}`),a.info(`\u{1F517} GitHub PR: ${d.prUrl}`),a.info(`\u{1F517} Jira Version: ${d.jiraVersionUrl}
40
- `)}catch(d){let u=d instanceof Error?d.message:String(d);n.push({version:p,error:u}),a.error(`\u274C Failed to create release: v${p}`),a.error(` Error: ${u}
41
- `)}let i=o.length,l=n.length;i===t.length?a.info(`\u2705 All ${t.length} release branches were created successfully.`):i>0?(a.warn(`\u26A0\uFE0F ${i} of ${t.length} release branches were created successfully.`),a.warn(`\u274C ${l} release(s) failed.`)):a.error(`\u274C All ${t.length} release branches failed to create.`),m.print();let c={createdBranches:o.map(p=>p.branchName),successCount:i,failureCount:l,releases:o,failedReleases:n};return{content:[{type:"text",text:JSON.stringify(c,null,2)}],structuredContent:c}},Oo={name:"release-create-batch",description:'Create several releases in one pass: for each comma-separated version in "versions", cuts the release branch off the appropriate base (dev for regular releases, main for hotfixes), opens a GitHub PR, and creates the Jira fix version. Continues on per-version failure and reports which versions succeeded and which failed. Confirmation is auto-skipped for MCP calls, so the caller is responsible for gating. "versions" is required when invoked via MCP (the interactive input prompt is unreachable without a TTY). Use release-create for a single version with optional checkout.',inputSchema:{versions:x.string().describe('Comma-separated list of versions to create (e.g., "1.2.5, 1.2.6"). Required for MCP calls.'),type:x.enum(["regular","hotfix"]).optional().default("regular").describe('Release type: "regular" or "hotfix" (default: "regular")')},outputSchema:{createdBranches:x.array(x.string()).describe("List of created release branches"),successCount:x.number().describe("Number of releases created successfully"),failureCount:x.number().describe("Number of releases that failed"),releases:x.array(x.object({version:x.string().describe("Version number"),type:x.enum(["regular","hotfix"]).describe("Release type"),branchName:x.string().describe("Release branch name"),prUrl:x.string().describe("GitHub PR URL"),jiraVersionUrl:x.string().describe("Jira version URL")})).describe("Detailed information for each created release with URLs"),failedReleases:x.array(x.object({version:x.string().describe("Version number that failed"),error:x.string().describe("Error message")})).describe("List of releases that failed with error messages")},handler:tr};import{z as Fo}from"zod/v4";var tt={name:"infra-kit",type:"module",version:"0.1.97",description:"infra-kit",main:"dist/cli.js",module:"dist/cli.js",bin:{"infra-kit":"dist/cli.js",ik:"dist/cli.js"},engines:{node:">=24.x"},scripts:{inspector:"npx @modelcontextprotocol/inspector node ./dist/mcp.js --debug",build:"pnpm run clean-artifacts && node ./scripts/build.js","clean-artifacts":"rm -rf dist","clean-cache":"rm -rf node_modules/.cache .eslintcache tsconfig.tsbuildinfo .turbo .swc","prettier-fix":"pnpm exec prettier **/* --write --no-error-on-unmatched-pattern --log-level warn --ignore-path ../../../.prettierignore","prettier-check":"pnpm exec prettier **/* --check --no-error-on-unmatched-pattern --log-level warn --ignore-path ../../../.prettierignore","eslint-check":"pnpm exec eslint --cache --quiet --report-unused-disable-directives ./src","eslint-fix":"pnpm exec eslint --cache --quiet --report-unused-disable-directives ./src --fix","ts-check":"tsc --noEmit",test:"pnpm exec vitest run --reporter=dot","test-watch":"pnpm exec vitest --watch","test-ui":"pnpm exec vitest --ui","test-report":"pnpm exec vitest run --coverage",qa:"pnpm run prettier-check && pnpm run eslint-check && pnpm run ts-check && pnpm run test && echo \u2705 Success",fix:"pnpm run prettier-fix && pnpm run eslint-fix && pnpm run qa"},dependencies:{"@inquirer/checkbox":"^5.1.4","@inquirer/confirm":"^6.0.12","@inquirer/select":"^5.1.4","@modelcontextprotocol/sdk":"^1.29.0",commander:"^14.0.3",pino:"^10.3.1","pino-pretty":"^13.1.3",yaml:"^2.8.4",zod:"^3.25.76",zx:"^8.8.5"},devDependencies:{"@pkg/eslint-config":"workspace:*","@pkg/vitest-config":"workspace:*",esbuild:"^0.28.0",typescript:"catalog:"}};var or=async()=>{let e=tt.version;a.info(e);let r={version:e};return{content:[{type:"text",text:JSON.stringify(r,null,2)}],structuredContent:r}},Do={name:"version",description:"Print the installed infra-kit CLI version",inputSchema:{},outputSchema:{version:Fo.string().describe("Installed infra-kit CLI version (from package.json)")},handler:or};import Vo from"@inquirer/checkbox";import Pr from"@inquirer/confirm";import Bo from"@inquirer/select";import Ko from"node:process";import{z as V}from"zod/v4";import{$ as z}from"zx";import{$ as ot}from"zx";var Re=async e=>{try{let r=(await ot`cmux list-workspaces`.quiet()).stdout,t=Wo(r,e);if(!t)return;await ot`cmux close-workspace --workspace ${t}`.quiet()}catch(r){a.debug({error:r,title:e},"cmux: skipped closing workspace")}},Wo=(e,r)=>{for(let t of e.split(`
42
- `)){let s=t.match(/^[* ]\s*(workspace:\d+)\s+(.+?)(?:\s+\[selected\])?\s*$/);if(!s)continue;let o=s[1];if((s[2]?.trim()??"")===r)return o}};import{$ as Lo}from"zx";var Ir=async()=>{try{let e=(await Lo`cmux list-workspaces`.quiet()).stdout,r=new Set;for(let t of e.split(`
43
- `)){let s=t.match(/^[* ]\s*workspace:\d+\s+(.+?)(?:\s+\[selected\])?\s*$/);if(!s)continue;let o=s[1]?.trim();o&&r.add(o)}return r}catch(e){return a.debug({error:e},"cmux: skipped listing workspace titles"),new Set}};import{$ as be}from"zx";var Ce=async e=>{let{cwd:r,title:t}=e,s=(await be`cmux new-workspace --cwd ${r}`).stdout,o=jo(s),n=(await be`cmux list-pane-surfaces --workspace ${o}`).stdout,i=Mo(n);await be`cmux new-split right --workspace ${o} --surface ${i}`,await be`cmux new-split down --workspace ${o} --surface ${i}`,t&&await be`cmux rename-workspace --workspace ${o} ${t}`},Mo=e=>{let r=e.match(/surface:\d+/);if(!r)throw new Error("cmux: could not locate initial surface in list-pane-surfaces output");return r[0]},jo=e=>{let r=e.match(/workspace:\d+/);if(!r)throw new Error("cmux: could not locate workspace ref in new-workspace output");return r[0]};var L=e=>{let{repoName:r,branch:t}=e,s=t.replace("release/","");return`${r} ${s}`};import st from"node:fs/promises";import sr from"node:path";var xe=async e=>{let{workspacePath:r,folderPaths:t}=e,s=sr.dirname(r),o;try{o=await st.readFile(r,"utf-8")}catch(d){throw new Error(`Cursor workspace file not found at ${r}: ${d.message}`)}let n;try{n=JSON.parse(o)}catch(d){throw new Error(`Failed to parse ${r} as JSON. Comments (JSONC) are not supported. ${d.message}`)}let i=n.folders??[],l=new Set(i.map(d=>sr.resolve(s,d.path))),c=[],p=[];for(let d of t){let u=sr.resolve(d);if(l.has(u)){p.push(d);continue}let h=sr.relative(s,u);i.push({path:h}),l.add(u),c.push(d)}return n.folders=i,await st.writeFile(r,`${JSON.stringify(n,null,2)}
44
- `,"utf-8"),{added:c,skipped:p}};import Jo from"node:fs/promises";import ir from"node:path";import nt from"node:fs/promises";import nr from"node:path";var q=async e=>{let{workspacePath:r,folderPaths:t}=e,s=nr.dirname(r),o;try{o=await nt.readFile(r,"utf-8")}catch(h){throw new Error(`Cursor workspace file not found at ${r}: ${h.message}`)}let n;try{n=JSON.parse(o)}catch(h){throw new Error(`Failed to parse ${r} as JSON. Comments (JSONC) are not supported. ${h.message}`)}let i=n.folders??[],l=new Set(t.map(h=>nr.resolve(h))),c=new Set,p=i.filter(h=>{let f=nr.resolve(s,h.path);return l.has(f)?(c.add(f),!1):!0});n.folders=p,await nt.writeFile(r,`${JSON.stringify(n,null,2)}
45
- `,"utf-8");let d=[],u=[];for(let h of t){let f=nr.resolve(h);c.has(f)?d.push(h):u.push(h)}return{removed:d,notFound:u}};var Er=async e=>{let{workspacePath:r,worktreeDir:t,currentBranches:s}=e,o=ir.dirname(r),n=ir.resolve(`${t}/release`),i=await Jo.readFile(r,"utf-8"),c=JSON.parse(i).folders??[],p=new Set(s.map(R=>ir.resolve(`${t}/${R}`))),d=[];for(let R of c){let I=ir.resolve(o,R.path);(I===n||I.startsWith(`${n}/`))&&!p.has(I)&&d.push(I)}let u=[];d.length>0&&(u=(await q({workspacePath:r,folderPaths:d})).removed);let h=s.map(R=>`${t}/${R}`),{added:f}=h.length>0?await xe({workspacePath:r,folderPaths:h}):{added:[]};return{added:f,removed:u}};import it from"node:path";var M=(e,r)=>it.isAbsolute(e)?e:it.resolve(r,e);var qo="feature",zo="release",Uo="release/v",Te=["workspace","windows","none"],ar=async e=>{let{confirmedCommand:r,all:t,versions:s,cursor:o,githubDesktop:n,cmux:i}=e;m.start("worktrees-add");try{let l=await _("release"),c=await b(),p=`${c}${j}`;await at(`${p}/${zo}`),await at(`${p}/${qo}`);let d=[];if(s)d=s.split(",").map($=>`release/v${$.trim()}`);else{let $=await k(),F=$.map(D=>D.branch);if(F.length===0)return a.info("\u2139\uFE0F No open release branches found"),m.print(),{content:[{type:"text",text:JSON.stringify({createdWorktrees:[],count:0},null,2)}],structuredContent:{createdWorktrees:[],count:0}};if(t)d=F;else{m.setInteractive();let D=new Map($.map(Se=>[Se.branch,y(Se.title)])),dr=await C();d=await Vo({required:!0,message:"\u{1F33F} Select release branches",choices:E({branches:F,descriptions:dr,types:D})})}}t?m.addOption("--all",!0):m.addOption("--versions",d.map($=>$.replace("release/v","")));let u=r?!0:await Pr({message:"Are you sure you want to proceed with these worktree changes?"});r||m.setInteractive(),u||(a.info("Operation cancelled. Exiting..."),Ko.exit(0)),r||m.addOption("--yes",!0);let h=o??await Bo({message:"Cursor mode for created worktrees?",default:"workspace",choices:[{name:"Add to workspace file",value:"workspace",description:"Append each worktree as a folder in ide.config.workspaceConfigPath, then open the workspace"},{name:"Open separate windows",value:"windows",description:"Open each created worktree in its own Cursor window"},{name:"Skip",value:"none",description:"Do not open Cursor"}]});typeof o>"u"&&m.setInteractive(),m.addOption("--cursor",h);let f=n??await Pr({message:"Open created worktrees in GitHub Desktop?"});typeof n>"u"&&m.setInteractive(),f?m.addOption("--github-desktop",!0):m.addOption("--no-github-desktop",!0);let R=i??await Pr({message:"Open created worktrees in cmux?"});typeof i>"u"&&m.setInteractive(),R?m.addOption("--cmux",!0):m.addOption("--no-cmux",!0);let{branchesToCreate:I}=Go({selectedReleaseBranches:d,currentWorktrees:l}),T=await Ho(I,p);if(Yo(T),h==="workspace"){let $=await w(),F=$.ide?.provider==="cursor"?$.ide.config:void 0;if(!F?.workspaceConfigPath)a.warn("\u26A0\uFE0F Skipping Cursor: ide.config.workspaceConfigPath is not set in infra-kit.yml");else{let D=M(F.workspaceConfigPath,c),dr=T.map(mt=>`${p}/${mt}`),{added:Se,skipped:Nr}=await xe({workspacePath:D,folderPaths:dr}),pt=Nr.length>0?` (${Nr.length} already present)`:"";a.info(`\u2705 Added ${Se.length} folder(s) to ${D}${pt}`),await z`cursor ${D}`}}else if(h==="windows")for(let $ of T)await z`cursor ${p}/${$}`;if(f)for(let $ of T)await z`github ${p}/${$}`,await z`sleep 5`;if(R){let $=await W();for(let F of T){let D=L({repoName:$,branch:F});await Ce({cwd:`${p}/${F}`,title:D})}}m.print();let B={createdWorktrees:T,count:T.length};return{content:[{type:"text",text:JSON.stringify(B,null,2)}],structuredContent:B}}catch(l){throw a.error({error:l},"\u274C Error managing worktrees"),l}},at=async e=>{await z`mkdir -p ${e}`},Go=e=>{let{selectedReleaseBranches:r,currentWorktrees:t}=e,s=t.filter(n=>n.startsWith(Uo));return{branchesToCreate:r.filter(n=>!s.includes(n))}},Ho=async(e,r)=>{let t=await Promise.allSettled(e.map(async o=>{let n=`${r}/${o}`;return await z`git worktree add ${n} ${o}`,await z({cwd:n})`pnpm install`,o})),s=[];for(let[o,n]of t.entries())if(n.status==="fulfilled")s.push(n.value);else{let i=e[o];a.error({error:n.reason},`\u274C Failed to create worktree for ${i}`)}return s},Yo=e=>{if(e.length>0){a.info("\u2705 Created git worktrees:");for(let r of e)a.info(r);a.info("")}else a.info("\u2139\uFE0F No new git worktrees to create")},Xo={name:"worktrees-add",description:'Create local git worktrees for release branches under the worktrees directory and run "pnpm install" in each. Mutates the local filesystem. When invoked via MCP, pass either "versions" (comma-separated) or all=true \u2014 the branch picker and "open in Cursor / GitHub Desktop / cmux" follow-up prompts are unreachable without a TTY, and the CLI confirmation is auto-skipped for MCP calls.',inputSchema:{all:V.boolean().optional().describe('Add worktrees for every open release branch. Either "all" or "versions" must be provided for MCP calls (the interactive picker is unavailable without a TTY). Ignored if "versions" is provided.'),versions:V.string().optional().describe('Comma-separated release versions to target (e.g. "1.2.5, 1.2.6"). Either "versions" or all=true must be provided for MCP calls. Overrides "all" when set.'),cursor:V.enum(Te).optional().describe('Cursor open mode for created worktrees. "workspace" (default behavior when set interactively) appends each worktree as a folder to "ide.config.workspaceConfigPath" in infra-kit.yml and opens the workspace. "windows" opens each worktree in its own Cursor window. "none" skips Cursor. Defaults to "none" in MCP mode (the follow-up prompt is not shown).'),githubDesktop:V.boolean().optional().describe("Open each created worktree in GitHub Desktop. Defaults to false in MCP mode (the follow-up prompt is not shown)."),cmux:V.boolean().optional().describe("Open each created worktree in a new cmux workspace with a 3-pane layout (left-top, left-bottom, full-height right), all rooted at the worktree directory. Defaults to false in MCP mode (the follow-up prompt is not shown).")},outputSchema:{createdWorktrees:V.array(V.string()).describe("List of created git worktree branches"),count:V.number().describe("Number of git worktrees created")},handler:ar};import{z as se}from"zod/v4";var cr=async()=>{let e=await _("release");if(e.length===0)return a.info("\u2139\uFE0F No active worktrees found"),{content:[{type:"text",text:JSON.stringify({worktrees:[],count:0},null,2)}],structuredContent:{worktrees:[],count:0}};let[r,t]=await Promise.all([k(),C()]),s=new Map(r.map(c=>[c.branch,y(c.title)])),o=e.map(c=>{let p=c.replace("release/",""),d=s.get(c)||"regular",u=t.get(p)||null;return{version:p,type:d,description:u}}),n=Math.max(...o.map(c=>c.version.length)),i=o.map(c=>{let p=re(c.version,c.type,n);return c.description?`${p} ${c.description}`:p});a.info("\u{1F33F} Active worktrees:"),a.info(`
59
+ `);let n={releases:r.map(i=>({version:i.version,type:i.type,description:t.get(i.version)||null})),count:r.length};return{content:[{type:"text",text:JSON.stringify(n,null,2)}],structuredContent:n}},os={name:"gh-release-list",description:"List every open release PR with its version, type (regular / hotfix), and associated Jira fix-version description. Read-only; sourced from GitHub and Jira.",inputSchema:{},outputSchema:{releases:ue.array(ue.object({version:ue.string().describe("Release version"),type:ue.enum(["regular","hotfix"]).describe("Release type"),description:ue.string().nullable().describe("Jira version description")})).describe("List of all release branches"),count:ue.number().describe("Number of release branches")},handler:pr};import ps from"@inquirer/confirm";import ms from"@inquirer/select";import Vr from"node:process";import{z as J}from"zod/v4";import{question as wt}from"zx";import ss from"@inquirer/confirm";import ns from"@inquirer/select";import Mr from"node:process";import{z as x}from"zod/v4";import{question as is}from"zx";var as='"1.2.5, 1.2.6", "next,next", or "next,next,1.2.7"',cs=async e=>{let{versions:r,type:t,confirmedCommand:o}=e,s=r,n=t||"regular";t||(m.setInteractive(),n=await ns({message:"Select release type:",choices:[{name:"regular",value:"regular"},{name:"hotfix",value:"hotfix"}],default:"regular"})),m.addOption("--type",n),s||(m.setInteractive(),s=await is(`Enter versions by comma (e.g. ${as}): `));let i=pe(s);i.length===0&&(a.error("No versions provided. Exiting..."),Mr.exit(1));let c=i.some(d=>d.toLowerCase()===le)?await Ae():[],p;try{p=Ie(i,n,c)}catch(d){throw d instanceof j&&(a.error(d.message),Mr.exit(1)),d}m.addOption("--versions",p.join(", ")),p.length===1&&a.warn('\u{1F4A1} You are creating only one release. Consider using "create-release" command for single releases.');let u=o?!0:await ss({message:`Are you sure you want to create release branches for these versions: ${p.join(", ")}?`});return o||m.setInteractive(),u||(a.info("Operation cancelled. Exiting..."),Mr.exit(0)),m.addOption("--yes",!0),{versionsList:p,type:n}},de=async e=>{m.start("release-create-batch");let r=await ne(),{versionsList:t,type:o}=await cs(e);await Se(o);let s=[],n=[];for(let p of t)try{let u=await Ee({version:p,jiraConfig:r,type:o});s.push(u),a.info(`\u2705 Successfully created release: v${p}`),a.info(`\u{1F517} GitHub PR: ${u.prUrl}`),a.info(`\u{1F517} Jira Version: ${u.jiraVersionUrl}
60
+ `)}catch(u){let d=u instanceof Error?u.message:String(u);n.push({version:p,error:d}),a.error(`\u274C Failed to create release: v${p}`),a.error(` Error: ${d}
61
+ `)}let i=s.length,l=n.length;i===t.length?a.info(`\u2705 All ${t.length} release branches were created successfully.`):i>0?(a.warn(`\u26A0\uFE0F ${i} of ${t.length} release branches were created successfully.`),a.warn(`\u274C ${l} release(s) failed.`)):a.error(`\u274C All ${t.length} release branches failed to create.`),m.print();let c={createdBranches:s.map(p=>p.branchName),successCount:i,failureCount:l,releases:s,failedReleases:n};return{content:[{type:"text",text:JSON.stringify(c,null,2)}],structuredContent:c}},ls={name:"release-create-batch",description:'Create several releases in one pass: for each comma-separated version in "versions", cuts the release branch off the appropriate base (dev for regular releases, main for hotfixes), opens a GitHub PR, and creates the Jira fix version. The literal token "next" auto-increments from the latest known version (regular bumps minor + resets patch; hotfix bumps patch on the highest minor); multiple "next" tokens advance sequentially. Existing versions are unioned from remote release branches and Jira fix versions. Continues on per-version failure and reports which versions succeeded and which failed. Confirmation is auto-skipped for MCP calls, so the caller is responsible for gating. "versions" is required when invoked via MCP (the interactive input prompt is unreachable without a TTY). Use release-create for a single version with optional checkout.',inputSchema:{versions:x.string().describe('Comma-separated versions to create (e.g., "1.2.5, 1.2.6", "next,next", or "next,next,1.2.7"). Required for MCP calls.'),type:x.enum(["regular","hotfix"]).optional().default("regular").describe('Release type: "regular" or "hotfix" (default: "regular")')},outputSchema:{createdBranches:x.array(x.string()).describe("List of created release branches"),successCount:x.number().describe("Number of releases created successfully"),failureCount:x.number().describe("Number of releases that failed"),releases:x.array(x.object({version:x.string().describe("Version number"),type:x.enum(["regular","hotfix"]).describe("Release type"),branchName:x.string().describe("Release branch name"),prUrl:x.string().describe("GitHub PR URL"),jiraVersionUrl:x.string().describe("Jira version URL")})).describe("Detailed information for each created release with URLs"),failedReleases:x.array(x.object({version:x.string().describe("Version number that failed"),error:x.string().describe("Error message")})).describe("List of releases that failed with error messages")},handler:de};var us='"1.2.5", "next", or "next,next,1.2.7"',ds=async()=>(m.setInteractive(),ms({message:"Select release type:",choices:[{name:"regular",value:"regular"},{name:"hotfix",value:"hotfix"}],default:"regular"})),fs=(e,r)=>{try{return tr(e,r)}catch(t){if(t instanceof j)return null;throw t}},hs=e=>{throw e instanceof j&&(a.error(e.message),Vr.exit(1)),e},gs=async e=>{let{inputVersion:r,type:t,ensureKnown:o}=e;if(r&&r.trim()!=="")return pe(r);m.setInteractive();let s=fs(await o(),t),n=s?` [${s}]`:"",i=(await wt(`Enter version(s) (e.g. ${us})${n}: `)).trim();return i===""?s?[s]:[]:pe(i)},vs=async e=>{let r=await gs(e);r.length===0&&(a.error("No version provided. Exiting..."),Vr.exit(1));let t=r.some(o=>o.toLowerCase()===le);try{return Ie(r,e.type,t?await e.ensureKnown():[])}catch(o){return hs(o)}},ws=async e=>e!==void 0?e:(m.setInteractive(),(await wt("Enter description (optional, press Enter to skip): ")).trim()),mr=async e=>{let{version:r,description:t,type:o,confirmedCommand:s}=e;m.start("release-create");let n=await ne(),i=o??await ds();m.addOption("--type",i);let l=null,p=await vs({inputVersion:r,type:i,ensureKnown:async()=>(l===null&&(l=await Ae()),l)});if(p.length>1)return a.info(`Detected ${p.length} versions, routing to release-create-batch...`),de({versions:p.join(","),type:i,confirmedCommand:s});let u=p[0];m.addOption("--version",u);let d=await ws(t);d&&m.addOption("--description",d);let h=s?!0:await ps({message:`Are you sure you want to create release branch for version ${u}?`});s||m.setInteractive(),h||(a.info("Operation cancelled. Exiting..."),Vr.exit(0)),m.addOption("--yes",!0),await Se(i);let f=await Ee({version:u,jiraConfig:n,description:d,type:i});a.info(`\u2705 Successfully created release: v${u}`),a.info(`\u{1F517} GitHub PR: ${f.prUrl}`),a.info(`\u{1F517} Jira Version: ${f.jiraVersionUrl}`),m.print();let R={version:u,type:i,branchName:f.branchName,prUrl:f.prUrl,jiraVersionUrl:f.jiraVersionUrl};return{content:[{type:"text",text:JSON.stringify(R,null,2)}],structuredContent:R}},ys={name:"release-create",description:'Create a new release: cuts the release branch off the appropriate base (dev for regular releases, main for hotfixes), opens a GitHub release PR, and creates the matching Jira fix version. Does not switch the working tree to the new branch \u2014 the caller stays on the base branch. Confirmation is auto-skipped for MCP calls, so the caller is responsible for gating. "version" is required when invoked via MCP (the interactive input prompt is unreachable without a TTY); pass "next" to auto-compute the next version (regular bumps minor + resets patch; hotfix bumps patch on the highest minor) using the union of remote release branches and Jira fix versions. "type" / "description" default to regular / empty when omitted. For multiple versions in one call, prefer release-create-batch.',inputSchema:{version:J.string().describe('Version to create (e.g., "1.2.5") or the literal token "next" for auto-increment. Required for MCP calls.'),description:J.string().optional().describe("Optional description for the Jira version"),type:J.enum(["regular","hotfix"]).optional().default("regular").describe('Release type: "regular" or "hotfix" (default: "regular")')},outputSchema:{version:J.string().describe("Version number"),type:J.enum(["regular","hotfix"]).describe("Release type"),branchName:J.string().describe("Release branch name"),prUrl:J.string().describe("GitHub PR URL"),jiraVersionUrl:J.string().describe("Jira version URL")},handler:mr};import{z as Rs}from"zod/v4";var yt={name:"infra-kit",type:"module",version:"0.1.98",description:"infra-kit",main:"dist/cli.js",module:"dist/cli.js",bin:{"infra-kit":"dist/cli.js",ik:"dist/cli.js"},engines:{node:">=24.x"},scripts:{inspector:"npx @modelcontextprotocol/inspector node ./dist/mcp.js --debug",build:"pnpm run clean-artifacts && node ./scripts/build.js","clean-artifacts":"rm -rf dist","clean-cache":"rm -rf node_modules/.cache .eslintcache tsconfig.tsbuildinfo .turbo .swc","prettier-fix":"pnpm exec prettier **/* --write --no-error-on-unmatched-pattern --log-level warn --ignore-path ../../../.prettierignore","prettier-check":"pnpm exec prettier **/* --check --no-error-on-unmatched-pattern --log-level warn --ignore-path ../../../.prettierignore","eslint-check":"pnpm exec eslint --cache --quiet --report-unused-disable-directives ./src","eslint-fix":"pnpm exec eslint --cache --quiet --report-unused-disable-directives ./src --fix","ts-check":"tsc --noEmit",test:"pnpm exec vitest run --reporter=dot","test-watch":"pnpm exec vitest --watch","test-ui":"pnpm exec vitest --ui","test-report":"pnpm exec vitest run --coverage",qa:"pnpm run prettier-check && pnpm run eslint-check && pnpm run ts-check && pnpm run test && echo \u2705 Success",fix:"pnpm run prettier-fix && pnpm run eslint-fix && pnpm run qa"},dependencies:{"@inquirer/checkbox":"^5.1.4","@inquirer/confirm":"^6.0.12","@inquirer/select":"^5.1.4","@modelcontextprotocol/sdk":"^1.29.0",commander:"^14.0.3",pino:"^10.3.1","pino-pretty":"^13.1.3",yaml:"^2.8.4",zod:"^3.25.76",zx:"^8.8.5"},devDependencies:{"@pkg/eslint-config":"workspace:*","@pkg/vitest-config":"workspace:*",esbuild:"^0.28.0",typescript:"catalog:"}};var ur=async()=>{let e=yt.version;a.info(e);let r={version:e};return{content:[{type:"text",text:JSON.stringify(r,null,2)}],structuredContent:r}},bs={name:"version",description:"Print the installed infra-kit CLI version",inputSchema:{},outputSchema:{version:Rs.string().describe("Installed infra-kit CLI version (from package.json)")},handler:ur};import Ss from"@inquirer/checkbox";import Kr from"@inquirer/confirm";import Es from"@inquirer/select";import Is from"node:process";import{z as B}from"zod/v4";import{$ as H}from"zx";import{$ as kt}from"zx";var Oe=async e=>{try{let r=(await kt`cmux list-workspaces`.quiet()).stdout,t=xs(r,e);if(!t)return;await kt`cmux close-workspace --workspace ${t}`.quiet()}catch(r){a.debug({error:r,title:e},"cmux: skipped closing workspace")}},xs=(e,r)=>{for(let t of e.split(`
62
+ `)){let o=t.match(/^[* ]\s*(workspace:\d+)\s+(.+?)(?:\s+\[selected\])?\s*$/);if(!o)continue;let s=o[1];if((o[2]?.trim()??"")===r)return s}};import{$ as Cs}from"zx";var Jr=async()=>{try{let e=(await Cs`cmux list-workspaces`.quiet()).stdout,r=new Set;for(let t of e.split(`
63
+ `)){let o=t.match(/^[* ]\s*workspace:\d+\s+(.+?)(?:\s+\[selected\])?\s*$/);if(!o)continue;let s=o[1]?.trim();s&&r.add(s)}return r}catch(e){return a.debug({error:e},"cmux: skipped listing workspace titles"),new Set}};import{$ as De}from"zx";var Fe=async e=>{let{cwd:r,title:t}=e,o=(await De`cmux new-workspace --cwd ${r}`).stdout,s=$s(o),n=(await De`cmux list-pane-surfaces --workspace ${s}`).stdout,i=Ts(n);await De`cmux new-split right --workspace ${s} --surface ${i}`,await De`cmux new-split down --workspace ${s} --surface ${i}`,t&&await De`cmux rename-workspace --workspace ${s} ${t}`},Ts=e=>{let r=e.match(/surface:\d+/);if(!r)throw new Error("cmux: could not locate initial surface in list-pane-surfaces output");return r[0]},$s=e=>{let r=e.match(/workspace:\d+/);if(!r)throw new Error("cmux: could not locate workspace ref in new-workspace output");return r[0]};var L=e=>{let{repoName:r,branch:t}=e,o=t.replace("release/","");return`${r} ${o}`};import Rt from"node:fs/promises";import dr from"node:path";var je=async e=>{let{workspacePath:r,folderPaths:t}=e,o=dr.dirname(r),s;try{s=await Rt.readFile(r,"utf-8")}catch(u){throw new Error(`Cursor workspace file not found at ${r}: ${u.message}`)}let n;try{n=JSON.parse(s)}catch(u){throw new Error(`Failed to parse ${r} as JSON. Comments (JSONC) are not supported. ${u.message}`)}let i=n.folders??[],l=new Set(i.map(u=>dr.resolve(o,u.path))),c=[],p=[];for(let u of t){let d=dr.resolve(u);if(l.has(d)){p.push(u);continue}let h=dr.relative(o,d);i.push({path:h}),l.add(d),c.push(u)}return n.folders=i,await Rt.writeFile(r,`${JSON.stringify(n,null,2)}
64
+ `,"utf-8"),{added:c,skipped:p}};import Ps from"node:fs/promises";import hr from"node:path";import bt from"node:fs/promises";import fr from"node:path";var z=async e=>{let{workspacePath:r,folderPaths:t}=e,o=fr.dirname(r),s;try{s=await bt.readFile(r,"utf-8")}catch(h){throw new Error(`Cursor workspace file not found at ${r}: ${h.message}`)}let n;try{n=JSON.parse(s)}catch(h){throw new Error(`Failed to parse ${r} as JSON. Comments (JSONC) are not supported. ${h.message}`)}let i=n.folders??[],l=new Set(t.map(h=>fr.resolve(h))),c=new Set,p=i.filter(h=>{let f=fr.resolve(o,h.path);return l.has(f)?(c.add(f),!1):!0});n.folders=p,await bt.writeFile(r,`${JSON.stringify(n,null,2)}
65
+ `,"utf-8");let u=[],d=[];for(let h of t){let f=fr.resolve(h);c.has(f)?u.push(h):d.push(h)}return{removed:u,notFound:d}};var Br=async e=>{let{workspacePath:r,worktreeDir:t,currentBranches:o}=e,s=hr.dirname(r),n=hr.resolve(`${t}/release`),i=await Ps.readFile(r,"utf-8"),c=JSON.parse(i).folders??[],p=new Set(o.map(R=>hr.resolve(`${t}/${R}`))),u=[];for(let R of c){let S=hr.resolve(s,R.path);(S===n||S.startsWith(`${n}/`))&&!p.has(S)&&u.push(S)}let d=[];u.length>0&&(d=(await z({workspacePath:r,folderPaths:u})).removed);let h=o.map(R=>`${t}/${R}`),{added:f}=h.length>0?await je({workspacePath:r,folderPaths:h}):{added:[]};return{added:f,removed:d}};import xt from"node:path";var W=(e,r)=>xt.isAbsolute(e)?e:xt.resolve(r,e);var As="feature",_s="release",Ns="release/v",Le=["workspace","windows","none"],gr=async e=>{let{confirmedCommand:r,all:t,versions:o,cursor:s,githubDesktop:n,cmux:i}=e;m.start("worktrees-add");try{let l=await _("release"),c=await C(),p=`${c}${M}`;await Ct(`${p}/${_s}`),await Ct(`${p}/${As}`);let u=[];if(o)u=o.split(",").map($=>`release/v${$.trim()}`);else{let $=await k(),D=$.map(F=>F.branch);if(D.length===0)return a.info("\u2139\uFE0F No open release branches found"),m.print(),{content:[{type:"text",text:JSON.stringify({createdWorktrees:[],count:0},null,2)}],structuredContent:{createdWorktrees:[],count:0}};if(t)u=D;else{m.setInteractive();let F=new Map($.map(Me=>[Me.branch,y(Me.title)])),Rr=await b();u=await Ss({required:!0,message:"\u{1F33F} Select release branches",choices:E({branches:D,descriptions:Rr,types:F})})}}t?m.addOption("--all",!0):m.addOption("--versions",u.map($=>$.replace("release/v","")));let d=r?!0:await Kr({message:"Are you sure you want to proceed with these worktree changes?"});r||m.setInteractive(),d||(a.info("Operation cancelled. Exiting..."),Is.exit(0)),r||m.addOption("--yes",!0);let h=s??await Es({message:"Cursor mode for created worktrees?",default:"workspace",choices:[{name:"Add to workspace file",value:"workspace",description:"Append each worktree as a folder in ide.config.workspaceConfigPath, then open the workspace"},{name:"Open separate windows",value:"windows",description:"Open each created worktree in its own Cursor window"},{name:"Skip",value:"none",description:"Do not open Cursor"}]});typeof s>"u"&&m.setInteractive(),m.addOption("--cursor",h);let f=n??await Kr({message:"Open created worktrees in GitHub Desktop?"});typeof n>"u"&&m.setInteractive(),f?m.addOption("--github-desktop",!0):m.addOption("--no-github-desktop",!0);let R=i??await Kr({message:"Open created worktrees in cmux?"});typeof i>"u"&&m.setInteractive(),R?m.addOption("--cmux",!0):m.addOption("--no-cmux",!0);let{branchesToCreate:S}=Os({selectedReleaseBranches:u,currentWorktrees:l}),T=await Ds(S,p);if(Fs(T),h==="workspace"){let $=await w(),D=$.ide?.provider==="cursor"?$.ide.config:void 0;if(!D?.workspaceConfigPath)a.warn("\u26A0\uFE0F Skipping Cursor: ide.config.workspaceConfigPath is not set in infra-kit.yml");else{let F=W(D.workspaceConfigPath,c),Rr=T.map(Et=>`${p}/${Et}`),{added:Me,skipped:zr}=await je({workspacePath:F,folderPaths:Rr}),St=zr.length>0?` (${zr.length} already present)`:"";a.info(`\u2705 Added ${Me.length} folder(s) to ${F}${St}`),await H`cursor ${F}`}}else if(h==="windows")for(let $ of T)await H`cursor ${p}/${$}`;if(f)for(let $ of T)await H`github ${p}/${$}`,await H`sleep 5`;if(R){let $=await N();for(let D of T){let F=L({repoName:$,branch:D});await Fe({cwd:`${p}/${D}`,title:F})}}m.print();let K={createdWorktrees:T,count:T.length};return{content:[{type:"text",text:JSON.stringify(K,null,2)}],structuredContent:K}}catch(l){throw a.error({error:l},"\u274C Error managing worktrees"),l}},Ct=async e=>{await H`mkdir -p ${e}`},Os=e=>{let{selectedReleaseBranches:r,currentWorktrees:t}=e,o=t.filter(n=>n.startsWith(Ns));return{branchesToCreate:r.filter(n=>!o.includes(n))}},Ds=async(e,r)=>{let t=await Promise.allSettled(e.map(async s=>{let n=`${r}/${s}`;return await H`git worktree add ${n} ${s}`,await H({cwd:n})`pnpm install`,s})),o=[];for(let[s,n]of t.entries())if(n.status==="fulfilled")o.push(n.value);else{let i=e[s];a.error({error:n.reason},`\u274C Failed to create worktree for ${i}`)}return o},Fs=e=>{if(e.length>0){a.info("\u2705 Created git worktrees:");for(let r of e)a.info(r);a.info("")}else a.info("\u2139\uFE0F No new git worktrees to create")},js={name:"worktrees-add",description:'Create local git worktrees for release branches under the worktrees directory and run "pnpm install" in each. Mutates the local filesystem. When invoked via MCP, pass either "versions" (comma-separated) or all=true \u2014 the branch picker and "open in Cursor / GitHub Desktop / cmux" follow-up prompts are unreachable without a TTY, and the CLI confirmation is auto-skipped for MCP calls.',inputSchema:{all:B.boolean().optional().describe('Add worktrees for every open release branch. Either "all" or "versions" must be provided for MCP calls (the interactive picker is unavailable without a TTY). Ignored if "versions" is provided.'),versions:B.string().optional().describe('Comma-separated release versions to target (e.g. "1.2.5, 1.2.6"). Either "versions" or all=true must be provided for MCP calls. Overrides "all" when set.'),cursor:B.enum(Le).optional().describe('Cursor open mode for created worktrees. "workspace" (default behavior when set interactively) appends each worktree as a folder to "ide.config.workspaceConfigPath" in infra-kit.yml and opens the workspace. "windows" opens each worktree in its own Cursor window. "none" skips Cursor. Defaults to "none" in MCP mode (the follow-up prompt is not shown).'),githubDesktop:B.boolean().optional().describe("Open each created worktree in GitHub Desktop. Defaults to false in MCP mode (the follow-up prompt is not shown)."),cmux:B.boolean().optional().describe("Open each created worktree in a new cmux workspace with a 3-pane layout (left-top, left-bottom, full-height right), all rooted at the worktree directory. Defaults to false in MCP mode (the follow-up prompt is not shown).")},outputSchema:{createdWorktrees:B.array(B.string()).describe("List of created git worktree branches"),count:B.number().describe("Number of git worktrees created")},handler:gr};import{z as fe}from"zod/v4";var vr=async()=>{let e=await _("release");if(e.length===0)return a.info("\u2139\uFE0F No active worktrees found"),{content:[{type:"text",text:JSON.stringify({worktrees:[],count:0},null,2)}],structuredContent:{worktrees:[],count:0}};let[r,t]=await Promise.all([k(),b()]),o=new Map(r.map(c=>[c.branch,y(c.title)])),s=e.map(c=>{let p=c.replace("release/",""),u=o.get(c)||"regular",d=t.get(p)||null;return{version:p,type:u,description:d}}),n=Math.max(...s.map(c=>c.version.length)),i=s.map(c=>{let p=ie(c.version,c.type,n);return c.description?`${p} ${c.description}`:p});a.info("\u{1F33F} Active worktrees:"),a.info(`
46
66
  ${i.join(`
47
67
  `)}
48
- `);let l={worktrees:o,count:o.length};return{content:[{type:"text",text:JSON.stringify(l,null,2)}],structuredContent:l}},Zo={name:"worktrees-list",description:"List existing release-branch worktrees with version, release type (regular / hotfix), and Jira fix-version description. Read-only.",inputSchema:{},outputSchema:{worktrees:se.array(se.object({version:se.string().describe("Release version"),type:se.enum(["regular","hotfix"]).describe("Release type"),description:se.string().nullable().describe("Jira version description")})).describe("List of all worktrees with details"),count:se.number().describe("Number of worktrees")},handler:cr};import{z as ne}from"zod/v4";import{$ as Qo}from"zx";var lr=async()=>{m.start("worktrees-open");try{let e=await b(),r=`${e}${j}`,t=await _("release"),s=await es({projectRoot:e,worktreeDir:r,currentBranches:t}),o=await rs({worktreeDir:r,currentBranches:t}),n={openedCmux:o.opened,skippedCmux:o.skipped,cursorFoldersAdded:s.added,cursorFoldersRemoved:s.removed};return ts(n,{cursorRan:s.ran,cmuxRan:o.ran}),m.print(),{content:[{type:"text",text:JSON.stringify(n,null,2)}],structuredContent:{...n}}}catch(e){throw a.error({error:e},"\u274C Error opening worktrees"),e}},es=async e=>{let{projectRoot:r,worktreeDir:t,currentBranches:s}=e,o=await w(),n=o.ide?.provider==="cursor"?o.ide.config:void 0;if(!n||n.mode!=="workspace"||!n.workspaceConfigPath)return a.warn('\u26A0\uFE0F Skipping Cursor: ide.provider must be "cursor", mode "workspace", and workspaceConfigPath set.'),{ran:!1,added:0,removed:0};let i=M(n.workspaceConfigPath,r);try{let{added:l,removed:c}=await Er({workspacePath:i,worktreeDir:t,currentBranches:s});return await Qo`cursor ${i}`,{ran:!0,added:l.length,removed:c.length}}catch(l){return a.warn({error:l},`\u26A0\uFE0F Failed to reconcile/open Cursor workspace at ${i}`),{ran:!1,added:0,removed:0}}},rs=async e=>{let{worktreeDir:r,currentBranches:t}=e;if(t.length===0)return{ran:!0,opened:[],skipped:[]};let s=await W(),o=await Ir(),n=[],i=[];for(let l of t){let c=L({repoName:s,branch:l});if(o.has(c)){i.push(c);continue}try{await Ce({cwd:`${r}/${l}`,title:c}),n.push(c)}catch(p){a.warn({error:p,title:c},`\u26A0\uFE0F Failed to open cmux workspace for ${l}`)}}return{ran:!0,opened:n,skipped:i}},ts=(e,r)=>{if(r.cursorRan&&(e.cursorFoldersAdded>0&&a.info(`\u2705 Added ${e.cursorFoldersAdded} folder(s) to Cursor workspace`),e.cursorFoldersRemoved>0&&a.info(`\u{1F9F9} Removed ${e.cursorFoldersRemoved} dangling folder(s) from Cursor workspace`)),e.openedCmux.length>0){a.info("\u2705 Opened cmux workspaces:");for(let t of e.openedCmux)a.info(t)}e.skippedCmux.length>0&&a.info(`\u2139\uFE0F Skipped ${e.skippedCmux.length} cmux workspace(s) already open`),!r.cursorRan&&e.openedCmux.length===0&&e.skippedCmux.length===0&&e.cursorFoldersAdded===0&&e.cursorFoldersRemoved===0&&a.info("\u2139\uFE0F Nothing to open")},os={name:"worktrees-open",description:"Open Cursor against the configured workspace file and ensure a cmux workspace exists for each existing release worktree. Idempotent and additive \u2014 never removes worktrees, never recreates running cmux workspaces. Use after a cold start (Cursor + cmux closed). For stale-worktree cleanup, use worktrees-sync.",inputSchema:{},outputSchema:{openedCmux:ne.array(ne.string()).describe("Titles of cmux workspaces opened during this run"),skippedCmux:ne.array(ne.string()).describe("Titles of cmux workspaces that were already open"),cursorFoldersAdded:ne.number().describe("Number of worktree folders added to the Cursor workspace file"),cursorFoldersRemoved:ne.number().describe("Number of dangling worktree folders removed from the Cursor workspace file")},handler:lr};import ss from"@inquirer/checkbox";import ns from"@inquirer/confirm";import is from"node:process";import{z as $e}from"zod/v4";import{$ as Ar}from"zx";var pr=async e=>{let{confirmedCommand:r,all:t,versions:s}=e;m.start("worktrees-remove");try{let o=await _("release");if(o.length===0)return a.info("\u2139\uFE0F No active worktrees to remove"),m.print(),{content:[{type:"text",text:JSON.stringify({removedWorktrees:[],count:0},null,2)}],structuredContent:{removedWorktrees:[],count:0}};let n=await b(),i=`${n}${j}`,l=[];if(t)l=o;else if(s)l=s.split(",").map(f=>`release/v${f.trim()}`);else{m.setInteractive();let[f,R]=await Promise.all([C(),k()]),I=new Map(R.map(T=>[T.branch,y(T.title)]));l=await ss({required:!0,message:"\u{1F33F} Select release branches",choices:E({branches:o,descriptions:f,types:I})})}let c=l.length===o.length;c?m.addOption("--all",!0):m.addOption("--versions",l.map(f=>f.replace("release/v","")));let p=r?!0:await ns({message:"Are you sure you want to proceed with these worktree changes?"});r||m.setInteractive(),p||(a.info("Operation cancelled. Exiting..."),is.exit(0)),r||m.addOption("--yes",!0);let d=await W(),u=await as({branches:l,worktreeDir:i,repoName:d,allSelected:c});await cs({removedWorktrees:u,worktreeDir:i,projectRoot:n}),ls(u),m.print();let h={removedWorktrees:u,count:u.length};return{content:[{type:"text",text:JSON.stringify(h,null,2)}],structuredContent:h}}catch(o){throw a.error({error:o},"\u274C Error managing worktrees"),o}},as=async e=>{let{branches:r,worktreeDir:t,repoName:s,allSelected:o}=e,n=await Promise.allSettled(r.map(async l=>{let c=`${t}/${l}`,p=L({repoName:s,branch:l});return await Re(p),await Ar`git worktree remove ${c}`,l})),i=[];for(let[l,c]of n.entries())if(c.status==="fulfilled")i.push(c.value);else{let p=r[l];a.error({error:c.reason},`\u274C Failed to remove worktree for ${p}`)}return o&&i.length===r.length&&(await Ar`git worktree prune`,await Ar`rm -rf ${t}`,a.info(`\u{1F5D1}\uFE0F Removed worktree folder: ${t}`),a.info("")),i},cs=async e=>{let{removedWorktrees:r,worktreeDir:t,projectRoot:s}=e;if(r.length===0)return;let o=await w(),n=o.ide?.provider==="cursor"?o.ide.config:void 0;if(!n||n.mode!=="workspace"||!n.workspaceConfigPath)return;let i=M(n.workspaceConfigPath,s),l=r.map(c=>`${t}/${c}`);try{let{removed:c}=await q({workspacePath:i,folderPaths:l});c.length>0&&a.info(`\u2705 Removed ${c.length} folder(s) from ${i}`)}catch(c){a.warn({error:c},`\u26A0\uFE0F Failed to update Cursor workspace at ${i}`)}},ls=e=>{if(e.length>0){a.info("\u274C Removed worktrees:");for(let r of e)a.info(r);a.info("")}else a.info("\u2139\uFE0F No unused worktrees to remove")},ps={name:"worktrees-remove",description:'Remove local git worktrees for release branches. When everything is removed, also runs "git worktree prune" and deletes the worktrees directory. When invoked via MCP, pass either "versions" (comma-separated) or all=true \u2014 the branch picker is unreachable without a TTY, and the CLI confirmation is auto-skipped for MCP calls, so the caller is responsible for gating.',inputSchema:{all:$e.boolean().optional().describe('Remove every existing worktree. Either "all" or "versions" must be provided for MCP calls (the interactive picker is unavailable without a TTY). Ignored if "versions" is provided.'),versions:$e.string().optional().describe('Comma-separated release versions to target (e.g. "1.2.5, 1.2.6"). Either "versions" or all=true must be provided for MCP calls. Overrides "all" when set.')},outputSchema:{removedWorktrees:$e.array($e.string()).describe("List of removed git worktree branches"),count:$e.number().describe("Number of git worktrees removed")},handler:pr};import ms from"@inquirer/confirm";import ds from"node:process";import{z as _r}from"zod/v4";import{$ as us}from"zx";var fs="release/v",mr=async e=>{let{confirmedCommand:r}=e;m.start("worktrees-sync");try{let t=await _("release"),s=await b(),o=`${s}${j}`,n=await He(),i=r?!0:await ms({message:"Are you sure you want to proceed with these worktree changes?"});r||m.setInteractive(),i||(a.info("Operation cancelled. Exiting..."),ds.exit(0)),r||m.addOption("--yes",!0);let{branchesToRemove:l}=hs({releasePRsList:n,currentWorktrees:t}),c=await W(),p=await gs({branches:l,worktreeDir:o,repoName:c});await vs({removedWorktrees:p,worktreeDir:o,projectRoot:s}),ws(p),m.print();let d={removedWorktrees:p,count:p.length};return{content:[{type:"text",text:JSON.stringify(d,null,2)}],structuredContent:d}}catch(t){throw a.error({error:t},"\u274C Error managing worktrees"),t}},hs=e=>{let{releasePRsList:r,currentWorktrees:t}=e;return{branchesToRemove:t.filter(n=>n.startsWith(fs)).filter(n=>!r.includes(n))}},gs=async e=>{let{branches:r,worktreeDir:t,repoName:s}=e,o=[];for(let n of r)try{let i=`${t}/${n}`,l=L({repoName:s,branch:n});await Re(l),await us`git worktree remove ${i}`,o.push(n)}catch(i){a.error({error:i,branch:n},`\u274C Failed to remove worktree for ${n}`)}return o},vs=async e=>{let{removedWorktrees:r,worktreeDir:t,projectRoot:s}=e;if(r.length===0)return;let o=await w(),n=o.ide?.provider==="cursor"?o.ide.config:void 0;if(!n||n.mode!=="workspace"||!n.workspaceConfigPath)return;let i=M(n.workspaceConfigPath,s),l=r.map(c=>`${t}/${c}`);try{let{removed:c}=await q({workspacePath:i,folderPaths:l});c.length>0&&a.info(`\u2705 Removed ${c.length} folder(s) from ${i}`)}catch(c){a.warn({error:c},`\u26A0\uFE0F Failed to update Cursor workspace at ${i}`)}},ws=e=>{if(e.length>0){a.info("\u274C Removed worktrees:");for(let r of e)a.info(r);a.info("")}else a.info("\u2139\uFE0F No unused worktrees to remove")},ys={name:"worktrees-sync",description:"Remove worktrees whose release PR is no longer open (stale cleanup). Only removes \u2014 never creates; use worktrees-add to create worktrees for new releases. The CLI confirmation is auto-skipped for MCP calls, so the caller is responsible for gating.",inputSchema:{},outputSchema:{removedWorktrees:_r.array(_r.string()).describe("List of removed worktree branches"),count:_r.number().describe("Number of worktrees removed during sync")},handler:mr};var v=new Rs,bs=e=>{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 --cursor value "${String(e)}". Expected one of: ${Te.join(", ")}.`)}},ct=async e=>{try{e?await v.parseAsync(e):await v.parseAsync()}catch(r){let t=r instanceof Error?r.message:String(r);a.error(t),Or.exit(1)}};v.command("merge-dev").description("Merge dev branch into every release branch").option("-a, --all","Select all active release branches").option("-y, --yes","Skip confirmation prompt").action(async e=>{await Ye({all:e.all,confirmedCommand:e.yes})});v.command("release-list").description("List all release branches").action(async()=>{await er()});v.command("release-create").description("Create a single release branch").option("-v, --version <version>","Specify the version to create, e.g. 1.2.5").option("-d, --description <description>","Optional description for the Jira version").addOption(new lt("-t, --type <type>","Release type (default: regular)").choices(["regular","hotfix"])).option("-y, --yes","Skip confirmation prompt").option("--no-checkout","Do not checkout the created branch after creation (checkout is default)").action(async e=>{await rr({version:e.version,description:e.description,type:e.type,confirmedCommand:e.yes,checkout:e.checkout})});v.command("release-create-batch").description("Create multiple release branches (batch operation)").option("-v, --versions <versions>","Specify the versions to create by comma, e.g. 1.2.5, 1.2.6").addOption(new lt("-t, --type <type>","Release type (default: regular)").choices(["regular","hotfix"])).option("-y, --yes","Skip confirmation prompt").action(async e=>{await tr({versions:e.versions,type:e.type,confirmedCommand:e.yes})});v.command("release-deploy-all").description("Deploy any release branch to any environment").option("-v, --version <version>","Specify the version to deploy, e.g. 1.2.5").option("-e, --env <env>","Specify the environment to deploy to, e.g. dev").option("--skip-terraform","Skip terraform deployment step").action(async e=>{await Ze({version:e.version,env:e.env,skipTerraform:e.skipTerraform})});v.command("release-deploy-selected").description("Deploy selected services from release branch to any environment").option("-v, --version <version>","Specify the version to deploy, e.g. 1.2.5").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").action(async e=>{await Qe({version:e.version,env:e.env,services:e.services,skipTerraform:e.skipTerraform})});v.command("release-deliver").description("Release a new version to production").option("-v, --version <version>","Specify the version to release, e.g. 1.2.5").option("-y, --yes","Skip confirmation prompt").action(async e=>{await Xe({version:e.version,confirmedCommand:e.yes})});v.command("worktrees-sync").description("Remove release worktrees whose PRs are no longer open").option("-y, --yes","Skip confirmation prompt").action(async e=>{await mr({confirmedCommand:e.yes})});v.command("worktrees-add").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("-c, --cursor [mode]","Cursor mode for created worktrees: workspace (default) | windows | none").option("--no-cursor","Skip Cursor (alias for --cursor none)").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 e=>{await ar({confirmedCommand:e.yes,all:e.all,versions:e.versions,cursor:bs(e.cursor),githubDesktop:e.githubDesktop,cmux:e.cmux})});v.command("worktrees-list").description("List all git worktrees with detailed information").action(async()=>{await cr()});v.command("worktrees-remove").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 e=>{await pr({confirmedCommand:e.yes,all:e.all,versions:e.versions})});v.command("worktrees-open").description("Open Cursor + cmux for existing release worktrees (cold-start restore)").action(async()=>{await lr()});v.command("doctor").description("Check installation and authentication status of gh and doppler CLIs").action(async()=>{await Oe()});v.command("version").description("Print the installed infra-kit CLI version").action(async()=>{await or()});v.command("env-status").description("Show Doppler authentication status and detected project info").action(async()=>{await Be()});v.command("env-list").description("List available Doppler configs for the detected project").action(async()=>{await je()});v.command("init").description("Inject shell integration into your profile .zshrc").action(async()=>{await ur()});v.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 e=>{await Ve({config:e.config})});v.command("env-clear").description("Clear loaded env vars. Source the returned file path to apply.").action(async()=>{await Me()});if(Or.argv.length<=2){let e=["merge-dev","release-list","release-create","release-create-batch","release-deploy-all","release-deploy-selected","release-deliver"],r=["worktrees-add","worktrees-list","worktrees-open","worktrees-remove","worktrees-sync"],t=["doctor","init","version","env-status","env-list","env-load","env-clear"],s=new Map(v.commands.map(c=>[c.name(),c])),o=[...e,...r,...t],n=Math.max(...o.map(c=>c.length)),i=c=>c.filter(p=>s.has(p)).map(p=>({name:`${p.padEnd(n)} ${s.get(p).description()}`,value:p})),l=await ks({message:"Select a command to run",choices:[new ie(" "),new ie("\u2014 Release Management \u2014"),...i(e),new ie(" "),new ie("\u2014 Worktrees \u2014"),...i(r),new ie(" "),new ie("\u2014 Environment \u2014"),...i(t)]},{output:Or.stderr});await ct(["node","infra-kit",l])}else await ct();
68
+ `);let l={worktrees:s,count:s.length};return{content:[{type:"text",text:JSON.stringify(l,null,2)}],structuredContent:l}},Ls={name:"worktrees-list",description:"List existing release-branch worktrees with version, release type (regular / hotfix), and Jira fix-version description. Read-only.",inputSchema:{},outputSchema:{worktrees:fe.array(fe.object({version:fe.string().describe("Release version"),type:fe.enum(["regular","hotfix"]).describe("Release type"),description:fe.string().nullable().describe("Jira version description")})).describe("List of all worktrees with details"),count:fe.number().describe("Number of worktrees")},handler:vr};import{z as he}from"zod/v4";import{$ as Ws}from"zx";var wr=async()=>{m.start("worktrees-open");try{let e=await C(),r=`${e}${M}`,t=await _("release"),o=await Ms({projectRoot:e,worktreeDir:r,currentBranches:t}),s=await Vs({worktreeDir:r,currentBranches:t}),n={openedCmux:s.opened,skippedCmux:s.skipped,cursorFoldersAdded:o.added,cursorFoldersRemoved:o.removed};return Js(n,{cursorRan:o.ran,cmuxRan:s.ran}),m.print(),{content:[{type:"text",text:JSON.stringify(n,null,2)}],structuredContent:{...n}}}catch(e){throw a.error({error:e},"\u274C Error opening worktrees"),e}},Ms=async e=>{let{projectRoot:r,worktreeDir:t,currentBranches:o}=e,s=await w(),n=s.ide?.provider==="cursor"?s.ide.config:void 0;if(!n||n.mode!=="workspace"||!n.workspaceConfigPath)return a.warn('\u26A0\uFE0F Skipping Cursor: ide.provider must be "cursor", mode "workspace", and workspaceConfigPath set.'),{ran:!1,added:0,removed:0};let i=W(n.workspaceConfigPath,r);try{let{added:l,removed:c}=await Br({workspacePath:i,worktreeDir:t,currentBranches:o});return await Ws`cursor ${i}`,{ran:!0,added:l.length,removed:c.length}}catch(l){return a.warn({error:l},`\u26A0\uFE0F Failed to reconcile/open Cursor workspace at ${i}`),{ran:!1,added:0,removed:0}}},Vs=async e=>{let{worktreeDir:r,currentBranches:t}=e;if(t.length===0)return{ran:!0,opened:[],skipped:[]};let o=await N(),s=await Jr(),n=[],i=[];for(let l of t){let c=L({repoName:o,branch:l});if(s.has(c)){i.push(c);continue}try{await Fe({cwd:`${r}/${l}`,title:c}),n.push(c)}catch(p){a.warn({error:p,title:c},`\u26A0\uFE0F Failed to open cmux workspace for ${l}`)}}return{ran:!0,opened:n,skipped:i}},Js=(e,r)=>{if(r.cursorRan&&(e.cursorFoldersAdded>0&&a.info(`\u2705 Added ${e.cursorFoldersAdded} folder(s) to Cursor workspace`),e.cursorFoldersRemoved>0&&a.info(`\u{1F9F9} Removed ${e.cursorFoldersRemoved} dangling folder(s) from Cursor workspace`)),e.openedCmux.length>0){a.info("\u2705 Opened cmux workspaces:");for(let t of e.openedCmux)a.info(t)}e.skippedCmux.length>0&&a.info(`\u2139\uFE0F Skipped ${e.skippedCmux.length} cmux workspace(s) already open`),!r.cursorRan&&e.openedCmux.length===0&&e.skippedCmux.length===0&&e.cursorFoldersAdded===0&&e.cursorFoldersRemoved===0&&a.info("\u2139\uFE0F Nothing to open")},Bs={name:"worktrees-open",description:"Open Cursor against the configured workspace file and ensure a cmux workspace exists for each existing release worktree. Idempotent and additive \u2014 never removes worktrees, never recreates running cmux workspaces. Use after a cold start (Cursor + cmux closed). For stale-worktree cleanup, use worktrees-sync.",inputSchema:{},outputSchema:{openedCmux:he.array(he.string()).describe("Titles of cmux workspaces opened during this run"),skippedCmux:he.array(he.string()).describe("Titles of cmux workspaces that were already open"),cursorFoldersAdded:he.number().describe("Number of worktree folders added to the Cursor workspace file"),cursorFoldersRemoved:he.number().describe("Number of dangling worktree folders removed from the Cursor workspace file")},handler:wr};import Ks from"@inquirer/checkbox";import qs from"@inquirer/confirm";import Us from"node:process";import{z as We}from"zod/v4";import{$ as qr}from"zx";var yr=async e=>{let{confirmedCommand:r,all:t,versions:o}=e;m.start("worktrees-remove");try{let s=await _("release");if(s.length===0)return a.info("\u2139\uFE0F No active worktrees to remove"),m.print(),{content:[{type:"text",text:JSON.stringify({removedWorktrees:[],count:0},null,2)}],structuredContent:{removedWorktrees:[],count:0}};let n=await C(),i=`${n}${M}`,l=[];if(t)l=s;else if(o)l=o.split(",").map(f=>`release/v${f.trim()}`);else{m.setInteractive();let[f,R]=await Promise.all([b(),k()]),S=new Map(R.map(T=>[T.branch,y(T.title)]));l=await Ks({required:!0,message:"\u{1F33F} Select release branches",choices:E({branches:s,descriptions:f,types:S})})}let c=l.length===s.length;c?m.addOption("--all",!0):m.addOption("--versions",l.map(f=>f.replace("release/v","")));let p=r?!0:await qs({message:"Are you sure you want to proceed with these worktree changes?"});r||m.setInteractive(),p||(a.info("Operation cancelled. Exiting..."),Us.exit(0)),r||m.addOption("--yes",!0);let u=await N(),d=await Gs({branches:l,worktreeDir:i,repoName:u,allSelected:c});await zs({removedWorktrees:d,worktreeDir:i,projectRoot:n}),Hs(d),m.print();let h={removedWorktrees:d,count:d.length};return{content:[{type:"text",text:JSON.stringify(h,null,2)}],structuredContent:h}}catch(s){throw a.error({error:s},"\u274C Error managing worktrees"),s}},Gs=async e=>{let{branches:r,worktreeDir:t,repoName:o,allSelected:s}=e,n=await Promise.allSettled(r.map(async l=>{let c=`${t}/${l}`,p=L({repoName:o,branch:l});return await Oe(p),await qr`git worktree remove ${c}`,l})),i=[];for(let[l,c]of n.entries())if(c.status==="fulfilled")i.push(c.value);else{let p=r[l];a.error({error:c.reason},`\u274C Failed to remove worktree for ${p}`)}return s&&i.length===r.length&&(await qr`git worktree prune`,await qr`rm -rf ${t}`,a.info(`\u{1F5D1}\uFE0F Removed worktree folder: ${t}`),a.info("")),i},zs=async e=>{let{removedWorktrees:r,worktreeDir:t,projectRoot:o}=e;if(r.length===0)return;let s=await w(),n=s.ide?.provider==="cursor"?s.ide.config:void 0;if(!n||n.mode!=="workspace"||!n.workspaceConfigPath)return;let i=W(n.workspaceConfigPath,o),l=r.map(c=>`${t}/${c}`);try{let{removed:c}=await z({workspacePath:i,folderPaths:l});c.length>0&&a.info(`\u2705 Removed ${c.length} folder(s) from ${i}`)}catch(c){a.warn({error:c},`\u26A0\uFE0F Failed to update Cursor workspace at ${i}`)}},Hs=e=>{if(e.length>0){a.info("\u274C Removed worktrees:");for(let r of e)a.info(r);a.info("")}else a.info("\u2139\uFE0F No unused worktrees to remove")},Ys={name:"worktrees-remove",description:'Remove local git worktrees for release branches. When everything is removed, also runs "git worktree prune" and deletes the worktrees directory. When invoked via MCP, pass either "versions" (comma-separated) or all=true \u2014 the branch picker is unreachable without a TTY, and the CLI confirmation is auto-skipped for MCP calls, so the caller is responsible for gating.',inputSchema:{all:We.boolean().optional().describe('Remove every existing worktree. Either "all" or "versions" must be provided for MCP calls (the interactive picker is unavailable without a TTY). Ignored if "versions" is provided.'),versions:We.string().optional().describe('Comma-separated release versions to target (e.g. "1.2.5, 1.2.6"). Either "versions" or all=true must be provided for MCP calls. Overrides "all" when set.')},outputSchema:{removedWorktrees:We.array(We.string()).describe("List of removed git worktree branches"),count:We.number().describe("Number of git worktrees removed")},handler:yr};import Xs from"@inquirer/confirm";import Zs from"node:process";import{z as Ur}from"zod/v4";import{$ as Qs}from"zx";var en="release/v",kr=async e=>{let{confirmedCommand:r}=e;m.start("worktrees-sync");try{let t=await _("release"),o=await C(),s=`${o}${M}`,n=await nr(),i=r?!0:await Xs({message:"Are you sure you want to proceed with these worktree changes?"});r||m.setInteractive(),i||(a.info("Operation cancelled. Exiting..."),Zs.exit(0)),r||m.addOption("--yes",!0);let{branchesToRemove:l}=rn({releasePRsList:n,currentWorktrees:t}),c=await N(),p=await tn({branches:l,worktreeDir:s,repoName:c});await on({removedWorktrees:p,worktreeDir:s,projectRoot:o}),sn(p),m.print();let u={removedWorktrees:p,count:p.length};return{content:[{type:"text",text:JSON.stringify(u,null,2)}],structuredContent:u}}catch(t){throw a.error({error:t},"\u274C Error managing worktrees"),t}},rn=e=>{let{releasePRsList:r,currentWorktrees:t}=e;return{branchesToRemove:t.filter(n=>n.startsWith(en)).filter(n=>!r.includes(n))}},tn=async e=>{let{branches:r,worktreeDir:t,repoName:o}=e,s=[];for(let n of r)try{let i=`${t}/${n}`,l=L({repoName:o,branch:n});await Oe(l),await Qs`git worktree remove ${i}`,s.push(n)}catch(i){a.error({error:i,branch:n},`\u274C Failed to remove worktree for ${n}`)}return s},on=async e=>{let{removedWorktrees:r,worktreeDir:t,projectRoot:o}=e;if(r.length===0)return;let s=await w(),n=s.ide?.provider==="cursor"?s.ide.config:void 0;if(!n||n.mode!=="workspace"||!n.workspaceConfigPath)return;let i=W(n.workspaceConfigPath,o),l=r.map(c=>`${t}/${c}`);try{let{removed:c}=await z({workspacePath:i,folderPaths:l});c.length>0&&a.info(`\u2705 Removed ${c.length} folder(s) from ${i}`)}catch(c){a.warn({error:c},`\u26A0\uFE0F Failed to update Cursor workspace at ${i}`)}},sn=e=>{if(e.length>0){a.info("\u274C Removed worktrees:");for(let r of e)a.info(r);a.info("")}else a.info("\u2139\uFE0F No unused worktrees to remove")},nn={name:"worktrees-sync",description:"Remove worktrees whose release PR is no longer open (stale cleanup). Only removes \u2014 never creates; use worktrees-add to create worktrees for new releases. The CLI confirmation is auto-skipped for MCP calls, so the caller is responsible for gating.",inputSchema:{},outputSchema:{removedWorktrees:Ur.array(Ur.string()).describe("List of removed worktree branches"),count:Ur.number().describe("Number of worktrees removed during sync")},handler:kr};var g=new cn,ln=e=>{if(!(typeof e>"u")){if(e===!0)return"workspace";if(e===!1)return"none";if(typeof e=="string"&&Le.includes(e))return e;throw new Error(`Invalid --cursor value "${String(e)}". Expected one of: ${Le.join(", ")}.`)}},Tt=async e=>{try{e?await g.parseAsync(e):await g.parseAsync()}catch(r){let t=r instanceof Error?r.message:String(r);a.error(t),Gr.exit(1)}};g.command("merge-dev").description("Merge dev branch into every release branch").option("-a, --all","Select all active release branches").option("-y, --yes","Skip confirmation prompt").action(async e=>{await ir({all:e.all,confirmedCommand:e.yes})});g.command("release-list").description("List all release branches").action(async()=>{await pr()});g.command("release-create").description("Create a single release branch").option("-v, --version <version>",'Version to create, e.g. "1.2.5", "next", or "next,next,1.2.7" (multi-value routes to batch)').option("-d, --description <description>","Optional description for the Jira version").addOption(new $t("-t, --type <type>","Release type (default: regular)").choices(["regular","hotfix"])).option("-y, --yes","Skip confirmation prompt").action(async e=>{await mr({version:e.version,description:e.description,type:e.type,confirmedCommand:e.yes})});g.command("release-create-batch").description("Create multiple release branches (batch operation)").option("-v, --versions <versions>",'Comma-separated versions, e.g. "1.2.5, 1.2.6", "next,next", or "next,next,1.2.7"').addOption(new $t("-t, --type <type>","Release type (default: regular)").choices(["regular","hotfix"])).option("-y, --yes","Skip confirmation prompt").action(async e=>{await de({versions:e.versions,type:e.type,confirmedCommand:e.yes})});g.command("release-deploy-all").description("Deploy any release branch to any environment").option("-v, --version <version>","Specify the version to deploy, e.g. 1.2.5").option("-e, --env <env>","Specify the environment to deploy to, e.g. dev").option("--skip-terraform","Skip terraform deployment step").action(async e=>{await cr({version:e.version,env:e.env,skipTerraform:e.skipTerraform})});g.command("release-deploy-selected").description("Deploy selected services from release branch to any environment").option("-v, --version <version>","Specify the version to deploy, e.g. 1.2.5").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").action(async e=>{await lr({version:e.version,env:e.env,services:e.services,skipTerraform:e.skipTerraform})});g.command("release-deliver").description("Release a new version to production").option("-v, --version <version>","Specify the version to release, e.g. 1.2.5").option("-y, --yes","Skip confirmation prompt").action(async e=>{await ar({version:e.version,confirmedCommand:e.yes})});g.command("worktrees-sync").description("Remove release worktrees whose PRs are no longer open").option("-y, --yes","Skip confirmation prompt").action(async e=>{await kr({confirmedCommand:e.yes})});g.command("worktrees-add").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("-c, --cursor [mode]","Cursor mode for created worktrees: workspace (default) | windows | none").option("--no-cursor","Skip Cursor (alias for --cursor none)").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 e=>{await gr({confirmedCommand:e.yes,all:e.all,versions:e.versions,cursor:ln(e.cursor),githubDesktop:e.githubDesktop,cmux:e.cmux})});g.command("worktrees-list").description("List all git worktrees with detailed information").action(async()=>{await vr()});g.command("worktrees-remove").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 e=>{await yr({confirmedCommand:e.yes,all:e.all,versions:e.versions})});g.command("worktrees-open").description("Open Cursor + cmux for existing release worktrees (cold-start restore)").action(async()=>{await wr()});var Pt=g.command("config").description("Manage infra-kit configuration files");Pt.command("path").description("Show the resolved config merge chain and file paths").action(async()=>{await Cr()});Pt.command("edit").description("Open the user-scope per-project override file in $EDITOR").action(async()=>{await Tr()});g.command("doctor").description("Check installation and authentication status of gh and doppler CLIs").action(async()=>{await Be()});g.command("version").description("Print the installed infra-kit CLI version").action(async()=>{await ur()});g.command("env-status").description("Show Doppler authentication status and detected project info").action(async()=>{await Qe()});g.command("env-list").description("List available Doppler configs for the detected project").action(async()=>{await Ye()});g.command("init").description("Inject shell integration into your profile .zshrc").action(async()=>{await Pr()});g.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 e=>{await Ze({config:e.config})});g.command("env-clear").description("Clear loaded env vars. Source the returned file path to apply.").action(async()=>{await He()});if(Gr.argv.length<=2){let e=["merge-dev","release-list","release-create","release-create-batch","release-deploy-all","release-deploy-selected","release-deliver"],r=["worktrees-add","worktrees-list","worktrees-open","worktrees-remove","worktrees-sync"],t=["doctor","init","version","config","env-status","env-list","env-load","env-clear"],o=new Map(g.commands.map(c=>[c.name(),c])),s=[...e,...r,...t],n=Math.max(...s.map(c=>c.length)),i=c=>c.filter(p=>o.has(p)).map(p=>({name:`${p.padEnd(n)} ${o.get(p).description()}`,value:p})),l=await an({message:"Select a command to run",choices:[new ge(" "),new ge("\u2014 Release Management \u2014"),...i(e),new ge(" "),new ge("\u2014 Worktrees \u2014"),...i(r),new ge(" "),new ge("\u2014 Environment \u2014"),...i(t)]},{output:Gr.stderr});await Tt(["node","infra-kit",l])}else await Tt();
49
69
  //# sourceMappingURL=cli.js.map