infra-kit 0.1.129 → 0.1.130

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.
@@ -0,0 +1,159 @@
1
+ import{a as zr,b as ze,c as Gr,g as Kr,h as ne,i as Ge}from"./chunk-Q36WX5RP.js";import{b as Ce,c as vt,d as yt,e as lr,f as fn}from"./chunk-Z6KTUVIC.js";import{a as F,b as Wr,c as ar,d as mn,e as Vr,f as Le,g as We,h as Jr,i as Ve,j as Ee,k as Je,l as Br,m as Be,n as un,o as cr,p as $e,q as Z,r as m}from"./chunk-V375VXOL.js";import{E as an,F as cn,G as ln,I as pn,J as Rt,K as q,M as H,N as b,O as Te,a as Zo,b as jr,c as P,d as oe,e as me,f as Xo,g as wt,h as J,i as $,j as Lr,k as Yo,l as M,m as y,n as Qo,o as en,p as rn,q as U,r as tn,s as on,v as l,x as nn,y as sn}from"./chunk-4YU4TAGX.js";import{a as kt,c as dn}from"./chunk-YGCVOVNX.js";import mr from"node:path";import pi from"node:process";import{z as j}from"zod";import Us from"node:fs/promises";var se=async e=>{try{return await Us.access(e),!0}catch{return!1}};import si from"node:path";import gn from"node:fs/promises";import hn from"node:path";import{pathToFileURL as qs}from"node:url";import{z as Hs}from"zod";var ue="infra-kit.config.ts",bt=async e=>{try{let r=await gn.readFile(hn.join(e,"package.json"),"utf-8");return JSON.parse(r)}catch{return{}}},pr=async(e,r=Ce)=>{let t=hn.join(e,ue);if(!await se(t))throw new Error(`${ue} not found at ${t}`);let o=await gn.stat(t),i=(await import(`${qs(t).href}?mtime=${Number(o.mtimeMs)}`)).default;if(i===void 0)throw new Error(`${ue} at ${t} has no default export`);let c=typeof i=="function"?await i():i,a=kt.safeParse(c);if(!a.success)throw new Error(`Invalid ${ue} at ${t}: ${Hs.prettifyError(a.error)}`);return yt(a.data,r)};import wn from"node:fs/promises";import Ur from"node:path";import Zs from"yaml";var Xs="pnpm-workspace.yaml",Ys=async e=>(await wn.readdir(e,{withFileTypes:!0}).catch(()=>[])).filter(t=>t.isDirectory()).map(t=>Ur.join(e,t.name)),Qs=async(e,r)=>{let t=[];for(let o of e){if(r==="*"){t.push(...await Ys(o));continue}let n=Ur.join(o,r);await se(n)&&t.push(n)}return t},ei=async(e,r)=>{let t=[e];for(let o of r.split("/"))t=await Qs(t,o);return t},dr=async e=>{let r=await wn.readFile(Ur.join(e,Xs),"utf-8"),o=((Zs.parse(r)??{}).packages??[]).filter(s=>!s.startsWith("!")&&!s.startsWith("vendor")),n=new Set;for(let s of o){let i=await ei(e,s);for(let c of i)await se(Ur.join(c,"package.json"))&&n.add(c)}return[...n].sort()};var xt=async(e,r=Ce)=>{try{let t=await pr(e,r);return{check:{name:ue,status:"pass",message:"present and valid"},rules:t}}catch(t){return{check:{name:ue,status:"fail",message:t.message},rules:null}}};import ri from"node:fs/promises";import ti from"node:path";var Ct=async(e,r)=>Promise.all(r.map(async t=>{let o=await ri.stat(ti.join(e,t)).catch(()=>null);return o?o.isFile()?{name:`file:${t}`,status:"pass",message:"exists"}:{name:`file:${t}`,status:"fail",message:`not a file: ${t} (found a directory)`}:{name:`file:${t}`,status:"fail",message:`missing file: ${t}`}}));var Tt=(e,r)=>r.map(t=>{let o=e[t];return typeof o!="string"?{name:`script:${t}`,status:"fail",message:`missing "${t}" in package.json scripts`}:o.trim().length===0?{name:`script:${t}`,status:"fail",message:`"${t}" is empty in package.json scripts`}:{name:`script:${t}`,status:"pass",message:"defined"}});import oi from"node:fs/promises";import ni from"node:path";var Ke="turbo.json",Et=async(e,r)=>{if(r.length===0)return[];let t;try{let n=await oi.readFile(ni.join(e,Ke),"utf-8");t=JSON.parse(n)}catch(n){return[{name:Ke,status:"fail",message:`cannot read/parse ${Ke}: ${n.message}`}]}let o=t.tasks;return o===null||typeof o!="object"?[{name:Ke,status:"fail",message:`no "tasks" object defined in ${Ke}`}]:r.map(n=>{let s=n in o||`//#${n}`in o;return{name:`turbo:${n}`,status:s?"pass":"fail",message:s?"defined":`missing turbo task "${n}" in ${Ke}`}})};var $t=async(e,r=Ce)=>{let t=await bt(e),o=t.name??si.basename(e),{check:n,rules:s}=await xt(e,r),i=[n];s&&(i.push(...Tt(t.scripts??{},s.requiredScripts)),i.push(...await Ct(e,s.requiredFiles)),i.push(...await Et(e,s.turboTasks)));let c=i.every(a=>a.status==="pass");return{packageDir:e,packageName:o,checks:i,passed:c}};var g=e=>[{type:"text",text:e}],w=e=>e;import ii from"node:path";var ai=(e,r)=>{let t=new Set;for(let o of Object.values(e))for(let n of Object.keys(an(o,r).proxy))t.add(n);return[...t]},ci=async(e,r)=>{let t={},o=[];return await Promise.all(r.map(async n=>{try{let i=(await dn(ii.join(e,"apps",n,"ui")))?.proxy?.routes;if(!i)return;t[n]=Object.fromEntries(Object.entries(i).map(([c,a])=>[c,a.packageName]))}catch(s){o.push({app:n,message:s instanceof Error?s.message:String(s)})}})),{routePkg:(n,s)=>t[n]?.[s],loadErrors:o}},li=(e,r)=>[...r.map(t=>({name:`devServersPresets:config:${t.app}`,status:"fail",message:`could not load apps/${t.app}/ui/infra-kit.config.ts (referenced by a preset proxy override): ${t.message}`})),...e.map(t=>({name:`devServersPresets:${t.preset}`,status:"fail",message:t.message}))],vn=async e=>{let r=(await b()).devServersPresets;if(!r||Object.keys(r).length===0)return null;let t=nn(e),o=sn(e),n={api:t.map(d=>d.name),ui:o.map(d=>d.name)},{routePkg:s,loadErrors:i}=await ci(e,ai(r,n)),c={discovered:n,apiPkgByApp:Object.fromEntries(t.map(d=>[d.name,d.packageName])),routePkg:s},a=li(cn(r,c),i),p=a.length===0?[{name:"devServersPresets:proxy-locality",status:"pass",message:"every local proxy override resolves to a backend the preset launches"}]:a;return{packageDir:e,packageName:"devServersPresets",checks:p,passed:a.length===0}};var di=async e=>{let r=mr.resolve(e);for(;r!==mr.dirname(r);){if(await se(mr.join(r,"package.json")))return r;r=mr.dirname(r)}if(await se(mr.join(r,"package.json")))return r;throw new Error(`No package.json found in or above ${e}`)},mi=async e=>e.root?[{dir:await y(),baseline:vt}]:e.all?(await dr(await y())).map(t=>({dir:t})):[{dir:await di(e.cwd??pi.cwd())}],ui=e=>{let r=e.passed?"PASS":"FAIL";l.info(`
2
+ ${e.packageName} \u2014 ${r}`);for(let t of e.checks){let o=t.status==="pass"?"[PASS]":"[FAIL]";l.info(` ${o} ${t.name}: ${t.message}`)}},yn=async(e={})=>{let r=await mi(e),t=[];for(let s of r)t.push(await $t(s.dir,s.baseline));if(e.root){let s=await vn(r[0].dir);s&&t.push(s)}for(let s of t)ui(s);let o=t.every(s=>s.passed);l.info(`
3
+ ${o?"\u2705 All valid":"\u274C Audit failed"} (${t.length} checked)`);let n={allPassed:o,packages:t.map(s=>({name:s.packageName,passed:s.passed,checks:s.checks}))};return{content:g(JSON.stringify(n,null,2)),structuredContent:n}},fi={all:j.boolean().optional().describe("Audit every non-vendor workspace package"),root:j.boolean().optional().describe("Audit the monorepo root (turbo pipeline + root commands)")},gi={allPassed:j.boolean().describe("Whether every audited package passed all checks"),packages:j.array(j.object({name:j.string(),passed:j.boolean(),checks:j.array(j.object({name:j.string(),status:j.enum(["pass","fail"]),message:j.string()}))})).describe("Per-package check results")},Pt=w({name:"audit",description:"Audit packages against infra-kit.config.ts rules (config present and valid, required scripts, required files, and turbo tasks for the root). Defaults to the current package; all=true audits every non-vendor workspace package; root=true audits the monorepo root.",inputSchema:fi,outputSchema:gi,handler:e=>yn({all:e.all,root:e.root})});import ge from"node:fs";import Nn from"node:os";import wr from"node:path";import Oi from"node:process";var Ue=(e,r,t)=>{let o=e.indexOf(r),n=e.indexOf(t);return o!==-1&&n!==-1&&n>=o},fe=(e,r,t)=>{let o=e.indexOf(r),n=e.indexOf(t);if(o===-1||n===-1||n<o)return null;let s=e.slice(0,o).replace(/\n+$/,""),i=e.slice(n+t.length).replace(/^\n+/,"");return s+(i?`
4
+ ${i}`:"")};var kn=(e,r,t)=>`${e}
5
+ ${r}
6
+ ${t}`,ur=({content:e,body:r,startMarker:t,endMarker:o,placement:n="replace-in-place"})=>{let s=kn(t,r,o),i=Ue(e,t,o);if(n==="replace-in-place"&&i){let p=e.indexOf(t),d=e.indexOf(o)+o.length;return e.slice(0,p)+s+e.slice(d)}let a=(i?fe(e,t,o)??e:e).replace(/\n+$/,"");return a.length>0?`${a}
7
+ ${s}
8
+ `:`${s}
9
+ `};import N from"node:fs";import fr from"node:path";var qr={name:"infra-kit",type:"module",version:"0.1.130",files:["dist"],description:"infra-kit",main:"dist/index.js",module:"dist/index.js",types:"dist/entry/index.d.ts",exports:{".":{types:"./dist/entry/index.d.ts",import:"./dist/index.js"},"./vite":{types:"./dist/entry/vite.d.ts",import:"./dist/vite.js"}},bin:{"infra-kit":"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","infra-kit-check":"pnpm exec infra-kit audit","clean-artifacts":"rm -rf dist","clean-cache":"rm -rf node_modules/.cache .eslintcache tsconfig.tsbuildinfo .turbo .swc","prettier-fix":"pnpm exec prettier **/* --write --no-error-on-unmatched-pattern --log-level silent --ignore-path ../../../.prettierignore","prettier-check":"pnpm exec prettier **/* --check --no-error-on-unmatched-pattern --log-level silent --ignore-path ../../../.prettierignore","eslint-check":"pnpm exec eslint --cache --quiet --report-unused-disable-directives ./src","eslint-fix":"pnpm exec eslint --cache --quiet --report-unused-disable-directives ./src --fix","ts-check":"tsc --noEmit",test:"pnpm exec vitest run --reporter=minimal","test-watch":"pnpm exec vitest --watch --silent passed-only","test-ui":"pnpm exec vitest --ui --silent passed-only","test-report":"pnpm exec vitest run --coverage --silent passed-only",qa:"pnpm run prettier-check && pnpm run eslint-check && pnpm run ts-check && pnpm run test && echo \u2705 Success",fix:"pnpm run prettier-fix && pnpm run eslint-fix && pnpm run qa"},dependencies:{"@aws-lambda-powertools/logger":"^2.33.1","@inquirer/checkbox":"^5.2.1","@inquirer/confirm":"^6.1.1","@inquirer/select":"^5.2.1","@modelcontextprotocol/sdk":"^1.29.0",chalk:"^5.6.2",chokidar:"^5.0.0",commander:"^15.0.0",fastify:"5.10.0",ink:"^7.1.0",pino:"^10.3.1","pino-pretty":"^13.1.3",portless:"^0.15.1",react:"19.2.7",yaml:"^2.9.0",zod:"^4.4.3",zx:"^8.8.5"},devDependencies:{"@types/aws-lambda":"^8.10.162","@types/react":"19.2.17","@wl/eslint-config":"workspace:*","@wl/vitest-config":"workspace:*",esbuild:"^0.28.1","ink-testing-library":"^4.0.0",typescript:"^6.0.3"}};var gr="<!-- infra-kit:begin -->",hr="<!-- infra-kit:end -->",wi="<!-- infra-kit:version ",vi="<!-- infra-kit:import:begin -->",yi="<!-- infra-kit:import:end -->",ki="AGENTS.md",Ri="CLAUDE.md",bi=e=>`${wi}${e} -->`,xi=e=>[bi(e),"","# infra-kit","","This repository uses the **infra-kit** CLI for environment, worktree, and release workflows.","This block is generated by `infra-kit init` \u2014 edit text *outside* the markers, never inside.","","## Commands (`ik` = `pnpm exec infra-kit`)","","- `ik env-load -c <config>` / `ik env-clear` / `ik env-status` \u2014 load, clear, or inspect Doppler env vars for a config (e.g. `dev`). Source the returned file to apply.","- `ik worktrees add` / `worktrees list` / `worktrees reload` / `worktrees remove` / `worktrees sync` \u2014 manage release and feature git worktrees.","- `ik release create` / `release list` / `release deploy-all` / `release deploy-selected` / `release deliver` / `release desc-edit` \u2014 release-branch and deploy flow.","- `ik release merge-dev` \u2014 merge the dev branch into every release branch.","- `ik audit` \u2014 audit packages against `infra-kit.config.ts` rules.","- `ik doctor` \u2014 check gh / doppler / aws / rtk install + auth and repo setup.","- `ik init` \u2014 (re)install shell integration and regenerate these agent-instruction files.","","## Conventions","","- Tickets are prefixed by area: `[FE]` frontend, `[BE]` backend, `[DO]` DevOps/infra, `[APP]` mobile app, `[IDEA]` proposal, `[ROOT]` cross-cutting. Pick the single dominant area.","- Environment variables are managed through Doppler via `ik env-load` \u2014 never commit secrets."].join(`
10
+ `),Rn=e=>{if(N.existsSync(e)&&N.lstatSync(e).isSymbolicLink())throw new Error(`Refusing to write ${e} because the destination is a symlink`)},bn=e=>{let r=new Date().toISOString().replace(/[:.]/g,"-");N.copyFileSync(e,`${e}.backup.${r}`)},xn=(e,r)=>{Rn(e);let t=N.existsSync(e);return(t?N.readFileSync(e,"utf-8"):null)===r?"unchanged":(t&&bn(e),N.mkdirSync(fr.dirname(e),{recursive:!0}),N.writeFileSync(e,r,"utf-8"),t?"updated":"created")},Ci=(e,r)=>N.existsSync(e)?N.readFileSync(e,"utf-8"):r,Ti=(e,r,t)=>{let o=N.readFileSync(e,"utf-8");if(!Ue(o,r,t))throw new Error(`Post-write validation failed: managed block missing from ${e}`)},Ei=e=>{if(!N.existsSync(e))return"unchanged";Rn(e);let r=N.readFileSync(e,"utf-8"),t=fe(r,gr,hr);return t===null?"unchanged":t.trim()===""?(bn(e),N.rmSync(e),"removed"):xn(e,t)},Cn=async()=>{let e;try{e=(await H()).main}catch{return l.info("Skipped agent-instruction files \u2014 not inside an infra-kit repo"),{skipped:!0,root:null,written:[]}}if(!N.existsSync(e))return l.info("Skipped agent-instruction files \u2014 no infra-kit.json at the repo root"),{skipped:!0,root:null,written:[]};let r=fr.dirname(e),t=qr.version,o=xi(t),n=fr.join(r,ki),s=fr.join(r,Ri),i=Ci(s,"");i=fe(i,vi,yi)??i,i=ur({content:i,body:o,startMarker:gr,endMarker:hr,placement:"replace-in-place"});let c=[{path:s,action:xn(s,i)},{path:n,action:Ei(n)}];Ti(s,gr,hr);for(let a of c)a.action==="unchanged"&&a.path!==s||l.info(` ${a.action.padEnd(9)} ${fr.relative(r,a.path)}`);return l.info(`Agent-instruction files synced (infra-kit ${t})`),{skipped:!1,root:r,written:c}};import L from"node:fs/promises";import X from"node:path";import{pathToFileURL as Ai}from"node:url";import _i from"yaml";import{z as Pn}from"zod";import $i from"node:fs/promises";import Pi from"node:os";var ie=async e=>{try{return await $i.access(e),!0}catch{return!1}},k=e=>{let r=Pi.homedir();return e.startsWith(r)?`~${e.slice(r.length)}`:e};import Si from"node:fs/promises";import St from"node:os";import It from"node:path";import{z as Ii}from"zod";import{z as Hr}from"zod";var Tn="vendor.json",Zr=Hr.object({workspaceDir:Hr.string().min(1),targets:Hr.array(Hr.string()).min(1)}).strict();var At=()=>It.join(St.homedir(),ln,Tn),En=e=>{if(e==="~")return St.homedir();if(e.startsWith("~/"))return It.join(St.homedir(),e.slice(2));if(It.isAbsolute(e))return e;throw new Error(`workspaceDir must be absolute or ~-prefixed, got: ${e}`)},qe=async()=>{let e=At(),r;try{r=await Si.readFile(e,"utf-8")}catch{throw new Error(`Factory config not found at ${e}. infra-kit needs a machine-local factory registry to know where your project repos live and which to stamp. Run \`infra-kit vendor-config --init\` to scaffold it, or create it manually as JSON:
11
+
12
+ {
13
+ "workspaceDir": "~/projects",
14
+ "targets": ["my-repo"]
15
+ }
16
+ `)}let t;try{t=r.trim()===""?{}:JSON.parse(r)}catch(n){throw new Error(`Invalid JSON in vendor.json at ${e}: ${n.message}`)}let o=Zr.safeParse(t);if(!o.success)throw new Error(`Invalid factory config at ${e}: ${Ii.prettifyError(o.error)}`);return o.data};var $n=e=>e.replace(/\.json$/,".yml"),Sn=async()=>{let e;try{e=await H()}catch{return}let r=[{label:"infra-kit.json",yml:$n(e.main),json:e.main,schema:pn},{label:"~/.infra-kit/infra-kit.json",yml:X.join(X.dirname(e.userGlobal),"config.yml"),json:e.userGlobal,schema:Rt},{label:`~/.infra-kit/projects/${e.projectName}/infra-kit.json`,yml:$n(e.userProject),json:e.userProject,schema:Rt}],t=0;for(let o of r){let[n,s]=await Promise.all([ie(o.yml),ie(o.json)]);if(n){if(s){l.info(`\u26A0 Skipped ${k(o.yml)} \u2014 ${k(o.json)} already exists (remove the stale .yml manually)`);continue}try{let i=await L.readFile(o.yml,"utf-8"),c=_i.parse(i)??{},a=o.schema.safeParse(c);if(!a.success){l.info(`\u26A0 Skipped ${k(o.yml)} \u2014 invalid config: ${Pn.prettifyError(a.error)}`);continue}await L.mkdir(X.dirname(o.json),{recursive:!0}),await L.writeFile(o.json,`${JSON.stringify(a.data,null,2)}
17
+ `,"utf-8"),await L.rm(o.yml,{force:!0}),l.info(`\u2713 Migrated ${k(o.yml)} \u2192 ${k(o.json)}`),t++}catch(i){l.info(`\u26A0 Skipped ${k(o.yml)} \u2014 ${i.message}`)}}}t>0&&Te()},In=async()=>{let e;try{e=await H()}catch{return}let r=X.dirname(e.userGlobal),t=[{from:X.join(r,"config.json"),to:e.userGlobal},{from:X.join(r,"config.example.jsonc"),to:X.join(r,"infra-kit.example.jsonc")}],o=0;for(let{from:n,to:s}of t){let[i,c]=await Promise.all([ie(n),ie(s)]);if(i){if(c){l.info(`\u26A0 Skipped ${k(n)} \u2014 ${k(s)} already exists (remove the stale file manually)`);continue}try{await L.mkdir(X.dirname(s),{recursive:!0}),await L.rename(n,s),l.info(`\u2713 Renamed ${k(n)} \u2192 ${k(s)}`),o++}catch(a){l.info(`\u26A0 Skipped ${k(n)} \u2014 ${a.message}`)}}}o>0&&Te()},An=async()=>{let e=At(),r=X.dirname(e),t=X.join(r,"vendor.config.ts"),[o,n]=await Promise.all([ie(t),ie(e)]);if(o){if(n){l.info(`\u26A0 Skipped ${k(t)} \u2014 ${k(e)} already exists (remove the stale vendor.config.ts manually)`);return}try{let s=await L.stat(t),a=(await import(`${Ai(t).href}?mtime=${Number(s.mtimeMs)}`)).default,p=typeof a=="function",d=p?await a():a,u=Zr.safeParse(d);if(!u.success){l.info(`\u26A0 Skipped ${k(t)} \u2014 invalid factory config: ${Pn.prettifyError(u.error)}`);return}await L.mkdir(r,{recursive:!0}),await L.writeFile(e,`${JSON.stringify(u.data,null,2)}
18
+ `,"utf-8"),await L.rm(t,{force:!0}),p?l.info(`\u26A0 Migrated ${k(t)} \u2192 ${k(e)} as a STATIC SNAPSHOT \u2014 the old file was a function (export default () => ({...})); computed values (env vars, directory globbing) were frozen at their current values and no longer re-evaluate. Edit ${k(e)} directly to change them.`):l.info(`\u2713 Migrated ${k(t)} \u2192 ${k(e)}`)}catch(s){l.info(`\u26A0 Skipped ${k(t)} \u2014 ${s.message}`)}}},Ni=e=>{let r=e.ide;if(r===null||typeof r!="object")return{changed:!1,result:e};let t=!1,o=s=>{if(s===null||typeof s!="object"||!("config"in s))return s;let i=s.config;if(i===null||typeof i!="object"||!("mode"in i))return s;t=!0;let c=Object.fromEntries(Object.entries(i).filter(([a])=>a!=="mode"));return{...s,config:c}},n=Array.isArray(r)?r.map(o):o(r);return t?{changed:!0,result:{...e,ide:n}}:{changed:!1,result:e}},_n=async()=>{let e;try{e=await H()}catch{return}let r=[e.main,e.userGlobal,e.userProject],t=0;for(let o of r)if(await ie(o))try{let n=await L.readFile(o,"utf-8");if(n.trim()==="")continue;let s=JSON.parse(n),{changed:i,result:c}=Ni(s);if(!i)continue;await L.writeFile(o,`${JSON.stringify(c,null,2)}
19
+ `,"utf-8"),l.info(`\u2713 Normalized ide config in ${k(o)} (removed legacy "mode")`),t++}catch(n){l.info(`\u26A0 Skipped normalizing ${k(o)} \u2014 ${n.message}`)}t>0&&Te()};var vr="# -- infra-kit:begin --",He="# -- infra-kit:end --",Di=[["# region infra-kit","# endregion infra-kit"]],Mi="# infra-kit shell functions",Fi=`{}
20
+ `,ji=`// infra-kit user-global config \u2014 ~/.infra-kit/infra-kit.json
21
+ //
22
+ // Merge chain (later layers override earlier ones at top-level keys):
23
+ // 1. <repo>/infra-kit.json \u2014 committed project config (required)
24
+ // 2. ~/.infra-kit/infra-kit.json \u2014 user-global (the sibling of this file)
25
+ // 3. ~/.infra-kit/projects/<repo-name>/infra-kit.json \u2014 user-scope per-project override
26
+ //
27
+ // Merge is shallow: setting a top-level key replaces that whole section from
28
+ // layer 1. Arrays do not concatenate. Top-level keys recognized:
29
+ // environments, envManagement, ide, taskManager, worktrees, envAutoLoad.
30
+ //
31
+ // This .example.jsonc is reference only \u2014 it is NOT loaded. Put real global
32
+ // overrides in the sibling infra-kit.json (strict JSON: no comments, double-quoted
33
+ // keys). Per-project tweaks belong in layer 3 \u2014 run \`infra-kit config edit\`.
34
+ //
35
+ // Every recognized key is documented below. NOTE: \`environments\` and
36
+ // \`envManagement\` are REQUIRED in the committed project infra-kit.json (layer 1)
37
+ // and are usually NOT set in this user-global layer \u2014 they are shown here only to
38
+ // document the full, valid config shape.
39
+ {
40
+ // "environments": ["dev", "staging", "prod"], // string[] (>=1) \u2014 required in layer 1
41
+ //
42
+ // "envManagement": { // required in layer 1; provider-tagged
43
+ // "provider": "doppler",
44
+ // "config": { "name": "my-doppler-project" }
45
+ // },
46
+ //
47
+ // "ide": {
48
+ // "provider": "cursor",
49
+ // "config": { "workspaceConfigPath": "/path/to/your.code-workspace" }
50
+ // },
51
+ // // Or, for Zed (no workspace file \u2014 one window with all worktrees via "zed <root> <wt...>"):
52
+ // "ide": { "provider": "zed", "config": {} },
53
+ // // Or drive BOTH editors at once with an array (at most one entry per provider):
54
+ // "ide": [
55
+ // { "provider": "cursor", "config": { "workspaceConfigPath": "/path/to/your.code-workspace" } },
56
+ // { "provider": "zed", "config": {} }
57
+ // ],
58
+ //
59
+ // "taskManager": {
60
+ // "provider": "jira",
61
+ // "config": { "baseUrl": "https://acme.atlassian.net", "projectId": 123 }
62
+ // },
63
+ //
64
+ // "worktrees": {
65
+ // "openInGithubDesktop": false,
66
+ // "openInCmux": true,
67
+ // // cmux pane layout for opened worktrees: "two-columns" (default, left | right)
68
+ // // or "three-pane" (left split top/bottom + full-height right).
69
+ // "cmux": { "layout": "two-columns" }
70
+ // },
71
+ //
72
+ // // Auto-load Doppler env when working inside this project/worktree. Omit to
73
+ // // disable. "trigger" (pick one): "shell-startup" (new shells) | "cli-invocation"
74
+ // // (before each infra-kit command, primes subsequent commands). "config" is the
75
+ // // environment to load (must be one of "environments"). Requires the committed
76
+ // // infra-kit.json at the git repo root, and the zsh shell integration
77
+ // // (infra-kit init + a new shell). zsh only.
78
+ // "envAutoLoad": { "trigger": "shell-startup", "config": "dev" }
79
+ }
80
+ `,Li=`// infra-kit factory registry \u2014 ~/.infra-kit/vendor.json
81
+ //
82
+ // Machine-local registry the vendor commands (sync/manifest/diff) read to know
83
+ // where your project repos live and which ones to stamp. This .example.jsonc is
84
+ // reference only \u2014 it is NOT loaded. The real file is the strict-JSON sibling
85
+ // vendor.json (no comments, double-quoted keys); run \`infra-kit vendor config --init\`
86
+ // to scaffold it.
87
+ {
88
+ // "workspaceDir": "~/projects", // string (absolute or ~-prefixed) \u2014 where target repos are cloned
89
+ // "targets": ["my-repo-a", "my-repo-b"] // string[] (>=1) \u2014 repo dir names resolved under workspaceDir
90
+ }
91
+ `,Sd=async()=>{let e=wr.join(Nn.homedir(),".zshrc"),r=ge.existsSync(e)?Ji(ge.readFileSync(e,"utf-8")):"",t=ur({content:r,body:On(),startMarker:vr,endMarker:He,placement:"append-end"});ge.writeFileSync(e,t),l.info(`Added infra-kit shell functions to ${e}`),await Sn(),await _n(),await In(),await An(),Wi(),await Cn();let o=Oi.env.SHELL??"";o.includes("zsh")||l.warn(`Your login shell ($SHELL=${o||"unset"}) is not zsh. The infra-kit shell integration (env-load/env-clear/auto-load) is zsh-only and won't activate in bash/fish.`),l.info("Run `source ~/.zshrc` or open a new terminal to activate.")},Wi=()=>{let e=wr.join(Nn.homedir(),".infra-kit"),r=wr.join(e,"infra-kit.json");if(ge.mkdirSync(e,{recursive:!0}),ge.writeFileSync(wr.join(e,"infra-kit.example.jsonc"),ji,"utf-8"),ge.writeFileSync(wr.join(e,"vendor.example.jsonc"),Li,"utf-8"),ge.existsSync(r)){l.info(`User-global config already present at ${r} (refreshed reference examples)`);return}ge.writeFileSync(r,Fi,"utf-8"),l.info(`Wrote user-global config to ${r} (see the sibling .example.jsonc files for reference)`)},Vi=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"),Ji=e=>{let r=fe(e,vr,He);if(r!==null)return r;for(let[c,a]of Di){let p=fe(e,c,a);if(p!==null)return p}let t=e.indexOf(Mi);if(t===-1)return e;let o=e.slice(0,t).replace(/\n+$/,""),n=e.slice(t).split(`
92
+ `),s=0;for(;s<n.length&&Vi(n[s]);)s++;let i=n.slice(s).join(`
93
+ `);return o+(i?`
94
+ ${i}`:"")},On=()=>{let e="pnpm exec infra-kit";return["zmodload zsh/stat 2>/dev/null","zmodload zsh/datetime 2>/dev/null","zmodload zsh/sched 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}}",": ${_INFRA_KIT_WARM_TTL:=7200}","export _INFRA_KIT_LAST_LOAD_MTIME _INFRA_KIT_LAST_CLEAR_MTIME _INFRA_KIT_SHELL_STARTED _INFRA_KIT_WARM_TTL",`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_notify() {"," zle && print -u2 -n $'\\r\\e[K'",' print -u2 -- "$1"'," zle && zle reset-prompt","}","_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 load_mtime=0 clear_mtime=0",' [[ -f "$load_file" ]] && load_mtime=$(zstat +mtime -- "$load_file" 2>/dev/null || echo 0)',' [[ -f "$clear_file" ]] && clear_mtime=$(zstat +mtime -- "$clear_file" 2>/dev/null || echo 0)'," if (( load_mtime > _INFRA_KIT_LAST_LOAD_MTIME && load_mtime >= _INFRA_KIT_SHELL_STARTED && load_mtime >= clear_mtime )); then",' source "$load_file"'," _INFRA_KIT_LAST_LOAD_MTIME=$load_mtime",' _infra_kit_notify "infra-kit: auto-loaded vars for ${INFRA_KIT_ENV_CONFIG:-?}"'," fi"," if (( clear_mtime > _INFRA_KIT_LAST_CLEAR_MTIME && clear_mtime >= _INFRA_KIT_SHELL_STARTED && clear_mtime > load_mtime )); then",' source "$clear_file"'," _INFRA_KIT_LAST_CLEAR_MTIME=$clear_mtime",' _infra_kit_notify "infra-kit: auto-cleared env"'," fi","}","autoload -Uz add-zsh-hook","if (( _INFRA_KIT_SHELL_STARTED > 0 )); then"," add-zsh-hook precmd _infra_kit_autoload","fi","_INFRA_KIT_AUTOLOAD_WINDOW=6","export _INFRA_KIT_AUTOLOAD_WINDOW","_infra_kit_poll_autoload() {"," _infra_kit_autoload"," if (( _INFRA_KIT_LAST_LOAD_MTIME < _INFRA_KIT_SHELL_STARTED )) && (( ${EPOCHSECONDS:-0} - _INFRA_KIT_SHELL_STARTED < _INFRA_KIT_AUTOLOAD_WINDOW )); then"," (( $+builtins[sched] )) && sched +1 _infra_kit_poll_autoload"," fi","}","_infra_kit_warm_source() {",' local canon="$1" key'," if (( $+commands[shasum] )); then",' key=$(printf %s "$canon" | shasum -a 256 | cut -c1-64)'," elif (( $+commands[sha256sum] )); then",' key=$(printf %s "$canon" | sha256sum | cut -c1-64)'," else"," return"," fi",' local cache_root="${XDG_CACHE_HOME:-$HOME/.cache}/infra-kit"',' local warm="$cache_root/projects/$key/env-load.sh"',' local wclear="$cache_root/projects/$key/env-clear.sh"',' [[ -f "$warm" ]] || return'," local wm=0 cm=0",' wm=$(zstat +mtime -- "$warm" 2>/dev/null || echo 0)',' [[ -f "$wclear" ]] && cm=$(zstat +mtime -- "$wclear" 2>/dev/null || echo 0)'," (( cm >= wm )) && return"," (( ${EPOCHSECONDS:-0} - wm >= _INFRA_KIT_WARM_TTL )) && return",' source "$warm"',' _infra_kit_notify "infra-kit: loaded cached vars for ${INFRA_KIT_ENV_CONFIG:-?} (refreshing\u2026)"',"}","_infra_kit_startup_autoload() {",' [[ -z "$INFRA_KIT_SESSION" ]] && return',' local dir="$PWD" prev=""',' while [[ -n "$dir" && "$dir" != "$prev" ]]; do',' if [[ -f "$dir/infra-kit.json" ]]; then',' [[ -n "$INFRA_KIT_ENV_CONFIG" && "$dir" == "$INFRA_KIT_ENV_PROJECT_ROOT" ]] && return',' local canon="${dir:A}"',' _infra_kit_warm_source "$canon"',` ( ${e} env-autoload --project-dir "$canon" & ) >/dev/null 2>&1`," (( $+builtins[sched] )) && sched +1 _infra_kit_poll_autoload"," return"," fi",' prev="$dir"',' dir="${dir:h}"'," done","}","if (( _INFRA_KIT_SHELL_STARTED > 0 )); then"," _infra_kit_startup_autoload","fi"].join(`
95
+ `)},Dn=()=>`${vr}
96
+ ${On()}
97
+ ${He}`;import W from"node:fs";import Ln from"node:os";import Ae from"node:path";import{z as Ze}from"zod";import{$ as Lt}from"zx";import{$ as Mn}from"zx";var Fn=5e3,Xr=async()=>{try{await Mn`doppler --version`.timeout(Fn)}catch(e){throw new Error("Doppler CLI is not installed. Install it from: https://docs.doppler.com/docs/install-cli",{cause:e})}try{await Mn`doppler me`.timeout(Fn)}catch(e){throw new Error("Doppler CLI is not authenticated (or timed out). Run: doppler login",{cause:e})}};var Bi="Could not find requested project",zi="Could not find requested config",_t=e=>e.includes(Bi)?"project":e.includes(zi)?"config":"unknown",Nt=({kind:e,project:r,config:t,available:o})=>{let n=e==="project"?[`Doppler project "${r}" not found (set in infra-kit.json \u2192 envManagement.config.name).`]:[`Doppler config "${t}" not found in project "${r}" (set in infra-kit.json \u2192 environments).`];if(o&&o.length>0){let s=e==="project"?"Available projects":`Available configs in "${r}"`;n.push(`${s}: ${o.join(", ")}.`)}return n.push(e==="project"?"Fix: update envManagement.config.name to an existing project, or create it in Doppler.":"Fix: update environments to an existing config, or create it in Doppler."),n.join(`
98
+ `)};import{$ as yr}from"zx";var Gi=5e3,Pe=async()=>{let{envManagement:e}=await b();return e.config.name},kr=async()=>jn(()=>yr`doppler projects --json`),Ot=async e=>jn(()=>yr`doppler configs --project ${e} --json`),jn=async e=>{let r=yr.quiet;yr.quiet=!0;try{let t=await e().timeout(Gi);return Ki(t.stdout)}catch{return null}finally{yr.quiet=r}},Ki=e=>{let r;try{r=JSON.parse(e)}catch{return null}return Array.isArray(r)?r.map(t=>t!==null&&typeof t=="object"?t.name:void 0).filter(t=>typeof t=="string"):null};import Se from"node:fs";import Rr from"node:path";var Dt=({autoLoaded:e,projectDir:r,canonicalProjectRoot:t})=>!e||!r||!t?!1:t===r,Ie=e=>{if(!e)return"";try{return Se.realpathSync(e)}catch{return""}},Mt=(e,r)=>{try{let t=cr(e);Se.mkdirSync(t,{recursive:!0,mode:448}),$e(Rr.join(t,F),r,384)}catch(t){l.debug(`warm-cache write skipped: ${t.message}`)}},Ft=(e=Date.now(),r=ar)=>{let t=un(),o;try{o=Se.readdirSync(t,{withFileTypes:!0})}catch{return}for(let n of o){if(!n.isDirectory())continue;let s=Rr.join(t,n.name);try{let{mtimeMs:i}=Se.statSync(Rr.join(s,F));e-i>=r*1e3&&Se.rmSync(s,{recursive:!0,force:!0})}catch{}}},jt=(e,r)=>{try{let t=cr(e);if(r){Se.rmSync(t,{recursive:!0,force:!0});return}if(!Se.existsSync(Rr.join(t,F)))return;$e(Rr.join(t,Wr),`# infra-kit warm cache cleared
99
+ `,384)}catch(t){l.debug(`warm-cache invalidate skipped: ${t.message}`)}};var he=async(e,r,t,o)=>{try{return await Lt`${r}`,{name:e,status:"pass",message:t}}catch{return{name:e,status:"fail",message:o}}},Ui=()=>{let e="zshrc init block",r=Ae.join(Ln.homedir(),".zshrc");if(!W.existsSync(r))return{name:e,status:"fail",message:"~/.zshrc not found. Run: infra-kit init"};let t=W.readFileSync(r,"utf-8"),o=t.indexOf(vr),n=t.indexOf(He);if(o===-1||n===-1||n<o)return{name:e,status:"fail",message:"infra-kit shell block missing from ~/.zshrc. Run: infra-kit init"};let s=t.slice(o,n+He.length).trim(),i=Dn().trim();return s!==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"}},qi=async()=>{let e="warm cache",r;try{r=await y()}catch{return{name:e,status:"pass",message:"warm cache: not a git project"}}let t=Ie(r);if(!t)return{name:e,status:"pass",message:"warm cache: unavailable"};let o=Ae.join(cr(t),F);if(!W.existsSync(o))return{name:e,status:"pass",message:"warm cache: none yet (populated on next auto-load)"};let n=Math.floor((Date.now()-W.statSync(o).mtimeMs)/1e3),s=Math.floor(n/60),i=Math.floor(ar/60);return n>=ar?{name:e,status:"pass",message:`warm cache: present but stale (${s}m old, TTL ${i}m) \u2014 will refresh`}:{name:e,status:"pass",message:`warm cache: present, ${s}m old`}},Hi=async()=>{let e="pnpm enableGlobalVirtualStore";try{let r=await y(),t=Ae.join(r,"pnpm-workspace.yaml");if(!W.existsSync(t))return{name:e,status:"fail",message:`pnpm-workspace.yaml not found at ${t}`};let o=W.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}`}}},Zi=async()=>{let e="infra-kit config valid";try{return Te(),await b(),{name:e,status:"pass",message:"infra-kit.json is valid (user overrides applied if present)"}}catch(r){return{name:e,status:"fail",message:r.message}}},Xi=async()=>{let e="doppler project exists",r;try{r=await Pe()}catch{return{name:e,status:"pass",message:"Skipped \u2014 infra-kit config could not be read (see config check)"}}let t=await kr();return t===null?{name:e,status:"pass",message:"Skipped \u2014 could not list Doppler projects (see doppler auth check)"}:t.includes(r)?{name:e,status:"pass",message:`Doppler project "${r}" exists`}:{name:e,status:"fail",message:`Doppler project "${r}" not found (set in infra-kit.json \u2192 envManagement.config.name). Available: ${t.length>0?t.join(", "):"none"}`}},Yi=async()=>{let e="user override path";try{let r=await H(),t=Ln.homedir(),o=r.userProject.startsWith(t)?`~${r.userProject.slice(t.length)}`:r.userProject,s=W.existsSync(r.userProject)?"(exists)":"(not yet created)";return{name:e,status:"pass",message:`${o} ${s} \u2014 project: ${r.projectName}`}}catch(r){return{name:e,status:"fail",message:r.message}}},Qi=async()=>{let e="legacy user-global config",r;try{r=await H()}catch{return{name:e,status:"pass",message:"Skipped \u2014 infra-kit config paths could not be resolved"}}let t=Ae.join(Ae.dirname(r.userGlobal),"config.json");return W.existsSync(t)?W.existsSync(r.userGlobal)?{name:e,status:"fail",message:`Stale legacy config.json found at ${k(t)} \u2014 ${k(r.userGlobal)} is active; remove the old file.`}:{name:e,status:"fail",message:`Legacy user-global config.json found at ${k(t)} \u2014 run \`infra-kit init\` to migrate it (your overrides are not being applied).`}:{name:e,status:"pass",message:"No legacy user-global config.json"}},ea={cursor:{command:["cursor","--version"],label:"Cursor",failMsg:"Cursor is not installed. Install from: https://cursor.com/"},zed:{command:["zed","--version"],label:"Zed",failMsg:"Zed is not installed. Install from: https://zed.dev/"}},ra=async e=>{let r=ea[e];try{return await Lt`${r.command}`,{ok:!0,label:r.label,failMsg:r.failMsg}}catch{return{ok:!1,label:r.label,failMsg:r.failMsg}}},ta=async()=>{let e="ide installed",r;try{Te();let n=await b();r=q(n).map(s=>s.provider)}catch{return{name:e,status:"pass",message:"Skipped \u2014 infra-kit config could not be read (see config check)"}}if(r.length===0)return{name:e,status:"pass",message:"No IDE configured (ide unset)"};let t=await Promise.all(r.map(n=>ra(n))),o=t.filter(n=>!n.ok);return o.length===0?{name:e,status:"pass",message:`Installed: ${t.map(n=>n.label).join(", ")}`}:{name:e,status:"fail",message:o.map(n=>n.failMsg).join("; ")}},oa=[1,2,3,5,7],na=async()=>{let e="rtk configured";try{let t=(await Lt`rtk init --show`).stdout.split(`
100
+ `).map(n=>n.trim()).filter(n=>n.startsWith("[ok]")||n.startsWith("[--]")),o=[];for(let n of oa){let s=t[n-1];(!s||!s.startsWith("[ok]"))&&o.push(n)}return o.length>0?{name:e,status:"fail",message:`rtk setup incomplete (items ${o.join(", ")} not [ok]). Run: rtk init -g --auto-patch`}:{name:e,status:"pass",message:"rtk hook, RTK.md, global CLAUDE.md, settings.json, and Cursor hook are configured"}}catch(r){return{name:e,status:"fail",message:`Failed to run 'rtk init --show': ${r.message}`}}},sa=async()=>{let e;try{e=(await H()).main}catch{return[]}if(!W.existsSync(e))return[];let r=Ae.join(Ae.dirname(e),"CLAUDE.md"),t=W.existsSync(r)?W.readFileSync(r,"utf-8"):"",o=Ue(t,gr,hr);return[{name:"CLAUDE.md block",status:o?"pass":"fail",message:o?"CLAUDE.md block present":"infra-kit block missing from CLAUDE.md. Run: infra-kit init"}]},Wn=async()=>{let r=[...await Promise.all([he("gh installed",["gh","--version"],"GitHub CLI is installed","GitHub CLI is not installed. Install from: https://cli.github.com/"),he("gh authenticated",["gh","auth","status"],"GitHub CLI is authenticated","GitHub CLI is not authenticated. Run: gh auth login"),he("doppler installed",["doppler","--version"],"Doppler CLI is installed","Doppler CLI is not installed. Install from: https://docs.doppler.com/docs/install-cli"),he("doppler authenticated",["doppler","me"],"Doppler CLI is authenticated","Doppler CLI is not authenticated. Run: doppler login"),he("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"),he("rtk installed",["rtk","--version"],"RTK is installed","RTK is not installed. Install from: https://github.com/rtk-ai/rtk"),he("typescript-language-server installed",["typescript-language-server","--version"],"typescript-language-server is installed","typescript-language-server is not installed. Install from: https://github.com/typescript-language-server/typescript-language-server#installing"),he("cmux installed",["cmux","--version"],"cmux is installed","cmux is not installed. Install from: https://cmux.com/"),na(),Promise.resolve(Ui()),qi(),Hi(),Zi(),Xi(),Yi(),Qi(),ta()]),...await sa()];l.info(`Doctor check results:
101
+ `);for(let o of r){let n=o.status==="pass"?"[PASS]":"[FAIL]";l.info(` ${n} ${o.name}: ${o.message}`)}let t={checks:r.map(o=>({name:o.name,status:o.status,message:o.message})),allPassed:r.every(o=>o.status==="pass")};return{content:g(JSON.stringify(t,null,2)),structuredContent:t}},Wt=w({name:"doctor",description:"Check installation and authentication status of gh, doppler, aws, and rtk CLIs",inputSchema:{},outputSchema:{checks:Ze.array(Ze.object({name:Ze.string().describe("Name of the check"),status:Ze.enum(["pass","fail"]).describe("Check result"),message:Ze.string().describe("Details about the check result")})).describe("List of all check results"),allPassed:Ze.boolean().describe("Whether all checks passed")},handler:Wn});import aa from"@inquirer/select";import{Buffer as ca}from"node:buffer";import la from"node:fs";import pa from"node:path";import Vn from"node:process";import{z as br}from"zod";import{$ as Yr}from"zx";var Vt=e=>{if(e===null||typeof e!="object")return;let r=e.stderr;return typeof r=="string"&&r.length>0?r:void 0},ia=(e,r)=>{let t=r.stderrExcerpt??Vt(e),o=[`failed to ${r.operation}`];return t&&o.push(`stderr: ${t.slice(0,200).trim()}`),r.remediation&&o.push(`try: ${r.remediation}`),o.join(" \u2014 ")},f=class extends Error{operation;remediation;constructor(r,t){super(ia(r,t),{cause:r}),this.name="OperationError",this.operation=t.operation,this.remediation=t.remediation}};var da=e=>e?[`${Ee}=${_e("1")}`]:[`unset ${Ee}`,`unset ${Je}`],Bn=({pairs:e,config:r,project:t,projectRoot:o,loadedAt:n,autoLoaded:s})=>["set -a",...e.map(([i,c])=>`${i}=${_e(c)}`),`${Vr}=${_e(r)}`,`${Le}=${_e(r)}`,`${We}=${_e(t)}`,`${Jr}=${_e(o)}`,`${Ve}=${_e(n)}`,...da(s),"set +a"],ma=async()=>{try{return await y()}catch{return""}},zn=async({config:e,autoLoaded:r=!1,beforeWrite:t,projectDir:o})=>{await Xr();let n=await Pe(),s=await ma(),i=await fa(n,e),c=new Date().toISOString(),p=`${Bn({pairs:i,config:e,project:n,projectRoot:s,loadedAt:c,autoLoaded:r}).join(`
102
+ `)}
103
+ `,d=Be(),u=pa.resolve(d,F);if(t&&!t())return null;la.mkdirSync(d,{recursive:!0,mode:448}),$e(u,p,384);let h=Ie(s);return Dt({autoLoaded:r,projectDir:o,canonicalProjectRoot:h})&&(Mt(o,p),Ft()),{filePath:u,variableCount:i.length,project:n,config:e}},Gn=async e=>{let{config:r}=e;m.start("env-load");let t="";if(r)t=r;else{await Xr();let{environments:s}=await b();m.setInteractive(),t=await aa({message:"Select environment config",choices:s.map(i=>({name:i,value:i}))},{output:Vn.stderr})}m.addOption("--config",t);let o=await zn({config:t,autoLoaded:!1});if(!o)throw new Error("env-load: write was unexpectedly aborted");Vn.stdout.write(`${o.filePath}
104
+ `),m.print();let n={filePath:o.filePath,variableCount:o.variableCount,project:o.project,config:o.config};return{content:g(JSON.stringify(n,null,2)),structuredContent:n}},Jn=1024*1024,ua=3e4,fa=async(e,r)=>{let t=Yr.quiet;Yr.quiet=!0;try{let o;try{o=await Yr`doppler secrets download --no-file --format json --project ${e} --config ${r}`.timeout(ua)}catch(n){throw await ga(n,e,r)}return ha(o.stdout),va(o.stdout)}finally{Yr.quiet=t}},ga=async(e,r,t)=>{let o=Vt(e)??(e instanceof Error?e.message:String(e)),n=_t(o);if(n==="unknown")return e instanceof Error?e:new Error(String(e));let s=n==="project"?await kr():await Ot(r);return new Error(Nt({kind:n,project:r,config:t,available:s}))},ha=e=>{let r=ca.byteLength(e,"utf-8");if(r>Jn)throw new Error(`doppler returned unexpectedly large output (${r} bytes > ${Jn}) \u2014 refusing to write to disk`)},_e=e=>`'${e.replaceAll("'","'\\''")}'`,wa=/^[A-Z_]\w*$/i,va=e=>{let r;try{r=JSON.parse(e)}catch{throw new Error(`doppler returned non-JSON output for env-load (got: ${JSON.stringify(e.slice(0,80))})`)}if(r===null||typeof r!="object"||Array.isArray(r))throw new Error("doppler returned unexpected JSON shape for env-load (expected an object of KEY: value pairs)");let t=[];for(let[o,n]of Object.entries(r)){if(!wa.test(o))throw new Error(`doppler returned an invalid env var name for env-load (got: ${JSON.stringify(o.slice(0,80))})`);if(typeof n!="string")throw new TypeError(`doppler returned a non-string value for "${o}" (got ${typeof n})`);t.push([o,n])}if(t.length===0)throw new Error("doppler returned empty output for env-load");return t},Jt=w({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:br.string().describe('Doppler config / environment name to load (e.g. "dev", "arthur", "renana"). Required for MCP calls.')},outputSchema:{filePath:br.string().describe("Path to the file that must be sourced to apply variables"),variableCount:br.number().describe("Number of variables loaded"),project:br.string().describe("Doppler project name"),config:br.string().describe("Doppler config name")},handler:Gn});import Bt from"node:fs";import Kn from"node:path";import ya from"node:process";import{z as xr}from"zod";var ka=async e=>{let r="";try{r=await y()}catch{return}let t=Ie(r);t&&jt(t,e)},Ra=e=>[...e.map(r=>`unset ${r}`),`unset ${Vr}`,`unset ${Le}`,`unset ${We}`,`unset ${Jr}`,`unset ${Ve}`,`unset ${Ee}`,`export ${Je}='1'`],Un=async({purge:e=!1}={})=>{let r=Be(),t=Kn.join(r,F),o=Bt.existsSync(t);if(!o&&!e)throw new Error("No loaded environment found. Run `env-load` first.");await ka(e);let n=o?Br(t):[],s=Ra(n),i=Kn.resolve(r,Wr);Bt.mkdirSync(r,{recursive:!0,mode:448}),$e(i,`${s.join(`
105
+ `)}
106
+ `,384),ya.stdout.write(`${i}
107
+ `),o&&Bt.rmSync(t,{force:!0});let c={filePath:i,variableCount:n.length,unsetStatements:s,purged:e};return{content:g(JSON.stringify(c,null,2)),structuredContent:c}},zt=w({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:xr.string().describe("Path to the file that must be sourced to apply"),variableCount:xr.number().describe("Number of variables cleared"),unsetStatements:xr.array(xr.string()).describe("Unset statements generated"),purged:xr.boolean().describe("Whether the project warm cache was purged outright")},handler:()=>Un()});import{z as Gt}from"zod";var qn=async()=>{let e=await Pe(),{environments:r}=await b();l.info(`Doppler project: ${e}
108
+ `),l.info("Available configs:");for(let o of r)l.info(` - ${o}`);let t={project:e,configs:r};return{content:g(JSON.stringify(t,null,2)),structuredContent:t}},Kt=w({name:"env-list",description:"List the environments the project is configured to support. Returns the `environments` list declared in infra-kit.json 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:Gt.string().describe("Detected Doppler project name"),configs:Gt.array(Gt.string()).describe("Available environment configs")},handler:qn});import ba from"node:path";import Ne from"node:process";import{z as we}from"zod";var Hn=async()=>{l.info("Environment session status:");let e=Be(),r=Ne.env[mn],t=ba.join(e,F),o=0,n=0,s=Ne.env[Le]??null,i=Ne.env[We]??null,c=Ne.env[Ve]??null,a=Ne.env[Ee]==="1",p=!!Ne.env[Je];if(s){let u=Br(t);u.length>0&&(n=u.length,o=u.filter(v=>v in Ne.env).length);let h=c?.replace(/\.\d{3}Z$/,"")??null,R=a?"auto-loaded":"manually loaded";if(l.info(` ${s}: ${o} of ${n} vars loaded (${R}, project: ${i}, loadedAt: ${h}, session: ${r})
109
+ `),n>0&&o<n){let v=n-o;l.warn(` ${v} cached var(s) are not present in the current process \u2014 env-load needs to be re-sourced, or vars were unset manually.`)}}else{let u=p?" (cleared \u2014 auto-load suppressed until a new shell or explicit env-load)":"";l.info(` Session ${r}: no env loaded${u}
110
+ `)}let d={sessionId:r,sessionLoadedCount:o,sessionTotalCount:n,sessionConfig:s,sessionProject:i,sessionLoadedAt:c,autoLoaded:a,cleared:p};return{content:g(JSON.stringify(d,null,2)),structuredContent:d}},Ut=w({name:"env-status",description:"Report which Doppler project/config is currently loaded in the terminal session, when it was loaded, how many variables are cached, whether it was auto-loaded, and whether a clear is suppressing auto-load. Pure local introspection \u2014 makes NO Doppler call (use doctor for auth). Read-only \u2014 use env-load / env-clear to change the terminal session.",inputSchema:{},outputSchema:{sessionId:we.string().describe("Current terminal session ID"),sessionLoadedCount:we.number().describe("Number of cached vars active in the current session"),sessionTotalCount:we.number().describe("Total number of cached var names"),sessionConfig:we.string().nullable().describe("Doppler config name of the loaded session (environment name)"),sessionProject:we.string().nullable().describe("Doppler project name of the loaded session"),sessionLoadedAt:we.string().nullable().describe("ISO 8601 timestamp of when the env was loaded"),autoLoaded:we.boolean().describe("True when the loaded env was applied by env auto-load (not a manual env-load)"),cleared:we.boolean().describe("True when env-clear is currently suppressing auto-load in this shell")},handler:Hn});import Ca from"@inquirer/checkbox";import Ta from"@inquirer/confirm";import Ea from"node:process";import{z as rr}from"zod";import{$ as B}from"zx";import{$ as au}from"zx";import{$ as A}from"zx";import{$ as Tr}from"zx";import Cr from"node:process";var qt=async(e,r)=>{try{let{baseUrl:t,token:o,email:n,projectId:s}=r,i={name:e.name,projectId:e.projectId||s,description:e.description||"",released:e.released||!1,archived:e.archived||!1},c=`${t}/rest/api/3/version`,a=btoa(`${n}:${o}`),p=await fetch(c,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json",Authorization:`Basic ${a}`},body:JSON.stringify(i)});if(!p.ok){let u=await p.text();throw l.error({status:p.status,statusText:p.statusText,error:u},"Failed to create Jira version"),new Error(`HTTP ${p.status}: ${p.statusText}`)}return{success:!0,version:await p.json()}}catch(t){throw l.error({error:t},"Error creating Jira version"),t}},Xe=async e=>{try{let{baseUrl:r,token:t,email:o,projectId:n}=e,s=`${r}/rest/api/3/project/${n}/versions`,i=btoa(`${o}:${t}`),c=await fetch(s,{method:"GET",headers:{Accept:"application/json",Authorization:`Basic ${i}`}});if(!c.ok){let p=await c.text();throw l.error({status:c.status,statusText:c.statusText,error:p},"Failed to get Jira project versions"),new Error(`HTTP ${c.status}: ${c.statusText}`)}return await c.json()}catch(r){throw l.error({error:r},"Error getting Jira project versions"),r}},Qr=async(e,r)=>{try{return(await Xe(r)).find(n=>n.name===e)||null}catch(t){throw l.error({error:t,versionName:e},"Error finding Jira version by name"),t}},et=async(e,r)=>{try{let{baseUrl:t,token:o,email:n}=r,s={};e.released!==void 0&&(s.released=e.released),e.archived!==void 0&&(s.archived=e.archived),e.releaseDate!==void 0&&(s.releaseDate=e.releaseDate),e.description!==void 0&&(s.description=e.description);let i=`${t}/rest/api/3/version/${e.versionId}`,c=btoa(`${n}:${o}`),a=await fetch(i,{method:"PUT",headers:{Accept:"application/json","Content-Type":"application/json",Authorization:`Basic ${c}`},body:JSON.stringify(s)});if(!a.ok){let d=await a.text();throw l.error({status:a.status,statusText:a.statusText,error:d},"Failed to update Jira version"),new Error(`HTTP ${a.status}: ${a.statusText}`)}return{success:!0,version:await a.json()}}catch(t){throw l.error({error:t},"Error updating Jira version"),t}},Ht=async(e,r)=>{try{let{versionName:t}=e,o=await Qr(t,r);if(!o)throw l.error({versionName:t},"Jira version not found"),new Error(`Version "${t}" not found in Jira project`);return await et({versionId:o.id,released:!0,releaseDate:new Date().toISOString().split("T")[0]},r)}catch(t){throw l.error({error:t},"Error delivering Jira release"),t}},Ye=async()=>{let e=Cr.env.JIRA_BASE_URL,r=Cr.env.JIRA_TOKEN||Cr.env.JIRA_API_TOKEN,t=Cr.env.JIRA_PROJECT_ID,o=Cr.env.JIRA_EMAIL,n=[];if(e||n.push("JIRA_BASE_URL (e.g., https://your-domain.atlassian.net)"),r||n.push("JIRA_TOKEN or JIRA_API_TOKEN (your Jira API token)"),t||n.push("JIRA_PROJECT_ID (numeric project ID)"),o||n.push("JIRA_EMAIL (your Jira email address)"),n.length>0){let i=["Jira configuration is required but incomplete.","Please configure the following environment variables:",...n.map(c=>` - ${c}`),"","You can set these in your .env file or as environment variables."].join(`
111
+ `);throw new Error(i)}let s=Number.parseInt(t,10);if(Number.isNaN(s))throw new TypeError(`Invalid JIRA_PROJECT_ID: "${t}" must be a numeric value (e.g., 10001)`);return{baseUrl:e.replace(/\/$/,""),token:r,projectId:s,email:o}},Oe=async()=>{try{return await Ye()}catch(e){return l.warn({error:e},"Jira configuration not available, skipping Jira integration"),null}};var Zn="dev",Qe=e=>e==="hotfix"?"main":"dev",Zt=async(e="regular")=>{let r=Qe(e);Tr.quiet=!0,await Tr`git fetch origin`,await Tr`git switch ${r}`,await Tr`git pull origin ${r}`,Tr.quiet=!1},Xt=async e=>{let{id:r,jiraConfig:t,description:o,type:n="regular"}=e,s=J(r),i=await qt({name:s,projectId:t.projectId,description:o||"",released:!1,archived:!1},t),c=`${t.baseUrl}/projects/${i.version.projectId}/versions/${i.version.id}/tab/release-report-all-issues`,a=await rt({id:r,jiraVersionUrl:c,type:n,description:o});return{version:$(r),type:n,branchName:a.branchName,prUrl:a.prUrl,jiraVersionUrl:c}},E=async()=>{let e=new Map,r=await Oe();if(!r)return e;try{let t=await Xe(r);for(let o of t)o.description&&e.set(o.name,o.description)}catch{}return e},er=(e,r,t)=>{let o=t?" ".repeat(t-e.length+3):" ",n=`[${r}]`.padEnd(11);return`${e}${o}${n}`},x=e=>e.toLowerCase().startsWith("hotfix")?"hotfix":"regular",Xn=e=>e.flatMap(r=>{let t=P(r);return t?[{branch:r,id:t,label:$(t)}]:[]}),ae=e=>{try{return me(oe(e))}catch(r){throw new f(r,{operation:`resolve release ref "${e}"`,remediation:'pass a version (e.g. "1.2.5") or a release name (e.g. "checkout-redesign")'})}},Er=e=>{if(e===Zn)return Zn;let r=P(e);return r?$(r):e},De=e=>e.flatMap(r=>{let t=P(r);return t?[$(t)]:[]}),I=e=>{let{branches:r,descriptions:t,types:o}=e,n=Xn(r),s=Math.max(0,...n.map(i=>i.label.length));return n.map(({branch:i,id:c,label:a})=>{let p=o?o.get(i)||"regular":void 0,d=t.get(J(c)),u=" ".repeat(s-a.length+3),h=p?er(a,p,s):a;return d&&(h=p?`${h} ${d}`:`${a}${u}${d}`),{name:h,value:i}})};var Yn=e=>e.map(r=>({pr:r,id:P(r.headRefName)})).filter(r=>r.id!==null).sort((r,t)=>Yo(r.id,t.id,{a:r.pr.createdAt,b:t.pr.createdAt})).map(r=>r.pr),Qn=async()=>{let e=await A`gh pr list --search "Release in:title" --base dev --json number,title,headRefName,state,baseRefName,createdAt`,r=await A`gh pr list --search "Hotfix in:title" --base main --json number,title,headRefName,state,baseRefName,createdAt`,t=[...JSON.parse(e.stdout),...JSON.parse(r.stdout)],o=new Set;return t.filter(n=>o.has(n.headRefName)?!1:(o.add(n.headRefName),!0))},tt=async()=>{try{let e=await Qn();if(e.length===0)throw new f(void 0,{operation:"find open release PRs",remediation:"open a release PR first, or check you are in the right repo"});return Yn(e).map(r=>r.headRefName)}catch(e){throw e instanceof f?e:(l.error({error:e},"\u274C Error fetching release PRs"),new f(e,{operation:"fetch release PRs"}))}},C=async()=>{try{let e=await Qn();if(e.length===0)throw new f(void 0,{operation:"find open release PRs",remediation:"open a release PR first, or check you are in the right repo"});return Yn(e).map(r=>({branch:r.headRefName,title:r.title,createdAt:r.createdAt}))}catch(e){throw e instanceof f?e:(l.error({error:e},"\u274C Error fetching release PRs"),new f(e,{operation:"fetch release PRs"}))}},ot=async e=>{let{branch:r,body:t}=e;try{A.quiet=!0,await A`gh pr edit ${r} --body ${t}`,A.quiet=!1}catch(o){throw l.error({error:o,branch:r},`Error updating release PR body for ${r}`),o}},rt=async e=>{let{id:r,jiraVersionUrl:t,type:o,description:n}=e,s=Xo(r,o),i=Qe(o),c=me(r),a=n&&n.trim()!==""?`${t}
112
+
113
+ ${n}`:`${t}
114
+ `;try{A.quiet=!0,await A`git switch ${i}`,await A`git pull origin ${i}`,await A`git checkout -b ${c}`,await A`git push -u origin ${c}`,await A`git commit --allow-empty-message --allow-empty --message ''`,await A`git push origin ${c}`;let d=(await A`gh pr create --title ${s} --body ${a} --base ${i} --head ${c}`).stdout.trim();return await A`git switch ${i}`,A.quiet=!1,{branchName:c,prUrl:d}}catch(p){throw l.error({error:p,branchName:c},`Error creating release branch ${c}`),p}};var O=async e=>{let{operation:r,requiredBranch:t}=e;if(await rn())throw new f(void 0,{operation:r,remediation:"run this from the main repository checkout, not a linked git worktree",stderrExcerpt:"command run from inside a linked worktree"});if(t){let o=await Qo();if(o!==t)throw new f(void 0,{operation:r,remediation:`switch to ${t} first (git switch ${t})`,stderrExcerpt:`current branch is "${o}", expected "${t}"`})}if(!await en())throw new f(void 0,{operation:r,remediation:"commit or stash your changes, then retry",stderrExcerpt:"working tree has uncommitted changes"})};var es=async e=>{let{all:r,confirmedCommand:t}=e;m.start("merge-dev"),await O({operation:"merge dev into release branches",requiredBranch:"dev"});let n=(await C()).filter(d=>x(d.title)==="regular").map(d=>d.branch);if(n.length===0)return l.info("\u2139\uFE0F No open release branches found"),m.print(),{content:g(JSON.stringify({successfulMerges:0,failedMerges:0,failedBranches:[],totalBranches:0},null,2)),structuredContent:{successfulMerges:0,failedMerges:0,failedBranches:[],totalBranches:0}};let s=[];if(r)s=n;else{m.setInteractive();let d=await E();s=await Ca({required:!0,message:"\u{1F33F} Select release branches",choices:I({branches:n,descriptions:d})})}s.length===n.length?m.addOption("--all",!0):m.addOption("--versions",De(s));let c=t?!0:await Ta({message:`Are you sure you want to merge dev into these branches: ${s.join(", ")}?`});t||m.setInteractive(),c||(l.info("Operation cancelled. Exiting..."),Ea.exit(0)),t||m.addOption("--yes",!0),B.quiet=!0,await B`git fetch origin`,await B`git switch dev`,await B`git pull origin dev`;let a=[];for(let d of s)await $a(d)||a.push(d);if(B.quiet=!1,a.length>0){l.info(`
115
+ \u26A0\uFE0F ${a.length} branch(es) failed to merge automatically.
116
+ `),l.info("\u{1F4CB} Manual merge script for failed branches:");for(let d of a)l.info(`# Merge dev into ${d} and resolve conflicts if any
117
+
118
+ git switch ${d} && git pull origin ${d} && git merge origin/dev
119
+ git push origin ${d} && git switch dev
120
+ `);l.info(`\u2705 ${s.length-a.length}/${s.length} merges completed successfully.`)}else l.info(`\u2705 All merges completed successfully!
121
+ `);m.print();let p={successfulMerges:s.length-a.length,failedMerges:a.length,failedBranches:a,totalBranches:s.length};return{content:g(JSON.stringify(p,null,2)),structuredContent:p}},$a=async e=>{try{return await B`git switch ${e}`,await B`git pull origin ${e}`,await B`git merge origin/dev --no-edit`,await B`git push origin ${e}`,await B`git switch dev`,l.info(`Successfully merged dev into ${e}`),!0}catch(r){let t=new f(r,{operation:`merge dev into ${e}`,remediation:"resolve conflicts manually or rerun after 'git fetch origin'"});return l.error({error:r,branch:e,msg:t.message}),await B`git reset --merge HEAD~1`,!1}},Yt=w({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:rr.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:rr.number().describe("Number of successful merges"),failedMerges:rr.number().describe("Number of failed merges"),failedBranches:rr.array(rr.string()).describe("List of branches that failed to merge"),totalBranches:rr.number().describe("Total number of branches processed")},handler:es});import Pa from"@inquirer/confirm";import Sa from"@inquirer/select";import Ia from"node:process";import{z as Sr}from"zod";import{$ as D}from"zx";var rs=(e,r)=>{if(!(typeof e!="string"||e.length===0))return e.slice(-r).trim()},$r=e=>{if(e===null||typeof e!="object")return{message:String(e)};let r=e,t={};e instanceof Error?(t.name=e.name,t.message=e.message):typeof r.message=="string"&&(t.message=r.message);let o=r.exitCode;(typeof o=="number"||o===null)&&(t.exitCode=o);let n=rs(r.stderr,500);n&&(t.stderr=n);let s=rs(r.stdout,200);return s&&(t.stdout=s),t};import{$ as ts}from"zx";var Pr=async e=>{let{branches:r,worktreeDir:t,repoName:o,pruneFolder:n=!1}=e,s=await Promise.allSettled(r.map(async c=>{let a=`${t}/${c}`,p=ne({repoName:o,branch:c});return await ze(p),await ts`git worktree remove ${a}`,c})),i=[];for(let[c,a]of s.entries())if(a.status==="fulfilled")i.push(a.value);else{let p=r[c],d=new f(a.reason,{operation:`remove worktree for ${p}`,remediation:"check 'git worktree list' for the path; uncommitted changes block removal"});l.error({error:a.reason,msg:d.message})}return n&&i.length===r.length&&await ts`git worktree prune`,i};var tr=async(e,r,t)=>{try{return await t()}catch(o){throw l.error({err:$r(o)},`\u274C Failed to ${e}`),new f(o,{operation:e,remediation:r})}},ns=async e=>{let r=await D`gh pr list --head ${e} --state all --json number,state,title --limit 1`;return JSON.parse(r.stdout)[0]??null},Aa=async e=>{let r=wt(e),t=await D`gh pr list --head dev --base main --state merged --json number,state,title --limit 20`;return JSON.parse(t.stdout).find(s=>s.title===r)??null},os=async()=>{let e=await D`gh pr list --head dev --base main --state open --json number,state,title --limit 5`;return JSON.parse(e.stdout)[0]??null},_a=async e=>{let r=ae(e),t=await ns(r);if(!t)throw l.error(`\u274C No PR found for branch ${r}.`),new f(void 0,{operation:`deliver release ${r}`,remediation:`confirm a PR exists ('gh pr list --head ${r} --state all')`});return{selectedReleaseBranch:r,releasePrTitle:t.title}},Na=async()=>{let e=await C(),r=e.map(i=>i.branch),t=new Map(e.map(i=>[i.branch,x(i.title)]));m.setInteractive();let o=await E(),n=await Sa({message:"\u{1F33F} Select release branch",choices:I({branches:r,descriptions:o,types:t})}),s=e.find(i=>i.branch===n);if(!s)throw l.error(`\u274C Release branch ${n} not found in open PRs.`),new f(void 0,{operation:`deliver release ${n}`,remediation:`confirm an open PR exists for ${n} ('gh pr list')`});return{selectedReleaseBranch:n,releasePrTitle:s.title}},Oa=async e=>{if(!(await M("release")).includes(e))return;let[t,o]=await Promise.all([y(),U()]),n=`${t}${Z}`;if((await Pr({branches:[e],worktreeDir:n,repoName:o})).length===0)throw new f(void 0,{operation:`remove worktree for ${e} before merge`,remediation:`run manually: git worktree remove ${n}/${e} (use --force if uncommitted changes)`})},Da=async e=>{let{selectedReleaseBranch:r,releaseType:t}=e,o=t==="hotfix"?"main":"dev",n=await ns(r);if(!n)throw new f(void 0,{operation:`look up release PR for ${r}`,remediation:"verify the PR exists in GitHub"});if(n.state==="MERGED"){l.info(`\u2713 Release PR ${r} already merged \u2014 skipping`);return}if(n.state==="CLOSED")throw new f(void 0,{operation:`merge release PR ${r} into ${o}`,remediation:"the PR is closed without merge; reopen it or create a new release"});await tr(`merge release PR ${r} into ${o}`,`check 'gh pr view ${r}' for mergeability and required reviews`,async()=>{await D`gh pr merge ${r} --squash --admin --delete-branch`})},Ma=async e=>{let r=$(e),t=wt(e),o=await os();if(o){let s=o.number;return o.title!==t&&(l.info(`Adopting open dev \u2192 main PR #${s} ("${o.title}") and retitling for ${r}`),await tr(`retitle dev \u2192 main PR #${s} to "${t}"`,`update manually: gh pr edit ${s} --title "${t}"`,async()=>{await D`gh pr edit ${s} --title ${t}`})),s}await tr(`create RC PR (dev \u2192 main) for ${r}`,"run 'gh pr create --base main --head dev' manually to surface the underlying error (e.g. no commits between dev and main)",async()=>{await D`gh pr create --base main --head dev --title ${t} --body ""`});let n=await os();if(!n)throw new f(void 0,{operation:`look up RC PR for ${r}`,remediation:"verify the RC PR was created ('gh pr list --head dev --base main')"});return n.number},Fa=async e=>{let r=$(e);if(await Aa(e)){l.info(`\u2713 RC PR for ${r} already merged into main \u2014 skipping`);return}let o=await Ma(e);await tr(`merge RC PR #${o} (dev \u2192 main) for ${r}`,`check 'gh pr view ${o}' for mergeability and required reviews`,async()=>{await D`gh pr merge ${o} --squash --admin`})},ja=async()=>{D.quiet=!1,await tr("dispatch deploy-all workflow on main","check 'gh workflow list' and that you have permission to dispatch deploy-all.yml",async()=>{await D`gh workflow run deploy-all.yml --ref main -f environment=prod`}),D.quiet=!0},La=async()=>{await tr("sync main back into dev","run manually: git switch main && git pull && git switch dev && git pull && git merge main --no-edit && git push",async()=>{await D`git switch main && git pull && git switch dev && git pull && git merge main --no-edit && git push`})},Wa=async e=>{try{await tn(e)}catch(r){l.warn({err:$r(r)},`Failed to delete local branch ${e} (non-blocking)`)}try{await on(e)}catch(r){l.warn({err:$r(r)},`Failed to delete remote branch ${e} (non-blocking)`)}},Va=async e=>{let r=await Oe();if(!r){l.info("\u{1F514} Jira is not configured, skipping Jira release delivery");return}try{let t=J(e);await Ht({versionName:t},r)}catch(t){l.error({err:$r(t)},"Failed to deliver Jira release (non-blocking)")}},ss=async e=>{let{version:r,confirmedCommand:t}=e;m.start("release-deliver"),await O({operation:"deliver release"});let{selectedReleaseBranch:o,releasePrTitle:n}=r?await _a(r):await Na(),s=P(o);if(!s)throw new f(void 0,{operation:`deliver release ${o}`,remediation:'pass a version (e.g. "1.2.5") or a release name (e.g. "checkout-redesign")'});let i=$(s);m.addOption("--version",i),l.info(`Delivering ${s.kind==="name"?"named release":"version"} ${o}`);let c=x(n),a=t?!0:await Pa({message:`Are you sure you want to deliver version ${o} to production?`});t||m.setInteractive(),a||(l.info("Operation cancelled. Exiting..."),Ia.exit(0)),m.addOption("--yes",!0),D.quiet=!0,await Oa(o),await Da({selectedReleaseBranch:o,releaseType:c}),c!=="hotfix"&&await Fa(s),await ja(),await La(),await Wa(o),D.quiet=!1,await Va(s),l.info(`Successfully delivered ${o} to production!`),m.print();let p={releaseBranch:o,version:i,type:c,success:!0};return{content:g(JSON.stringify(p,null,2)),structuredContent:p}},Qt=w({name:"gh-release-deliver",description:'Deliver a release to production. For hotfixes: squash-merges the release branch to main and dispatches the deploy-all workflow. For regular releases: squash-merges to dev, opens an RC PR, merges dev into main, dispatches the deploy-all workflow, then syncs main back to dev. Also releases the matching Jira fix version if Jira is configured. Dispatches the deploy workflow fire-and-forget \u2014 the tool returns once the workflow is accepted by GitHub, not when the deployment finishes. PR-merge steps are idempotent: re-running after a partial failure skips PRs that are already merged. Irreversible production operation: the confirmation prompt is auto-skipped for MCP calls, so the caller is responsible for gating. "version" is required when invoked via MCP (the picker is unreachable without a TTY).',inputSchema:{version:Sr.string().describe('Accepts a release version (e.g. "1.2.5") OR a release name (e.g. "checkout-redesign") to deliver to production. Required for MCP calls.')},outputSchema:{releaseBranch:Sr.string().describe("The release branch that was delivered"),version:Sr.string().describe("The version that was delivered"),type:Sr.enum(["regular","hotfix"]).describe("Release type"),success:Sr.boolean().describe("Whether the delivery was successful")},handler:ss});import Ja from"@inquirer/confirm";import is from"@inquirer/select";import{z as ve}from"zod";import{$ as eo}from"zx";var Ba=async e=>{let{confirmedCommand:r,branch:t,env:o}=e;if(r)return!0;m.setInteractive();let n=await Ja({message:`Deploy ${t} \u2192 ${o}?`,default:!1});return n&&m.addOption("--yes",!0),n},as=async e=>{let{version:r,env:t,skipTerraform:o,confirmedCommand:n}=e;m.start("release-deploy-all");let s="";if(r)s=r==="dev"?"dev":ae(r);else{m.setInteractive();let d=await C(),u=d.map(v=>v.branch),h=new Map(d.map(v=>[v.branch,x(v.title)])),R=await E();s=await is({message:"\u{1F33F} Select release branch",choices:[{name:"dev",value:"dev"},...I({branches:u,descriptions:R,types:h})]})}let i=Er(s);m.addOption("--version",i);let{environments:c}=await b(),a="";if(t?a=t:(m.setInteractive(),a=await is({message:"\u{1F9EA} Select environment",choices:c.map(d=>({name:d,value:d}))})),m.addOption("--env",a),!c.includes(a))throw new f(void 0,{operation:"launch deploy-all workflow",remediation:`pass one of: ${c.join(", ")}`,stderrExcerpt:`invalid environment: ${a}`});let p=o??!1;if(p&&m.addOption("--skip-terraform",!0),!await Ba({confirmedCommand:n,branch:s,env:a})){l.info("Deployment cancelled");let d={releaseBranch:s,version:i,environment:a,skipTerraformDeploy:p,success:!1};return{content:g(JSON.stringify(d,null,2)),structuredContent:d}}try{eo.quiet=!0,await eo`gh workflow run deploy-all.yml --ref ${s} -f environment=${a} ${p?["-f","skip_terraform_deploy=true"]:[]}`,eo.quiet=!1,l.info(`Successfully launched deploy-all workflow_dispatch for release branch: ${s} and environment: ${a}`),m.print();let u={releaseBranch:s,version:i,environment:a,skipTerraformDeploy:p,success:!0};return{content:g(JSON.stringify(u,null,2)),structuredContent:u}}catch(d){throw l.error({error:d},"\u274C Error launching workflow"),new f(d,{operation:"launch deploy-all workflow",remediation:"check 'gh workflow list' and that deploy-all.yml exists on the target ref"})}},ro=w({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:ve.string().describe('Accepts a release version (e.g. "1.2.5") OR a release name (e.g. "checkout-redesign") \u2014 resolves to the release/vX.Y.Z or release/<name> branch. Pass "dev" to deploy from the dev branch instead. Required for MCP calls.'),env:ve.string().describe('Target environment name \u2014 must match an env configured for the project (e.g. "dev", "renana", "oriana"). Required for MCP calls.'),skipTerraform:ve.boolean().optional().describe("Skip the terraform deployment stage.")},outputSchema:{releaseBranch:ve.string().describe("The release branch that was deployed"),version:ve.string().describe("The version that was deployed"),environment:ve.string().describe("The environment deployed to"),skipTerraformDeploy:ve.boolean().describe("Whether terraform deployment was skipped"),success:ve.boolean().describe("Whether the deployment was successful")},handler:as});import za from"@inquirer/checkbox";import Ga from"@inquirer/confirm";import cs from"@inquirer/select";import Ka from"node:fs/promises";import{resolve as Ua}from"node:path";import qa from"yaml";import{z as V}from"zod";import{$ as to}from"zx";var Ha=async e=>{let{confirmedCommand:r,branch:t,env:o}=e;if(r)return!0;m.setInteractive();let n=await Ga({message:`Deploy ${t} \u2192 ${o}?`,default:!1});return n&&m.addOption("--yes",!0),n},ls=async e=>{let{version:r,env:t,services:o,skipTerraform:n,confirmedCommand:s}=e;m.start("release-deploy-selected");let i="";if(r)i=r==="dev"?"dev":ae(r);else{m.setInteractive();let v=await C(),S=v.map(xe=>xe.branch),_=new Map(v.map(xe=>[xe.branch,x(xe.title)])),K=await E();i=await cs({message:"\u{1F33F} Select release branch",choices:[{name:"dev",value:"dev"},...I({branches:S,descriptions:K,types:_})]})}let c=Er(i);m.addOption("--version",c);let{environments:a}=await b(),p="";if(t?p=t:(m.setInteractive(),p=await cs({message:"\u{1F9EA} Select environment",choices:a.map(v=>({name:v,value:v}))})),m.addOption("--env",p),!a.includes(p))throw new f(void 0,{operation:"launch deploy-selected workflow",remediation:`pass one of: ${a.join(", ")}`,stderrExcerpt:`invalid environment: ${p}`});let d=await Za();if(d.length===0)throw new f(void 0,{operation:"launch deploy-selected workflow",remediation:"check .github/workflows/deploy-selected-services.yml for boolean service inputs",stderrExcerpt:"no services found in workflow file"});let u=[];if(o&&o.length>0?u=o:(m.setInteractive(),u=await za({message:"\u{1F680} Select services to deploy (space to select, enter to confirm)",choices:d.map(v=>({name:v,value:v}))})),m.addOption("--services",u),u.length===0)throw new f(void 0,{operation:"launch deploy-selected workflow",remediation:`pass at least one service from: ${d.join(", ")}`,stderrExcerpt:"no services selected"});let h=u.filter(v=>!d.includes(v));if(h.length>0)throw new f(void 0,{operation:"launch deploy-selected workflow",remediation:`pass services from: ${d.join(", ")}`,stderrExcerpt:`invalid services: ${h.join(", ")}`});let R=n??!1;if(R&&m.addOption("--skip-terraform",!0),!await Ha({confirmedCommand:s,branch:i,env:p})){l.info("Deployment cancelled");let v={releaseBranch:i,version:c,environment:p,services:u,skipTerraformDeploy:R,success:!1};return{content:g(JSON.stringify(v,null,2)),structuredContent:v}}try{to.quiet=!0;let v=u.flatMap(K=>["-f",`${K}=true`]);await to`gh workflow run deploy-selected-services.yml --ref ${i} -f environment=${p} ${v} ${R?["-f","skip_terraform_deploy=true"]:[]}`,to.quiet=!1,l.info(`Successfully launched deploy-selected-services workflow_dispatch for release branch: ${i}, environment: ${p}, services: ${u.join(", ")}`),m.print();let _={releaseBranch:i,version:c,environment:p,services:u,skipTerraformDeploy:R,success:!0};return{content:g(JSON.stringify(_,null,2)),structuredContent:_}}catch(v){throw l.error({error:v},"\u274C Error launching workflow"),new f(v,{operation:"launch deploy-selected workflow",remediation:"check 'gh workflow list' and that deploy-selected-services.yml exists on the target ref"})}},Za=async()=>{let e=await y(),r=Ua(e,".github/workflows/deploy-selected-services.yml"),t=await Ka.readFile(r,"utf-8"),n=qa.parse(t).on.workflow_dispatch.inputs,s=[];for(let[i,c]of Object.entries(n))c.type==="boolean"&&i!=="skip_terraform_deploy"&&s.push(i);return s},oo=w({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:V.string().describe('Accepts a release version (e.g. "1.2.5") OR a release name (e.g. "checkout-redesign") \u2014 resolves to the release/vX.Y.Z or release/<name> branch. Pass "dev" to deploy from the dev branch instead. Required for MCP calls.'),env:V.string().describe('Target environment name \u2014 must match an env configured for the project (e.g. "dev", "renana", "oriana"). Required for MCP calls.'),services:V.array(V.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:V.boolean().optional().describe("Skip the terraform deployment stage.")},outputSchema:{releaseBranch:V.string().describe("The release branch that was deployed"),version:V.string().describe("The version that was deployed"),environment:V.string().describe("The environment deployed to"),services:V.array(V.string()).describe("The services that were deployed"),skipTerraformDeploy:V.boolean().describe("Whether terraform deployment was skipped"),success:V.boolean().describe("Whether the deployment was successful")},handler:ls});import{z as or}from"zod";var ps=async()=>{let r=(await C()).flatMap(i=>{let c=P(i.branch);return c?[{version:$(c),jiraKey:J(c),type:x(i.title)}]:[]}),t=await E(),o=Math.max(...r.map(i=>i.version.length)),n=r.map(i=>{let c=er(i.version,i.type,o),a=t.get(i.jiraKey);return a?`${c} ${a}`:c});l.info(`All release branches:
122
+ `),l.info(`
123
+ ${n.join(`
124
+ `)}
125
+ `);let s={releases:r.map(i=>({version:i.version,type:i.type,description:t.get(i.jiraKey)||null})),count:r.length};return{content:g(JSON.stringify(s,null,2)),structuredContent:s}},no=w({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:or.array(or.object({version:or.string().describe("Release version"),type:or.enum(["regular","hotfix"]).describe("Release type"),description:or.string().nullable().describe("Jira version description")})).describe("List of all release branches"),count:or.number().describe("Number of release branches")},handler:ps});var ye=e=>e.slice(1).split(".").map(Number),so=e=>[...e].sort((r,t)=>{let[o,n,s]=ye(r),[i,c,a]=ye(t);return o!==i?(o??0)-(i??0):n!==c?(n??0)-(c??0):(s??0)-(a??0)});var ms="next",Xa=/^v?(\d+)\.(\d+)\.(\d+)$/,Ya=e=>e.replace(/^.*release\//,""),ao=e=>{let r=Ya(e.trim()),t=Xa.exec(r);return t?[Number(t[1]),Number(t[2]),Number(t[3])]:null},ds=e=>`${e[0]}.${e[1]}.${e[2]}`,co=e=>{let r=[...e.remoteBranches??[],...e.jiraVersions??[]],t=[],o=new Set;for(let n of r){let s=ao(n);if(!s)continue;let i=ds(s);o.has(i)||(o.add(i),t.push(s))}return so(t.map(n=>ds(n))).map(n=>ye(`v${n}`))},Me=class extends Error{constructor(){super("No prior release versions found from git or Jira. Specify the version explicitly."),this.name="NoPriorVersionsError"}},nt=(e,r)=>{if(e.length===0)throw new Me;let t=e[e.length-1];if(r==="hotfix"){let[s,i]=t,c=e.reduce((a,p)=>p[0]===s&&p[1]===i?Math.max(a,p[2]):a,0);return`${s}.${i}.${c+1}`}let[o,n]=t;return`${o}.${n+1}.0`},lo=e=>e.trim().toLowerCase()===ms,Qa=e=>e==="regular"||e==="hotfix",us=e=>"name"in e,ec=e=>{let r=e.trim();if(r==="")throw new Error("Release spec is empty");let t=r.indexOf(":"),o=r,n="regular",s="";if(t!==-1){o=r.slice(0,t).trim();let c=r.slice(t+1),a=c.indexOf(":"),p=a===-1?c.trim():c.slice(0,a).trim();s=a===-1?"":c.slice(a+1).trim();let d=p.toLowerCase();if(!Qa(d))throw new Error(`Invalid release type "${p}". Expected "regular" or "hotfix".`);n=d}if(lo(o)||ao(o)!==null){let c={version:o,type:n};return s!==""&&(c.description=s),c}let i={name:o,type:n};return s!==""&&(i.description=s),i},po=e=>{let r=e.id.raw;return e.description!==void 0&&e.description!==""?`${r}:${e.type}:${e.description}`:e.type==="hotfix"?`${r}:hotfix`:r},io=(e,r)=>r!==void 0&&r!==""?{...e,description:r}:e,rc=e=>{let r=e.name.trim();return jr(r),io({id:{kind:"name",name:r,raw:r},type:e.type},e.description)},mo=(e,r)=>{let t=[...r];return e.map(o=>{if(us(o))return rc(o);let n=o.version.trim();if(n==="")throw new Error("Release entry has an empty version");if(lo(n)){let c=nt(t,o.type);return t.push(ye(`v${c}`)),io({id:oe(c),type:o.type},o.description)}let s=ao(n);if(!s)throw new Error(`Invalid version "${n}". Expected semver like "1.2.5" or the token "next".`);let i=`${s[0]}.${s[1]}.${s[2]}`;return t.push(s),io({id:oe(i),type:o.type},o.description)})},uo=e=>e.some(r=>!us(r)&&lo(r.version));import{$ as st}from"zx";var tc=e=>e.split(`
126
+ `).map(r=>{let t=r.indexOf(" ");return t===-1?null:P(r.slice(t+1))}).filter(r=>r!==null&&r.kind==="version").map(r=>r.raw),oc=async()=>{let e=st.quiet;try{st.quiet=!0;let r=await st`git ls-remote --heads origin 'release/v*'`;return tc(r.stdout)}finally{st.quiet=e}},nc=async()=>{let e=await Oe();return e?(await Xe(e)).map(t=>t.name):[]},fo=async()=>{let[e,r]=await Promise.allSettled([oc(),nc()]);return e.status==="rejected"&&l.warn({error:e.reason},"Failed to list remote release branches; continuing without them"),r.status==="rejected"&&l.warn({error:r.reason},"Failed to fetch Jira versions; continuing without them"),co({remoteBranches:e.status==="fulfilled"?e.value:[],jiraVersions:r.status==="fulfilled"?r.value:[]})};import hs from"@inquirer/confirm";import fs from"@inquirer/select";import it from"node:process";import{z as T}from"zod";import{question as ho}from"zx";var sc='"1.2.5" or "next"',ic=(e,r)=>{try{return nt(e,r)}catch(t){if(t instanceof Me)return null;throw t}},go=(e,r)=>{try{return mo(e,r)}catch(t){throw t instanceof Me?new f(t,{operation:"resolve release version",remediation:'pass an explicit version (e.g. "1.2.5") instead of "next" when there are no prior versions'}):t instanceof Zo?new f(t,{operation:"validate release name",remediation:'use a kebab-case name like "checkout-redesign" (lowercase, digits, single hyphens, not a reserved word)'}):t}},ac=async(e,r)=>{let t=ic(e,r),o=t?` [${t}]`:"",n=(await ho(` Version (e.g. ${sc})${o}: `)).trim(),s=n===""?t??"":n;return s===""&&(l.error("No version provided. Exiting..."),it.exit(1)),s},cc=async()=>{let e=(await ho(' Name (kebab-case, e.g. "checkout-redesign"): ')).trim();e===""&&(l.error("No name provided. Exiting..."),it.exit(1));try{jr(e)}catch(r){let t=r instanceof Error?r.message:String(r);l.error(`${t} Exiting...`),it.exit(1)}return e},lc=async e=>{m.setInteractive();let r=null,t=[],o=async()=>(r===null&&(r=await e(),t.push(...r)),t),n=[],s=!0;for(;s;){let i=n.length+1,c=await fs({message:`Release #${i} \u2014 version or name?`,choices:[{name:"version (semver / next)",value:"version"},{name:"name (free-form)",value:"name"}],default:"version"}),a=await fs({message:`Release #${i} \u2014 select type:`,choices:[{name:"regular",value:"regular"},{name:"hotfix",value:"hotfix"}],default:"regular"}),p;if(c==="name"){let u=await cc();p=go([{name:u,type:a}],[])[0]}else{let u=await ac(await o(),a);p=go([{version:u,type:a}],t)[0],p.id.kind==="version"&&t.push(ye(`v${p.id.raw}`))}let d=(await ho(" Description (optional, press Enter to skip): ")).trim();n.push({...p,...d!==""?{description:d}:{}}),s=await hs({message:"Add another release?",default:!1})}return n},pc=e=>{let t=[e.id.kind==="version"?`v${e.id.raw}`:e.id.name,e.type];return e.description&&t.push(e.description),t.join(" \xB7 ")},gs=e=>{for(let r of e)m.addOption("--release",po(r))},dc=async(e,r)=>{if(e&&e.length>0){let o=uo(e)?await r():[],n=go(e,o);return gs(n),n}let t=await lc(r);return gs(t),t},mc=e=>{if(new Set(e.map(t=>t.type)).size>1)throw new f(void 0,{operation:"create release",remediation:"create regular and hotfix releases in separate invocations",stderrExcerpt:"mixed regular and hotfix releases in one batch are not supported"})},uc=async(e,r)=>{let t=e.map(pc).join(`
127
+ - `),o=r?!0:await hs({message:`Create the following ${e.length} release(s)?
128
+ - ${t}
129
+ `});r||m.setInteractive(),o||(l.info("Operation cancelled. Exiting..."),it.exit(0)),m.addOption("--yes",!0)},fc=async e=>{let{entry:r,jiraConfig:t}=e,o=$(r.id),n=r.id.kind==="version"?`v${r.id.raw}`:r.id.name;try{await Zt(r.type);let s=await Xt({id:r.id,jiraConfig:t,description:r.description,type:r.type});return l.info(`\u2705 Successfully created release: ${n} (${r.type})`),l.info(`\u{1F517} GitHub PR: ${s.prUrl}`),l.info(`\u{1F517} Jira Version: ${s.jiraVersionUrl}
130
+ `),{result:s}}catch(s){let i=new f(s,{operation:`create release ${n} (${r.type})`,remediation:"verify the version or name is unique and the base branch is clean"});return l.error(`\u274C ${i.message}
131
+ `),{failure:{version:o,error:i.message}}}},gc=(e,r,t)=>{r===e?l.info(`\u2705 All ${e} release branch(es) were created successfully.`):r>0?(l.warn(`\u26A0\uFE0F ${r} of ${e} release branches were created successfully.`),l.warn(`\u274C ${t} release(s) failed.`)):l.error(`\u274C All ${e} release branch(es) failed to create.`)},ws=async e=>{let{releases:r,confirmedCommand:t}=e;m.start("release-create");let o=await Ye(),n=null,i=await dc(r,async()=>(n===null&&(n=await fo()),n));if(i.length===0)throw new f(void 0,{operation:"create release",remediation:'pass at least one entry in "releases" (e.g. [{ version: "1.2.5", type: "regular" }])',stderrExcerpt:"no releases provided"});mc(i),await O({operation:"create release",requiredBranch:Qe(i[0].type)}),await uc(i,!!t);let c=[],a=[];for(let d of i){let{result:u,failure:h}=await fc({entry:d,jiraConfig:o});u&&c.push(u),h&&a.push(h)}gc(i.length,c.length,a.length),m.print();let p={createdBranches:c.map(d=>d.branchName),successCount:c.length,failureCount:a.length,releases:c,failedReleases:a};return{content:g(JSON.stringify(p,null,2)),structuredContent:p}},wo=w({name:"release-create",description:'Create one or more releases in a single call. Each entry in "releases" carries EITHER a "version" (semver or the literal token "next") OR a "name" (free-form kebab-case identifier) \u2014 exactly one is required and they are mutually exclusive. Each entry also has its own type (regular|hotfix, default regular) and optional description; all entries in one call must share the same type \u2014 mixed regular+hotfix batches are rejected (create them in separate invocations). For each release this tool switches to the appropriate base branch (dev for regular, main for hotfix), cuts the release branch (release/v<semver> for versions, release/<name> for names), opens a GitHub release PR, and creates the matching Jira fix version (v<semver> for versions, <name> for names). 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. Named releases never auto-bump and "next" is version-only. Must be run from the main repository checkout (not a linked worktree) on the matching base branch with a clean working tree. 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:T.array(T.object({version:T.string().optional().describe('Version to create (e.g., "1.2.5") or the literal token "next" for auto-increment. Mutually exclusive with "name".'),name:T.string().optional().describe('Free-form kebab-case release name (e.g., "checkout-redesign"). Mutually exclusive with "version". Named releases never auto-bump.'),type:T.enum(["regular","hotfix"]).optional().default("regular").describe('Release type: "regular" (branches off dev) or "hotfix" (branches off main).'),description:T.string().optional().describe("Optional description for the Jira version.")}).refine(e=>e.version===void 0!=(e.name===void 0),{message:'Each release entry must have exactly one of "version" or "name" (they are mutually exclusive).'}).transform(e=>e.name!==void 0?{name:e.name,type:e.type,...e.description?{description:e.description}:{}}:{version:e.version,type:e.type,...e.description?{description:e.description}:{}})).min(1).describe('One or more releases to create. Each entry has exactly one of "version" or "name", plus its own type and optional description.')},outputSchema:{createdBranches:T.array(T.string()).describe("List of created release branch names"),successCount:T.number().describe("Number of releases created successfully"),failureCount:T.number().describe("Number of releases that failed"),releases:T.array(T.object({version:T.string().describe("Version number"),type:T.enum(["regular","hotfix"]).describe("Release type"),branchName:T.string().describe("Release branch name"),prUrl:T.string().describe("GitHub PR URL"),jiraVersionUrl:T.string().describe("Jira version URL")})).describe("Detailed information for each created release with URLs"),failedReleases:T.array(T.object({version:T.string().describe("Version number that failed"),error:T.string().describe("Error message")})).describe("List of releases that failed with error messages")},handler:ws});import hc from"@inquirer/confirm";import wc from"@inquirer/select";import vc from"node:process";import{z as ke}from"zod";import{question as yc}from"zx";var vs=(e,r)=>`${e.baseUrl}/projects/${r.projectId}/versions/${r.id}/tab/release-report-all-issues`,kc=(e,r)=>r.trim()!==""?`${e}
132
+
133
+ ${r}`:`${e}
134
+ `,Rc=async()=>{let e=await C(),r=e.map(s=>s.branch),t=new Map(e.map(s=>[s.branch,x(s.title)])),o=await E(),n=await wc({message:"\u{1F33F} Select release branch",choices:I({branches:r,descriptions:o,types:t})});return{branch:n,type:t.get(n)||"regular"}},bc=async e=>{let t=(await C()).find(o=>o.branch===e);if(!t)throw new f(void 0,{operation:`edit description for ${e}`,remediation:`confirm an open PR exists for ${e} ('gh pr list')`});return x(t.title)},xc=async e=>{let r=e===""?"(no current description)":`current: "${e}"`,o=(await yc(` New description ${r}
135
+ (press Enter to keep current): `)).replace(/\n$/,"");return o===""?e:o},ys=async e=>{let{version:r,description:t,confirmedCommand:o}=e;m.start("release-desc-edit");let n=await Ye(),s;r?(s=ae(r),await bc(s)):(m.setInteractive(),s=(await Rc()).branch);let i=P(s);if(!i)throw new f(void 0,{operation:`edit description for ${s}`,remediation:'pass a version (e.g. "1.2.5") or a release name (e.g. "checkout-redesign")'});let c=$(i);m.addOption("--version",c);let a=J(i),p=await Qr(a,n);if(!p)throw new f(void 0,{operation:`edit description for ${a}`,remediation:`create the Jira fix version "${a}" first or pick a different release`});let d=p.description??"",u;if(t!==void 0?(u=t,m.addOption("--description",u)):(m.setInteractive(),u=await xc(d)),u===d){l.info(`No change \u2014 description for ${a} is already: "${d}"`),m.print();let _={version:c,branch:s,jiraVersionUrl:vs(n,p),previousDescription:d,newDescription:u,changed:!1};return{content:g(JSON.stringify(_,null,2)),structuredContent:_}}let h=o?!0:await hc({message:`Update description for ${a}?
136
+ from: "${d}"
137
+ to: "${u}"
138
+ `});o||m.setInteractive(),h||(l.info("Operation cancelled. Exiting..."),vc.exit(0)),m.addOption("--yes",!0),await et({versionId:p.id,description:u},n);let R=vs(n,p),v=kc(R,u);await ot({branch:s,body:v}),l.info(`\u2705 Updated description for ${a}`),l.info(`\u{1F517} Jira Version: ${R}`),l.info(`\u{1F517} PR branch: ${s}
139
+ `),m.print();let S={version:c,branch:s,jiraVersionUrl:R,previousDescription:d,newDescription:u,changed:!0};return{content:g(JSON.stringify(S,null,2)),structuredContent:S}},vo=w({name:"release-desc-edit",description:"Edit a release's description in Jira and in the matching GitHub release PR body. Accepts a release version or a release name: targets the Jira fix version named `v<version>` (versioned) or `<name>` (named) and the open PR on branch `release/v<version>` or `release/<name>`. The PR body is rewritten canonically to `<jiraVersionUrl>\\n\\n<description>` \u2014 any prior manual edits to the body are overwritten. Both `version` and `description` are required for MCP calls (the picker/prompt are unreachable without a TTY). Empty `description` clears the description on both sides. Confirmation is auto-skipped for MCP, so the caller is responsible for gating.",inputSchema:{version:ke.string().describe('Accepts a release version (e.g. "1.2.5") OR a release name (e.g. "checkout-redesign").'),description:ke.string().describe("New description. Empty string clears the description.")},outputSchema:{version:ke.string().describe("Release version"),branch:ke.string().describe('Release branch name (e.g. "release/v1.2.5" or "release/checkout-redesign")'),jiraVersionUrl:ke.string().describe("Jira fix version URL"),previousDescription:ke.string().describe("The description before the update"),newDescription:ke.string().describe("The description after the update"),changed:ke.boolean().describe("Whether the description actually changed")},handler:ys});import{existsSync as xs}from"node:fs";import Cs from"node:path";import Oc from"node:process";import{z as ce}from"zod";import{createHash as Cc}from"node:crypto";import{readFileSync as Tc}from"node:fs";var at=e=>Cc("sha256").update(Tc(e)).digest("hex");import{readFileSync as Ac,writeFileSync as _c}from"node:fs";import pt from"node:path";import{z as Y}from"zod";import{readdirSync as Sc}from"node:fs";import yo from"node:path";var z="vendor",Ec=new Set(["node_modules","dist",".turbo",".omc","__screenshots__",".vitest-attachments",".output",".source",".nitro",".tanstack"]),$c=new Set([".sync-manifest.json",".eslintcache","log.txt"]),Pc=[".tsbuildinfo"],ks=e=>Ec.has(e),Rs=e=>$c.has(e)?!0:Pc.some(r=>e.endsWith(r));var Ic=e=>e.split(yo.sep).join("/"),ct=e=>{let r=[],t=o=>{for(let n of Sc(o,{withFileTypes:!0})){let s=yo.join(o,n.name);if(n.isDirectory()){if(ks(n.name))continue;t(s);continue}Rs(n.name)||r.push(Ic(yo.relative(e,s)))}};return t(e),r.sort()};var Q=".sync-manifest.json",lt=1,Nc=Y.object({schemaVersion:Y.number().optional(),source:Y.string(),commit:Y.string(),syncedAt:Y.string(),fileCount:Y.number(),files:Y.record(Y.string(),Y.string())}),ko=e=>(e.schemaVersion??lt)>lt,bs=e=>{let r={};for(let t of ct(e))try{r[t]=at(pt.join(e,t))}catch(o){let n=o instanceof Error?o.message:String(o);throw new Error(`Cannot hash vendor file "${t}" (broken symlink or unreadable file): ${n}`)}return r},Ro=e=>{let r=pt.join(e,Q),t;try{t=Ac(r,"utf8")}catch{throw new Error(`Missing ${Q} at ${r}`)}let o=Nc.safeParse(JSON.parse(t));if(!o.success)throw new Error(`Invalid ${Q} at ${r}: ${Y.prettifyError(o.error)}`);return o.data},bo=(e,r)=>{let t=bs(e),o={schemaVersion:lt,source:r.source,commit:r.commit,syncedAt:new Date().toISOString(),fileCount:Object.keys(t).length,files:t};return _c(pt.join(e,Q),`${JSON.stringify(o,null,2)}
140
+ `),o},xo=(e,r)=>{let t=r.files,o=ct(e),n=[],s=[];for(let a of o){if(!(a in t)){s.push(a);continue}at(pt.join(e,a))!==t[a]&&n.push(a)}let i=new Set(o),c=Object.keys(t).filter(a=>!i.has(a));return{modified:n,added:s,removed:c}};var Co=30,To=(e,r)=>{if(r.length!==0){l.info(`
141
+ ${e} (${r.length}):`);for(let t of r.slice(0,Co))l.info(` ${t}`);r.length>Co&&l.info(` \u2026and ${r.length-Co} more`)}},Ts=async(e={})=>{let r=e.cwd??await y(),t=Cs.join(r,z),o={modified:[],added:[],removed:[],fileCount:0};if(!xs(t)){l.info(`\u2139\uFE0F No ${z}/ folder found \u2014 nothing to check.`);let d={status:"skipped",ok:!0,...o};return{content:g(JSON.stringify(d,null,2)),structuredContent:d}}if(!xs(Cs.join(t,Q))){l.error(`\u274C Missing ${z}/${Q}. Re-run the vendor sync to generate it.`);let d={status:"missing-manifest",ok:!1,...o};return{content:g(JSON.stringify(d,null,2)),structuredContent:d}}let n=Ro(t);if(ko(n)){l.error(`\u274C ${z}/${Q} has a newer schemaVersion (${String(n.schemaVersion)}) than this CLI supports. Upgrade infra-kit.`);let d={status:"unknown-schema",ok:!1,...o};return{content:g(JSON.stringify(d,null,2)),structuredContent:d}}let{modified:s,added:i,removed:c}=xo(t,n),a=s.length>0||i.length>0||c.length>0;a?(l.error(`\u274C ${z}/ has drifted from ${z}/${Q}.`),l.error(" These files are mirrored from the source repo \u2014 edit them upstream, not here."),To("Modified",s),To("Added (not in manifest)",i),To("Removed (in manifest, now missing)",c)):l.info(`\u2705 ${z}/ matches manifest (${n.fileCount} files).`);let p={status:a?"drift":"clean",ok:!a,fileCount:n.fileCount,modified:s,added:i,removed:c};return{content:g(JSON.stringify(p,null,2)),structuredContent:p}},Dc={status:ce.enum(["clean","drift","skipped","missing-manifest","unknown-schema"]),ok:ce.boolean().describe("Whether the vendor tree matches its manifest (false \u2192 CI should fail)"),fileCount:ce.number(),modified:ce.array(ce.string()),added:ce.array(ce.string()),removed:ce.array(ce.string())},Eo=w({name:"vendor-check",description:"Verify that files under vendor/ match the checksums in vendor/.sync-manifest.json. Self-contained (no source repo or config needed). Returns ok=false on drift, missing manifest, or an unknown future schemaVersion; ok=true when clean or when no vendor/ folder exists.",inputSchema:{},outputSchema:Dc,handler:()=>Ts({cwd:Oc.cwd()})});import{z as re}from"zod";import Mc from"node:fs/promises";import Fc from"node:path";import{pathToFileURL as jc}from"node:url";import{z as Lc}from"zod";var dt=async e=>{let r=Fc.join(e,lr),t;try{t=await Mc.stat(r)}catch{throw new Error(`${lr} not found at ${r}`)}let s=(await import(`${jc(r).href}?mtime=${Number(t.mtimeMs)}`)).default;if(s===void 0)throw new Error(`${lr} at ${r} has no default export`);let i=typeof s=="function"?await s():s,c=fn.safeParse(i);if(!c.success)throw new Error(`Invalid ${lr} at ${r}: ${Lc.prettifyError(c.error)}`);return c.data};import{existsSync as ee,mkdirSync as Wc,writeFileSync as Vc}from"node:fs";import G from"node:path";import{$ as Ir}from"zx";var Jc=["node_modules","dist","*.tsbuildinfo",".turbo",".eslintcache",".omc","__screenshots__",".vitest-attachments",".output",".source",".nitro",".tanstack","log.txt"],Bc=`# vendor/ \u2014 mirrored from the source repo
142
+
143
+ **DO NOT EDIT files in this folder here.**
144
+
145
+ Everything under \`vendor/\` is the single source of truth maintained in the source
146
+ repo and copied into this repo by \`infra-kit vendor sync\`. Local edits are
147
+ overwritten on the next sync and will fail \`infra-kit vendor check\` in CI.
148
+
149
+ To change a vendored package, edit it in the source repo and re-run the sync.
150
+
151
+ See \`.sync-manifest.json\` for the source commit and per-file checksums.
152
+ `,$s=()=>Jc.map(e=>`--exclude=${e}`),mt=async e=>{try{return(await Ir({cwd:e})`git rev-parse HEAD`).stdout.trim()}catch{return"unknown"}},zc=async(e,r)=>{if(!ee(e))return!1;ee(r)&&await Ir`rm -rf ${r}`;let t=`${e}/`,o=`${r}/`;return await Ir`rsync -a ${$s()} ${t} ${o}`,!0},Gc=async(e,r)=>{if(!ee(e))return!1;let t=G.dirname(r);return ee(t)||Wc(t,{recursive:!0}),await Ir`cp ${e} ${r}`,!0},Kc=async(e,r)=>{if(!ee(e))return[];if(!ee(r))return[`missing target: ${r}`];let t=`${e}/`,o=`${r}/`;return(await Ir`rsync -ai --dry-run --delete ${$s()} ${t} ${o}`).stdout.split(`
153
+ `).map(s=>s.trim()).filter(Boolean)},Ps=(e,r)=>{let t=G.join(e,z);ee(t)&&(Vc(G.join(t,"README.md"),Bc),bo(t,r))},$o=(e,r)=>G.join(En(e),r),nr=(e,r)=>r?e.filter(t=>r.includes(t)):e,Es=(e,r,t,o,n)=>{let s=G.resolve(e),i=G.resolve(r);if(i!==s&&!i.startsWith(s+G.sep))throw new f(void 0,{operation:`sync vendor item ${n}`,stderrExcerpt:`${t} escapes repo root: ${o}`})},Ss=async(e,r,t,o,n)=>{let s=[];for(let i of o){let c=$o(t,i);if(!ee(c)){s.push({repo:i,copied:0,total:e.copy.length,skipped:!0});continue}let a=0;for(let p of e.copy){let d=G.join(r,p.source),u=G.join(c,p.target);Es(r,d,"source",p.source,p.name),Es(c,u,"target",p.target,p.name),(p.type==="directory"?await zc(d,u):await Gc(d,u))&&a++}Ps(c,n),s.push({repo:i,copied:a,total:e.copy.length,skipped:!1})}return{source:n.source,commit:n.commit,repos:s}},Is=async(e,r,t)=>{let o=[];for(let n of r){let s=$o(e,n),i=!ee(s);i||Ps(s,t),o.push({repo:n,skipped:i})}return o},As=async(e,r,t,o)=>{let n=[],s=e.copy.filter(i=>i.vendored===!0);for(let i of o){let c=$o(t,i);if(ee(c))for(let a of s){let p=G.join(r,a.source),d=G.join(c,a.target),u=await Kc(p,d);u.length>0&&n.push({repo:i,target:a.target,changes:u})}}return n};var Po=20,_s=async(e={})=>{let r=e.cwd??await y(),t=await dt(r),o=await qe(),n=nr(o.targets,e.repos),s=await As(t,r,o.workspaceDir,n);if(s.length===0)l.info("\u{1F389} No drift detected.");else for(let c of s){l.info(`\u274C ${c.repo} \u2192 ${c.target} (${c.changes.length} change(s)):`);for(let a of c.changes.slice(0,Po))l.info(` ${a}`);c.changes.length>Po&&l.info(` \u2026and ${c.changes.length-Po} more`)}let i={ok:s.length===0,drifted:s.length,entries:s};return{content:g(JSON.stringify(i,null,2)),structuredContent:i}},Uc={ok:re.boolean().describe("Whether every target is in sync with the source"),drifted:re.number(),entries:re.array(re.object({repo:re.string(),target:re.string(),changes:re.array(re.string())}))},So=w({name:"vendor-diff",description:"Source-aware drift check: compare each target repo vendored subtree against the source via rsync dry-run. Read-only; run from the source repo root. ok=false when any target has drifted.",inputSchema:{repos:re.array(re.string()).optional().describe("Restrict to these target repo names")},outputSchema:Uc,handler:e=>_s({repos:e.repos})});import qc from"node:path";import{z as Re}from"zod";var Ns=async e=>{let r=e.cwd??await y(),t=await qe(),o=nr(t.targets,e.repos),n=await mt(r),s=qc.basename(r),i=await Is(t.workspaceDir,o,{source:s,commit:n});for(let a of i)l.info(a.skipped?`\u26A0\uFE0F ${a.repo}: target does not exist \u2014 skipped`:`\u{1F4DD} ${a.repo}: manifest written`);let c={source:s,commit:n,repos:i};return{content:g(JSON.stringify(c,null,2)),structuredContent:c}},Hc={source:Re.string(),commit:Re.string(),repos:Re.array(Re.object({repo:Re.string(),skipped:Re.boolean()}))},Io=w({name:"vendor-manifest",description:"Regenerate each target repo vendor/.sync-manifest.json + README from current content without copying. Mutating; run from the source repo root.",inputSchema:{repos:Re.array(Re.string()).optional().describe("Restrict to these target repo names")},outputSchema:Hc,handler:e=>Ns({repos:e.repos,confirmedCommand:e.confirmedCommand})});import Zc from"@inquirer/confirm";import Os from"node:path";import Ds from"node:process";import{z as te}from"zod";var Ms=async e=>{let r=e.cwd??await y(),t=await dt(r),o=await qe(),n=nr(o.targets,e.repos);e.confirmedCommand||await Zc({message:`Sync vendor files from ${Os.basename(r)} into ${n.length} repo(s)?`},{output:Ds.stderr})||Ds.exit(0);let s=await mt(r),i=Os.basename(r),c=await Ss(t,r,o.workspaceDir,n,{source:i,commit:s});for(let a of c.repos)a.skipped?l.info(`\u26A0\uFE0F ${a.repo}: target does not exist \u2014 skipped`):l.info(`\u2705 ${a.repo}: copied ${a.copied}/${a.total} items + manifest`);return{content:g(JSON.stringify(c,null,2)),structuredContent:c}},Xc={source:te.string(),commit:te.string(),repos:te.array(te.object({repo:te.string(),copied:te.number(),total:te.number(),skipped:te.boolean()}))},Ao=w({name:"vendor-sync",description:"Copy vendored files from the source repo (vendor.config.ts) into each target repo and regenerate their vendor/.sync-manifest.json + README. Mutating; run from the source repo root.",inputSchema:{repos:te.array(te.string()).optional().describe("Restrict to these target repo names")},outputSchema:Xc,handler:e=>Ms({repos:e.repos,confirmedCommand:e.confirmedCommand})});import{z as Yc}from"zod";var Fs=async()=>{let e=qr.version;l.info(e);let r={version:e};return{content:g(JSON.stringify(r,null,2)),structuredContent:r}},_o=w({name:"version",description:"Print the installed infra-kit CLI version",inputSchema:{},outputSchema:{version:Yc.string().describe("Installed infra-kit CLI version (from package.json)")},handler:Fs});var ut=["workspace","none"];import js from"node:fs/promises";import ft from"node:path";var Ar=async e=>{let{workspacePath:r,folderPaths:t}=e,o=ft.dirname(r),n;try{n=await js.readFile(r,"utf-8")}catch(d){throw new Error(`Cursor workspace file not found at ${r}: ${d.message}`)}let s;try{s=JSON.parse(n)}catch(d){throw new Error(`Failed to parse ${r} as JSON. Comments (JSONC) are not supported. ${d.message}`)}let i=s.folders??[],c=new Set(i.map(d=>ft.resolve(o,d.path))),a=[],p=[];for(let d of t){let u=ft.resolve(d);if(c.has(u)){p.push(d);continue}let h=ft.relative(o,u);i.push({path:h}),c.add(u),a.push(d)}return s.folders=i,await js.writeFile(r,`${JSON.stringify(s,null,2)}
154
+ `,"utf-8"),{added:a,skipped:p}};import{$ as Qc}from"zx";var _r=async e=>{await Qc`cursor ${e}`};import el from"node:fs/promises";import ht from"node:path";import Ls from"node:fs/promises";import gt from"node:path";var Nr=async e=>{let{workspacePath:r,folderPaths:t}=e,o=gt.dirname(r),n;try{n=await Ls.readFile(r,"utf-8")}catch(h){throw new Error(`Cursor workspace file not found at ${r}: ${h.message}`)}let s;try{s=JSON.parse(n)}catch(h){throw new Error(`Failed to parse ${r} as JSON. Comments (JSONC) are not supported. ${h.message}`)}let i=s.folders??[],c=new Set(t.map(h=>gt.resolve(h))),a=new Set,p=i.filter(h=>{let R=gt.resolve(o,h.path);return c.has(R)?(a.add(R),!1):!0});s.folders=p,await Ls.writeFile(r,`${JSON.stringify(s,null,2)}
155
+ `,"utf-8");let d=[],u=[];for(let h of t){let R=gt.resolve(h);a.has(R)?d.push(h):u.push(h)}return{removed:d,notFound:u}};var No=async e=>{let{workspacePath:r,worktreeDir:t,currentBranches:o}=e,n=ht.dirname(r),s=ht.resolve(`${t}/release`),i=await el.readFile(r,"utf-8"),a=JSON.parse(i).folders??[],p=new Set(o.map(v=>ht.resolve(`${t}/${v}`))),d=[];for(let v of a){let S=ht.resolve(n,v.path);(S===s||S.startsWith(`${s}/`))&&!p.has(S)&&d.push(S)}let u=[];d.length>0&&(u=(await Nr({workspacePath:r,folderPaths:d})).removed);let h=o.map(v=>`${t}/${v}`),{added:R}=h.length>0?await Ar({workspacePath:r,folderPaths:h}):{added:[]};return{added:R,removed:u}};import Ws from"node:path";var Fe=(e,r)=>Ws.isAbsolute(e)?e:Ws.resolve(r,e);var Oo=async e=>{let{projectRoot:r,worktreeDir:t,currentBranches:o,cursorConfig:n}=e;if(!n.workspaceConfigPath)return l.warn("\u26A0\uFE0F Skipping Cursor: workspaceConfigPath is not set."),{ran:!1,added:0,removed:0};let s=Fe(n.workspaceConfigPath,r);try{let{added:i,removed:c}=await No({workspacePath:s,worktreeDir:t,currentBranches:o});return o.length>0&&await _r(s),{ran:!0,added:i.length,removed:c.length}}catch(i){return l.warn({error:i},`\u26A0\uFE0F Failed to reconcile/open Cursor workspace at ${s}`),{ran:!1,added:0,removed:0}}};import{$ as rl}from"zx";var Do=async e=>{let{folderPaths:r}=e;for(let t of r)await rl`zed --add ${t}`;return{added:r}};import{$ as tl}from"zx";var Mo=async e=>{let{projectRoot:r,worktreeDir:t,currentBranches:o}=e;if(o.length===0)return{ran:!1,added:0,removed:0};let n=[r,...o.map(s=>`${t}/${s}`)];try{return await tl`zed ${n}`,{ran:!0,added:o.length,removed:0}}catch(s){return l.warn({error:s},"\u26A0\uFE0F Failed to open Zed workspace"),{ran:!1,added:0,removed:0}}};import{$ as ol}from"zx";var Fo=async e=>{let{projectRoot:r,worktreeDir:t,remainingBranches:o}=e,n=[r,...o.map(s=>`${t}/${s}`)];try{return await ol`zed --reuse ${n}`,l.info(`\u21BB Refreshed Zed workspace to root + ${o.length} release worktree(s) (other folders in the focused window are not preserved)`),{ran:!0}}catch(s){return l.warn({error:s},"\u26A0\uFE0F Failed to refresh Zed workspace"),{ran:!1}}};var le=e=>{throw new Error(`Unexpected value: ${JSON.stringify(e)}`)};var jo=async e=>{let{projectRoot:r,worktreeDir:t,branches:o}=e,n=await b(),s=q(n),i=o.map(a=>`${t}/${a}`),c=[];for(let a of s)switch(a.provider){case"cursor":{if(!a.config.workspaceConfigPath){l.warn("\u26A0\uFE0F Skipping Cursor: ide.config.workspaceConfigPath is not set in infra-kit config"),c.push({ran:!1,provider:"cursor",added:0,skipped:0});break}let p=Fe(a.config.workspaceConfigPath,r),{added:d,skipped:u}=await Ar({workspacePath:p,folderPaths:i}),h=u.length>0?` (${u.length} already present)`:"";l.info(`\u2705 Added ${d.length} folder(s) to ${p}${h}`),await _r(p),c.push({ran:!0,provider:"cursor",added:d.length,skipped:u.length});break}case"zed":{let{added:p}=await Do({folderPaths:i});l.info(`\u2705 Added ${p.length} folder(s) to Zed workspace`),c.push({ran:!0,provider:"zed",added:p.length,skipped:0});break}default:le(a)}return c};var Lo=async e=>{let r=await b(),t=q(r),o=[];for(let n of t)switch(n.provider){case"cursor":{let s=await Oo({...e,cursorConfig:n.config});o.push({...s,provider:"cursor"});break}case"zed":{let s=await Mo(e);o.push({...s,provider:"zed"});break}default:le(n)}return o};var Wo=e=>{switch(e){case"cursor":return"Cursor";case"zed":return"Zed";case void 0:return"IDE";default:return le(e)}};var Or=async e=>{let{projectRoot:r,worktreeDir:t,currentWorktrees:o,removedWorktrees:n,allowEditorRelaunch:s}=e;if(n.length===0)return[];let i=await b(),c=q(i),a=n.map(u=>`${t}/${u}`),p=o.filter(u=>!n.includes(u)),d=[];for(let u of c)switch(u.provider){case"cursor":{d.push(await nl({ide:u,projectRoot:r,folderPaths:a}));break}case"zed":{d.push(await sl({projectRoot:r,worktreeDir:t,remainingBranches:p,allowEditorRelaunch:s}));break}default:le(u)}return d},nl=async e=>{let{ide:r,projectRoot:t,folderPaths:o}=e;if(!r.config.workspaceConfigPath)return{provider:"cursor",supported:!0,removed:[]};let n=Fe(r.config.workspaceConfigPath,t);try{let{removed:s}=await Nr({workspacePath:n,folderPaths:o});return s.length>0&&l.info(`\u2705 Removed ${s.length} folder(s) from ${n}`),{provider:"cursor",supported:!0,removed:s}}catch(s){return l.warn({error:s},`\u26A0\uFE0F Failed to update Cursor workspace at ${n}`),{provider:"cursor",supported:!0,removed:[]}}},sl=async e=>{let{projectRoot:r,worktreeDir:t,remainingBranches:o,allowEditorRelaunch:n}=e;return n?(await Fo({projectRoot:r,worktreeDir:t,remainingBranches:o}),{provider:"zed",supported:!0,removed:[]}):(l.info("\u2139\uFE0F Zed folder removal skipped (no interactive session); close removed worktree folders in Zed manually if needed."),{provider:"zed",supported:!0,removed:[]})};import il from"@inquirer/checkbox";import Vo from"@inquirer/confirm";import al from"node:process";import{z as pe}from"zod";import{$ as Dr}from"zx";var cl="feature",ll="release",Js=async e=>{let{confirmedCommand:r,all:t,versions:o,githubDesktop:n,cmux:s}=e,i=e.ide??e.cursor;m.start("worktrees-add"),await O({operation:"create worktrees",requiredBranch:"dev"});try{let c=await M("release"),a=await y(),p=`${a}${Z}`;await Vs(`${p}/${ll}`),await Vs(`${p}/${cl}`);let d=[];if(o)d=o.split(",").map(de=>me(oe(de.trim())));else{let de=await C(),ir=de.map(je=>je.branch);if(ir.length===0)return l.info("\u2139\uFE0F No open release branches found"),m.print(),{content:g(JSON.stringify({createdWorktrees:[],count:0},null,2)),structuredContent:{createdWorktrees:[],count:0}};if(t)d=ir;else{m.setInteractive();let je=new Map(de.map(Ho=>[Ho.branch,x(Ho.title)])),Fr=await E();d=await il({required:!0,message:"\u{1F33F} Select release branches",choices:I({branches:ir,descriptions:Fr,types:je})})}}t?m.addOption("--all",!0):m.addOption("--versions",De(d));let u=r?!0:await Vo({message:"Are you sure you want to proceed with these worktree changes?"});r||m.setInteractive(),u||(l.info("Operation cancelled. Exiting..."),al.exit(0)),r||m.addOption("--yes",!0);let h=await b(),R=i??(q(h).length>0?"workspace":"none");m.addOption("--ide",R);let v=n??h.worktrees?.openInGithubDesktop??await Vo({message:"Open created worktrees in GitHub Desktop?"});typeof n>"u"&&h.worktrees?.openInGithubDesktop===void 0&&m.setInteractive(),v?m.addOption("--github-desktop",!0):m.addOption("--no-github-desktop",!0);let S=s??h.worktrees?.openInCmux??await Vo({message:"Open created worktrees in cmux?"});typeof s>"u"&&h.worktrees?.openInCmux===void 0&&m.setInteractive(),S?m.addOption("--cmux",!0):m.addOption("--no-cmux",!0);let{branchesToCreate:_}=pl({selectedReleaseBranches:d,currentWorktrees:c}),K=await dl(_,p);if(ml(K),R==="workspace"&&await jo({projectRoot:a,worktreeDir:p,branches:K}),v)for(let de of K)await Dr`github ${p}/${de}`,await Dr`sleep 5`;if(S){let de=await U(),ir=await Gr();for(let je of K){let Fr=ne({repoName:de,branch:je});ir.has(zr(Fr))||await Kr({cwd:`${p}/${je}`,title:Fr})}}m.print();let xe={createdWorktrees:K,count:K.length};return{content:g(JSON.stringify(xe,null,2)),structuredContent:xe}}catch(c){throw Ge(c)?c:(l.error({error:c},"\u274C Error managing worktrees"),new f(c,{operation:"create worktrees",remediation:"verify branches don't already exist as worktrees: 'git worktree list'"}))}},Vs=async e=>{await Dr`mkdir -p ${e}`},pl=e=>{let{selectedReleaseBranches:r,currentWorktrees:t}=e,o=t.filter(s=>Lr(s));return{branchesToCreate:r.filter(s=>!o.includes(s))}},dl=async(e,r)=>{let t=await Promise.allSettled(e.map(async n=>{let s=`${r}/${n}`;return await Dr`git worktree add ${s} ${n}`,await Dr({cwd:s})`pnpm install`,n})),o=[];for(let[n,s]of t.entries())if(s.status==="fulfilled")o.push(s.value);else{let i=e[n],c=new f(s.reason,{operation:`git worktree add for ${i}`,remediation:"check the branch name and that the parent dir is writable"});l.error({error:s.reason,msg:c.message})}return o},ml=e=>{if(e.length>0){l.info("\u2705 Created git worktrees:");for(let r of e)l.info(r);l.info("")}else l.info("\u2139\uFE0F No new git worktrees to create")},Jo=w({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:pe.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:pe.string().optional().describe('Comma-separated release versions or names to target (e.g. "1.2.5, 1.2.6" or "checkout-redesign, 1.2.5"). Either "versions" or all=true must be provided for MCP calls. Overrides "all" when set.'),ide:pe.enum(ut).optional().describe('Editor open mode for created worktrees, applied to all configured editors (Cursor and/or Zed, per the "ide" config). "workspace" (the only attach style) adds each worktree to every configured editor workspace and opens it. "none" skips the editor. Resolution order: this flag \u2192 "workspace" when at least one "ide" is configured \u2192 "none" otherwise.'),cursor:pe.enum(ut).optional().describe('Deprecated alias for "ide". Prefer "ide". Ignored when "ide" is provided.'),githubDesktop:pe.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:pe.boolean().optional().describe('Open each created worktree in a new cmux workspace, all rooted at the worktree directory. Pane layout follows "worktrees.cmux.layout" (default "two-columns": left | right; or "three-pane": left split top/bottom + full-height right). Resolution order: this flag \u2192 "worktrees.openInCmux" from infra-kit config \u2192 interactive prompt (CLI) / false (MCP, no TTY).')},outputSchema:{createdWorktrees:pe.array(pe.string()).describe("List of created git worktree branches"),count:pe.number().describe("Number of git worktrees created")},handler:Js});import{z as sr}from"zod";var Bs=async()=>{let e=await M("release");if(e.length===0)return l.info("\u2139\uFE0F No active worktrees found"),{content:g(JSON.stringify({worktrees:[],count:0},null,2)),structuredContent:{worktrees:[],count:0}};let[r,t]=await Promise.all([C(),E()]),o=new Map(r.map(a=>[a.branch,x(a.title)])),n=e.flatMap(a=>{let p=P(a);if(!p)return[];let d=$(p),u=o.get(a)||"regular",h=t.get(J(p))||null;return[{version:d,type:u,description:h}]}),s=Math.max(...n.map(a=>a.version.length)),i=n.map(a=>{let p=er(a.version,a.type,s);return a.description?`${p} ${a.description}`:p});l.info("\u{1F33F} Active worktrees:"),l.info(`
156
+ ${i.join(`
157
+ `)}
158
+ `);let c={worktrees:n,count:n.length};return{content:g(JSON.stringify(c,null,2)),structuredContent:c}},Bo=w({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:sr.array(sr.object({version:sr.string().describe("Release version"),type:sr.enum(["regular","hotfix"]).describe("Release type"),description:sr.string().nullable().describe("Jira version description")})).describe("List of all worktrees with details"),count:sr.number().describe("Number of worktrees")},handler:Bs});import{z as be}from"zod";var zs=async()=>{m.start("worktrees-reload");try{let e=await y(),r=`${e}${Z}`,t=await M("release"),o=await U(),n=await ul({currentBranches:t,repoName:o}),[s,{opened:i}]=await Promise.all([Lo({projectRoot:e,worktreeDir:r,currentBranches:t}),fl({worktreeDir:r,currentBranches:t,repoName:o})]),c={closedCmux:n,openedCmux:i,ideProviders:s.filter(a=>a.ran).map(a=>a.provider),ideFoldersAdded:s.reduce((a,p)=>a+p.added,0),ideFoldersRemoved:s.reduce((a,p)=>a+p.removed,0)};return gl(c,{ideRan:s.some(a=>a.ran)}),m.print(),{content:g(JSON.stringify(c,null,2)),structuredContent:{...c}}}catch(e){throw l.error({error:e},"\u274C Error reloading worktrees"),new f(e,{operation:"reload worktrees",remediation:"run 'worktrees-list' to confirm the branches exist"})}},ul=async e=>{let{currentBranches:r,repoName:t}=e;if(r.length===0)return[];let o=await Gr(),n=[];for(let s of r){let i=ne({repoName:t,branch:s});o.has(zr(i))&&(await ze(i),n.push(i))}return n},fl=async e=>{let{worktreeDir:r,currentBranches:t,repoName:o}=e,n=[];for(let s of t){let i=ne({repoName:o,branch:s});try{await Kr({cwd:`${r}/${s}`,title:i}),n.push(i)}catch(c){l.warn({error:c,title:i},`\u26A0\uFE0F Failed to reopen cmux workspace for ${s}`)}}return{opened:n}},gl=(e,r)=>{if(e.closedCmux.length>0&&l.info(`\u{1F9F9} Closed ${e.closedCmux.length} cmux workspace(s)`),r.ideRan){let t=e.ideProviders.map(o=>Wo(o)).join(", ");e.ideFoldersAdded>0&&l.info(`\u2705 Added ${e.ideFoldersAdded} folder(s) to ${t} workspace(s)`),e.ideFoldersRemoved>0&&l.info(`\u{1F9F9} Removed ${e.ideFoldersRemoved} dangling folder(s) from ${t} workspace(s)`)}if(e.openedCmux.length>0){l.info("\u2705 Reopened cmux workspaces:");for(let t of e.openedCmux)l.info(t)}!r.ideRan&&e.closedCmux.length===0&&e.openedCmux.length===0&&e.ideFoldersAdded===0&&e.ideFoldersRemoved===0&&l.info("\u2139\uFE0F Nothing to reload")},zo=w({name:"worktrees-reload",description:"Close all open cmux workspaces for the current release worktrees, then reopen the full set \u2014 the single window-restore command. Every configured editor (Cursor and/or Zed) is reconciled + relaunched (no per-window close). Disruptive: closes live cmux windows first. Safe to run from any branch. Use to refresh stale windows or to restore everything after a cold start (editor + cmux closed).",inputSchema:{},outputSchema:{closedCmux:be.array(be.string()).describe("Titles of cmux workspaces a close was attempted for (best-effort)"),openedCmux:be.array(be.string()).describe("Titles of cmux workspaces reopened during this run"),ideProviders:be.array(be.string()).describe("Configured IDE providers that were reloaded (cursor | zed); empty if none configured"),ideFoldersAdded:be.number().describe("Total worktree folders added across all configured editor workspaces"),ideFoldersRemoved:be.number().describe("Total dangling worktree folders removed across all configured editor workspaces")},handler:zs});import hl from"@inquirer/checkbox";import wl from"@inquirer/confirm";import vl from"node:process";import{z as Mr}from"zod";var Gs=async e=>{let{confirmedCommand:r,all:t,versions:o}=e;m.start("worktrees-remove"),await O({operation:"remove worktrees",requiredBranch:"dev"});try{let n=await M("release");if(n.length===0)return l.info("\u2139\uFE0F No active worktrees to remove"),m.print(),{content:g(JSON.stringify({removedWorktrees:[],count:0},null,2)),structuredContent:{removedWorktrees:[],count:0}};let s=await y(),i=`${s}${Z}`,c=[];if(t)c=n;else if(o)c=o.split(",").map(R=>me(oe(R.trim())));else{m.setInteractive();let[R,v]=await Promise.all([E(),C()]),S=new Map(v.map(_=>[_.branch,x(_.title)]));c=await hl({required:!0,message:"\u{1F33F} Select release branches",choices:I({branches:n,descriptions:R,types:S})})}let a=c.length===n.length;a?m.addOption("--all",!0):m.addOption("--versions",De(c));let p=r?!0:await wl({message:"Are you sure you want to proceed with these worktree changes?"});r||m.setInteractive(),p||(l.info("Operation cancelled. Exiting..."),vl.exit(0)),r||m.addOption("--yes",!0);let d=await U(),u=await Pr({branches:c,worktreeDir:i,repoName:d,pruneFolder:a});await Or({projectRoot:s,worktreeDir:i,currentWorktrees:n,removedWorktrees:u,allowEditorRelaunch:!r}),yl(u),m.print();let h={removedWorktrees:u,count:u.length};return{content:g(JSON.stringify(h,null,2)),structuredContent:h}}catch(n){throw Ge(n)?n:(l.error({error:n},"\u274C Error managing worktrees"),new f(n,{operation:"remove worktrees",remediation:"check 'git worktree list' for the path; uncommitted changes block removal"}))}},yl=e=>{if(e.length>0){l.info("\u274C Removed worktrees:");for(let r of e)l.info(r);l.info("")}else l.info("\u2139\uFE0F No unused worktrees to remove")},Go=w({name:"worktrees-remove",description:'Remove local git worktrees for release branches. When everything is removed, also runs "git worktree prune" to clear stale metadata; the worktrees directory and its release/feature subfolders are left in place. 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:Mr.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:Mr.string().optional().describe('Comma-separated release versions or names to target (e.g. "1.2.5, 1.2.6" or "checkout-redesign, 1.2.5"). Either "versions" or all=true must be provided for MCP calls. Overrides "all" when set.')},outputSchema:{removedWorktrees:Mr.array(Mr.string()).describe("List of removed git worktree branches"),count:Mr.number().describe("Number of git worktrees removed")},handler:Gs});import kl from"@inquirer/confirm";import Rl from"node:process";import{z as Ko}from"zod";import{$ as bl}from"zx";var Ks=async e=>{let{confirmedCommand:r}=e;m.start("worktrees-sync"),await O({operation:"sync worktrees",requiredBranch:"dev"});try{let t=await M("release"),o=await y(),n=`${o}${Z}`,s=await tt(),i=r?!0:await kl({message:"Are you sure you want to proceed with these worktree changes?"});r||m.setInteractive(),i||(l.info("Operation cancelled. Exiting..."),Rl.exit(0)),r||m.addOption("--yes",!0);let{branchesToRemove:c}=xl({releasePRsList:s,currentWorktrees:t}),a=await U(),p=await Cl({branches:c,worktreeDir:n,repoName:a});await Or({projectRoot:o,worktreeDir:n,currentWorktrees:t,removedWorktrees:p,allowEditorRelaunch:!1}),Tl(p),m.print();let d={removedWorktrees:p,count:p.length};return{content:g(JSON.stringify(d,null,2)),structuredContent:d}}catch(t){throw Ge(t)?t:(l.error({error:t},"\u274C Error managing worktrees"),new f(t,{operation:"sync worktrees with remote",remediation:"ensure 'gh auth status' is ok and you can reach origin"}))}},xl=e=>{let{releasePRsList:r,currentWorktrees:t}=e;return{branchesToRemove:t.filter(s=>Lr(s)).filter(s=>!r.includes(s))}},Cl=async e=>{let{branches:r,worktreeDir:t,repoName:o}=e,n=[];for(let s of r)try{let i=`${t}/${s}`,c=ne({repoName:o,branch:s});await ze(c),await bl`git worktree remove ${i}`,n.push(s)}catch(i){let c=new f(i,{operation:`remove stale worktree for ${s}`,remediation:"inspect the worktree dir manually; rerun with the branch checked out elsewhere"});l.error({error:i,branch:s,msg:c.message})}return n},Tl=e=>{if(e.length>0){l.info("\u274C Removed worktrees:");for(let r of e)l.info(r);l.info("")}else l.info("\u2139\uFE0F No unused worktrees to remove")},Uo=w({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:Ko.array(Ko.string()).describe("List of removed worktree branches"),count:Ko.number().describe("Number of worktrees removed during sync")},handler:Ks});var qo=[{cliName:"merge-dev",menuGroup:"release",mcpTool:Yt,mcpExposed:!0},{cliName:"release-list",menuGroup:"release",mcpTool:no,mcpExposed:!0},{cliName:"release-create",menuGroup:"release",mcpTool:wo,mcpExposed:!0},{cliName:"release-desc-edit",menuGroup:"release",mcpTool:vo,mcpExposed:!0},{cliName:"release-deploy-all",menuGroup:"release",mcpTool:ro,mcpExposed:!0},{cliName:"release-deploy-selected",menuGroup:"release",mcpTool:oo,mcpExposed:!0},{cliName:"release-deliver",menuGroup:"release",mcpTool:Qt,mcpExposed:!1},{cliName:"worktrees-add",menuGroup:"worktrees",mcpTool:Jo,mcpExposed:!0},{cliName:"worktrees-list",menuGroup:"worktrees",mcpTool:Bo,mcpExposed:!0},{cliName:"worktrees-reload",menuGroup:"worktrees",mcpTool:zo,mcpExposed:!0},{cliName:"worktrees-remove",menuGroup:"worktrees",mcpTool:Go,mcpExposed:!1},{cliName:"worktrees-sync",menuGroup:"worktrees",mcpTool:Uo,mcpExposed:!0},{cliName:"audit",menuGroup:"environment",mcpTool:Pt,mcpExposed:!0},{cliName:"vendor",menuGroup:"environment",mcpTool:null,mcpExposed:!1},{cliName:"vendor-config",menuGroup:"environment",mcpTool:null,mcpExposed:!1},{cliName:"doctor",menuGroup:"environment",mcpTool:Wt,mcpExposed:!1},{cliName:"dev",menuGroup:null,mcpTool:null,mcpExposed:!1},{cliName:"init",menuGroup:"environment",mcpTool:null,mcpExposed:!1},{cliName:"version",menuGroup:"environment",mcpTool:_o,mcpExposed:!0},{cliName:"config",menuGroup:"environment",mcpTool:null,mcpExposed:!1},{cliName:"env-status",menuGroup:"environment",mcpTool:Ut,mcpExposed:!0},{cliName:"env-list",menuGroup:"environment",mcpTool:Kt,mcpExposed:!0},{cliName:"env-load",menuGroup:"environment",mcpTool:Jt,mcpExposed:!0},{cliName:"env-clear",menuGroup:"environment",mcpTool:zt,mcpExposed:!0},{cliName:"env-autoload",menuGroup:null,mcpTool:null,mcpExposed:!1},{cliName:"vendor-check",menuGroup:null,mcpTool:Eo,mcpExposed:!0},{cliName:"vendor-diff",menuGroup:null,mcpTool:So,mcpExposed:!0},{cliName:"vendor-manifest",menuGroup:null,mcpTool:Io,mcpExposed:!1},{cliName:"vendor-sync",menuGroup:null,mcpTool:Ao,mcpExposed:!1}],El=()=>qo.flatMap(e=>e.mcpExposed&&e.mcpTool?[e.mcpTool]:[]),$l=e=>qo.flatMap(r=>r.menuGroup===e?[r.cliName]:[]);export{yn as a,ie as b,k as c,At as d,En as e,qe as f,Sd as g,Wn as h,zn as i,Gn as j,Un as k,qn as l,Hn as m,es as n,ss as o,as as p,ls as q,ps as r,ec as s,ws as t,ys as u,Ts as v,_s as w,Ns as x,Ms as y,Fs as z,ut as A,Js as B,Bs as C,zs as D,Gs as E,Ks as F,El as G,$l as H};
159
+ //# sourceMappingURL=chunk-AP63Y7KE.js.map