infra-kit 0.1.51 → 0.1.53

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/mcp.js CHANGED
@@ -1,18 +1,20 @@
1
- import{config as Me}from"dotenv";import{resolve as Ne}from"node:path";import{$ as L}from"zx";async function ae(){try{L.quiet=!0;let r=(await L`git rev-parse --show-toplevel`).stdout.trim();Me({path:Ne(r,".env")})}catch{}finally{L.quiet=!1}}import{StdioServerTransport as Sr}from"@modelcontextprotocol/sdk/server/stdio.js";import Ie from"node:process";import k from"node:process";import ce from"node:process";import O from"pino";import We from"pino-pretty";var S="/tmp/mcp-infra-kit.log",le=()=>{let e=ce.argv.includes("--debug")?"debug":"info",r=O({level:e},O.destination({dest:S}));return r.info(`Logger initialized with level: ${e}. Logging to: ${S}`),r},Je=()=>{let e=ce.argv.includes("--debug")?"debug":"info",r=["time","pid","hostname"];return e==="debug"&&r.push("level"),O({level:e},We({ignore:r.join(","),colorize:!0}))},t=Je();var me=e=>{k.on("SIGINT",()=>{e.info({msg:"Received SIGINT. Shutting down..."}),k.exit(0)}),k.on("SIGTERM",()=>{e.info({msg:"Received SIGTERM. Shutting down..."}),k.exit(0)}),k.on("uncaughtException",r=>{e.fatal({err:r,msg:"Uncaught Exception"}),e.error(`Uncaught Exception! Check ${S}. Shutting down...`),e.flush(),k.exit(1)}),k.on("unhandledRejection",(r,o)=>{e.fatal({reason:r,promise:o,msg:"Unhandled Rejection"}),e.error(`Unhandled Rejection! Check ${S}. Shutting down...`),e.flush(),k.exit(1)})};import{McpServer as Tr}from"@modelcontextprotocol/sdk/server/mcp.js";var ue=async e=>{};var pe=async e=>{};import Oe from"@inquirer/checkbox";import De from"@inquirer/confirm";import Be from"node:process";import{z as $}from"zod";import{$ as w}from"zx";import{$ as Ur}from"zx";import ge from"node:process";import{$ as Le}from"zx";var D=e=>e.replace("release/","").slice(1).split(".").map(Number),B=e=>[...e].sort((r,o)=>{let[n,s,i]=D(r),[a,c,l]=D(o);return n!==a?(n??0)-(a??0):s!==c?(s??0)-(c??0):(i??0)-(l??0)});var p=async()=>{try{let e=await Le`gh pr list --search "Release in:title" --base dev --json number,title,headRefName,state,baseRefName`,r=JSON.parse(e.stdout);r.length===0&&(t.error("\u274C No release PRs found. Check the project folder for the script. Exiting..."),ge.exit(1));let o=r.map(n=>n.headRefName);return B(o)}catch(e){t.error({error:e},"\u274C Error fetching release PRs"),ge.exit(1)}};var fe=async e=>{let{all:r,confirmedCommand:o}=e,n=await p(),s=[];r?s=n:s=await Oe({required:!0,message:"\u{1F33F} Select release branches",choices:n.map(l=>({name:l.replace("release/v",""),value:l}))}),o||await De({message:`Are you sure you want to merge dev into these branches: ${s.join(", ")}?`})||(t.info("Operation cancelled. Exiting..."),Be.exit(0)),w.quiet=!0,await w`git fetch origin`,await w`git switch dev`,await w`git pull origin dev`;let a=[];for(let l of s)await _e(l)||a.push(l);if(w.quiet=!1,a.length>0){t.info(`
2
- \u26A0\uFE0F ${a.length} branch(es) failed to merge automatically.
1
+ import{StdioServerTransport as Jr}from"@modelcontextprotocol/sdk/server/stdio.js";import je from"node:process";import k from"node:process";import le from"node:process";import L from"pino";import Ne from"pino-pretty";var E="/tmp/mcp-infra-kit.log",me=()=>{let e=le.argv.includes("--debug")?"debug":"info",r=L({level:e},L.destination({dest:E}));return r.info(`Logger initialized with level: ${e}. Logging to: ${E}`),r},We=()=>{let e=le.argv.includes("--debug")?"debug":"info",r=["time","pid","hostname"];return e==="debug"&&r.push("level"),L({level:e},Ne({ignore:r.join(","),colorize:!0}))},t=We();var ue=e=>{k.on("SIGINT",()=>{e.info({msg:"Received SIGINT. Shutting down..."}),k.exit(0)}),k.on("SIGTERM",()=>{e.info({msg:"Received SIGTERM. Shutting down..."}),k.exit(0)}),k.on("uncaughtException",r=>{e.fatal({err:r,msg:"Uncaught Exception"}),e.error(`Uncaught Exception! Check ${E}. Shutting down...`),e.flush(),k.exit(1)}),k.on("unhandledRejection",(r,o)=>{e.fatal({reason:r,promise:o,msg:"Unhandled Rejection"}),e.error(`Unhandled Rejection! Check ${E}. Shutting down...`),e.flush(),k.exit(1)})};import{config as Le}from"dotenv";import{resolve as De}from"node:path";import{$ as D}from"zx";async function pe(){try{D.quiet=!0;let r=(await D`git rev-parse --show-toplevel`).stdout.trim();Le({path:De(r,".env")})}catch{}finally{D.quiet=!1}}import{McpServer as Ar}from"@modelcontextprotocol/sdk/server/mcp.js";var ge=async e=>{};var fe=async e=>{};import Be from"@inquirer/checkbox";import _e from"@inquirer/confirm";import Ve from"node:process";import{z as $}from"zod";import{$ as h}from"zx";import{$ as Gr}from"zx";import de from"node:process";import{$ as y}from"zx";var O=e=>e.replace("release/","").slice(1).split(".").map(Number),B=e=>[...e].sort((r,o)=>{let[n,s,i]=O(r),[c,a,l]=O(o);return n!==c?(n??0)-(c??0):s!==a?(s??0)-(a??0):(i??0)-(l??0)});var g=async()=>{try{let e=await y`gh pr list --search "Release in:title" --base dev --json number,title,headRefName,state,baseRefName`,r=JSON.parse(e.stdout);r.length===0&&(t.error("\u274C No release PRs found. Check the project folder for the script. Exiting..."),de.exit(1));let o=r.map(n=>n.headRefName);return B(o)}catch(e){t.error({error:e},"\u274C Error fetching release PRs"),de.exit(1)}},J=async e=>{let r=`release/v${e}`;try{await y`git switch dev`,await y`git pull origin dev`,await y`git checkout -b ${r}`,await y`git push -u origin ${r}`,await y`git commit --allow-empty-message --allow-empty --message ''`,await y`git push origin ${r}`;let n=(await y`gh pr create --title "Release v${e}" --body "Release v${e}" --base dev --head ${r}`).stdout.trim();return await y`git switch dev`,{branchName:r,prUrl:n}}catch(o){throw t.error({error:o,branchName:r},`Error creating release branch ${r}`),o}};var he=async e=>{let{all:r,confirmedCommand:o}=e,n=await g(),s=[];r?s=n:s=await Be({required:!0,message:"\u{1F33F} Select release branches",choices:n.map(l=>({name:l.replace("release/v",""),value:l}))}),o||await _e({message:`Are you sure you want to merge dev into these branches: ${s.join(", ")}?`})||(t.info("Operation cancelled. Exiting..."),Ve.exit(0)),h.quiet=!0,await h`git fetch origin`,await h`git switch dev`,await h`git pull origin dev`;let c=[];for(let l of s)await Ue(l)||c.push(l);if(h.quiet=!1,c.length>0){t.info(`
2
+ \u26A0\uFE0F ${c.length} branch(es) failed to merge automatically.
3
3
  `),t.info(`\u{1F4CB} Manual merge script for failed branches:
4
- `),t.info("```bash");for(let l of a)t.info(`# Phase #1: Merge dev into ${l}`),t.info(`git switch ${l} && git pull origin ${l} && git merge origin/dev`),t.info("# Phase #2:Resolve conflicts if any, then:"),t.info(`git push origin ${l} && git switch dev`);t.info(`\u2705 ${s.length-a.length}/${s.length} merges completed successfully.`)}else t.info("\u2705 All merges completed successfully!");let c={successfulMerges:s.length-a.length,failedMerges:a.length,failedBranches:a,totalBranches:s.length};return{content:[{type:"text",text:JSON.stringify(c,null,2)}],structuredContent:c}},_e=async e=>{try{return await w`git switch ${e}`,await w`git pull origin ${e}`,await w`git merge origin/dev --no-edit`,await w`git push origin ${e}`,await w`git switch dev`,t.info(`Successfully merged dev into ${e}`),!0}catch(r){return t.error({error:r,branch:e},`Error merging dev into ${e}`),await w`git reset --merge HEAD~1`,!1}},_={name:"gh-merge-dev",description:"Merge dev branch into selected release branches",inputSchema:{all:$.boolean().describe("Merge dev into all release branches without prompting")},outputSchema:{successfulMerges:$.number().describe("Number of successful merges"),failedMerges:$.number().describe("Number of failed merges"),failedBranches:$.array($.string()).describe("List of branches that failed to merge"),totalBranches:$.number().describe("Total number of branches processed")},handler:fe};import de from"@inquirer/confirm";import I from"node:process";import{z as h}from"zod";import{$ as g,question as qe}from"zx";import P from"node:process";async function q(e,r){try{let{baseUrl:o,token:n,projectId:s}=r,i=e.releaseDate||new Date().toISOString().split("T")[0],a={name:e.name,projectId:e.projectId||s,description:e.description||`Release version ${e.name}`,releaseDate:i,released:e.released??!0,archived:e.archived??!1};t.info({version:e.name,projectId:a.projectId},"Creating Jira version");let c=`${o}/rest/api/3/version`,l=await fetch(c,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify(a)});if(!l.ok){let f=await l.text();return t.error({status:l.status,statusText:l.statusText,error:f},"Failed to create Jira version"),{success:!1,error:`HTTP ${l.status}: ${l.statusText}`}}let m=await l.json();return t.info({versionId:m.id,versionName:m.name},"Successfully created Jira version"),{success:!0,version:m}}catch(o){return t.error({error:o},"Error creating Jira version"),{success:!1,error:o instanceof Error?o.message:String(o)}}}function U(){let e=P.env.JIRA_BASE_URL,r=P.env.JIRA_TOKEN||P.env.JIRA_API_TOKEN,o=P.env.JIRA_PROJECT_ID,n=P.env.JIRA_EMAIL;if(!e||!r||!o)return t.debug({hasBaseUrl:!!e,hasToken:!!r,hasProjectId:!!o},"Jira configuration incomplete, skipping Jira integration"),null;let s=Number.parseInt(o,10);return Number.isNaN(s)?(t.warn({projectIdStr:o},"Invalid JIRA_PROJECT_ID (must be numeric), skipping Jira integration"),null):{baseUrl:e.replace(/\/$/,""),token:r,projectId:s,email:n}}var he=async e=>{let{versions:r,confirmedCommand:o,checkout:n}=e,s="",i=n,a=U();a||(t.error("Jira configuration is required but not found."),t.error("Please configure the following environment variables in your .env file:"),t.error(" - JIRA_BASE_URL (e.g., https://your-domain.atlassian.net)"),t.error(" - JIRA_TOKEN (your Jira API token)"),t.error(" - JIRA_PROJECT_ID (numeric project ID)"),I.exit(1)),t.info("Jira integration enabled - versions will be created in Jira"),r?s=r:s=await qe("Enter versions by comma (e.g. 1.2.5, 1.2.6): ");let c=s.split(",").map(u=>u.trim());c.length===0&&(t.error("No versions provided. Exiting..."),I.exit(1)),i&&c.length>1&&t.warn("\u26A0\uFE0F Checkout option is ignored when creating multiple branches. Only works with single branch creation."),c.length===1&&!i&&(i=await de({message:"Checkout to the created branch?"})),o||await de({message:`Are you sure you want to create release branches for these versions: ${c.join(", ")}?`})||(t.info("Operation cancelled. Exiting..."),I.exit(0)),g.quiet=!0,await g`git fetch origin`,await g`git switch dev`,await g`git pull origin dev`;let m=[];for(let u of c){let J=await Ue(u),j=`v${u}`,A=await q({name:j,projectId:a.projectId,description:"",released:!1,archived:!1},a);if(A.success){let ne=A.version.project,ie=ne?`${a.baseUrl}/projects/${ne}/versions/${A.version.id}/tab/release-report-all-issues`:"";m.push({version:u,branchName:J.branchName,prUrl:J.prUrl,jiraVersionUrl:ie}),t.info(`Successfully created release: ${j}`),t.info(` GitHub PR: ${J.prUrl}`),t.info(` Jira Version: ${ie}`)}else t.error(`\u2717 Failed to create Jira version for ${j}: ${A.error}`),t.error("Jira version creation is mandatory. Exiting..."),I.exit(1)}let f=i&&c.length===1;if(f){let u=`release/v${c[0]}`;await g`git switch ${u}`,t.info(`\u{1F504} Switched to branch ${u}`)}t.info(`${c.length} release branches were created successfully.`),g.quiet=!1;let b={createdBranches:c.map(u=>`release/v${u}`),branchCount:c.length,isCheckedOut:f,releases:m};return{content:[{type:"text",text:JSON.stringify(b,null,2)}],structuredContent:b}};async function Ue(e){let r=`release/v${e}`;try{await g`git switch dev`,await g`git pull origin dev`,await g`git checkout -b ${r}`,await g`git push -u origin ${r}`,await g`git commit --allow-empty-message --allow-empty --message ''`,await g`git push origin ${r}`;let o=await g`gh pr create --title "Release v${e}" --body "Release v${e}" --base dev --head ${r} --json url`,n=JSON.parse(o.stdout);return await g`git switch dev`,{branchName:r,prUrl:n.url}}catch(o){throw t.error({error:o,branchName:r},`Error creating release branch ${r}`),o}}var F={name:"gh-release-create",description:"Create new release branches for specified versions and optionally create Jira versions",inputSchema:{versions:h.string().describe('Comma-separated list of versions to create (e.g., "1.2.5, 1.2.6")'),checkout:h.boolean().optional().describe("Checkout to the created branch (only works with single version)")},outputSchema:{createdBranches:h.array(h.string()).describe("List of created release branches"),branchCount:h.number().describe("Number of branches created"),isCheckedOut:h.boolean().describe("Whether the branch was checked out"),releases:h.array(h.object({version:h.string().describe("Version number"),branchName:h.string().describe("Release branch name"),prUrl:h.string().describe("GitHub PR URL"),jiraVersionUrl:h.string().describe("Jira version URL")})).describe("Detailed information for each created release with URLs only")},handler:he};import Fe from"@inquirer/confirm";import ze from"@inquirer/select";import z from"node:process";import{z as M}from"zod";import{$ as y}from"zx";var we=async e=>{let{version:r,confirmedCommand:o}=e,n=await p(),s="";r?s=`release/v${r}`:s=await ze({message:"\u{1F33F} Select release branch",choices:n.map(a=>({name:a.replace("release/v",""),value:a}))}),n.includes(s)||(t.error(`\u274C Release branch ${s} not found in open PRs. Exiting...`),z.exit(1)),o||await Fe({message:`Are you sure you want to deliver version ${s} to production?`})||(t.info("Operation cancelled. Exiting..."),z.exit(0));try{y.quiet=!0,await y`gh pr merge ${s} --squash --admin --delete-branch`,await y`gh pr create --base main --head dev --title "Release v${s.replace("release/v","")} (RC)" --body ""`,await y`gh pr merge dev --squash --admin`,y.quiet=!1,await y`gh workflow run deploy-all.yml --ref main -f environment=prod`,y.quiet=!0,await y`git switch main && git pull && git switch dev && git pull && git merge main --no-edit && git push`,y.quiet=!1,t.info(`Successfully delivered ${s} to production!`);let a={releaseBranch:s,version:s.replace("release/v",""),success:!0};return{content:[{type:"text",text:JSON.stringify(a,null,2)}],structuredContent:a}}catch(a){t.error({error:a},"\u274C Error merging release branch into dev"),z.exit(1)}},G={name:"gh-release-deliver",description:"Deliver a release branch to production",inputSchema:{version:M.string().describe('Version to deliver to production (e.g., "1.2.5")')},outputSchema:{releaseBranch:M.string().describe("The release branch that was delivered"),version:M.string().describe("The version that was delivered"),success:M.boolean().describe("Whether the delivery was successful")},handler:we};import ve from"@inquirer/select";import H from"node:process";import{z as T}from"zod";import{$ as K}from"zx";var V=["dev","arthur","renana","roman","eliran","oriana"],C="-worktrees";var ye=async e=>{let{version:r,env:o}=e,n=["dev"],s=await p();n.push(...s);let i="";r?i=`release/v${r}`:i=await ve({message:"\u{1F33F} Select release branch",choices:n.map(c=>({name:c.replace("release/v",""),value:c}))}),n.includes(i)||(t.error(`\u274C Release branch ${i} not found in open PRs. Exiting...`),H.exit(1));let a="";o?a=o:a=await ve({message:"\u{1F9EA} Select environment",choices:V.map(c=>({name:c,value:c}))}),V.includes(a)||(t.error(`\u274C Invalid environment: ${a}. Exiting...`),H.exit(1));try{K.quiet=!0,await K`gh workflow run deploy-all.yml --ref ${i} -f environment=${a}`,K.quiet=!1,t.info(`Successfully launched deploy-all workflow_dispatch for release branch: ${i} and environment: ${a}`);let c={releaseBranch:i,version:i.replace("release/v",""),environment:a,success:!0};return{content:[{type:"text",text:JSON.stringify(c,null,2)}],structuredContent:c}}catch(c){t.error({error:c},"\u274C Error launching workflow"),H.exit(1)}},X={name:"gh-release-deploy",description:"Deploy a release branch to a specified environment",inputSchema:{version:T.string().describe('Version to deploy (e.g., "1.2.5")'),env:T.string().describe('Environment to deploy to (e.g., "dev", "renana", "oriana")')},outputSchema:{releaseBranch:T.string().describe("The release branch that was deployed"),version:T.string().describe("The version that was deployed"),environment:T.string().describe("The environment deployed to"),success:T.boolean().describe("Whether the deployment was successful")},handler:ye};import{z as Q}from"zod";var Re=async()=>{let r=(await p()).map(n=>n.replace("release/",""));t.info(`All release branches:
4
+ `),t.info("```bash");for(let l of c)t.info(`# Phase #1: Merge dev into ${l}`),t.info(`git switch ${l} && git pull origin ${l} && git merge origin/dev`),t.info("# Phase #2:Resolve conflicts if any, then:"),t.info(`git push origin ${l} && git switch dev`);t.info(`\u2705 ${s.length-c.length}/${s.length} merges completed successfully.`)}else t.info("\u2705 All merges completed successfully!");let a={successfulMerges:s.length-c.length,failedMerges:c.length,failedBranches:c,totalBranches:s.length};return{content:[{type:"text",text:JSON.stringify(a,null,2)}],structuredContent:a}},Ue=async e=>{try{return await h`git switch ${e}`,await h`git pull origin ${e}`,await h`git merge origin/dev --no-edit`,await h`git push origin ${e}`,await h`git switch dev`,t.info(`Successfully merged dev into ${e}`),!0}catch(r){return t.error({error:r,branch:e},`Error merging dev into ${e}`),await h`git reset --merge HEAD~1`,!1}},_={name:"gh-merge-dev",description:"Merge dev branch into selected release branches",inputSchema:{all:$.boolean().describe("Merge dev into all release branches without prompting")},outputSchema:{successfulMerges:$.number().describe("Number of successful merges"),failedMerges:$.number().describe("Number of failed merges"),failedBranches:$.array($.string()).describe("List of branches that failed to merge"),totalBranches:$.number().describe("Total number of branches processed")},handler:he};import we from"@inquirer/confirm";import ve from"node:process";import{z as d}from"zod";import{$ as C,question as Ge}from"zx";import S from"node:process";var V=async(e,r)=>{try{let{baseUrl:o,token:n,email:s,projectId:i}=r,c={name:e.name,projectId:e.projectId||i,description:e.description||"",released:e.released??!0,archived:e.archived??!1},a=`${o}/rest/api/3/version`,l=btoa(`${s}:${n}`),m=await fetch(a,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json",Authorization:`Basic ${l}`},body:JSON.stringify(c)});if(!m.ok){let w=await m.text();throw t.error({status:m.status,statusText:m.statusText,error:w},"Failed to create Jira version"),new Error(`HTTP ${m.status}: ${m.statusText}`)}return{success:!0,version:await m.json()}}catch(o){throw t.error({error:o},"Error creating Jira version"),o}},qe=async e=>{try{let{baseUrl:r,token:o,email:n,projectId:s}=e,i=`${r}/rest/api/3/project/${s}/versions`,c=btoa(`${n}:${o}`),a=await fetch(i,{method:"GET",headers:{Accept:"application/json",Authorization:`Basic ${c}`}});if(!a.ok){let m=await a.text();throw t.error({status:a.status,statusText:a.statusText,error:m},"Failed to get Jira project versions"),new Error(`HTTP ${a.status}: ${a.statusText}`)}return await a.json()}catch(r){throw t.error({error:r},"Error getting Jira project versions"),r}},Fe=async(e,r)=>{try{return(await qe(r)).find(s=>s.name===e)||null}catch(o){throw t.error({error:o,versionName:e},"Error finding Jira version by name"),o}},ze=async(e,r)=>{try{let{baseUrl:o,token:n,email:s}=r,i={released:e.released??!0,archived:e.archived??!1};e.releaseDate?i.releaseDate=e.releaseDate:e.released!==!1&&(i.releaseDate=new Date().toISOString().split("T")[0]),e.description!==void 0&&(i.description=e.description);let c=`${o}/rest/api/3/version/${e.versionId}`,a=btoa(`${s}:${n}`),l=await fetch(c,{method:"PUT",headers:{Accept:"application/json","Content-Type":"application/json",Authorization:`Basic ${a}`},body:JSON.stringify(i)});if(!l.ok){let p=await l.text();throw t.error({status:l.status,statusText:l.statusText,error:p},"Failed to update Jira version"),new Error(`HTTP ${l.status}: ${l.statusText}`)}return{success:!0,version:await l.json()}}catch(o){throw t.error({error:o},"Error updating Jira version"),o}},U=async(e,r)=>{try{let{versionName:o}=e,n=await Fe(o,r);if(!n)throw t.error({versionName:o},"Jira version not found"),new Error(`Version "${o}" not found in Jira project`);return await ze({versionId:n.id,released:!0,releaseDate:new Date().toISOString().split("T")[0]},r)}catch(o){throw t.error({error:o},"Error delivering Jira release"),o}},I=async()=>{let e=S.env.JIRA_BASE_URL,r=S.env.JIRA_TOKEN||S.env.JIRA_API_TOKEN,o=S.env.JIRA_PROJECT_ID,n=S.env.JIRA_EMAIL,s=[];if(e||s.push("JIRA_BASE_URL (e.g., https://your-domain.atlassian.net)"),r||s.push("JIRA_TOKEN or JIRA_API_TOKEN (your Jira API token)"),o||s.push("JIRA_PROJECT_ID (numeric project ID)"),n||s.push("JIRA_EMAIL (your Jira email address)"),s.length>0){let c=["Jira configuration is required but incomplete.","Please configure the following environment variables:",...s.map(a=>` - ${a}`),"","You can set these in your .env file or as environment variables."].join(`
5
+ `);throw new Error(c)}let i=Number.parseInt(o,10);if(Number.isNaN(i))throw new TypeError(`Invalid JIRA_PROJECT_ID: "${o}" must be a numeric value (e.g., 10001)`);return{baseUrl:e.replace(/\/$/,""),token:r,projectId:i,email:n}},q=async()=>{try{return await I()}catch(e){return t.warn({error:e},"Jira configuration not available, skipping Jira integration"),null}};var ye=async e=>{let{versions:r,confirmedCommand:o,checkout:n}=e,s="",i=n,c=await I();r?s=r:s=await Ge("Enter versions by comma (e.g. 1.2.5, 1.2.6): ");let a=s.split(",").map(u=>u.trim());a.length===0&&(t.error("No versions provided. Exiting..."),ve.exit(1)),i&&a.length>1&&t.warn("\u26A0\uFE0F Checkout option is ignored when creating multiple branches. Only works with single branch creation."),a.length===1&&!i&&(i=await we({message:"Checkout to the created branch?"})),o||await we({message:`Are you sure you want to create release branches for these versions: ${a.join(", ")}?`})||(t.info("Operation cancelled. Exiting..."),ve.exit(0)),C.quiet=!0,await C`git fetch origin`,await C`git switch dev`,await C`git pull origin dev`;let m=[];for(let u of a){let ie=`v${u}`,ae=await V({name:ie,projectId:c.projectId,description:"",released:!1,archived:!1},c),W=await J(u),ce=`${c.baseUrl}/projects/${ae.version.projectId}/versions/${ae.version.id}/tab/release-report-all-issues`;m.push({version:u,branchName:W.branchName,prUrl:W.prUrl,jiraVersionUrl:ce}),t.info(`\u2705 Successfully created release: ${ie}`),t.info(`\u{1F517} GitHub PR: ${W.prUrl}`),t.info(`\u{1F517} Jira Version: ${ce}
6
+ `)}let p=i&&a.length===1;if(p){let u=`release/v${a[0]}`;await C`git switch ${u}`,t.info(`\u{1F504} Switched to branch ${u}`)}t.info(`${a.length} release branches were created successfully.`),C.quiet=!1;let w={createdBranches:a.map(u=>`release/v${u}`),branchCount:a.length,isCheckedOut:p,releases:m};return{content:[{type:"text",text:JSON.stringify(w,null,2)}],structuredContent:w}},F={name:"gh-release-create",description:"Create new release branches for specified versions and optionally create Jira versions",inputSchema:{versions:d.string().describe('Comma-separated list of versions to create (e.g., "1.2.5, 1.2.6")'),checkout:d.boolean().optional().describe("Checkout to the created branch (only works with single version)")},outputSchema:{createdBranches:d.array(d.string()).describe("List of created release branches"),branchCount:d.number().describe("Number of branches created"),isCheckedOut:d.boolean().describe("Whether the branch was checked out"),releases:d.array(d.object({version:d.string().describe("Version number"),branchName:d.string().describe("Release branch name"),prUrl:d.string().describe("GitHub PR URL"),jiraVersionUrl:d.string().describe("Jira version URL")})).describe("Detailed information for each created release with URLs only")},handler:ye};import He from"@inquirer/confirm";import Ke from"@inquirer/select";import z from"node:process";import{z as M}from"zod";import{$ as R}from"zx";var Re=async e=>{let{version:r,confirmedCommand:o}=e,n=await g(),s="";r?s=`release/v${r}`:s=await Ke({message:"\u{1F33F} Select release branch",choices:n.map(c=>({name:c.replace("release/v",""),value:c}))}),n.includes(s)||(t.error(`\u274C Release branch ${s} not found in open PRs. Exiting...`),z.exit(1)),o||await He({message:`Are you sure you want to deliver version ${s} to production?`})||(t.info("Operation cancelled. Exiting..."),z.exit(0));try{R.quiet=!0,await R`gh pr merge ${s} --squash --admin --delete-branch`,await R`gh pr create --base main --head dev --title "Release v${s.replace("release/v","")} (RC)" --body ""`,await R`gh pr merge dev --squash --admin`,R.quiet=!1,await R`gh workflow run deploy-all.yml --ref main -f environment=prod`,R.quiet=!0,await R`git switch main && git pull && git switch dev && git pull && git merge main --no-edit && git push`,R.quiet=!1;let c=await q();if(c)try{let l=s.replace("release/","");await U({versionName:l},c)}catch(l){t.error({error:l},"Failed to deliver Jira release (non-blocking)")}else t.info("\u{1F514} Jira is not configured, skipping Jira release delivery");t.info(`Successfully delivered ${s} to production!`);let a={releaseBranch:s,version:s.replace("release/v",""),success:!0};return{content:[{type:"text",text:JSON.stringify(a,null,2)}],structuredContent:a}}catch(c){t.error({error:c},"\u274C Error merging release branch into dev"),z.exit(1)}},G={name:"gh-release-deliver",description:"Deliver a release branch to production",inputSchema:{version:M.string().describe('Version to deliver to production (e.g., "1.2.5")')},outputSchema:{releaseBranch:M.string().describe("The release branch that was delivered"),version:M.string().describe("The version that was delivered"),success:M.boolean().describe("Whether the delivery was successful")},handler:Re};import be from"@inquirer/select";import K from"node:process";import{z as P}from"zod";import{$ as X}from"zx";var H=["dev","arthur","renana","roman","eliran","oriana"],T="-worktrees";var ke=async e=>{let{version:r,env:o}=e,n=["dev"],s=await g();n.push(...s);let i="";r?i=`release/v${r}`:i=await be({message:"\u{1F33F} Select release branch",choices:n.map(a=>({name:a.replace("release/v",""),value:a}))}),n.includes(i)||(t.error(`\u274C Release branch ${i} not found in open PRs. Exiting...`),K.exit(1));let c="";o?c=o:c=await be({message:"\u{1F9EA} Select environment",choices:H.map(a=>({name:a,value:a}))}),H.includes(c)||(t.error(`\u274C Invalid environment: ${c}. Exiting...`),K.exit(1));try{X.quiet=!0,await X`gh workflow run deploy-all.yml --ref ${i} -f environment=${c}`,X.quiet=!1,t.info(`Successfully launched deploy-all workflow_dispatch for release branch: ${i} and environment: ${c}`);let a={releaseBranch:i,version:i.replace("release/v",""),environment:c,success:!0};return{content:[{type:"text",text:JSON.stringify(a,null,2)}],structuredContent:a}}catch(a){t.error({error:a},"\u274C Error launching workflow"),K.exit(1)}},Y={name:"gh-release-deploy",description:"Deploy a release branch to a specified environment",inputSchema:{version:P.string().describe('Version to deploy (e.g., "1.2.5")'),env:P.string().describe('Environment to deploy to (e.g., "dev", "renana", "oriana")')},outputSchema:{releaseBranch:P.string().describe("The release branch that was deployed"),version:P.string().describe("The version that was deployed"),environment:P.string().describe("The environment deployed to"),success:P.boolean().describe("Whether the deployment was successful")},handler:ke};import{z as Q}from"zod";var xe=async()=>{let r=(await g()).map(n=>n.replace("release/",""));t.info(`All release branches:
5
7
  `),t.info(`
6
8
  ${r.join(`
7
- `)}`);let o={releases:r,count:r.length};return{content:[{type:"text",text:JSON.stringify(o,null,2)}],structuredContent:o}},Y={name:"gh-release-list",description:"List all open release branches",inputSchema:{},outputSchema:{releases:Q.array(Q.string()).describe("List of all release branches"),count:Q.number().describe("Number of release branches")},handler:Re};import He from"@inquirer/checkbox";import Ke from"@inquirer/confirm";import Xe from"node:process";import{z as N}from"zod";import{$ as xe}from"zx";import{$ as be}from"zx";var v=async e=>{let o=(await be`git worktree list`).stdout.split(`
8
- `).filter(Boolean),n={release:Ge,feature:Ve};return o.map(n[e]).filter(s=>s!==null)},Ge=e=>{let r=e.split(" ").filter(Boolean);return r.length<3||!r[0]?.includes("release/v")?null:`release/${r[0]?.split("/").pop()||""}`},Ve=e=>{let r=e.split(" ").filter(Boolean);return r.length<3||!r[0]?.includes("feature/")?null:`feature/${r[0]?.split("/").pop()||""}`},R=async()=>(await be`git rev-parse --show-toplevel`).stdout.trim();var Qe="feature",Ye="release",Ze="release/v",$e=async e=>{let{confirmedCommand:r,all:o}=e;try{let n=await v("release"),i=`${await R()}${C}`;await ke(`${i}/${Ye}`),await ke(`${i}/${Qe}`);let a=await p(),c=[];o?c=a:c=await He({required:!0,message:"\u{1F33F} Select release branches",choices:a.map(u=>({name:u.replace("release/v",""),value:u}))}),r||await Ke({message:"Are you sure you want to proceed with these worktree changes?"})||(t.info("Operation cancelled. Exiting..."),Xe.exit(0));let{branchesToCreate:m}=er({selectedReleaseBranches:c,currentWorktrees:n}),f=await rr(m,i);tr(f);let b={createdWorktrees:f,count:f.length};return{content:[{type:"text",text:JSON.stringify(b,null,2)}],structuredContent:b}}catch(n){throw t.error({error:n},"\u274C Error managing worktrees"),n}},ke=async e=>{await xe`mkdir -p ${e}`},er=e=>{let{selectedReleaseBranches:r,currentWorktrees:o}=e,n=o.filter(i=>i.startsWith(Ze));return{branchesToCreate:r.filter(i=>!n.includes(i))}},rr=async(e,r)=>{let o=[];for(let n of e)try{let s=`${r}/${n}`;await xe`git worktree add ${s} ${n}`,o.push(n)}catch(s){t.error({error:s,branch:n},`\u274C Failed to create worktree for ${n}`)}return o},tr=e=>{e.length>0?(t.info(`
9
+ `)}`);let o={releases:r,count:r.length};return{content:[{type:"text",text:JSON.stringify(o,null,2)}],structuredContent:o}},Z={name:"gh-release-list",description:"List all open release branches",inputSchema:{},outputSchema:{releases:Q.array(Q.string()).describe("List of all release branches"),count:Q.number().describe("Number of release branches")},handler:xe};import Qe from"@inquirer/checkbox";import Ze from"@inquirer/confirm";import er from"node:process";import{z as j}from"zod";import{$ as Te}from"zx";import{$ as $e}from"zx";var v=async e=>{let o=(await $e`git worktree list`).stdout.split(`
10
+ `).filter(Boolean),n={release:Xe,feature:Ye};return o.map(n[e]).filter(s=>s!==null)},Xe=e=>{let r=e.split(" ").filter(Boolean);return r.length<3||!r[0]?.includes("release/v")?null:`release/${r[0]?.split("/").pop()||""}`},Ye=e=>{let r=e.split(" ").filter(Boolean);return r.length<3||!r[0]?.includes("feature/")?null:`feature/${r[0]?.split("/").pop()||""}`},b=async()=>(await $e`git rev-parse --show-toplevel`).stdout.trim();var rr="feature",tr="release",or="release/v",Pe=async e=>{let{confirmedCommand:r,all:o}=e;try{let n=await v("release"),i=`${await b()}${T}`;await Ce(`${i}/${tr}`),await Ce(`${i}/${rr}`);let c=await g(),a=[];o?a=c:a=await Qe({required:!0,message:"\u{1F33F} Select release branches",choices:c.map(u=>({name:u.replace("release/v",""),value:u}))}),r||await Ze({message:"Are you sure you want to proceed with these worktree changes?"})||(t.info("Operation cancelled. Exiting..."),er.exit(0));let{branchesToCreate:m}=sr({selectedReleaseBranches:a,currentWorktrees:n}),p=await nr(m,i);ir(p);let w={createdWorktrees:p,count:p.length};return{content:[{type:"text",text:JSON.stringify(w,null,2)}],structuredContent:w}}catch(n){throw t.error({error:n},"\u274C Error managing worktrees"),n}},Ce=async e=>{await Te`mkdir -p ${e}`},sr=e=>{let{selectedReleaseBranches:r,currentWorktrees:o}=e,n=o.filter(i=>i.startsWith(or));return{branchesToCreate:r.filter(i=>!n.includes(i))}},nr=async(e,r)=>{let o=[];for(let n of e)try{let s=`${r}/${n}`;await Te`git worktree add ${s} ${n}`,o.push(n)}catch(s){t.error({error:s,branch:n},`\u274C Failed to create worktree for ${n}`)}return o},ir=e=>{e.length>0?(t.info(`
9
11
  `),t.info("\u2705 Created worktrees:"),t.info(e.join(`
10
- `)),t.info("")):t.info("\u2139\uFE0F No new worktrees to create")},Z={name:"worktrees-add",description:"Create worktrees for selected release branches",inputSchema:{all:N.boolean().describe("Add worktrees for all release branches without prompting")},outputSchema:{createdWorktrees:N.array(N.string()).describe("List of created worktree branches"),count:N.number().describe("Number of worktrees created")},handler:$e};import{z as d}from"zod";import{$ as E}from"zx";var Te=async()=>{try{let[e,r]=await Promise.all([v("release"),v("feature")]),o=await R(),n=await or(e,r,o);lr(n);let s={worktrees:n,totalCount:n.length,releaseCount:e.length,featureCount:r.length};return{content:[{type:"text",text:JSON.stringify(s,null,2)}],structuredContent:s}}catch(e){throw t.error({error:e},"\u274C Error listing worktrees"),e}},or=async(e,r,o)=>{let n=[...e.map(i=>({branch:i,type:"release"})),...r.map(i=>({branch:i,type:"feature"}))],s=[];for(let{branch:i,type:a}of n)try{let c=`${o}/${i}`,l=await sr(i),m=await nr(c),f=await ir(c),b=await ar(c),u=await cr(c);s.push({branch:i,path:c,commit:m.substring(0,8),isCurrent:l,type:a,status:f,lastCommitMessage:b.substring(0,60)+(b.length>60?"...":""),aheadBehind:u})}catch(c){t.warn({error:c,branch:i},`\u26A0\uFE0F Could not process worktree ${i}`)}return s.sort((i,a)=>i.type!==a.type?i.type==="release"?-1:1:i.branch.localeCompare(a.branch))},sr=async e=>{try{return(await E`git branch --show-current`).stdout.trim()===e}catch{return!1}},nr=async e=>{try{return(await E`cd ${e} && git rev-parse HEAD`).stdout.trim()}catch{return"unknown"}},ir=async e=>{try{let o=(await E`cd ${e} && git status --porcelain`).stdout.trim().split(`
11
- `).filter(Boolean);return o.length===0?"clean":o.length<=3?"modified":"dirty"}catch{return"unknown"}},ar=async e=>{try{return(await E`cd ${e} && git log -1 --pretty=format:"%s"`).stdout.trim()}catch{return"No commit message available"}},cr=async e=>{try{let o=(await E`cd ${e} && git rev-list --count --left-right @{u}...HEAD 2>/dev/null || echo "0 0"`).stdout.trim().split(" ").map(Number),n=o[0]||0,s=o[1]||0;return s===0&&n===0?"up to date":s>0&&n===0?`\u2191${s} ahead`:n>0&&s===0?`\u2193${n} behind`:`\u2191${s} \u2193${n}`}catch{return"unknown"}},lr=e=>{if(e.length===0){t.info(`
12
+ `)),t.info("")):t.info("\u2139\uFE0F No new worktrees to create")},ee={name:"worktrees-add",description:"Create worktrees for selected release branches",inputSchema:{all:j.boolean().describe("Add worktrees for all release branches without prompting")},outputSchema:{createdWorktrees:j.array(j.string()).describe("List of created worktree branches"),count:j.number().describe("Number of worktrees created")},handler:Pe};import{z as f}from"zod";import{$ as A}from"zx";var Se=async()=>{try{let[e,r]=await Promise.all([v("release"),v("feature")]),o=await b(),n=await ar(e,r,o);gr(n);let s={worktrees:n,totalCount:n.length,releaseCount:e.length,featureCount:r.length};return{content:[{type:"text",text:JSON.stringify(s,null,2)}],structuredContent:s}}catch(e){throw t.error({error:e},"\u274C Error listing worktrees"),e}},ar=async(e,r,o)=>{let n=[...e.map(i=>({branch:i,type:"release"})),...r.map(i=>({branch:i,type:"feature"}))],s=[];for(let{branch:i,type:c}of n)try{let a=`${o}/${i}`,l=await cr(i),m=await lr(a),p=await mr(a),w=await ur(a),u=await pr(a);s.push({branch:i,path:a,commit:m.substring(0,8),isCurrent:l,type:c,status:p,lastCommitMessage:w.substring(0,60)+(w.length>60?"...":""),aheadBehind:u})}catch(a){t.warn({error:a,branch:i},`\u26A0\uFE0F Could not process worktree ${i}`)}return s.sort((i,c)=>i.type!==c.type?i.type==="release"?-1:1:i.branch.localeCompare(c.branch))},cr=async e=>{try{return(await A`git branch --show-current`).stdout.trim()===e}catch{return!1}},lr=async e=>{try{return(await A`cd ${e} && git rev-parse HEAD`).stdout.trim()}catch{return"unknown"}},mr=async e=>{try{let o=(await A`cd ${e} && git status --porcelain`).stdout.trim().split(`
13
+ `).filter(Boolean);return o.length===0?"clean":o.length<=3?"modified":"dirty"}catch{return"unknown"}},ur=async e=>{try{return(await A`cd ${e} && git log -1 --pretty=format:"%s"`).stdout.trim()}catch{return"No commit message available"}},pr=async e=>{try{let o=(await A`cd ${e} && git rev-list --count --left-right @{u}...HEAD 2>/dev/null || echo "0 0"`).stdout.trim().split(" ").map(Number),n=o[0]||0,s=o[1]||0;return s===0&&n===0?"up to date":s>0&&n===0?`\u2191${s} ahead`:n>0&&s===0?`\u2193${n} behind`:`\u2191${s} \u2193${n}`}catch{return"unknown"}},gr=e=>{if(e.length===0){t.info(`
12
14
  \u{1F33F} Git Worktrees`),t.info("\u2500".repeat(80)),t.info("\u2139\uFE0F No worktrees found"),t.info("\u2500".repeat(80));return}t.info(`
13
- \u{1F33F} Git Worktrees`),t.info("\u2550".repeat(100));let r=e.filter(s=>s.type==="release"),o=e.filter(s=>s.type==="feature");Ce("\u{1F680} Releases",r),o.length>0&&r.length>0&&t.info(""),Ce("\u2728 Features",o);let n=e.find(s=>s.isCurrent);t.info(`
14
- ${"\u2550".repeat(100)}`),t.info(`\u{1F4CA} Summary: ${e.length} total worktrees (${r.length} releases, ${o.length} features)`),n&&t.info(`\u{1F4CD} Currently on: ${n.branch}`),t.info("")},Ce=(e,r)=>{if(r.length!==0){t.info(`
15
- ${e}`),t.info("\u2500".repeat(50));for(let[o,n]of r.entries())mr(n),o<r.length-1&&t.info("")}},mr=e=>{let r=e.isCurrent?"\u{1F4CD}":" ",o=ur(e.status),s=`${e.type==="release"?"\u{1F680}":"\u2728"} ${e.branch}`;t.info(`${r} ${o} ${s}`);let i=e.aheadBehind!=="unknown"?` | ${e.aheadBehind}`:"";t.info(` \u{1F4DD} ${e.commit}${i}`),t.info(` \u{1F4AC} ${e.lastCommitMessage}`);let a=e.path.split("/").slice(-2).join("/");t.info(` \u{1F4C1} ${a}`)},ur=e=>{switch(e){case"clean":return"\u2705";case"modified":return"\u26A0\uFE0F ";case"dirty":return"\u{1F534}";default:return"\u2753"}},ee={name:"worktrees-list",description:"List all git worktrees with detailed information",inputSchema:{},outputSchema:{worktrees:d.array(d.object({branch:d.string(),path:d.string(),commit:d.string(),isCurrent:d.boolean(),type:d.enum(["release","feature"]),status:d.string(),lastCommitMessage:d.string(),aheadBehind:d.string()})).describe("List of all worktrees with details"),totalCount:d.number().describe("Total number of worktrees"),releaseCount:d.number().describe("Number of release worktrees"),featureCount:d.number().describe("Number of feature worktrees")},handler:Te};import pr from"@inquirer/checkbox";import gr from"@inquirer/confirm";import fr from"node:process";import{z as W}from"zod";import{$ as dr}from"zx";var Se=async e=>{let{confirmedCommand:r,all:o}=e;try{let n=await v("release"),i=`${await R()}${C}`,a=[];o?a=n:a=await pr({required:!0,message:"\u{1F33F} Select release branches",choices:n.map(f=>({name:f.replace("release/v",""),value:f}))}),r||await gr({message:"Are you sure you want to proceed with these worktree changes?"})||(t.info("Operation cancelled. Exiting..."),fr.exit(0));let l=await hr(a,i);wr(l);let m={removedWorktrees:l,count:l.length};return{content:[{type:"text",text:JSON.stringify(m,null,2)}],structuredContent:m}}catch(n){throw t.error({error:n},"\u274C Error managing worktrees"),n}},hr=async(e,r)=>{let o=[];for(let n of e)try{let s=`${r}/${n}`;await dr`git worktree remove ${s}`,o.push(n)}catch(s){t.error({error:s,branch:n},`\u274C Failed to remove worktree for ${n}`)}return o},wr=e=>{e.length>0?(t.info("\u274C Removed worktrees:"),t.info(e.join(`
16
- `)),t.info("")):t.info("\u2139\uFE0F No unused worktrees to remove")},re={name:"worktrees-remove",description:"Remove selected worktrees",inputSchema:{all:W.boolean().describe("Remove all worktrees without prompting")},outputSchema:{removedWorktrees:W.array(W.string()).describe("List of removed worktree branches"),count:W.number().describe("Number of worktrees removed")},handler:Se};import vr from"@inquirer/confirm";import yr from"node:process";import{z as te}from"zod";import{$ as Rr}from"zx";var br="release/v",Pe=async e=>{let{confirmedCommand:r}=e;try{let o=await v("release"),s=`${await R()}${C}`,i=await p();r||await vr({message:"Are you sure you want to proceed with these worktree changes?"})||(t.info("Operation cancelled. Exiting..."),yr.exit(0));let{branchesToRemove:c}=kr({releasePRsList:i,currentWorktrees:o}),l=await xr(c,s);$r(l);let m={removedWorktrees:l,count:l.length};return{content:[{type:"text",text:JSON.stringify(m,null,2)}],structuredContent:m}}catch(o){throw t.error({error:o},"\u274C Error managing worktrees"),o}},kr=e=>{let{releasePRsList:r,currentWorktrees:o}=e;return{branchesToRemove:o.filter(i=>i.startsWith(br)).filter(i=>!r.includes(i))}},xr=async(e,r)=>{let o=[];for(let n of e)try{let s=`${r}/${n}`;await Rr`git worktree remove ${s}`,o.push(n)}catch(s){t.error({error:s,branch:n},`\u274C Failed to remove worktree for ${n}`)}return o},$r=e=>{e.length>0?(t.info("\u274C Removed worktrees:"),t.info(e.join(`
17
- `)),t.info("")):t.info("\u2139\uFE0F No unused worktrees to remove")},oe={name:"worktrees-sync",description:"Synchronize worktrees with active release branches",inputSchema:{},outputSchema:{removedWorktrees:te.array(te.string()).describe("List of removed worktree branches"),count:te.number().describe("Number of worktrees removed during sync")},handler:Pe};var se=e=>async r=>{let{toolName:o,handler:n}=e;t.info({msg:`Tool execution started: ${o}`,params:r});try{let s=await n({...r,confirmedCommand:!0});return t.info({msg:`Tool execution successful: ${o}`}),s}catch(s){throw t.error({err:s,params:r,msg:`Tool execution failed: ${o}`}),s}};var Cr=[_,F,G,X,Y,Z,ee,re,oe],Ee=async e=>{for(let r of Cr)e.registerTool(r.name,{description:r.description,inputSchema:r.inputSchema,outputSchema:r.outputSchema},se({toolName:r.name,handler:r.handler}))};async function Ae(){let e=new Tr({name:"infra-kit",version:"0.1.0"},{capabilities:{resources:{},tools:{},prompts:{}}});return await ue(e),await pe(e),await Ee(e),e}await ae();var x=le(),Pr=async()=>{let e;try{e=await Ae(),x.info("MCP Server instance created")}catch(r){x.error({err:r,msg:"Failed to create MCP server"}),x.error("Fatal error during server creation."),Ie.exit(1)}try{let r=new Sr;await e.connect(r),x.info({msg:"Server connected to transport. Ready."})}catch(r){x.error({err:r,msg:"Failed to initialize server"}),x.error("Fatal error during server transport init."),Ie.exit(1)}};me(x);Pr();
15
+ \u{1F33F} Git Worktrees`),t.info("\u2550".repeat(100));let r=e.filter(s=>s.type==="release"),o=e.filter(s=>s.type==="feature");Ee("\u{1F680} Releases",r),o.length>0&&r.length>0&&t.info(""),Ee("\u2728 Features",o);let n=e.find(s=>s.isCurrent);t.info(`
16
+ ${"\u2550".repeat(100)}`),t.info(`\u{1F4CA} Summary: ${e.length} total worktrees (${r.length} releases, ${o.length} features)`),n&&t.info(`\u{1F4CD} Currently on: ${n.branch}`),t.info("")},Ee=(e,r)=>{if(r.length!==0){t.info(`
17
+ ${e}`),t.info("\u2500".repeat(50));for(let[o,n]of r.entries())fr(n),o<r.length-1&&t.info("")}},fr=e=>{let r=e.isCurrent?"\u{1F4CD}":" ",o=dr(e.status),s=`${e.type==="release"?"\u{1F680}":"\u2728"} ${e.branch}`;t.info(`${r} ${o} ${s}`);let i=e.aheadBehind!=="unknown"?` | ${e.aheadBehind}`:"";t.info(` \u{1F4DD} ${e.commit}${i}`),t.info(` \u{1F4AC} ${e.lastCommitMessage}`);let c=e.path.split("/").slice(-2).join("/");t.info(` \u{1F4C1} ${c}`)},dr=e=>{switch(e){case"clean":return"\u2705";case"modified":return"\u26A0\uFE0F ";case"dirty":return"\u{1F534}";default:return"\u2753"}},re={name:"worktrees-list",description:"List all git worktrees with detailed information",inputSchema:{},outputSchema:{worktrees:f.array(f.object({branch:f.string(),path:f.string(),commit:f.string(),isCurrent:f.boolean(),type:f.enum(["release","feature"]),status:f.string(),lastCommitMessage:f.string(),aheadBehind:f.string()})).describe("List of all worktrees with details"),totalCount:f.number().describe("Total number of worktrees"),releaseCount:f.number().describe("Number of release worktrees"),featureCount:f.number().describe("Number of feature worktrees")},handler:Se};import hr from"@inquirer/checkbox";import wr from"@inquirer/confirm";import vr from"node:process";import{z as N}from"zod";import{$ as yr}from"zx";var Ae=async e=>{let{confirmedCommand:r,all:o}=e;try{let n=await v("release"),i=`${await b()}${T}`,c=[];o?c=n:c=await hr({required:!0,message:"\u{1F33F} Select release branches",choices:n.map(p=>({name:p.replace("release/v",""),value:p}))}),r||await wr({message:"Are you sure you want to proceed with these worktree changes?"})||(t.info("Operation cancelled. Exiting..."),vr.exit(0));let l=await Rr(c,i);br(l);let m={removedWorktrees:l,count:l.length};return{content:[{type:"text",text:JSON.stringify(m,null,2)}],structuredContent:m}}catch(n){throw t.error({error:n},"\u274C Error managing worktrees"),n}},Rr=async(e,r)=>{let o=[];for(let n of e)try{let s=`${r}/${n}`;await yr`git worktree remove ${s}`,o.push(n)}catch(s){t.error({error:s,branch:n},`\u274C Failed to remove worktree for ${n}`)}return o},br=e=>{e.length>0?(t.info("\u274C Removed worktrees:"),t.info(e.join(`
18
+ `)),t.info("")):t.info("\u2139\uFE0F No unused worktrees to remove")},te={name:"worktrees-remove",description:"Remove selected worktrees",inputSchema:{all:N.boolean().describe("Remove all worktrees without prompting")},outputSchema:{removedWorktrees:N.array(N.string()).describe("List of removed worktree branches"),count:N.number().describe("Number of worktrees removed")},handler:Ae};import kr from"@inquirer/confirm";import xr from"node:process";import{z as oe}from"zod";import{$ as $r}from"zx";var Cr="release/v",Je=async e=>{let{confirmedCommand:r}=e;try{let o=await v("release"),s=`${await b()}${T}`,i=await g();r||await kr({message:"Are you sure you want to proceed with these worktree changes?"})||(t.info("Operation cancelled. Exiting..."),xr.exit(0));let{branchesToRemove:a}=Tr({releasePRsList:i,currentWorktrees:o}),l=await Pr(a,s);Er(l);let m={removedWorktrees:l,count:l.length};return{content:[{type:"text",text:JSON.stringify(m,null,2)}],structuredContent:m}}catch(o){throw t.error({error:o},"\u274C Error managing worktrees"),o}},Tr=e=>{let{releasePRsList:r,currentWorktrees:o}=e;return{branchesToRemove:o.filter(i=>i.startsWith(Cr)).filter(i=>!r.includes(i))}},Pr=async(e,r)=>{let o=[];for(let n of e)try{let s=`${r}/${n}`;await $r`git worktree remove ${s}`,o.push(n)}catch(s){t.error({error:s,branch:n},`\u274C Failed to remove worktree for ${n}`)}return o},Er=e=>{e.length>0?(t.info("\u274C Removed worktrees:"),t.info(e.join(`
19
+ `)),t.info("")):t.info("\u2139\uFE0F No unused worktrees to remove")},se={name:"worktrees-sync",description:"Synchronize worktrees with active release branches",inputSchema:{},outputSchema:{removedWorktrees:oe.array(oe.string()).describe("List of removed worktree branches"),count:oe.number().describe("Number of worktrees removed during sync")},handler:Je};var ne=e=>async r=>{let{toolName:o,handler:n}=e;t.info({msg:`Tool execution started: ${o}`,params:r});try{let s=await n({...r,confirmedCommand:!0});return t.info({msg:`Tool execution successful: ${o}`}),s}catch(s){throw t.error({err:s,params:r,msg:`Tool execution failed: ${o}`}),s}};var Sr=[_,F,G,Y,Z,ee,re,te,se],Ie=async e=>{for(let r of Sr)e.registerTool(r.name,{description:r.description,inputSchema:r.inputSchema,outputSchema:r.outputSchema},ne({toolName:r.name,handler:r.handler}))};async function Me(){let e=new Ar({name:"infra-kit",version:"0.1.0"},{capabilities:{resources:{},tools:{},prompts:{}}});return await ge(e),await fe(e),await Ie(e),e}await pe();var x=me(),Ir=async()=>{let e;try{e=await Me(),x.info("MCP Server instance created")}catch(r){x.error({err:r,msg:"Failed to create MCP server"}),x.error("Fatal error during server creation."),je.exit(1)}try{let r=new Jr;await e.connect(r),x.info({msg:"Server connected to transport. Ready."})}catch(r){x.error({err:r,msg:"Failed to initialize server"}),x.error("Fatal error during server transport init."),je.exit(1)}};ue(x);Ir();
18
20
  //# sourceMappingURL=mcp.js.map