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