infra-kit 0.1.39 → 0.1.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +18 -18
- package/dist/cli.js.map +4 -4
- package/dist/mcp.js +18 -1
- package/dist/mcp.js.map +4 -4
- package/package.json +3 -2
- package/src/commands/gh-merge-dev/gh-merge-dev.ts +59 -22
- package/src/commands/gh-merge-dev/index.ts +1 -1
- package/src/commands/gh-release-create/gh-release-create.ts +58 -20
- package/src/commands/gh-release-create/index.ts +1 -1
- package/src/commands/gh-release-deliver/gh-release-deliver.ts +47 -11
- package/src/commands/gh-release-deliver/index.ts +1 -1
- package/src/commands/gh-release-deploy/gh-release-deploy.ts +47 -7
- package/src/commands/gh-release-deploy/index.ts +1 -1
- package/src/commands/gh-release-list/gh-release-list.ts +37 -5
- package/src/commands/gh-release-list/index.ts +1 -1
- package/src/commands/worktrees-add/index.ts +1 -1
- package/src/commands/worktrees-add/worktrees-add.ts +45 -19
- package/src/commands/worktrees-list/index.ts +1 -1
- package/src/commands/worktrees-list/worktrees-list.ts +69 -33
- package/src/commands/worktrees-remove/index.ts +1 -1
- package/src/commands/worktrees-remove/worktrees-remove.ts +44 -18
- package/src/commands/worktrees-sync/index.ts +1 -1
- package/src/commands/worktrees-sync/worktrees-sync.ts +42 -19
- package/src/entry/cli.ts +6 -6
- package/src/entry/mcp.ts +4 -4
- package/src/lib/error-handlers/index.ts +8 -2
- package/src/lib/logger/index.ts +23 -2
- package/src/mcp/prompts/index.ts +1 -1
- package/src/mcp/resources/index.ts +1 -1
- package/src/mcp/server.ts +2 -2
- package/src/mcp/tools/index.ts +39 -1
- package/src/shared/gh-cli-auth/gh-cli-auth.ts +6 -4
- package/src/shared/gh-release-prs/gh-release-prs.ts +4 -2
- package/src/shared/logger/index.ts +4 -0
- package/src/shared/tool-handler/index.ts +1 -0
- package/src/shared/tool-handler/tool-handler.ts +29 -0
- package/src/types.ts +11 -0
package/dist/mcp.js
CHANGED
|
@@ -1,2 +1,19 @@
|
|
|
1
|
-
import{StdioServerTransport as
|
|
1
|
+
import{StdioServerTransport as Lr}from"@modelcontextprotocol/sdk/server/stdio";import Re from"node:process";import v from"node:process";var j=["dev","arthur","renana","roman","eliran","oriana"],k="-worktrees",E="/tmp/mcp-infra-kit.log";var K=e=>{v.on("SIGINT",()=>{e.info({msg:"Received SIGINT. Shutting down..."}),v.exit(0)}),v.on("SIGTERM",()=>{e.info({msg:"Received SIGTERM. Shutting down..."}),v.exit(0)}),v.on("uncaughtException",r=>{e.fatal({err:r,msg:"Uncaught Exception"}),e.error(`Uncaught Exception! Check ${E}. Shutting down...`),e.flush(),v.exit(1)}),v.on("unhandledRejection",(r,n)=>{e.fatal({reason:r,promise:n,msg:"Unhandled Rejection"}),e.error(`Unhandled Rejection! Check ${E}. Shutting down...`),e.flush(),v.exit(1)})};import Q from"node:process";import Y from"pino";import ke from"pino-pretty";var O=()=>{let e=Q.argv.includes("--debug")?"debug":"info",r=Y({level:e});return r.info(`Logger initialized with level: ${e}. Logging to: ${E}`),r},Z=()=>{let e=Q.argv.includes("--debug")?"debug":"info",r=["time","pid","hostname"];return e==="debug"&&r.push("level"),Y({level:e},ke({ignore:r.join(","),colorize:!0}))};import{Server as Mr}from"@modelcontextprotocol/sdk/server/index.js";var ee=async e=>{};var re=async e=>{};import $e from"@inquirer/checkbox";import Se from"@inquirer/confirm";import Ce from"node:process";import{z as y}from"zod";import{$ as h}from"zx";import te from"node:process";import{$ as xe}from"zx";var t=Z();var p=async()=>{try{let e=await xe`gh pr list --search "Release in:title" --base dev --json number,title,headRefName,state,baseRefName`,r=JSON.parse(e.stdout);return r.length===0&&(t.error("\u274C No release PRs found. Check the project folder for the script. Exiting..."),te.exit(1)),r.map(n=>n.headRefName)}catch(e){t.error({error:e},"\u274C Error fetching release PRs"),te.exit(1)}};var oe=async e=>{let{all:r,confirmedCommand:n}=e,s=await p(),o=[];r?o=s:o=await $e({required:!0,message:"\u{1F33F} Select release branches",choices:s.map(l=>({name:l.replace("release/v",""),value:l}))}),(n?!0:await Se({message:`Are you sure you want to merge dev into these branches: ${o.join(", ")}?`}))||(t.info("Operation cancelled. Exiting..."),Ce.exit(0)),h.quiet=!0,await h`git fetch origin`,await h`git switch dev`,await h`git pull origin dev`;let i=[];for(let l of o)await Te(l)||i.push(l);if(h.quiet=!1,i.length>0){t.info(`
|
|
2
|
+
\u26A0\uFE0F ${i.length} branch(es) failed to merge automatically.
|
|
3
|
+
`),t.info(`\u{1F4CB} Manual merge script for failed branches:
|
|
4
|
+
`),t.info("```bash");for(let l of i)t.info(`# Merge dev into ${l}`),t.info(`git switch ${l} && git pull origin ${l} && git merge origin/dev`),t.info("# Resolve conflicts if any, then:"),t.info(`git push origin ${l} && git switch dev`),t.info("");t.info("```\n"),t.info(`\u2705 ${o.length-i.length}/${o.length} merges completed successfully.`)}else t.info("\u2705 All merges completed successfully!");let c={successfulMerges:o.length-i.length,failedMerges:i.length,failedBranches:i,totalBranches:o.length};return{content:[{type:"text",text:JSON.stringify(c,null,2)}],structuredContent:c}},Te=async e=>{t.info(`Merging dev into ${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(`\u2714\uFE0F Successfully merged dev into ${e}`),!0}catch(r){return t.error({error:r,branch:e},`\u274C Error merging dev into ${e}`),await h`git reset --merge HEAD~1`,!1}},Ee=y.object({all:y.boolean().describe("Merge dev into all release branches without prompting")}),Pe=y.object({successfulMerges:y.number().describe("Number of successful merges"),failedMerges:y.number().describe("Number of failed merges"),failedBranches:y.array(y.string()).describe("List of branches that failed to merge"),totalBranches:y.number().describe("Total number of branches processed")}),N={name:"gh-merge-dev",description:"Merge dev branch into selected release branches",inputSchema:Ee,outputSchema:Pe,handler:oe};import se from"@inquirer/confirm";import ne from"node:process";import{z as b}from"zod";import{$ as f,question as Ae}from"zx";var ie=async e=>{let{versions:r,confirmedCommand:n,checkout:s}=e,o="",a=s;r?o=r:o=await Ae("Enter versions by comma (e.g. 1.2.5, 1.2.6): ");let i=o.split(",").map(m=>m.trim());i.length===0&&(t.error("No versions provided. Exiting..."),ne.exit(1)),a&&i.length>1&&t.warn("\u26A0\uFE0F Checkout option is ignored when creating multiple branches. Only works with single branch creation."),i.length===1&&!a&&(a=await se({message:"Checkout to the created branch?"})),(n?!0:await se({message:`Are you sure you want to create release branches for these versions: ${i.join(", ")}?`}))||(t.info("Operation cancelled. Exiting..."),ne.exit(0)),await f`git fetch origin`,await f`git switch dev`,await f`git pull origin dev`;for(let m of i)await Me(m);let l=a&&i.length===1;if(l){let m=`release/v${i[0]}`;t.info(`\u{1F504} Checking out to ${m}...`),await f`git switch ${m}`,t.info(`\u2705 Switched to branch ${m}`)}t.info("\u2705 All release branches were created successfully.");let g={createdBranches:i.map(m=>`release/v${m}`),branchCount:i.length,isCheckedOut:l};return{content:[{type:"text",text:JSON.stringify(g,null,2)}],structuredContent:g}};async function Me(e){let r=`release/v${e}`;t.info(`Creating release branch ${r}...`);try{await f`git switch dev`,await f`git pull origin dev`,await f`git checkout -b ${r}`,await f`git push -u origin ${r}`,await f`git commit --allow-empty-message --allow-empty --message ''`,await f`git push origin ${r}`,await f`gh pr create --title "Release v${e}" --body "Release v${e}" --base dev --head ${r}`,await f`git switch dev`,t.info(`\u2714\uFE0F Successfully created release branch: ${r}`)}catch(n){t.error({error:n,branchName:r},`Error creating release branch ${r}`)}}var We=b.object({versions:b.string().describe('Comma-separated list of versions to create (e.g., "1.2.5, 1.2.6")'),checkout:b.boolean().optional().describe("Checkout to the created branch (only works with single version)")}),Le=b.object({createdBranches:b.array(b.string()).describe("List of created release branches"),branchCount:b.number().describe("Number of branches created"),isCheckedOut:b.boolean().describe("Whether the branch was checked out")}),D={name:"gh-release-create",description:"Create new release branches for specified versions",inputSchema:We,outputSchema:Le,handler:ie};import Oe from"@inquirer/confirm";import je from"@inquirer/select";import B from"node:process";import{z as x}from"zod";import{$ as P}from"zx";var ae=async e=>{let{version:r,confirmedCommand:n}=e,s=await p(),o="";r?o=`release/v${r}`:o=await je({message:"\u{1F33F} Select release branch",choices:s.map(i=>({name:i.replace("release/v",""),value:i}))}),s.includes(o)||(t.error(`\u274C Release branch ${o} not found in open PRs. Exiting...`),B.exit(1)),(n?!0:await Oe({message:`Are you sure you want to deliver version ${o} to production?`}))||(t.info("Operation cancelled. Exiting..."),B.exit(0));try{await P`gh pr merge ${o} --squash --admin --delete-branch`,await P`gh pr create --base main --head dev --title "Release v${o.replace("release/v","")} (RC)" --body ""`,await P`gh pr merge dev --squash --admin`,await P`gh workflow run deploy-all.yml --ref main -f environment=prod`,await P`git switch main && git pull && git switch dev && git pull && git merge main --no-edit && git push`,t.info(`
|
|
5
|
+
`),t.info(`\u2714\uFE0F Successfully delivered ${o} to production!`);let i={releaseBranch:o,version:o.replace("release/v",""),success:!0};return{content:[{type:"text",text:JSON.stringify(i,null,2)}],structuredContent:i}}catch(i){t.error({error:i},"\u274C Error merging release branch into dev"),B.exit(1)}},Ne=x.object({version:x.string().describe('Version to deliver to production (e.g., "1.2.5")')}),De=x.object({releaseBranch:x.string().describe("The release branch that was delivered"),version:x.string().describe("The version that was delivered"),success:x.boolean().describe("Whether the delivery was successful")}),I={name:"gh-release-deliver",description:"Deliver a release branch to production",inputSchema:Ne,outputSchema:De,handler:ae};import ce from"@inquirer/select";import z from"node:process";import{z as R}from"zod";import{$ as Be}from"zx";var le=async e=>{let{version:r,env:n}=e,s=["dev"],o=await p();s.push(...o);let a="";r?a=`release/v${r}`:a=await ce({message:"\u{1F33F} Select release branch",choices:s.map(c=>({name:c.replace("release/v",""),value:c}))}),s.includes(a)||(t.error(`\u274C Release branch ${a} not found in open PRs. Exiting...`),z.exit(1));let i="";n?i=n:i=await ce({message:"\u{1F9EA} Select environment",choices:j.map(c=>({name:c,value:c}))}),j.includes(i)||(t.error(`\u274C Invalid environment: ${i}. Exiting...`),z.exit(1));try{await Be`gh workflow run deploy-all.yml --ref ${a} -f environment=${i}`,t.info(`
|
|
6
|
+
`),t.info(`\u2705 Successfully launched deploy-all workflow_dispatch for release branch: ${a} and environment: ${i}`);let c={releaseBranch:a,version:a.replace("release/v",""),environment:i,success:!0};return{content:[{type:"text",text:JSON.stringify(c,null,2)}],structuredContent:c}}catch(c){t.error({error:c},"\u274C Error launching workflow"),z.exit(1)}},Ie=R.object({version:R.string().describe('Version to deploy (e.g., "1.2.5")'),env:R.string().describe('Environment to deploy to (e.g., "dev", "renana", "oriana")')}),ze=R.object({releaseBranch:R.string().describe("The release branch that was deployed"),version:R.string().describe("The version that was deployed"),environment:R.string().describe("The environment deployed to"),success:R.boolean().describe("Whether the deployment was successful")}),_={name:"gh-release-deploy",description:"Deploy a release branch to a specified environment",inputSchema:Ie,outputSchema:ze,handler:le};import{z as A}from"zod";var F=e=>e.replace("release/","").slice(1).split(".").map(Number),q=e=>e.sort((r,n)=>{let[s,o,a]=F(r),[i,c,l]=F(n);return s!==i?(s??0)-(i??0):o!==c?(o??0)-(c??0):(a??0)-(l??0)});var me=async()=>{let r=(await p()).map(o=>o.replace("release/","")),n=q(r);t.info(`All release branches:
|
|
7
|
+
`),t.info(n.join(`
|
|
8
|
+
`));let s={releases:n,count:n.length};return{content:[{type:"text",text:JSON.stringify(s,null,2)}],structuredContent:s}},_e=A.object({}),Fe=A.object({releases:A.array(A.string()).describe("List of all release branches"),count:A.number().describe("Number of release branches")}),G={name:"gh-release-list",description:"List all open release branches",inputSchema:_e,outputSchema:Fe,handler:me};import He from"@inquirer/checkbox";import Je from"@inquirer/confirm";import Ue from"node:process";import{z as $}from"zod";import{$ as pe}from"zx";import{$ as ue}from"zx";var d=async e=>{let n=(await ue`git worktree list`).stdout.split(`
|
|
9
|
+
`).filter(Boolean),s={release:qe,feature:Ge};return n.map(s[e]).filter(o=>o!==null)},qe=e=>{let r=e.split(" ").filter(Boolean);return r.length<3||!r[0]?.includes("release/v")?null:`release/${r[0]?.split("/").pop()||""}`},Ge=e=>{let r=e.split(" ").filter(Boolean);return r.length<3||!r[0]?.includes("feature/")?null:`feature/${r[0]?.split("/").pop()||""}`},w=async()=>(await ue`git rev-parse --show-toplevel`).stdout.trim();var Ve="feature",Xe="release",Ke="release/v",fe=async e=>{let{confirmedCommand:r,all:n}=e;try{let s=await d("release"),a=`${await w()}${k}`;await ge(`${a}/${Xe}`),await ge(`${a}/${Ve}`);let i=await p(),c=[];n?c=i:c=await He({required:!0,message:"\u{1F33F} Select release branches",choices:i.map(L=>({name:L.replace("release/v",""),value:L}))}),(r?!0:await Je({message:"Are you sure you want to proceed with these worktree changes?"}))||(t.info("Operation cancelled. Exiting..."),Ue.exit(0));let{branchesToCreate:g}=Qe({selectedReleaseBranches:c,currentWorktrees:s}),m=await Ye(g,a);Ze(m);let T={createdWorktrees:m,count:m.length};return{content:[{type:"text",text:JSON.stringify(T,null,2)}],structuredContent:T}}catch(s){throw t.error({error:s},"\u274C Error managing worktrees"),s}},ge=async e=>{await pe`mkdir -p ${e}`},Qe=e=>{let{selectedReleaseBranches:r,currentWorktrees:n}=e,s=n.filter(a=>a.startsWith(Ke));return{branchesToCreate:r.filter(a=>!s.includes(a))}},Ye=async(e,r)=>{let n=[];for(let s of e)try{let o=`${r}/${s}`;await pe`git worktree add ${o} ${s}`,n.push(s)}catch(o){t.error({error:o,branch:s},`\u274C Failed to create worktree for ${s}`)}return n},Ze=e=>{e.length>0?(t.info(`
|
|
10
|
+
`),t.info("\u2705 Created worktrees:"),t.info(e.join(`
|
|
11
|
+
`)),t.info("")):t.info("\u2139\uFE0F No new worktrees to create")},er=$.object({all:$.boolean().describe("Add worktrees for all release branches without prompting")}),rr=$.object({createdWorktrees:$.array($.string()).describe("List of created worktree branches"),count:$.number().describe("Number of worktrees created")}),H={name:"worktrees-add",description:"Create worktrees for selected release branches",inputSchema:er,outputSchema:rr,handler:fe};import{z as u}from"zod";import{$ as M}from"zx";var de=async()=>{try{let[e,r]=await Promise.all([d("release"),d("feature")]),n=await w(),s=await tr(e,r,n);cr(s);let o={worktrees:s,totalCount:s.length,releaseCount:e.length,featureCount:r.length};return{content:[{type:"text",text:JSON.stringify(o,null,2)}],structuredContent:o}}catch(e){throw t.error({error:e},"\u274C Error listing worktrees"),e}},tr=async(e,r,n)=>{let s=[...e.map(a=>({branch:a,type:"release"})),...r.map(a=>({branch:a,type:"feature"}))],o=[];for(let{branch:a,type:i}of s)try{let c=`${n}/${a}`,l=await or(a),g=await sr(c),m=await nr(c),T=await ir(c),L=await ar(c);o.push({branch:a,path:c,commit:g.substring(0,8),isCurrent:l,type:i,status:m,lastCommitMessage:T.substring(0,60)+(T.length>60?"...":""),aheadBehind:L})}catch(c){t.warn({error:c,branch:a},`\u26A0\uFE0F Could not process worktree ${a}`)}return o.sort((a,i)=>a.type!==i.type?a.type==="release"?-1:1:a.branch.localeCompare(i.branch))},or=async e=>{try{return(await M`git branch --show-current`).stdout.trim()===e}catch{return!1}},sr=async e=>{try{return(await M`cd ${e} && git rev-parse HEAD`).stdout.trim()}catch{return"unknown"}},nr=async e=>{try{let n=(await M`cd ${e} && git status --porcelain`).stdout.trim().split(`
|
|
12
|
+
`).filter(Boolean);return n.length===0?"clean":n.length<=3?"modified":"dirty"}catch{return"unknown"}},ir=async e=>{try{return(await M`cd ${e} && git log -1 --pretty=format:"%s"`).stdout.trim()}catch{return"No commit message available"}},ar=async e=>{try{let n=(await M`cd ${e} && git rev-list --count --left-right @{u}...HEAD 2>/dev/null || echo "0 0"`).stdout.trim().split(" ").map(Number),s=n[0]||0,o=n[1]||0;return o===0&&s===0?"up to date":o>0&&s===0?`\u2191${o} ahead`:s>0&&o===0?`\u2193${s} behind`:`\u2191${o} \u2193${s}`}catch{return"unknown"}},cr=e=>{if(e.length===0){t.info(`
|
|
13
|
+
\u{1F33F} Git Worktrees`),t.info("\u2500".repeat(80)),t.info("\u2139\uFE0F No worktrees found"),t.info("\u2500".repeat(80));return}t.info(`
|
|
14
|
+
\u{1F33F} Git Worktrees`),t.info("\u2550".repeat(100));let r=e.filter(o=>o.type==="release"),n=e.filter(o=>o.type==="feature");he("\u{1F680} Releases",r),n.length>0&&r.length>0&&t.info(""),he("\u2728 Features",n);let s=e.find(o=>o.isCurrent);t.info(`
|
|
15
|
+
${"\u2550".repeat(100)}`),t.info(`\u{1F4CA} Summary: ${e.length} total worktrees (${r.length} releases, ${n.length} features)`),s&&t.info(`\u{1F4CD} Currently on: ${s.branch}`),t.info("")},he=(e,r)=>{if(r.length!==0){t.info(`
|
|
16
|
+
${e}`),t.info("\u2500".repeat(50));for(let[n,s]of r.entries())lr(s),n<r.length-1&&t.info("")}},lr=e=>{let r=e.isCurrent?"\u{1F4CD}":" ",n=mr(e.status),o=`${e.type==="release"?"\u{1F680}":"\u2728"} ${e.branch}`;t.info(`${r} ${n} ${o}`);let a=e.aheadBehind!=="unknown"?` | ${e.aheadBehind}`:"";t.info(` \u{1F4DD} ${e.commit}${a}`),t.info(` \u{1F4AC} ${e.lastCommitMessage}`);let i=e.path.split("/").slice(-2).join("/");t.info(` \u{1F4C1} ${i}`)},mr=e=>{switch(e){case"clean":return"\u2705";case"modified":return"\u26A0\uFE0F ";case"dirty":return"\u{1F534}";default:return"\u2753"}},ur=u.object({}),gr=u.object({worktrees:u.array(u.object({branch:u.string(),path:u.string(),commit:u.string(),isCurrent:u.boolean(),type:u.enum(["release","feature"]),status:u.string(),lastCommitMessage:u.string(),aheadBehind:u.string()})).describe("List of all worktrees with details"),totalCount:u.number().describe("Total number of worktrees"),releaseCount:u.number().describe("Number of release worktrees"),featureCount:u.number().describe("Number of feature worktrees")}),J={name:"worktrees-list",description:"List all git worktrees with detailed information",inputSchema:ur,outputSchema:gr,handler:de};import pr from"@inquirer/checkbox";import fr from"@inquirer/confirm";import hr from"node:process";import{z as S}from"zod";import{$ as dr}from"zx";var we=async e=>{let{confirmedCommand:r,all:n}=e;try{let s=await d("release"),a=`${await w()}${k}`,i=[];n?i=s:i=await pr({required:!0,message:"\u{1F33F} Select release branches",choices:s.map(m=>({name:m.replace("release/v",""),value:m}))}),(r?!0:await fr({message:"Are you sure you want to proceed with these worktree changes?"}))||(t.info("Operation cancelled. Exiting..."),hr.exit(0));let l=await wr(i,a);vr(l);let g={removedWorktrees:l,count:l.length};return{content:[{type:"text",text:JSON.stringify(g,null,2)}],structuredContent:g}}catch(s){throw t.error({error:s},"\u274C Error managing worktrees"),s}},wr=async(e,r)=>{let n=[];for(let s of e)try{let o=`${r}/${s}`;await dr`git worktree remove ${o}`,n.push(s)}catch(o){t.error({error:o,branch:s},`\u274C Failed to remove worktree for ${s}`)}return n},vr=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")},yr=S.object({all:S.boolean().describe("Remove all worktrees without prompting")}),br=S.object({removedWorktrees:S.array(S.string()).describe("List of removed worktree branches"),count:S.number().describe("Number of worktrees removed")}),U={name:"worktrees-remove",description:"Remove selected worktrees",inputSchema:yr,outputSchema:br,handler:we};import Rr from"@inquirer/confirm";import kr from"node:process";import{z as W}from"zod";import{$ as xr}from"zx";var $r="release/v",ve=async e=>{let{confirmedCommand:r}=e;try{let n=await d("release"),o=`${await w()}${k}`,a=await p();(r?!0:await Rr({message:"Are you sure you want to proceed with these worktree changes?"}))||(t.info("Operation cancelled. Exiting..."),kr.exit(0));let{branchesToRemove:c}=Sr({releasePRsList:a,currentWorktrees:n}),l=await Cr(c,o);Tr(l);let g={removedWorktrees:l,count:l.length};return{content:[{type:"text",text:JSON.stringify(g,null,2)}],structuredContent:g}}catch(n){throw t.error({error:n},"\u274C Error managing worktrees"),n}},Sr=e=>{let{releasePRsList:r,currentWorktrees:n}=e;return{branchesToRemove:n.filter(a=>a.startsWith($r)).filter(a=>!r.includes(a))}},Cr=async(e,r)=>{let n=[];for(let s of e)try{let o=`${r}/${s}`;await xr`git worktree remove ${o}`,n.push(s)}catch(o){t.error({error:o,branch:s},`\u274C Failed to remove worktree for ${s}`)}return n},Tr=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")},Er=W.object({}),Pr=W.object({removedWorktrees:W.array(W.string()).describe("List of removed worktree branches"),count:W.number().describe("Number of worktrees removed during sync")}),V={name:"worktrees-sync",description:"Synchronize worktrees with active release branches",inputSchema:Er,outputSchema:Pr,handler:ve};var X=e=>async r=>{let{toolName:n,handler:s}=e;t.info({msg:`Tool execution started: ${n}`,params:r});try{let o=await s({...r,confirmedCommand:!0});return t.info({msg:`Tool execution successful: ${n}`}),o}catch(o){throw t.error({err:o,params:r,msg:`Tool execution failed: ${n}`}),o}};var Ar=[N,D,I,_,G,H,J,U,V],ye=async e=>{for(let r of Ar)e.registerTool(r.name,{description:r.description,inputSchema:r.inputSchema,outputSchema:r.outputSchema,handler:r.handler},X({toolName:r.name,handler:r.handler}))};var Wr=O();async function be(){let e=new Mr({name:"infra-kit",description:"Infra Kit is a tool that helps you manage your infrastructure.",version:"0.1.0"},{capabilities:{resources:{},tools:{},prompts:{}}});return await ee(e),await re(e),await ye(e),Wr.info("MCP Server instance created"),e}var C=O(),Or=async()=>{let e;try{e=await be()}catch(r){C.error({err:r,msg:"Failed to create MCP server"}),C.error("Fatal error during server creation."),Re.exit(1)}try{let r=new Lr;await e.connect(r),C.info({msg:"Server connected to transport. Ready."})}catch(r){C.error({err:r,msg:"Failed to initialize server"}),C.error("Fatal error during server transport init."),Re.exit(1)}};K(C);Or();
|
|
2
19
|
//# sourceMappingURL=mcp.js.map
|
package/dist/mcp.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/entry/mcp.ts", "../src/lib/error-handlers/index.ts", "../src/shared/constants.ts", "../src/lib/logger/index.ts", "../src/mcp/server.ts", "../src/mcp/prompts/index.ts", "../src/mcp/resources/index.ts", "../src/mcp/tools/index.ts"],
|
|
4
|
-
"sourcesContent": ["import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio'\nimport process from 'node:process'\n\nimport { setupErrorHandlers } from 'src/lib/error-handlers'\nimport { initLogger } from 'src/lib/logger'\n\nimport { createMcpServer } from '../mcp/server'\n\nconst logger = initLogger()\n\nconst startServer = async () => {\n let server\n try {\n server = await createMcpServer()\n } catch (error) {\n logger.error({ err: error, msg: 'Failed to create MCP server' })\n console.error(`Fatal error during server creation.`)\n\n process.exit(1)\n }\n\n try {\n const transport = new StdioServerTransport()\n\n await server.connect(transport)\n\n logger.info({ msg: 'Server connected to transport. Ready.' })\n } catch (error) {\n logger.error({ err: error, msg: 'Failed to initialize server' })\n console.error(`Fatal error during server transport init.`)\n\n process.exit(1)\n }\n}\n\n// Setup error handlers\nsetupErrorHandlers(logger)\n\n// Start the server\nstartServer()\n", "import process from 'node:process'\nimport type { Logger } from 'pino'\n\nimport { LOG_FILE_PATH } from 'src/shared/constants'\n\nexport const setupErrorHandlers = (logger: Logger) => {\n process.on('SIGINT', () => {\n logger.info({ msg: 'Received SIGINT. Shutting down...' })\n process.exit(0)\n })\n\n process.on('SIGTERM', () => {\n logger.info({ msg: 'Received SIGTERM. Shutting down...' })\n process.exit(0)\n })\n\n process.on('uncaughtException', (error) => {\n logger.fatal({ err: error, msg: 'Uncaught Exception' })\n console.error(`Uncaught Exception! Check ${LOG_FILE_PATH}. Shutting down...`)\n logger.flush()\n process.exit(1)\n })\n\n process.on('unhandledRejection', (reason, promise) => {\n logger.fatal({ reason, promise, msg: 'Unhandled Rejection' })\n console.error(`Unhandled Rejection! Check ${LOG_FILE_PATH}. Shutting down...`)\n logger.flush()\n process.exit(1)\n })\n}\n", "/**\n * List of environments for the project deployment\n */\nexport const ENVs = ['dev', 'arthur', 'renana', 'roman', 'eliran', 'oriana']\n\nexport const WORKTREES_DIR_SUFFIX = '-worktrees'\n// eslint-disable-next-line sonarjs/publicly-writable-directories\nexport const LOG_FILE_PATH = '/tmp/mcp-infra-kit.log'\n", "import process from 'node:process'\nimport pino from 'pino'\n\nimport { LOG_FILE_PATH } from 'src/shared/constants'\n\nexport const initLogger = () => {\n const logLevel = process.argv.includes('--debug') ? 'debug' : 'info'\n\n const logger = pino({ level: logLevel }, pino.destination(LOG_FILE_PATH))\n\n logger.info(`Logger initialized with level: ${logLevel}. Logging to: ${LOG_FILE_PATH}`)\n\n return logger\n}\n", "import { Server } from '@modelcontextprotocol/sdk/server/index.js'\n\nimport { initLogger } from 'src/lib/logger'\n\nimport { initializePrompts } from './prompts'\nimport { initializeResources } from './resources'\nimport { initializeTools } from './tools'\n\nconst logger = initLogger()\n\nexport async function createMcpServer() {\n const server = new Server(\n {\n name: 'infra-kit',\n description: 'Infra Kit is a tool that helps you manage your infrastructure.',\n version: '0.1.0',\n },\n {\n capabilities: {\n resources: {},\n tools: {},\n prompts: {},\n },\n },\n )\n\n await initializePrompts(server)\n await initializeResources(server)\n await initializeTools(server)\n\n logger.info('MCP Server instance created')\n\n return server\n}\n", "import type { Server } from '@modelcontextprotocol/sdk/server/index'\n\nexport const initializePrompts = async (server: Server) => {}\n", "import type { Server } from '@modelcontextprotocol/sdk/server/index'\n\nexport const initializeResources = async (server: Server) => {}\n", "import type { Server } from '@modelcontextprotocol/sdk/server/index'\n\nexport const initializeTools = async (server: Server) => {}\n"],
|
|
5
|
-
"mappings": "AAAA,OAAS,wBAAAA,MAA4B,yCACrC,OAAOC,MAAa,eCDpB,OAAOC,MAAa,eCOb,IAAMC,EAAgB,yBDFtB,IAAMC,EAAsBC,GAAmB,CACpDC,EAAQ,GAAG,SAAU,IAAM,CACzBD,EAAO,KAAK,CAAE,IAAK,mCAAoC,CAAC,EACxDC,EAAQ,KAAK,CAAC,CAChB,CAAC,EAEDA,EAAQ,GAAG,UAAW,IAAM,CAC1BD,EAAO,KAAK,CAAE,IAAK,oCAAqC,CAAC,EACzDC,EAAQ,KAAK,CAAC,CAChB,CAAC,EAEDA,EAAQ,GAAG,oBAAsBC,GAAU,CACzCF,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gB,CACjC,OAASC,EAAO,CACdL,EAAO,MAAM,CAAE,IAAKK,EAAO,IAAK,6BAA8B,CAAC,EAC/D,QAAQ,MAAM,qCAAqC,EAEnDC,EAAQ,KAAK,CAAC,CAChB,CAEA,GAAI,CACF,IAAMC,EAAY,IAAIC,EAEtB,MAAML,EAAO,QAAQI,CAAS,EAE9BP,EAAO,KAAK,CAAE,IAAK,uCAAwC,CAAC,CAC9D,OAASK,EAAO,CACdL,EAAO,MAAM,CAAE,IAAKK,EAAO,IAAK,6BAA8B,CAAC,EAC/D,QAAQ,MAAM,2CAA2C,EAEzDC,EAAQ,KAAK,CAAC,CAChB,CACF,EAGAG,EAAmBT,CAAM,EAGzBE,EAAY",
|
|
6
|
-
"names": ["StdioServerTransport", "process", "process", "LOG_FILE_PATH", "setupErrorHandlers", "logger", "process", "error", "LOG_FILE_PATH", "reason", "promise", "process", "pino", "
|
|
3
|
+
"sources": ["../src/entry/mcp.ts", "../src/lib/error-handlers/index.ts", "../src/shared/constants.ts", "../src/lib/logger/index.ts", "../src/mcp/server.ts", "../src/mcp/prompts/index.ts", "../src/mcp/resources/index.ts", "../src/commands/gh-merge-dev/gh-merge-dev.ts", "../src/shared/gh-release-prs/gh-release-prs.ts", "../src/shared/logger/index.ts", "../src/commands/gh-release-create/gh-release-create.ts", "../src/commands/gh-release-deliver/gh-release-deliver.ts", "../src/commands/gh-release-deploy/gh-release-deploy.ts", "../src/commands/gh-release-list/gh-release-list.ts", "../src/shared/version-utils/version-utils.ts", "../src/commands/worktrees-add/worktrees-add.ts", "../src/shared/git-utils/git-utils.ts", "../src/commands/worktrees-list/worktrees-list.ts", "../src/commands/worktrees-remove/worktrees-remove.ts", "../src/commands/worktrees-sync/worktrees-sync.ts", "../src/shared/tool-handler/tool-handler.ts", "../src/mcp/tools/index.ts"],
|
|
4
|
+
"sourcesContent": ["import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio'\nimport process from 'node:process'\n\nimport { setupErrorHandlers } from 'src/lib/error-handlers'\nimport { initLoggerMcp } from 'src/lib/logger'\n\nimport { createMcpServer } from '../mcp/server'\n\nconst logger = initLoggerMcp()\n\nconst startServer = async () => {\n let server\n try {\n server = await createMcpServer()\n } catch (error) {\n logger.error({ err: error, msg: 'Failed to create MCP server' })\n logger.error(`Fatal error during server creation.`)\n\n process.exit(1)\n }\n\n try {\n const transport = new StdioServerTransport()\n\n await server.connect(transport)\n\n logger.info({ msg: 'Server connected to transport. Ready.' })\n } catch (error) {\n logger.error({ err: error, msg: 'Failed to initialize server' })\n logger.error(`Fatal error during server transport init.`)\n\n process.exit(1)\n }\n}\n\n// Setup error handlers\nsetupErrorHandlers(logger)\n\n// Start the server\nstartServer()\n", "import process from 'node:process'\nimport type { Logger } from 'pino'\n\nimport { LOG_FILE_PATH } from 'src/shared/constants'\n\n/**\n * Setup error handlers for the application\n * @param logger - The logger instance\n *\n * ONLY FOR SERVER!\n */\nexport const setupErrorHandlers = (logger: Logger) => {\n process.on('SIGINT', () => {\n logger.info({ msg: 'Received SIGINT. Shutting down...' })\n process.exit(0)\n })\n\n process.on('SIGTERM', () => {\n logger.info({ msg: 'Received SIGTERM. Shutting down...' })\n process.exit(0)\n })\n\n process.on('uncaughtException', (error) => {\n logger.fatal({ err: error, msg: 'Uncaught Exception' })\n logger.error(`Uncaught Exception! Check ${LOG_FILE_PATH}. Shutting down...`)\n logger.flush()\n process.exit(1)\n })\n\n process.on('unhandledRejection', (reason, promise) => {\n logger.fatal({ reason, promise, msg: 'Unhandled Rejection' })\n logger.error(`Unhandled Rejection! Check ${LOG_FILE_PATH}. Shutting down...`)\n logger.flush()\n process.exit(1)\n })\n}\n", "/**\n * List of environments for the project deployment\n */\nexport const ENVs = ['dev', 'arthur', 'renana', 'roman', 'eliran', 'oriana']\n\nexport const WORKTREES_DIR_SUFFIX = '-worktrees'\n// eslint-disable-next-line sonarjs/publicly-writable-directories\nexport const LOG_FILE_PATH = '/tmp/mcp-infra-kit.log'\n", "import process from 'node:process'\nimport pino from 'pino'\nimport pretty from 'pino-pretty'\n\nimport { LOG_FILE_PATH } from 'src/shared/constants'\n\nexport const initLoggerMcp = () => {\n const logLevel = process.argv.includes('--debug') ? 'debug' : 'info'\n\n const logger = pino({ level: logLevel })\n\n logger.info(`Logger initialized with level: ${logLevel}. Logging to: ${LOG_FILE_PATH}`)\n\n return logger\n}\n\nexport const initLoggerCLI = () => {\n const logLevel = process.argv.includes('--debug') ? 'debug' : 'info'\n\n const ignoreFields = ['time', 'pid', 'hostname']\n\n if (logLevel === 'debug') {\n ignoreFields.push('level')\n }\n\n const logger = pino(\n { level: logLevel },\n pretty({\n ignore: ignoreFields.join(','),\n colorize: true,\n }),\n )\n\n return logger\n}\n", "import { Server } from '@modelcontextprotocol/sdk/server/index.js'\n\nimport { initLoggerMcp } from 'src/lib/logger'\n\nimport { initializePrompts } from './prompts'\nimport { initializeResources } from './resources'\nimport { initializeTools } from './tools'\n\nconst logger = initLoggerMcp()\n\nexport async function createMcpServer() {\n const server = new Server(\n {\n name: 'infra-kit',\n description: 'Infra Kit is a tool that helps you manage your infrastructure.',\n version: '0.1.0',\n },\n {\n capabilities: {\n resources: {},\n tools: {},\n prompts: {},\n },\n },\n )\n\n await initializePrompts(server)\n await initializeResources(server)\n await initializeTools(server)\n\n logger.info('MCP Server instance created')\n\n return server\n}\n", "import type { Server } from '@modelcontextprotocol/sdk/server/index'\n\nexport const initializePrompts = async (_server: Server) => {}\n", "import type { Server } from '@modelcontextprotocol/sdk/server/index'\n\nexport const initializeResources = async (_server: Server) => {}\n", "import checkbox from '@inquirer/checkbox'\nimport confirm from '@inquirer/confirm'\nimport process from 'node:process'\nimport { z } from 'zod'\nimport { $ } from 'zx'\n\nimport { getReleasePRs } from 'src/shared/gh-release-prs'\nimport { logger } from 'src/shared/logger'\nimport type { RequiredConfirmedOptionArg, ToolsExecutionResult } from 'src/types'\n\ninterface GhMergeDevArgs extends RequiredConfirmedOptionArg {\n all: boolean\n}\n\n/**\n * Merge dev into every release branch\n */\nexport const ghMergeDev = async (args: GhMergeDevArgs): Promise<ToolsExecutionResult> => {\n const { all, confirmedCommand } = args\n\n const releasePRsList = await getReleasePRs()\n\n let selectedReleaseBranches: string[] = []\n\n if (all) {\n selectedReleaseBranches = releasePRsList\n } else {\n selectedReleaseBranches = await checkbox({\n required: true,\n message: '\uD83C\uDF3F Select release branches',\n choices: releasePRsList.map((pr) => ({\n name: pr.replace('release/v', ''),\n value: pr,\n })),\n })\n }\n\n // Validate input\n // if (selectedReleaseBranches.length === 0) {\n // console.error('No branches provided. Exiting...')\n // process.exit(1)\n // }\n\n const answer = confirmedCommand\n ? true\n : await confirm({\n message: `Are you sure you want to merge dev into these branches: ${selectedReleaseBranches.join(', ')}?`,\n })\n\n if (!answer) {\n logger.info('Operation cancelled. Exiting...')\n process.exit(0)\n }\n\n $.quiet = true\n\n await $`git fetch origin`\n await $`git switch dev`\n await $`git pull origin dev`\n\n const failedBranches: string[] = []\n\n // Merge dev into each branch\n for (const branch of selectedReleaseBranches) {\n const success = await mergeDev(branch)\n\n if (!success) {\n failedBranches.push(branch)\n }\n }\n\n $.quiet = false\n\n if (failedBranches.length > 0) {\n logger.info(`\\n\u26A0\uFE0F ${failedBranches.length} branch(es) failed to merge automatically.\\n`)\n logger.info('\uD83D\uDCCB Manual merge script for failed branches:\\n')\n logger.info('```bash')\n for (const branch of failedBranches) {\n logger.info(`# Merge dev into ${branch}`)\n logger.info(`git switch ${branch} && git pull origin ${branch} && git merge origin/dev`)\n logger.info(`# Resolve conflicts if any, then:`)\n logger.info(`git push origin ${branch} && git switch dev`)\n logger.info('')\n }\n logger.info('```\\n')\n logger.info(\n `\u2705 ${selectedReleaseBranches.length - failedBranches.length}/${selectedReleaseBranches.length} merges completed successfully.`,\n )\n } else {\n logger.info('\u2705 All merges completed successfully!')\n }\n\n const structuredContent = {\n successfulMerges: selectedReleaseBranches.length - failedBranches.length,\n failedMerges: failedBranches.length,\n failedBranches,\n totalBranches: selectedReleaseBranches.length,\n }\n\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(structuredContent, null, 2),\n },\n ],\n structuredContent,\n }\n}\n\nconst mergeDev = async (branch: string): Promise<boolean> => {\n logger.info(`Merging dev into ${branch}...`)\n\n try {\n await $`git switch ${branch}`\n\n await $`git pull origin ${branch}`\n\n await $`git merge origin/dev --no-edit`\n\n await $`git push origin ${branch}`\n\n await $`git switch dev`\n\n logger.info(`\u2714\uFE0F Successfully merged dev into ${branch}`)\n\n return true\n } catch (error: unknown) {\n logger.error({ error, branch }, `\u274C Error merging dev into ${branch}`)\n\n await $`git reset --merge HEAD~1`\n\n return false\n }\n}\n\n// MCP Tool Registration\nconst ghMergeDevSchema = z.object({\n all: z.boolean().describe('Merge dev into all release branches without prompting'),\n})\n\nconst ghMergeDevOutputSchema = z.object({\n successfulMerges: z.number().describe('Number of successful merges'),\n failedMerges: z.number().describe('Number of failed merges'),\n failedBranches: z.array(z.string()).describe('List of branches that failed to merge'),\n totalBranches: z.number().describe('Total number of branches processed'),\n})\n\nexport const ghMergeDevMcpTool = {\n name: 'gh-merge-dev',\n description: 'Merge dev branch into selected release branches',\n inputSchema: ghMergeDevSchema,\n outputSchema: ghMergeDevOutputSchema,\n handler: ghMergeDev,\n}\n", "import process from 'node:process'\nimport { $ } from 'zx'\n\nimport { logger } from 'src/shared/logger'\n\ninterface ReleasePR {\n headRefName: string\n number: number\n state: string\n title: string\n baseRefName: string\n}\n\n/**\n * Fetch open release PRs from GitHub with 'Release' in the title and base 'dev'.\n * Returns an array of headRefName strings.\n * Throws an error if fetching fails.\n *\n * @returns [release/v1.18.22, release/v1.18.23, release/v1.18.24]\n */\nexport const getReleasePRs = async (): Promise<string[]> => {\n try {\n // Example of releasePRs.output: {\"headRefName\":\"release/v1.8.0\",\"number\":665,\"state\":\"OPEN\",\"title\":\"WIP Release/v1.8.0\"}\n const releasePRs =\n await $`gh pr list --search \"Release in:title\" --base dev --json number,title,headRefName,state,baseRefName`\n\n const releasePRsArray: ReleasePR[] = JSON.parse(releasePRs.stdout)\n\n if (releasePRsArray.length === 0) {\n logger.error('\u274C No release PRs found. Check the project folder for the script. Exiting...')\n process.exit(1)\n }\n\n return releasePRsArray.map((pr) => pr.headRefName)\n } catch (error) {\n logger.error({ error }, '\u274C Error fetching release PRs')\n process.exit(1)\n }\n}\n", "import { initLoggerCLI } from 'src/lib/logger'\n\n// INFO: This is a logger for NPM CLI package\nexport const logger = initLoggerCLI()\n", "import confirm from '@inquirer/confirm'\nimport process from 'node:process'\nimport { z } from 'zod'\nimport { $, question } from 'zx'\n\nimport { logger } from 'src/shared/logger'\nimport type { RequiredConfirmedOptionArg, ToolsExecutionResult } from 'src/types'\n\ninterface GhReleaseCreateArgs extends RequiredConfirmedOptionArg {\n versions: string\n checkout?: boolean\n}\n\n/**\n * Create release branches for a given version\n */\nexport const ghReleaseCreate = async (args: GhReleaseCreateArgs): Promise<ToolsExecutionResult> => {\n const { versions, confirmedCommand, checkout } = args\n\n let versionBranches = ''\n let _checkout = checkout\n\n if (versions) {\n versionBranches = versions\n } else {\n versionBranches = await question('Enter versions by comma (e.g. 1.2.5, 1.2.6): ')\n }\n\n const versionsList = versionBranches.split(',').map((version) => version.trim()) // ['1.2.5', '1.2.6']\n\n // Validate input\n if (versionsList.length === 0) {\n logger.error('No versions provided. Exiting...')\n process.exit(1)\n }\n\n // Warn user if checkout option is used with multiple branches\n if (_checkout && versionsList.length > 1) {\n logger.warn(\n '\u26A0\uFE0F Checkout option is ignored when creating multiple branches. Only works with single branch creation.',\n )\n }\n\n if (versionsList.length === 1 && !_checkout) {\n _checkout = await confirm({\n message: `Checkout to the created branch?`,\n })\n }\n\n const answer = confirmedCommand\n ? true\n : await confirm({\n message: `Are you sure you want to create release branches for these versions: ${versionsList.join(', ')}?`,\n })\n\n if (!answer) {\n logger.info('Operation cancelled. Exiting...')\n process.exit(0)\n }\n\n await $`git fetch origin`\n\n await $`git switch dev`\n\n await $`git pull origin dev`\n\n // Create release branches for each version\n for (const version of versionsList) {\n await createReleaseBranch(version)\n }\n\n // If checkout option is enabled and we created only one branch, checkout to it\n const isCheckedOut = _checkout && versionsList.length === 1\n\n if (isCheckedOut) {\n const branchName = `release/v${versionsList[0]}`\n\n logger.info(`\uD83D\uDD04 Checking out to ${branchName}...`)\n\n await $`git switch ${branchName}`\n\n logger.info(`\u2705 Switched to branch ${branchName}`)\n }\n\n logger.info('\u2705 All release branches were created successfully.')\n\n const structuredContent = {\n createdBranches: versionsList.map((version) => `release/v${version}`),\n branchCount: versionsList.length,\n isCheckedOut,\n }\n\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(structuredContent, null, 2),\n },\n ],\n structuredContent,\n }\n}\n\n// #region Declarations\n\n// Function to create a release branch\nasync function createReleaseBranch(version: string) {\n const branchName = `release/v${version}`\n\n logger.info(`Creating release branch ${branchName}...`)\n\n try {\n await $`git switch dev`\n await $`git pull origin dev`\n\n await $`git checkout -b ${branchName}`\n await $`git push -u origin ${branchName}`\n await $`git commit --allow-empty-message --allow-empty --message ''`\n await $`git push origin ${branchName}`\n\n // Create PR if not already exists (optional: you may want to check for existing PRs)\n await $`gh pr create --title \"Release v${version}\" --body \"Release v${version}\" --base dev --head ${branchName}`\n\n await $`git switch dev`\n logger.info(`\u2714\uFE0F Successfully created release branch: ${branchName}`)\n } catch (error: unknown) {\n logger.error({ error, branchName }, `Error creating release branch ${branchName}`)\n }\n}\n// #endregion Declarations\n\n// MCP Tool Registration\nconst ghReleaseCreateSchema = z.object({\n versions: z.string().describe('Comma-separated list of versions to create (e.g., \"1.2.5, 1.2.6\")'),\n checkout: z.boolean().optional().describe('Checkout to the created branch (only works with single version)'),\n})\n\nconst ghReleaseCreateOutputSchema = z.object({\n createdBranches: z.array(z.string()).describe('List of created release branches'),\n branchCount: z.number().describe('Number of branches created'),\n isCheckedOut: z.boolean().describe('Whether the branch was checked out'),\n})\n\nexport const ghReleaseCreateMcpTool = {\n name: 'gh-release-create',\n description: 'Create new release branches for specified versions',\n inputSchema: ghReleaseCreateSchema,\n outputSchema: ghReleaseCreateOutputSchema,\n handler: ghReleaseCreate,\n}\n", "import confirm from '@inquirer/confirm'\nimport select from '@inquirer/select'\nimport process from 'node:process'\nimport { z } from 'zod'\nimport { $ } from 'zx'\n\nimport { getReleasePRs } from 'src/shared/gh-release-prs'\nimport { logger } from 'src/shared/logger'\nimport type { RequiredConfirmedOptionArg, ToolsExecutionResult } from 'src/types'\n\ninterface GhReleaseDeliverArgs extends RequiredConfirmedOptionArg {\n version: string\n}\n\n/**\n * Deliver a release branch to production\n */\nexport const ghReleaseDeliver = async (args: GhReleaseDeliverArgs): Promise<ToolsExecutionResult> => {\n const { version, confirmedCommand } = args\n\n const releasePRsList = await getReleasePRs()\n\n let selectedReleaseBranch = '' // \"release/v1.8.0\"\n\n if (version) {\n selectedReleaseBranch = `release/v${version}`\n } else {\n selectedReleaseBranch = await select({\n message: '\uD83C\uDF3F Select release branch',\n choices: releasePRsList.map((pr) => ({\n name: pr.replace('release/v', ''),\n value: pr,\n })),\n })\n }\n\n // Check if release branch exists in the list\n if (!releasePRsList.includes(selectedReleaseBranch)) {\n logger.error(`\u274C Release branch ${selectedReleaseBranch} not found in open PRs. Exiting...`)\n process.exit(1)\n }\n\n const answer = confirmedCommand\n ? true\n : await confirm({\n message: `Are you sure you want to deliver version ${selectedReleaseBranch} to production?`,\n })\n\n if (!answer) {\n logger.info('Operation cancelled. Exiting...')\n process.exit(0)\n }\n\n try {\n await $`gh pr merge ${selectedReleaseBranch} --squash --admin --delete-branch` // TODO: add --body (AI for generate message)\n\n await $`gh pr create --base main --head dev --title \"Release v${selectedReleaseBranch.replace('release/v', '')} (RC)\" --body \"\"`\n\n await $`gh pr merge dev --squash --admin`\n\n await $`gh workflow run deploy-all.yml --ref main -f environment=prod`\n\n // Merge main into dev\n await $`git switch main && git pull && git switch dev && git pull && git merge main --no-edit && git push`\n\n logger.info('\\n')\n logger.info(`\u2714\uFE0F Successfully delivered ${selectedReleaseBranch} to production!`)\n\n const structuredContent = {\n releaseBranch: selectedReleaseBranch,\n version: selectedReleaseBranch.replace('release/v', ''),\n success: true,\n }\n\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(structuredContent, null, 2),\n },\n ],\n structuredContent,\n }\n } catch (error: unknown) {\n logger.error({ error }, '\u274C Error merging release branch into dev')\n process.exit(1)\n }\n}\n\n// MCP Tool Registration\nconst ghReleaseDeliverSchema = z.object({\n version: z.string().describe('Version to deliver to production (e.g., \"1.2.5\")'),\n})\n\nconst ghReleaseDeliverOutputSchema = z.object({\n releaseBranch: z.string().describe('The release branch that was delivered'),\n version: z.string().describe('The version that was delivered'),\n success: z.boolean().describe('Whether the delivery was successful'),\n})\n\nexport const ghReleaseDeliverMcpTool = {\n name: 'gh-release-deliver',\n description: 'Deliver a release branch to production',\n inputSchema: ghReleaseDeliverSchema,\n outputSchema: ghReleaseDeliverOutputSchema,\n handler: ghReleaseDeliver,\n}\n", "import select from '@inquirer/select'\nimport process from 'node:process'\nimport { z } from 'zod'\nimport { $ } from 'zx'\n\nimport { ENVs } from 'src/shared/constants'\nimport { getReleasePRs } from 'src/shared/gh-release-prs'\nimport { logger } from 'src/shared/logger'\nimport type { ToolsExecutionResult } from 'src/types'\n\ninterface GhReleaseDeployArgs {\n version: string\n env: string\n}\n\n/**\n * Deploy a release branch to an environment\n */\nexport const ghReleaseDeploy = async (args: GhReleaseDeployArgs): Promise<ToolsExecutionResult> => {\n const { version, env } = args\n\n // TODO: add validation for semver version for version variable\n\n const releasePRsList: string[] = ['dev'] // [\"release/v1.8.0\", \"release/v1.9.0\"]\n\n const releasePRs = await getReleasePRs()\n\n releasePRsList.push(...releasePRs)\n\n let selectedReleaseBranch = '' // \"release/v1.8.0\"\n\n if (version) {\n selectedReleaseBranch = `release/v${version}`\n } else {\n selectedReleaseBranch = await select({\n message: '\uD83C\uDF3F Select release branch',\n choices: releasePRsList.map((pr) => ({\n name: pr.replace('release/v', ''),\n value: pr,\n })),\n })\n }\n\n // Check if release branch exists in the list\n if (!releasePRsList.includes(selectedReleaseBranch)) {\n logger.error(`\u274C Release branch ${selectedReleaseBranch} not found in open PRs. Exiting...`)\n process.exit(1)\n }\n\n let selectedEnv = ''\n\n if (env) {\n selectedEnv = env\n } else {\n selectedEnv = await select({\n message: '\uD83E\uDDEA Select environment',\n choices: ENVs.map((env) => ({\n name: env,\n value: env,\n })),\n })\n }\n\n if (!ENVs.includes(selectedEnv)) {\n logger.error(`\u274C Invalid environment: ${selectedEnv}. Exiting...`)\n process.exit(1)\n }\n\n try {\n await $`gh workflow run deploy-all.yml --ref ${selectedReleaseBranch} -f environment=${selectedEnv}`\n\n logger.info('\\n')\n logger.info(\n `\u2705 Successfully launched deploy-all workflow_dispatch for release branch: ${selectedReleaseBranch} and environment: ${selectedEnv}`,\n )\n\n const structuredContent = {\n releaseBranch: selectedReleaseBranch,\n version: selectedReleaseBranch.replace('release/v', ''),\n environment: selectedEnv,\n success: true,\n }\n\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(structuredContent, null, 2),\n },\n ],\n structuredContent,\n }\n } catch (error: unknown) {\n logger.error({ error }, '\u274C Error launching workflow')\n process.exit(1)\n }\n}\n\n// MCP Tool Registration\nconst ghReleaseDeploySchema = z.object({\n version: z.string().describe('Version to deploy (e.g., \"1.2.5\")'),\n env: z.string().describe('Environment to deploy to (e.g., \"dev\", \"renana\", \"oriana\")'),\n})\n\nconst ghReleaseDeployOutputSchema = z.object({\n releaseBranch: z.string().describe('The release branch that was deployed'),\n version: z.string().describe('The version that was deployed'),\n environment: z.string().describe('The environment deployed to'),\n success: z.boolean().describe('Whether the deployment was successful'),\n})\n\nexport const ghReleaseDeployMcpTool = {\n name: 'gh-release-deploy',\n description: 'Deploy a release branch to a specified environment',\n inputSchema: ghReleaseDeploySchema,\n outputSchema: ghReleaseDeployOutputSchema,\n handler: ghReleaseDeploy,\n}\n", "import { z } from 'zod'\n\nimport { getReleasePRs } from 'src/shared/gh-release-prs'\nimport { logger } from 'src/shared/logger'\nimport { sortVersions } from 'src/shared/version-utils'\nimport type { ToolsExecutionResult } from 'src/types'\n\n/**\n * List all open release branches\n */\nexport const ghReleaseList = async (): Promise<ToolsExecutionResult> => {\n const releasePRs = await getReleasePRs()\n\n const releasePRsList = releasePRs.map((pr) => pr.replace('release/', ''))\n const sortedReleases = sortVersions(releasePRsList)\n\n logger.info('All release branches: \\n')\n logger.info(sortedReleases.join('\\n'))\n\n const structuredContent = {\n releases: sortedReleases,\n count: sortedReleases.length,\n }\n\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(structuredContent, null, 2),\n },\n ],\n structuredContent,\n }\n}\n\n// MCP Tool Registration\nconst ghReleaseListSchema = z.object({})\n\nconst ghReleaseListOutputSchema = z.object({\n releases: z.array(z.string()).describe('List of all release branches'),\n count: z.number().describe('Number of release branches'),\n})\n\nexport const ghReleaseListMcpTool = {\n name: 'gh-release-list',\n description: 'List all open release branches',\n inputSchema: ghReleaseListSchema,\n outputSchema: ghReleaseListOutputSchema,\n handler: ghReleaseList,\n}\n", "/**\n * Parse version string into major, minor, patch numbers\n */\nexport const parseVersion = (versionStr: string): [number, number, number] => {\n return versionStr.replace('release/', '').slice(1).split('.').map(Number) as [number, number, number]\n}\n\n/**\n * Sort version strings in ascending order\n */\nexport const sortVersions = (versions: string[]): string[] => {\n return versions.sort((a, b) => {\n const [majA, minA, patchA] = parseVersion(a)\n const [majB, minB, patchB] = parseVersion(b)\n\n if (majA !== majB) return (majA ?? 0) - (majB ?? 0)\n if (minA !== minB) return (minA ?? 0) - (minB ?? 0)\n return (patchA ?? 0) - (patchB ?? 0)\n })\n}\n", "import checkbox from '@inquirer/checkbox'\nimport confirm from '@inquirer/confirm'\nimport process from 'node:process'\nimport { z } from 'zod'\nimport { $ } from 'zx'\n\nimport { WORKTREES_DIR_SUFFIX } from 'src/shared/constants'\nimport { getReleasePRs } from 'src/shared/gh-release-prs'\nimport { getCurrentWorktrees, getProjectRoot } from 'src/shared/git-utils'\nimport { logger } from 'src/shared/logger'\nimport type { RequiredConfirmedOptionArg, ToolsExecutionResult } from 'src/types'\n\n// Constants\nconst FEATURE_DIR = 'feature'\nconst RELEASE_DIR = 'release'\nconst RELEASE_BRANCH_PREFIX = 'release/v'\n\ninterface WorktreeManagementArgs extends RequiredConfirmedOptionArg {\n all: boolean\n}\n\n/**\n * Manage git worktrees for release branches\n * Creates worktrees for active release branches and removes unused ones\n */\nexport const worktreesAdd = async (options: WorktreeManagementArgs): Promise<ToolsExecutionResult> => {\n const { confirmedCommand, all } = options\n\n try {\n const currentWorktrees = await getCurrentWorktrees('release')\n const projectRoot = await getProjectRoot()\n\n const worktreeDir = `${projectRoot}${WORKTREES_DIR_SUFFIX}`\n await ensureWorktreeDirectory(`${worktreeDir}/${RELEASE_DIR}`)\n await ensureWorktreeDirectory(`${worktreeDir}/${FEATURE_DIR}`)\n\n const releasePRsList = await getReleasePRs()\n\n let selectedReleaseBranches: string[] = []\n\n if (all) {\n selectedReleaseBranches = releasePRsList\n } else {\n selectedReleaseBranches = await checkbox({\n required: true,\n message: '\uD83C\uDF3F Select release branches',\n choices: releasePRsList.map((pr) => ({\n name: pr.replace('release/v', ''),\n value: pr,\n })),\n })\n }\n\n // Ask for confirmation\n const answer = confirmedCommand\n ? true\n : await confirm({\n message: 'Are you sure you want to proceed with these worktree changes?',\n })\n\n if (!answer) {\n logger.info('Operation cancelled. Exiting...')\n process.exit(0)\n }\n\n const { branchesToCreate } = categorizeWorktrees({\n selectedReleaseBranches,\n currentWorktrees,\n })\n\n const createdWorktrees = await createWorktrees(branchesToCreate, worktreeDir)\n\n logResults(createdWorktrees)\n\n const structuredContent = {\n createdWorktrees,\n count: createdWorktrees.length,\n }\n\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(structuredContent, null, 2),\n },\n ],\n structuredContent,\n }\n } catch (error) {\n logger.error({ error }, '\u274C Error managing worktrees')\n throw error\n }\n}\n\n/**\n * Ensure the worktree directory exists\n */\nconst ensureWorktreeDirectory = async (worktreeDir: string): Promise<void> => {\n await $`mkdir -p ${worktreeDir}`\n}\n\ninterface CategorizeWorktreesArgs {\n selectedReleaseBranches: string[]\n currentWorktrees: string[]\n}\n\n/**\n * Categorize release worktrees into those that need to be created or removed\n */\nconst categorizeWorktrees = (args: CategorizeWorktreesArgs): { branchesToCreate: string[] } => {\n const { selectedReleaseBranches, currentWorktrees } = args\n\n const currentBranchNames = currentWorktrees.filter((branch) => branch.startsWith(RELEASE_BRANCH_PREFIX))\n\n const branchesToCreate = selectedReleaseBranches.filter((branch) => !currentBranchNames.includes(branch))\n\n return { branchesToCreate }\n}\n\n/**\n * Create worktrees for the specified branches\n */\nconst createWorktrees = async (branches: string[], worktreeDir: string): Promise<string[]> => {\n const created: string[] = []\n\n for (const branch of branches) {\n try {\n const worktreePath = `${worktreeDir}/${branch}`\n\n await $`git worktree add ${worktreePath} ${branch}`\n\n created.push(branch)\n } catch (error) {\n logger.error({ error, branch }, `\u274C Failed to create worktree for ${branch}`)\n }\n }\n\n return created\n}\n\n/**\n * Log the results of worktree management\n */\nconst logResults = (created: string[]): void => {\n if (created.length > 0) {\n logger.info('\\n')\n logger.info('\u2705 Created worktrees:')\n logger.info(created.join('\\n'))\n logger.info('')\n } else {\n logger.info('\u2139\uFE0F No new worktrees to create')\n }\n}\n\n// MCP Tool Registration\nconst worktreesAddSchema = z.object({\n all: z.boolean().describe('Add worktrees for all release branches without prompting'),\n})\n\nconst worktreesAddOutputSchema = z.object({\n createdWorktrees: z.array(z.string()).describe('List of created worktree branches'),\n count: z.number().describe('Number of worktrees created'),\n})\n\nexport const worktreesAddMcpTool = {\n name: 'worktrees-add',\n description: 'Create worktrees for selected release branches',\n inputSchema: worktreesAddSchema,\n outputSchema: worktreesAddOutputSchema,\n handler: worktreesAdd,\n}\n", "import { $ } from 'zx'\n\n/**\n * Get current git worktrees\n *\n * @returns [release/v1.18.22, release/v1.18.23, release/v1.18.24] or [feature/mobile-app, feature/explore-page, feature/login-page]\n */\nexport const getCurrentWorktrees = async (type: 'release' | 'feature'): Promise<string[]> => {\n const worktreesOutput = await $`git worktree list`\n const worktreeLines = worktreesOutput.stdout.split('\\n').filter(Boolean)\n\n const worktreePredicateMap = {\n release: releaseWorktreePredicate,\n feature: featureWorktreePredicate,\n }\n\n return worktreeLines.map(worktreePredicateMap[type]).filter((branch) => branch !== null)\n}\n\nconst releaseWorktreePredicate = (line: string): string | null => {\n const parts = line.split(' ').filter(Boolean)\n\n if (parts.length < 3 || !parts[0]?.includes('release/v')) return null\n\n return `release/${parts[0]?.split('/').pop() || ''}`\n}\n\nconst featureWorktreePredicate = (line: string): string | null => {\n const parts = line.split(' ').filter(Boolean)\n\n if (parts.length < 3 || !parts[0]?.includes('feature/')) return null\n\n return `feature/${parts[0]?.split('/').pop() || ''}`\n}\n\n/**\n * Get the current project root directory\n */\nexport const getProjectRoot = async (): Promise<string> => {\n const result = await $`git rev-parse --show-toplevel`\n return result.stdout.trim()\n}\n", "import { z } from 'zod'\nimport { $ } from 'zx'\n\nimport { getCurrentWorktrees, getProjectRoot } from 'src/shared/git-utils'\nimport { logger } from 'src/shared/logger'\nimport type { ToolsExecutionResult } from 'src/types'\n\ninterface WorktreeInfo {\n branch: string\n path: string\n commit: string\n isCurrent: boolean\n type: 'release' | 'feature'\n status: string\n lastCommitMessage: string\n aheadBehind: string\n}\n\n/**\n * List all (features and releases) git worktrees with detailed information\n */\nexport const worktreesList = async (): Promise<ToolsExecutionResult> => {\n try {\n const [releaseWorktrees, featureWorktrees] = await Promise.all([\n getCurrentWorktrees('release'),\n getCurrentWorktrees('feature'),\n ])\n\n const projectRoot = await getProjectRoot()\n const worktreesInfo = await processWorktrees(releaseWorktrees, featureWorktrees, projectRoot)\n\n logResults(worktreesInfo)\n\n const structuredContent = {\n worktrees: worktreesInfo,\n totalCount: worktreesInfo.length,\n releaseCount: releaseWorktrees.length,\n featureCount: featureWorktrees.length,\n }\n\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(structuredContent, null, 2),\n },\n ],\n structuredContent,\n }\n } catch (error) {\n logger.error({ error }, '\u274C Error listing worktrees')\n throw error\n }\n}\n\n/**\n * Process worktrees to get detailed information\n */\nconst processWorktrees = async (\n releaseWorktrees: string[],\n featureWorktrees: string[],\n projectRoot: string,\n): Promise<WorktreeInfo[]> => {\n const allWorktrees = [\n ...releaseWorktrees.map((branch) => ({ branch, type: 'release' as const })),\n ...featureWorktrees.map((branch) => ({ branch, type: 'feature' as const })),\n ]\n\n const worktreesInfo: WorktreeInfo[] = []\n\n for (const { branch, type } of allWorktrees) {\n try {\n const worktreePath = `${projectRoot}/${branch}`\n const isCurrent = await isCurrentWorktree(branch)\n const commit = await getWorktreeCommit(worktreePath)\n const status = await getWorktreeStatus(worktreePath)\n const lastCommitMessage = await getLastCommitMessage(worktreePath)\n const aheadBehind = await getAheadBehind(worktreePath)\n\n worktreesInfo.push({\n branch,\n path: worktreePath,\n commit: commit.substring(0, 8),\n isCurrent,\n type,\n status,\n lastCommitMessage: lastCommitMessage.substring(0, 60) + (lastCommitMessage.length > 60 ? '...' : ''),\n aheadBehind,\n })\n } catch (error) {\n logger.warn({ error, branch }, `\u26A0\uFE0F Could not process worktree ${branch}`)\n }\n }\n\n return worktreesInfo.sort((a, b) => {\n // Sort by type first (releases before features), then by branch name\n if (a.type !== b.type) {\n return a.type === 'release' ? -1 : 1\n }\n return a.branch.localeCompare(b.branch)\n })\n}\n\n/**\n * Check if a worktree is currently active\n */\nconst isCurrentWorktree = async (branch: string): Promise<boolean> => {\n try {\n const currentBranch = await $`git branch --show-current`\n return currentBranch.stdout.trim() === branch\n } catch {\n return false\n }\n}\n\n/**\n * Get the commit hash for a worktree\n */\nconst getWorktreeCommit = async (worktreePath: string): Promise<string> => {\n try {\n const result = await $`cd ${worktreePath} && git rev-parse HEAD`\n return result.stdout.trim()\n } catch {\n return 'unknown'\n }\n}\n\n/**\n * Get the status of a worktree\n */\nconst getWorktreeStatus = async (worktreePath: string): Promise<string> => {\n try {\n const result = await $`cd ${worktreePath} && git status --porcelain`\n const changes = result.stdout.trim().split('\\n').filter(Boolean)\n\n if (changes.length === 0) return 'clean'\n if (changes.length <= 3) return 'modified'\n return 'dirty'\n } catch {\n return 'unknown'\n }\n}\n\n/**\n * Get the last commit message for a worktree\n */\nconst getLastCommitMessage = async (worktreePath: string): Promise<string> => {\n try {\n const result = await $`cd ${worktreePath} && git log -1 --pretty=format:\"%s\"`\n\n return result.stdout.trim()\n } catch {\n return 'No commit message available'\n }\n}\n\n/**\n * Get ahead/behind information for a worktree\n */\nconst getAheadBehind = async (worktreePath: string): Promise<string> => {\n try {\n const result =\n await $`cd ${worktreePath} && git rev-list --count --left-right @{u}...HEAD 2>/dev/null || echo \"0 0\"`\n\n const parts = result.stdout.trim().split('\\t').map(Number)\n const behind = parts[0] || 0\n const ahead = parts[1] || 0\n\n if (ahead === 0 && behind === 0) return 'up to date'\n if (ahead > 0 && behind === 0) return `\u2191${ahead} ahead`\n if (behind > 0 && ahead === 0) return `\u2193${behind} behind`\n\n return `\u2191${ahead} \u2193${behind}`\n } catch {\n return 'unknown'\n }\n}\n\n/**\n * Log the worktrees list in a beautiful formatted way\n */\nconst logResults = (worktrees: WorktreeInfo[]): void => {\n if (worktrees.length === 0) {\n logger.info('\\n\uD83C\uDF3F Git Worktrees')\n logger.info('\u2500'.repeat(80))\n logger.info('\u2139\uFE0F No worktrees found')\n logger.info('\u2500'.repeat(80))\n return\n }\n\n logger.info('\\n\uD83C\uDF3F Git Worktrees')\n logger.info('\u2550'.repeat(100))\n\n // Separate releases and features\n const releases = worktrees.filter((w) => w.type === 'release')\n const features = worktrees.filter((w) => w.type === 'feature')\n\n // Display releases first\n displayWorktreeSection('\uD83D\uDE80 Releases', releases)\n\n // Display features second\n if (features.length > 0 && releases.length > 0) {\n logger.info('')\n }\n\n displayWorktreeSection('\u2728 Features', features)\n\n // Summary\n const current = worktrees.find((w) => w.isCurrent)\n logger.info(`\\n${'\u2550'.repeat(100)}`)\n logger.info(\n `\uD83D\uDCCA Summary: ${worktrees.length} total worktrees (${releases.length} releases, ${features.length} features)`,\n )\n\n if (current) {\n logger.info(`\uD83D\uDCCD Currently on: ${current.branch}`)\n }\n\n logger.info('')\n}\n\n/**\n * Display a section of worktrees\n */\nconst displayWorktreeSection = (sectionTitle: string, worktrees: WorktreeInfo[]): void => {\n if (worktrees.length === 0) return\n\n logger.info(`\\n${sectionTitle}`)\n logger.info('\u2500'.repeat(50))\n\n for (const [index, worktree] of worktrees.entries()) {\n displayWorktree(worktree)\n\n if (index < worktrees.length - 1) {\n logger.info('')\n }\n }\n}\n\n/**\n * Display a single worktree entry\n */\nconst displayWorktree = (worktree: WorktreeInfo): void => {\n // Worktree status indicators\n const currentIndicator = worktree.isCurrent ? '\uD83D\uDCCD' : ' '\n const statusIndicator = getStatusIndicator(worktree.status)\n\n const typeIcon = worktree.type === 'release' ? '\uD83D\uDE80' : '\u2728'\n\n // Branch name with color coding\n const branchDisplay = `${typeIcon} ${worktree.branch}`\n\n logger.info(`${currentIndicator} ${statusIndicator} ${branchDisplay}`)\n\n // Commit and sync info\n const syncInfo = worktree.aheadBehind !== 'unknown' ? ` | ${worktree.aheadBehind}` : ''\n logger.info(` \uD83D\uDCDD ${worktree.commit}${syncInfo}`)\n\n // Last commit message\n logger.info(` \uD83D\uDCAC ${worktree.lastCommitMessage}`)\n\n // Path (shortened for display)\n const shortPath = worktree.path.split('/').slice(-2).join('/')\n logger.info(` \uD83D\uDCC1 ${shortPath}`)\n}\n\n/**\n * Get status indicator based on worktree status\n */\nconst getStatusIndicator = (status: string): string => {\n switch (status) {\n case 'clean':\n return '\u2705'\n case 'modified':\n return '\u26A0\uFE0F '\n case 'dirty':\n return '\uD83D\uDD34'\n default:\n return '\u2753'\n }\n}\n\n// MCP Tool Registration\nconst worktreesListSchema = z.object({})\n\nconst worktreesListOutputSchema = z.object({\n worktrees: z\n .array(\n z.object({\n branch: z.string(),\n path: z.string(),\n commit: z.string(),\n isCurrent: z.boolean(),\n type: z.enum(['release', 'feature']),\n status: z.string(),\n lastCommitMessage: z.string(),\n aheadBehind: z.string(),\n }),\n )\n .describe('List of all worktrees with details'),\n totalCount: z.number().describe('Total number of worktrees'),\n releaseCount: z.number().describe('Number of release worktrees'),\n featureCount: z.number().describe('Number of feature worktrees'),\n})\n\nexport const worktreesListMcpTool = {\n name: 'worktrees-list',\n description: 'List all git worktrees with detailed information',\n inputSchema: worktreesListSchema,\n outputSchema: worktreesListOutputSchema,\n handler: worktreesList,\n}\n", "import checkbox from '@inquirer/checkbox'\nimport confirm from '@inquirer/confirm'\nimport process from 'node:process'\nimport { z } from 'zod'\nimport { $ } from 'zx'\n\nimport { WORKTREES_DIR_SUFFIX } from 'src/shared/constants'\nimport { getCurrentWorktrees, getProjectRoot } from 'src/shared/git-utils'\nimport { logger } from 'src/shared/logger'\nimport type { RequiredConfirmedOptionArg, ToolsExecutionResult } from 'src/types'\n\n// Constants\ninterface WorktreeManagementArgs extends RequiredConfirmedOptionArg {\n all: boolean\n}\n\n/**\n * Manage git worktrees for release branches\n * Creates worktrees for active release branches and removes unused ones\n */\nexport const worktreesRemove = async (options: WorktreeManagementArgs): Promise<ToolsExecutionResult> => {\n const { confirmedCommand, all } = options\n\n try {\n const currentWorktrees = await getCurrentWorktrees('release')\n const projectRoot = await getProjectRoot()\n\n const worktreeDir = `${projectRoot}${WORKTREES_DIR_SUFFIX}`\n\n let selectedReleaseBranches: string[] = []\n\n if (all) {\n selectedReleaseBranches = currentWorktrees\n } else {\n selectedReleaseBranches = await checkbox({\n required: true,\n message: '\uD83C\uDF3F Select release branches',\n choices: currentWorktrees.map((pr) => ({\n name: pr.replace('release/v', ''),\n value: pr,\n })),\n })\n }\n\n // Ask for confirmation\n const answer = confirmedCommand\n ? true\n : await confirm({\n message: 'Are you sure you want to proceed with these worktree changes?',\n })\n\n if (!answer) {\n logger.info('Operation cancelled. Exiting...')\n process.exit(0)\n }\n\n const removedWorktrees = await removeWorktrees(selectedReleaseBranches, worktreeDir)\n\n logResults(removedWorktrees)\n\n const structuredContent = {\n removedWorktrees,\n count: removedWorktrees.length,\n }\n\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(structuredContent, null, 2),\n },\n ],\n structuredContent,\n }\n } catch (error) {\n logger.error({ error }, '\u274C Error managing worktrees')\n throw error\n }\n}\n\n/**\n * Remove worktrees for the specified branches\n */\nconst removeWorktrees = async (branches: string[], worktreeDir: string): Promise<string[]> => {\n const removed: string[] = []\n\n for (const branch of branches) {\n try {\n const worktreePath = `${worktreeDir}/${branch}`\n await $`git worktree remove ${worktreePath}`\n removed.push(branch)\n } catch (error) {\n logger.error({ error, branch }, `\u274C Failed to remove worktree for ${branch}`)\n }\n }\n\n return removed\n}\n\n/**\n * Log the results of worktree management\n */\nconst logResults = (removed: string[]): void => {\n if (removed.length > 0) {\n logger.info('\u274C Removed worktrees:')\n logger.info(removed.join('\\n'))\n logger.info('')\n } else {\n logger.info('\u2139\uFE0F No unused worktrees to remove')\n }\n}\n\n// MCP Tool Registration\nconst worktreesRemoveSchema = z.object({\n all: z.boolean().describe('Remove all worktrees without prompting'),\n})\n\nconst worktreesRemoveOutputSchema = z.object({\n removedWorktrees: z.array(z.string()).describe('List of removed worktree branches'),\n count: z.number().describe('Number of worktrees removed'),\n})\n\nexport const worktreesRemoveMcpTool = {\n name: 'worktrees-remove',\n description: 'Remove selected worktrees',\n inputSchema: worktreesRemoveSchema,\n outputSchema: worktreesRemoveOutputSchema,\n handler: worktreesRemove,\n}\n", "import confirm from '@inquirer/confirm'\nimport process from 'node:process'\nimport { z } from 'zod'\nimport { $ } from 'zx'\n\nimport { WORKTREES_DIR_SUFFIX } from 'src/shared/constants'\nimport { getReleasePRs } from 'src/shared/gh-release-prs'\nimport { getCurrentWorktrees, getProjectRoot } from 'src/shared/git-utils'\nimport { logger } from 'src/shared/logger'\nimport type { RequiredConfirmedOptionArg, ToolsExecutionResult } from 'src/types'\n\n// Constants\nconst RELEASE_BRANCH_PREFIX = 'release/v'\n\ninterface WorktreeSyncArgs extends RequiredConfirmedOptionArg {}\n\n/**\n * Manage git worktrees for release branches\n * Creates worktrees for active release branches and removes unused ones\n */\nexport const worktreesSync = async (options: WorktreeSyncArgs): Promise<ToolsExecutionResult> => {\n const { confirmedCommand } = options\n\n try {\n const currentWorktrees = await getCurrentWorktrees('release')\n const projectRoot = await getProjectRoot()\n\n const worktreeDir = `${projectRoot}${WORKTREES_DIR_SUFFIX}`\n\n const releasePRsList = await getReleasePRs()\n\n // Ask for confirmation\n const answer = confirmedCommand\n ? true\n : await confirm({\n message: 'Are you sure you want to proceed with these worktree changes?',\n })\n\n if (!answer) {\n logger.info('Operation cancelled. Exiting...')\n process.exit(0)\n }\n\n const { branchesToRemove } = categorizeWorktrees({\n releasePRsList,\n currentWorktrees,\n })\n\n const removedWorktrees = await removeWorktrees(branchesToRemove, worktreeDir)\n\n logResults(removedWorktrees)\n\n const structuredContent = {\n removedWorktrees,\n count: removedWorktrees.length,\n }\n\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(structuredContent, null, 2),\n },\n ],\n structuredContent,\n }\n } catch (error) {\n logger.error({ error }, '\u274C Error managing worktrees')\n throw error\n }\n}\n\ninterface CategorizeWorktreesArgs {\n releasePRsList: string[]\n currentWorktrees: string[]\n}\n\n/**\n * Categorize worktrees into those that need to be created or removed\n */\nconst categorizeWorktrees = (args: CategorizeWorktreesArgs): { branchesToRemove: string[] } => {\n const { releasePRsList, currentWorktrees } = args\n\n const currentBranchNames = currentWorktrees.filter((branch) => branch.startsWith(RELEASE_BRANCH_PREFIX))\n\n const branchesToRemove = currentBranchNames.filter((branch) => !releasePRsList.includes(branch))\n\n return { branchesToRemove }\n}\n\n/**\n * Remove worktrees for the specified branches\n */\nconst removeWorktrees = async (branches: string[], worktreeDir: string): Promise<string[]> => {\n const removed: string[] = []\n\n for (const branch of branches) {\n try {\n const worktreePath = `${worktreeDir}/${branch}`\n await $`git worktree remove ${worktreePath}`\n removed.push(branch)\n } catch (error) {\n logger.error({ error, branch }, `\u274C Failed to remove worktree for ${branch}`)\n }\n }\n\n return removed\n}\n\n/**\n * Log the results of worktree management\n */\nconst logResults = (removed: string[]): void => {\n if (removed.length > 0) {\n logger.info('\u274C Removed worktrees:')\n logger.info(removed.join('\\n'))\n logger.info('')\n } else {\n logger.info('\u2139\uFE0F No unused worktrees to remove')\n }\n}\n\n// MCP Tool Registration\nconst worktreesSyncSchema = z.object({})\n\nconst worktreesSyncOutputSchema = z.object({\n removedWorktrees: z.array(z.string()).describe('List of removed worktree branches'),\n count: z.number().describe('Number of worktrees removed during sync'),\n})\n\nexport const worktreesSyncMcpTool = {\n name: 'worktrees-sync',\n description: 'Synchronize worktrees with active release branches',\n inputSchema: worktreesSyncSchema,\n outputSchema: worktreesSyncOutputSchema,\n handler: worktreesSync,\n}\n", "import type { ToolsExecutionResult } from 'src/types'\n\nimport { logger } from '../logger'\n\ninterface ToolHandlerArgs {\n toolName: string\n handler: (params: any) => Promise<ToolsExecutionResult>\n}\n\nexport const createToolHandler = (args: ToolHandlerArgs) => async (params: unknown) => {\n const { toolName, handler } = args\n\n logger.info({ msg: `Tool execution started: ${toolName}`, params })\n try {\n const payload = await handler({ ...(params as object), confirmedCommand: true })\n\n logger.info({ msg: `Tool execution successful: ${toolName}` })\n\n return payload\n } catch (error) {\n logger.error({\n err: error,\n params,\n msg: `Tool execution failed: ${toolName}`,\n })\n\n throw error\n }\n}\n", "import type { Server } from '@modelcontextprotocol/sdk/server/index'\n\nimport { ghMergeDevMcpTool } from 'src/commands/gh-merge-dev'\nimport { ghReleaseCreateMcpTool } from 'src/commands/gh-release-create'\nimport { ghReleaseDeliverMcpTool } from 'src/commands/gh-release-deliver'\nimport { ghReleaseDeployMcpTool } from 'src/commands/gh-release-deploy'\nimport { ghReleaseListMcpTool } from 'src/commands/gh-release-list'\nimport { worktreesAddMcpTool } from 'src/commands/worktrees-add'\nimport { worktreesListMcpTool } from 'src/commands/worktrees-list'\nimport { worktreesRemoveMcpTool } from 'src/commands/worktrees-remove'\nimport { worktreesSyncMcpTool } from 'src/commands/worktrees-sync'\nimport { createToolHandler } from 'src/shared/tool-handler'\n\nconst tools = [\n ghMergeDevMcpTool,\n ghReleaseCreateMcpTool,\n ghReleaseDeliverMcpTool,\n ghReleaseDeployMcpTool,\n ghReleaseListMcpTool,\n worktreesAddMcpTool,\n worktreesListMcpTool,\n worktreesRemoveMcpTool,\n worktreesSyncMcpTool,\n]\n\nexport const initializeTools = async (server: Server) => {\n for (const tool of tools) {\n // eslint-disable-next-line ts/ban-ts-comment\n // @ts-expect-error\n server.registerTool(\n tool.name,\n {\n description: tool.description,\n inputSchema: tool.inputSchema,\n outputSchema: tool.outputSchema,\n handler: tool.handler,\n },\n createToolHandler({ toolName: tool.name, handler: tool.handler }),\n )\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,wBAAAA,OAA4B,yCACrC,OAAOC,OAAa,eCDpB,OAAOC,MAAa,eCGb,IAAMC,EAAO,CAAC,MAAO,SAAU,SAAU,QAAS,SAAU,QAAQ,EAE9DC,EAAuB,aAEvBC,EAAgB,yBDItB,IAAMC,EAAsBC,GAAmB,CACpDC,EAAQ,GAAG,SAAU,IAAM,CACzBD,EAAO,KAAK,CAAE,IAAK,mCAAoC,CAAC,EACxDC,EAAQ,KAAK,CAAC,CAChB,CAAC,EAEDA,EAAQ,GAAG,UAAW,IAAM,CAC1BD,EAAO,KAAK,CAAE,IAAK,oCAAqC,CAAC,EACzDC,EAAQ,KAAK,CAAC,CAChB,CAAC,EAEDA,EAAQ,GAAG,oBAAsBC,GAAU,CACzCF,EAAO,MAAM,CAAE,IAAKE,EAAO,IAAK,oBAAqB,CAAC,EACtDF,EAAO,MAAM,6BAA6BG,CAAa,oBAAoB,EAC3EH,EAAO,MAAM,EACbC,EAAQ,KAAK,CAAC,CAChB,CAAC,EAEDA,EAAQ,GAAG,qBAAsB,CAACG,EAAQC,IAAY,CACpDL,EAAO,MAAM,CAAE,OAAAI,EAAQ,QAAAC,EA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AAK,CAAE,IAAK,uCAAwC,CAAC,CAC9D,OAASK,EAAO,CACdL,EAAO,MAAM,CAAE,IAAKK,EAAO,IAAK,6BAA8B,CAAC,EAC/DL,EAAO,MAAM,2CAA2C,EAExDM,GAAQ,KAAK,CAAC,CAChB,CACF,EAGAG,EAAmBT,CAAM,EAGzBE,GAAY",
|
|
6
|
+
"names": ["StdioServerTransport", "process", "process", "ENVs", "WORKTREES_DIR_SUFFIX", "LOG_FILE_PATH", "setupErrorHandlers", "logger", "process", "error", "LOG_FILE_PATH", "reason", "promise", "process", "pino", "pretty", "initLoggerMcp", "logLevel", "process", "logger", "pino", "LOG_FILE_PATH", "initLoggerCLI", "ignoreFields", "pretty", "Server", "initializePrompts", "_server", "initializeResources", "_server", "checkbox", "confirm", "process", "z", "$", "process", "$", "logger", "initLoggerCLI", "getReleasePRs", "releasePRs", "$", "releasePRsArray", "logger", "process", "pr", "error", "ghMergeDev", "args", "all", "confirmedCommand", "releasePRsList", "getReleasePRs", "selectedReleaseBranches", "checkbox", "pr", "confirm", "logger", "process", "$", "failedBranches", "branch", "mergeDev", "structuredContent", "error", "ghMergeDevSchema", "z", "ghMergeDevOutputSchema", "ghMergeDevMcpTool", "confirm", "process", "z", "$", "question", "ghReleaseCreate", "args", "versions", "confirmedCommand", "checkout", "versionBranches", "_checkout", "question", "versionsList", "version", "logger", "process", "confirm", "$", "createReleaseBranch", "isCheckedOut", "branchName", "structuredContent", "error", "ghReleaseCreateSchema", "z", "ghReleaseCreateOutputSchema", "ghReleaseCreateMcpTool", "confirm", "select", "process", "z", "$", "ghReleaseDeliver", "args", "version", "confirmedCommand", "releasePRsList", "getReleasePRs", "selectedReleaseBranch", "select", "pr", "logger", "process", "confirm", "$", "structuredContent", "error", "ghReleaseDeliverSchema", "z", "ghReleaseDeliverOutputSchema", "ghReleaseDeliverMcpTool", "select", "process", "z", "$", "ghReleaseDeploy", "args", "version", "env", "releasePRsList", "releasePRs", "getReleasePRs", "selectedReleaseBranch", "select", "pr", "logger", "process", "selectedEnv", "ENVs", "$", "structuredContent", "error", "ghReleaseDeploySchema", "z", "ghReleaseDeployOutputSchema", "ghReleaseDeployMcpTool", "z", "parseVersion", "versionStr", "sortVersions", "versions", "a", "b", "majA", "minA", "patchA", "majB", "minB", "patchB", "ghReleaseList", "releasePRsList", "getReleasePRs", "pr", "sortedReleases", "sortVersions", "logger", "structuredContent", "ghReleaseListSchema", "z", "ghReleaseListOutputSchema", "ghReleaseListMcpTool", "checkbox", "confirm", "process", "z", "$", "$", "getCurrentWorktrees", "type", "worktreeLines", "worktreePredicateMap", "releaseWorktreePredicate", "featureWorktreePredicate", "branch", "line", "parts", "getProjectRoot", "FEATURE_DIR", "RELEASE_DIR", "RELEASE_BRANCH_PREFIX", "worktreesAdd", "options", "confirmedCommand", "all", "currentWorktrees", "getCurrentWorktrees", "worktreeDir", "getProjectRoot", "WORKTREES_DIR_SUFFIX", "ensureWorktreeDirectory", "releasePRsList", "getReleasePRs", "selectedReleaseBranches", "checkbox", "pr", "confirm", "logger", "process", "branchesToCreate", "categorizeWorktrees", "createdWorktrees", "createWorktrees", "logResults", "structuredContent", "error", "$", "args", "currentBranchNames", "branch", "branches", "created", "worktreePath", "worktreesAddSchema", "z", "worktreesAddOutputSchema", "worktreesAddMcpTool", "z", "$", "worktreesList", "releaseWorktrees", "featureWorktrees", "getCurrentWorktrees", "projectRoot", "getProjectRoot", "worktreesInfo", "processWorktrees", "logResults", "structuredContent", "error", "logger", "allWorktrees", "branch", "type", "worktreePath", "isCurrent", "isCurrentWorktree", "commit", "getWorktreeCommit", "status", "getWorktreeStatus", "lastCommitMessage", "getLastCommitMessage", "aheadBehind", "getAheadBehind", "b", "$", "changes", "parts", "behind", "ahead", "worktrees", "releases", "w", "features", "displayWorktreeSection", "current", "sectionTitle", "index", "worktree", "displayWorktree", "currentIndicator", "statusIndicator", "getStatusIndicator", "branchDisplay", "syncInfo", "shortPath", "worktreesListSchema", "z", "worktreesListOutputSchema", "worktreesListMcpTool", "checkbox", "confirm", "process", "z", "$", "worktreesRemove", "options", "confirmedCommand", "all", "currentWorktrees", "getCurrentWorktrees", "worktreeDir", "getProjectRoot", "WORKTREES_DIR_SUFFIX", "selectedReleaseBranches", "checkbox", "pr", "confirm", "logger", "process", "removedWorktrees", "removeWorktrees", "logResults", "structuredContent", "error", "branches", "removed", "branch", "worktreePath", "$", "worktreesRemoveSchema", "z", "worktreesRemoveOutputSchema", "worktreesRemoveMcpTool", "confirm", "process", "z", "$", "RELEASE_BRANCH_PREFIX", "worktreesSync", "options", "confirmedCommand", "currentWorktrees", "getCurrentWorktrees", "worktreeDir", "getProjectRoot", "WORKTREES_DIR_SUFFIX", "releasePRsList", "getReleasePRs", "confirm", "logger", "process", "branchesToRemove", "categorizeWorktrees", "removedWorktrees", "removeWorktrees", "logResults", "structuredContent", "error", "args", "branch", "branches", "removed", "worktreePath", "$", "worktreesSyncSchema", "z", "worktreesSyncOutputSchema", "worktreesSyncMcpTool", "createToolHandler", "args", "params", "toolName", "handler", "logger", "payload", "error", "tools", "ghMergeDevMcpTool", "ghReleaseCreateMcpTool", "ghReleaseDeliverMcpTool", "ghReleaseDeployMcpTool", "ghReleaseListMcpTool", "worktreesAddMcpTool", "worktreesListMcpTool", "worktreesRemoveMcpTool", "worktreesSyncMcpTool", "initializeTools", "server", "tool", "createToolHandler", "logger", "initLoggerMcp", "createMcpServer", "server", "Server", "initializePrompts", "initializeResources", "initializeTools", "logger", "initLoggerMcp", "startServer", "server", "createMcpServer", "error", "process", "transport", "StdioServerTransport", "setupErrorHandlers"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "infra-kit",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.41",
|
|
5
5
|
"description": "infra-kit",
|
|
6
6
|
"main": "dist/cli.js",
|
|
7
7
|
"module": "dist/cli.js",
|
|
@@ -32,9 +32,10 @@
|
|
|
32
32
|
"@inquirer/checkbox": "^4.2.4",
|
|
33
33
|
"@inquirer/confirm": "^5.1.18",
|
|
34
34
|
"@inquirer/select": "^4.3.4",
|
|
35
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
35
|
+
"@modelcontextprotocol/sdk": "^1.20.0",
|
|
36
36
|
"commander": "^14.0.1",
|
|
37
37
|
"pino": "^10.0.0",
|
|
38
|
+
"pino-pretty": "^13.1.2",
|
|
38
39
|
"zod": "^3.25.76",
|
|
39
40
|
"zx": "^8.8.4"
|
|
40
41
|
},
|
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
1
|
import checkbox from '@inquirer/checkbox'
|
|
3
2
|
import confirm from '@inquirer/confirm'
|
|
4
3
|
import process from 'node:process'
|
|
4
|
+
import { z } from 'zod'
|
|
5
5
|
import { $ } from 'zx'
|
|
6
6
|
|
|
7
7
|
import { getReleasePRs } from 'src/shared/gh-release-prs'
|
|
8
|
+
import { logger } from 'src/shared/logger'
|
|
9
|
+
import type { RequiredConfirmedOptionArg, ToolsExecutionResult } from 'src/types'
|
|
8
10
|
|
|
9
|
-
interface GhMergeDevArgs {
|
|
11
|
+
interface GhMergeDevArgs extends RequiredConfirmedOptionArg {
|
|
10
12
|
all: boolean
|
|
11
|
-
yes: boolean
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* Merge dev into every release branch
|
|
16
17
|
*/
|
|
17
|
-
export const ghMergeDev = async (args: GhMergeDevArgs): Promise<
|
|
18
|
-
const { all,
|
|
18
|
+
export const ghMergeDev = async (args: GhMergeDevArgs): Promise<ToolsExecutionResult> => {
|
|
19
|
+
const { all, confirmedCommand } = args
|
|
19
20
|
|
|
20
21
|
const releasePRsList = await getReleasePRs()
|
|
21
22
|
|
|
@@ -40,14 +41,14 @@ export const ghMergeDev = async (args: GhMergeDevArgs): Promise<{ failedBranches
|
|
|
40
41
|
// process.exit(1)
|
|
41
42
|
// }
|
|
42
43
|
|
|
43
|
-
const answer =
|
|
44
|
+
const answer = confirmedCommand
|
|
44
45
|
? true
|
|
45
46
|
: await confirm({
|
|
46
47
|
message: `Are you sure you want to merge dev into these branches: ${selectedReleaseBranches.join(', ')}?`,
|
|
47
48
|
})
|
|
48
49
|
|
|
49
50
|
if (!answer) {
|
|
50
|
-
|
|
51
|
+
logger.info('Operation cancelled. Exiting...')
|
|
51
52
|
process.exit(0)
|
|
52
53
|
}
|
|
53
54
|
|
|
@@ -71,29 +72,44 @@ export const ghMergeDev = async (args: GhMergeDevArgs): Promise<{ failedBranches
|
|
|
71
72
|
$.quiet = false
|
|
72
73
|
|
|
73
74
|
if (failedBranches.length > 0) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
logger.info(`\n⚠️ ${failedBranches.length} branch(es) failed to merge automatically.\n`)
|
|
76
|
+
logger.info('📋 Manual merge script for failed branches:\n')
|
|
77
|
+
logger.info('```bash')
|
|
77
78
|
for (const branch of failedBranches) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
79
|
+
logger.info(`# Merge dev into ${branch}`)
|
|
80
|
+
logger.info(`git switch ${branch} && git pull origin ${branch} && git merge origin/dev`)
|
|
81
|
+
logger.info(`# Resolve conflicts if any, then:`)
|
|
82
|
+
logger.info(`git push origin ${branch} && git switch dev`)
|
|
83
|
+
logger.info('')
|
|
83
84
|
}
|
|
84
|
-
|
|
85
|
-
|
|
85
|
+
logger.info('```\n')
|
|
86
|
+
logger.info(
|
|
86
87
|
`✅ ${selectedReleaseBranches.length - failedBranches.length}/${selectedReleaseBranches.length} merges completed successfully.`,
|
|
87
88
|
)
|
|
88
89
|
} else {
|
|
89
|
-
|
|
90
|
+
logger.info('✅ All merges completed successfully!')
|
|
90
91
|
}
|
|
91
92
|
|
|
92
|
-
|
|
93
|
+
const structuredContent = {
|
|
94
|
+
successfulMerges: selectedReleaseBranches.length - failedBranches.length,
|
|
95
|
+
failedMerges: failedBranches.length,
|
|
96
|
+
failedBranches,
|
|
97
|
+
totalBranches: selectedReleaseBranches.length,
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return {
|
|
101
|
+
content: [
|
|
102
|
+
{
|
|
103
|
+
type: 'text',
|
|
104
|
+
text: JSON.stringify(structuredContent, null, 2),
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
structuredContent,
|
|
108
|
+
}
|
|
93
109
|
}
|
|
94
110
|
|
|
95
111
|
const mergeDev = async (branch: string): Promise<boolean> => {
|
|
96
|
-
|
|
112
|
+
logger.info(`Merging dev into ${branch}...`)
|
|
97
113
|
|
|
98
114
|
try {
|
|
99
115
|
await $`git switch ${branch}`
|
|
@@ -106,13 +122,34 @@ const mergeDev = async (branch: string): Promise<boolean> => {
|
|
|
106
122
|
|
|
107
123
|
await $`git switch dev`
|
|
108
124
|
|
|
109
|
-
|
|
125
|
+
logger.info(`✔️ Successfully merged dev into ${branch}`)
|
|
126
|
+
|
|
110
127
|
return true
|
|
111
128
|
} catch (error: unknown) {
|
|
112
|
-
|
|
129
|
+
logger.error({ error, branch }, `❌ Error merging dev into ${branch}`)
|
|
113
130
|
|
|
114
131
|
await $`git reset --merge HEAD~1`
|
|
115
132
|
|
|
116
133
|
return false
|
|
117
134
|
}
|
|
118
135
|
}
|
|
136
|
+
|
|
137
|
+
// MCP Tool Registration
|
|
138
|
+
const ghMergeDevSchema = z.object({
|
|
139
|
+
all: z.boolean().describe('Merge dev into all release branches without prompting'),
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
const ghMergeDevOutputSchema = z.object({
|
|
143
|
+
successfulMerges: z.number().describe('Number of successful merges'),
|
|
144
|
+
failedMerges: z.number().describe('Number of failed merges'),
|
|
145
|
+
failedBranches: z.array(z.string()).describe('List of branches that failed to merge'),
|
|
146
|
+
totalBranches: z.number().describe('Total number of branches processed'),
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
export const ghMergeDevMcpTool = {
|
|
150
|
+
name: 'gh-merge-dev',
|
|
151
|
+
description: 'Merge dev branch into selected release branches',
|
|
152
|
+
inputSchema: ghMergeDevSchema,
|
|
153
|
+
outputSchema: ghMergeDevOutputSchema,
|
|
154
|
+
handler: ghMergeDev,
|
|
155
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { ghMergeDev } from './gh-merge-dev'
|
|
1
|
+
export { ghMergeDev, ghMergeDevMcpTool } from './gh-merge-dev'
|
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
1
|
import confirm from '@inquirer/confirm'
|
|
3
2
|
import process from 'node:process'
|
|
3
|
+
import { z } from 'zod'
|
|
4
4
|
import { $, question } from 'zx'
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
import { logger } from 'src/shared/logger'
|
|
7
|
+
import type { RequiredConfirmedOptionArg, ToolsExecutionResult } from 'src/types'
|
|
8
|
+
|
|
9
|
+
interface GhReleaseCreateArgs extends RequiredConfirmedOptionArg {
|
|
7
10
|
versions: string
|
|
8
|
-
yes: boolean
|
|
9
11
|
checkout?: boolean
|
|
10
12
|
}
|
|
11
13
|
|
|
12
14
|
/**
|
|
13
15
|
* Create release branches for a given version
|
|
14
16
|
*/
|
|
15
|
-
export const ghReleaseCreate = async (args: GhReleaseCreateArgs): Promise<
|
|
16
|
-
const { versions,
|
|
17
|
+
export const ghReleaseCreate = async (args: GhReleaseCreateArgs): Promise<ToolsExecutionResult> => {
|
|
18
|
+
const { versions, confirmedCommand, checkout } = args
|
|
17
19
|
|
|
18
20
|
let versionBranches = ''
|
|
19
21
|
let _checkout = checkout
|
|
@@ -28,13 +30,13 @@ export const ghReleaseCreate = async (args: GhReleaseCreateArgs): Promise<string
|
|
|
28
30
|
|
|
29
31
|
// Validate input
|
|
30
32
|
if (versionsList.length === 0) {
|
|
31
|
-
|
|
33
|
+
logger.error('No versions provided. Exiting...')
|
|
32
34
|
process.exit(1)
|
|
33
35
|
}
|
|
34
36
|
|
|
35
37
|
// Warn user if checkout option is used with multiple branches
|
|
36
38
|
if (_checkout && versionsList.length > 1) {
|
|
37
|
-
|
|
39
|
+
logger.warn(
|
|
38
40
|
'⚠️ Checkout option is ignored when creating multiple branches. Only works with single branch creation.',
|
|
39
41
|
)
|
|
40
42
|
}
|
|
@@ -45,14 +47,14 @@ export const ghReleaseCreate = async (args: GhReleaseCreateArgs): Promise<string
|
|
|
45
47
|
})
|
|
46
48
|
}
|
|
47
49
|
|
|
48
|
-
const answer =
|
|
50
|
+
const answer = confirmedCommand
|
|
49
51
|
? true
|
|
50
52
|
: await confirm({
|
|
51
53
|
message: `Are you sure you want to create release branches for these versions: ${versionsList.join(', ')}?`,
|
|
52
54
|
})
|
|
53
55
|
|
|
54
56
|
if (!answer) {
|
|
55
|
-
|
|
57
|
+
logger.info('Operation cancelled. Exiting...')
|
|
56
58
|
process.exit(0)
|
|
57
59
|
}
|
|
58
60
|
|
|
@@ -68,16 +70,35 @@ export const ghReleaseCreate = async (args: GhReleaseCreateArgs): Promise<string
|
|
|
68
70
|
}
|
|
69
71
|
|
|
70
72
|
// If checkout option is enabled and we created only one branch, checkout to it
|
|
71
|
-
|
|
73
|
+
const isCheckedOut = _checkout && versionsList.length === 1
|
|
74
|
+
|
|
75
|
+
if (isCheckedOut) {
|
|
72
76
|
const branchName = `release/v${versionsList[0]}`
|
|
73
|
-
|
|
77
|
+
|
|
78
|
+
logger.info(`🔄 Checking out to ${branchName}...`)
|
|
79
|
+
|
|
74
80
|
await $`git switch ${branchName}`
|
|
75
|
-
|
|
81
|
+
|
|
82
|
+
logger.info(`✅ Switched to branch ${branchName}`)
|
|
76
83
|
}
|
|
77
84
|
|
|
78
|
-
|
|
85
|
+
logger.info('✅ All release branches were created successfully.')
|
|
79
86
|
|
|
80
|
-
|
|
87
|
+
const structuredContent = {
|
|
88
|
+
createdBranches: versionsList.map((version) => `release/v${version}`),
|
|
89
|
+
branchCount: versionsList.length,
|
|
90
|
+
isCheckedOut,
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return {
|
|
94
|
+
content: [
|
|
95
|
+
{
|
|
96
|
+
type: 'text',
|
|
97
|
+
text: JSON.stringify(structuredContent, null, 2),
|
|
98
|
+
},
|
|
99
|
+
],
|
|
100
|
+
structuredContent,
|
|
101
|
+
}
|
|
81
102
|
}
|
|
82
103
|
|
|
83
104
|
// #region Declarations
|
|
@@ -86,7 +107,7 @@ export const ghReleaseCreate = async (args: GhReleaseCreateArgs): Promise<string
|
|
|
86
107
|
async function createReleaseBranch(version: string) {
|
|
87
108
|
const branchName = `release/v${version}`
|
|
88
109
|
|
|
89
|
-
|
|
110
|
+
logger.info(`Creating release branch ${branchName}...`)
|
|
90
111
|
|
|
91
112
|
try {
|
|
92
113
|
await $`git switch dev`
|
|
@@ -101,12 +122,29 @@ async function createReleaseBranch(version: string) {
|
|
|
101
122
|
await $`gh pr create --title "Release v${version}" --body "Release v${version}" --base dev --head ${branchName}`
|
|
102
123
|
|
|
103
124
|
await $`git switch dev`
|
|
104
|
-
|
|
125
|
+
logger.info(`✔️ Successfully created release branch: ${branchName}`)
|
|
105
126
|
} catch (error: unknown) {
|
|
106
|
-
|
|
107
|
-
`Error creating release branch ${branchName}:`,
|
|
108
|
-
error instanceof Error ? error.message : 'Unknown error',
|
|
109
|
-
)
|
|
127
|
+
logger.error({ error, branchName }, `Error creating release branch ${branchName}`)
|
|
110
128
|
}
|
|
111
129
|
}
|
|
112
130
|
// #endregion Declarations
|
|
131
|
+
|
|
132
|
+
// MCP Tool Registration
|
|
133
|
+
const ghReleaseCreateSchema = z.object({
|
|
134
|
+
versions: z.string().describe('Comma-separated list of versions to create (e.g., "1.2.5, 1.2.6")'),
|
|
135
|
+
checkout: z.boolean().optional().describe('Checkout to the created branch (only works with single version)'),
|
|
136
|
+
})
|
|
137
|
+
|
|
138
|
+
const ghReleaseCreateOutputSchema = z.object({
|
|
139
|
+
createdBranches: z.array(z.string()).describe('List of created release branches'),
|
|
140
|
+
branchCount: z.number().describe('Number of branches created'),
|
|
141
|
+
isCheckedOut: z.boolean().describe('Whether the branch was checked out'),
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
export const ghReleaseCreateMcpTool = {
|
|
145
|
+
name: 'gh-release-create',
|
|
146
|
+
description: 'Create new release branches for specified versions',
|
|
147
|
+
inputSchema: ghReleaseCreateSchema,
|
|
148
|
+
outputSchema: ghReleaseCreateOutputSchema,
|
|
149
|
+
handler: ghReleaseCreate,
|
|
150
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { ghReleaseCreate } from './gh-release-create'
|
|
1
|
+
export { ghReleaseCreate, ghReleaseCreateMcpTool } from './gh-release-create'
|