infra-kit 0.1.89 → 0.1.90

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,41 +1,42 @@
1
- import Zt,{Separator as Z}from"@inquirer/select";import{Command as Qt,Option as br}from"commander";import Rr from"node:process";import{z as J}from"zod";import{$ as $r}from"zx";import xr from"node:process";import Tr from"pino";import Cr from"pino-pretty";var Ir=()=>{let e=xr.argv.includes("--debug")?"debug":"info",r=["time","pid","hostname"];return e==="debug"&&r.push("level"),Tr({level:e},Cr({destination:2,ignore:r.join(","),colorize:!0}))},n=Ir();var Q=async(e,r,t,s)=>{try{return await $r`${r}`,{name:e,status:"pass",message:t}}catch{return{name:e,status:"fail",message:s}}},me=async()=>{let e=await Promise.all([Q("gh installed",["gh","--version"],"GitHub CLI is installed","GitHub CLI is not installed. Install from: https://cli.github.com/"),Q("gh authenticated",["gh","auth","status"],"GitHub CLI is authenticated","GitHub CLI is not authenticated. Run: gh auth login"),Q("doppler installed",["doppler","--version"],"Doppler CLI is installed","Doppler CLI is not installed. Install from: https://docs.doppler.com/docs/install-cli"),Q("doppler authenticated",["doppler","me"],"Doppler CLI is authenticated","Doppler CLI is not authenticated. Run: doppler login"),Q("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")]);n.info(`Doctor check results:
2
- `);for(let t of e){let s=t.status==="pass"?"[PASS]":"[FAIL]";n.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}},_r={name:"doctor",description:"Check installation and authentication status of gh, doppler, and aws CLIs",inputSchema:{},outputSchema:{checks:J.array(J.object({name:J.string().describe("Name of the check"),status:J.enum(["pass","fail"]).describe("Check result"),message:J.string().describe("Details about the check result")})).describe("List of all check results"),allPassed:J.boolean().describe("Whether all checks passed")},handler:me};import ue from"node:fs";import tr from"node:path";import Pr from"node:process";import{z as fe}from"zod";import er from"node:fs";import Ar from"node:path";import Sr from"node:process";var Er="./node_modules/.cache/infra-kit",j="env-load.sh",rr="env-clear.sh",Je="INFRA_KIT_SESSION",F="INFRA_KIT_ENV_CONFIG",V="INFRA_KIT_ENV_PROJECT",W="INFRA_KIT_ENV_LOADED_AT",de=e=>er.existsSync(e)?er.readFileSync(e,"utf-8").split(`
3
- `).filter(t=>t.includes("=")&&!t.startsWith("set ")).map(t=>t.split("=")[0]):[],B=()=>{let e=Sr.env[Je];if(!e)throw new Error("INFRA_KIT_SESSION is not set. Run `source ~/.zshrc` or `infra-kit init` first.");return Ar.join(Er,e)},K="-worktrees";var he=async()=>{let e=B(),r=tr.join(e,j);if(!ue.existsSync(r))return n.error("No loaded environment found. Run `env-load` first."),{content:[{type:"text",text:"No loaded environment found. Run `env-load` first."}]};let t=de(r),s=[...t.map(i=>`unset ${i}`),`unset ${F}`,`unset ${V}`,`unset ${W}`],o=tr.resolve(e,rr);ue.mkdirSync(e,{recursive:!0}),ue.writeFileSync(o,`${s.join(`
1
+ import vo,{Separator as ee}from"@inquirer/select";import{Command as yo,Option as Pr}from"commander";import pr from"node:process";import{z as j}from"zod";import{$ as Jr}from"zx";import Or from"node:process";import Lr from"pino";import Dr from"pino-pretty";var Mr=()=>{let e=Or.argv.includes("--debug")?"debug":"info",r=["time","pid","hostname"];return e==="debug"&&r.push("level"),Lr({level:e},Dr({destination:2,ignore:r.join(","),colorize:!0}))},n=Mr();var te=async(e,r,t,s)=>{try{return await Jr`${r}`,{name:e,status:"pass",message:t}}catch{return{name:e,status:"fail",message:s}}},ve=async()=>{let e=await Promise.all([te("gh installed",["gh","--version"],"GitHub CLI is installed","GitHub CLI is not installed. Install from: https://cli.github.com/"),te("gh authenticated",["gh","auth","status"],"GitHub CLI is authenticated","GitHub CLI is not authenticated. Run: gh auth login"),te("doppler installed",["doppler","--version"],"Doppler CLI is installed","Doppler CLI is not installed. Install from: https://docs.doppler.com/docs/install-cli"),te("doppler authenticated",["doppler","me"],"Doppler CLI is authenticated","Doppler CLI is not authenticated. Run: doppler login"),te("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")]);n.info(`Doctor check results:
2
+ `);for(let t of e){let s=t.status==="pass"?"[PASS]":"[FAIL]";n.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}},jr={name:"doctor",description:"Check installation and authentication status of gh, doppler, and aws CLIs",inputSchema:{},outputSchema:{checks:j.array(j.object({name:j.string().describe("Name of the check"),status:j.enum(["pass","fail"]).describe("Check result"),message:j.string().describe("Details about the check result")})).describe("List of all check results"),allPassed:j.boolean().describe("Whether all checks passed")},handler:ve};import He from"node:fs";import dr from"node:path";import Wr from"node:process";import{z as ke}from"zod";import oe from"node:fs";import Fr from"node:os";import Ue from"node:path";import ze from"node:process";var F="env-load.sh",ur="env-clear.sh",ye="INFRA_KIT_SESSION",V="INFRA_KIT_ENV_CONFIG",W="INFRA_KIT_ENV_PROJECT",B="INFRA_KIT_ENV_LOADED_AT",we=/^([A-Z_]\w*)=/i,Re=e=>{if(!oe.existsSync(e))return[];let r=oe.readFileSync(e,"utf-8"),t=[];for(let s of r.split(`
3
+ `)){let o=we.exec(s);o&&t.push(o[1])}return t},Vr=()=>{let e=ze.env.XDG_CACHE_HOME,r=e&&e.length>0?e:Ue.join(Fr.homedir(),".cache");return Ue.join(r,"infra-kit")},K=()=>{let e=ze.env[ye];if(!e)throw new Error(`${ye} is not set. Run \`infra-kit init\` then \`source ~/.zshrc\`.`);return Ue.join(Vr(),e)},be=(e,r,t)=>{let s=`${e}.tmp.${ze.pid}`;oe.writeFileSync(s,r,{mode:t});try{oe.renameSync(s,e)}catch(o){throw oe.rmSync(s,{force:!0}),o}},q="-worktrees";var xe=async()=>{let e=K(),r=dr.join(e,F);if(!He.existsSync(r))throw new Error("No loaded environment found. Run `env-load` first.");let t=Re(r),s=[...t.map(a=>`unset ${a}`),`unset ${V}`,`unset ${W}`,`unset ${B}`],o=dr.resolve(e,ur);He.mkdirSync(e,{recursive:!0,mode:448}),be(o,`${s.join(`
4
4
  `)}
5
- `),Pr.stdout.write(`${o}
6
- `),ue.unlinkSync(r);let a={filePath:o,variableCount:t.length,unsetStatements:s};return{content:[{type:"text",text:JSON.stringify(a,null,2)}],structuredContent:a}},Nr={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:fe.string().describe("Path to the file that must be sourced to apply"),variableCount:fe.number().describe("Number of variables cleared"),unsetStatements:fe.array(fe.string()).describe("Unset statements generated")},handler:he};import{z as Fe}from"zod";import or from"node:process";import{$ as sr}from"zx";var D=async()=>{try{await sr`doppler --version`}catch(e){n.error({error:e},"Error: Doppler CLI is not installed."),n.error("Please install it from: https://docs.doppler.com/docs/install-cli"),or.exit(1)}try{await sr`doppler me`}catch(e){n.error({error:e},"Error: Doppler CLI is not authenticated."),n.error("Please authenticate by running: doppler login"),or.exit(1)}};import Lr from"node:fs/promises";import Mr from"node:path";import Jr from"yaml";import{z as L}from"zod";import{$ as nr}from"zx";var P=async e=>{let t=(await nr`git worktree list`).stdout.split(`
7
- `).filter(Boolean),s={release:Or,feature:Dr};return t.map(s[e]).filter(o=>o!==null)},Or=e=>{let r=e.split(" ").filter(Boolean);return r.length<3||!r[0]?.includes("release/v")?null:`release/${r[0]?.split("/").pop()||""}`},Dr=e=>{let r=e.split(" ").filter(Boolean);return r.length<3||!r[0]?.includes("feature/")?null:`feature/${r[0]?.split("/").pop()||""}`},$=async()=>(await nr`git rev-parse --show-toplevel`).stdout.trim();var jr="infra-kit.yml",Fr=L.object({dopplerProjectName:L.string().min(1),environments:L.array(L.string().min(1)).min(1),taskManagerProvider:L.union([L.string(),L.literal(!1)])}),je=null,S=async()=>(je||(je=Vr()),je),Vr=async()=>{let e=await $(),r=Mr.join(e,jr),t;try{t=await Lr.readFile(r,"utf-8")}catch{throw new Error(`infra-kit.yml not found at ${r}`)}let s=Jr.parse(t),o=Fr.safeParse(s);if(!o.success)throw new Error(`Invalid infra-kit.yml at ${r}: ${o.error.message}`);return o.data};var ee=async()=>{let{dopplerProjectName:e}=await S();return e};var ge=async()=>{await D();let e=await ee(),{environments:r}=await S();n.info(`Doppler project: ${e}
8
- `),n.info("Available configs:");for(let s of r)n.info(` - ${s}`);let t={project:e,configs:r};return{content:[{type:"text",text:JSON.stringify(t,null,2)}],structuredContent:t}},Wr={name:"env-list",description:"List the environments the project is configured to support. Returns a static list defined in infra-kit constants (not a live fetch from Doppler) plus the Doppler project name auto-detected from the current directory. Read-only.",inputSchema:{},outputSchema:{project:Fe.string().describe("Detected Doppler project name"),configs:Fe.array(Fe.string()).describe("Available environment configs")},handler:ge};import Kr from"@inquirer/select";import ir from"node:fs";import qr from"node:path";import ar from"node:process";import{z as re}from"zod";import{$ as Ve}from"zx";var Br=()=>{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(" ");n.info(`\u{1F4DF} Equivalent command:
5
+ `,384),Wr.stdout.write(`${o}
6
+ `),He.unlinkSync(r);let i={filePath:o,variableCount:t.length,unsetStatements:s};return{content:[{type:"text",text:JSON.stringify(i,null,2)}],structuredContent:i}},Br={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:ke.string().describe("Path to the file that must be sourced to apply"),variableCount:ke.number().describe("Number of variables cleared"),unsetStatements:ke.array(ke.string()).describe("Unset statements generated")},handler:xe};import{z as Xe}from"zod";import hr from"node:fs/promises";import Ur from"node:path";import zr from"yaml";import{z as M}from"zod";import Kr from"node:path";import{$ as fr}from"zx";var N=async e=>{let t=(await fr`git worktree list`).stdout.split(`
7
+ `).filter(Boolean),s={release:qr,feature:Gr};return t.map(s[e]).filter(o=>o!==null)},qr=e=>{let r=e.split(" ").filter(Boolean);return r.length<3||!r[0]?.includes("release/v")?null:`release/${r[0]?.split("/").pop()||""}`},Gr=e=>{let r=e.split(" ").filter(Boolean);return r.length<3||!r[0]?.includes("feature/")?null:`feature/${r[0]?.split("/").pop()||""}`},T=async()=>(await fr`git rev-parse --show-toplevel`).stdout.trim(),Ye=async()=>{let e=await T();return Kr.basename(e)};var Hr="infra-kit.yml",Yr=M.object({dopplerProjectName:M.string().min(1),environments:M.array(M.string().min(1)).min(1),taskManagerProvider:M.union([M.string(),M.literal(!1)])}),se=null,A=async()=>{let e=await T(),r=Ur.join(e,Hr),t;try{t=await hr.stat(r)}catch{throw se=null,new Error(`infra-kit.yml not found at ${r}`)}if(se&&se.mtimeMs===t.mtimeMs)return se.value;let s=await hr.readFile(r,"utf-8"),o=zr.parse(s),i=Yr.safeParse(o);if(!i.success)throw new Error(`Invalid infra-kit.yml at ${r}: ${i.error.message}`);return se={mtimeMs:t.mtimeMs,value:i.data},i.data};var ne=async()=>{let{dopplerProjectName:e}=await A();return e};var Te=async()=>{let e=await ne(),{environments:r}=await A();n.info(`Doppler project: ${e}
8
+ `),n.info("Available configs:");for(let s of r)n.info(` - ${s}`);let t={project:e,configs:r};return{content:[{type:"text",text:JSON.stringify(t,null,2)}],structuredContent:t}},Xr={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:Xe.string().describe("Detected Doppler project name"),configs:Xe.array(Xe.string()).describe("Available environment configs")},handler:Te};import Qr from"@inquirer/select";import{Buffer as et}from"node:buffer";import rt from"node:fs";import tt from"node:path";import vr from"node:process";import{z as ae}from"zod";import{$ as Ce}from"zx";import{$ as gr}from"zx";var ie=async()=>{try{await gr`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 gr`doppler me`}catch(e){throw new Error("Doppler CLI is not authenticated. Run: doppler login",{cause:e})}};var Zr=()=>{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(" ");n.info(`\u{1F4DF} Equivalent command:
9
9
  pnpm exec infra-kit ${e} ${s}
10
- `)},reset(){e="",r=[],t=!1}}},l=Br();var ve=async e=>{await D();let{config:r}=e;l.start("env-load");let t="";if(r)t=r;else{let{environments:h}=await S();l.setInteractive(),t=await Kr({message:"Select environment config",choices:h.map(f=>({name:f,value:f}))},{output:ar.stderr})}l.addOption("--config",t);let s=await ee();Ve.quiet=!0;let o=await Ve`doppler secrets download --no-file --format env --project ${s} --config ${t}`;Ve.quiet=!1;let a=o.stdout.trim(),i=new Date().toISOString(),p=["set -a",a,`${F}=${t}`,`${V}=${s}`,`${W}=${i}`,"set +a"],c=B(),m=qr.resolve(c,j);ir.mkdirSync(c,{recursive:!0}),ir.writeFileSync(m,`${p.join(`
10
+ `)},reset(){e="",r=[],t=!1}}},l=Zr();var Ie=async e=>{await ie();let{config:r}=e;l.start("env-load");let t="";if(r)t=r;else{let{environments:d}=await A();l.setInteractive(),t=await Qr({message:"Select environment config",choices:d.map(h=>({name:h,value:h}))},{output:vr.stderr})}l.addOption("--config",t);let s=await ne(),o=await st(s,t);ct(o);let i=new Date().toISOString(),a=["set -a",o,`${V}=${Ze(t)}`,`${W}=${Ze(s)}`,`${B}=${Ze(i)}`,"set +a"],p=K(),c=tt.resolve(p,F);rt.mkdirSync(p,{recursive:!0,mode:448}),be(c,`${a.join(`
11
11
  `)}
12
- `),ar.stdout.write(`${m}
13
- `);let d=a.split(`
14
- `).filter(h=>h.includes("=")).length,u={filePath:m,variableCount:d,project:s,config:t};return{content:[{type:"text",text:JSON.stringify(u,null,2)}],structuredContent:u}},Gr={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:re.string().describe('Doppler config / environment name to load (e.g. "dev", "arthur", "renana"). Required for MCP calls.')},outputSchema:{filePath:re.string().describe("Path to the file that must be sourced to apply variables"),variableCount:re.number().describe("Number of variables loaded"),project:re.string().describe("Doppler project name"),config:re.string().describe("Doppler config name")},handler:ve};import zr from"node:path";import te from"node:process";import{z as q}from"zod";var ye=async()=>{await D(),n.info("Environment session status:");let e=B(),r=te.env[Je],t=zr.join(e,j),s=0,o=0,a=te.env[F]??null,i=te.env[V]??null,p=te.env[W]??null;if(a){let m=de(t);m.length>0&&(o=m.length,s=m.filter(u=>u in te.env).length);let d=p?.replace(/\.\d{3}Z$/,"")??null;n.info(` ${a}: ${s} of ${o} vars loaded (project: ${i}, loadedAt: ${d}, session: ${r})
15
- `)}else n.info(` Session ${r}: no env loaded
16
- `);let c={sessionId:r,sessionLoadedCount:s,sessionTotalCount:o,sessionConfig:a,sessionProject:i,sessionLoadedAt:p};return{content:[{type:"text",text:JSON.stringify(c,null,2)}],structuredContent:c}},Ur={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:ye};import Zr from"@inquirer/checkbox";import Qr from"@inquirer/confirm";import et from"node:process";import{z as U}from"zod";import{$ as _}from"zx";import{$ as Cs}from"zx";import xe from"node:process";import{$ as C}from"zx";import{$ as ne}from"zx";import oe from"node:process";var We=async(e,r)=>{try{let{baseUrl:t,token:s,email:o,projectId:a}=r,i={name:e.name,projectId:e.projectId||a,description:e.description||"",released:e.released||!1,archived:e.archived||!1},p=`${t}/rest/api/3/version`,c=btoa(`${o}:${s}`),m=await fetch(p,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json",Authorization:`Basic ${c}`},body:JSON.stringify(i)});if(!m.ok){let u=await m.text();throw n.error({status:m.status,statusText:m.statusText,error:u},"Failed to create Jira version"),new Error(`HTTP ${m.status}: ${m.statusText}`)}return{success:!0,version:await m.json()}}catch(t){throw n.error({error:t},"Error creating Jira version"),t}},we=async e=>{try{let{baseUrl:r,token:t,email:s,projectId:o}=e,a=`${r}/rest/api/3/project/${o}/versions`,i=btoa(`${s}:${t}`),p=await fetch(a,{method:"GET",headers:{Accept:"application/json",Authorization:`Basic ${i}`}});if(!p.ok){let m=await p.text();throw n.error({status:p.status,statusText:p.statusText,error:m},"Failed to get Jira project versions"),new Error(`HTTP ${p.status}: ${p.statusText}`)}return await p.json()}catch(r){throw n.error({error:r},"Error getting Jira project versions"),r}},Yr=async(e,r)=>{try{return(await we(r)).find(o=>o.name===e)||null}catch(t){throw n.error({error:t,versionName:e},"Error finding Jira version by name"),t}},Xr=async(e,r)=>{try{let{baseUrl:t,token:s,email:o}=r,a={released:e.released??!0,archived:e.archived??!1};e.releaseDate?a.releaseDate=e.releaseDate:e.released!==!1&&(a.releaseDate=new Date().toISOString().split("T")[0]),e.description!==void 0&&(a.description=e.description);let i=`${t}/rest/api/3/version/${e.versionId}`,p=btoa(`${o}:${s}`),c=await fetch(i,{method:"PUT",headers:{Accept:"application/json","Content-Type":"application/json",Authorization:`Basic ${p}`},body:JSON.stringify(a)});if(!c.ok){let d=await c.text();throw n.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 n.error({error:t},"Error updating Jira version"),t}},Be=async(e,r)=>{try{let{versionName:t}=e,s=await Yr(t,r);if(!s)throw n.error({versionName:t},"Jira version not found"),new Error(`Version "${t}" not found in Jira project`);return await Xr({versionId:s.id,released:!0,releaseDate:new Date().toISOString().split("T")[0]},r)}catch(t){throw n.error({error:t},"Error delivering Jira release"),t}},G=async()=>{let e=oe.env.JIRA_BASE_URL,r=oe.env.JIRA_TOKEN||oe.env.JIRA_API_TOKEN,t=oe.env.JIRA_PROJECT_ID,s=oe.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(p=>` - ${p}`),"","You can set these in your .env file or as environment variables."].join(`
17
- `);throw new Error(i)}let a=Number.parseInt(t,10);if(Number.isNaN(a))throw new TypeError(`Invalid JIRA_PROJECT_ID: "${t}" must be a numeric value (e.g., 10001)`);return{baseUrl:e.replace(/\/$/,""),token:r,projectId:a,email:s}},se=async()=>{try{return await G()}catch(e){return n.warn({error:e},"Jira configuration not available, skipping Jira integration"),null}};var Re=e=>e==="hotfix"?"main":"dev",ie=async(e="regular")=>{let r=Re(e);ne.quiet=!0,await ne`git fetch origin`,await ne`git switch ${r}`,await ne`git pull origin ${r}`,ne.quiet=!1},ae=async e=>{let{version:r,jiraConfig:t,description:s,type:o="regular"}=e,a=`v${r}`,i=await We({name:a,projectId:t.projectId,description:s||"",released:!1,archived:!1},t),p=`${t.baseUrl}/projects/${i.version.projectId}/versions/${i.version.id}/tab/release-report-all-issues`,c=await be({version:r,jiraVersionUrl:p,type:o});return{version:r,type:o,branchName:c.branchName,prUrl:c.prUrl,jiraVersionUrl:p}},w=async()=>{let e=new Map,r=await se();if(!r)return e;try{let t=await we(r);for(let s of t)s.description&&e.set(s.name,s.description)}catch{}return e},z=(e,r,t)=>{let s=t?" ".repeat(t-e.length+3):" ",o=`[${r}]`.padEnd(11);return`${e}${s}${o}`},v=e=>e.toLowerCase().startsWith("hotfix")?"hotfix":"regular",T=e=>{let{branches:r,descriptions:t,types:s}=e,o=r.map(i=>i.replace("release/v","")),a=Math.max(...o.map(i=>i.length));return r.map((i,p)=>{let c=o[p],m=s?s.get(i)||"regular":void 0,d=t.get(`v${c}`),u=" ".repeat(a-c.length+3),h=m?z(c,m,a):c;return d&&(h=m?`${h} ${d}`:`${c}${u}${d}`),{name:h,value:i}})};var Ke=e=>e.replace("release/","").slice(1).split(".").map(Number),ke=e=>[...e].sort((r,t)=>{let[s,o,a]=Ke(r),[i,p,c]=Ke(t);return s!==i?(s??0)-(i??0):o!==p?(o??0)-(p??0):(a??0)-(c??0)});var cr=async()=>{let e=await C`gh pr list --search "Release in:title" --base dev --json number,title,headRefName,state,baseRefName`,r=await C`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))},Te=async()=>{try{let e=await cr();return e.length===0&&(n.error("\u274C No release PRs found. Check the project folder for the script. Exiting..."),xe.exit(1)),ke(e.map(r=>r.headRefName))}catch(e){n.error({error:e},"\u274C Error fetching release PRs"),xe.exit(1)}},y=async()=>{try{let e=await cr();e.length===0&&(n.error("\u274C No release PRs found. Check the project folder for the script. Exiting..."),xe.exit(1));let r=ke(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){n.error({error:e},"\u274C Error fetching release PRs"),xe.exit(1)}},be=async e=>{let{version:r,jiraVersionUrl:t,type:s}=e,o=s==="hotfix"?"Hotfix":"Release",a=Re(s),i=`release/v${r}`;try{C.quiet=!0,await C`git switch ${a}`,await C`git pull origin ${a}`,await C`git checkout -b ${i}`,await C`git push -u origin ${i}`,await C`git commit --allow-empty-message --allow-empty --message ''`,await C`git push origin ${i}`;let c=(await C`gh pr create --title "${o} v${r}" --body "${t} \n" --base ${a} --head ${i}`).stdout.trim();return await C`git switch ${a}`,C.quiet=!1,{branchName:i,prUrl:c}}catch(p){throw n.error({error:p,branchName:i},`Error creating release branch ${i}`),p}};var Ce=async e=>{let{all:r,confirmedCommand:t}=e;l.start("merge-dev");let o=(await y()).filter(d=>v(d.title)==="regular").map(d=>d.branch);if(o.length===0)return n.info("\u2139\uFE0F No open release branches found"),l.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 a=[];if(r)a=o;else{l.setInteractive();let d=await w();a=await Zr({required:!0,message:"\u{1F33F} Select release branches",choices:T({branches:o,descriptions:d})})}a.length===o.length?l.addOption("--all",!0):l.addOption("--versions",a.map(d=>d.replace("release/v","")));let p=t?!0:await Qr({message:`Are you sure you want to merge dev into these branches: ${a.join(", ")}?`});t||l.setInteractive(),p||(n.info("Operation cancelled. Exiting..."),et.exit(0)),t||l.addOption("--yes",!0),_.quiet=!0,await _`git fetch origin`,await _`git switch dev`,await _`git pull origin dev`;let c=[];for(let d of a)await rt(d)||c.push(d);if(_.quiet=!1,c.length>0){n.info(`
12
+ `,384),vr.stdout.write(`${c}
13
+ `),l.print();let m=it(o),u={filePath:c,variableCount:m,project:s,config:t};return{content:[{type:"text",text:JSON.stringify(u,null,2)}],structuredContent:u}},yr=1024*1024,ot=3e4,st=async(e,r)=>{let t=Ce.quiet;Ce.quiet=!0;try{let s=await Ce`doppler secrets download --no-file --format env --project ${e} --config ${r}`.timeout(ot);return nt(s.stdout),s.stdout.trim()}finally{Ce.quiet=t}},nt=e=>{let r=et.byteLength(e,"utf-8");if(r>yr)throw new Error(`doppler returned unexpectedly large output (${r} bytes > ${yr}) \u2014 refusing to write to disk`)},it=e=>e.split(`
14
+ `).filter(r=>we.test(r)).length,at=new Set(["set -a","set +a"]),Ze=e=>`'${e.replaceAll("'","'\\''")}'`,ct=e=>{if(e.trim().length===0)throw new Error("doppler returned empty output for env-load");for(let r of e.split(`
15
+ `)){let t=r.trim();if(!(t.length===0||at.has(t))&&!we.test(t))throw new Error(`doppler returned unexpected output for env-load (expected KEY=value lines, got: ${JSON.stringify(t.slice(0,80))})`)}},lt={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:ae.string().describe('Doppler config / environment name to load (e.g. "dev", "arthur", "renana"). Required for MCP calls.')},outputSchema:{filePath:ae.string().describe("Path to the file that must be sourced to apply variables"),variableCount:ae.number().describe("Number of variables loaded"),project:ae.string().describe("Doppler project name"),config:ae.string().describe("Doppler config name")},handler:Ie};import pt from"node:path";import ce from"node:process";import{z as G}from"zod";var $e=async()=>{await ie(),n.info("Environment session status:");let e=K(),r=ce.env[ye],t=pt.join(e,F),s=0,o=0,i=ce.env[V]??null,a=ce.env[W]??null,p=ce.env[B]??null;if(i){let m=Re(t);m.length>0&&(o=m.length,s=m.filter(d=>d in ce.env).length);let u=p?.replace(/\.\d{3}Z$/,"")??null;if(n.info(` ${i}: ${s} of ${o} vars loaded (project: ${a}, loadedAt: ${u}, session: ${r})
16
+ `),o>0&&s<o){let d=o-s;n.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 n.info(` Session ${r}: no env loaded
17
+ `);let c={sessionId:r,sessionLoadedCount:s,sessionTotalCount:o,sessionConfig:i,sessionProject:a,sessionLoadedAt:p};return{content:[{type:"text",text:JSON.stringify(c,null,2)}],structuredContent:c}},mt={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:G.string().describe("Current terminal session ID"),sessionLoadedCount:G.number().describe("Number of cached vars active in the current session"),sessionTotalCount:G.number().describe("Total number of cached var names"),sessionConfig:G.string().nullable().describe("Doppler config name of the loaded session (environment name)"),sessionProject:G.string().nullable().describe("Doppler project name of the loaded session"),sessionLoadedAt:G.string().nullable().describe("ISO 8601 timestamp of when the env was loaded")},handler:$e};import ht from"@inquirer/checkbox";import gt from"@inquirer/confirm";import vt from"node:process";import{z as H}from"zod";import{$}from"zx";import{$ as Ws}from"zx";import Pe from"node:process";import{$ as C}from"zx";import{$ as me}from"zx";import le from"node:process";var Qe=async(e,r)=>{try{let{baseUrl:t,token:s,email:o,projectId:i}=r,a={name:e.name,projectId:e.projectId||i,description:e.description||"",released:e.released||!1,archived:e.archived||!1},p=`${t}/rest/api/3/version`,c=btoa(`${o}:${s}`),m=await fetch(p,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json",Authorization:`Basic ${c}`},body:JSON.stringify(a)});if(!m.ok){let d=await m.text();throw n.error({status:m.status,statusText:m.statusText,error:d},"Failed to create Jira version"),new Error(`HTTP ${m.status}: ${m.statusText}`)}return{success:!0,version:await m.json()}}catch(t){throw n.error({error:t},"Error creating Jira version"),t}},_e=async e=>{try{let{baseUrl:r,token:t,email:s,projectId:o}=e,i=`${r}/rest/api/3/project/${o}/versions`,a=btoa(`${s}:${t}`),p=await fetch(i,{method:"GET",headers:{Accept:"application/json",Authorization:`Basic ${a}`}});if(!p.ok){let m=await p.text();throw n.error({status:p.status,statusText:p.statusText,error:m},"Failed to get Jira project versions"),new Error(`HTTP ${p.status}: ${p.statusText}`)}return await p.json()}catch(r){throw n.error({error:r},"Error getting Jira project versions"),r}},dt=async(e,r)=>{try{return(await _e(r)).find(o=>o.name===e)||null}catch(t){throw n.error({error:t,versionName:e},"Error finding Jira version by name"),t}},ft=async(e,r)=>{try{let{baseUrl:t,token:s,email:o}=r,i={released:e.released??!0,archived:e.archived??!1};e.releaseDate?i.releaseDate=e.releaseDate:e.released!==!1&&(i.releaseDate=new Date().toISOString().split("T")[0]),e.description!==void 0&&(i.description=e.description);let a=`${t}/rest/api/3/version/${e.versionId}`,p=btoa(`${o}:${s}`),c=await fetch(a,{method:"PUT",headers:{Accept:"application/json","Content-Type":"application/json",Authorization:`Basic ${p}`},body:JSON.stringify(i)});if(!c.ok){let u=await c.text();throw n.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 n.error({error:t},"Error updating Jira version"),t}},er=async(e,r)=>{try{let{versionName:t}=e,s=await dt(t,r);if(!s)throw n.error({versionName:t},"Jira version not found"),new Error(`Version "${t}" not found in Jira project`);return await ft({versionId:s.id,released:!0,releaseDate:new Date().toISOString().split("T")[0]},r)}catch(t){throw n.error({error:t},"Error delivering Jira release"),t}},U=async()=>{let e=le.env.JIRA_BASE_URL,r=le.env.JIRA_TOKEN||le.env.JIRA_API_TOKEN,t=le.env.JIRA_PROJECT_ID,s=le.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 a=["Jira configuration is required but incomplete.","Please configure the following environment variables:",...o.map(p=>` - ${p}`),"","You can set these in your .env file or as environment variables."].join(`
18
+ `);throw new Error(a)}let i=Number.parseInt(t,10);if(Number.isNaN(i))throw new TypeError(`Invalid JIRA_PROJECT_ID: "${t}" must be a numeric value (e.g., 10001)`);return{baseUrl:e.replace(/\/$/,""),token:r,projectId:i,email:s}},pe=async()=>{try{return await U()}catch(e){return n.warn({error:e},"Jira configuration not available, skipping Jira integration"),null}};var Ee=e=>e==="hotfix"?"main":"dev",ue=async(e="regular")=>{let r=Ee(e);me.quiet=!0,await me`git fetch origin`,await me`git switch ${r}`,await me`git pull origin ${r}`,me.quiet=!1},de=async e=>{let{version:r,jiraConfig:t,description:s,type:o="regular"}=e,i=`v${r}`,a=await Qe({name:i,projectId:t.projectId,description:s||"",released:!1,archived:!1},t),p=`${t.baseUrl}/projects/${a.version.projectId}/versions/${a.version.id}/tab/release-report-all-issues`,c=await Ae({version:r,jiraVersionUrl:p,type:o});return{version:r,type:o,branchName:c.branchName,prUrl:c.prUrl,jiraVersionUrl:p}},w=async()=>{let e=new Map,r=await pe();if(!r)return e;try{let t=await _e(r);for(let s of t)s.description&&e.set(s.name,s.description)}catch{}return e},z=(e,r,t)=>{let s=t?" ".repeat(t-e.length+3):" ",o=`[${r}]`.padEnd(11);return`${e}${s}${o}`},v=e=>e.toLowerCase().startsWith("hotfix")?"hotfix":"regular",k=e=>{let{branches:r,descriptions:t,types:s}=e,o=r.map(a=>a.replace("release/v","")),i=Math.max(...o.map(a=>a.length));return r.map((a,p)=>{let c=o[p],m=s?s.get(a)||"regular":void 0,u=t.get(`v${c}`),d=" ".repeat(i-c.length+3),h=m?z(c,m,i):c;return u&&(h=m?`${h} ${u}`:`${c}${d}${u}`),{name:h,value:a}})};var rr=e=>e.replace("release/","").slice(1).split(".").map(Number),Se=e=>[...e].sort((r,t)=>{let[s,o,i]=rr(r),[a,p,c]=rr(t);return s!==a?(s??0)-(a??0):o!==p?(o??0)-(p??0):(i??0)-(c??0)});var wr=async()=>{let e=await C`gh pr list --search "Release in:title" --base dev --json number,title,headRefName,state,baseRefName`,r=await C`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))},Ne=async()=>{try{let e=await wr();return e.length===0&&(n.error("\u274C No release PRs found. Check the project folder for the script. Exiting..."),Pe.exit(1)),Se(e.map(r=>r.headRefName))}catch(e){n.error({error:e},"\u274C Error fetching release PRs"),Pe.exit(1)}},y=async()=>{try{let e=await wr();e.length===0&&(n.error("\u274C No release PRs found. Check the project folder for the script. Exiting..."),Pe.exit(1));let r=Se(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){n.error({error:e},"\u274C Error fetching release PRs"),Pe.exit(1)}},Ae=async e=>{let{version:r,jiraVersionUrl:t,type:s}=e,o=s==="hotfix"?"Hotfix":"Release",i=Ee(s),a=`release/v${r}`;try{C.quiet=!0,await C`git switch ${i}`,await C`git pull origin ${i}`,await C`git checkout -b ${a}`,await C`git push -u origin ${a}`,await C`git commit --allow-empty-message --allow-empty --message ''`,await C`git push origin ${a}`;let c=(await C`gh pr create --title "${o} v${r}" --body "${t} \n" --base ${i} --head ${a}`).stdout.trim();return await C`git switch ${i}`,C.quiet=!1,{branchName:a,prUrl:c}}catch(p){throw n.error({error:p,branchName:a},`Error creating release branch ${a}`),p}};var Oe=async e=>{let{all:r,confirmedCommand:t}=e;l.start("merge-dev");let o=(await y()).filter(u=>v(u.title)==="regular").map(u=>u.branch);if(o.length===0)return n.info("\u2139\uFE0F No open release branches found"),l.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 i=[];if(r)i=o;else{l.setInteractive();let u=await w();i=await ht({required:!0,message:"\u{1F33F} Select release branches",choices:k({branches:o,descriptions:u})})}i.length===o.length?l.addOption("--all",!0):l.addOption("--versions",i.map(u=>u.replace("release/v","")));let p=t?!0:await gt({message:`Are you sure you want to merge dev into these branches: ${i.join(", ")}?`});t||l.setInteractive(),p||(n.info("Operation cancelled. Exiting..."),vt.exit(0)),t||l.addOption("--yes",!0),$.quiet=!0,await $`git fetch origin`,await $`git switch dev`,await $`git pull origin dev`;let c=[];for(let u of i)await yt(u)||c.push(u);if($.quiet=!1,c.length>0){n.info(`
18
19
  \u26A0\uFE0F ${c.length} branch(es) failed to merge automatically.
19
- `),n.info("\u{1F4CB} Manual merge script for failed branches:");for(let d of c)n.info(`# Merge dev into ${d} and resolve conflicts if any
20
+ `),n.info("\u{1F4CB} Manual merge script for failed branches:");for(let u of c)n.info(`# Merge dev into ${u} and resolve conflicts if any
20
21
 
21
- git switch ${d} && git pull origin ${d} && git merge origin/dev
22
- git push origin ${d} && git switch dev
23
- `);n.info(`\u2705 ${a.length-c.length}/${a.length} merges completed successfully.`)}else n.info(`\u2705 All merges completed successfully!
24
- `);l.print();let m={successfulMerges:a.length-c.length,failedMerges:c.length,failedBranches:c,totalBranches:a.length};return{content:[{type:"text",text:JSON.stringify(m,null,2)}],structuredContent:m}},rt=async e=>{try{return await _`git switch ${e}`,await _`git pull origin ${e}`,await _`git merge origin/dev --no-edit`,await _`git push origin ${e}`,await _`git switch dev`,n.info(`Successfully merged dev into ${e}`),!0}catch(r){return n.error({error:r,branch:e},`Error merging dev into ${e}`),await _`git reset --merge HEAD~1`,!1}},tt={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:U.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:U.number().describe("Number of successful merges"),failedMerges:U.number().describe("Number of failed merges"),failedBranches:U.array(U.string()).describe("List of branches that failed to merge"),totalBranches:U.number().describe("Total number of branches processed")},handler:Ce};import ot from"@inquirer/confirm";import st from"@inquirer/select";import qe from"node:process";import{z as ce}from"zod";import{$ as k}from"zx";var Ie=async e=>{let{version:r,confirmedCommand:t}=e;l.start("release-deliver");let s=await y(),o=s.map(u=>u.branch),a=new Map(s.map(u=>[u.branch,v(u.title)])),i="";if(r)i=`release/v${r}`;else{l.setInteractive();let u=await w();i=await st({message:"\u{1F33F} Select release branch",choices:T({branches:o,descriptions:u,types:a})})}let p=i.replace("release/v","");l.addOption("--version",p);let c=s.find(u=>u.branch===i);c||(n.error(`\u274C Release branch ${i} not found in open PRs. Exiting...`),qe.exit(1));let m=v(c.title),d=t?!0:await ot({message:`Are you sure you want to deliver version ${i} to production?`});t||l.setInteractive(),d||(n.info("Operation cancelled. Exiting..."),qe.exit(0)),l.addOption("--yes",!0);try{k.quiet=!0,m==="hotfix"?(await k`gh pr merge ${i} --squash --admin --delete-branch`,k.quiet=!1,await k`gh workflow run deploy-all.yml --ref main -f environment=prod`,k.quiet=!0,await k`git switch main && git pull && git switch dev && git pull && git merge main --no-edit && git push`):(await k`gh pr merge ${i} --squash --admin --delete-branch`,await k`gh pr create --base main --head dev --title "Release v${p} (RC)" --body ""`,await k`gh pr merge dev --squash --admin`,k.quiet=!1,await k`gh workflow run deploy-all.yml --ref main -f environment=prod`,k.quiet=!0,await k`git switch main && git pull && git switch dev && git pull && git merge main --no-edit && git push`),k.quiet=!1;let u=await se();if(u)try{let f=i.replace("release/","");await Be({versionName:f},u)}catch(f){n.error({error:f},"Failed to deliver Jira release (non-blocking)")}else n.info("\u{1F514} Jira is not configured, skipping Jira release delivery");n.info(`Successfully delivered ${i} to production!`),l.print();let h={releaseBranch:i,version:i.replace("release/v",""),type:m,success:!0};return{content:[{type:"text",text:JSON.stringify(h,null,2)}],structuredContent:h}}catch(u){n.error({error:u},"\u274C Error merging release branch into dev"),qe.exit(1)}},nt={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:ce.string().describe('Release version to deliver to production (e.g., "1.2.5"). Required for MCP calls.')},outputSchema:{releaseBranch:ce.string().describe("The release branch that was delivered"),version:ce.string().describe("The version that was delivered"),type:ce.enum(["regular","hotfix"]).describe("Release type"),success:ce.boolean().describe("Whether the delivery was successful")},handler:Ie};import lr from"@inquirer/select";import pr from"node:process";import{z as O}from"zod";import{$ as Ge}from"zx";var $e=async e=>{let{version:r,env:t,skipTerraform:s}=e;l.start("release-deploy-all");let o="";if(r)o=r==="dev"?"dev":`release/v${r}`;else{l.setInteractive();let m=await y(),d=m.map(f=>f.branch),u=new Map(m.map(f=>[f.branch,v(f.title)])),h=await w();o=await lr({message:"\u{1F33F} Select release branch",choices:[{name:"dev",value:"dev"},...T({branches:d,descriptions:h,types:u})]})}let a=o==="dev"?"dev":o.replace("release/v","");l.addOption("--version",a);let{environments:i}=await S(),p="";t?p=t:(l.setInteractive(),p=await lr({message:"\u{1F9EA} Select environment",choices:i.map(m=>({name:m,value:m}))})),l.addOption("--env",p),i.includes(p)||(n.error(`\u274C Invalid environment: ${p}. Exiting...`),pr.exit(1));let c=s??!1;c&&l.addOption("--skip-terraform",!0);try{Ge.quiet=!0,await Ge`gh workflow run deploy-all.yml --ref ${o} -f environment=${p} ${c?["-f","skip_terraform_deploy=true"]:[]}`,Ge.quiet=!1,n.info(`Successfully launched deploy-all workflow_dispatch for release branch: ${o} and environment: ${p}`),l.print();let d={releaseBranch:o,version:o.replace("release/v",""),environment:p,skipTerraformDeploy:c,success:!0};return{content:[{type:"text",text:JSON.stringify(d,null,2)}],structuredContent:d}}catch(m){n.error({error:m},"\u274C Error launching workflow"),pr.exit(1)}},it={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:O.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:O.string().describe('Target environment name \u2014 must match an env configured for the project (e.g. "dev", "renana", "oriana"). Required for MCP calls.'),skipTerraform:O.boolean().optional().describe("Skip the terraform deployment stage.")},outputSchema:{releaseBranch:O.string().describe("The release branch that was deployed"),version:O.string().describe("The version that was deployed"),environment:O.string().describe("The environment deployed to"),skipTerraformDeploy:O.boolean().describe("Whether terraform deployment was skipped"),success:O.boolean().describe("Whether the deployment was successful")},handler:$e};import at from"@inquirer/checkbox";import mr from"@inquirer/select";import ct from"node:fs/promises";import{resolve as lt}from"node:path";import le from"node:process";import pt from"yaml";import{z as I}from"zod";import{$ as ze}from"zx";var _e=async e=>{let{version:r,env:t,services:s,skipTerraform:o}=e;l.start("release-deploy-selected");let a="";if(r)a=r==="dev"?"dev":`release/v${r}`;else{l.setInteractive();let f=await y(),x=f.map(N=>N.branch),A=new Map(f.map(N=>[N.branch,v(N.title)])),b=await w();a=await mr({message:"\u{1F33F} Select release branch",choices:[{name:"dev",value:"dev"},...T({branches:x,descriptions:b,types:A})]})}let i=a==="dev"?"dev":a.replace("release/v","");l.addOption("--version",i);let{environments:p}=await S(),c="";t?c=t:(l.setInteractive(),c=await mr({message:"\u{1F9EA} Select environment",choices:p.map(f=>({name:f,value:f}))})),l.addOption("--env",c),p.includes(c)||(n.error(`\u274C Invalid environment: ${c}. Exiting...`),le.exit(1));let m=await mt();m.length===0&&(n.error("\u274C No services found in workflow file. Exiting..."),le.exit(1));let d=[];s&&s.length>0?d=s:(l.setInteractive(),d=await at({message:"\u{1F680} Select services to deploy (space to select, enter to confirm)",choices:m.map(f=>({name:f,value:f}))})),l.addOption("--services",d),d.length===0&&(n.error("\u274C No services selected. Exiting..."),le.exit(1));let u=d.filter(f=>!m.includes(f));u.length>0&&(n.error(`\u274C Invalid services: ${u.join(", ")}. Available services: ${m.join(", ")}`),le.exit(1));let h=o??!1;h&&l.addOption("--skip-terraform",!0);try{ze.quiet=!0;let f=d.flatMap(b=>["-f",`${b}=true`]);await ze`gh workflow run deploy-selected-services.yml --ref ${a} -f environment=${c} ${f} ${h?["-f","skip_terraform_deploy=true"]:[]}`,ze.quiet=!1,n.info(`Successfully launched deploy-selected-services workflow_dispatch for release branch: ${a}, environment: ${c}, services: ${d.join(", ")}`),l.print();let A={releaseBranch:a,version:a.replace("release/v",""),environment:c,services:d,skipTerraformDeploy:h,success:!0};return{content:[{type:"text",text:JSON.stringify(A,null,2)}],structuredContent:A}}catch(f){n.error({error:f},"\u274C Error launching workflow"),le.exit(1)}},mt=async()=>{let e=await $(),r=lt(e,".github/workflows/deploy-selected-services.yml"),t=await ct.readFile(r,"utf-8"),o=pt.parse(t).on.workflow_dispatch.inputs,a=[];for(let[i,p]of Object.entries(o))p.type==="boolean"&&i!=="skip_terraform_deploy"&&a.push(i);return a},dt={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:I.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:I.string().describe('Target environment name \u2014 must match an env configured for the project (e.g. "dev", "renana", "oriana"). Required for MCP calls.'),services:I.array(I.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:I.boolean().optional().describe("Skip the terraform deployment stage.")},outputSchema:{releaseBranch:I.string().describe("The release branch that was deployed"),version:I.string().describe("The version that was deployed"),environment:I.string().describe("The environment deployed to"),services:I.array(I.string()).describe("The services that were deployed"),skipTerraformDeploy:I.boolean().describe("Whether terraform deployment was skipped"),success:I.boolean().describe("Whether the deployment was successful")},handler:_e};import{z as H}from"zod";var Ae=async()=>{let r=(await y()).map(i=>({version:i.branch.replace("release/",""),type:v(i.title)})),t=await w(),s=Math.max(...r.map(i=>i.version.length)),o=r.map(i=>{let p=z(i.version,i.type,s),c=t.get(i.version);return c?`${p} ${c}`:p});n.info(`All release branches:
22
+ git switch ${u} && git pull origin ${u} && git merge origin/dev
23
+ git push origin ${u} && git switch dev
24
+ `);n.info(`\u2705 ${i.length-c.length}/${i.length} merges completed successfully.`)}else n.info(`\u2705 All merges completed successfully!
25
+ `);l.print();let m={successfulMerges:i.length-c.length,failedMerges:c.length,failedBranches:c,totalBranches:i.length};return{content:[{type:"text",text:JSON.stringify(m,null,2)}],structuredContent:m}},yt=async e=>{try{return await $`git switch ${e}`,await $`git pull origin ${e}`,await $`git merge origin/dev --no-edit`,await $`git push origin ${e}`,await $`git switch dev`,n.info(`Successfully merged dev into ${e}`),!0}catch(r){return n.error({error:r,branch:e},`Error merging dev into ${e}`),await $`git reset --merge HEAD~1`,!1}},wt={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:H.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:H.number().describe("Number of successful merges"),failedMerges:H.number().describe("Number of failed merges"),failedBranches:H.array(H.string()).describe("List of branches that failed to merge"),totalBranches:H.number().describe("Total number of branches processed")},handler:Oe};import Rt from"@inquirer/confirm";import bt from"@inquirer/select";import tr from"node:process";import{z as fe}from"zod";import{$ as b}from"zx";var Le=async e=>{let{version:r,confirmedCommand:t}=e;l.start("release-deliver");let s=await y(),o=s.map(d=>d.branch),i=new Map(s.map(d=>[d.branch,v(d.title)])),a="";if(r)a=`release/v${r}`;else{l.setInteractive();let d=await w();a=await bt({message:"\u{1F33F} Select release branch",choices:k({branches:o,descriptions:d,types:i})})}let p=a.replace("release/v","");l.addOption("--version",p);let c=s.find(d=>d.branch===a);c||(n.error(`\u274C Release branch ${a} not found in open PRs. Exiting...`),tr.exit(1));let m=v(c.title),u=t?!0:await Rt({message:`Are you sure you want to deliver version ${a} to production?`});t||l.setInteractive(),u||(n.info("Operation cancelled. Exiting..."),tr.exit(0)),l.addOption("--yes",!0);try{b.quiet=!0,m==="hotfix"?(await b`gh pr merge ${a} --squash --admin --delete-branch`,b.quiet=!1,await b`gh workflow run deploy-all.yml --ref main -f environment=prod`,b.quiet=!0,await b`git switch main && git pull && git switch dev && git pull && git merge main --no-edit && git push`):(await b`gh pr merge ${a} --squash --admin --delete-branch`,await b`gh pr create --base main --head dev --title "Release v${p} (RC)" --body ""`,await b`gh pr merge dev --squash --admin`,b.quiet=!1,await b`gh workflow run deploy-all.yml --ref main -f environment=prod`,b.quiet=!0,await b`git switch main && git pull && git switch dev && git pull && git merge main --no-edit && git push`),b.quiet=!1;let d=await pe();if(d)try{let f=a.replace("release/","");await er({versionName:f},d)}catch(f){n.error({error:f},"Failed to deliver Jira release (non-blocking)")}else n.info("\u{1F514} Jira is not configured, skipping Jira release delivery");n.info(`Successfully delivered ${a} to production!`),l.print();let h={releaseBranch:a,version:a.replace("release/v",""),type:m,success:!0};return{content:[{type:"text",text:JSON.stringify(h,null,2)}],structuredContent:h}}catch(d){n.error({error:d},"\u274C Error merging release branch into dev"),tr.exit(1)}},kt={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:fe.string().describe('Release version to deliver to production (e.g., "1.2.5"). Required for MCP calls.')},outputSchema:{releaseBranch:fe.string().describe("The release branch that was delivered"),version:fe.string().describe("The version that was delivered"),type:fe.enum(["regular","hotfix"]).describe("Release type"),success:fe.boolean().describe("Whether the delivery was successful")},handler:Le};import Rr from"@inquirer/select";import br from"node:process";import{z as O}from"zod";import{$ as or}from"zx";var De=async e=>{let{version:r,env:t,skipTerraform:s}=e;l.start("release-deploy-all");let o="";if(r)o=r==="dev"?"dev":`release/v${r}`;else{l.setInteractive();let m=await y(),u=m.map(f=>f.branch),d=new Map(m.map(f=>[f.branch,v(f.title)])),h=await w();o=await Rr({message:"\u{1F33F} Select release branch",choices:[{name:"dev",value:"dev"},...k({branches:u,descriptions:h,types:d})]})}let i=o==="dev"?"dev":o.replace("release/v","");l.addOption("--version",i);let{environments:a}=await A(),p="";t?p=t:(l.setInteractive(),p=await Rr({message:"\u{1F9EA} Select environment",choices:a.map(m=>({name:m,value:m}))})),l.addOption("--env",p),a.includes(p)||(n.error(`\u274C Invalid environment: ${p}. Exiting...`),br.exit(1));let c=s??!1;c&&l.addOption("--skip-terraform",!0);try{or.quiet=!0,await or`gh workflow run deploy-all.yml --ref ${o} -f environment=${p} ${c?["-f","skip_terraform_deploy=true"]:[]}`,or.quiet=!1,n.info(`Successfully launched deploy-all workflow_dispatch for release branch: ${o} and environment: ${p}`),l.print();let u={releaseBranch:o,version:o.replace("release/v",""),environment:p,skipTerraformDeploy:c,success:!0};return{content:[{type:"text",text:JSON.stringify(u,null,2)}],structuredContent:u}}catch(m){n.error({error:m},"\u274C Error launching workflow"),br.exit(1)}},xt={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:O.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:O.string().describe('Target environment name \u2014 must match an env configured for the project (e.g. "dev", "renana", "oriana"). Required for MCP calls.'),skipTerraform:O.boolean().optional().describe("Skip the terraform deployment stage.")},outputSchema:{releaseBranch:O.string().describe("The release branch that was deployed"),version:O.string().describe("The version that was deployed"),environment:O.string().describe("The environment deployed to"),skipTerraformDeploy:O.boolean().describe("Whether terraform deployment was skipped"),success:O.boolean().describe("Whether the deployment was successful")},handler:De};import Tt from"@inquirer/checkbox";import kr from"@inquirer/select";import Ct from"node:fs/promises";import{resolve as It}from"node:path";import he from"node:process";import $t from"yaml";import{z as I}from"zod";import{$ as sr}from"zx";var Me=async e=>{let{version:r,env:t,services:s,skipTerraform:o}=e;l.start("release-deploy-selected");let i="";if(r)i=r==="dev"?"dev":`release/v${r}`;else{l.setInteractive();let f=await y(),_=f.map(D=>D.branch),P=new Map(f.map(D=>[D.branch,v(D.title)])),E=await w();i=await kr({message:"\u{1F33F} Select release branch",choices:[{name:"dev",value:"dev"},...k({branches:_,descriptions:E,types:P})]})}let a=i==="dev"?"dev":i.replace("release/v","");l.addOption("--version",a);let{environments:p}=await A(),c="";t?c=t:(l.setInteractive(),c=await kr({message:"\u{1F9EA} Select environment",choices:p.map(f=>({name:f,value:f}))})),l.addOption("--env",c),p.includes(c)||(n.error(`\u274C Invalid environment: ${c}. Exiting...`),he.exit(1));let m=await _t();m.length===0&&(n.error("\u274C No services found in workflow file. Exiting..."),he.exit(1));let u=[];s&&s.length>0?u=s:(l.setInteractive(),u=await Tt({message:"\u{1F680} Select services to deploy (space to select, enter to confirm)",choices:m.map(f=>({name:f,value:f}))})),l.addOption("--services",u),u.length===0&&(n.error("\u274C No services selected. Exiting..."),he.exit(1));let d=u.filter(f=>!m.includes(f));d.length>0&&(n.error(`\u274C Invalid services: ${d.join(", ")}. Available services: ${m.join(", ")}`),he.exit(1));let h=o??!1;h&&l.addOption("--skip-terraform",!0);try{sr.quiet=!0;let f=u.flatMap(E=>["-f",`${E}=true`]);await sr`gh workflow run deploy-selected-services.yml --ref ${i} -f environment=${c} ${f} ${h?["-f","skip_terraform_deploy=true"]:[]}`,sr.quiet=!1,n.info(`Successfully launched deploy-selected-services workflow_dispatch for release branch: ${i}, environment: ${c}, services: ${u.join(", ")}`),l.print();let P={releaseBranch:i,version:i.replace("release/v",""),environment:c,services:u,skipTerraformDeploy:h,success:!0};return{content:[{type:"text",text:JSON.stringify(P,null,2)}],structuredContent:P}}catch(f){n.error({error:f},"\u274C Error launching workflow"),he.exit(1)}},_t=async()=>{let e=await T(),r=It(e,".github/workflows/deploy-selected-services.yml"),t=await Ct.readFile(r,"utf-8"),o=$t.parse(t).on.workflow_dispatch.inputs,i=[];for(let[a,p]of Object.entries(o))p.type==="boolean"&&a!=="skip_terraform_deploy"&&i.push(a);return i},Et={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:I.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:I.string().describe('Target environment name \u2014 must match an env configured for the project (e.g. "dev", "renana", "oriana"). Required for MCP calls.'),services:I.array(I.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:I.boolean().optional().describe("Skip the terraform deployment stage.")},outputSchema:{releaseBranch:I.string().describe("The release branch that was deployed"),version:I.string().describe("The version that was deployed"),environment:I.string().describe("The environment deployed to"),services:I.array(I.string()).describe("The services that were deployed"),skipTerraformDeploy:I.boolean().describe("Whether terraform deployment was skipped"),success:I.boolean().describe("Whether the deployment was successful")},handler:Me};import{z as Y}from"zod";var Je=async()=>{let r=(await y()).map(a=>({version:a.branch.replace("release/",""),type:v(a.title)})),t=await w(),s=Math.max(...r.map(a=>a.version.length)),o=r.map(a=>{let p=z(a.version,a.type,s),c=t.get(a.version);return c?`${p} ${c}`:p});n.info(`All release branches:
25
26
  `),n.info(`
26
27
  ${o.join(`
27
28
  `)}
28
- `);let a={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(a,null,2)}],structuredContent:a}},ut={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:H.array(H.object({version:H.string().describe("Release version"),type:H.enum(["regular","hotfix"]).describe("Release type"),description:H.string().nullable().describe("Jira version description")})).describe("List of all release branches"),count:H.number().describe("Number of release branches")},handler:Ae};import Se from"node:fs";import ft from"node:os";import ht from"node:path";var ur="# -- infra-kit:begin --",fr="# -- infra-kit:end --",gt=[["# region infra-kit","# endregion infra-kit"]],vt="# infra-kit shell functions",Ue=async()=>{let e=ht.join(ft.homedir(),".zshrc"),r=Rt();if(Se.existsSync(e)){let t=Se.readFileSync(e,"utf-8"),s=wt(t);Se.writeFileSync(e,s)}Se.appendFileSync(e,`
29
+ `);let i={releases:r.map(a=>({version:a.version,type:a.type,description:t.get(a.version)||null})),count:r.length};return{content:[{type:"text",text:JSON.stringify(i,null,2)}],structuredContent:i}},At={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:Y.array(Y.object({version:Y.string().describe("Release version"),type:Y.enum(["regular","hotfix"]).describe("Release type"),description:Y.string().nullable().describe("Jira version description")})).describe("List of all release branches"),count:Y.number().describe("Number of release branches")},handler:Je};import je from"node:fs";import St from"node:os";import Pt from"node:path";var Tr="# -- infra-kit:begin --",Cr="# -- infra-kit:end --",Nt=[["# region infra-kit","# endregion infra-kit"]],Ot="# infra-kit shell functions",nr=async()=>{let e=Pt.join(St.homedir(),".zshrc"),r=Mt();if(je.existsSync(e)){let t=je.readFileSync(e,"utf-8"),s=Dt(t);je.writeFileSync(e,s)}je.appendFileSync(e,`
29
30
  ${r}
30
- `),n.info(`Added infra-kit shell functions to ${e}`),n.info("Run `source ~/.zshrc` or open a new terminal to activate.")},yt=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_LAST_")||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"),dr=(e,r,t)=>{let s=e.indexOf(r),o=e.indexOf(t);if(s===-1||o===-1)return null;let a=e.slice(0,s).replace(/\n+$/,""),i=e.slice(o+t.length).replace(/^\n+/,"");return a+(i?`
31
- ${i}`:"")},wt=e=>{let r=dr(e,ur,fr);if(r!==null)return r;for(let[p,c]of gt){let m=dr(e,p,c);if(m!==null)return m}let t=e.indexOf(vt);if(t===-1)return e;let s=e.slice(0,t).replace(/\n+$/,""),o=e.slice(t).split(`
32
- `),a=0;for(;a<o.length&&yt(o[a]);)a++;let i=o.slice(a).join(`
33
- `);return s+(i?`
34
- ${i}`:"")},Rt=()=>{let e="pnpm exec infra-kit";return[ur,"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; f=$(${e} env-load "$@") && source "$f" && _INFRA_KIT_LAST_LOAD_MTIME=$(zstat +mtime -- "$f" 2>/dev/null || echo 0) && ${e} env-status; }`,`env-clear() { local f; f=$(${e} env-clear) && source "$f" && _INFRA_KIT_LAST_CLEAR_MTIME=$(zstat +mtime -- "$f" 2>/dev/null || echo 0) && ${e} env-status; }`,`env-status() { ${e} env-status; }`,`alias ik='${e}'`,"_infra_kit_autoload() {",' [[ -z "$INFRA_KIT_SESSION" ]] && return',' local dir="./node_modules/.cache/infra-kit/$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","add-zsh-hook precmd _infra_kit_autoload",fr].join(`
35
- `)};import hr from"@inquirer/confirm";import bt from"@inquirer/select";import gr from"node:process";import{z as E}from"zod";import{$ as He,question as vr}from"zx";var Ee=async e=>{let{version:r,description:t,type:s,confirmedCommand:o,checkout:a}=e;l.start("release-create");let i=r,p=t,c=s||"regular",m=a,d=await G();i||(l.setInteractive(),i=await vr("Enter version (e.g. 1.2.5): ")),(!i||i.trim()==="")&&(n.error("No version provided. Exiting..."),gr.exit(1));let u=i.trim();l.addOption("--version",u),s||(l.setInteractive(),c=await bt({message:"Select release type:",choices:[{name:"regular",value:"regular"},{name:"hotfix",value:"hotfix"}],default:"regular"})),l.addOption("--type",c),p===void 0&&(l.setInteractive(),p=await vr("Enter description (optional, press Enter to skip): "),p.trim()===""&&(p="")),p&&l.addOption("--description",p);let h=o?!0:await hr({message:`Are you sure you want to create release branch for version ${u}?`});o||l.setInteractive(),h||(n.info("Operation cancelled. Exiting..."),gr.exit(0)),l.addOption("--yes",!0),await ie(c);let f=await ae({version:u,jiraConfig:d,description:p,type:c});n.info(`\u2705 Successfully created release: v${u}`),n.info(`\u{1F517} GitHub PR: ${f.prUrl}`),n.info(`\u{1F517} Jira Version: ${f.jiraVersionUrl}`),m===void 0&&(l.setInteractive(),m=await hr({message:`Do you want to checkout to the created branch ${f.branchName}?`,default:!0})),m||l.addOption("--no-checkout",!0),m&&(He.quiet=!0,await He`git switch ${f.branchName}`,He.quiet=!1,n.info(`\u{1F504} Switched to branch ${f.branchName}`)),l.print();let x={version:u,type:c,branchName:f.branchName,prUrl:f.prUrl,jiraVersionUrl:f.jiraVersionUrl,isCheckedOut:m};return{content:[{type:"text",text:JSON.stringify(x,null,2)}],structuredContent:x}},kt={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:E.string().describe('Version to create (e.g., "1.2.5"). Required for MCP calls.'),description:E.string().optional().describe("Optional description for the Jira version"),type:E.enum(["regular","hotfix"]).optional().default("regular").describe('Release type: "regular" or "hotfix" (default: "regular")'),checkout:E.boolean().optional().default(!0).describe("Checkout to the created branch (default: true)")},outputSchema:{version:E.string().describe("Version number"),type:E.enum(["regular","hotfix"]).describe("Release type"),branchName:E.string().describe("Release branch name"),prUrl:E.string().describe("GitHub PR URL"),jiraVersionUrl:E.string().describe("Jira version URL"),isCheckedOut:E.boolean().describe("Whether the branch was checked out")},handler:Ee};import xt from"@inquirer/confirm";import Tt from"@inquirer/select";import yr from"node:process";import{z as R}from"zod";import{question as Ct}from"zx";var It=async e=>{let{versions:r,type:t,confirmedCommand:s}=e,o=r,a=t||"regular";o||(l.setInteractive(),o=await Ct("Enter versions by comma (e.g. 1.2.5, 1.2.6): "));let i=o.split(",").map(c=>c.trim()).filter(Boolean);l.addOption("--versions",i.join(", ")),i.length===0&&(n.error("No versions provided. Exiting..."),yr.exit(1)),t||(l.setInteractive(),a=await Tt({message:"Select release type:",choices:[{name:"regular",value:"regular"},{name:"hotfix",value:"hotfix"}],default:"regular"})),l.addOption("--type",a),i.length===1&&n.warn('\u{1F4A1} You are creating only one release. Consider using "create-release" command for single releases.');let p=s?!0:await xt({message:`Are you sure you want to create release branches for these versions: ${i.join(", ")}?`});return s||l.setInteractive(),p||(n.info("Operation cancelled. Exiting..."),yr.exit(0)),l.addOption("--yes",!0),{versionsList:i,type:a}},Pe=async e=>{l.start("release-create-batch");let r=await G(),{versionsList:t,type:s}=await It(e);await ie(s);let o=[],a=[];for(let m of t)try{let d=await ae({version:m,jiraConfig:r,type:s});o.push(d),n.info(`\u2705 Successfully created release: v${m}`),n.info(`\u{1F517} GitHub PR: ${d.prUrl}`),n.info(`\u{1F517} Jira Version: ${d.jiraVersionUrl}
36
- `)}catch(d){let u=d instanceof Error?d.message:String(d);a.push({version:m,error:u}),n.error(`\u274C Failed to create release: v${m}`),n.error(` Error: ${u}
37
- `)}let i=o.length,p=a.length;i===t.length?n.info(`\u2705 All ${t.length} release branches were created successfully.`):i>0?(n.warn(`\u26A0\uFE0F ${i} of ${t.length} release branches were created successfully.`),n.warn(`\u274C ${p} release(s) failed.`)):n.error(`\u274C All ${t.length} release branches failed to create.`),l.print();let c={createdBranches:o.map(m=>m.branchName),successCount:i,failureCount:p,releases:o,failedReleases:a};return{content:[{type:"text",text:JSON.stringify(c,null,2)}],structuredContent:c}},$t={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:R.string().describe('Comma-separated list of versions to create (e.g., "1.2.5, 1.2.6"). Required for MCP calls.'),type:R.enum(["regular","hotfix"]).optional().default("regular").describe('Release type: "regular" or "hotfix" (default: "regular")')},outputSchema:{createdBranches:R.array(R.string()).describe("List of created release branches"),successCount:R.number().describe("Number of releases created successfully"),failureCount:R.number().describe("Number of releases that failed"),releases:R.array(R.object({version:R.string().describe("Version number"),type:R.enum(["regular","hotfix"]).describe("Release type"),branchName:R.string().describe("Release branch name"),prUrl:R.string().describe("GitHub PR URL"),jiraVersionUrl:R.string().describe("Jira version URL")})).describe("Detailed information for each created release with URLs"),failedReleases:R.array(R.object({version:R.string().describe("Version number that failed"),error:R.string().describe("Error message")})).describe("List of releases that failed with error messages")},handler:Pe};import _t from"@inquirer/checkbox";import Ye from"@inquirer/confirm";import At from"node:process";import{z as M}from"zod";import{$ as Y}from"zx";var St="feature",Et="release",Pt="release/v",Ne=async e=>{let{confirmedCommand:r,all:t,versions:s,cursor:o,githubDesktop:a}=e;l.start("worktrees-add");try{let i=await P("release"),c=`${await $()}${K}`;await wr(`${c}/${Et}`),await wr(`${c}/${St}`);let m=[];if(s)m=s.split(",").map(b=>`release/v${b.trim()}`);else{let b=await y(),N=b.map(Me=>Me.branch);if(N.length===0)return n.info("\u2139\uFE0F No open release branches found"),l.print(),{content:[{type:"text",text:JSON.stringify({createdWorktrees:[],count:0},null,2)}],structuredContent:{createdWorktrees:[],count:0}};if(t)m=N;else{l.setInteractive();let Me=new Map(b.map(Qe=>[Qe.branch,v(Qe.title)])),kr=await w();m=await _t({required:!0,message:"\u{1F33F} Select release branches",choices:T({branches:N,descriptions:kr,types:Me})})}}t?l.addOption("--all",!0):l.addOption("--versions",m.map(b=>b.replace("release/v","")));let d=r?!0:await Ye({message:"Are you sure you want to proceed with these worktree changes?"});r||l.setInteractive(),d||(n.info("Operation cancelled. Exiting..."),At.exit(0)),r||l.addOption("--yes",!0);let u=o??await Ye({message:"Open created worktrees in Cursor?"});typeof o>"u"&&l.setInteractive(),u?l.addOption("--cursor",!0):l.addOption("--no-cursor",!0);let h=a??await Ye({message:"Open created worktrees in GitHub Desktop?"});typeof a>"u"&&l.setInteractive(),h?l.addOption("--github-desktop",!0):l.addOption("--no-github-desktop",!0);let{branchesToCreate:f}=Nt({selectedReleaseBranches:m,currentWorktrees:i}),x=await Ot(f,c);if(Dt(x),u)for(let b of x)await Y`cursor ${c}/${b}`;if(h)for(let b of x)await Y`github ${c}/${b}`,await Y`sleep 5`;l.print();let A={createdWorktrees:x,count:x.length};return{content:[{type:"text",text:JSON.stringify(A,null,2)}],structuredContent:A}}catch(i){throw n.error({error:i},"\u274C Error managing worktrees"),i}},wr=async e=>{await Y`mkdir -p ${e}`},Nt=e=>{let{selectedReleaseBranches:r,currentWorktrees:t}=e,s=t.filter(a=>a.startsWith(Pt));return{branchesToCreate:r.filter(a=>!s.includes(a))}},Ot=async(e,r)=>{let t=await Promise.allSettled(e.map(async o=>{let a=`${r}/${o}`;return await Y`git worktree add ${a} ${o}`,await Y({cwd:a})`pnpm install`,o})),s=[];for(let[o,a]of t.entries())if(a.status==="fulfilled")s.push(a.value);else{let i=e[o];n.error({error:a.reason},`\u274C Failed to create worktree for ${i}`)}return s},Dt=e=>{if(e.length>0){n.info("\u2705 Created git worktrees:");for(let r of e)n.info(r);n.info("")}else n.info("\u2139\uFE0F No new git worktrees to create")},Lt={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" follow-up prompts are unreachable without a TTY, and the CLI confirmation is auto-skipped for MCP calls.',inputSchema:{all:M.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:M.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:M.boolean().optional().describe("Open each created worktree in Cursor. Defaults to false in MCP mode (the follow-up prompt is not shown)."),githubDesktop:M.boolean().optional().describe("Open each created worktree in GitHub Desktop. Defaults to false in MCP mode (the follow-up prompt is not shown).")},outputSchema:{createdWorktrees:M.array(M.string()).describe("List of created git worktree branches"),count:M.number().describe("Number of git worktrees created")},handler:Ne};import{z as X}from"zod";var Oe=async()=>{let e=await P("release");if(e.length===0)return n.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([y(),w()]),s=new Map(r.map(c=>[c.branch,v(c.title)])),o=e.map(c=>{let m=c.replace("release/",""),d=s.get(c)||"regular",u=t.get(m)||null;return{version:m,type:d,description:u}}),a=Math.max(...o.map(c=>c.version.length)),i=o.map(c=>{let m=z(c.version,c.type,a);return c.description?`${m} ${c.description}`:m});n.info("\u{1F33F} Active worktrees:"),n.info(`
38
- ${i.join(`
31
+ `),n.info(`Added infra-kit shell functions to ${e}`),n.info("Run `source ~/.zshrc` or open a new terminal to activate.")},Lt=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"),xr=(e,r,t)=>{let s=e.indexOf(r),o=e.indexOf(t);if(s===-1||o===-1)return null;let i=e.slice(0,s).replace(/\n+$/,""),a=e.slice(o+t.length).replace(/^\n+/,"");return i+(a?`
32
+ ${a}`:"")},Dt=e=>{let r=xr(e,Tr,Cr);if(r!==null)return r;for(let[p,c]of Nt){let m=xr(e,p,c);if(m!==null)return m}let t=e.indexOf(Ot);if(t===-1)return e;let s=e.slice(0,t).replace(/\n+$/,""),o=e.slice(t).split(`
33
+ `),i=0;for(;i<o.length&&Lt(o[i]);)i++;let a=o.slice(i).join(`
34
+ `);return s+(a?`
35
+ ${a}`:"")},Mt=()=>{let e="pnpm exec infra-kit";return[Tr,"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",Cr].join(`
36
+ `)};import Ir from"@inquirer/confirm";import Jt from"@inquirer/select";import $r from"node:process";import{z as S}from"zod";import{$ as ir,question as _r}from"zx";var Fe=async e=>{let{version:r,description:t,type:s,confirmedCommand:o,checkout:i}=e;l.start("release-create");let a=r,p=t,c=s||"regular",m=i,u=await U();a||(l.setInteractive(),a=await _r("Enter version (e.g. 1.2.5): ")),(!a||a.trim()==="")&&(n.error("No version provided. Exiting..."),$r.exit(1));let d=a.trim();l.addOption("--version",d),s||(l.setInteractive(),c=await Jt({message:"Select release type:",choices:[{name:"regular",value:"regular"},{name:"hotfix",value:"hotfix"}],default:"regular"})),l.addOption("--type",c),p===void 0&&(l.setInteractive(),p=await _r("Enter description (optional, press Enter to skip): "),p.trim()===""&&(p="")),p&&l.addOption("--description",p);let h=o?!0:await Ir({message:`Are you sure you want to create release branch for version ${d}?`});o||l.setInteractive(),h||(n.info("Operation cancelled. Exiting..."),$r.exit(0)),l.addOption("--yes",!0),await ue(c);let f=await de({version:d,jiraConfig:u,description:p,type:c});n.info(`\u2705 Successfully created release: v${d}`),n.info(`\u{1F517} GitHub PR: ${f.prUrl}`),n.info(`\u{1F517} Jira Version: ${f.jiraVersionUrl}`),m===void 0&&(l.setInteractive(),m=await Ir({message:`Do you want to checkout to the created branch ${f.branchName}?`,default:!0})),m||l.addOption("--no-checkout",!0),m&&(ir.quiet=!0,await ir`git switch ${f.branchName}`,ir.quiet=!1,n.info(`\u{1F504} Switched to branch ${f.branchName}`)),l.print();let _={version:d,type:c,branchName:f.branchName,prUrl:f.prUrl,jiraVersionUrl:f.jiraVersionUrl,isCheckedOut:m};return{content:[{type:"text",text:JSON.stringify(_,null,2)}],structuredContent:_}},jt={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:S.string().describe('Version to create (e.g., "1.2.5"). Required for MCP calls.'),description:S.string().optional().describe("Optional description for the Jira version"),type:S.enum(["regular","hotfix"]).optional().default("regular").describe('Release type: "regular" or "hotfix" (default: "regular")'),checkout:S.boolean().optional().default(!0).describe("Checkout to the created branch (default: true)")},outputSchema:{version:S.string().describe("Version number"),type:S.enum(["regular","hotfix"]).describe("Release type"),branchName:S.string().describe("Release branch name"),prUrl:S.string().describe("GitHub PR URL"),jiraVersionUrl:S.string().describe("Jira version URL"),isCheckedOut:S.boolean().describe("Whether the branch was checked out")},handler:Fe};import Ft from"@inquirer/confirm";import Vt from"@inquirer/select";import Er from"node:process";import{z as R}from"zod";import{question as Wt}from"zx";var Bt=async e=>{let{versions:r,type:t,confirmedCommand:s}=e,o=r,i=t||"regular";o||(l.setInteractive(),o=await Wt("Enter versions by comma (e.g. 1.2.5, 1.2.6): "));let a=o.split(",").map(c=>c.trim()).filter(Boolean);l.addOption("--versions",a.join(", ")),a.length===0&&(n.error("No versions provided. Exiting..."),Er.exit(1)),t||(l.setInteractive(),i=await Vt({message:"Select release type:",choices:[{name:"regular",value:"regular"},{name:"hotfix",value:"hotfix"}],default:"regular"})),l.addOption("--type",i),a.length===1&&n.warn('\u{1F4A1} You are creating only one release. Consider using "create-release" command for single releases.');let p=s?!0:await Ft({message:`Are you sure you want to create release branches for these versions: ${a.join(", ")}?`});return s||l.setInteractive(),p||(n.info("Operation cancelled. Exiting..."),Er.exit(0)),l.addOption("--yes",!0),{versionsList:a,type:i}},Ve=async e=>{l.start("release-create-batch");let r=await U(),{versionsList:t,type:s}=await Bt(e);await ue(s);let o=[],i=[];for(let m of t)try{let u=await de({version:m,jiraConfig:r,type:s});o.push(u),n.info(`\u2705 Successfully created release: v${m}`),n.info(`\u{1F517} GitHub PR: ${u.prUrl}`),n.info(`\u{1F517} Jira Version: ${u.jiraVersionUrl}
37
+ `)}catch(u){let d=u instanceof Error?u.message:String(u);i.push({version:m,error:d}),n.error(`\u274C Failed to create release: v${m}`),n.error(` Error: ${d}
38
+ `)}let a=o.length,p=i.length;a===t.length?n.info(`\u2705 All ${t.length} release branches were created successfully.`):a>0?(n.warn(`\u26A0\uFE0F ${a} of ${t.length} release branches were created successfully.`),n.warn(`\u274C ${p} release(s) failed.`)):n.error(`\u274C All ${t.length} release branches failed to create.`),l.print();let c={createdBranches:o.map(m=>m.branchName),successCount:a,failureCount:p,releases:o,failedReleases:i};return{content:[{type:"text",text:JSON.stringify(c,null,2)}],structuredContent:c}},Kt={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:R.string().describe('Comma-separated list of versions to create (e.g., "1.2.5, 1.2.6"). Required for MCP calls.'),type:R.enum(["regular","hotfix"]).optional().default("regular").describe('Release type: "regular" or "hotfix" (default: "regular")')},outputSchema:{createdBranches:R.array(R.string()).describe("List of created release branches"),successCount:R.number().describe("Number of releases created successfully"),failureCount:R.number().describe("Number of releases that failed"),releases:R.array(R.object({version:R.string().describe("Version number"),type:R.enum(["regular","hotfix"]).describe("Release type"),branchName:R.string().describe("Release branch name"),prUrl:R.string().describe("GitHub PR URL"),jiraVersionUrl:R.string().describe("Jira version URL")})).describe("Detailed information for each created release with URLs"),failedReleases:R.array(R.object({version:R.string().describe("Version number that failed"),error:R.string().describe("Error message")})).describe("List of releases that failed with error messages")},handler:Ve};import Gt from"@inquirer/checkbox";import We from"@inquirer/confirm";import Ut from"node:process";import{z as L}from"zod";import{$ as Z}from"zx";import{$ as X}from"zx";var ar=async e=>{let{cwd:r,title:t}=e;await X`cmux new-workspace --cwd ${r}`;let s=(await X`cmux current-workspace`).stdout.trim(),o=(await X`cmux list-pane-surfaces --workspace ${s}`).stdout,i=qt(o);await X`cmux new-split right --workspace ${s} --surface ${i}`,await X`cmux new-split down --workspace ${s} --surface ${i}`,t&&await X`cmux rename-workspace --workspace ${s} ${t}`},qt=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]};var zt="feature",Ht="release",Yt="release/v",Be=async e=>{let{confirmedCommand:r,all:t,versions:s,cursor:o,githubDesktop:i,cmux:a}=e;l.start("worktrees-add");try{let p=await N("release"),m=`${await T()}${q}`;await Ar(`${m}/${Ht}`),await Ar(`${m}/${zt}`);let u=[];if(s)u=s.split(",").map(x=>`release/v${x.trim()}`);else{let x=await y(),J=x.map(re=>re.branch);if(J.length===0)return n.info("\u2139\uFE0F No open release branches found"),l.print(),{content:[{type:"text",text:JSON.stringify({createdWorktrees:[],count:0},null,2)}],structuredContent:{createdWorktrees:[],count:0}};if(t)u=J;else{l.setInteractive();let re=new Map(x.map(mr=>[mr.branch,v(mr.title)])),Nr=await w();u=await Gt({required:!0,message:"\u{1F33F} Select release branches",choices:k({branches:J,descriptions:Nr,types:re})})}}t?l.addOption("--all",!0):l.addOption("--versions",u.map(x=>x.replace("release/v","")));let d=r?!0:await We({message:"Are you sure you want to proceed with these worktree changes?"});r||l.setInteractive(),d||(n.info("Operation cancelled. Exiting..."),Ut.exit(0)),r||l.addOption("--yes",!0);let h=o??await We({message:"Open created worktrees in Cursor?"});typeof o>"u"&&l.setInteractive(),h?l.addOption("--cursor",!0):l.addOption("--no-cursor",!0);let f=i??await We({message:"Open created worktrees in GitHub Desktop?"});typeof i>"u"&&l.setInteractive(),f?l.addOption("--github-desktop",!0):l.addOption("--no-github-desktop",!0);let _=a??await We({message:"Open created worktrees in cmux?"});typeof a>"u"&&l.setInteractive(),_?l.addOption("--cmux",!0):l.addOption("--no-cmux",!0);let{branchesToCreate:P}=Xt({selectedReleaseBranches:u,currentWorktrees:p}),E=await Zt(P,m);if(Qt(E),h)for(let x of E)await Z`cursor ${m}/${x}`;if(f)for(let x of E)await Z`github ${m}/${x}`,await Z`sleep 5`;if(_){let x=await Ye();for(let J of E){let re=J.replace("release/","");await ar({cwd:`${m}/${J}`,title:`${x} ${re}`})}}l.print();let D={createdWorktrees:E,count:E.length};return{content:[{type:"text",text:JSON.stringify(D,null,2)}],structuredContent:D}}catch(p){throw n.error({error:p},"\u274C Error managing worktrees"),p}},Ar=async e=>{await Z`mkdir -p ${e}`},Xt=e=>{let{selectedReleaseBranches:r,currentWorktrees:t}=e,s=t.filter(i=>i.startsWith(Yt));return{branchesToCreate:r.filter(i=>!s.includes(i))}},Zt=async(e,r)=>{let t=await Promise.allSettled(e.map(async o=>{let i=`${r}/${o}`;return await Z`git worktree add ${i} ${o}`,await Z({cwd:i})`pnpm install`,o})),s=[];for(let[o,i]of t.entries())if(i.status==="fulfilled")s.push(i.value);else{let a=e[o];n.error({error:i.reason},`\u274C Failed to create worktree for ${a}`)}return s},Qt=e=>{if(e.length>0){n.info("\u2705 Created git worktrees:");for(let r of e)n.info(r);n.info("")}else n.info("\u2139\uFE0F No new git worktrees to create")},eo={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:L.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:L.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:L.boolean().optional().describe("Open each created worktree in Cursor. Defaults to false in MCP mode (the follow-up prompt is not shown)."),githubDesktop:L.boolean().optional().describe("Open each created worktree in GitHub Desktop. Defaults to false in MCP mode (the follow-up prompt is not shown)."),cmux:L.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:L.array(L.string()).describe("List of created git worktree branches"),count:L.number().describe("Number of git worktrees created")},handler:Be};import{z as Q}from"zod";var Ke=async()=>{let e=await N("release");if(e.length===0)return n.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([y(),w()]),s=new Map(r.map(c=>[c.branch,v(c.title)])),o=e.map(c=>{let m=c.replace("release/",""),u=s.get(c)||"regular",d=t.get(m)||null;return{version:m,type:u,description:d}}),i=Math.max(...o.map(c=>c.version.length)),a=o.map(c=>{let m=z(c.version,c.type,i);return c.description?`${m} ${c.description}`:m});n.info("\u{1F33F} Active worktrees:"),n.info(`
39
+ ${a.join(`
39
40
  `)}
40
- `);let p={worktrees:o,count:o.length};return{content:[{type:"text",text:JSON.stringify(p,null,2)}],structuredContent:p}},Mt={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:X.array(X.object({version:X.string().describe("Release version"),type:X.enum(["regular","hotfix"]).describe("Release type"),description:X.string().nullable().describe("Jira version description")})).describe("List of all worktrees with details"),count:X.number().describe("Number of worktrees")},handler:Oe};import Jt from"@inquirer/checkbox";import jt from"@inquirer/confirm";import Ft from"node:process";import{z as pe}from"zod";import{$ as Xe}from"zx";var De=async e=>{let{confirmedCommand:r,all:t,versions:s}=e;l.start("worktrees-remove");try{let o=await P("release");if(o.length===0)return n.info("\u2139\uFE0F No active worktrees to remove"),l.print(),{content:[{type:"text",text:JSON.stringify({removedWorktrees:[],count:0},null,2)}],structuredContent:{removedWorktrees:[],count:0}};let i=`${await $()}${K}`,p=[];if(t)p=o;else if(s)p=s.split(",").map(h=>`release/v${h.trim()}`);else{l.setInteractive();let[h,f]=await Promise.all([w(),y()]),x=new Map(f.map(A=>[A.branch,v(A.title)]));p=await Jt({required:!0,message:"\u{1F33F} Select release branches",choices:T({branches:o,descriptions:h,types:x})})}p.length===o.length?l.addOption("--all",!0):l.addOption("--versions",p.map(h=>h.replace("release/v","")));let m=r?!0:await jt({message:"Are you sure you want to proceed with these worktree changes?"});r||l.setInteractive(),m||(n.info("Operation cancelled. Exiting..."),Ft.exit(0)),r||l.addOption("--yes",!0);let d=await Vt(p,i);Wt(d),l.print();let u={removedWorktrees:d,count:d.length};return{content:[{type:"text",text:JSON.stringify(u,null,2)}],structuredContent:u}}catch(o){throw n.error({error:o},"\u274C Error managing worktrees"),o}},Vt=async(e,r)=>{let t=await Promise.allSettled(e.map(async o=>{let a=`${r}/${o}`;return await Xe`git worktree remove ${a}`,o})),s=[];for(let[o,a]of t.entries())if(a.status==="fulfilled")s.push(a.value);else{let i=e[o];n.error({error:a.reason},`\u274C Failed to remove worktree for ${i}`)}return s.length===e.length&&(await Xe`git worktree prune`,await Xe`rm -rf ${r}`,n.info(`\u{1F5D1}\uFE0F Removed worktree folder: ${r}`),n.info("")),s},Wt=e=>{if(e.length>0){n.info("\u274C Removed worktrees:");for(let r of e)n.info(r);n.info("")}else n.info("\u2139\uFE0F No unused worktrees to remove")},Bt={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:pe.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:pe.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:pe.array(pe.string()).describe("List of removed git worktree branches"),count:pe.number().describe("Number of git worktrees removed")},handler:De};import Kt from"@inquirer/confirm";import qt from"node:process";import{z as Ze}from"zod";import{$ as Gt}from"zx";var zt="release/v",Le=async e=>{let{confirmedCommand:r}=e;l.start("worktrees-sync");try{let t=await P("release"),o=`${await $()}${K}`,a=await Te(),i=r?!0:await Kt({message:"Are you sure you want to proceed with these worktree changes?"});r||l.setInteractive(),i||(n.info("Operation cancelled. Exiting..."),qt.exit(0)),r||l.addOption("--yes",!0);let{branchesToRemove:p}=Ut({releasePRsList:a,currentWorktrees:t}),c=await Ht(p,o);Yt(c),l.print();let m={removedWorktrees:c,count:c.length};return{content:[{type:"text",text:JSON.stringify(m,null,2)}],structuredContent:m}}catch(t){throw n.error({error:t},"\u274C Error managing worktrees"),t}},Ut=e=>{let{releasePRsList:r,currentWorktrees:t}=e;return{branchesToRemove:t.filter(a=>a.startsWith(zt)).filter(a=>!r.includes(a))}},Ht=async(e,r)=>{let t=[];for(let s of e)try{let o=`${r}/${s}`;await Gt`git worktree remove ${o}`,t.push(s)}catch(o){n.error({error:o,branch:s},`\u274C Failed to remove worktree for ${s}`)}return t},Yt=e=>{if(e.length>0){n.info("\u274C Removed worktrees:");for(let r of e)n.info(r);n.info("")}else n.info("\u2139\uFE0F No unused worktrees to remove")},Xt={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:Ze.array(Ze.string()).describe("List of removed worktree branches"),count:Ze.number().describe("Number of worktrees removed during sync")},handler:Le};var g=new Qt;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 Ce({all:e.all,confirmedCommand:e.yes})});g.command("release-list").description("List all release branches").action(async()=>{await Ae()});g.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 br("-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 Ee({version:e.version,description:e.description,type:e.type,confirmedCommand:e.yes,checkout:e.checkout})});g.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 br("-t, --type <type>","Release type (default: regular)").choices(["regular","hotfix"])).option("-y, --yes","Skip confirmation prompt").action(async e=>{await Pe({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 $e({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 _e({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 Ie({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 Le({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","Open created worktrees in Cursor").option("--no-cursor","Skip Cursor prompt").option("-g, --github-desktop","Open created worktrees in GitHub Desktop").option("--no-github-desktop","Skip GitHub Desktop prompt").action(async e=>{await Ne({confirmedCommand:e.yes,all:e.all,versions:e.versions,cursor:e.cursor,githubDesktop:e.githubDesktop})});g.command("worktrees-list").description("List all git worktrees with detailed information").action(async()=>{await Oe()});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 De({confirmedCommand:e.yes,all:e.all,versions:e.versions})});g.command("doctor").description("Check installation and authentication status of gh and doppler CLIs").action(async()=>{await me()});g.command("env-status").description("Show Doppler authentication status and detected project info").action(async()=>{await ye()});g.command("env-list").description("List available Doppler configs for the detected project").action(async()=>{await ge()});g.command("init").description("Inject shell integration into your profile .zshrc").action(async()=>{await Ue()});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 ve({config:e.config})});g.command("env-clear").description("Clear loaded env vars. Source the returned file path to apply.").action(async()=>{await he()});if(Rr.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-remove","worktrees-sync"],t=["doctor","init","env-status","env-list","env-load","env-clear"],s=new Map(g.commands.map(c=>[c.name(),c])),o=[...e,...r,...t],a=Math.max(...o.map(c=>c.length)),i=c=>c.filter(m=>s.has(m)).map(m=>({name:`${m.padEnd(a)} ${s.get(m).description()}`,value:m})),p=await Zt({message:"Select a command to run",choices:[new Z(" "),new Z("\u2014 Release Management \u2014"),...i(e),new Z(" "),new Z("\u2014 Worktrees \u2014"),...i(r),new Z(" "),new Z("\u2014 Environment \u2014"),...i(t)]},{output:Rr.stderr});g.parse(["node","infra-kit",p])}else g.parse();
41
+ `);let p={worktrees:o,count:o.length};return{content:[{type:"text",text:JSON.stringify(p,null,2)}],structuredContent:p}},ro={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:Q.array(Q.object({version:Q.string().describe("Release version"),type:Q.enum(["regular","hotfix"]).describe("Release type"),description:Q.string().nullable().describe("Jira version description")})).describe("List of all worktrees with details"),count:Q.number().describe("Number of worktrees")},handler:Ke};import to from"@inquirer/checkbox";import oo from"@inquirer/confirm";import so from"node:process";import{z as ge}from"zod";import{$ as cr}from"zx";var qe=async e=>{let{confirmedCommand:r,all:t,versions:s}=e;l.start("worktrees-remove");try{let o=await N("release");if(o.length===0)return n.info("\u2139\uFE0F No active worktrees to remove"),l.print(),{content:[{type:"text",text:JSON.stringify({removedWorktrees:[],count:0},null,2)}],structuredContent:{removedWorktrees:[],count:0}};let a=`${await T()}${q}`,p=[];if(t)p=o;else if(s)p=s.split(",").map(h=>`release/v${h.trim()}`);else{l.setInteractive();let[h,f]=await Promise.all([w(),y()]),_=new Map(f.map(P=>[P.branch,v(P.title)]));p=await to({required:!0,message:"\u{1F33F} Select release branches",choices:k({branches:o,descriptions:h,types:_})})}p.length===o.length?l.addOption("--all",!0):l.addOption("--versions",p.map(h=>h.replace("release/v","")));let m=r?!0:await oo({message:"Are you sure you want to proceed with these worktree changes?"});r||l.setInteractive(),m||(n.info("Operation cancelled. Exiting..."),so.exit(0)),r||l.addOption("--yes",!0);let u=await no(p,a);io(u),l.print();let d={removedWorktrees:u,count:u.length};return{content:[{type:"text",text:JSON.stringify(d,null,2)}],structuredContent:d}}catch(o){throw n.error({error:o},"\u274C Error managing worktrees"),o}},no=async(e,r)=>{let t=await Promise.allSettled(e.map(async o=>{let i=`${r}/${o}`;return await cr`git worktree remove ${i}`,o})),s=[];for(let[o,i]of t.entries())if(i.status==="fulfilled")s.push(i.value);else{let a=e[o];n.error({error:i.reason},`\u274C Failed to remove worktree for ${a}`)}return s.length===e.length&&(await cr`git worktree prune`,await cr`rm -rf ${r}`,n.info(`\u{1F5D1}\uFE0F Removed worktree folder: ${r}`),n.info("")),s},io=e=>{if(e.length>0){n.info("\u274C Removed worktrees:");for(let r of e)n.info(r);n.info("")}else n.info("\u2139\uFE0F No unused worktrees to remove")},ao={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:ge.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:ge.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:ge.array(ge.string()).describe("List of removed git worktree branches"),count:ge.number().describe("Number of git worktrees removed")},handler:qe};import co from"@inquirer/confirm";import lo from"node:process";import{z as lr}from"zod";import{$ as po}from"zx";var mo="release/v",Ge=async e=>{let{confirmedCommand:r}=e;l.start("worktrees-sync");try{let t=await N("release"),o=`${await T()}${q}`,i=await Ne(),a=r?!0:await co({message:"Are you sure you want to proceed with these worktree changes?"});r||l.setInteractive(),a||(n.info("Operation cancelled. Exiting..."),lo.exit(0)),r||l.addOption("--yes",!0);let{branchesToRemove:p}=uo({releasePRsList:i,currentWorktrees:t}),c=await fo(p,o);ho(c),l.print();let m={removedWorktrees:c,count:c.length};return{content:[{type:"text",text:JSON.stringify(m,null,2)}],structuredContent:m}}catch(t){throw n.error({error:t},"\u274C Error managing worktrees"),t}},uo=e=>{let{releasePRsList:r,currentWorktrees:t}=e;return{branchesToRemove:t.filter(i=>i.startsWith(mo)).filter(i=>!r.includes(i))}},fo=async(e,r)=>{let t=[];for(let s of e)try{let o=`${r}/${s}`;await po`git worktree remove ${o}`,t.push(s)}catch(o){n.error({error:o,branch:s},`\u274C Failed to remove worktree for ${s}`)}return t},ho=e=>{if(e.length>0){n.info("\u274C Removed worktrees:");for(let r of e)n.info(r);n.info("")}else n.info("\u2139\uFE0F No unused worktrees to remove")},go={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:lr.array(lr.string()).describe("List of removed worktree branches"),count:lr.number().describe("Number of worktrees removed during sync")},handler:Ge};var g=new yo,Sr=async e=>{try{e?await g.parseAsync(e):await g.parseAsync()}catch(r){let t=r instanceof Error?r.message:String(r);n.error(t),pr.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 Oe({all:e.all,confirmedCommand:e.yes})});g.command("release-list").description("List all release branches").action(async()=>{await Je()});g.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 Pr("-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 Fe({version:e.version,description:e.description,type:e.type,confirmedCommand:e.yes,checkout:e.checkout})});g.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 Pr("-t, --type <type>","Release type (default: regular)").choices(["regular","hotfix"])).option("-y, --yes","Skip confirmation prompt").action(async e=>{await Ve({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 De({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 Me({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 Le({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 Ge({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","Open created worktrees in Cursor").option("--no-cursor","Skip Cursor prompt").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 Be({confirmedCommand:e.yes,all:e.all,versions:e.versions,cursor:e.cursor,githubDesktop:e.githubDesktop,cmux:e.cmux})});g.command("worktrees-list").description("List all git worktrees with detailed information").action(async()=>{await Ke()});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 qe({confirmedCommand:e.yes,all:e.all,versions:e.versions})});g.command("doctor").description("Check installation and authentication status of gh and doppler CLIs").action(async()=>{await ve()});g.command("env-status").description("Show Doppler authentication status and detected project info").action(async()=>{await $e()});g.command("env-list").description("List available Doppler configs for the detected project").action(async()=>{await Te()});g.command("init").description("Inject shell integration into your profile .zshrc").action(async()=>{await nr()});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 Ie({config:e.config})});g.command("env-clear").description("Clear loaded env vars. Source the returned file path to apply.").action(async()=>{await xe()});if(pr.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-remove","worktrees-sync"],t=["doctor","init","env-status","env-list","env-load","env-clear"],s=new Map(g.commands.map(c=>[c.name(),c])),o=[...e,...r,...t],i=Math.max(...o.map(c=>c.length)),a=c=>c.filter(m=>s.has(m)).map(m=>({name:`${m.padEnd(i)} ${s.get(m).description()}`,value:m})),p=await vo({message:"Select a command to run",choices:[new ee(" "),new ee("\u2014 Release Management \u2014"),...a(e),new ee(" "),new ee("\u2014 Worktrees \u2014"),...a(r),new ee(" "),new ee("\u2014 Environment \u2014"),...a(t)]},{output:pr.stderr});await Sr(["node","infra-kit",p])}else await Sr();
41
42
  //# sourceMappingURL=cli.js.map