infra-kit 0.1.100 → 0.1.101

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.
@@ -1 +1,2 @@
1
1
  {"t":0,"agent":"a353f93","agent_type":"unknown","event":"agent_stop","success":true}
2
+ {"t":0,"agent":"a573bb5","agent_type":"unknown","event":"agent_stop","success":true}
@@ -3,5 +3,5 @@
3
3
  "total_spawned": 0,
4
4
  "total_completed": 0,
5
5
  "total_failed": 0,
6
- "last_updated": "2026-05-13T08:11:24.346Z"
6
+ "last_updated": "2026-05-13T08:14:26.351Z"
7
7
  }
package/dist/cli.js CHANGED
@@ -1,12 +1,12 @@
1
- import Dn,{Separator as ye}from"@inquirer/select";import{Command as jn}from"commander";import Zr from"node:process";import xr from"node:fs/promises";import fo from"node:os";import go from"node:path";import nt from"node:process";import{$ as ho}from"zx";import Cr from"node:fs/promises";import zt from"node:os";import We from"node:path";import Gt from"yaml";import{z as y}from"zod/v4";import Bt from"node:path";import{$ as et}from"zx";var N=async e=>{let t=(await et`git worktree list`).stdout.split(`
1
+ import Dn,{Separator as ye}from"@inquirer/select";import{Command as jn}from"commander";import Zr from"node:process";import xr from"node:fs/promises";import fo from"node:os";import ho from"node:path";import nt from"node:process";import{$ as go}from"zx";import Cr from"node:fs/promises";import zt from"node:os";import We from"node:path";import Gt from"yaml";import{z as y}from"zod/v4";import Bt from"node:path";import{$ as et}from"zx";var N=async e=>{let t=(await et`git worktree list`).stdout.split(`
2
2
  `).filter(Boolean),o={release:Kt,feature:qt};return t.map(o[e]).filter(s=>s!==null)},rt=e=>{let r=e.trimEnd();if(!r.endsWith("]"))return null;let t=r.lastIndexOf("[");if(t===-1)return null;let o=r.slice(t+1,-1);return o.length>0?o:null},Kt=e=>{let r=rt(e);return r?.startsWith("release/v")?r:null},qt=e=>{let r=rt(e);return r?.startsWith("feature/")?r:null},S=async()=>(await et`git rev-parse --show-toplevel`).stdout.trim(),D=async()=>{let e=await S();return Bt.basename(e)};var tt="infra-kit.yml",Ut=".infra-kit",Ht="config.yml",Xt="projects",Yt=y.object({provider:y.literal("doppler"),config:y.object({name:y.string().min(1)})}),Zt=y.discriminatedUnion("provider",[Yt]),Qt=y.object({mode:y.enum(["workspace","windows"]).default("workspace"),workspaceConfigPath:y.string().min(1).optional()}).refine(e=>e.mode!=="workspace"||!!e.workspaceConfigPath,{message:'workspaceConfigPath is required when mode is "workspace"',path:["workspaceConfigPath"]}),eo=y.object({provider:y.literal("cursor"),config:Qt}),ro=y.discriminatedUnion("provider",[eo]),to=y.object({provider:y.literal("jira"),config:y.object({baseUrl:y.string().url(),projectId:y.number().int().positive()})}),oo=y.discriminatedUnion("provider",[to]),so=y.object({openInGithubDesktop:y.boolean().optional(),openInCmux:y.boolean().optional()}),st=y.object({environments:y.array(y.string().min(1)).min(1),envManagement:Zt,ide:ro.optional(),taskManager:oo.optional(),worktrees:so.optional()}),no=st.partial(),re=null,U=async()=>{let e=await S(),r=await D(),t=We.join(zt.homedir(),Ut);return{main:We.join(e,tt),userGlobal:We.join(t,Ht),userProject:We.join(t,Xt,r,tt),projectName:r}},R=async()=>{let e=await U(),r;try{r=await Cr.stat(e.main)}catch{throw re=null,new Error(`infra-kit.yml not found at ${e.main}`)}let[t,o]=await Promise.all([ot(e.userGlobal),ot(e.userProject)]),s={main:Number(r.mtimeMs),userGlobal:t?Number(t.mtimeMs):null,userProject:o?Number(o.mtimeMs):null};if(re&&ao(re.mtimes,s))return re.value;let n=[{label:"infra-kit.yml",path:e.main,required:!0},{label:"~/.infra-kit/config.yml",path:e.userGlobal,required:!1},{label:`~/.infra-kit/projects/${e.projectName}/infra-kit.yml`,path:e.userProject,required:!1}],i={};for(let c of n){let p=await co(c);p!==null&&(i={...i,...p})}let l=st.safeParse(i);if(!l.success)throw new Error(`Invalid merged infra-kit config: ${y.prettifyError(l.error)}`);return re={mtimes:s,value:l.data},l.data},ke=()=>{re=null},ot=async e=>{try{return await Cr.stat(e)}catch{return null}},io=async e=>{try{return await Cr.readFile(e,"utf-8")}catch{return null}},ao=(e,r)=>{let t=Object.keys(e);return t.length!==Object.keys(r).length?!1:t.every(o=>e[o]===r[o])},co=async e=>{let r=await io(e.path);if(r===null){if(e.required)throw new Error(`${e.label} not found at ${e.path}`);return null}let t=Gt.parse(r)??{},o=no.safeParse(t);if(!o.success)throw new Error(`Invalid ${e.label} at ${e.path}: ${y.prettifyError(o.error)}`);return o.data};import lo from"node:process";import po from"pino";import mo from"pino-pretty";var uo=()=>{let e=lo.argv.includes("--debug")?"debug":"info",r=["time","pid","hostname"];return e==="debug"&&r.push("level"),po({level:e},mo({destination:2,ignore:r.join(","),colorize:!0}))},a=uo();var it=async e=>{try{return await xr.access(e),!0}catch{return!1}},at=e=>{let r=fo.homedir();return e.startsWith(r)?`~${e.slice(r.length)}`:e},Tr=async()=>{let e=await U(),r=await Promise.all([{label:"project (committed)",path:e.main},{label:"user global",path:e.userGlobal},{label:"user project",path:e.userProject}].map(async o=>({...o,exists:await it(o.path)})));a.info(`Project name: ${e.projectName}
3
3
  `),a.info(`Config merge chain (later overrides earlier):
4
- `);for(let o of r){let s=o.exists?" [\u2713]":" [ ]";a.info(`${s} ${o.label.padEnd(22)} ${at(o.path)}`)}let t={projectName:e.projectName,layers:r.map(o=>({label:o.label,path:o.path,exists:o.exists}))};return{content:[{type:"text",text:JSON.stringify(t,null,2)}],structuredContent:t}},$r=async()=>{let e=await U(),r=nt.env.EDITOR||nt.env.VISUAL||"vi";if(await xr.mkdir(go.dirname(e.userProject),{recursive:!0}),!await it(e.userProject)){let o=`# infra-kit user override for ${e.projectName} \u2014 ~/.infra-kit/projects/${e.projectName}/infra-kit.yml
4
+ `);for(let o of r){let s=o.exists?" [\u2713]":" [ ]";a.info(`${s} ${o.label.padEnd(22)} ${at(o.path)}`)}let t={projectName:e.projectName,layers:r.map(o=>({label:o.label,path:o.path,exists:o.exists}))};return{content:[{type:"text",text:JSON.stringify(t,null,2)}],structuredContent:t}},$r=async()=>{let e=await U(),r=nt.env.EDITOR||nt.env.VISUAL||"vi";if(await xr.mkdir(ho.dirname(e.userProject),{recursive:!0}),!await it(e.userProject)){let o=`# infra-kit user override for ${e.projectName} \u2014 ~/.infra-kit/projects/${e.projectName}/infra-kit.yml
5
5
  #
6
6
  # Layer 3 (highest precedence) of the config merge chain. Shallow-merged on
7
7
  # top of <repo>/infra-kit.yml and ~/.infra-kit/config.yml \u2014 top-level keys
8
8
  # (environments, envManagement, ide, taskManager, worktrees) replace wholesale.
9
- `;await xr.writeFile(e.userProject,o,"utf-8")}a.info(`Opening ${at(e.userProject)} in ${r}`),await ho({stdio:"inherit"})`${r} ${e.userProject}`,ke();let t={path:e.userProject,editor:r};return{content:[{type:"text",text:JSON.stringify(t,null,2)}],structuredContent:t}};import be from"node:fs";import pt from"node:os";import mt from"node:path";import{z as te}from"zod/v4";import{$ as dt}from"zx";import H from"node:fs";import lt from"node:os";import Pr from"node:path";var Le="# -- infra-kit:begin --",Re="# -- infra-kit:end --",wo=[["# region infra-kit","# endregion infra-kit"]],vo="# infra-kit shell functions",yo=`# infra-kit user-global config \u2014 ~/.infra-kit/config.yml
9
+ `;await xr.writeFile(e.userProject,o,"utf-8")}a.info(`Opening ${at(e.userProject)} in ${r}`),await go({stdio:"inherit"})`${r} ${e.userProject}`,ke();let t={path:e.userProject,editor:r};return{content:[{type:"text",text:JSON.stringify(t,null,2)}],structuredContent:t}};import be from"node:fs";import pt from"node:os";import mt from"node:path";import{z as te}from"zod/v4";import{$ as dt}from"zx";import H from"node:fs";import lt from"node:os";import Pr from"node:path";var Le="# -- infra-kit:begin --",Re="# -- infra-kit:end --",wo=[["# region infra-kit","# endregion infra-kit"]],vo="# infra-kit shell functions",yo=`# infra-kit user-global config \u2014 ~/.infra-kit/config.yml
10
10
  #
11
11
  # Merge chain (later layers override earlier ones at top-level keys):
12
12
  # 1. <repo>/infra-kit.yml \u2014 committed project config (required)
@@ -38,57 +38,57 @@ ${i}`:"")},bo=e=>{let r=ct(e,Le,Re);if(r!==null)return r;for(let[l,c]of wo){let
38
38
  `),n=0;for(;n<s.length&&Ro(s[n]);)n++;let i=s.slice(n).join(`
39
39
  `);return o+(i?`
40
40
  ${i}`:"")},Sr=()=>{let e="pnpm exec infra-kit";return[Le,"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",Re].join(`
41
- `)};var g=e=>[{type:"text",text:e}],v=e=>e;var oe=async(e,r,t,o)=>{try{return await dt`${r}`,{name:e,status:"pass",message:t}}catch{return{name:e,status:"fail",message:o}}},Co=()=>{let e="zshrc init block",r=mt.join(pt.homedir(),".zshrc");if(!be.existsSync(r))return{name:e,status:"fail",message:"~/.zshrc not found. Run: infra-kit init"};let t=be.readFileSync(r,"utf-8"),o=t.indexOf(Le),s=t.indexOf(Re);if(o===-1||s===-1||s<o)return{name:e,status:"fail",message:"infra-kit shell block missing from ~/.zshrc. Run: infra-kit init"};let n=t.slice(o,s+Re.length).trim(),i=Sr().trim();return n!==i?{name:e,status:"fail",message:"infra-kit shell block in ~/.zshrc is out of date. Run: infra-kit init"}:{name:e,status:"pass",message:"infra-kit shell block in ~/.zshrc is up to date"}},xo=async()=>{let e="pnpm enableGlobalVirtualStore";try{let r=await S(),t=mt.join(r,"pnpm-workspace.yaml");if(!be.existsSync(t))return{name:e,status:"fail",message:`pnpm-workspace.yaml not found at ${t}`};let o=be.readFileSync(t,"utf-8");return/^\s*enableGlobalVirtualStore\s*:\s*true\s*$/m.test(o)?{name:e,status:"pass",message:"enableGlobalVirtualStore: true is set"}:{name:e,status:"fail",message:"enableGlobalVirtualStore: true is missing in pnpm-workspace.yaml"}}catch(r){return{name:e,status:"fail",message:`Failed to read pnpm-workspace.yaml: ${r.message}`}}},To=async()=>{let e="infra-kit config valid";try{return ke(),await R(),{name:e,status:"pass",message:"infra-kit.yml is valid (user overrides applied if present)"}}catch(r){return{name:e,status:"fail",message:r.message}}},$o=async()=>{let e="user override path";try{let r=await U(),t=pt.homedir(),o=r.userProject.startsWith(t)?`~${r.userProject.slice(t.length)}`:r.userProject,n=be.existsSync(r.userProject)?"(exists)":"(not yet created)";return{name:e,status:"pass",message:`${o} ${n} \u2014 project: ${r.projectName}`}}catch(r){return{name:e,status:"fail",message:r.message}}},Po=[1,2,3,5,7],Eo=async()=>{let e="rtk configured";try{let t=(await dt`rtk init --show`).stdout.split(`
41
+ `)};var h=e=>[{type:"text",text:e}],v=e=>e;var oe=async(e,r,t,o)=>{try{return await dt`${r}`,{name:e,status:"pass",message:t}}catch{return{name:e,status:"fail",message:o}}},Co=()=>{let e="zshrc init block",r=mt.join(pt.homedir(),".zshrc");if(!be.existsSync(r))return{name:e,status:"fail",message:"~/.zshrc not found. Run: infra-kit init"};let t=be.readFileSync(r,"utf-8"),o=t.indexOf(Le),s=t.indexOf(Re);if(o===-1||s===-1||s<o)return{name:e,status:"fail",message:"infra-kit shell block missing from ~/.zshrc. Run: infra-kit init"};let n=t.slice(o,s+Re.length).trim(),i=Sr().trim();return n!==i?{name:e,status:"fail",message:"infra-kit shell block in ~/.zshrc is out of date. Run: infra-kit init"}:{name:e,status:"pass",message:"infra-kit shell block in ~/.zshrc is up to date"}},xo=async()=>{let e="pnpm enableGlobalVirtualStore";try{let r=await S(),t=mt.join(r,"pnpm-workspace.yaml");if(!be.existsSync(t))return{name:e,status:"fail",message:`pnpm-workspace.yaml not found at ${t}`};let o=be.readFileSync(t,"utf-8");return/^\s*enableGlobalVirtualStore\s*:\s*true\s*$/m.test(o)?{name:e,status:"pass",message:"enableGlobalVirtualStore: true is set"}:{name:e,status:"fail",message:"enableGlobalVirtualStore: true is missing in pnpm-workspace.yaml"}}catch(r){return{name:e,status:"fail",message:`Failed to read pnpm-workspace.yaml: ${r.message}`}}},To=async()=>{let e="infra-kit config valid";try{return ke(),await R(),{name:e,status:"pass",message:"infra-kit.yml is valid (user overrides applied if present)"}}catch(r){return{name:e,status:"fail",message:r.message}}},$o=async()=>{let e="user override path";try{let r=await U(),t=pt.homedir(),o=r.userProject.startsWith(t)?`~${r.userProject.slice(t.length)}`:r.userProject,n=be.existsSync(r.userProject)?"(exists)":"(not yet created)";return{name:e,status:"pass",message:`${o} ${n} \u2014 project: ${r.projectName}`}}catch(r){return{name:e,status:"fail",message:r.message}}},Po=[1,2,3,5,7],Eo=async()=>{let e="rtk configured";try{let t=(await dt`rtk init --show`).stdout.split(`
42
42
  `).map(s=>s.trim()).filter(s=>s.startsWith("[ok]")||s.startsWith("[--]")),o=[];for(let s of Po){let n=t[s-1];(!n||!n.startsWith("[ok]"))&&o.push(s)}return o.length>0?{name:e,status:"fail",message:`rtk setup incomplete (items ${o.join(", ")} not [ok]). Run: rtk init -g --auto-patch`}:{name:e,status:"pass",message:"rtk hook, RTK.md, global CLAUDE.md, settings.json, and Cursor hook are configured"}}catch(r){return{name:e,status:"fail",message:`Failed to run 'rtk init --show': ${r.message}`}}},Je=async()=>{let e=await Promise.all([oe("gh installed",["gh","--version"],"GitHub CLI is installed","GitHub CLI is not installed. Install from: https://cli.github.com/"),oe("gh authenticated",["gh","auth","status"],"GitHub CLI is authenticated","GitHub CLI is not authenticated. Run: gh auth login"),oe("doppler installed",["doppler","--version"],"Doppler CLI is installed","Doppler CLI is not installed. Install from: https://docs.doppler.com/docs/install-cli"),oe("doppler authenticated",["doppler","me"],"Doppler CLI is authenticated","Doppler CLI is not authenticated. Run: doppler login"),oe("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"),oe("rtk installed",["rtk","--version"],"RTK is installed","RTK is not installed. Install from: https://github.com/rtk-ai/rtk"),Eo(),Promise.resolve(Co()),xo(),To(),$o()]);a.info(`Doctor check results:
43
- `);for(let t of e){let o=t.status==="pass"?"[PASS]":"[FAIL]";a.info(` ${o} ${t.name}: ${t.message}`)}let r={checks:e.map(t=>({name:t.name,status:t.status,message:t.message})),allPassed:e.every(t=>t.status==="pass")};return{content:g(JSON.stringify(r,null,2)),structuredContent:r}},So=v({name:"doctor",description:"Check installation and authentication status of gh, doppler, aws, and rtk CLIs",inputSchema:{},outputSchema:{checks:te.array(te.object({name:te.string().describe("Name of the check"),status:te.enum(["pass","fail"]).describe("Check result"),message:te.string().describe("Details about the check result")})).describe("List of all check results"),allPassed:te.boolean().describe("Whether all checks passed")},handler:Je});import _r from"node:fs";import ft from"node:path";import _o from"node:process";import{z as ze}from"zod/v4";import Ce from"node:fs";import Io from"node:os";import Ir from"node:path";import Ar from"node:process";var se="env-load.sh",ut="env-clear.sh",Ve="INFRA_KIT_SESSION",ne="INFRA_KIT_ENV_CONFIG",ie="INFRA_KIT_ENV_PROJECT",ae="INFRA_KIT_ENV_LOADED_AT",Be=/^([A-Z_]\w*)=/i,Ke=e=>{if(!Ce.existsSync(e))return[];let r=Ce.readFileSync(e,"utf-8"),t=[];for(let o of r.split(`
43
+ `);for(let t of e){let o=t.status==="pass"?"[PASS]":"[FAIL]";a.info(` ${o} ${t.name}: ${t.message}`)}let r={checks:e.map(t=>({name:t.name,status:t.status,message:t.message})),allPassed:e.every(t=>t.status==="pass")};return{content:h(JSON.stringify(r,null,2)),structuredContent:r}},So=v({name:"doctor",description:"Check installation and authentication status of gh, doppler, aws, and rtk CLIs",inputSchema:{},outputSchema:{checks:te.array(te.object({name:te.string().describe("Name of the check"),status:te.enum(["pass","fail"]).describe("Check result"),message:te.string().describe("Details about the check result")})).describe("List of all check results"),allPassed:te.boolean().describe("Whether all checks passed")},handler:Je});import _r from"node:fs";import ft from"node:path";import _o from"node:process";import{z as ze}from"zod/v4";import Ce from"node:fs";import Io from"node:os";import Ir from"node:path";import Ar from"node:process";var se="env-load.sh",ut="env-clear.sh",Ve="INFRA_KIT_SESSION",ne="INFRA_KIT_ENV_CONFIG",ie="INFRA_KIT_ENV_PROJECT",ae="INFRA_KIT_ENV_LOADED_AT",Be=/^([A-Z_]\w*)=/i,Ke=e=>{if(!Ce.existsSync(e))return[];let r=Ce.readFileSync(e,"utf-8"),t=[];for(let o of r.split(`
44
44
  `)){let s=Be.exec(o);s&&t.push(s[1])}return t},Ao=()=>{let e=Ar.env.XDG_CACHE_HOME,r=e&&e.length>0?e:Ir.join(Io.homedir(),".cache");return Ir.join(r,"infra-kit")},ce=()=>{let e=Ar.env[Ve];if(!e)throw new Error(`${Ve} is not set. Run \`infra-kit init\` then \`source ~/.zshrc\`.`);return Ir.join(Ao(),e)},qe=(e,r,t)=>{let o=`${e}.tmp.${Ar.pid}`;Ce.writeFileSync(o,r,{mode:t});try{Ce.renameSync(o,e)}catch(s){throw Ce.rmSync(o,{force:!0}),s}},J="-worktrees";var Ge=async()=>{let e=ce(),r=ft.join(e,se);if(!_r.existsSync(r))throw new Error("No loaded environment found. Run `env-load` first.");let t=Ke(r),o=[...t.map(i=>`unset ${i}`),`unset ${ne}`,`unset ${ie}`,`unset ${ae}`],s=ft.resolve(e,ut);_r.mkdirSync(e,{recursive:!0,mode:448}),qe(s,`${o.join(`
45
45
  `)}
46
46
  `,384),_o.stdout.write(`${s}
47
- `),_r.unlinkSync(r);let n={filePath:s,variableCount:t.length,unsetStatements:o};return{content:g(JSON.stringify(n,null,2)),structuredContent:n}},Oo=v({name:"env-clear",description:'Generate a shell script that unsets every env var previously loaded by env-load for this session, plus the infra-kit session metadata vars. Does NOT mutate the calling process. When `infra-kit init` has installed the zsh shell integration, the user\'s terminal auto-sources the unset script on its next prompt (precmd hook) \u2014 so calling this via MCP will clear the vars in the shell that launched Claude Code automatically. Other callers must source "<filePath>" themselves or surface it to the user. Errors if no env is currently loaded.',inputSchema:{},outputSchema:{filePath:ze.string().describe("Path to the file that must be sourced to apply"),variableCount:ze.number().describe("Number of variables cleared"),unsetStatements:ze.array(ze.string()).describe("Unset statements generated")},handler:Ge});import{z as Or}from"zod/v4";var xe=async()=>{let{envManagement:e}=await R();return e.config.name};var Ue=async()=>{let e=await xe(),{environments:r}=await R();a.info(`Doppler project: ${e}
48
- `),a.info("Available configs:");for(let o of r)a.info(` - ${o}`);let t={project:e,configs:r};return{content:g(JSON.stringify(t,null,2)),structuredContent:t}},No=v({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:Or.string().describe("Detected Doppler project name"),configs:Or.array(Or.string()).describe("Available environment configs")},handler:Ue});import jo from"@inquirer/select";import{Buffer as Mo}from"node:buffer";import Fo from"node:fs";import Wo from"node:path";import ht from"node:process";import{z as $e}from"zod/v4";import{$ as He}from"zx";import{$ as gt}from"zx";var Te=async()=>{try{await gt`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 gt`doppler me`}catch(e){throw new Error("Doppler CLI is not authenticated. Run: doppler login",{cause:e})}};var Do=()=>{let e="",r=[],t=!1;return{start(o){e=o,r=[],t=!1},setInteractive(){t=!0},addOption(o,s){r.push({flag:o,value:s})},print(){if(!t||r.length===0)return;let o=r.map(s=>typeof s.value=="boolean"?s.value?s.flag:"":Array.isArray(s.value)?`${s.flag} "${s.value.join(", ")}"`:`${s.flag} "${s.value}"`).filter(Boolean).join(" ");a.info(`\u{1F4DF} Equivalent command:
47
+ `),_r.unlinkSync(r);let n={filePath:s,variableCount:t.length,unsetStatements:o};return{content:h(JSON.stringify(n,null,2)),structuredContent:n}},Oo=v({name:"env-clear",description:'Generate a shell script that unsets every env var previously loaded by env-load for this session, plus the infra-kit session metadata vars. Does NOT mutate the calling process. When `infra-kit init` has installed the zsh shell integration, the user\'s terminal auto-sources the unset script on its next prompt (precmd hook) \u2014 so calling this via MCP will clear the vars in the shell that launched Claude Code automatically. Other callers must source "<filePath>" themselves or surface it to the user. Errors if no env is currently loaded.',inputSchema:{},outputSchema:{filePath:ze.string().describe("Path to the file that must be sourced to apply"),variableCount:ze.number().describe("Number of variables cleared"),unsetStatements:ze.array(ze.string()).describe("Unset statements generated")},handler:Ge});import{z as Or}from"zod/v4";var xe=async()=>{let{envManagement:e}=await R();return e.config.name};var Ue=async()=>{let e=await xe(),{environments:r}=await R();a.info(`Doppler project: ${e}
48
+ `),a.info("Available configs:");for(let o of r)a.info(` - ${o}`);let t={project:e,configs:r};return{content:h(JSON.stringify(t,null,2)),structuredContent:t}},No=v({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:Or.string().describe("Detected Doppler project name"),configs:Or.array(Or.string()).describe("Available environment configs")},handler:Ue});import jo from"@inquirer/select";import{Buffer as Mo}from"node:buffer";import Fo from"node:fs";import Wo from"node:path";import gt from"node:process";import{z as $e}from"zod/v4";import{$ as He}from"zx";import{$ as ht}from"zx";var Te=async()=>{try{await ht`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 ht`doppler me`}catch(e){throw new Error("Doppler CLI is not authenticated. Run: doppler login",{cause:e})}};var Do=()=>{let e="",r=[],t=!1;return{start(o){e=o,r=[],t=!1},setInteractive(){t=!0},addOption(o,s){r.push({flag:o,value:s})},print(){if(!t||r.length===0)return;let o=r.map(s=>typeof s.value=="boolean"?s.value?s.flag:"":Array.isArray(s.value)?`${s.flag} "${s.value.join(", ")}"`:`${s.flag} "${s.value}"`).filter(Boolean).join(" ");a.info(`\u{1F4DF} Equivalent command:
49
49
  pnpm exec infra-kit ${e} ${o}
50
- `)},reset(){e="",r=[],t=!1}}},d=Do();var Xe=async e=>{await Te();let{config:r}=e;d.start("env-load");let t="";if(r)t=r;else{let{environments:f}=await R();d.setInteractive(),t=await jo({message:"Select environment config",choices:f.map(u=>({name:u,value:u}))},{output:ht.stderr})}d.addOption("--config",t);let o=await xe(),s=await Jo(o,t);qo(s);let n=new Date().toISOString(),i=["set -a",s,`${ne}=${Nr(t)}`,`${ie}=${Nr(o)}`,`${ae}=${Nr(n)}`,"set +a"],l=ce(),c=Wo.resolve(l,se);Fo.mkdirSync(l,{recursive:!0,mode:448}),qe(c,`${i.join(`
50
+ `)},reset(){e="",r=[],t=!1}}},d=Do();var Xe=async e=>{await Te();let{config:r}=e;d.start("env-load");let t="";if(r)t=r;else{let{environments:f}=await R();d.setInteractive(),t=await jo({message:"Select environment config",choices:f.map(u=>({name:u,value:u}))},{output:gt.stderr})}d.addOption("--config",t);let o=await xe(),s=await Jo(o,t);qo(s);let n=new Date().toISOString(),i=["set -a",s,`${ne}=${Nr(t)}`,`${ie}=${Nr(o)}`,`${ae}=${Nr(n)}`,"set +a"],l=ce(),c=Wo.resolve(l,se);Fo.mkdirSync(l,{recursive:!0,mode:448}),qe(c,`${i.join(`
51
51
  `)}
52
- `,384),ht.stdout.write(`${c}
53
- `),d.print();let p=Bo(s),m={filePath:c,variableCount:p,project:o,config:t};return{content:g(JSON.stringify(m,null,2)),structuredContent:m}},wt=1024*1024,Lo=3e4,Jo=async(e,r)=>{let t=He.quiet;He.quiet=!0;try{let o=await He`doppler secrets download --no-file --format env --project ${e} --config ${r}`.timeout(Lo);return Vo(o.stdout),o.stdout.trim()}finally{He.quiet=t}},Vo=e=>{let r=Mo.byteLength(e,"utf-8");if(r>wt)throw new Error(`doppler returned unexpectedly large output (${r} bytes > ${wt}) \u2014 refusing to write to disk`)},Bo=e=>e.split(`
52
+ `,384),gt.stdout.write(`${c}
53
+ `),d.print();let p=Bo(s),m={filePath:c,variableCount:p,project:o,config:t};return{content:h(JSON.stringify(m,null,2)),structuredContent:m}},wt=1024*1024,Lo=3e4,Jo=async(e,r)=>{let t=He.quiet;He.quiet=!0;try{let o=await He`doppler secrets download --no-file --format env --project ${e} --config ${r}`.timeout(Lo);return Vo(o.stdout),o.stdout.trim()}finally{He.quiet=t}},Vo=e=>{let r=Mo.byteLength(e,"utf-8");if(r>wt)throw new Error(`doppler returned unexpectedly large output (${r} bytes > ${wt}) \u2014 refusing to write to disk`)},Bo=e=>e.split(`
54
54
  `).filter(r=>Be.test(r)).length,Ko=new Set(["set -a","set +a"]),Nr=e=>`'${e.replaceAll("'","'\\''")}'`,qo=e=>{if(e.trim().length===0)throw new Error("doppler returned empty output for env-load");for(let r of e.split(`
55
55
  `)){let t=r.trim();if(!(t.length===0||Ko.has(t))&&!Be.test(t))throw new Error(`doppler returned unexpected output for env-load (expected KEY=value lines, got: ${JSON.stringify(t.slice(0,80))})`)}},zo=v({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:$e.string().describe('Doppler config / environment name to load (e.g. "dev", "arthur", "renana"). Required for MCP calls.')},outputSchema:{filePath:$e.string().describe("Path to the file that must be sourced to apply variables"),variableCount:$e.number().describe("Number of variables loaded"),project:$e.string().describe("Doppler project name"),config:$e.string().describe("Doppler config name")},handler:Xe});import Go from"node:path";import Pe from"node:process";import{z as le}from"zod/v4";var Ye=async()=>{await Te(),a.info("Environment session status:");let e=ce(),r=Pe.env[Ve],t=Go.join(e,se),o=0,s=0,n=Pe.env[ne]??null,i=Pe.env[ie]??null,l=Pe.env[ae]??null;if(n){let p=Ke(t);p.length>0&&(s=p.length,o=p.filter(f=>f in Pe.env).length);let m=l?.replace(/\.\d{3}Z$/,"")??null;if(a.info(` ${n}: ${o} of ${s} vars loaded (project: ${i}, loadedAt: ${m}, session: ${r})
56
56
  `),s>0&&o<s){let f=s-o;a.warn(` ${f} cached var(s) are not present in the current process \u2014 env-load needs to be re-sourced, or vars were unset manually.`)}}else a.info(` Session ${r}: no env loaded
57
- `);let c={sessionId:r,sessionLoadedCount:o,sessionTotalCount:s,sessionConfig:n,sessionProject:i,sessionLoadedAt:l};return{content:g(JSON.stringify(c,null,2)),structuredContent:c}},Uo=v({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:le.string().describe("Current terminal session ID"),sessionLoadedCount:le.number().describe("Number of cached vars active in the current session"),sessionTotalCount:le.number().describe("Total number of cached var names"),sessionConfig:le.string().nullable().describe("Doppler config name of the loaded session (environment name)"),sessionProject:le.string().nullable().describe("Doppler project name of the loaded session"),sessionLoadedAt:le.string().nullable().describe("ISO 8601 timestamp of when the env was loaded")},handler:Ye});import os from"@inquirer/checkbox";import ss from"@inquirer/confirm";import ns from"node:process";import{z as fe}from"zod/v4";import{$ as j}from"zx";import{$ as Fa}from"zx";import sr from"node:process";import{$ as A}from"zx";import{$ as Se}from"zx";import Ee from"node:process";var Dr=async(e,r)=>{try{let{baseUrl:t,token:o,email:s,projectId:n}=r,i={name:e.name,projectId:e.projectId||n,description:e.description||"",released:e.released||!1,archived:e.archived||!1},l=`${t}/rest/api/3/version`,c=btoa(`${s}:${o}`),p=await fetch(l,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json",Authorization:`Basic ${c}`},body:JSON.stringify(i)});if(!p.ok){let f=await p.text();throw a.error({status:p.status,statusText:p.statusText,error:f},"Failed to create Jira version"),new Error(`HTTP ${p.status}: ${p.statusText}`)}return{success:!0,version:await p.json()}}catch(t){throw a.error({error:t},"Error creating Jira version"),t}},pe=async e=>{try{let{baseUrl:r,token:t,email:o,projectId:s}=e,n=`${r}/rest/api/3/project/${s}/versions`,i=btoa(`${o}:${t}`),l=await fetch(n,{method:"GET",headers:{Accept:"application/json",Authorization:`Basic ${i}`}});if(!l.ok){let p=await l.text();throw a.error({status:l.status,statusText:l.statusText,error:p},"Failed to get Jira project versions"),new Error(`HTTP ${l.status}: ${l.statusText}`)}return await l.json()}catch(r){throw a.error({error:r},"Error getting Jira project versions"),r}},Ze=async(e,r)=>{try{return(await pe(r)).find(s=>s.name===e)||null}catch(t){throw a.error({error:t,versionName:e},"Error finding Jira version by name"),t}},Qe=async(e,r)=>{try{let{baseUrl:t,token:o,email:s}=r,n={};e.released!==void 0&&(n.released=e.released),e.archived!==void 0&&(n.archived=e.archived),e.releaseDate!==void 0&&(n.releaseDate=e.releaseDate),e.description!==void 0&&(n.description=e.description);let i=`${t}/rest/api/3/version/${e.versionId}`,l=btoa(`${s}:${o}`),c=await fetch(i,{method:"PUT",headers:{Accept:"application/json","Content-Type":"application/json",Authorization:`Basic ${l}`},body:JSON.stringify(n)});if(!c.ok){let m=await c.text();throw a.error({status:c.status,statusText:c.statusText,error:m},"Failed to update Jira version"),new Error(`HTTP ${c.status}: ${c.statusText}`)}return{success:!0,version:await c.json()}}catch(t){throw a.error({error:t},"Error updating Jira version"),t}},jr=async(e,r)=>{try{let{versionName:t}=e,o=await Ze(t,r);if(!o)throw a.error({versionName:t},"Jira version not found"),new Error(`Version "${t}" not found in Jira project`);return await Qe({versionId:o.id,released:!0,releaseDate:new Date().toISOString().split("T")[0]},r)}catch(t){throw a.error({error:t},"Error delivering Jira release"),t}},me=async()=>{let e=Ee.env.JIRA_BASE_URL,r=Ee.env.JIRA_TOKEN||Ee.env.JIRA_API_TOKEN,t=Ee.env.JIRA_PROJECT_ID,o=Ee.env.JIRA_EMAIL,s=[];if(e||s.push("JIRA_BASE_URL (e.g., https://your-domain.atlassian.net)"),r||s.push("JIRA_TOKEN or JIRA_API_TOKEN (your Jira API token)"),t||s.push("JIRA_PROJECT_ID (numeric project ID)"),o||s.push("JIRA_EMAIL (your Jira email address)"),s.length>0){let i=["Jira configuration is required but incomplete.","Please configure the following environment variables:",...s.map(l=>` - ${l}`),"","You can set these in your .env file or as environment variables."].join(`
57
+ `);let c={sessionId:r,sessionLoadedCount:o,sessionTotalCount:s,sessionConfig:n,sessionProject:i,sessionLoadedAt:l};return{content:h(JSON.stringify(c,null,2)),structuredContent:c}},Uo=v({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:le.string().describe("Current terminal session ID"),sessionLoadedCount:le.number().describe("Number of cached vars active in the current session"),sessionTotalCount:le.number().describe("Total number of cached var names"),sessionConfig:le.string().nullable().describe("Doppler config name of the loaded session (environment name)"),sessionProject:le.string().nullable().describe("Doppler project name of the loaded session"),sessionLoadedAt:le.string().nullable().describe("ISO 8601 timestamp of when the env was loaded")},handler:Ye});import os from"@inquirer/checkbox";import ss from"@inquirer/confirm";import ns from"node:process";import{z as fe}from"zod/v4";import{$ as j}from"zx";import{$ as Fa}from"zx";import sr from"node:process";import{$ as A}from"zx";import{$ as Se}from"zx";import Ee from"node:process";var Dr=async(e,r)=>{try{let{baseUrl:t,token:o,email:s,projectId:n}=r,i={name:e.name,projectId:e.projectId||n,description:e.description||"",released:e.released||!1,archived:e.archived||!1},l=`${t}/rest/api/3/version`,c=btoa(`${s}:${o}`),p=await fetch(l,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json",Authorization:`Basic ${c}`},body:JSON.stringify(i)});if(!p.ok){let f=await p.text();throw a.error({status:p.status,statusText:p.statusText,error:f},"Failed to create Jira version"),new Error(`HTTP ${p.status}: ${p.statusText}`)}return{success:!0,version:await p.json()}}catch(t){throw a.error({error:t},"Error creating Jira version"),t}},pe=async e=>{try{let{baseUrl:r,token:t,email:o,projectId:s}=e,n=`${r}/rest/api/3/project/${s}/versions`,i=btoa(`${o}:${t}`),l=await fetch(n,{method:"GET",headers:{Accept:"application/json",Authorization:`Basic ${i}`}});if(!l.ok){let p=await l.text();throw a.error({status:l.status,statusText:l.statusText,error:p},"Failed to get Jira project versions"),new Error(`HTTP ${l.status}: ${l.statusText}`)}return await l.json()}catch(r){throw a.error({error:r},"Error getting Jira project versions"),r}},Ze=async(e,r)=>{try{return(await pe(r)).find(s=>s.name===e)||null}catch(t){throw a.error({error:t,versionName:e},"Error finding Jira version by name"),t}},Qe=async(e,r)=>{try{let{baseUrl:t,token:o,email:s}=r,n={};e.released!==void 0&&(n.released=e.released),e.archived!==void 0&&(n.archived=e.archived),e.releaseDate!==void 0&&(n.releaseDate=e.releaseDate),e.description!==void 0&&(n.description=e.description);let i=`${t}/rest/api/3/version/${e.versionId}`,l=btoa(`${s}:${o}`),c=await fetch(i,{method:"PUT",headers:{Accept:"application/json","Content-Type":"application/json",Authorization:`Basic ${l}`},body:JSON.stringify(n)});if(!c.ok){let m=await c.text();throw a.error({status:c.status,statusText:c.statusText,error:m},"Failed to update Jira version"),new Error(`HTTP ${c.status}: ${c.statusText}`)}return{success:!0,version:await c.json()}}catch(t){throw a.error({error:t},"Error updating Jira version"),t}},jr=async(e,r)=>{try{let{versionName:t}=e,o=await Ze(t,r);if(!o)throw a.error({versionName:t},"Jira version not found"),new Error(`Version "${t}" not found in Jira project`);return await Qe({versionId:o.id,released:!0,releaseDate:new Date().toISOString().split("T")[0]},r)}catch(t){throw a.error({error:t},"Error delivering Jira release"),t}},me=async()=>{let e=Ee.env.JIRA_BASE_URL,r=Ee.env.JIRA_TOKEN||Ee.env.JIRA_API_TOKEN,t=Ee.env.JIRA_PROJECT_ID,o=Ee.env.JIRA_EMAIL,s=[];if(e||s.push("JIRA_BASE_URL (e.g., https://your-domain.atlassian.net)"),r||s.push("JIRA_TOKEN or JIRA_API_TOKEN (your Jira API token)"),t||s.push("JIRA_PROJECT_ID (numeric project ID)"),o||s.push("JIRA_EMAIL (your Jira email address)"),s.length>0){let i=["Jira configuration is required but incomplete.","Please configure the following environment variables:",...s.map(l=>` - ${l}`),"","You can set these in your .env file or as environment variables."].join(`
58
58
  `);throw new Error(i)}let n=Number.parseInt(t,10);if(Number.isNaN(n))throw new TypeError(`Invalid JIRA_PROJECT_ID: "${t}" must be a numeric value (e.g., 10001)`);return{baseUrl:e.replace(/\/$/,""),token:r,projectId:n,email:o}},X=async()=>{try{return await me()}catch(e){return a.warn({error:e},"Jira configuration not available, skipping Jira integration"),null}};var er=e=>e==="hotfix"?"main":"dev",Mr=async(e="regular")=>{let r=er(e);Se.quiet=!0,await Se`git fetch origin`,await Se`git switch ${r}`,await Se`git pull origin ${r}`,Se.quiet=!1},Fr=async e=>{let{version:r,jiraConfig:t,description:o,type:s="regular"}=e,n=`v${r}`,i=await Dr({name:n,projectId:t.projectId,description:o||"",released:!1,archived:!1},t),l=`${t.baseUrl}/projects/${i.version.projectId}/versions/${i.version.id}/tab/release-report-all-issues`,c=await rr({version:r,jiraVersionUrl:l,type:s,description:o});return{version:r,type:s,branchName:c.branchName,prUrl:c.prUrl,jiraVersionUrl:l}},T=async()=>{let e=new Map,r=await X();if(!r)return e;try{let t=await pe(r);for(let o of t)o.description&&e.set(o.name,o.description)}catch{}return e},de=(e,r,t)=>{let o=t?" ".repeat(t-e.length+3):" ",s=`[${r}]`.padEnd(11);return`${e}${o}${s}`},b=e=>e.toLowerCase().startsWith("hotfix")?"hotfix":"regular",I=e=>{let{branches:r,descriptions:t,types:o}=e,s=r.map(i=>i.replace("release/v","")),n=Math.max(...s.map(i=>i.length));return r.map((i,l)=>{let c=s[l],p=o?o.get(i)||"regular":void 0,m=t.get(`v${c}`),f=" ".repeat(n-c.length+3),u=p?de(c,p,n):c;return m&&(u=p?`${u} ${m}`:`${c}${f}${m}`),{name:u,value:i}})};import{$ as or}from"zx";var V=e=>e.replace("release/","").slice(1).split(".").map(Number),ue=e=>[...e].sort((r,t)=>{let[o,s,n]=V(r),[i,l,c]=V(t);return o!==i?(o??0)-(i??0):s!==l?(s??0)-(l??0):(n??0)-(c??0)});var yt="next",Xo=/^v?(\d+)\.(\d+)\.(\d+)$/,Yo=e=>e.replace(/^.*release\//,""),kt=e=>{let r=Yo(e.trim()),t=Xo.exec(r);return t?[Number(t[1]),Number(t[2]),Number(t[3])]:null},vt=e=>`${e[0]}.${e[1]}.${e[2]}`,Wr=e=>{let r=[...e.remoteBranches??[],...e.jiraVersions??[]],t=[],o=new Set;for(let s of r){let n=kt(s);if(!n)continue;let i=vt(n);o.has(i)||(o.add(i),t.push(n))}return ue(t.map(s=>vt(s))).map(s=>V(`v${s}`))},Y=class extends Error{constructor(){super("No prior release versions found from git or Jira. Specify the version explicitly."),this.name="NoPriorVersionsError"}},tr=(e,r)=>{if(e.length===0)throw new Y;let t=e[e.length-1];if(r==="hotfix"){let[n,i]=t,l=e.reduce((c,p)=>p[0]===n&&p[1]===i?Math.max(c,p[2]):c,0);return`${n}.${i}.${l+1}`}let[o,s]=t;return`${o}.${s+1}.0`},Rt=e=>e.trim().toLowerCase()===yt,Zo=e=>e==="regular"||e==="hotfix",Lr=e=>{let r=e.trim();if(r==="")throw new Error("Release spec is empty");let t=r.indexOf(":");if(t===-1)return{version:r,type:"regular"};let o=r.slice(0,t).trim(),s=r.slice(t+1),n=s.indexOf(":"),i=n===-1?s.trim():s.slice(0,n).trim(),l=n===-1?"":s.slice(n+1).trim(),c=i.toLowerCase();if(!Zo(c))throw new Error(`Invalid release type "${i}". Expected "regular" or "hotfix".`);let p={version:o,type:c};return l!==""&&(p.description=l),p},Jr=(e,r)=>{let t=[...r];return e.map(o=>{let s=o.version.trim();if(s==="")throw new Error("Release entry has an empty version");if(Rt(s)){let l=tr(t,o.type);return t.push(V(`v${l}`)),{...o,version:l}}let n=kt(s);if(!n)throw new Error(`Invalid version "${s}". Expected semver like "1.2.5" or the token "next".`);let i=`${n[0]}.${n[1]}.${n[2]}`;return t.push(n),{...o,version:i}})},Vr=e=>e.some(r=>Rt(r.version));var Qo=async()=>{let e=or.quiet;try{return or.quiet=!0,(await or`git ls-remote --heads origin 'release/v*'`).stdout.split(`
59
59
  `).map(o=>{let s=o.indexOf(" ");return s===-1?"":o.slice(s+1).replace(/^refs\/heads\//,"")}).filter(Boolean)}finally{or.quiet=e}},es=async()=>{let e=await X();return e?(await pe(e)).map(t=>t.name):[]},Br=async()=>{let[e,r]=await Promise.allSettled([Qo(),es()]);return e.status==="rejected"&&a.warn({error:e.reason},"Failed to list remote release branches; continuing without them"),r.status==="rejected"&&a.warn({error:r.reason},"Failed to fetch Jira versions; continuing without them"),Wr({remoteBranches:e.status==="fulfilled"?e.value:[],jiraVersions:r.status==="fulfilled"?r.value:[]})};var bt=async()=>{let e=await A`gh pr list --search "Release in:title" --base dev --json number,title,headRefName,state,baseRefName`,r=await A`gh pr list --search "Hotfix in:title" --base main --json number,title,headRefName,state,baseRefName`,t=[...JSON.parse(e.stdout),...JSON.parse(r.stdout)],o=new Set;return t.filter(s=>o.has(s.headRefName)?!1:(o.add(s.headRefName),!0))},nr=async()=>{try{let e=await bt();return e.length===0&&(a.error("\u274C No release PRs found. Check the project folder for the script. Exiting..."),sr.exit(1)),ue(e.map(r=>r.headRefName))}catch(e){a.error({error:e},"\u274C Error fetching release PRs"),sr.exit(1)}},C=async()=>{try{let e=await bt();e.length===0&&(a.error("\u274C No release PRs found. Check the project folder for the script. Exiting..."),sr.exit(1));let r=ue(e.map(o=>o.headRefName)),t=new Map(e.map(o=>[o.headRefName,o]));return r.map(o=>({branch:o,title:t.get(o).title}))}catch(e){a.error({error:e},"\u274C Error fetching release PRs"),sr.exit(1)}},ir=async e=>{let{branch:r,body:t}=e;try{A.quiet=!0,await A`gh pr edit ${r} --body ${t}`,A.quiet=!1}catch(o){throw a.error({error:o,branch:r},`Error updating release PR body for ${r}`),o}},rr=async e=>{let{version:r,jiraVersionUrl:t,type:o,description:s}=e,n=o==="hotfix"?"Hotfix":"Release",i=er(o),l=`release/v${r}`,c=s&&s.trim()!==""?`${t}
60
60
 
61
61
  ${s}`:`${t}
62
- `;try{A.quiet=!0,await A`git switch ${i}`,await A`git pull origin ${i}`,await A`git checkout -b ${l}`,await A`git push -u origin ${l}`,await A`git commit --allow-empty-message --allow-empty --message ''`,await A`git push origin ${l}`;let m=(await A`gh pr create --title "${n} v${r}" --body ${c} --base ${i} --head ${l}`).stdout.trim();return await A`git switch ${i}`,A.quiet=!1,{branchName:l,prUrl:m}}catch(p){throw a.error({error:p,branchName:l},`Error creating release branch ${l}`),p}};var rs=e=>{if(e===null||typeof e!="object")return;let r=e.stderr;return typeof r=="string"&&r.length>0?r:void 0},ts=(e,r)=>{let t=r.stderrExcerpt??rs(e),o=[`failed to ${r.operation}`];return t&&o.push(`stderr: ${t.slice(0,200).trim()}`),r.remediation&&o.push(`try: ${r.remediation}`),o.join(" \u2014 ")},w=class extends Error{operation;remediation;constructor(r,t){super(ts(r,t),{cause:r}),this.name="OperationError",this.operation=t.operation,this.remediation=t.remediation}};var ar=async e=>{let{all:r,confirmedCommand:t}=e;d.start("merge-dev");let s=(await C()).filter(m=>b(m.title)==="regular").map(m=>m.branch);if(s.length===0)return a.info("\u2139\uFE0F No open release branches found"),d.print(),{content:g(JSON.stringify({successfulMerges:0,failedMerges:0,failedBranches:[],totalBranches:0},null,2)),structuredContent:{successfulMerges:0,failedMerges:0,failedBranches:[],totalBranches:0}};let n=[];if(r)n=s;else{d.setInteractive();let m=await T();n=await os({required:!0,message:"\u{1F33F} Select release branches",choices:I({branches:s,descriptions:m})})}n.length===s.length?d.addOption("--all",!0):d.addOption("--versions",n.map(m=>m.replace("release/v","")));let l=t?!0:await ss({message:`Are you sure you want to merge dev into these branches: ${n.join(", ")}?`});t||d.setInteractive(),l||(a.info("Operation cancelled. Exiting..."),ns.exit(0)),t||d.addOption("--yes",!0),j.quiet=!0,await j`git fetch origin`,await j`git switch dev`,await j`git pull origin dev`;let c=[];for(let m of n)await is(m)||c.push(m);if(j.quiet=!1,c.length>0){a.info(`
62
+ `;try{A.quiet=!0,await A`git switch ${i}`,await A`git pull origin ${i}`,await A`git checkout -b ${l}`,await A`git push -u origin ${l}`,await A`git commit --allow-empty-message --allow-empty --message ''`,await A`git push origin ${l}`;let m=(await A`gh pr create --title "${n} v${r}" --body ${c} --base ${i} --head ${l}`).stdout.trim();return await A`git switch ${i}`,A.quiet=!1,{branchName:l,prUrl:m}}catch(p){throw a.error({error:p,branchName:l},`Error creating release branch ${l}`),p}};var rs=e=>{if(e===null||typeof e!="object")return;let r=e.stderr;return typeof r=="string"&&r.length>0?r:void 0},ts=(e,r)=>{let t=r.stderrExcerpt??rs(e),o=[`failed to ${r.operation}`];return t&&o.push(`stderr: ${t.slice(0,200).trim()}`),r.remediation&&o.push(`try: ${r.remediation}`),o.join(" \u2014 ")},w=class extends Error{operation;remediation;constructor(r,t){super(ts(r,t),{cause:r}),this.name="OperationError",this.operation=t.operation,this.remediation=t.remediation}};var ar=async e=>{let{all:r,confirmedCommand:t}=e;d.start("merge-dev");let s=(await C()).filter(m=>b(m.title)==="regular").map(m=>m.branch);if(s.length===0)return a.info("\u2139\uFE0F No open release branches found"),d.print(),{content:h(JSON.stringify({successfulMerges:0,failedMerges:0,failedBranches:[],totalBranches:0},null,2)),structuredContent:{successfulMerges:0,failedMerges:0,failedBranches:[],totalBranches:0}};let n=[];if(r)n=s;else{d.setInteractive();let m=await T();n=await os({required:!0,message:"\u{1F33F} Select release branches",choices:I({branches:s,descriptions:m})})}n.length===s.length?d.addOption("--all",!0):d.addOption("--versions",n.map(m=>m.replace("release/v","")));let l=t?!0:await ss({message:`Are you sure you want to merge dev into these branches: ${n.join(", ")}?`});t||d.setInteractive(),l||(a.info("Operation cancelled. Exiting..."),ns.exit(0)),t||d.addOption("--yes",!0),j.quiet=!0,await j`git fetch origin`,await j`git switch dev`,await j`git pull origin dev`;let c=[];for(let m of n)await is(m)||c.push(m);if(j.quiet=!1,c.length>0){a.info(`
63
63
  \u26A0\uFE0F ${c.length} branch(es) failed to merge automatically.
64
64
  `),a.info("\u{1F4CB} Manual merge script for failed branches:");for(let m of c)a.info(`# Merge dev into ${m} and resolve conflicts if any
65
65
 
66
66
  git switch ${m} && git pull origin ${m} && git merge origin/dev
67
67
  git push origin ${m} && git switch dev
68
68
  `);a.info(`\u2705 ${n.length-c.length}/${n.length} merges completed successfully.`)}else a.info(`\u2705 All merges completed successfully!
69
- `);d.print();let p={successfulMerges:n.length-c.length,failedMerges:c.length,failedBranches:c,totalBranches:n.length};return{content:g(JSON.stringify(p,null,2)),structuredContent:p}},is=async e=>{try{return await j`git switch ${e}`,await j`git pull origin ${e}`,await j`git merge origin/dev --no-edit`,await j`git push origin ${e}`,await j`git switch dev`,a.info(`Successfully merged dev into ${e}`),!0}catch(r){let t=new w(r,{operation:`merge dev into ${e}`,remediation:"resolve conflicts manually or rerun after 'git fetch origin'"});return a.error({error:r,branch:e,msg:t.message}),await j`git reset --merge HEAD~1`,!1}},as=v({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:fe.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:fe.number().describe("Number of successful merges"),failedMerges:fe.number().describe("Number of failed merges"),failedBranches:fe.array(fe.string()).describe("List of branches that failed to merge"),totalBranches:fe.number().describe("Total number of branches processed")},handler:ar});import cs from"@inquirer/confirm";import ls from"@inquirer/select";import ps from"node:process";import{z as Ie}from"zod/v4";import{$ as _}from"zx";var Ct=(e,r)=>{if(!(typeof e!="string"||e.length===0))return e.slice(-r).trim()},Kr=e=>{if(e===null||typeof e!="object")return{message:String(e)};let r=e,t={};e instanceof Error?(t.name=e.name,t.message=e.message):typeof r.message=="string"&&(t.message=r.message);let o=r.exitCode;(typeof o=="number"||o===null)&&(t.exitCode=o);let s=Ct(r.stderr,500);s&&(t.stderr=s);let n=Ct(r.stdout,200);return n&&(t.stdout=n),t};var ge=async(e,r,t)=>{try{return await t()}catch(o){throw a.error({err:Kr(o)},`\u274C Failed to ${e}`),new w(o,{operation:e,remediation:r})}},Tt=async e=>{let r=await _`gh pr list --head ${e} --state all --json number,state,title --limit 1`;return JSON.parse(r.stdout)[0]??null},ms=async e=>{let r=`Release v${e} (RC)`,t=await _`gh pr list --head dev --base main --state merged --json number,state,title --limit 20`;return JSON.parse(t.stdout).find(n=>n.title===r)??null},xt=async()=>{let e=await _`gh pr list --head dev --base main --state open --json number,state,title --limit 5`;return JSON.parse(e.stdout)[0]??null},ds=async e=>{let r=`release/v${e}`,t=await Tt(r);if(!t)throw a.error(`\u274C No PR found for branch ${r}.`),new w(void 0,{operation:`deliver release ${r}`,remediation:`confirm a PR exists ('gh pr list --head ${r} --state all')`});return{selectedReleaseBranch:r,releasePrTitle:t.title}},us=async()=>{let e=await C(),r=e.map(i=>i.branch),t=new Map(e.map(i=>[i.branch,b(i.title)]));d.setInteractive();let o=await T(),s=await ls({message:"\u{1F33F} Select release branch",choices:I({branches:r,descriptions:o,types:t})}),n=e.find(i=>i.branch===s);if(!n)throw a.error(`\u274C Release branch ${s} not found in open PRs.`),new w(void 0,{operation:`deliver release ${s}`,remediation:`confirm an open PR exists for ${s} ('gh pr list')`});return{selectedReleaseBranch:s,releasePrTitle:n.title}},fs=async e=>{let{selectedReleaseBranch:r,releaseType:t}=e,o=t==="hotfix"?"main":"dev",s=await Tt(r);if(!s)throw new w(void 0,{operation:`look up release PR for ${r}`,remediation:"verify the PR exists in GitHub"});if(s.state==="MERGED"){a.info(`\u2713 Release PR ${r} already merged \u2014 skipping`);return}if(s.state==="CLOSED")throw new w(void 0,{operation:`merge release PR ${r} into ${o}`,remediation:"the PR is closed without merge; reopen it or create a new release"});await ge(`merge release PR ${r} into ${o}`,`check 'gh pr view ${r}' for mergeability and required reviews`,async()=>{await _`gh pr merge ${r} --squash --admin --delete-branch`})},gs=async e=>{let r=`Release v${e} (RC)`,t=await xt();if(t){let s=t.number;return t.title!==r&&(a.info(`Adopting open dev \u2192 main PR #${s} ("${t.title}") and retitling for v${e}`),await ge(`retitle dev \u2192 main PR #${s} to "${r}"`,`update manually: gh pr edit ${s} --title "${r}"`,async()=>{await _`gh pr edit ${s} --title ${r}`})),s}await ge(`create RC PR (dev \u2192 main) for v${e}`,"run 'gh pr create --base main --head dev' manually to surface the underlying error (e.g. no commits between dev and main)",async()=>{await _`gh pr create --base main --head dev --title ${r} --body ""`});let o=await xt();if(!o)throw new w(void 0,{operation:`look up RC PR for v${e}`,remediation:"verify the RC PR was created ('gh pr list --head dev --base main')"});return o.number},hs=async e=>{if(await ms(e)){a.info(`\u2713 RC PR for v${e} already merged into main \u2014 skipping`);return}let t=await gs(e);await ge(`merge RC PR #${t} (dev \u2192 main) for v${e}`,`check 'gh pr view ${t}' for mergeability and required reviews`,async()=>{await _`gh pr merge ${t} --squash --admin`})},ws=async()=>{_.quiet=!1,await ge("dispatch deploy-all workflow on main","check 'gh workflow list' and that you have permission to dispatch deploy-all.yml",async()=>{await _`gh workflow run deploy-all.yml --ref main -f environment=prod`}),_.quiet=!0},vs=async()=>{await ge("sync main back into dev","run manually: git switch main && git pull && git switch dev && git pull && git merge main --no-edit && git push",async()=>{await _`git switch main && git pull && git switch dev && git pull && git merge main --no-edit && git push`})},ys=async e=>{let r=await X();if(!r){a.info("\u{1F514} Jira is not configured, skipping Jira release delivery");return}try{let t=e.replace("release/","");await jr({versionName:t},r)}catch(t){a.error({err:Kr(t)},"Failed to deliver Jira release (non-blocking)")}},cr=async e=>{let{version:r,confirmedCommand:t}=e;d.start("release-deliver");let{selectedReleaseBranch:o,releasePrTitle:s}=r?await ds(r):await us(),n=o.replace("release/v","");d.addOption("--version",n);let i=b(s),l=t?!0:await cs({message:`Are you sure you want to deliver version ${o} to production?`});t||d.setInteractive(),l||(a.info("Operation cancelled. Exiting..."),ps.exit(0)),d.addOption("--yes",!0),_.quiet=!0,await fs({selectedReleaseBranch:o,releaseType:i}),i!=="hotfix"&&await hs(n),await ws(),await vs(),_.quiet=!1,await ys(o),a.info(`Successfully delivered ${o} to production!`),d.print();let c={releaseBranch:o,version:n,type:i,success:!0};return{content:g(JSON.stringify(c,null,2)),structuredContent:c}},ks=v({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. PR-merge steps are idempotent: re-running after a partial failure skips PRs that are already merged. 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:Ie.string().describe('Release version to deliver to production (e.g., "1.2.5"). Required for MCP calls.')},outputSchema:{releaseBranch:Ie.string().describe("The release branch that was delivered"),version:Ie.string().describe("The version that was delivered"),type:Ie.enum(["regular","hotfix"]).describe("Release type"),success:Ie.boolean().describe("Whether the delivery was successful")},handler:cr});import $t from"@inquirer/select";import{z as B}from"zod/v4";import{$ as qr}from"zx";var lr=async e=>{let{version:r,env:t,skipTerraform:o}=e;d.start("release-deploy-all");let s="";if(r)s=r==="dev"?"dev":`release/v${r}`;else{d.setInteractive();let p=await C(),m=p.map(h=>h.branch),f=new Map(p.map(h=>[h.branch,b(h.title)])),u=await T();s=await $t({message:"\u{1F33F} Select release branch",choices:[{name:"dev",value:"dev"},...I({branches:m,descriptions:u,types:f})]})}let n=s==="dev"?"dev":s.replace("release/v","");d.addOption("--version",n);let{environments:i}=await R(),l="";if(t?l=t:(d.setInteractive(),l=await $t({message:"\u{1F9EA} Select environment",choices:i.map(p=>({name:p,value:p}))})),d.addOption("--env",l),!i.includes(l))throw new w(void 0,{operation:"launch deploy-all workflow",remediation:`pass one of: ${i.join(", ")}`,stderrExcerpt:`invalid environment: ${l}`});let c=o??!1;c&&d.addOption("--skip-terraform",!0);try{qr.quiet=!0,await qr`gh workflow run deploy-all.yml --ref ${s} -f environment=${l} ${c?["-f","skip_terraform_deploy=true"]:[]}`,qr.quiet=!1,a.info(`Successfully launched deploy-all workflow_dispatch for release branch: ${s} and environment: ${l}`),d.print();let m={releaseBranch:s,version:s.replace("release/v",""),environment:l,skipTerraformDeploy:c,success:!0};return{content:g(JSON.stringify(m,null,2)),structuredContent:m}}catch(p){throw a.error({error:p},"\u274C Error launching workflow"),new w(p,{operation:"launch deploy-all workflow",remediation:"check 'gh workflow list' and that deploy-all.yml exists on the target ref"})}},Rs=v({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:B.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:B.string().describe('Target environment name \u2014 must match an env configured for the project (e.g. "dev", "renana", "oriana"). Required for MCP calls.'),skipTerraform:B.boolean().optional().describe("Skip the terraform deployment stage.")},outputSchema:{releaseBranch:B.string().describe("The release branch that was deployed"),version:B.string().describe("The version that was deployed"),environment:B.string().describe("The environment deployed to"),skipTerraformDeploy:B.boolean().describe("Whether terraform deployment was skipped"),success:B.boolean().describe("Whether the deployment was successful")},handler:lr});import bs from"@inquirer/checkbox";import Pt from"@inquirer/select";import Cs from"node:fs/promises";import{resolve as xs}from"node:path";import Ts from"yaml";import{z as O}from"zod/v4";import{$ as zr}from"zx";var pr=async e=>{let{version:r,env:t,services:o,skipTerraform:s}=e;d.start("release-deploy-selected");let n="";if(r)n=r==="dev"?"dev":`release/v${r}`;else{d.setInteractive();let h=await C(),$=h.map(ee=>ee.branch),P=new Map(h.map(ee=>[ee.branch,b(ee.title)])),M=await T();n=await Pt({message:"\u{1F33F} Select release branch",choices:[{name:"dev",value:"dev"},...I({branches:$,descriptions:M,types:P})]})}let i=n==="dev"?"dev":n.replace("release/v","");d.addOption("--version",i);let{environments:l}=await R(),c="";if(t?c=t:(d.setInteractive(),c=await Pt({message:"\u{1F9EA} Select environment",choices:l.map(h=>({name:h,value:h}))})),d.addOption("--env",c),!l.includes(c))throw new w(void 0,{operation:"launch deploy-selected workflow",remediation:`pass one of: ${l.join(", ")}`,stderrExcerpt:`invalid environment: ${c}`});let p=await $s();if(p.length===0)throw new w(void 0,{operation:"launch deploy-selected workflow",remediation:"check .github/workflows/deploy-selected-services.yml for boolean service inputs",stderrExcerpt:"no services found in workflow file"});let m=[];if(o&&o.length>0?m=o:(d.setInteractive(),m=await bs({message:"\u{1F680} Select services to deploy (space to select, enter to confirm)",choices:p.map(h=>({name:h,value:h}))})),d.addOption("--services",m),m.length===0)throw new w(void 0,{operation:"launch deploy-selected workflow",remediation:`pass at least one service from: ${p.join(", ")}`,stderrExcerpt:"no services selected"});let f=m.filter(h=>!p.includes(h));if(f.length>0)throw new w(void 0,{operation:"launch deploy-selected workflow",remediation:`pass services from: ${p.join(", ")}`,stderrExcerpt:`invalid services: ${f.join(", ")}`});let u=s??!1;u&&d.addOption("--skip-terraform",!0);try{zr.quiet=!0;let h=m.flatMap(M=>["-f",`${M}=true`]);await zr`gh workflow run deploy-selected-services.yml --ref ${n} -f environment=${c} ${h} ${u?["-f","skip_terraform_deploy=true"]:[]}`,zr.quiet=!1,a.info(`Successfully launched deploy-selected-services workflow_dispatch for release branch: ${n}, environment: ${c}, services: ${m.join(", ")}`),d.print();let P={releaseBranch:n,version:n.replace("release/v",""),environment:c,services:m,skipTerraformDeploy:u,success:!0};return{content:g(JSON.stringify(P,null,2)),structuredContent:P}}catch(h){throw a.error({error:h},"\u274C Error launching workflow"),new w(h,{operation:"launch deploy-selected workflow",remediation:"check 'gh workflow list' and that deploy-selected-services.yml exists on the target ref"})}},$s=async()=>{let e=await S(),r=xs(e,".github/workflows/deploy-selected-services.yml"),t=await Cs.readFile(r,"utf-8"),s=Ts.parse(t).on.workflow_dispatch.inputs,n=[];for(let[i,l]of Object.entries(s))l.type==="boolean"&&i!=="skip_terraform_deploy"&&n.push(i);return n},Ps=v({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: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.'),services:O.array(O.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: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"),services:O.array(O.string()).describe("The services that were deployed"),skipTerraformDeploy:O.boolean().describe("Whether terraform deployment was skipped"),success:O.boolean().describe("Whether the deployment was successful")},handler:pr});import{z as he}from"zod/v4";var mr=async()=>{let r=(await C()).map(i=>({version:i.branch.replace("release/",""),type:b(i.title)})),t=await T(),o=Math.max(...r.map(i=>i.version.length)),s=r.map(i=>{let l=de(i.version,i.type,o),c=t.get(i.version);return c?`${l} ${c}`:l});a.info(`All release branches:
69
+ `);d.print();let p={successfulMerges:n.length-c.length,failedMerges:c.length,failedBranches:c,totalBranches:n.length};return{content:h(JSON.stringify(p,null,2)),structuredContent:p}},is=async e=>{try{return await j`git switch ${e}`,await j`git pull origin ${e}`,await j`git merge origin/dev --no-edit`,await j`git push origin ${e}`,await j`git switch dev`,a.info(`Successfully merged dev into ${e}`),!0}catch(r){let t=new w(r,{operation:`merge dev into ${e}`,remediation:"resolve conflicts manually or rerun after 'git fetch origin'"});return a.error({error:r,branch:e,msg:t.message}),await j`git reset --merge HEAD~1`,!1}},as=v({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:fe.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:fe.number().describe("Number of successful merges"),failedMerges:fe.number().describe("Number of failed merges"),failedBranches:fe.array(fe.string()).describe("List of branches that failed to merge"),totalBranches:fe.number().describe("Total number of branches processed")},handler:ar});import cs from"@inquirer/confirm";import ls from"@inquirer/select";import ps from"node:process";import{z as Ie}from"zod/v4";import{$ as _}from"zx";var Ct=(e,r)=>{if(!(typeof e!="string"||e.length===0))return e.slice(-r).trim()},Kr=e=>{if(e===null||typeof e!="object")return{message:String(e)};let r=e,t={};e instanceof Error?(t.name=e.name,t.message=e.message):typeof r.message=="string"&&(t.message=r.message);let o=r.exitCode;(typeof o=="number"||o===null)&&(t.exitCode=o);let s=Ct(r.stderr,500);s&&(t.stderr=s);let n=Ct(r.stdout,200);return n&&(t.stdout=n),t};var he=async(e,r,t)=>{try{return await t()}catch(o){throw a.error({err:Kr(o)},`\u274C Failed to ${e}`),new w(o,{operation:e,remediation:r})}},Tt=async e=>{let r=await _`gh pr list --head ${e} --state all --json number,state,title --limit 1`;return JSON.parse(r.stdout)[0]??null},ms=async e=>{let r=`Release v${e} (RC)`,t=await _`gh pr list --head dev --base main --state merged --json number,state,title --limit 20`;return JSON.parse(t.stdout).find(n=>n.title===r)??null},xt=async()=>{let e=await _`gh pr list --head dev --base main --state open --json number,state,title --limit 5`;return JSON.parse(e.stdout)[0]??null},ds=async e=>{let r=`release/v${e}`,t=await Tt(r);if(!t)throw a.error(`\u274C No PR found for branch ${r}.`),new w(void 0,{operation:`deliver release ${r}`,remediation:`confirm a PR exists ('gh pr list --head ${r} --state all')`});return{selectedReleaseBranch:r,releasePrTitle:t.title}},us=async()=>{let e=await C(),r=e.map(i=>i.branch),t=new Map(e.map(i=>[i.branch,b(i.title)]));d.setInteractive();let o=await T(),s=await ls({message:"\u{1F33F} Select release branch",choices:I({branches:r,descriptions:o,types:t})}),n=e.find(i=>i.branch===s);if(!n)throw a.error(`\u274C Release branch ${s} not found in open PRs.`),new w(void 0,{operation:`deliver release ${s}`,remediation:`confirm an open PR exists for ${s} ('gh pr list')`});return{selectedReleaseBranch:s,releasePrTitle:n.title}},fs=async e=>{let{selectedReleaseBranch:r,releaseType:t}=e,o=t==="hotfix"?"main":"dev",s=await Tt(r);if(!s)throw new w(void 0,{operation:`look up release PR for ${r}`,remediation:"verify the PR exists in GitHub"});if(s.state==="MERGED"){a.info(`\u2713 Release PR ${r} already merged \u2014 skipping`);return}if(s.state==="CLOSED")throw new w(void 0,{operation:`merge release PR ${r} into ${o}`,remediation:"the PR is closed without merge; reopen it or create a new release"});await he(`merge release PR ${r} into ${o}`,`check 'gh pr view ${r}' for mergeability and required reviews`,async()=>{await _`gh pr merge ${r} --squash --admin --delete-branch`})},hs=async e=>{let r=`Release v${e} (RC)`,t=await xt();if(t){let s=t.number;return t.title!==r&&(a.info(`Adopting open dev \u2192 main PR #${s} ("${t.title}") and retitling for v${e}`),await he(`retitle dev \u2192 main PR #${s} to "${r}"`,`update manually: gh pr edit ${s} --title "${r}"`,async()=>{await _`gh pr edit ${s} --title ${r}`})),s}await he(`create RC PR (dev \u2192 main) for v${e}`,"run 'gh pr create --base main --head dev' manually to surface the underlying error (e.g. no commits between dev and main)",async()=>{await _`gh pr create --base main --head dev --title ${r} --body ""`});let o=await xt();if(!o)throw new w(void 0,{operation:`look up RC PR for v${e}`,remediation:"verify the RC PR was created ('gh pr list --head dev --base main')"});return o.number},gs=async e=>{if(await ms(e)){a.info(`\u2713 RC PR for v${e} already merged into main \u2014 skipping`);return}let t=await hs(e);await he(`merge RC PR #${t} (dev \u2192 main) for v${e}`,`check 'gh pr view ${t}' for mergeability and required reviews`,async()=>{await _`gh pr merge ${t} --squash --admin`})},ws=async()=>{_.quiet=!1,await he("dispatch deploy-all workflow on main","check 'gh workflow list' and that you have permission to dispatch deploy-all.yml",async()=>{await _`gh workflow run deploy-all.yml --ref main -f environment=prod`}),_.quiet=!0},vs=async()=>{await he("sync main back into dev","run manually: git switch main && git pull && git switch dev && git pull && git merge main --no-edit && git push",async()=>{await _`git switch main && git pull && git switch dev && git pull && git merge main --no-edit && git push`})},ys=async e=>{let r=await X();if(!r){a.info("\u{1F514} Jira is not configured, skipping Jira release delivery");return}try{let t=e.replace("release/","");await jr({versionName:t},r)}catch(t){a.error({err:Kr(t)},"Failed to deliver Jira release (non-blocking)")}},cr=async e=>{let{version:r,confirmedCommand:t}=e;d.start("release-deliver");let{selectedReleaseBranch:o,releasePrTitle:s}=r?await ds(r):await us(),n=o.replace("release/v","");d.addOption("--version",n);let i=b(s),l=t?!0:await cs({message:`Are you sure you want to deliver version ${o} to production?`});t||d.setInteractive(),l||(a.info("Operation cancelled. Exiting..."),ps.exit(0)),d.addOption("--yes",!0),_.quiet=!0,await fs({selectedReleaseBranch:o,releaseType:i}),i!=="hotfix"&&await gs(n),await ws(),await vs(),_.quiet=!1,await ys(o),a.info(`Successfully delivered ${o} to production!`),d.print();let c={releaseBranch:o,version:n,type:i,success:!0};return{content:h(JSON.stringify(c,null,2)),structuredContent:c}},ks=v({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. PR-merge steps are idempotent: re-running after a partial failure skips PRs that are already merged. 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:Ie.string().describe('Release version to deliver to production (e.g., "1.2.5"). Required for MCP calls.')},outputSchema:{releaseBranch:Ie.string().describe("The release branch that was delivered"),version:Ie.string().describe("The version that was delivered"),type:Ie.enum(["regular","hotfix"]).describe("Release type"),success:Ie.boolean().describe("Whether the delivery was successful")},handler:cr});import $t from"@inquirer/select";import{z as B}from"zod/v4";import{$ as qr}from"zx";var lr=async e=>{let{version:r,env:t,skipTerraform:o}=e;d.start("release-deploy-all");let s="";if(r)s=r==="dev"?"dev":`release/v${r}`;else{d.setInteractive();let p=await C(),m=p.map(g=>g.branch),f=new Map(p.map(g=>[g.branch,b(g.title)])),u=await T();s=await $t({message:"\u{1F33F} Select release branch",choices:[{name:"dev",value:"dev"},...I({branches:m,descriptions:u,types:f})]})}let n=s==="dev"?"dev":s.replace("release/v","");d.addOption("--version",n);let{environments:i}=await R(),l="";if(t?l=t:(d.setInteractive(),l=await $t({message:"\u{1F9EA} Select environment",choices:i.map(p=>({name:p,value:p}))})),d.addOption("--env",l),!i.includes(l))throw new w(void 0,{operation:"launch deploy-all workflow",remediation:`pass one of: ${i.join(", ")}`,stderrExcerpt:`invalid environment: ${l}`});let c=o??!1;c&&d.addOption("--skip-terraform",!0);try{qr.quiet=!0,await qr`gh workflow run deploy-all.yml --ref ${s} -f environment=${l} ${c?["-f","skip_terraform_deploy=true"]:[]}`,qr.quiet=!1,a.info(`Successfully launched deploy-all workflow_dispatch for release branch: ${s} and environment: ${l}`),d.print();let m={releaseBranch:s,version:s.replace("release/v",""),environment:l,skipTerraformDeploy:c,success:!0};return{content:h(JSON.stringify(m,null,2)),structuredContent:m}}catch(p){throw a.error({error:p},"\u274C Error launching workflow"),new w(p,{operation:"launch deploy-all workflow",remediation:"check 'gh workflow list' and that deploy-all.yml exists on the target ref"})}},Rs=v({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:B.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:B.string().describe('Target environment name \u2014 must match an env configured for the project (e.g. "dev", "renana", "oriana"). Required for MCP calls.'),skipTerraform:B.boolean().optional().describe("Skip the terraform deployment stage.")},outputSchema:{releaseBranch:B.string().describe("The release branch that was deployed"),version:B.string().describe("The version that was deployed"),environment:B.string().describe("The environment deployed to"),skipTerraformDeploy:B.boolean().describe("Whether terraform deployment was skipped"),success:B.boolean().describe("Whether the deployment was successful")},handler:lr});import bs from"@inquirer/checkbox";import Pt from"@inquirer/select";import Cs from"node:fs/promises";import{resolve as xs}from"node:path";import Ts from"yaml";import{z as O}from"zod/v4";import{$ as zr}from"zx";var pr=async e=>{let{version:r,env:t,services:o,skipTerraform:s}=e;d.start("release-deploy-selected");let n="";if(r)n=r==="dev"?"dev":`release/v${r}`;else{d.setInteractive();let g=await C(),$=g.map(ee=>ee.branch),P=new Map(g.map(ee=>[ee.branch,b(ee.title)])),M=await T();n=await Pt({message:"\u{1F33F} Select release branch",choices:[{name:"dev",value:"dev"},...I({branches:$,descriptions:M,types:P})]})}let i=n==="dev"?"dev":n.replace("release/v","");d.addOption("--version",i);let{environments:l}=await R(),c="";if(t?c=t:(d.setInteractive(),c=await Pt({message:"\u{1F9EA} Select environment",choices:l.map(g=>({name:g,value:g}))})),d.addOption("--env",c),!l.includes(c))throw new w(void 0,{operation:"launch deploy-selected workflow",remediation:`pass one of: ${l.join(", ")}`,stderrExcerpt:`invalid environment: ${c}`});let p=await $s();if(p.length===0)throw new w(void 0,{operation:"launch deploy-selected workflow",remediation:"check .github/workflows/deploy-selected-services.yml for boolean service inputs",stderrExcerpt:"no services found in workflow file"});let m=[];if(o&&o.length>0?m=o:(d.setInteractive(),m=await bs({message:"\u{1F680} Select services to deploy (space to select, enter to confirm)",choices:p.map(g=>({name:g,value:g}))})),d.addOption("--services",m),m.length===0)throw new w(void 0,{operation:"launch deploy-selected workflow",remediation:`pass at least one service from: ${p.join(", ")}`,stderrExcerpt:"no services selected"});let f=m.filter(g=>!p.includes(g));if(f.length>0)throw new w(void 0,{operation:"launch deploy-selected workflow",remediation:`pass services from: ${p.join(", ")}`,stderrExcerpt:`invalid services: ${f.join(", ")}`});let u=s??!1;u&&d.addOption("--skip-terraform",!0);try{zr.quiet=!0;let g=m.flatMap(M=>["-f",`${M}=true`]);await zr`gh workflow run deploy-selected-services.yml --ref ${n} -f environment=${c} ${g} ${u?["-f","skip_terraform_deploy=true"]:[]}`,zr.quiet=!1,a.info(`Successfully launched deploy-selected-services workflow_dispatch for release branch: ${n}, environment: ${c}, services: ${m.join(", ")}`),d.print();let P={releaseBranch:n,version:n.replace("release/v",""),environment:c,services:m,skipTerraformDeploy:u,success:!0};return{content:h(JSON.stringify(P,null,2)),structuredContent:P}}catch(g){throw a.error({error:g},"\u274C Error launching workflow"),new w(g,{operation:"launch deploy-selected workflow",remediation:"check 'gh workflow list' and that deploy-selected-services.yml exists on the target ref"})}},$s=async()=>{let e=await S(),r=xs(e,".github/workflows/deploy-selected-services.yml"),t=await Cs.readFile(r,"utf-8"),s=Ts.parse(t).on.workflow_dispatch.inputs,n=[];for(let[i,l]of Object.entries(s))l.type==="boolean"&&i!=="skip_terraform_deploy"&&n.push(i);return n},Ps=v({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: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.'),services:O.array(O.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: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"),services:O.array(O.string()).describe("The services that were deployed"),skipTerraformDeploy:O.boolean().describe("Whether terraform deployment was skipped"),success:O.boolean().describe("Whether the deployment was successful")},handler:pr});import{z as ge}from"zod/v4";var mr=async()=>{let r=(await C()).map(i=>({version:i.branch.replace("release/",""),type:b(i.title)})),t=await T(),o=Math.max(...r.map(i=>i.version.length)),s=r.map(i=>{let l=de(i.version,i.type,o),c=t.get(i.version);return c?`${l} ${c}`:l});a.info(`All release branches:
70
70
  `),a.info(`
71
71
  ${s.join(`
72
72
  `)}
73
- `);let n={releases:r.map(i=>({version:i.version,type:i.type,description:t.get(i.version)||null})),count:r.length};return{content:g(JSON.stringify(n,null,2)),structuredContent:n}},Es=v({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:he.array(he.object({version:he.string().describe("Release version"),type:he.enum(["regular","hotfix"]).describe("Release type"),description:he.string().nullable().describe("Jira version description")})).describe("List of all release branches"),count:he.number().describe("Number of release branches")},handler:mr});import It from"@inquirer/confirm";import Ss from"@inquirer/select";import At from"node:process";import{z as x}from"zod/v4";import{question as Et}from"zx";var Is='"1.2.5" or "next"',As=(e,r)=>{try{return tr(e,r)}catch(t){if(t instanceof Y)return null;throw t}},_t=(e,r)=>{try{return Jr(e,r)}catch(t){throw t instanceof Y?new w(t,{operation:"resolve release version",remediation:'pass an explicit version (e.g. "1.2.5") instead of "next" when there are no prior versions'}):t}},_s=async e=>{d.setInteractive();let t=[...await e()],o=[],s=!0;for(;s;){let n=o.length+1,i=await Ss({message:`Release #${n} \u2014 select type:`,choices:[{name:"regular",value:"regular"},{name:"hotfix",value:"hotfix"}],default:"regular"}),l=As(t,i),c=l?` [${l}]`:"",p=(await Et(` Version (e.g. ${Is})${c}: `)).trim(),m=p===""?l??"":p;m===""&&(a.error("No version provided. Exiting..."),At.exit(1));let f=_t([{version:m,type:i}],t)[0];t.push(V(`v${f.version}`));let u=(await Et(" Description (optional, press Enter to skip): ")).trim();o.push({...f,...u!==""?{description:u}:{}}),s=await It({message:"Add another release?",default:!1})}return o},Os=e=>{let r=[`v${e.version}`,e.type];return e.description&&r.push(e.description),r.join(" \xB7 ")},St=e=>{for(let r of e){let t=r.description?`${r.version}:${r.type}:${r.description}`:`${r.version}:${r.type}`;d.addOption("--release",t)}},Ns=async(e,r)=>{if(e&&e.length>0){let o=Vr(e)?await r():[],s=_t(e,o);return St(s),s}let t=await _s(r);return St(t),t},Ds=async(e,r)=>{let t=e.map(Os).join(`
73
+ `);let n={releases:r.map(i=>({version:i.version,type:i.type,description:t.get(i.version)||null})),count:r.length};return{content:h(JSON.stringify(n,null,2)),structuredContent:n}},Es=v({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:ge.array(ge.object({version:ge.string().describe("Release version"),type:ge.enum(["regular","hotfix"]).describe("Release type"),description:ge.string().nullable().describe("Jira version description")})).describe("List of all release branches"),count:ge.number().describe("Number of release branches")},handler:mr});import It from"@inquirer/confirm";import Ss from"@inquirer/select";import At from"node:process";import{z as x}from"zod/v4";import{question as Et}from"zx";var Is='"1.2.5" or "next"',As=(e,r)=>{try{return tr(e,r)}catch(t){if(t instanceof Y)return null;throw t}},_t=(e,r)=>{try{return Jr(e,r)}catch(t){throw t instanceof Y?new w(t,{operation:"resolve release version",remediation:'pass an explicit version (e.g. "1.2.5") instead of "next" when there are no prior versions'}):t}},_s=async e=>{d.setInteractive();let t=[...await e()],o=[],s=!0;for(;s;){let n=o.length+1,i=await Ss({message:`Release #${n} \u2014 select type:`,choices:[{name:"regular",value:"regular"},{name:"hotfix",value:"hotfix"}],default:"regular"}),l=As(t,i),c=l?` [${l}]`:"",p=(await Et(` Version (e.g. ${Is})${c}: `)).trim(),m=p===""?l??"":p;m===""&&(a.error("No version provided. Exiting..."),At.exit(1));let f=_t([{version:m,type:i}],t)[0];t.push(V(`v${f.version}`));let u=(await Et(" Description (optional, press Enter to skip): ")).trim();o.push({...f,...u!==""?{description:u}:{}}),s=await It({message:"Add another release?",default:!1})}return o},Os=e=>{let r=[`v${e.version}`,e.type];return e.description&&r.push(e.description),r.join(" \xB7 ")},St=e=>{for(let r of e){let t=r.description?`${r.version}:${r.type}:${r.description}`:`${r.version}:${r.type}`;d.addOption("--release",t)}},Ns=async(e,r)=>{if(e&&e.length>0){let o=Vr(e)?await r():[],s=_t(e,o);return St(s),s}let t=await _s(r);return St(t),t},Ds=async(e,r)=>{let t=e.map(Os).join(`
74
74
  - `),o=r?!0:await It({message:`Create the following ${e.length} release(s)?
75
75
  - ${t}
76
76
  `});r||d.setInteractive(),o||(a.info("Operation cancelled. Exiting..."),At.exit(0)),d.addOption("--yes",!0)},js=async e=>{let{entry:r,jiraConfig:t}=e;try{await Mr(r.type);let o=await Fr({version:r.version,jiraConfig:t,description:r.description,type:r.type});return a.info(`\u2705 Successfully created release: v${r.version} (${r.type})`),a.info(`\u{1F517} GitHub PR: ${o.prUrl}`),a.info(`\u{1F517} Jira Version: ${o.jiraVersionUrl}
77
77
  `),{result:o}}catch(o){let s=new w(o,{operation:`create release v${r.version} (${r.type})`,remediation:"verify the version is unique and the base branch is clean"});return a.error(`\u274C ${s.message}
78
- `),{failure:{version:r.version,error:s.message}}}},Ms=(e,r,t)=>{r===e?a.info(`\u2705 All ${e} release branch(es) were created successfully.`):r>0?(a.warn(`\u26A0\uFE0F ${r} of ${e} release branches were created successfully.`),a.warn(`\u274C ${t} release(s) failed.`)):a.error(`\u274C All ${e} release branch(es) failed to create.`)},dr=async e=>{let{releases:r,confirmedCommand:t}=e;d.start("release-create");let o=await me(),s=null,i=await Ns(r,async()=>(s===null&&(s=await Br()),s));if(i.length===0)throw new w(void 0,{operation:"create release",remediation:'pass at least one entry in "releases" (e.g. [{ version: "1.2.5", type: "regular" }])',stderrExcerpt:"no releases provided"});await Ds(i,!!t);let l=[],c=[];for(let m of i){let{result:f,failure:u}=await js({entry:m,jiraConfig:o});f&&l.push(f),u&&c.push(u)}Ms(i.length,l.length,c.length),d.print();let p={createdBranches:l.map(m=>m.branchName),successCount:l.length,failureCount:c.length,releases:l,failedReleases:c};return{content:g(JSON.stringify(p,null,2)),structuredContent:p}},Fs=v({name:"release-create",description:'Create one or more releases in a single call. Each entry in "releases" carries its own version, type (regular|hotfix, default regular), and optional description, so regular and hotfix releases can be mixed in the same invocation. For each release this tool switches to the appropriate base branch (dev for regular, main for hotfix), cuts the release branch, opens a GitHub release PR, and creates the matching Jira fix version. The literal token "next" auto-increments from the union of remote release branches and Jira fix versions (regular bumps minor + resets patch; hotfix bumps patch on the highest minor); multiple "next" tokens advance sequentially across mixed types. Confirmation is auto-skipped for MCP calls, so the caller is responsible for gating. Continues on per-release failure and reports successes/failures.',inputSchema:{releases:x.array(x.object({version:x.string().describe('Version to create (e.g., "1.2.5") or the literal token "next" for auto-increment.'),type:x.enum(["regular","hotfix"]).optional().default("regular").describe('Release type: "regular" (branches off dev) or "hotfix" (branches off main).'),description:x.string().optional().describe("Optional description for the Jira version.")})).min(1).describe("One or more releases to create. Each entry has its own version, type, and optional description.")},outputSchema:{createdBranches:x.array(x.string()).describe("List of created release branch names"),successCount:x.number().describe("Number of releases created successfully"),failureCount:x.number().describe("Number of releases that failed"),releases:x.array(x.object({version:x.string().describe("Version number"),type:x.enum(["regular","hotfix"]).describe("Release type"),branchName:x.string().describe("Release branch name"),prUrl:x.string().describe("GitHub PR URL"),jiraVersionUrl:x.string().describe("Jira version URL")})).describe("Detailed information for each created release with URLs"),failedReleases:x.array(x.object({version:x.string().describe("Version number that failed"),error:x.string().describe("Error message")})).describe("List of releases that failed with error messages")},handler:dr});import Ws from"@inquirer/confirm";import Ls from"@inquirer/select";import Js from"node:process";import{z as K}from"zod/v4";import{question as Vs}from"zx";var Ot=(e,r)=>`${e.baseUrl}/projects/${r.projectId}/versions/${r.id}/tab/release-report-all-issues`,Bs=(e,r)=>r.trim()!==""?`${e}
78
+ `),{failure:{version:r.version,error:s.message}}}},Ms=(e,r,t)=>{r===e?a.info(`\u2705 All ${e} release branch(es) were created successfully.`):r>0?(a.warn(`\u26A0\uFE0F ${r} of ${e} release branches were created successfully.`),a.warn(`\u274C ${t} release(s) failed.`)):a.error(`\u274C All ${e} release branch(es) failed to create.`)},dr=async e=>{let{releases:r,confirmedCommand:t}=e;d.start("release-create");let o=await me(),s=null,i=await Ns(r,async()=>(s===null&&(s=await Br()),s));if(i.length===0)throw new w(void 0,{operation:"create release",remediation:'pass at least one entry in "releases" (e.g. [{ version: "1.2.5", type: "regular" }])',stderrExcerpt:"no releases provided"});await Ds(i,!!t);let l=[],c=[];for(let m of i){let{result:f,failure:u}=await js({entry:m,jiraConfig:o});f&&l.push(f),u&&c.push(u)}Ms(i.length,l.length,c.length),d.print();let p={createdBranches:l.map(m=>m.branchName),successCount:l.length,failureCount:c.length,releases:l,failedReleases:c};return{content:h(JSON.stringify(p,null,2)),structuredContent:p}},Fs=v({name:"release-create",description:'Create one or more releases in a single call. Each entry in "releases" carries its own version, type (regular|hotfix, default regular), and optional description, so regular and hotfix releases can be mixed in the same invocation. For each release this tool switches to the appropriate base branch (dev for regular, main for hotfix), cuts the release branch, opens a GitHub release PR, and creates the matching Jira fix version. The literal token "next" auto-increments from the union of remote release branches and Jira fix versions (regular bumps minor + resets patch; hotfix bumps patch on the highest minor); multiple "next" tokens advance sequentially across mixed types. Confirmation is auto-skipped for MCP calls, so the caller is responsible for gating. Continues on per-release failure and reports successes/failures.',inputSchema:{releases:x.array(x.object({version:x.string().describe('Version to create (e.g., "1.2.5") or the literal token "next" for auto-increment.'),type:x.enum(["regular","hotfix"]).optional().default("regular").describe('Release type: "regular" (branches off dev) or "hotfix" (branches off main).'),description:x.string().optional().describe("Optional description for the Jira version.")})).min(1).describe("One or more releases to create. Each entry has its own version, type, and optional description.")},outputSchema:{createdBranches:x.array(x.string()).describe("List of created release branch names"),successCount:x.number().describe("Number of releases created successfully"),failureCount:x.number().describe("Number of releases that failed"),releases:x.array(x.object({version:x.string().describe("Version number"),type:x.enum(["regular","hotfix"]).describe("Release type"),branchName:x.string().describe("Release branch name"),prUrl:x.string().describe("GitHub PR URL"),jiraVersionUrl:x.string().describe("Jira version URL")})).describe("Detailed information for each created release with URLs"),failedReleases:x.array(x.object({version:x.string().describe("Version number that failed"),error:x.string().describe("Error message")})).describe("List of releases that failed with error messages")},handler:dr});import Ws from"@inquirer/confirm";import Ls from"@inquirer/select";import Js from"node:process";import{z as K}from"zod/v4";import{question as Vs}from"zx";var Ot=(e,r)=>`${e.baseUrl}/projects/${r.projectId}/versions/${r.id}/tab/release-report-all-issues`,Bs=(e,r)=>r.trim()!==""?`${e}
79
79
 
80
80
  ${r}`:`${e}
81
81
  `,Ks=async()=>{let e=await C(),r=e.map(n=>n.branch),t=new Map(e.map(n=>[n.branch,b(n.title)])),o=await T(),s=await Ls({message:"\u{1F33F} Select release branch",choices:I({branches:r,descriptions:o,types:t})});return{branch:s,type:t.get(s)||"regular"}},qs=async e=>{let t=(await C()).find(o=>o.branch===e);if(!t)throw new w(void 0,{operation:`edit description for ${e}`,remediation:`confirm an open PR exists for ${e} ('gh pr list')`});return b(t.title)},zs=async e=>{let r=e===""?"(no current description)":`current: "${e}"`,o=(await Vs(` New description ${r}
82
- (press Enter to keep current): `)).replace(/\n$/,"");return o===""?e:o},ur=async e=>{let{version:r,description:t,confirmedCommand:o}=e;d.start("release-desc-edit");let s=await me(),n;r?(n=`release/v${r}`,await qs(n)):(d.setInteractive(),n=(await Ks()).branch);let i=n.replace("release/v","");d.addOption("--version",i);let l=`v${i}`,c=await Ze(l,s);if(!c)throw new w(void 0,{operation:`edit description for ${l}`,remediation:`create the Jira fix version "${l}" first or pick a different release`});let p=c.description??"",m;if(t!==void 0?(m=t,d.addOption("--description",m)):(d.setInteractive(),m=await zs(p)),m===p){a.info(`No change \u2014 description for ${l} is already: "${p}"`),d.print();let P={version:i,branch:n,jiraVersionUrl:Ot(s,c),previousDescription:p,newDescription:m,changed:!1};return{content:g(JSON.stringify(P,null,2)),structuredContent:P}}let f=o?!0:await Ws({message:`Update description for ${l}?
82
+ (press Enter to keep current): `)).replace(/\n$/,"");return o===""?e:o},ur=async e=>{let{version:r,description:t,confirmedCommand:o}=e;d.start("release-desc-edit");let s=await me(),n;r?(n=`release/v${r}`,await qs(n)):(d.setInteractive(),n=(await Ks()).branch);let i=n.replace("release/v","");d.addOption("--version",i);let l=`v${i}`,c=await Ze(l,s);if(!c)throw new w(void 0,{operation:`edit description for ${l}`,remediation:`create the Jira fix version "${l}" first or pick a different release`});let p=c.description??"",m;if(t!==void 0?(m=t,d.addOption("--description",m)):(d.setInteractive(),m=await zs(p)),m===p){a.info(`No change \u2014 description for ${l} is already: "${p}"`),d.print();let P={version:i,branch:n,jiraVersionUrl:Ot(s,c),previousDescription:p,newDescription:m,changed:!1};return{content:h(JSON.stringify(P,null,2)),structuredContent:P}}let f=o?!0:await Ws({message:`Update description for ${l}?
83
83
  from: "${p}"
84
84
  to: "${m}"
85
- `});o||d.setInteractive(),f||(a.info("Operation cancelled. Exiting..."),Js.exit(0)),d.addOption("--yes",!0),await Qe({versionId:c.id,description:m},s);let u=Ot(s,c),h=Bs(u,m);await ir({branch:n,body:h}),a.info(`\u2705 Updated description for ${l}`),a.info(`\u{1F517} Jira Version: ${u}`),a.info(`\u{1F517} PR branch: ${n}
86
- `),d.print();let $={version:i,branch:n,jiraVersionUrl:u,previousDescription:p,newDescription:m,changed:!0};return{content:g(JSON.stringify($,null,2)),structuredContent:$}},Gs=v({name:"release-desc-edit",description:"Edit a release's description in Jira and in the matching GitHub release PR body. Targets the Jira fix version named `v<version>` and the open PR on branch `release/v<version>`. The PR body is rewritten canonically to `<jiraVersionUrl>\\n\\n<description>` \u2014 any prior manual edits to the body are overwritten. Both `version` and `description` are required for MCP calls (the picker/prompt are unreachable without a TTY). Empty `description` clears the description on both sides. Confirmation is auto-skipped for MCP, so the caller is responsible for gating.",inputSchema:{version:K.string().describe('Release version, e.g. "1.2.5".'),description:K.string().describe("New description. Empty string clears the description.")},outputSchema:{version:K.string().describe("Release version"),branch:K.string().describe('Release branch name (e.g. "release/v1.2.5")'),jiraVersionUrl:K.string().describe("Jira fix version URL"),previousDescription:K.string().describe("The description before the update"),newDescription:K.string().describe("The description after the update"),changed:K.boolean().describe("Whether the description actually changed")},handler:ur});import{z as Hs}from"zod/v4";var Nt={name:"infra-kit",type:"module",version:"0.1.100",description:"infra-kit",main:"dist/cli.js",module:"dist/cli.js",bin:{"infra-kit":"dist/cli.js",ik:"dist/cli.js"},engines:{node:">=24.x"},scripts:{inspector:"npx @modelcontextprotocol/inspector node ./dist/mcp.js --debug",build:"pnpm run clean-artifacts && node ./scripts/build.js","clean-artifacts":"rm -rf dist","clean-cache":"rm -rf node_modules/.cache .eslintcache tsconfig.tsbuildinfo .turbo .swc","prettier-fix":"pnpm exec prettier **/* --write --no-error-on-unmatched-pattern --log-level silent --ignore-path ../../../.prettierignore","prettier-check":"pnpm exec prettier **/* --check --no-error-on-unmatched-pattern --log-level silent --ignore-path ../../../.prettierignore","eslint-check":"pnpm exec eslint --cache --quiet --report-unused-disable-directives ./src","eslint-fix":"pnpm exec eslint --cache --quiet --report-unused-disable-directives ./src --fix","ts-check":"tsc --noEmit",test:"pnpm exec vitest run --reporter=minimal","test-watch":"pnpm exec vitest --watch --silent passed-only","test-ui":"pnpm exec vitest --ui --silent passed-only","test-report":"pnpm exec vitest run --coverage --silent passed-only",qa:"pnpm run prettier-check && pnpm run eslint-check && pnpm run ts-check && pnpm run test && echo \u2705 Success",fix:"pnpm run prettier-fix && pnpm run eslint-fix && pnpm run qa"},dependencies:{"@inquirer/checkbox":"catalog:","@inquirer/confirm":"catalog:","@inquirer/select":"catalog:","@modelcontextprotocol/sdk":"^1.29.0",commander:"^14.0.3",pino:"^10.3.1","pino-pretty":"^13.1.3",yaml:"catalog:",zod:"^3.25.76",zx:"^8.8.5"},devDependencies:{"@pkg/eslint-config":"workspace:*","@pkg/vitest-config":"workspace:*",esbuild:"^0.28.0",typescript:"catalog:"}};var fr=async()=>{let e=Nt.version;a.info(e);let r={version:e};return{content:g(JSON.stringify(r,null,2)),structuredContent:r}},Xs=v({name:"version",description:"Print the installed infra-kit CLI version",inputSchema:{},outputSchema:{version:Hs.string().describe("Installed infra-kit CLI version (from package.json)")},handler:fr});import tn from"@inquirer/checkbox";import Hr from"@inquirer/confirm";import on from"@inquirer/select";import sn from"node:process";import{z as q}from"zod/v4";import{$ as Q}from"zx";import{$ as Dt}from"zx";var Ae=async e=>{try{let r=(await Dt`cmux list-workspaces`.quiet()).stdout,t=Ys(r,e);if(!t)return;await Dt`cmux close-workspace --workspace ${t}`.quiet()}catch(r){a.debug({error:r,title:e},"cmux: skipped closing workspace")}},Ys=(e,r)=>{for(let t of e.split(`
85
+ `});o||d.setInteractive(),f||(a.info("Operation cancelled. Exiting..."),Js.exit(0)),d.addOption("--yes",!0),await Qe({versionId:c.id,description:m},s);let u=Ot(s,c),g=Bs(u,m);await ir({branch:n,body:g}),a.info(`\u2705 Updated description for ${l}`),a.info(`\u{1F517} Jira Version: ${u}`),a.info(`\u{1F517} PR branch: ${n}
86
+ `),d.print();let $={version:i,branch:n,jiraVersionUrl:u,previousDescription:p,newDescription:m,changed:!0};return{content:h(JSON.stringify($,null,2)),structuredContent:$}},Gs=v({name:"release-desc-edit",description:"Edit a release's description in Jira and in the matching GitHub release PR body. Targets the Jira fix version named `v<version>` and the open PR on branch `release/v<version>`. The PR body is rewritten canonically to `<jiraVersionUrl>\\n\\n<description>` \u2014 any prior manual edits to the body are overwritten. Both `version` and `description` are required for MCP calls (the picker/prompt are unreachable without a TTY). Empty `description` clears the description on both sides. Confirmation is auto-skipped for MCP, so the caller is responsible for gating.",inputSchema:{version:K.string().describe('Release version, e.g. "1.2.5".'),description:K.string().describe("New description. Empty string clears the description.")},outputSchema:{version:K.string().describe("Release version"),branch:K.string().describe('Release branch name (e.g. "release/v1.2.5")'),jiraVersionUrl:K.string().describe("Jira fix version URL"),previousDescription:K.string().describe("The description before the update"),newDescription:K.string().describe("The description after the update"),changed:K.boolean().describe("Whether the description actually changed")},handler:ur});import{z as Hs}from"zod/v4";var Nt={name:"infra-kit",type:"module",version:"0.1.101",description:"infra-kit",main:"dist/cli.js",module:"dist/cli.js",bin:{"infra-kit":"dist/cli.js",ik:"dist/cli.js"},engines:{node:">=24.x"},scripts:{inspector:"npx @modelcontextprotocol/inspector node ./dist/mcp.js --debug",build:"pnpm run clean-artifacts && node ./scripts/build.js","clean-artifacts":"rm -rf dist","clean-cache":"rm -rf node_modules/.cache .eslintcache tsconfig.tsbuildinfo .turbo .swc","prettier-fix":"pnpm exec prettier **/* --write --no-error-on-unmatched-pattern --log-level silent --ignore-path ../../../.prettierignore","prettier-check":"pnpm exec prettier **/* --check --no-error-on-unmatched-pattern --log-level silent --ignore-path ../../../.prettierignore","eslint-check":"pnpm exec eslint --cache --quiet --report-unused-disable-directives ./src","eslint-fix":"pnpm exec eslint --cache --quiet --report-unused-disable-directives ./src --fix","ts-check":"tsc --noEmit",test:"pnpm exec vitest run --reporter=minimal","test-watch":"pnpm exec vitest --watch --silent passed-only","test-ui":"pnpm exec vitest --ui --silent passed-only","test-report":"pnpm exec vitest run --coverage --silent passed-only",qa:"pnpm run prettier-check && pnpm run eslint-check && pnpm run ts-check && pnpm run test && echo \u2705 Success",fix:"pnpm run prettier-fix && pnpm run eslint-fix && pnpm run qa"},dependencies:{"@inquirer/checkbox":"^5.1.5","@inquirer/confirm":"^6.0.13","@inquirer/select":"^5.1.5","@modelcontextprotocol/sdk":"^1.29.0",commander:"^14.0.3",pino:"^10.3.1","pino-pretty":"^13.1.3",yaml:"^2.9.0",zod:"^3.25.76",zx:"^8.8.5"},devDependencies:{"@pkg/eslint-config":"workspace:*","@pkg/vitest-config":"workspace:*",esbuild:"^0.28.0",typescript:"^6.0.3"}};var fr=async()=>{let e=Nt.version;a.info(e);let r={version:e};return{content:h(JSON.stringify(r,null,2)),structuredContent:r}},Xs=v({name:"version",description:"Print the installed infra-kit CLI version",inputSchema:{},outputSchema:{version:Hs.string().describe("Installed infra-kit CLI version (from package.json)")},handler:fr});import tn from"@inquirer/checkbox";import Hr from"@inquirer/confirm";import on from"@inquirer/select";import sn from"node:process";import{z as q}from"zod/v4";import{$ as Q}from"zx";import{$ as Dt}from"zx";var Ae=async e=>{try{let r=(await Dt`cmux list-workspaces`.quiet()).stdout,t=Ys(r,e);if(!t)return;await Dt`cmux close-workspace --workspace ${t}`.quiet()}catch(r){a.debug({error:r,title:e},"cmux: skipped closing workspace")}},Ys=(e,r)=>{for(let t of e.split(`
87
87
  `)){let o=t.match(/^[* ]\s*(workspace:\d+)\s+(.+?)(?:\s+\[selected\])?\s*$/);if(!o)continue;let s=o[1];if((o[2]?.trim()??"")===r)return s}};import{$ as Zs}from"zx";var Gr=async()=>{try{let e=(await Zs`cmux list-workspaces`.quiet()).stdout,r=new Set;for(let t of e.split(`
88
- `)){let o=t.match(/^[* ]\s*workspace:\d+\s+(.+?)(?:\s+\[selected\])?\s*$/);if(!o)continue;let s=o[1]?.trim();s&&r.add(s)}return r}catch(e){return a.debug({error:e},"cmux: skipped listing workspace titles"),new Set}};import{$ as _e}from"zx";var Oe=async e=>{let{cwd:r,title:t}=e,o=(await _e`cmux new-workspace --cwd ${r}`).stdout,s=en(o),n=(await _e`cmux list-pane-surfaces --workspace ${s}`).stdout,i=Qs(n);await _e`cmux new-split right --workspace ${s} --surface ${i}`,await _e`cmux new-split down --workspace ${s} --surface ${i}`,t&&await _e`cmux rename-workspace --workspace ${s} ${t}`},Qs=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]},en=e=>{let r=e.match(/workspace:\d+/);if(!r)throw new Error("cmux: could not locate workspace ref in new-workspace output");return r[0]};var F=e=>{let{repoName:r,branch:t}=e,o=t.replace("release/","");return`${r} ${o}`};import jt from"node:fs/promises";import gr from"node:path";var Ne=async e=>{let{workspacePath:r,folderPaths:t}=e,o=gr.dirname(r),s;try{s=await jt.readFile(r,"utf-8")}catch(m){throw new Error(`Cursor workspace file not found at ${r}: ${m.message}`)}let n;try{n=JSON.parse(s)}catch(m){throw new Error(`Failed to parse ${r} as JSON. Comments (JSONC) are not supported. ${m.message}`)}let i=n.folders??[],l=new Set(i.map(m=>gr.resolve(o,m.path))),c=[],p=[];for(let m of t){let f=gr.resolve(m);if(l.has(f)){p.push(m);continue}let u=gr.relative(o,f);i.push({path:u}),l.add(f),c.push(m)}return n.folders=i,await jt.writeFile(r,`${JSON.stringify(n,null,2)}
89
- `,"utf-8"),{added:c,skipped:p}};import rn from"node:fs/promises";import wr from"node:path";import Mt from"node:fs/promises";import hr from"node:path";var Z=async e=>{let{workspacePath:r,folderPaths:t}=e,o=hr.dirname(r),s;try{s=await Mt.readFile(r,"utf-8")}catch(u){throw new Error(`Cursor workspace file not found at ${r}: ${u.message}`)}let n;try{n=JSON.parse(s)}catch(u){throw new Error(`Failed to parse ${r} as JSON. Comments (JSONC) are not supported. ${u.message}`)}let i=n.folders??[],l=new Set(t.map(u=>hr.resolve(u))),c=new Set,p=i.filter(u=>{let h=hr.resolve(o,u.path);return l.has(h)?(c.add(h),!1):!0});n.folders=p,await Mt.writeFile(r,`${JSON.stringify(n,null,2)}
90
- `,"utf-8");let m=[],f=[];for(let u of t){let h=hr.resolve(u);c.has(h)?m.push(u):f.push(u)}return{removed:m,notFound:f}};var Ur=async e=>{let{workspacePath:r,worktreeDir:t,currentBranches:o}=e,s=wr.dirname(r),n=wr.resolve(`${t}/release`),i=await rn.readFile(r,"utf-8"),c=JSON.parse(i).folders??[],p=new Set(o.map($=>wr.resolve(`${t}/${$}`))),m=[];for(let $ of c){let P=wr.resolve(s,$.path);(P===n||P.startsWith(`${n}/`))&&!p.has(P)&&m.push(P)}let f=[];m.length>0&&(f=(await Z({workspacePath:r,folderPaths:m})).removed);let u=o.map($=>`${t}/${$}`),{added:h}=u.length>0?await Ne({workspacePath:r,folderPaths:u}):{added:[]};return{added:h,removed:f}};import Ft from"node:path";var W=(e,r)=>Ft.isAbsolute(e)?e:Ft.resolve(r,e);var nn="feature",an="release",cn="release/v",De=["workspace","windows","none"],vr=async e=>{let{confirmedCommand:r,all:t,versions:o,cursor:s,githubDesktop:n,cmux:i}=e;d.start("worktrees-add");try{let l=await N("release"),c=await S(),p=`${c}${J}`;await Wt(`${p}/${an}`),await Wt(`${p}/${nn}`);let m=[];if(o)m=o.split(",").map(E=>`release/v${E.trim()}`);else{let E=await C(),L=E.map(G=>G.branch);if(L.length===0)return a.info("\u2139\uFE0F No open release branches found"),d.print(),{content:g(JSON.stringify({createdWorktrees:[],count:0},null,2)),structuredContent:{createdWorktrees:[],count:0}};if(t)m=L;else{d.setInteractive();let G=new Map(E.map(Fe=>[Fe.branch,b(Fe.title)])),Me=await T();m=await tn({required:!0,message:"\u{1F33F} Select release branches",choices:I({branches:L,descriptions:Me,types:G})})}}t?d.addOption("--all",!0):d.addOption("--versions",m.map(E=>E.replace("release/v","")));let f=r?!0:await Hr({message:"Are you sure you want to proceed with these worktree changes?"});r||d.setInteractive(),f||(a.info("Operation cancelled. Exiting..."),sn.exit(0)),r||d.addOption("--yes",!0);let u=await R(),h=u.ide?.provider==="cursor"?u.ide.config:void 0,$=s??h?.mode??await on({message:"Cursor mode for created worktrees?",default:"workspace",choices:[{name:"Add to workspace file",value:"workspace",description:"Append each worktree as a folder in ide.config.workspaceConfigPath, then open the workspace"},{name:"Open separate windows",value:"windows",description:"Open each created worktree in its own Cursor window"},{name:"Skip",value:"none",description:"Do not open Cursor"}]});typeof s>"u"&&!h?.mode&&d.setInteractive(),d.addOption("--cursor",$);let P=n??u.worktrees?.openInGithubDesktop??await Hr({message:"Open created worktrees in GitHub Desktop?"});typeof n>"u"&&u.worktrees?.openInGithubDesktop===void 0&&d.setInteractive(),P?d.addOption("--github-desktop",!0):d.addOption("--no-github-desktop",!0);let M=i??u.worktrees?.openInCmux??await Hr({message:"Open created worktrees in cmux?"});typeof i>"u"&&u.worktrees?.openInCmux===void 0&&d.setInteractive(),M?d.addOption("--cmux",!0):d.addOption("--no-cmux",!0);let{branchesToCreate:ee}=ln({selectedReleaseBranches:m,currentWorktrees:l}),z=await pn(ee,p);if(mn(z),$==="workspace")if(!h?.workspaceConfigPath)a.warn("\u26A0\uFE0F Skipping Cursor: ide.config.workspaceConfigPath is not set in infra-kit config");else{let E=W(h.workspaceConfigPath,c),L=z.map(Vt=>`${p}/${Vt}`),{added:G,skipped:Me}=await Ne({workspacePath:E,folderPaths:L}),Fe=Me.length>0?` (${Me.length} already present)`:"";a.info(`\u2705 Added ${G.length} folder(s) to ${E}${Fe}`),await Q`cursor ${E}`}else if($==="windows")for(let E of z)await Q`cursor ${p}/${E}`;if(P)for(let E of z)await Q`github ${p}/${E}`,await Q`sleep 5`;if(M){let E=await D();for(let L of z){let G=F({repoName:E,branch:L});await Oe({cwd:`${p}/${L}`,title:G})}}d.print();let Qr={createdWorktrees:z,count:z.length};return{content:g(JSON.stringify(Qr,null,2)),structuredContent:Qr}}catch(l){throw a.error({error:l},"\u274C Error managing worktrees"),new w(l,{operation:"create worktrees",remediation:"verify branches don't already exist as worktrees: 'git worktree list'"})}},Wt=async e=>{await Q`mkdir -p ${e}`},ln=e=>{let{selectedReleaseBranches:r,currentWorktrees:t}=e,o=t.filter(n=>n.startsWith(cn));return{branchesToCreate:r.filter(n=>!o.includes(n))}},pn=async(e,r)=>{let t=await Promise.allSettled(e.map(async s=>{let n=`${r}/${s}`;return await Q`git worktree add ${n} ${s}`,await Q({cwd:n})`pnpm install`,s})),o=[];for(let[s,n]of t.entries())if(n.status==="fulfilled")o.push(n.value);else{let i=e[s],l=new w(n.reason,{operation:`git worktree add for ${i}`,remediation:"check the branch name and that the parent dir is writable"});a.error({error:n.reason,msg:l.message})}return o},mn=e=>{if(e.length>0){a.info("\u2705 Created git worktrees:");for(let r of e)a.info(r);a.info("")}else a.info("\u2139\uFE0F No new git worktrees to create")},dn=v({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:q.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:q.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:q.enum(De).optional().describe('Cursor open mode for created worktrees. "workspace" appends each worktree as a folder to "ide.config.workspaceConfigPath" in infra-kit config and opens the workspace. "windows" opens each worktree in its own Cursor window. "none" skips Cursor. Resolution order: this flag \u2192 "ide.config.mode" from infra-kit config \u2192 interactive prompt (CLI) / "none" (MCP, no TTY).'),githubDesktop:q.boolean().optional().describe('Open each created worktree in GitHub Desktop. Resolution order: this flag \u2192 "worktrees.openInGithubDesktop" from infra-kit config \u2192 interactive prompt (CLI) / false (MCP, no TTY).'),cmux:q.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. Resolution order: this flag \u2192 "worktrees.openInCmux" from infra-kit config \u2192 interactive prompt (CLI) / false (MCP, no TTY).')},outputSchema:{createdWorktrees:q.array(q.string()).describe("List of created git worktree branches"),count:q.number().describe("Number of git worktrees created")},handler:vr});import{z as we}from"zod/v4";var yr=async()=>{let e=await N("release");if(e.length===0)return a.info("\u2139\uFE0F No active worktrees found"),{content:g(JSON.stringify({worktrees:[],count:0},null,2)),structuredContent:{worktrees:[],count:0}};let[r,t]=await Promise.all([C(),T()]),o=new Map(r.map(c=>[c.branch,b(c.title)])),s=e.map(c=>{let p=c.replace("release/",""),m=o.get(c)||"regular",f=t.get(p)||null;return{version:p,type:m,description:f}}),n=Math.max(...s.map(c=>c.version.length)),i=s.map(c=>{let p=de(c.version,c.type,n);return c.description?`${p} ${c.description}`:p});a.info("\u{1F33F} Active worktrees:"),a.info(`
88
+ `)){let o=t.match(/^[* ]\s*workspace:\d+\s+(.+?)(?:\s+\[selected\])?\s*$/);if(!o)continue;let s=o[1]?.trim();s&&r.add(s)}return r}catch(e){return a.debug({error:e},"cmux: skipped listing workspace titles"),new Set}};import{$ as _e}from"zx";var Oe=async e=>{let{cwd:r,title:t}=e,o=(await _e`cmux new-workspace --cwd ${r}`).stdout,s=en(o),n=(await _e`cmux list-pane-surfaces --workspace ${s}`).stdout,i=Qs(n);await _e`cmux new-split right --workspace ${s} --surface ${i}`,await _e`cmux new-split down --workspace ${s} --surface ${i}`,t&&await _e`cmux rename-workspace --workspace ${s} ${t}`},Qs=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]},en=e=>{let r=e.match(/workspace:\d+/);if(!r)throw new Error("cmux: could not locate workspace ref in new-workspace output");return r[0]};var F=e=>{let{repoName:r,branch:t}=e,o=t.replace("release/","");return`${r} ${o}`};import jt from"node:fs/promises";import hr from"node:path";var Ne=async e=>{let{workspacePath:r,folderPaths:t}=e,o=hr.dirname(r),s;try{s=await jt.readFile(r,"utf-8")}catch(m){throw new Error(`Cursor workspace file not found at ${r}: ${m.message}`)}let n;try{n=JSON.parse(s)}catch(m){throw new Error(`Failed to parse ${r} as JSON. Comments (JSONC) are not supported. ${m.message}`)}let i=n.folders??[],l=new Set(i.map(m=>hr.resolve(o,m.path))),c=[],p=[];for(let m of t){let f=hr.resolve(m);if(l.has(f)){p.push(m);continue}let u=hr.relative(o,f);i.push({path:u}),l.add(f),c.push(m)}return n.folders=i,await jt.writeFile(r,`${JSON.stringify(n,null,2)}
89
+ `,"utf-8"),{added:c,skipped:p}};import rn from"node:fs/promises";import wr from"node:path";import Mt from"node:fs/promises";import gr from"node:path";var Z=async e=>{let{workspacePath:r,folderPaths:t}=e,o=gr.dirname(r),s;try{s=await Mt.readFile(r,"utf-8")}catch(u){throw new Error(`Cursor workspace file not found at ${r}: ${u.message}`)}let n;try{n=JSON.parse(s)}catch(u){throw new Error(`Failed to parse ${r} as JSON. Comments (JSONC) are not supported. ${u.message}`)}let i=n.folders??[],l=new Set(t.map(u=>gr.resolve(u))),c=new Set,p=i.filter(u=>{let g=gr.resolve(o,u.path);return l.has(g)?(c.add(g),!1):!0});n.folders=p,await Mt.writeFile(r,`${JSON.stringify(n,null,2)}
90
+ `,"utf-8");let m=[],f=[];for(let u of t){let g=gr.resolve(u);c.has(g)?m.push(u):f.push(u)}return{removed:m,notFound:f}};var Ur=async e=>{let{workspacePath:r,worktreeDir:t,currentBranches:o}=e,s=wr.dirname(r),n=wr.resolve(`${t}/release`),i=await rn.readFile(r,"utf-8"),c=JSON.parse(i).folders??[],p=new Set(o.map($=>wr.resolve(`${t}/${$}`))),m=[];for(let $ of c){let P=wr.resolve(s,$.path);(P===n||P.startsWith(`${n}/`))&&!p.has(P)&&m.push(P)}let f=[];m.length>0&&(f=(await Z({workspacePath:r,folderPaths:m})).removed);let u=o.map($=>`${t}/${$}`),{added:g}=u.length>0?await Ne({workspacePath:r,folderPaths:u}):{added:[]};return{added:g,removed:f}};import Ft from"node:path";var W=(e,r)=>Ft.isAbsolute(e)?e:Ft.resolve(r,e);var nn="feature",an="release",cn="release/v",De=["workspace","windows","none"],vr=async e=>{let{confirmedCommand:r,all:t,versions:o,cursor:s,githubDesktop:n,cmux:i}=e;d.start("worktrees-add");try{let l=await N("release"),c=await S(),p=`${c}${J}`;await Wt(`${p}/${an}`),await Wt(`${p}/${nn}`);let m=[];if(o)m=o.split(",").map(E=>`release/v${E.trim()}`);else{let E=await C(),L=E.map(G=>G.branch);if(L.length===0)return a.info("\u2139\uFE0F No open release branches found"),d.print(),{content:h(JSON.stringify({createdWorktrees:[],count:0},null,2)),structuredContent:{createdWorktrees:[],count:0}};if(t)m=L;else{d.setInteractive();let G=new Map(E.map(Fe=>[Fe.branch,b(Fe.title)])),Me=await T();m=await tn({required:!0,message:"\u{1F33F} Select release branches",choices:I({branches:L,descriptions:Me,types:G})})}}t?d.addOption("--all",!0):d.addOption("--versions",m.map(E=>E.replace("release/v","")));let f=r?!0:await Hr({message:"Are you sure you want to proceed with these worktree changes?"});r||d.setInteractive(),f||(a.info("Operation cancelled. Exiting..."),sn.exit(0)),r||d.addOption("--yes",!0);let u=await R(),g=u.ide?.provider==="cursor"?u.ide.config:void 0,$=s??g?.mode??await on({message:"Cursor mode for created worktrees?",default:"workspace",choices:[{name:"Add to workspace file",value:"workspace",description:"Append each worktree as a folder in ide.config.workspaceConfigPath, then open the workspace"},{name:"Open separate windows",value:"windows",description:"Open each created worktree in its own Cursor window"},{name:"Skip",value:"none",description:"Do not open Cursor"}]});typeof s>"u"&&!g?.mode&&d.setInteractive(),d.addOption("--cursor",$);let P=n??u.worktrees?.openInGithubDesktop??await Hr({message:"Open created worktrees in GitHub Desktop?"});typeof n>"u"&&u.worktrees?.openInGithubDesktop===void 0&&d.setInteractive(),P?d.addOption("--github-desktop",!0):d.addOption("--no-github-desktop",!0);let M=i??u.worktrees?.openInCmux??await Hr({message:"Open created worktrees in cmux?"});typeof i>"u"&&u.worktrees?.openInCmux===void 0&&d.setInteractive(),M?d.addOption("--cmux",!0):d.addOption("--no-cmux",!0);let{branchesToCreate:ee}=ln({selectedReleaseBranches:m,currentWorktrees:l}),z=await pn(ee,p);if(mn(z),$==="workspace")if(!g?.workspaceConfigPath)a.warn("\u26A0\uFE0F Skipping Cursor: ide.config.workspaceConfigPath is not set in infra-kit config");else{let E=W(g.workspaceConfigPath,c),L=z.map(Vt=>`${p}/${Vt}`),{added:G,skipped:Me}=await Ne({workspacePath:E,folderPaths:L}),Fe=Me.length>0?` (${Me.length} already present)`:"";a.info(`\u2705 Added ${G.length} folder(s) to ${E}${Fe}`),await Q`cursor ${E}`}else if($==="windows")for(let E of z)await Q`cursor ${p}/${E}`;if(P)for(let E of z)await Q`github ${p}/${E}`,await Q`sleep 5`;if(M){let E=await D();for(let L of z){let G=F({repoName:E,branch:L});await Oe({cwd:`${p}/${L}`,title:G})}}d.print();let Qr={createdWorktrees:z,count:z.length};return{content:h(JSON.stringify(Qr,null,2)),structuredContent:Qr}}catch(l){throw a.error({error:l},"\u274C Error managing worktrees"),new w(l,{operation:"create worktrees",remediation:"verify branches don't already exist as worktrees: 'git worktree list'"})}},Wt=async e=>{await Q`mkdir -p ${e}`},ln=e=>{let{selectedReleaseBranches:r,currentWorktrees:t}=e,o=t.filter(n=>n.startsWith(cn));return{branchesToCreate:r.filter(n=>!o.includes(n))}},pn=async(e,r)=>{let t=await Promise.allSettled(e.map(async s=>{let n=`${r}/${s}`;return await Q`git worktree add ${n} ${s}`,await Q({cwd:n})`pnpm install`,s})),o=[];for(let[s,n]of t.entries())if(n.status==="fulfilled")o.push(n.value);else{let i=e[s],l=new w(n.reason,{operation:`git worktree add for ${i}`,remediation:"check the branch name and that the parent dir is writable"});a.error({error:n.reason,msg:l.message})}return o},mn=e=>{if(e.length>0){a.info("\u2705 Created git worktrees:");for(let r of e)a.info(r);a.info("")}else a.info("\u2139\uFE0F No new git worktrees to create")},dn=v({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:q.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:q.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:q.enum(De).optional().describe('Cursor open mode for created worktrees. "workspace" appends each worktree as a folder to "ide.config.workspaceConfigPath" in infra-kit config and opens the workspace. "windows" opens each worktree in its own Cursor window. "none" skips Cursor. Resolution order: this flag \u2192 "ide.config.mode" from infra-kit config \u2192 interactive prompt (CLI) / "none" (MCP, no TTY).'),githubDesktop:q.boolean().optional().describe('Open each created worktree in GitHub Desktop. Resolution order: this flag \u2192 "worktrees.openInGithubDesktop" from infra-kit config \u2192 interactive prompt (CLI) / false (MCP, no TTY).'),cmux:q.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. Resolution order: this flag \u2192 "worktrees.openInCmux" from infra-kit config \u2192 interactive prompt (CLI) / false (MCP, no TTY).')},outputSchema:{createdWorktrees:q.array(q.string()).describe("List of created git worktree branches"),count:q.number().describe("Number of git worktrees created")},handler:vr});import{z as we}from"zod/v4";var yr=async()=>{let e=await N("release");if(e.length===0)return a.info("\u2139\uFE0F No active worktrees found"),{content:h(JSON.stringify({worktrees:[],count:0},null,2)),structuredContent:{worktrees:[],count:0}};let[r,t]=await Promise.all([C(),T()]),o=new Map(r.map(c=>[c.branch,b(c.title)])),s=e.map(c=>{let p=c.replace("release/",""),m=o.get(c)||"regular",f=t.get(p)||null;return{version:p,type:m,description:f}}),n=Math.max(...s.map(c=>c.version.length)),i=s.map(c=>{let p=de(c.version,c.type,n);return c.description?`${p} ${c.description}`:p});a.info("\u{1F33F} Active worktrees:"),a.info(`
91
91
  ${i.join(`
92
92
  `)}
93
- `);let l={worktrees:s,count:s.length};return{content:g(JSON.stringify(l,null,2)),structuredContent:l}},un=v({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:we.array(we.object({version:we.string().describe("Release version"),type:we.enum(["regular","hotfix"]).describe("Release type"),description:we.string().nullable().describe("Jira version description")})).describe("List of all worktrees with details"),count:we.number().describe("Number of worktrees")},handler:yr});import{z as ve}from"zod/v4";import{$ as fn}from"zx";var kr=async()=>{d.start("worktrees-open");try{let e=await S(),r=`${e}${J}`,t=await N("release"),o=await gn({projectRoot:e,worktreeDir:r,currentBranches:t}),s=await hn({worktreeDir:r,currentBranches:t}),n={openedCmux:s.opened,skippedCmux:s.skipped,cursorFoldersAdded:o.added,cursorFoldersRemoved:o.removed};return wn(n,{cursorRan:o.ran,cmuxRan:s.ran}),d.print(),{content:g(JSON.stringify(n,null,2)),structuredContent:{...n}}}catch(e){throw a.error({error:e},"\u274C Error opening worktrees"),new w(e,{operation:"open worktrees",remediation:"run 'worktrees-list' to confirm the branches exist"})}},gn=async e=>{let{projectRoot:r,worktreeDir:t,currentBranches:o}=e,s=await R(),n=s.ide?.provider==="cursor"?s.ide.config:void 0;if(!n||n.mode!=="workspace"||!n.workspaceConfigPath)return a.warn('\u26A0\uFE0F Skipping Cursor: ide.provider must be "cursor", mode "workspace", and workspaceConfigPath set.'),{ran:!1,added:0,removed:0};let i=W(n.workspaceConfigPath,r);try{let{added:l,removed:c}=await Ur({workspacePath:i,worktreeDir:t,currentBranches:o});return await fn`cursor ${i}`,{ran:!0,added:l.length,removed:c.length}}catch(l){return a.warn({error:l},`\u26A0\uFE0F Failed to reconcile/open Cursor workspace at ${i}`),{ran:!1,added:0,removed:0}}},hn=async e=>{let{worktreeDir:r,currentBranches:t}=e;if(t.length===0)return{ran:!0,opened:[],skipped:[]};let o=await D(),s=await Gr(),n=[],i=[];for(let l of t){let c=F({repoName:o,branch:l});if(s.has(c)){i.push(c);continue}try{await Oe({cwd:`${r}/${l}`,title:c}),n.push(c)}catch(p){a.warn({error:p,title:c},`\u26A0\uFE0F Failed to open cmux workspace for ${l}`)}}return{ran:!0,opened:n,skipped:i}},wn=(e,r)=>{if(r.cursorRan&&(e.cursorFoldersAdded>0&&a.info(`\u2705 Added ${e.cursorFoldersAdded} folder(s) to Cursor workspace`),e.cursorFoldersRemoved>0&&a.info(`\u{1F9F9} Removed ${e.cursorFoldersRemoved} dangling folder(s) from Cursor workspace`)),e.openedCmux.length>0){a.info("\u2705 Opened cmux workspaces:");for(let t of e.openedCmux)a.info(t)}e.skippedCmux.length>0&&a.info(`\u2139\uFE0F Skipped ${e.skippedCmux.length} cmux workspace(s) already open`),!r.cursorRan&&e.openedCmux.length===0&&e.skippedCmux.length===0&&e.cursorFoldersAdded===0&&e.cursorFoldersRemoved===0&&a.info("\u2139\uFE0F Nothing to open")},vn=v({name:"worktrees-open",description:"Open Cursor against the configured workspace file and ensure a cmux workspace exists for each existing release worktree. Idempotent and additive \u2014 never removes worktrees, never recreates running cmux workspaces. Use after a cold start (Cursor + cmux closed). For stale-worktree cleanup, use worktrees-sync.",inputSchema:{},outputSchema:{openedCmux:ve.array(ve.string()).describe("Titles of cmux workspaces opened during this run"),skippedCmux:ve.array(ve.string()).describe("Titles of cmux workspaces that were already open"),cursorFoldersAdded:ve.number().describe("Number of worktree folders added to the Cursor workspace file"),cursorFoldersRemoved:ve.number().describe("Number of dangling worktree folders removed from the Cursor workspace file")},handler:kr});import yn from"@inquirer/checkbox";import kn from"@inquirer/confirm";import Rn from"node:process";import{z as je}from"zod/v4";import{$ as Xr}from"zx";var Rr=async e=>{let{confirmedCommand:r,all:t,versions:o}=e;d.start("worktrees-remove");try{let s=await N("release");if(s.length===0)return a.info("\u2139\uFE0F No active worktrees to remove"),d.print(),{content:g(JSON.stringify({removedWorktrees:[],count:0},null,2)),structuredContent:{removedWorktrees:[],count:0}};let n=await S(),i=`${n}${J}`,l=[];if(t)l=s;else if(o)l=o.split(",").map(h=>`release/v${h.trim()}`);else{d.setInteractive();let[h,$]=await Promise.all([T(),C()]),P=new Map($.map(M=>[M.branch,b(M.title)]));l=await yn({required:!0,message:"\u{1F33F} Select release branches",choices:I({branches:s,descriptions:h,types:P})})}let c=l.length===s.length;c?d.addOption("--all",!0):d.addOption("--versions",l.map(h=>h.replace("release/v","")));let p=r?!0:await kn({message:"Are you sure you want to proceed with these worktree changes?"});r||d.setInteractive(),p||(a.info("Operation cancelled. Exiting..."),Rn.exit(0)),r||d.addOption("--yes",!0);let m=await D(),f=await bn({branches:l,worktreeDir:i,repoName:m,allSelected:c});await Cn({removedWorktrees:f,worktreeDir:i,projectRoot:n}),xn(f),d.print();let u={removedWorktrees:f,count:f.length};return{content:g(JSON.stringify(u,null,2)),structuredContent:u}}catch(s){throw a.error({error:s},"\u274C Error managing worktrees"),new w(s,{operation:"remove worktrees",remediation:"check 'git worktree list' for the path; uncommitted changes block removal"})}},bn=async e=>{let{branches:r,worktreeDir:t,repoName:o,allSelected:s}=e,n=await Promise.allSettled(r.map(async l=>{let c=`${t}/${l}`,p=F({repoName:o,branch:l});return await Ae(p),await Xr`git worktree remove ${c}`,l})),i=[];for(let[l,c]of n.entries())if(c.status==="fulfilled")i.push(c.value);else{let p=r[l],m=new w(c.reason,{operation:`remove worktree for ${p}`,remediation:"check 'git worktree list' for the path; uncommitted changes block removal"});a.error({error:c.reason,msg:m.message})}return s&&i.length===r.length&&(await Xr`git worktree prune`,await Xr`rm -rf ${t}`,a.info(`\u{1F5D1}\uFE0F Removed worktree folder: ${t}`),a.info("")),i},Cn=async e=>{let{removedWorktrees:r,worktreeDir:t,projectRoot:o}=e;if(r.length===0)return;let s=await R(),n=s.ide?.provider==="cursor"?s.ide.config:void 0;if(!n||n.mode!=="workspace"||!n.workspaceConfigPath)return;let i=W(n.workspaceConfigPath,o),l=r.map(c=>`${t}/${c}`);try{let{removed:c}=await Z({workspacePath:i,folderPaths:l});c.length>0&&a.info(`\u2705 Removed ${c.length} folder(s) from ${i}`)}catch(c){a.warn({error:c},`\u26A0\uFE0F Failed to update Cursor workspace at ${i}`)}},xn=e=>{if(e.length>0){a.info("\u274C Removed worktrees:");for(let r of e)a.info(r);a.info("")}else a.info("\u2139\uFE0F No unused worktrees to remove")},Tn=v({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:je.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:je.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:je.array(je.string()).describe("List of removed git worktree branches"),count:je.number().describe("Number of git worktrees removed")},handler:Rr});import $n from"@inquirer/confirm";import Pn from"node:process";import{z as Yr}from"zod/v4";import{$ as En}from"zx";var Sn="release/v",br=async e=>{let{confirmedCommand:r}=e;d.start("worktrees-sync");try{let t=await N("release"),o=await S(),s=`${o}${J}`,n=await nr(),i=r?!0:await $n({message:"Are you sure you want to proceed with these worktree changes?"});r||d.setInteractive(),i||(a.info("Operation cancelled. Exiting..."),Pn.exit(0)),r||d.addOption("--yes",!0);let{branchesToRemove:l}=In({releasePRsList:n,currentWorktrees:t}),c=await D(),p=await An({branches:l,worktreeDir:s,repoName:c});await _n({removedWorktrees:p,worktreeDir:s,projectRoot:o}),On(p),d.print();let m={removedWorktrees:p,count:p.length};return{content:g(JSON.stringify(m,null,2)),structuredContent:m}}catch(t){throw a.error({error:t},"\u274C Error managing worktrees"),new w(t,{operation:"sync worktrees with remote",remediation:"ensure 'gh auth status' is ok and you can reach origin"})}},In=e=>{let{releasePRsList:r,currentWorktrees:t}=e;return{branchesToRemove:t.filter(n=>n.startsWith(Sn)).filter(n=>!r.includes(n))}},An=async e=>{let{branches:r,worktreeDir:t,repoName:o}=e,s=[];for(let n of r)try{let i=`${t}/${n}`,l=F({repoName:o,branch:n});await Ae(l),await En`git worktree remove ${i}`,s.push(n)}catch(i){let l=new w(i,{operation:`remove stale worktree for ${n}`,remediation:"inspect the worktree dir manually; rerun with the branch checked out elsewhere"});a.error({error:i,branch:n,msg:l.message})}return s},_n=async e=>{let{removedWorktrees:r,worktreeDir:t,projectRoot:o}=e;if(r.length===0)return;let s=await R(),n=s.ide?.provider==="cursor"?s.ide.config:void 0;if(!n||n.mode!=="workspace"||!n.workspaceConfigPath)return;let i=W(n.workspaceConfigPath,o),l=r.map(c=>`${t}/${c}`);try{let{removed:c}=await Z({workspacePath:i,folderPaths:l});c.length>0&&a.info(`\u2705 Removed ${c.length} folder(s) from ${i}`)}catch(c){a.warn({error:c},`\u26A0\uFE0F Failed to update Cursor workspace at ${i}`)}},On=e=>{if(e.length>0){a.info("\u274C Removed worktrees:");for(let r of e)a.info(r);a.info("")}else a.info("\u2139\uFE0F No unused worktrees to remove")},Nn=v({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:Yr.array(Yr.string()).describe("List of removed worktree branches"),count:Yr.number().describe("Number of worktrees removed during sync")},handler:br});var k=new jn,Mn=(e,r)=>[...r,e],Fn=e=>{if(!(typeof e>"u")){if(e===!0)return"workspace";if(e===!1)return"none";if(typeof e=="string"&&De.includes(e))return e;throw new Error(`Invalid --cursor value "${String(e)}". Expected one of: ${De.join(", ")}.`)}},Lt=async e=>{try{e?await k.parseAsync(e):await k.parseAsync()}catch(r){let t=r instanceof Error?r.message:String(r);a.error(t),Zr.exit(1)}};k.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 ar({all:e.all,confirmedCommand:e.yes})});k.command("release-list").description("List all release branches").action(async()=>{await mr()});k.command("release-create").description("Create one or more release branches (each entry can mix regular/hotfix and its own description)").option("-r, --release <spec>",'Release spec "version[:type[:description]]" (repeatable). Examples: "1.2.5", "1.2.5:hotfix", "next:regular:Holiday backend"',Mn,[]).option("-y, --yes","Skip confirmation prompt").action(async e=>{let r=e.release,t=r.length>0?r.map(Lr):void 0;await dr({releases:t,confirmedCommand:e.yes})});k.command("release-desc-edit").description("Edit a release's description in Jira and in the matching GitHub PR body").option("-v, --version <version>","Release version, e.g. 1.2.5").option("-d, --description <description>",'New description (use "" to clear)').option("-y, --yes","Skip confirmation prompt").action(async e=>{await ur({version:e.version,description:e.description,confirmedCommand:e.yes})});k.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 lr({version:e.version,env:e.env,skipTerraform:e.skipTerraform})});k.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 pr({version:e.version,env:e.env,services:e.services,skipTerraform:e.skipTerraform})});k.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 cr({version:e.version,confirmedCommand:e.yes})});k.command("worktrees-sync").description("Remove release worktrees whose PRs are no longer open").option("-y, --yes","Skip confirmation prompt").action(async e=>{await br({confirmedCommand:e.yes})});k.command("worktrees-add").description("Add git worktrees for release branches").option("-y, --yes","Skip confirmation prompt").option("-a, --all","Select all active release branches").option("-v, --versions <versions>","Specify versions by comma, e.g. 1.2.5, 1.2.6").option("-c, --cursor [mode]","Cursor mode for created worktrees: workspace (default) | windows | none").option("--no-cursor","Skip Cursor (alias for --cursor none)").option("-g, --github-desktop","Open created worktrees in GitHub Desktop").option("--no-github-desktop","Skip GitHub Desktop prompt").option("-m, --cmux","Open created worktrees in cmux (3-pane layout)").option("--no-cmux","Skip cmux prompt").action(async e=>{await vr({confirmedCommand:e.yes,all:e.all,versions:e.versions,cursor:Fn(e.cursor),githubDesktop:e.githubDesktop,cmux:e.cmux})});k.command("worktrees-list").description("List all git worktrees with detailed information").action(async()=>{await yr()});k.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 Rr({confirmedCommand:e.yes,all:e.all,versions:e.versions})});k.command("worktrees-open").description("Open Cursor + cmux for existing release worktrees (cold-start restore)").action(async()=>{await kr()});var Jt=k.command("config").description("Manage infra-kit configuration files");Jt.command("path").description("Show the resolved config merge chain and file paths").action(async()=>{await Tr()});Jt.command("edit").description("Open the user-scope per-project override file in $EDITOR").action(async()=>{await $r()});k.command("doctor").description("Check installation and authentication status of gh and doppler CLIs").action(async()=>{await Je()});k.command("version").description("Print the installed infra-kit CLI version").action(async()=>{await fr()});k.command("env-status").description("Show Doppler authentication status and detected project info").action(async()=>{await Ye()});k.command("env-list").description("List available Doppler configs for the detected project").action(async()=>{await Ue()});k.command("init").description("Inject shell integration into your profile .zshrc").action(async()=>{await Er()});k.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 Xe({config:e.config})});k.command("env-clear").description("Clear loaded env vars. Source the returned file path to apply.").action(async()=>{await Ge()});if(Zr.argv.length<=2){let e=["merge-dev","release-list","release-create","release-desc-edit","release-deploy-all","release-deploy-selected","release-deliver"],r=["worktrees-add","worktrees-list","worktrees-open","worktrees-remove","worktrees-sync"],t=["doctor","init","version","config","env-status","env-list","env-load","env-clear"],o=new Map(k.commands.map(c=>[c.name(),c])),s=[...e,...r,...t],n=Math.max(...s.map(c=>c.length)),i=c=>c.filter(p=>o.has(p)).map(p=>({name:`${p.padEnd(n)} ${o.get(p).description()}`,value:p})),l=await Dn({message:"Select a command to run",choices:[new ye(" "),new ye("\u2014 Release Management \u2014"),...i(e),new ye(" "),new ye("\u2014 Worktrees \u2014"),...i(r),new ye(" "),new ye("\u2014 Environment \u2014"),...i(t)]},{output:Zr.stderr});await Lt(["node","infra-kit",l])}else await Lt();
93
+ `);let l={worktrees:s,count:s.length};return{content:h(JSON.stringify(l,null,2)),structuredContent:l}},un=v({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:we.array(we.object({version:we.string().describe("Release version"),type:we.enum(["regular","hotfix"]).describe("Release type"),description:we.string().nullable().describe("Jira version description")})).describe("List of all worktrees with details"),count:we.number().describe("Number of worktrees")},handler:yr});import{z as ve}from"zod/v4";import{$ as fn}from"zx";var kr=async()=>{d.start("worktrees-open");try{let e=await S(),r=`${e}${J}`,t=await N("release"),o=await hn({projectRoot:e,worktreeDir:r,currentBranches:t}),s=await gn({worktreeDir:r,currentBranches:t}),n={openedCmux:s.opened,skippedCmux:s.skipped,cursorFoldersAdded:o.added,cursorFoldersRemoved:o.removed};return wn(n,{cursorRan:o.ran,cmuxRan:s.ran}),d.print(),{content:h(JSON.stringify(n,null,2)),structuredContent:{...n}}}catch(e){throw a.error({error:e},"\u274C Error opening worktrees"),new w(e,{operation:"open worktrees",remediation:"run 'worktrees-list' to confirm the branches exist"})}},hn=async e=>{let{projectRoot:r,worktreeDir:t,currentBranches:o}=e,s=await R(),n=s.ide?.provider==="cursor"?s.ide.config:void 0;if(!n||n.mode!=="workspace"||!n.workspaceConfigPath)return a.warn('\u26A0\uFE0F Skipping Cursor: ide.provider must be "cursor", mode "workspace", and workspaceConfigPath set.'),{ran:!1,added:0,removed:0};let i=W(n.workspaceConfigPath,r);try{let{added:l,removed:c}=await Ur({workspacePath:i,worktreeDir:t,currentBranches:o});return await fn`cursor ${i}`,{ran:!0,added:l.length,removed:c.length}}catch(l){return a.warn({error:l},`\u26A0\uFE0F Failed to reconcile/open Cursor workspace at ${i}`),{ran:!1,added:0,removed:0}}},gn=async e=>{let{worktreeDir:r,currentBranches:t}=e;if(t.length===0)return{ran:!0,opened:[],skipped:[]};let o=await D(),s=await Gr(),n=[],i=[];for(let l of t){let c=F({repoName:o,branch:l});if(s.has(c)){i.push(c);continue}try{await Oe({cwd:`${r}/${l}`,title:c}),n.push(c)}catch(p){a.warn({error:p,title:c},`\u26A0\uFE0F Failed to open cmux workspace for ${l}`)}}return{ran:!0,opened:n,skipped:i}},wn=(e,r)=>{if(r.cursorRan&&(e.cursorFoldersAdded>0&&a.info(`\u2705 Added ${e.cursorFoldersAdded} folder(s) to Cursor workspace`),e.cursorFoldersRemoved>0&&a.info(`\u{1F9F9} Removed ${e.cursorFoldersRemoved} dangling folder(s) from Cursor workspace`)),e.openedCmux.length>0){a.info("\u2705 Opened cmux workspaces:");for(let t of e.openedCmux)a.info(t)}e.skippedCmux.length>0&&a.info(`\u2139\uFE0F Skipped ${e.skippedCmux.length} cmux workspace(s) already open`),!r.cursorRan&&e.openedCmux.length===0&&e.skippedCmux.length===0&&e.cursorFoldersAdded===0&&e.cursorFoldersRemoved===0&&a.info("\u2139\uFE0F Nothing to open")},vn=v({name:"worktrees-open",description:"Open Cursor against the configured workspace file and ensure a cmux workspace exists for each existing release worktree. Idempotent and additive \u2014 never removes worktrees, never recreates running cmux workspaces. Use after a cold start (Cursor + cmux closed). For stale-worktree cleanup, use worktrees-sync.",inputSchema:{},outputSchema:{openedCmux:ve.array(ve.string()).describe("Titles of cmux workspaces opened during this run"),skippedCmux:ve.array(ve.string()).describe("Titles of cmux workspaces that were already open"),cursorFoldersAdded:ve.number().describe("Number of worktree folders added to the Cursor workspace file"),cursorFoldersRemoved:ve.number().describe("Number of dangling worktree folders removed from the Cursor workspace file")},handler:kr});import yn from"@inquirer/checkbox";import kn from"@inquirer/confirm";import Rn from"node:process";import{z as je}from"zod/v4";import{$ as Xr}from"zx";var Rr=async e=>{let{confirmedCommand:r,all:t,versions:o}=e;d.start("worktrees-remove");try{let s=await N("release");if(s.length===0)return a.info("\u2139\uFE0F No active worktrees to remove"),d.print(),{content:h(JSON.stringify({removedWorktrees:[],count:0},null,2)),structuredContent:{removedWorktrees:[],count:0}};let n=await S(),i=`${n}${J}`,l=[];if(t)l=s;else if(o)l=o.split(",").map(g=>`release/v${g.trim()}`);else{d.setInteractive();let[g,$]=await Promise.all([T(),C()]),P=new Map($.map(M=>[M.branch,b(M.title)]));l=await yn({required:!0,message:"\u{1F33F} Select release branches",choices:I({branches:s,descriptions:g,types:P})})}let c=l.length===s.length;c?d.addOption("--all",!0):d.addOption("--versions",l.map(g=>g.replace("release/v","")));let p=r?!0:await kn({message:"Are you sure you want to proceed with these worktree changes?"});r||d.setInteractive(),p||(a.info("Operation cancelled. Exiting..."),Rn.exit(0)),r||d.addOption("--yes",!0);let m=await D(),f=await bn({branches:l,worktreeDir:i,repoName:m,allSelected:c});await Cn({removedWorktrees:f,worktreeDir:i,projectRoot:n}),xn(f),d.print();let u={removedWorktrees:f,count:f.length};return{content:h(JSON.stringify(u,null,2)),structuredContent:u}}catch(s){throw a.error({error:s},"\u274C Error managing worktrees"),new w(s,{operation:"remove worktrees",remediation:"check 'git worktree list' for the path; uncommitted changes block removal"})}},bn=async e=>{let{branches:r,worktreeDir:t,repoName:o,allSelected:s}=e,n=await Promise.allSettled(r.map(async l=>{let c=`${t}/${l}`,p=F({repoName:o,branch:l});return await Ae(p),await Xr`git worktree remove ${c}`,l})),i=[];for(let[l,c]of n.entries())if(c.status==="fulfilled")i.push(c.value);else{let p=r[l],m=new w(c.reason,{operation:`remove worktree for ${p}`,remediation:"check 'git worktree list' for the path; uncommitted changes block removal"});a.error({error:c.reason,msg:m.message})}return s&&i.length===r.length&&(await Xr`git worktree prune`,await Xr`rm -rf ${t}`,a.info(`\u{1F5D1}\uFE0F Removed worktree folder: ${t}`),a.info("")),i},Cn=async e=>{let{removedWorktrees:r,worktreeDir:t,projectRoot:o}=e;if(r.length===0)return;let s=await R(),n=s.ide?.provider==="cursor"?s.ide.config:void 0;if(!n||n.mode!=="workspace"||!n.workspaceConfigPath)return;let i=W(n.workspaceConfigPath,o),l=r.map(c=>`${t}/${c}`);try{let{removed:c}=await Z({workspacePath:i,folderPaths:l});c.length>0&&a.info(`\u2705 Removed ${c.length} folder(s) from ${i}`)}catch(c){a.warn({error:c},`\u26A0\uFE0F Failed to update Cursor workspace at ${i}`)}},xn=e=>{if(e.length>0){a.info("\u274C Removed worktrees:");for(let r of e)a.info(r);a.info("")}else a.info("\u2139\uFE0F No unused worktrees to remove")},Tn=v({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:je.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:je.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:je.array(je.string()).describe("List of removed git worktree branches"),count:je.number().describe("Number of git worktrees removed")},handler:Rr});import $n from"@inquirer/confirm";import Pn from"node:process";import{z as Yr}from"zod/v4";import{$ as En}from"zx";var Sn="release/v",br=async e=>{let{confirmedCommand:r}=e;d.start("worktrees-sync");try{let t=await N("release"),o=await S(),s=`${o}${J}`,n=await nr(),i=r?!0:await $n({message:"Are you sure you want to proceed with these worktree changes?"});r||d.setInteractive(),i||(a.info("Operation cancelled. Exiting..."),Pn.exit(0)),r||d.addOption("--yes",!0);let{branchesToRemove:l}=In({releasePRsList:n,currentWorktrees:t}),c=await D(),p=await An({branches:l,worktreeDir:s,repoName:c});await _n({removedWorktrees:p,worktreeDir:s,projectRoot:o}),On(p),d.print();let m={removedWorktrees:p,count:p.length};return{content:h(JSON.stringify(m,null,2)),structuredContent:m}}catch(t){throw a.error({error:t},"\u274C Error managing worktrees"),new w(t,{operation:"sync worktrees with remote",remediation:"ensure 'gh auth status' is ok and you can reach origin"})}},In=e=>{let{releasePRsList:r,currentWorktrees:t}=e;return{branchesToRemove:t.filter(n=>n.startsWith(Sn)).filter(n=>!r.includes(n))}},An=async e=>{let{branches:r,worktreeDir:t,repoName:o}=e,s=[];for(let n of r)try{let i=`${t}/${n}`,l=F({repoName:o,branch:n});await Ae(l),await En`git worktree remove ${i}`,s.push(n)}catch(i){let l=new w(i,{operation:`remove stale worktree for ${n}`,remediation:"inspect the worktree dir manually; rerun with the branch checked out elsewhere"});a.error({error:i,branch:n,msg:l.message})}return s},_n=async e=>{let{removedWorktrees:r,worktreeDir:t,projectRoot:o}=e;if(r.length===0)return;let s=await R(),n=s.ide?.provider==="cursor"?s.ide.config:void 0;if(!n||n.mode!=="workspace"||!n.workspaceConfigPath)return;let i=W(n.workspaceConfigPath,o),l=r.map(c=>`${t}/${c}`);try{let{removed:c}=await Z({workspacePath:i,folderPaths:l});c.length>0&&a.info(`\u2705 Removed ${c.length} folder(s) from ${i}`)}catch(c){a.warn({error:c},`\u26A0\uFE0F Failed to update Cursor workspace at ${i}`)}},On=e=>{if(e.length>0){a.info("\u274C Removed worktrees:");for(let r of e)a.info(r);a.info("")}else a.info("\u2139\uFE0F No unused worktrees to remove")},Nn=v({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:Yr.array(Yr.string()).describe("List of removed worktree branches"),count:Yr.number().describe("Number of worktrees removed during sync")},handler:br});var k=new jn,Mn=(e,r)=>[...r,e],Fn=e=>{if(!(typeof e>"u")){if(e===!0)return"workspace";if(e===!1)return"none";if(typeof e=="string"&&De.includes(e))return e;throw new Error(`Invalid --cursor value "${String(e)}". Expected one of: ${De.join(", ")}.`)}},Lt=async e=>{try{e?await k.parseAsync(e):await k.parseAsync()}catch(r){let t=r instanceof Error?r.message:String(r);a.error(t),Zr.exit(1)}};k.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 ar({all:e.all,confirmedCommand:e.yes})});k.command("release-list").description("List all release branches").action(async()=>{await mr()});k.command("release-create").description("Create one or more release branches (each entry can mix regular/hotfix and its own description)").option("-r, --release <spec>",'Release spec "version[:type[:description]]" (repeatable). Examples: "1.2.5", "1.2.5:hotfix", "next:regular:Holiday backend"',Mn,[]).option("-y, --yes","Skip confirmation prompt").action(async e=>{let r=e.release,t=r.length>0?r.map(Lr):void 0;await dr({releases:t,confirmedCommand:e.yes})});k.command("release-desc-edit").description("Edit a release's description in Jira and in the matching GitHub PR body").option("-v, --version <version>","Release version, e.g. 1.2.5").option("-d, --description <description>",'New description (use "" to clear)').option("-y, --yes","Skip confirmation prompt").action(async e=>{await ur({version:e.version,description:e.description,confirmedCommand:e.yes})});k.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 lr({version:e.version,env:e.env,skipTerraform:e.skipTerraform})});k.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 pr({version:e.version,env:e.env,services:e.services,skipTerraform:e.skipTerraform})});k.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 cr({version:e.version,confirmedCommand:e.yes})});k.command("worktrees-sync").description("Remove release worktrees whose PRs are no longer open").option("-y, --yes","Skip confirmation prompt").action(async e=>{await br({confirmedCommand:e.yes})});k.command("worktrees-add").description("Add git worktrees for release branches").option("-y, --yes","Skip confirmation prompt").option("-a, --all","Select all active release branches").option("-v, --versions <versions>","Specify versions by comma, e.g. 1.2.5, 1.2.6").option("-c, --cursor [mode]","Cursor mode for created worktrees: workspace (default) | windows | none").option("--no-cursor","Skip Cursor (alias for --cursor none)").option("-g, --github-desktop","Open created worktrees in GitHub Desktop").option("--no-github-desktop","Skip GitHub Desktop prompt").option("-m, --cmux","Open created worktrees in cmux (3-pane layout)").option("--no-cmux","Skip cmux prompt").action(async e=>{await vr({confirmedCommand:e.yes,all:e.all,versions:e.versions,cursor:Fn(e.cursor),githubDesktop:e.githubDesktop,cmux:e.cmux})});k.command("worktrees-list").description("List all git worktrees with detailed information").action(async()=>{await yr()});k.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 Rr({confirmedCommand:e.yes,all:e.all,versions:e.versions})});k.command("worktrees-open").description("Open Cursor + cmux for existing release worktrees (cold-start restore)").action(async()=>{await kr()});var Jt=k.command("config").description("Manage infra-kit configuration files");Jt.command("path").description("Show the resolved config merge chain and file paths").action(async()=>{await Tr()});Jt.command("edit").description("Open the user-scope per-project override file in $EDITOR").action(async()=>{await $r()});k.command("doctor").description("Check installation and authentication status of gh and doppler CLIs").action(async()=>{await Je()});k.command("version").description("Print the installed infra-kit CLI version").action(async()=>{await fr()});k.command("env-status").description("Show Doppler authentication status and detected project info").action(async()=>{await Ye()});k.command("env-list").description("List available Doppler configs for the detected project").action(async()=>{await Ue()});k.command("init").description("Inject shell integration into your profile .zshrc").action(async()=>{await Er()});k.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 Xe({config:e.config})});k.command("env-clear").description("Clear loaded env vars. Source the returned file path to apply.").action(async()=>{await Ge()});if(Zr.argv.length<=2){let e=["merge-dev","release-list","release-create","release-desc-edit","release-deploy-all","release-deploy-selected","release-deliver"],r=["worktrees-add","worktrees-list","worktrees-open","worktrees-remove","worktrees-sync"],t=["doctor","init","version","config","env-status","env-list","env-load","env-clear"],o=new Map(k.commands.map(c=>[c.name(),c])),s=[...e,...r,...t],n=Math.max(...s.map(c=>c.length)),i=c=>c.filter(p=>o.has(p)).map(p=>({name:`${p.padEnd(n)} ${o.get(p).description()}`,value:p})),l=await Dn({message:"Select a command to run",choices:[new ye(" "),new ye("\u2014 Release Management \u2014"),...i(e),new ye(" "),new ye("\u2014 Worktrees \u2014"),...i(r),new ye(" "),new ye("\u2014 Environment \u2014"),...i(t)]},{output:Zr.stderr});await Lt(["node","infra-kit",l])}else await Lt();
94
94
  //# sourceMappingURL=cli.js.map