infra-kit 0.1.98 → 0.1.99

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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/lib/logger/index.ts", "../src/mcp/server.ts", "../src/mcp/prompts/index.ts", "../src/mcp/resources/index.ts", "../src/commands/env-clear/env-clear.ts", "../src/lib/constants.ts", "../src/commands/env-list/env-list.ts", "../src/lib/infra-kit-config/infra-kit-config.ts", "../src/lib/git-utils/git-utils.ts", "../src/integrations/doppler/doppler-project.ts", "../src/commands/env-load/env-load.ts", "../src/integrations/doppler/doppler-cli-auth.ts", "../src/lib/command-echo/command-echo.ts", "../src/commands/env-status/env-status.ts", "../src/commands/gh-merge-dev/gh-merge-dev.ts", "../src/integrations/gh/gh-cli-auth/gh-cli-auth.ts", "../src/integrations/gh/gh-release-prs/gh-release-prs.ts", "../src/lib/release-utils/release-utils.ts", "../src/integrations/jira/api.ts", "../src/lib/version-utils/load-existing-versions.ts", "../src/lib/version-utils/version-utils.ts", "../src/lib/version-utils/next-version.ts", "../src/commands/gh-release-deliver/gh-release-deliver.ts", "../src/commands/gh-release-deploy-all/gh-release-deploy-all.ts", "../src/commands/gh-release-deploy-selected/gh-release-deploy-selected.ts", "../src/commands/gh-release-list/gh-release-list.ts", "../src/commands/release-create/release-create.ts", "../src/commands/release-create-batch/release-create-batch.ts", "../src/commands/version/version.ts", "../package.json", "../src/commands/worktrees-add/worktrees-add.ts", "../src/integrations/cmux/close-workspace-by-title.ts", "../src/integrations/cmux/list-workspace-titles.ts", "../src/integrations/cmux/open-workspace-with-layout.ts", "../src/integrations/cmux/workspace-title.ts", "../src/integrations/cursor/add-folders-to-workspace.ts", "../src/integrations/cursor/reconcile-workspace-folders.ts", "../src/integrations/cursor/remove-folders-from-workspace.ts", "../src/integrations/cursor/resolve-workspace-path.ts", "../src/commands/worktrees-list/worktrees-list.ts", "../src/commands/worktrees-open/worktrees-open.ts", "../src/commands/worktrees-remove/worktrees-remove.ts", "../src/commands/worktrees-sync/worktrees-sync.ts", "../src/lib/tool-handler/tool-handler.ts", "../src/mcp/tools/index.ts"],
4
- "sourcesContent": ["import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'\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\n try {\n server = await createMcpServer()\n\n logger.info('MCP Server instance created')\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 '../logger/index'\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", "import process from 'node:process'\nimport pino from 'pino'\nimport pretty from 'pino-pretty'\n\n// eslint-disable-next-line sonarjs/publicly-writable-directories\nexport const LOG_FILE_PATH = '/tmp/mcp-infra-kit.log'\n\nexport const initLoggerMcp = () => {\n const logLevel = process.argv.includes('--debug') ? 'debug' : 'info'\n\n const logger = pino({ level: logLevel }, pino.destination({ dest: LOG_FILE_PATH }))\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 destination: 2,\n ignore: ignoreFields.join(','),\n colorize: true,\n }),\n )\n\n return logger\n}\n\n// Singleton logger instance for CLI usage\nexport const logger = initLoggerCLI()\n", "import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\n\nimport { initializePrompts } from './prompts'\nimport { initializeResources } from './resources'\nimport { initializeTools } from './tools'\n\nexport async function createMcpServer() {\n const server = new McpServer(\n {\n name: 'infra-kit',\n version: '1.0.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 return server\n}\n", "import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\n\nexport const initializePrompts = async (_server: McpServer) => {}\n", "import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\n\nexport const initializeResources = async (_server: McpServer) => {}\n", "import fs from 'node:fs'\nimport path from 'node:path'\nimport process from 'node:process'\nimport { z } from 'zod/v4'\n\nimport {\n ENV_CLEAR_FILE,\n ENV_LOAD_FILE,\n INFRA_KIT_ENV_CONFIG_VAR,\n INFRA_KIT_ENV_LOADED_AT_VAR,\n INFRA_KIT_ENV_PROJECT_VAR,\n atomicWriteFileSync,\n getSessionCacheDir,\n parseVarNamesFromEnvFile,\n} from 'src/lib/constants'\nimport type { ToolsExecutionResult } from 'src/types'\n\n/**\n * Clear loaded env vars. Prints a file path to stdout that must be sourced to apply.\n * The env-clear shell alias does this automatically. Throws when no env is loaded\n * so CLI callers exit non-zero and MCP callers receive a structured tool error.\n */\nexport const envClear = async (): Promise<ToolsExecutionResult> => {\n const cacheDir = getSessionCacheDir()\n const envLoadPath = path.join(cacheDir, ENV_LOAD_FILE)\n\n if (!fs.existsSync(envLoadPath)) {\n throw new Error('No loaded environment found. Run `env-load` first.')\n }\n\n const varNames = parseVarNamesFromEnvFile(envLoadPath)\n\n const unsetLines = [\n ...varNames.map((v) => {\n return `unset ${v}`\n }),\n `unset ${INFRA_KIT_ENV_CONFIG_VAR}`,\n `unset ${INFRA_KIT_ENV_PROJECT_VAR}`,\n `unset ${INFRA_KIT_ENV_LOADED_AT_VAR}`,\n ]\n\n const clearFilePath = path.resolve(cacheDir, ENV_CLEAR_FILE)\n\n fs.mkdirSync(cacheDir, { recursive: true, mode: 0o700 })\n\n atomicWriteFileSync(clearFilePath, `${unsetLines.join('\\n')}\\n`, 0o600)\n\n // REQUIRED\n process.stdout.write(`${clearFilePath}\\n`)\n\n // Remove env load file so the next env-clear call correctly reports \"no env loaded\".\n fs.unlinkSync(envLoadPath)\n\n const structuredContent = {\n filePath: clearFilePath,\n variableCount: varNames.length,\n unsetStatements: unsetLines,\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\nexport const envClearMcpTool = {\n name: 'env-clear',\n description:\n 'Generate a shell script that unsets every env var previously loaded by env-load for this session, plus the infra-kit session metadata vars. Does NOT mutate the calling process. When `infra-kit init` has installed the zsh shell integration, the user\\'s terminal auto-sources the unset script on its next prompt (precmd hook) \u2014 so calling this via MCP will clear the vars in the shell that launched Claude Code automatically. Other callers must source \"<filePath>\" themselves or surface it to the user. Errors if no env is currently loaded.',\n inputSchema: {},\n outputSchema: {\n filePath: z.string().describe('Path to the file that must be sourced to apply'),\n variableCount: z.number().describe('Number of variables cleared'),\n unsetStatements: z.array(z.string()).describe('Unset statements generated'),\n },\n handler: envClear,\n}\n", "import fs from 'node:fs'\nimport os from 'node:os'\nimport path from 'node:path'\nimport process from 'node:process'\n\nexport const ENV_LOAD_FILE = 'env-load.sh'\nexport const ENV_CLEAR_FILE = 'env-clear.sh'\n\nexport const INFRA_KIT_SESSION_VAR = 'INFRA_KIT_SESSION'\nexport const INFRA_KIT_ENV_CONFIG_VAR = 'INFRA_KIT_ENV_CONFIG'\nexport const INFRA_KIT_ENV_PROJECT_VAR = 'INFRA_KIT_ENV_PROJECT'\nexport const INFRA_KIT_ENV_LOADED_AT_VAR = 'INFRA_KIT_ENV_LOADED_AT'\n\n/**\n * Matches a line of the form `KEY=...` where KEY is an env-var identifier\n * (letter or underscore, then word chars). Capture group 1 is the name. Shared\n * between env-load (validation, var counting) and parseVarNamesFromEnvFile.\n */\nexport const ENV_VAR_LINE_PATTERN = /^([A-Z_]\\w*)=/i\n\nexport const parseVarNamesFromEnvFile = (filePath: string): string[] => {\n if (!fs.existsSync(filePath)) return []\n\n const content = fs.readFileSync(filePath, 'utf-8')\n const names: string[] = []\n\n for (const line of content.split('\\n')) {\n const match = ENV_VAR_LINE_PATTERN.exec(line)\n\n if (match) {\n names.push(match[1]!)\n }\n }\n\n return names\n}\n\n/**\n * Root cache dir for infra-kit across all sessions. Resolved from\n * $XDG_CACHE_HOME when set, falling back to ~/.cache/infra-kit. Keep in sync\n * with the shell block emitted by `infra-kit init` (src/commands/init/init.ts).\n */\nexport const getCacheRoot = (): string => {\n const xdg = process.env.XDG_CACHE_HOME\n const base = xdg && xdg.length > 0 ? xdg : path.join(os.homedir(), '.cache')\n\n return path.join(base, 'infra-kit')\n}\n\nexport const getSessionCacheDir = (): string => {\n const session = process.env[INFRA_KIT_SESSION_VAR]\n\n if (!session) {\n throw new Error(`${INFRA_KIT_SESSION_VAR} is not set. Run \\`infra-kit init\\` then \\`source ~/.zshrc\\`.`)\n }\n\n return path.join(getCacheRoot(), session)\n}\n\n/**\n * Write content atomically: write to a pid-suffixed temp file in the same\n * directory, then rename. fs.renameSync is atomic on a single filesystem, so\n * concurrent writers can't produce a half-written secret file.\n */\nexport const atomicWriteFileSync = (filePath: string, content: string, mode: number): void => {\n const tmpPath = `${filePath}.tmp.${process.pid}`\n\n fs.writeFileSync(tmpPath, content, { mode })\n\n try {\n fs.renameSync(tmpPath, filePath)\n } catch (error) {\n fs.rmSync(tmpPath, { force: true })\n throw error\n }\n}\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 { z } from 'zod/v4'\n\nimport { getDopplerProject } from 'src/integrations/doppler/doppler-project'\nimport { getInfraKitConfig } from 'src/lib/infra-kit-config'\nimport { logger } from 'src/lib/logger'\nimport type { ToolsExecutionResult } from 'src/types'\n\n/**\n * List available Doppler configs for the detected project.\n *\n * Purely local: reads infra-kit.yml and does not call Doppler. We intentionally\n * do not run validateDopplerCliAndAuth here \u2014 users listing envs often do so\n * before `doppler login`, and a spurious auth error would be misleading.\n */\nexport const envList = async (): Promise<ToolsExecutionResult> => {\n const project = await getDopplerProject()\n const { environments } = await getInfraKitConfig()\n\n logger.info(`Doppler project: ${project}\\n`)\n logger.info('Available configs:')\n\n for (const env of environments) {\n logger.info(` - ${env}`)\n }\n\n const structuredContent = {\n project,\n configs: environments,\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\nexport const envListMcpTool = {\n name: 'env-list',\n description:\n 'List the environments the project is configured to support. Returns the `environments` list declared in infra-kit.yml at the project root (not a live fetch from Doppler) plus the Doppler project name resolved from the same file. Read-only.',\n inputSchema: {},\n outputSchema: {\n project: z.string().describe('Detected Doppler project name'),\n configs: z.array(z.string()).describe('Available environment configs'),\n },\n handler: envList,\n}\n", "import fs from 'node:fs/promises'\nimport os from 'node:os'\nimport path from 'node:path'\nimport yaml from 'yaml'\nimport { z } from 'zod/v4'\n\nimport { getProjectRoot, getRepoName } from 'src/lib/git-utils'\n\nconst INFRA_KIT_CONFIG_FILE = 'infra-kit.yml'\n\nconst USER_CONFIG_DIR_NAME = '.infra-kit'\nconst USER_GLOBAL_CONFIG_FILE = 'config.yml'\nconst USER_PROJECTS_DIR = 'projects'\n\n// envManagement\nconst dopplerEnvManagementSchema = z.object({\n provider: z.literal('doppler'),\n config: z.object({\n name: z.string().min(1),\n }),\n})\n\nconst envManagementSchema = z.discriminatedUnion('provider', [dopplerEnvManagementSchema])\n\n// ide\nconst cursorIdeConfigSchema = z\n .object({\n mode: z.enum(['workspace', 'windows']).default('workspace'),\n workspaceConfigPath: z.string().min(1).optional(),\n })\n .refine(\n (v) => {\n return v.mode !== 'workspace' || !!v.workspaceConfigPath\n },\n {\n message: 'workspaceConfigPath is required when mode is \"workspace\"',\n path: ['workspaceConfigPath'],\n },\n )\n\nconst cursorIdeSchema = z.object({\n provider: z.literal('cursor'),\n config: cursorIdeConfigSchema,\n})\n\nconst ideSchema = z.discriminatedUnion('provider', [cursorIdeSchema])\n\n// taskManager\nconst jiraTaskManagerSchema = z.object({\n provider: z.literal('jira'),\n config: z.object({\n baseUrl: z.string().url(),\n projectId: z.number().int().positive(),\n }),\n})\n\nconst taskManagerSchema = z.discriminatedUnion('provider', [jiraTaskManagerSchema])\n\nconst infraKitConfigSchema = z.object({\n environments: z.array(z.string().min(1)).min(1),\n envManagement: envManagementSchema,\n ide: ideSchema.optional(),\n taskManager: taskManagerSchema.optional(),\n})\n\nconst infraKitOverrideConfigSchema = infraKitConfigSchema.partial()\n\nexport type InfraKitConfig = z.infer<typeof infraKitConfigSchema>\n\nexport interface InfraKitConfigPaths {\n /** Committed project config (required). */\n main: string\n /** User-scope global overrides applied to every project. */\n userGlobal: string\n /** User-scope per-project overrides \u2014 `<userProjectsDir>/<projectName>/infra-kit.yml`. */\n userProject: string\n /** Repo basename (`path.basename(projectRoot)`) used to namespace the user-project file. */\n projectName: string\n}\n\ninterface CacheEntry {\n mtimes: Record<keyof Omit<InfraKitConfigPaths, 'projectName'>, number | null>\n value: InfraKitConfig\n}\n\nlet cached: CacheEntry | null = null\n\n/**\n * Resolve every file path that participates in the config merge chain. Always\n * returns paths even for files that don't yet exist, so callers can use them\n * for \"where would my override go?\" prompts.\n *\n * @example\n * const paths = await getInfraKitConfigPaths()\n * // {\n * // main: '/Users/arthur/projects/api/infra-kit.yml',\n * // userGlobal: '/Users/arthur/.infra-kit/config.yml',\n * // userProject: '/Users/arthur/.infra-kit/projects/api/infra-kit.yml',\n * // projectName: 'api',\n * // }\n */\nexport const getInfraKitConfigPaths = async (): Promise<InfraKitConfigPaths> => {\n const projectRoot = await getProjectRoot()\n const projectName = await getRepoName()\n const userConfigDir = path.join(os.homedir(), USER_CONFIG_DIR_NAME)\n\n return {\n main: path.join(projectRoot, INFRA_KIT_CONFIG_FILE),\n userGlobal: path.join(userConfigDir, USER_GLOBAL_CONFIG_FILE),\n userProject: path.join(userConfigDir, USER_PROJECTS_DIR, projectName, INFRA_KIT_CONFIG_FILE),\n projectName,\n }\n}\n\n/**\n * Read and validate `infra-kit.yml`, with optional override layers shallow-merged\n * on top in this order (later wins):\n * 1. project `infra-kit.yml` \u2014 committed source of truth\n * 2. `~/.infra-kit/config.yml` \u2014 user-global defaults\n * 3. `~/.infra-kit/projects/<repo-name>/infra-kit.yml` \u2014 user-scope per-project overrides\n *\n * Top-level keys (entire capability sections like `ide`, `envManagement`)\n * replace wholesale. Results are cached per file mtimes so the long-running\n * MCP server picks up edits without a restart.\n *\n * @example\n * // infra-kit.yml: { environments: ['dev'], envManagement: { provider: 'doppler', config: { name: 'p' } } }\n * // ~/.infra-kit/config.yml: { ide: { provider: 'cursor', config: { mode: 'windows' } } }\n * const cfg = await getInfraKitConfig()\n * // => { environments: ['dev'], envManagement: {...}, ide: { provider: 'cursor', config: { mode: 'windows' } } }\n */\nexport const getInfraKitConfig = async (): Promise<InfraKitConfig> => {\n const paths = await getInfraKitConfigPaths()\n\n let mainStat: Awaited<ReturnType<typeof fs.stat>>\n\n try {\n mainStat = await fs.stat(paths.main)\n } catch {\n cached = null\n throw new Error(`infra-kit.yml not found at ${paths.main}`)\n }\n\n const [userGlobalStat, userProjectStat] = await Promise.all([\n statIfExists(paths.userGlobal),\n statIfExists(paths.userProject),\n ])\n\n const mtimes = {\n main: Number(mainStat.mtimeMs),\n userGlobal: userGlobalStat ? Number(userGlobalStat.mtimeMs) : null,\n userProject: userProjectStat ? Number(userProjectStat.mtimeMs) : null,\n }\n\n if (cached && shallowEqual(cached.mtimes, mtimes)) {\n return cached.value\n }\n\n const layers: ConfigLayer[] = [\n { label: 'infra-kit.yml', path: paths.main, required: true },\n { label: '~/.infra-kit/config.yml', path: paths.userGlobal, required: false },\n {\n label: `~/.infra-kit/projects/${paths.projectName}/infra-kit.yml`,\n path: paths.userProject,\n required: false,\n },\n ]\n\n let merged: Record<string, unknown> = {}\n\n for (const layer of layers) {\n const data = await loadLayer(layer)\n\n if (data === null) continue\n\n merged = { ...merged, ...data }\n }\n\n const finalResult = infraKitConfigSchema.safeParse(merged)\n\n if (!finalResult.success) {\n throw new Error(`Invalid merged infra-kit config: ${z.prettifyError(finalResult.error)}`)\n }\n\n cached = { mtimes, value: finalResult.data }\n\n return finalResult.data\n}\n\n/**\n * For tests \u2014 drops the in-memory cache so the next read hits disk.\n *\n * @example\n * resetInfraKitConfigCache()\n * await getInfraKitConfig() // re-reads files even if mtimes look unchanged\n */\nexport const resetInfraKitConfigCache = (): void => {\n cached = null\n}\n\n/**\n * `fs.stat` that returns `null` instead of throwing on ENOENT. Used so the\n * resolver can probe optional files in the merge chain without try/catch noise.\n *\n * @example\n * const stat = await statIfExists('/does/not/exist') // => null\n */\nconst statIfExists = async (filePath: string): Promise<Awaited<ReturnType<typeof fs.stat>> | null> => {\n try {\n return await fs.stat(filePath)\n } catch {\n return null\n }\n}\n\n/**\n * `fs.readFile` that returns `null` instead of throwing on ENOENT.\n *\n * @example\n * const raw = await readIfExists('/missing.yml') // => null\n * const raw = await readIfExists('/exists.yml') // => 'environments: [dev]\\n'\n */\nconst readIfExists = async (filePath: string): Promise<string | null> => {\n try {\n return await fs.readFile(filePath, 'utf-8')\n } catch {\n return null\n }\n}\n\n/**\n * Reference-equality comparison of every key in two flat records. Used to\n * cheaply detect whether the cached mtime fingerprint still matches.\n *\n * @example\n * shallowEqual({ a: 1, b: 2 }, { a: 1, b: 2 }) // => true\n * shallowEqual({ a: 1 }, { a: 1, b: 2 }) // => false\n * shallowEqual({ a: 1 }, { a: 2 }) // => false\n */\nconst shallowEqual = <T extends Record<string, unknown>>(a: T, b: T): boolean => {\n const keys = Object.keys(a)\n\n if (keys.length !== Object.keys(b).length) return false\n\n return keys.every((k) => {\n return a[k] === b[k]\n })\n}\n\ninterface ConfigLayer {\n label: string\n path: string\n required: boolean\n}\n\n/**\n * Read a single layer of the merge chain: parse the YAML if the file exists\n * and validate it against the override schema. Returns `null` if an optional\n * layer is missing; throws if the layer is required or invalid.\n *\n * @example\n * await loadLayer({ label: '~/.infra-kit/config.yml', path: '/missing.yml', required: false })\n * // => null\n *\n * @example\n * // /home/me/.infra-kit/config.yml: 'ide:\\n provider: cursor\\n config: { mode: windows }'\n * await loadLayer({ label: '~/.infra-kit/config.yml', path: '/home/me/.infra-kit/config.yml', required: false })\n * // => { ide: { provider: 'cursor', config: { mode: 'windows' } } }\n */\nconst loadLayer = async (layer: ConfigLayer): Promise<Record<string, unknown> | null> => {\n const raw = await readIfExists(layer.path)\n\n if (raw === null) {\n if (layer.required) {\n throw new Error(`${layer.label} not found at ${layer.path}`)\n }\n\n return null\n }\n\n const parsedRaw = yaml.parse(raw) ?? {}\n const result = infraKitOverrideConfigSchema.safeParse(parsedRaw)\n\n if (!result.success) {\n throw new Error(`Invalid ${layer.label} at ${layer.path}: ${z.prettifyError(result.error)}`)\n }\n\n return result.data as Record<string, unknown>\n}\n", "import path from 'node:path'\nimport { $ } 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\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) => {\n return branch !== null\n })\n}\n\n/**\n * Extract the branch name from a `git worktree list` output line.\n *\n * `git worktree list` formats each line as:\n * <path> <hash> [<branch>]\n *\n * Reads the branch from the trailing `[branch]` token so it works for the\n * main checkout too (whose path does not encode the branch name).\n */\nconst parseWorktreeBranch = (line: string): string | null => {\n const trimmed = line.trimEnd()\n\n if (!trimmed.endsWith(']')) return null\n\n const open = trimmed.lastIndexOf('[')\n\n if (open === -1) return null\n\n const branch = trimmed.slice(open + 1, -1)\n\n return branch.length > 0 ? branch : null\n}\n\n/**\n * Extract a release branch name from a `git worktree list` output line.\n *\n * Returns `null` for lines that are not release worktrees.\n *\n * @example\n * releaseWorktreePredicate('/path/to/release/v1.18.22 abc1234 [release/v1.18.22]')\n * // => 'release/v1.18.22'\n *\n * @example\n * releaseWorktreePredicate('/path/to/feature/login abc1234 [feature/login]')\n * // => null\n */\nconst releaseWorktreePredicate = (line: string): string | null => {\n const branch = parseWorktreeBranch(line)\n\n return branch?.startsWith('release/v') ? branch : null\n}\n\n/**\n * Extract a feature branch name from a `git worktree list` output line.\n *\n * Returns `null` for lines that are not feature worktrees.\n *\n * @example\n * featureWorktreePredicate('/path/to/feature/login-page abc1234 [feature/login-page]')\n * // => 'feature/login-page'\n *\n * @example\n * featureWorktreePredicate('/path/to/release/v1.18.22 abc1234 [release/v1.18.22]')\n * // => null\n */\nconst featureWorktreePredicate = (line: string): string | null => {\n const branch = parseWorktreeBranch(line)\n\n return branch?.startsWith('feature/') ? branch : null\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\n return result.stdout.trim()\n}\n\n/**\n * Get the current repository name (basename of the project root)\n */\nexport const getRepoName = async (): Promise<string> => {\n const projectRoot = await getProjectRoot()\n\n return path.basename(projectRoot)\n}\n", "import { getInfraKitConfig } from 'src/lib/infra-kit-config'\n\n/**\n * Resolve Doppler project name from infra-kit.yml at the project root\n */\nexport const getDopplerProject = async (): Promise<string> => {\n const { envManagement } = await getInfraKitConfig()\n\n return envManagement.config.name\n}\n", "import select from '@inquirer/select'\nimport { Buffer } from 'node:buffer'\nimport fs from 'node:fs'\nimport path from 'node:path'\nimport process from 'node:process'\nimport { z } from 'zod/v4'\nimport { $ } from 'zx'\n\nimport { validateDopplerCliAndAuth } from 'src/integrations/doppler'\nimport { getDopplerProject } from 'src/integrations/doppler/doppler-project'\nimport { commandEcho } from 'src/lib/command-echo'\nimport {\n ENV_LOAD_FILE,\n ENV_VAR_LINE_PATTERN,\n INFRA_KIT_ENV_CONFIG_VAR,\n INFRA_KIT_ENV_LOADED_AT_VAR,\n INFRA_KIT_ENV_PROJECT_VAR,\n atomicWriteFileSync,\n getSessionCacheDir,\n} from 'src/lib/constants'\nimport { getInfraKitConfig } from 'src/lib/infra-kit-config'\nimport type { ToolsExecutionResult } from 'src/types'\n\ninterface EnvLoadArgs {\n config?: string\n}\n\n/**\n * Load environment variables from Doppler for the given config\n */\nexport const envLoad = async (args: EnvLoadArgs): Promise<ToolsExecutionResult> => {\n await validateDopplerCliAndAuth()\n\n const { config } = args\n\n commandEcho.start('env-load')\n\n let selectedConfig = ''\n\n if (config) {\n selectedConfig = config\n } else {\n const { environments } = await getInfraKitConfig()\n\n commandEcho.setInteractive()\n selectedConfig = await select(\n {\n message: 'Select environment config',\n choices: environments.map((env) => {\n return { name: env, value: env }\n }),\n },\n // Render to stderr so the prompt is visible when stdout is captured via $() in the shell function.\n // Only env-load and env-clear use the $() stdout-capture shell pattern.\n { output: process.stderr },\n )\n }\n\n commandEcho.addOption('--config', selectedConfig)\n\n const project = await getDopplerProject()\n\n const envContent = await downloadDopplerSecrets(project, selectedConfig)\n\n assertValidEnvContent(envContent)\n\n // Build env file content in dotenv format\n const loadedAt = new Date().toISOString()\n const envFileLines = [\n 'set -a',\n envContent,\n `${INFRA_KIT_ENV_CONFIG_VAR}=${shellSingleQuote(selectedConfig)}`,\n `${INFRA_KIT_ENV_PROJECT_VAR}=${shellSingleQuote(project)}`,\n `${INFRA_KIT_ENV_LOADED_AT_VAR}=${shellSingleQuote(loadedAt)}`,\n 'set +a',\n ]\n\n const cacheDir = getSessionCacheDir()\n const envFilePath = path.resolve(cacheDir, ENV_LOAD_FILE)\n\n fs.mkdirSync(cacheDir, { recursive: true, mode: 0o700 })\n atomicWriteFileSync(envFilePath, `${envFileLines.join('\\n')}\\n`, 0o600)\n\n // REQUIRED\n process.stdout.write(`${envFilePath}\\n`)\n\n // Logs to stderr (pino \u2192 pretty-print), so it doesn't pollute the captured\n // file path that the shell wrapper reads from stdout.\n commandEcho.print()\n\n const varCount = countEnvVarLines(envContent)\n\n const structuredContent = {\n filePath: envFilePath,\n variableCount: varCount,\n project,\n config: selectedConfig,\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/**\n * Cap the Doppler stdout we're willing to accept. A well-formed env bundle is\n * O(10 KB); megabytes would indicate a service regression or the wrong stream\n * being captured, and we don't want to write that to disk or source it.\n */\nexport const DOPPLER_MAX_OUTPUT_BYTES = 1024 * 1024\n\n/**\n * Hard upper bound for the Doppler subprocess. Well under zx's default so a\n * hung call surfaces quickly instead of blocking an interactive shell or an\n * MCP tool handler.\n */\nconst DOPPLER_DOWNLOAD_TIMEOUT_MS = 30_000\n\nconst downloadDopplerSecrets = async (project: string, config: string): Promise<string> => {\n const prevQuiet = $.quiet\n\n $.quiet = true\n try {\n const result =\n await $`doppler secrets download --no-file --format env --project ${project} --config ${config}`.timeout(\n DOPPLER_DOWNLOAD_TIMEOUT_MS,\n )\n\n assertDopplerOutputSize(result.stdout)\n\n return result.stdout.trim()\n } finally {\n $.quiet = prevQuiet\n }\n}\n\nexport const assertDopplerOutputSize = (stdout: string): void => {\n const bytes = Buffer.byteLength(stdout, 'utf-8')\n\n if (bytes > DOPPLER_MAX_OUTPUT_BYTES) {\n throw new Error(\n `doppler returned unexpectedly large output (${bytes} bytes > ${DOPPLER_MAX_OUTPUT_BYTES}) \u2014 refusing to write to disk`,\n )\n }\n}\n\nconst countEnvVarLines = (content: string): number => {\n return content.split('\\n').filter((line) => {\n return ENV_VAR_LINE_PATTERN.test(line)\n }).length\n}\n\nconst SHELL_DIRECTIVE_LINES = new Set(['set -a', 'set +a'])\n\nexport const shellSingleQuote = (value: string): string => {\n const escaped = value.replaceAll(\"'\", \"'\\\\''\")\n\n return `'${escaped}'`\n}\n\n/**\n * Guard against Doppler returning non-env output (auth warnings on stdout,\n * partial downloads, HTML error pages, etc.). Every non-blank, non-directive\n * line must match KEY=VALUE \u2014 skipping directives keeps future format tweaks\n * cheap without loosening the check.\n */\nexport const assertValidEnvContent = (content: string): void => {\n if (content.trim().length === 0) {\n throw new Error('doppler returned empty output for env-load')\n }\n\n for (const line of content.split('\\n')) {\n const trimmed = line.trim()\n\n if (trimmed.length === 0 || SHELL_DIRECTIVE_LINES.has(trimmed)) continue\n\n if (!ENV_VAR_LINE_PATTERN.test(trimmed)) {\n throw new Error(\n `doppler returned unexpected output for env-load (expected KEY=value lines, got: ${JSON.stringify(trimmed.slice(0, 80))})`,\n )\n }\n }\n}\n\n// MCP Tool Registration\nexport const envLoadMcpTool = {\n name: 'env-load',\n description:\n 'Download the env vars for a Doppler config and write them to a temporary shell script. Does NOT mutate the calling process \u2014 returns the path to a script that must be sourced (\"source <filePath>\") for the vars to take effect. The infra-kit shell wrapper auto-sources; direct MCP callers must handle sourcing themselves or surface filePath to the user. \"config\" is required when invoked via MCP (the CLI interactive picker is unreachable without a TTY).',\n inputSchema: {\n config: z\n .string()\n .describe('Doppler config / environment name to load (e.g. \"dev\", \"arthur\", \"renana\"). Required for MCP calls.'),\n },\n outputSchema: {\n filePath: z.string().describe('Path to the file that must be sourced to apply variables'),\n variableCount: z.number().describe('Number of variables loaded'),\n project: z.string().describe('Doppler project name'),\n config: z.string().describe('Doppler config name'),\n },\n handler: envLoad,\n}\n", "import { $ } from 'zx'\n\n/**\n * Validate Doppler CLI installation and authentication status. Throws on failure\n * so callers (CLI entry, MCP tool handler) can translate to the right surface \u2014\n * CLI exits non-zero; MCP returns a structured tool error instead of tearing\n * down the server.\n */\nexport const validateDopplerCliAndAuth = async (): Promise<void> => {\n try {\n await $`doppler --version`\n } catch (error: unknown) {\n throw new Error('Doppler CLI is not installed. Install it from: https://docs.doppler.com/docs/install-cli', {\n cause: error,\n })\n }\n\n try {\n await $`doppler me`\n } catch (error: unknown) {\n throw new Error('Doppler CLI is not authenticated. Run: doppler login', { cause: error })\n }\n}\n", "import { logger } from 'src/lib/logger'\n\ninterface CommandOption {\n flag: string\n value: string | string[] | boolean\n}\n\nconst createCommandEcho = () => {\n let commandName = ''\n let options: CommandOption[] = []\n let isInteractive = false\n\n return {\n /**\n * Initialize command echo for a new command\n */\n start(name: string): void {\n commandName = name\n options = []\n isInteractive = false\n },\n\n /**\n * Mark that the command had interactive input (prompts)\n * Call this once when ANY prompt happens\n */\n setInteractive(): void {\n isInteractive = true\n },\n\n /**\n * Track an option selection\n * @param flag The CLI flag (e.g., \"--versions\")\n * @param value The selected value\n */\n addOption(flag: string, value: string | string[] | boolean): void {\n options.push({ flag, value })\n },\n\n /**\n * Print the equivalent CLI command if there was interactive input\n */\n print(): void {\n if (!isInteractive || options.length === 0) {\n return\n }\n\n const formattedOptions = options\n .map((opt) => {\n if (typeof opt.value === 'boolean') {\n return opt.value ? opt.flag : ''\n }\n\n if (Array.isArray(opt.value)) {\n return `${opt.flag} \"${opt.value.join(', ')}\"`\n }\n\n return `${opt.flag} \"${opt.value}\"`\n })\n .filter(Boolean)\n .join(' ')\n\n logger.info(`\uD83D\uDCDF Equivalent command: \\npnpm exec infra-kit ${commandName} ${formattedOptions}\\n`)\n },\n\n /**\n * Reset state (useful for testing)\n */\n reset(): void {\n commandName = ''\n options = []\n isInteractive = false\n },\n }\n}\n\n// Singleton instance (same pattern as logger)\nexport const commandEcho = createCommandEcho()\n", "import path from 'node:path'\nimport process from 'node:process'\nimport { z } from 'zod/v4'\n\nimport { validateDopplerCliAndAuth } from 'src/integrations/doppler'\nimport {\n ENV_LOAD_FILE,\n INFRA_KIT_ENV_CONFIG_VAR,\n INFRA_KIT_ENV_LOADED_AT_VAR,\n INFRA_KIT_ENV_PROJECT_VAR,\n INFRA_KIT_SESSION_VAR,\n getSessionCacheDir,\n parseVarNamesFromEnvFile,\n} from 'src/lib/constants'\nimport { logger } from 'src/lib/logger'\nimport type { ToolsExecutionResult } from 'src/types'\n\n/**\n * Show Doppler authentication status and detected project info\n */\nexport const envStatus = async (): Promise<ToolsExecutionResult> => {\n await validateDopplerCliAndAuth()\n\n logger.info('Environment session status:')\n\n // Check session-loaded vars \u2014 getSessionCacheDir() throws if INFRA_KIT_SESSION is unset\n const cacheDir = getSessionCacheDir()\n\n const sessionId = process.env[INFRA_KIT_SESSION_VAR]!\n const envLoadPath = path.join(cacheDir, ENV_LOAD_FILE)\n\n let sessionLoadedCount = 0\n let sessionTotalCount = 0\n\n const sessionConfig = process.env[INFRA_KIT_ENV_CONFIG_VAR] ?? null\n const sessionProject = process.env[INFRA_KIT_ENV_PROJECT_VAR] ?? null\n const sessionLoadedAt = process.env[INFRA_KIT_ENV_LOADED_AT_VAR] ?? null\n\n if (sessionConfig) {\n const varNames = parseVarNamesFromEnvFile(envLoadPath)\n\n if (varNames.length > 0) {\n sessionTotalCount = varNames.length\n sessionLoadedCount = varNames.filter((v) => {\n return v in process.env\n }).length\n }\n\n const loadedAtDisplay = sessionLoadedAt?.replace(/\\.\\d{3}Z$/, '') ?? null\n\n logger.info(\n ` ${sessionConfig}: ${sessionLoadedCount} of ${sessionTotalCount} vars loaded (project: ${sessionProject}, loadedAt: ${loadedAtDisplay}, session: ${sessionId})\\n`,\n )\n\n if (sessionTotalCount > 0 && sessionLoadedCount < sessionTotalCount) {\n const missing = sessionTotalCount - sessionLoadedCount\n\n logger.warn(\n ` ${missing} cached var(s) are not present in the current process \u2014 env-load needs to be re-sourced, or vars were unset manually.`,\n )\n }\n } else {\n logger.info(` Session ${sessionId}: no env loaded\\n`)\n }\n\n const structuredContent = {\n sessionId,\n sessionLoadedCount,\n sessionTotalCount,\n sessionConfig,\n sessionProject,\n sessionLoadedAt,\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\nexport const envStatusMcpTool = {\n name: 'env-status',\n description:\n 'Report which Doppler project/config is currently loaded in the terminal session, when it was loaded, and how many variables are cached. Read-only \u2014 use env-load / env-clear to change the terminal session.',\n inputSchema: {},\n outputSchema: {\n sessionId: z.string().describe('Current terminal session ID'),\n sessionLoadedCount: z.number().describe('Number of cached vars active in the current session'),\n sessionTotalCount: z.number().describe('Total number of cached var names'),\n sessionConfig: z.string().nullable().describe('Doppler config name of the loaded session (environment name)'),\n sessionProject: z.string().nullable().describe('Doppler project name of the loaded session'),\n sessionLoadedAt: z.string().nullable().describe('ISO 8601 timestamp of when the env was loaded'),\n },\n handler: envStatus,\n}\n", "/* eslint-disable sonarjs/cognitive-complexity */\nimport checkbox from '@inquirer/checkbox'\nimport confirm from '@inquirer/confirm'\nimport process from 'node:process'\nimport { z } from 'zod/v4'\nimport { $ } from 'zx'\n\nimport { getReleasePRsWithInfo } from 'src/integrations/gh'\nimport { commandEcho } from 'src/lib/command-echo'\nimport { logger } from 'src/lib/logger'\nimport { detectReleaseType, formatBranchChoices, getJiraDescriptions } from 'src/lib/release-utils'\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 commandEcho.start('merge-dev')\n\n // Only merge dev into regular releases (not hotfixes, which target main)\n const allPRs = await getReleasePRsWithInfo()\n const releasePRsList = allPRs\n .filter((pr) => {\n return detectReleaseType(pr.title) === 'regular'\n })\n .map((pr) => {\n return pr.branch\n })\n\n if (releasePRsList.length === 0) {\n logger.info('\u2139\uFE0F No open release branches found')\n\n commandEcho.print()\n\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify({ successfulMerges: 0, failedMerges: 0, failedBranches: [], totalBranches: 0 }, null, 2),\n },\n ],\n structuredContent: { successfulMerges: 0, failedMerges: 0, failedBranches: [], totalBranches: 0 },\n }\n }\n\n let selectedReleaseBranches: string[] = []\n\n if (all) {\n selectedReleaseBranches = releasePRsList\n } else {\n commandEcho.setInteractive()\n\n const descriptions = await getJiraDescriptions()\n\n selectedReleaseBranches = await checkbox({\n required: true,\n message: '\uD83C\uDF3F Select release branches',\n choices: formatBranchChoices({ branches: releasePRsList, descriptions }),\n })\n }\n\n // Track --all flag if all branches were selected (either via flag or interactively)\n const allSelected = selectedReleaseBranches.length === releasePRsList.length\n\n if (allSelected) {\n commandEcho.addOption('--all', true)\n } else {\n commandEcho.addOption(\n '--versions',\n selectedReleaseBranches.map((branch) => {\n return branch.replace('release/v', '')\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 (!confirmedCommand) {\n commandEcho.setInteractive()\n }\n\n if (!answer) {\n logger.info('Operation cancelled. Exiting...')\n process.exit(0)\n }\n\n // Track --yes flag if confirmation was interactive (user confirmed)\n if (!confirmedCommand) {\n commandEcho.addOption('--yes', true)\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 for (const branch of failedBranches) {\n logger.info(\n `# Merge dev into ${branch} and resolve conflicts if any \\n\\ngit switch ${branch} && git pull origin ${branch} && git merge origin/dev\\ngit push origin ${branch} && git switch dev\\n`,\n )\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\n commandEcho.print()\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 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(`Successfully merged dev into ${branch}`)\n\n return true\n } catch (error: unknown) {\n logger.error({ error, branch }, `Error merging dev into ${branch}`)\n\n await $`git reset --merge HEAD~1`\n\n return false\n }\n}\n\n// MCP Tool Registration\nexport const ghMergeDevMcpTool = {\n name: 'gh-merge-dev',\n description:\n 'Merge origin/dev into every open regular (non-hotfix) release branch and push the result. Mutates local git state and the remote release branches. When invoked via MCP, pass all=true \u2014 the branch picker is unreachable without a TTY, and the confirmation prompt is auto-skipped for MCP calls, so the caller is responsible for gating. Irreversible once pushed.',\n inputSchema: {\n all: z\n .boolean()\n .optional()\n .describe(\n 'Target every open regular release branch. Must be true for MCP calls (the interactive picker is unavailable without a TTY).',\n ),\n },\n outputSchema: {\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 handler: ghMergeDev,\n}\n", "import process from 'node:process'\nimport { $ } from 'zx'\n\nimport { logger } from 'src/lib/logger'\n\n/**\n * Validate GitHub CLI installation and authentication status and throw an error if not valid\n */\nexport const validateGitHubCliAndAuth = async () => {\n try {\n await $`gh --version`\n } catch (error: unknown) {\n logger.error({ error }, 'Error: GitHub CLI (gh) is not installed.')\n logger.error('Please install it from: https://cli.github.com/')\n process.exit(1)\n }\n\n try {\n await $`gh auth status`\n } catch (error: unknown) {\n logger.error({ error }, 'Error: GitHub CLI (gh) is not authenticated.')\n logger.error('Please authenticate it from: https://cli.github.com/manual/gh_auth_login or type \"gh auth login\"')\n process.exit(1)\n }\n}\n", "import process from 'node:process'\nimport { $ } from 'zx'\n\nimport { logger } from 'src/lib/logger'\nimport { getBaseBranch } from 'src/lib/release-utils'\nimport type { ReleaseType } from 'src/lib/release-utils'\nimport { sortVersions } from 'src/lib/version-utils'\n\ninterface ReleasePR {\n headRefName: string\n number: number\n state: string\n title: string\n baseRefName: string\n}\n\nexport interface ReleasePRInfo {\n branch: string\n title: string\n}\n\n/**\n * Fetch all open release/hotfix PRs from GitHub.\n * Searches both dev (regular) and main (hotfix) base branches.\n * Returns deduplicated ReleasePR objects.\n */\nconst fetchAllReleasePRs = async (): Promise<ReleasePR[]> => {\n const releasePRs =\n await $`gh pr list --search \"Release in:title\" --base dev --json number,title,headRefName,state,baseRefName`\n\n const hotfixPRs =\n await $`gh pr list --search \"Hotfix in:title\" --base main --json number,title,headRefName,state,baseRefName`\n\n const all: ReleasePR[] = [...JSON.parse(releasePRs.stdout), ...JSON.parse(hotfixPRs.stdout)]\n\n // Deduplicate by headRefName\n const seen = new Set<string>()\n\n return all.filter((pr) => {\n if (seen.has(pr.headRefName)) return false\n\n seen.add(pr.headRefName)\n\n return true\n })\n}\n\n/**\n * Fetch open release PRs from GitHub with 'Release' or 'Hotfix' in the title and base 'dev'.\n * Returns an array of headRefName strings sorted by semver in ascending order.\n *\n * @returns [release/v1.18.22, release/v1.18.23, release/v1.18.24] (sorted by semver)\n */\nexport const getReleasePRs = async (): Promise<string[]> => {\n try {\n const prs = await fetchAllReleasePRs()\n\n if (prs.length === 0) {\n logger.error('\u274C No release PRs found. Check the project folder for the script. Exiting...')\n\n process.exit(1)\n }\n\n return sortVersions(\n prs.map((pr) => {\n return pr.headRefName\n }),\n )\n } catch (error) {\n logger.error({ error }, '\u274C Error fetching release PRs')\n\n process.exit(1)\n }\n}\n\n/**\n * Fetch open release PRs with title info (for detecting release type).\n * Returns ReleasePRInfo objects sorted by semver.\n */\nexport const getReleasePRsWithInfo = async (): Promise<ReleasePRInfo[]> => {\n try {\n const prs = await fetchAllReleasePRs()\n\n if (prs.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 const sortedBranches = sortVersions(\n prs.map((pr) => {\n return pr.headRefName\n }),\n )\n const prByBranch = new Map(\n prs.map((pr) => {\n return [pr.headRefName, pr]\n }),\n )\n\n return sortedBranches.map((branch) => {\n return {\n branch,\n title: prByBranch.get(branch)!.title,\n }\n })\n } catch (error) {\n logger.error({ error }, '\u274C Error fetching release PRs')\n process.exit(1)\n }\n}\n\ninterface CreateReleaseBranchArgs {\n version: string\n jiraVersionUrl: string\n type: ReleaseType\n description?: string\n}\n\n// Function to create a release branch\nexport const createReleaseBranch = async (\n args: CreateReleaseBranchArgs,\n): Promise<{ branchName: string; prUrl: string }> => {\n const { version, jiraVersionUrl, type, description } = args\n const titlePrefix = type === 'hotfix' ? 'Hotfix' : 'Release'\n const baseBranch = getBaseBranch(type)\n\n const branchName = `release/v${version}`\n\n const body = description && description.trim() !== '' ? `${jiraVersionUrl}\\n\\n${description}` : `${jiraVersionUrl} \\n`\n\n try {\n $.quiet = true\n\n await $`git switch ${baseBranch}`\n await $`git pull origin ${baseBranch}`\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 and capture URL\n const prResult =\n await $`gh pr create --title \"${titlePrefix} v${version}\" --body ${body} --base ${baseBranch} --head ${branchName}`\n\n const prLink = prResult.stdout.trim()\n\n await $`git switch ${baseBranch}`\n\n $.quiet = false\n\n return {\n branchName,\n prUrl: prLink,\n }\n } catch (error: unknown) {\n logger.error({ error, branchName }, `Error creating release branch ${branchName}`)\n\n throw error\n }\n}\n", "import { $ } from 'zx'\n\nimport { createReleaseBranch } from 'src/integrations/gh'\nimport { createJiraVersion, getProjectVersions, loadJiraConfigOptional } from 'src/integrations/jira'\nimport type { JiraConfig } from 'src/integrations/jira'\n\nexport type ReleaseType = 'regular' | 'hotfix'\n\n/**\n * Get the base branch for a release type.\n * Regular releases branch from/to dev, hotfixes branch from/to main.\n */\nexport const getBaseBranch = (type: ReleaseType): string => {\n return type === 'hotfix' ? 'main' : 'dev'\n}\n\nexport interface ReleaseCreationResult {\n version: string\n type: ReleaseType\n branchName: string\n prUrl: string\n jiraVersionUrl: string\n}\n\n/**\n * Prepare git repository for release creation\n * Fetches latest changes, switches to base branch, and pulls latest\n */\nexport const prepareGitForRelease = async (type: ReleaseType = 'regular'): Promise<void> => {\n const baseBranch = getBaseBranch(type)\n\n $.quiet = true\n\n await $`git fetch origin`\n await $`git switch ${baseBranch}`\n await $`git pull origin ${baseBranch}`\n\n $.quiet = false\n}\n\ninterface CreateSingleReleaseArgs {\n version: string\n jiraConfig: JiraConfig\n description?: string\n type?: ReleaseType\n}\n\n/**\n * Create a single release by creating both Jira version and GitHub release branch\n */\nexport const createSingleRelease = async (args: CreateSingleReleaseArgs): Promise<ReleaseCreationResult> => {\n const { version, jiraConfig, description, type = 'regular' } = args\n // 1. Create Jira version (mandatory)\n const versionName = `v${version}`\n\n const result = await createJiraVersion(\n {\n name: versionName,\n projectId: jiraConfig.projectId,\n description: description || '',\n released: false,\n archived: false,\n },\n jiraConfig,\n )\n\n // Construct user-friendly Jira URL using project key from API response\n const jiraVersionUrl = `${jiraConfig.baseUrl}/projects/${result.version!.projectId}/versions/${result.version!.id}/tab/release-report-all-issues`\n\n // 2. Create GitHub release branch\n const releaseInfo = await createReleaseBranch({ version, jiraVersionUrl, type, description })\n\n return {\n version,\n type,\n branchName: releaseInfo.branchName,\n prUrl: releaseInfo.prUrl,\n jiraVersionUrl,\n }\n}\n\n/**\n * Fetch Jira version descriptions mapped by version name (e.g., \"v1.2.5\" \u2192 \"Some description\")\n * Gracefully returns empty map if Jira is unavailable\n */\nexport const getJiraDescriptions = async (): Promise<Map<string, string>> => {\n const descriptions = new Map<string, string>()\n\n const jiraConfig = await loadJiraConfigOptional()\n\n if (!jiraConfig) return descriptions\n\n try {\n const versions = await getProjectVersions(jiraConfig)\n\n for (const version of versions) {\n if (version.description) {\n descriptions.set(version.name, version.description)\n }\n }\n } catch {\n // Jira fetch failed, continue without descriptions\n }\n\n return descriptions\n}\n\n/**\n * Format a version string with its release type tag, e.g. \"1.2.5 [regular]\"\n * When maxVersionLength is provided, pads the version for alignment.\n */\nexport const formatVersionLabel = (version: string, type: ReleaseType, maxVersionLength?: number): string => {\n const padding = maxVersionLength ? ' '.repeat(maxVersionLength - version.length + 3) : ' '\n const tag = `[${type}]`.padEnd(11)\n\n return `${version}${padding}${tag}`\n}\n\n/**\n * Detect release type from PR title.\n * PRs titled \"Hotfix v...\" are hotfix, everything else is regular.\n */\nexport const detectReleaseType = (title: string): ReleaseType => {\n return title.toLowerCase().startsWith('hotfix') ? 'hotfix' : 'regular'\n}\n\ninterface FormatBranchChoicesArgs {\n branches: string[]\n descriptions: Map<string, string>\n types?: Map<string, ReleaseType>\n}\n\n/**\n * Format release branch names as checkbox choices with aligned type tags and Jira descriptions\n */\nexport const formatBranchChoices = (args: FormatBranchChoicesArgs): { name: string; value: string }[] => {\n const { branches, descriptions, types } = args\n\n const versionNames = branches.map((b) => {\n return b.replace('release/v', '')\n })\n\n const maxLen = Math.max(\n ...versionNames.map((v) => {\n return v.length\n }),\n )\n\n return branches.map((branch, i) => {\n const version = versionNames[i] as string\n const type = types ? types.get(branch) || 'regular' : undefined\n const desc = descriptions.get(`v${version}`)\n const padding = ' '.repeat(maxLen - version.length + 3)\n\n let name = type ? formatVersionLabel(version, type, maxLen) : version\n\n if (desc) {\n name = type ? `${name} ${desc}` : `${version}${padding}${desc}`\n }\n\n return { name, value: branch }\n })\n}\n", "import process from 'node:process'\n\nimport { logger } from 'src/lib/logger'\n\nimport type {\n CreateJiraVersionParams,\n CreateJiraVersionResult,\n DeliverJiraReleaseParams,\n DeliverJiraReleaseResult,\n JiraConfig,\n JiraVersion,\n UpdateJiraVersionParams,\n UpdateJiraVersionResult,\n} from './types.js'\n\n/**\n * Creates a new version in Jira using the REST API\n * @param params - Version creation parameters\n * @param config - Jira configuration (baseUrl, token, projectId)\n * @returns Result containing created version or error\n */\nexport const createJiraVersion = async (\n params: CreateJiraVersionParams,\n config: JiraConfig,\n): Promise<CreateJiraVersionResult> => {\n try {\n const { baseUrl, token, email, projectId } = config\n\n // Use current date if not provided\n // const releaseDate =\n // params.releaseDate || new Date().toISOString().split('T')[0] // 2025-12-06\n\n // Prepare request body\n const requestBody = {\n name: params.name,\n projectId: params.projectId || projectId,\n description: params.description || '',\n // releaseDate,\n released: params.released || false,\n archived: params.archived || false,\n }\n\n // logger.info(\n // { version: params.name, projectId: requestBody.projectId },\n // 'Creating Jira version',\n // )\n\n // Make API request\n const url = `${baseUrl}/rest/api/3/version`\n\n // Create Basic auth credentials\n const credentials = btoa(`${email}:${token}`)\n\n const response = await fetch(url, {\n method: 'POST',\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n Authorization: `Basic ${credentials}`,\n },\n body: JSON.stringify(requestBody),\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n\n logger.error(\n {\n status: response.status,\n statusText: response.statusText,\n error: errorText,\n },\n 'Failed to create Jira version',\n )\n\n throw new Error(`HTTP ${response.status}: ${response.statusText}`)\n }\n\n const version = (await response.json()) as JiraVersion\n\n // logger.info(\n // { versionId: version.id, versionName: version.name },\n // 'Successfully created Jira version',\n // )\n\n return {\n success: true,\n version,\n }\n } catch (error) {\n logger.error({ error }, 'Error creating Jira version')\n\n throw error\n }\n}\n\n/**\n * Gets all versions for a project from Jira\n * @param config - Jira configuration\n * @returns Array of JiraVersion objects\n */\nexport const getProjectVersions = async (config: JiraConfig): Promise<JiraVersion[]> => {\n try {\n const { baseUrl, token, email, projectId } = config\n\n const url = `${baseUrl}/rest/api/3/project/${projectId}/versions`\n const credentials = btoa(`${email}:${token}`)\n\n const response = await fetch(url, {\n method: 'GET',\n headers: {\n Accept: 'application/json',\n Authorization: `Basic ${credentials}`,\n },\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n\n logger.error(\n {\n status: response.status,\n statusText: response.statusText,\n error: errorText,\n },\n 'Failed to get Jira project versions',\n )\n\n throw new Error(`HTTP ${response.status}: ${response.statusText}`)\n }\n\n const versions = (await response.json()) as JiraVersion[]\n\n return versions\n } catch (error) {\n logger.error({ error }, 'Error getting Jira project versions')\n\n throw error\n }\n}\n\n/**\n * Finds a Jira version by name in the project\n * @param versionName - Name of the version to find (e.g., \"v1.33.10\")\n * @param config - Jira configuration\n * @returns JiraVersion if found, null otherwise\n */\nconst findVersionByName = async (versionName: string, config: JiraConfig): Promise<JiraVersion | null> => {\n try {\n const versions = await getProjectVersions(config)\n const version = versions.find((v) => {\n return v.name === versionName\n })\n\n return version || null\n } catch (error) {\n logger.error({ error, versionName }, 'Error finding Jira version by name')\n\n throw error\n }\n}\n\n/**\n * Updates an existing Jira version\n * @param params - Update parameters\n * @param config - Jira configuration\n * @returns Result containing updated version or error\n */\nconst updateJiraVersion = async (\n params: UpdateJiraVersionParams,\n config: JiraConfig,\n): Promise<UpdateJiraVersionResult> => {\n try {\n const { baseUrl, token, email } = config\n\n // Prepare request body - only include fields that are provided\n const requestBody: Record<string, any> = {\n released: params.released ?? true,\n archived: params.archived ?? false,\n }\n\n // Add releaseDate if provided, otherwise use current date when releasing\n if (params.releaseDate) {\n requestBody.releaseDate = params.releaseDate\n } else if (params.released !== false) {\n requestBody.releaseDate = new Date().toISOString().split('T')[0] // YYYY-MM-DD\n }\n\n if (params.description !== undefined) {\n requestBody.description = params.description\n }\n\n const url = `${baseUrl}/rest/api/3/version/${params.versionId}`\n const credentials = btoa(`${email}:${token}`)\n\n const response = await fetch(url, {\n method: 'PUT',\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n Authorization: `Basic ${credentials}`,\n },\n body: JSON.stringify(requestBody),\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n\n logger.error(\n {\n status: response.status,\n statusText: response.statusText,\n error: errorText,\n },\n 'Failed to update Jira version',\n )\n\n throw new Error(`HTTP ${response.status}: ${response.statusText}`)\n }\n\n const version = (await response.json()) as JiraVersion\n\n return {\n success: true,\n version,\n }\n } catch (error) {\n logger.error({ error }, 'Error updating Jira version')\n\n throw error\n }\n}\n\n/**\n * Delivers a Jira release by marking it as released with the current date\n * @param params - Parameters containing the version name\n * @param config - Jira configuration\n * @returns Result containing updated version\n * @throws Error if version not found or update fails\n */\nexport const deliverJiraRelease = async (\n params: DeliverJiraReleaseParams,\n config: JiraConfig,\n): Promise<DeliverJiraReleaseResult> => {\n try {\n const { versionName } = params\n\n // Find the version by name\n const version = await findVersionByName(versionName, config)\n\n if (!version) {\n logger.error({ versionName }, 'Jira version not found')\n throw new Error(`Version \"${versionName}\" not found in Jira project`)\n }\n\n // Update the version to mark it as released\n const result = await updateJiraVersion(\n {\n versionId: version.id,\n released: true,\n releaseDate: new Date().toISOString().split('T')[0], // Current date in YYYY-MM-DD format\n },\n config,\n )\n\n return result\n } catch (error) {\n logger.error({ error }, 'Error delivering Jira release')\n throw error\n }\n}\n\n/**\n * Loads Jira configuration from environment variables\n * @throws Error with detailed message if configuration is missing or invalid\n * @returns Promise<JiraConfig>\n */\nexport const loadJiraConfig = async (): Promise<JiraConfig> => {\n const baseUrl = process.env.JIRA_BASE_URL\n const token = process.env.JIRA_TOKEN || process.env.JIRA_API_TOKEN\n const projectIdStr = process.env.JIRA_PROJECT_ID\n const email = process.env.JIRA_EMAIL\n\n const missingVars: string[] = []\n\n if (!baseUrl) missingVars.push('JIRA_BASE_URL (e.g., https://your-domain.atlassian.net)')\n if (!token) missingVars.push('JIRA_TOKEN or JIRA_API_TOKEN (your Jira API token)')\n if (!projectIdStr) missingVars.push('JIRA_PROJECT_ID (numeric project ID)')\n if (!email) missingVars.push('JIRA_EMAIL (your Jira email address)')\n\n if (missingVars.length > 0) {\n const errorMessage = [\n 'Jira configuration is required but incomplete.',\n 'Please configure the following environment variables:',\n ...missingVars.map((v) => {\n return ` - ${v}`\n }),\n '',\n 'You can set these in your .env file or as environment variables.',\n ].join('\\n')\n\n throw new Error(errorMessage)\n }\n\n const projectId = Number.parseInt(projectIdStr!, 10)\n\n if (Number.isNaN(projectId)) {\n throw new TypeError(`Invalid JIRA_PROJECT_ID: \"${projectIdStr}\" must be a numeric value (e.g., 10001)`)\n }\n\n return {\n baseUrl: baseUrl!.replace(/\\/$/, ''), // Remove trailing slash\n token: token!,\n projectId,\n email: email!,\n }\n}\n\n/**\n * Attempts to load Jira configuration from environment variables\n * Returns null if configuration is missing or invalid (for optional Jira integration)\n * @returns Promise<JiraConfig | null>\n */\nexport const loadJiraConfigOptional = async (): Promise<JiraConfig | null> => {\n try {\n const config = await loadJiraConfig()\n\n return config\n } catch (error) {\n logger.warn({ error }, 'Jira configuration not available, skipping Jira integration')\n\n return null\n }\n}\n", "import { $ } from 'zx'\n\nimport { getProjectVersions, loadJiraConfigOptional } from 'src/integrations/jira'\nimport { logger } from 'src/lib/logger'\n\nimport { collectKnownVersions } from './next-version'\nimport type { SemVer } from './next-version'\n\nconst parseRemoteRefs = async (): Promise<string[]> => {\n const previousQuiet = $.quiet\n\n try {\n $.quiet = true\n const result = await $`git ls-remote --heads origin 'release/v*'`\n const lines = result.stdout.split('\\n')\n\n return lines\n .map((line) => {\n const tab = line.indexOf('\\t')\n\n if (tab === -1) return ''\n\n return line.slice(tab + 1).replace(/^refs\\/heads\\//, '')\n })\n .filter(Boolean)\n } finally {\n $.quiet = previousQuiet\n }\n}\n\nconst fetchJiraVersionNames = async (): Promise<string[]> => {\n const config = await loadJiraConfigOptional()\n\n if (!config) return []\n\n const versions = await getProjectVersions(config)\n\n return versions.map((v) => {\n return v.name\n })\n}\n\n/**\n * Load known release versions from the union of:\n * - remote release branches (`release/v*` on origin)\n * - Jira fix versions (when configured)\n *\n * Each source is queried in parallel; if either fails, we log a warning\n * and continue with the other so a transient outage doesn't block release\n * creation.\n */\nexport const loadExistingVersions = async (): Promise<SemVer[]> => {\n const [branchesResult, jiraResult] = await Promise.allSettled([parseRemoteRefs(), fetchJiraVersionNames()])\n\n if (branchesResult.status === 'rejected') {\n logger.warn({ error: branchesResult.reason }, 'Failed to list remote release branches; continuing without them')\n }\n\n if (jiraResult.status === 'rejected') {\n logger.warn({ error: jiraResult.reason }, 'Failed to fetch Jira versions; continuing without them')\n }\n\n return collectKnownVersions({\n remoteBranches: branchesResult.status === 'fulfilled' ? branchesResult.value : [],\n jiraVersions: jiraResult.status === 'fulfilled' ? jiraResult.value : [],\n })\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 * Note: Returns a new sorted array without mutating the original\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\n return (patchA ?? 0) - (patchB ?? 0)\n })\n}\n", "import type { ReleaseType } from 'src/lib/release-utils'\n\nimport { parseVersion, sortVersions } from './version-utils'\n\nexport const NEXT_TOKEN = 'next'\n\nexport type SemVer = readonly [number, number, number]\n\nexport interface ExistingVersionsSources {\n remoteBranches?: string[]\n jiraVersions?: string[]\n}\n\nconst VERSION_RE = /^v?(\\d+)\\.(\\d+)\\.(\\d+)$/\n\nconst stripBranchPrefix = (raw: string): string => {\n return raw.replace(/^.*release\\//, '')\n}\n\nconst tryParse = (raw: string): SemVer | null => {\n const cleaned = stripBranchPrefix(raw.trim())\n const match = VERSION_RE.exec(cleaned)\n\n if (!match) return null\n\n return [Number(match[1]), Number(match[2]), Number(match[3])]\n}\n\nconst semverKey = (v: SemVer): string => {\n return `${v[0]}.${v[1]}.${v[2]}`\n}\n\nexport const collectKnownVersions = (sources: ExistingVersionsSources): SemVer[] => {\n const all = [...(sources.remoteBranches ?? []), ...(sources.jiraVersions ?? [])]\n const parsed: SemVer[] = []\n const seen = new Set<string>()\n\n for (const raw of all) {\n const v = tryParse(raw)\n\n if (!v) continue\n\n const key = semverKey(v)\n\n if (seen.has(key)) continue\n\n seen.add(key)\n parsed.push(v)\n }\n\n return sortVersions(\n parsed.map((v) => {\n return semverKey(v)\n }),\n ).map((s) => {\n return parseVersion(`v${s}`)\n })\n}\n\nexport class NoPriorVersionsError extends Error {\n constructor() {\n super('No prior release versions found from git or Jira. Specify the version explicitly.')\n this.name = 'NoPriorVersionsError'\n }\n}\n\n/**\n * Compute the next semantic version based on release type.\n * - regular: bump minor, reset patch to 0\n * - hotfix: bump patch on the highest minor (any patch)\n *\n * Returns the version without the leading \"v\" (e.g. \"1.64.0\").\n */\nexport const computeNextVersion = (known: SemVer[], type: ReleaseType): string => {\n if (known.length === 0) throw new NoPriorVersionsError()\n\n const max = known[known.length - 1] as SemVer\n\n if (type === 'hotfix') {\n const [major, minor] = max\n\n const highestPatchOnMinor = known.reduce((acc, v) => {\n if (v[0] === major && v[1] === minor) return Math.max(acc, v[2])\n\n return acc\n }, 0)\n\n return `${major}.${minor}.${highestPatchOnMinor + 1}`\n }\n\n const [major, minor] = max\n\n return `${major}.${minor + 1}.0`\n}\n\nconst isNextToken = (token: string): boolean => {\n return token.trim().toLowerCase() === NEXT_TOKEN\n}\n\n/**\n * Resolve a list of input tokens (mix of \"next\" and explicit semver strings)\n * into concrete version strings. Each \"next\" advances based on the running\n * max so \"next,next\" produces sequential versions.\n */\nexport const resolveVersionTokens = (tokens: string[], type: ReleaseType, known: SemVer[]): string[] => {\n const running: SemVer[] = [...known]\n const resolved: string[] = []\n\n for (const token of tokens) {\n const trimmed = token.trim()\n\n if (trimmed === '') continue\n\n if (isNextToken(trimmed)) {\n const next = computeNextVersion(running, type)\n\n resolved.push(next)\n running.push(parseVersion(`v${next}`))\n continue\n }\n\n const parsed = tryParse(trimmed)\n\n if (!parsed) {\n throw new Error(`Invalid version \"${trimmed}\". Expected semver like \"1.2.5\" or the token \"next\".`)\n }\n\n const explicit = `${parsed[0]}.${parsed[1]}.${parsed[2]}`\n\n resolved.push(explicit)\n running.push(parsed)\n }\n\n return resolved\n}\n\n/**\n * Split a raw user input into tokens, trimming and removing empties.\n * Accepts both whitespace-separated and comma-separated lists.\n */\nexport const splitVersionInput = (input: string): string[] => {\n return input\n .split(',')\n .map((t) => {\n return t.trim()\n })\n .filter(Boolean)\n}\n", "import confirm from '@inquirer/confirm'\nimport select from '@inquirer/select'\nimport process from 'node:process'\nimport { z } from 'zod/v4'\nimport { $ } from 'zx'\n\nimport { getReleasePRsWithInfo } from 'src/integrations/gh'\nimport { deliverJiraRelease, loadJiraConfigOptional } from 'src/integrations/jira'\nimport { commandEcho } from 'src/lib/command-echo'\nimport { logger } from 'src/lib/logger'\nimport { detectReleaseType, formatBranchChoices, getJiraDescriptions } from 'src/lib/release-utils'\nimport type { ReleaseType } from 'src/lib/release-utils'\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 commandEcho.start('release-deliver')\n\n const releasePRsInfo = await getReleasePRsWithInfo()\n\n const branches = releasePRsInfo.map((pr) => {\n return pr.branch\n })\n\n const releaseTypes = new Map<string, ReleaseType>(\n releasePRsInfo.map((pr) => {\n return [pr.branch, detectReleaseType(pr.title)]\n }),\n )\n\n let selectedReleaseBranch = '' // \"release/v1.8.0\"\n\n if (version) {\n selectedReleaseBranch = `release/v${version}`\n } else {\n commandEcho.setInteractive()\n\n const descriptions = await getJiraDescriptions()\n\n selectedReleaseBranch = await select({\n message: '\uD83C\uDF3F Select release branch',\n choices: formatBranchChoices({ branches, descriptions, types: releaseTypes }),\n })\n }\n\n const selectedVersion = selectedReleaseBranch.replace('release/v', '')\n\n commandEcho.addOption('--version', selectedVersion)\n\n // Check if release branch exists in the list\n const prInfo = releasePRsInfo.find((pr) => {\n return pr.branch === selectedReleaseBranch\n })\n\n if (!prInfo) {\n logger.error(`\u274C Release branch ${selectedReleaseBranch} not found in open PRs. Exiting...`)\n process.exit(1)\n }\n\n const releaseType: ReleaseType = detectReleaseType(prInfo.title)\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 (!confirmedCommand) {\n commandEcho.setInteractive()\n }\n\n if (!answer) {\n logger.info('Operation cancelled. Exiting...')\n process.exit(0)\n }\n\n // Track --yes flag if confirmation was interactive (user confirmed)\n commandEcho.addOption('--yes', true)\n\n try {\n $.quiet = true\n\n if (releaseType === 'hotfix') {\n // Hotfix: merge directly into main, deploy, sync back to dev\n await $`gh pr merge ${selectedReleaseBranch} --squash --admin --delete-branch`\n\n $.quiet = false\n\n await $`gh workflow run deploy-all.yml --ref main -f environment=prod`\n\n $.quiet = true\n\n // Sync main into dev\n await $`git switch main && git pull && git switch dev && git pull && git merge main --no-edit && git push`\n } else {\n // Regular: merge into dev, create RC PR to main, merge to main, deploy, sync\n await $`gh pr merge ${selectedReleaseBranch} --squash --admin --delete-branch`\n await $`gh pr create --base main --head dev --title \"Release v${selectedVersion} (RC)\" --body \"\"`\n await $`gh pr merge dev --squash --admin`\n\n $.quiet = false\n\n await $`gh workflow run deploy-all.yml --ref main -f environment=prod`\n\n $.quiet = true\n\n // Sync main into dev\n await $`git switch main && git pull && git switch dev && git pull && git merge main --no-edit && git push`\n }\n\n $.quiet = false\n\n // Deliver Jira release if Jira is configured\n const jiraConfig = await loadJiraConfigOptional()\n\n if (jiraConfig) {\n try {\n const versionName = selectedReleaseBranch.replace('release/', '')\n\n await deliverJiraRelease({ versionName }, jiraConfig)\n } catch (error) {\n logger.error({ error }, 'Failed to deliver Jira release (non-blocking)')\n }\n } else {\n logger.info('\uD83D\uDD14 Jira is not configured, skipping Jira release delivery')\n }\n\n logger.info(`Successfully delivered ${selectedReleaseBranch} to production!`)\n\n commandEcho.print()\n\n const structuredContent = {\n releaseBranch: selectedReleaseBranch,\n version: selectedReleaseBranch.replace('release/v', ''),\n type: releaseType,\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\nexport const ghReleaseDeliverMcpTool = {\n name: 'gh-release-deliver',\n description:\n 'Deliver a release to production. For hotfixes: squash-merges the release branch to main and dispatches the deploy-all workflow. For regular releases: squash-merges to dev, opens an RC PR, merges dev into main, dispatches the deploy-all workflow, then syncs main back to dev. Also releases the matching Jira fix version if Jira is configured. Dispatches the deploy workflow fire-and-forget \u2014 the tool returns once the workflow is accepted by GitHub, not when the deployment finishes. Irreversible production operation: the confirmation prompt is auto-skipped for MCP calls, so the caller is responsible for gating. \"version\" is required when invoked via MCP (the picker is unreachable without a TTY).',\n inputSchema: {\n version: z.string().describe('Release version to deliver to production (e.g., \"1.2.5\"). Required for MCP calls.'),\n },\n outputSchema: {\n releaseBranch: z.string().describe('The release branch that was delivered'),\n version: z.string().describe('The version that was delivered'),\n type: z.enum(['regular', 'hotfix']).describe('Release type'),\n success: z.boolean().describe('Whether the delivery was successful'),\n },\n handler: ghReleaseDeliver,\n}\n", "import select from '@inquirer/select'\nimport process from 'node:process'\nimport { z } from 'zod/v4'\nimport { $ } from 'zx'\n\nimport { getReleasePRsWithInfo } from 'src/integrations/gh'\nimport { commandEcho } from 'src/lib/command-echo'\nimport { getInfraKitConfig } from 'src/lib/infra-kit-config'\nimport { logger } from 'src/lib/logger'\nimport { detectReleaseType, formatBranchChoices, getJiraDescriptions } from 'src/lib/release-utils'\nimport type { ReleaseType } from 'src/lib/release-utils'\nimport type { ToolsExecutionResult } from 'src/types'\n\ninterface GhReleaseDeployAllArgs {\n version: string\n env: string\n skipTerraform?: boolean\n}\n\n/**\n * Deploy a release branch to an environment\n */\nexport const ghReleaseDeployAll = async (args: GhReleaseDeployAllArgs): Promise<ToolsExecutionResult> => {\n const { version, env, skipTerraform } = args\n\n commandEcho.start('release-deploy-all')\n\n let selectedReleaseBranch = '' // \"release/v1.8.0\"\n\n if (version) {\n selectedReleaseBranch = version === 'dev' ? 'dev' : `release/v${version}`\n } else {\n commandEcho.setInteractive()\n\n const releasePRsInfo = await getReleasePRsWithInfo()\n\n const branches = releasePRsInfo.map((pr) => {\n return pr.branch\n })\n\n const releaseTypes = new Map<string, ReleaseType>(\n releasePRsInfo.map((pr) => {\n return [pr.branch, detectReleaseType(pr.title)]\n }),\n )\n\n const descriptions = await getJiraDescriptions()\n\n selectedReleaseBranch = await select({\n message: '\uD83C\uDF3F Select release branch',\n choices: [{ name: 'dev', value: 'dev' }, ...formatBranchChoices({ branches, descriptions, types: releaseTypes })],\n })\n }\n\n const selectedVersion = selectedReleaseBranch === 'dev' ? 'dev' : selectedReleaseBranch.replace('release/v', '')\n\n commandEcho.addOption('--version', selectedVersion)\n\n const { environments } = await getInfraKitConfig()\n\n let selectedEnv = ''\n\n if (env) {\n selectedEnv = env\n } else {\n commandEcho.setInteractive()\n\n selectedEnv = await select({\n message: '\uD83E\uDDEA Select environment',\n choices: environments.map((env) => {\n return {\n name: env,\n value: env,\n }\n }),\n })\n }\n\n commandEcho.addOption('--env', selectedEnv)\n\n if (!environments.includes(selectedEnv)) {\n logger.error(`\u274C Invalid environment: ${selectedEnv}. Exiting...`)\n process.exit(1)\n }\n\n const shouldSkipTerraform = skipTerraform ?? false\n\n if (shouldSkipTerraform) {\n commandEcho.addOption('--skip-terraform', true)\n }\n\n try {\n $.quiet = true\n\n const skipTerraformFlag = shouldSkipTerraform ? ['-f', 'skip_terraform_deploy=true'] : []\n\n await $`gh workflow run deploy-all.yml --ref ${selectedReleaseBranch} -f environment=${selectedEnv} ${skipTerraformFlag}`\n\n $.quiet = false\n\n logger.info(\n `Successfully launched deploy-all workflow_dispatch for release branch: ${selectedReleaseBranch} and environment: ${selectedEnv}`,\n )\n\n commandEcho.print()\n\n const structuredContent = {\n releaseBranch: selectedReleaseBranch,\n version: selectedReleaseBranch.replace('release/v', ''),\n environment: selectedEnv,\n skipTerraformDeploy: shouldSkipTerraform,\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\nexport const ghReleaseDeployAllMcpTool = {\n name: 'gh-release-deploy-all',\n description:\n 'Dispatch the deploy-all.yml GitHub Actions workflow to deploy every service from a release branch to the given environment. Fire-and-forget \u2014 returns once GitHub accepts the workflow_dispatch, NOT when the deployment finishes; watch the workflow run for completion status. Use gh-release-deploy-selected for a subset of services. Pass version=\"dev\" to deploy from the dev branch instead of a release branch. Both \"version\" and \"env\" are required when invoked via MCP (interactive pickers are unavailable without a TTY).',\n inputSchema: {\n version: z\n .string()\n .describe(\n 'Release version to deploy from (e.g. \"1.2.5\") \u2014 resolves to the release/vX.Y.Z branch. Pass \"dev\" to deploy from the dev branch instead. Required for MCP calls.',\n ),\n env: z\n .string()\n .describe(\n 'Target environment name \u2014 must match an env configured for the project (e.g. \"dev\", \"renana\", \"oriana\"). Required for MCP calls.',\n ),\n skipTerraform: z.boolean().optional().describe('Skip the terraform deployment stage.'),\n },\n outputSchema: {\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 skipTerraformDeploy: z.boolean().describe('Whether terraform deployment was skipped'),\n success: z.boolean().describe('Whether the deployment was successful'),\n },\n handler: ghReleaseDeployAll,\n}\n", "import checkbox from '@inquirer/checkbox'\nimport select from '@inquirer/select'\nimport fs from 'node:fs/promises'\nimport { resolve } from 'node:path'\nimport process from 'node:process'\nimport yaml from 'yaml'\nimport { z } from 'zod/v4'\nimport { $ } from 'zx'\n\nimport { getReleasePRsWithInfo } from 'src/integrations/gh'\nimport { commandEcho } from 'src/lib/command-echo'\nimport { getProjectRoot } from 'src/lib/git-utils'\nimport { getInfraKitConfig } from 'src/lib/infra-kit-config'\nimport { logger } from 'src/lib/logger'\nimport { detectReleaseType, formatBranchChoices, getJiraDescriptions } from 'src/lib/release-utils'\nimport type { ReleaseType } from 'src/lib/release-utils'\nimport type { ToolsExecutionResult } from 'src/types'\n\ninterface GhReleaseDeploySelectedArgs {\n version: string\n env: string\n services: string[]\n skipTerraform?: boolean\n}\n\n/**\n * Deploy selected services from a release branch to an environment\n */\n// eslint-disable-next-line sonarjs/cognitive-complexity\nexport const ghReleaseDeploySelected = async (args: GhReleaseDeploySelectedArgs): Promise<ToolsExecutionResult> => {\n const { version, env, services, skipTerraform } = args\n\n commandEcho.start('release-deploy-selected')\n\n let selectedReleaseBranch = ''\n\n if (version) {\n selectedReleaseBranch = version === 'dev' ? 'dev' : `release/v${version}`\n } else {\n commandEcho.setInteractive()\n\n const releasePRsInfo = await getReleasePRsWithInfo()\n\n const branches = releasePRsInfo.map((pr) => {\n return pr.branch\n })\n\n const releaseTypes = new Map<string, ReleaseType>(\n releasePRsInfo.map((pr) => {\n return [pr.branch, detectReleaseType(pr.title)]\n }),\n )\n\n const descriptions = await getJiraDescriptions()\n\n selectedReleaseBranch = await select({\n message: '\uD83C\uDF3F Select release branch',\n choices: [{ name: 'dev', value: 'dev' }, ...formatBranchChoices({ branches, descriptions, types: releaseTypes })],\n })\n }\n\n const selectedVersion = selectedReleaseBranch === 'dev' ? 'dev' : selectedReleaseBranch.replace('release/v', '')\n\n commandEcho.addOption('--version', selectedVersion)\n\n const { environments } = await getInfraKitConfig()\n\n let selectedEnv = ''\n\n if (env) {\n selectedEnv = env\n } else {\n commandEcho.setInteractive()\n\n selectedEnv = await select({\n message: '\uD83E\uDDEA Select environment',\n choices: environments.map((env) => {\n return {\n name: env,\n value: env,\n }\n }),\n })\n }\n\n commandEcho.addOption('--env', selectedEnv)\n\n if (!environments.includes(selectedEnv)) {\n logger.error(`\u274C Invalid environment: ${selectedEnv}. Exiting...`)\n process.exit(1)\n }\n\n // Parse available services from workflow file\n const availableServices = await parseServicesFromWorkflow()\n\n if (availableServices.length === 0) {\n logger.error('\u274C No services found in workflow file. Exiting...')\n\n process.exit(1)\n }\n\n let selectedServices: string[] = []\n\n if (services && services.length > 0) {\n selectedServices = services\n } else {\n commandEcho.setInteractive()\n\n selectedServices = await checkbox({\n message: '\uD83D\uDE80 Select services to deploy (space to select, enter to confirm)',\n choices: availableServices.map((svc) => {\n return {\n name: svc,\n value: svc,\n }\n }),\n })\n }\n\n commandEcho.addOption('--services', selectedServices)\n\n if (selectedServices.length === 0) {\n logger.error('\u274C No services selected. Exiting...')\n process.exit(1)\n }\n\n // Validate all selected services\n const invalidServices = selectedServices.filter((svc) => {\n return !availableServices.includes(svc)\n })\n\n if (invalidServices.length > 0) {\n logger.error(\n `\u274C Invalid services: ${invalidServices.join(', ')}. Available services: ${availableServices.join(', ')}`,\n )\n process.exit(1)\n }\n\n const shouldSkipTerraform = skipTerraform ?? false\n\n if (shouldSkipTerraform) {\n commandEcho.addOption('--skip-terraform', true)\n }\n\n try {\n $.quiet = true\n\n // Build the workflow command with boolean flags for each selected service\n const serviceFlags = selectedServices.flatMap((svc) => {\n return ['-f', `${svc}=true`]\n })\n const skipTerraformFlag = shouldSkipTerraform ? ['-f', 'skip_terraform_deploy=true'] : []\n\n await $`gh workflow run deploy-selected-services.yml --ref ${selectedReleaseBranch} -f environment=${selectedEnv} ${serviceFlags} ${skipTerraformFlag}`\n\n $.quiet = false\n\n logger.info(\n `Successfully launched deploy-selected-services workflow_dispatch for release branch: ${selectedReleaseBranch}, environment: ${selectedEnv}, services: ${selectedServices.join(', ')}`,\n )\n\n commandEcho.print()\n\n const structuredContent = {\n releaseBranch: selectedReleaseBranch,\n version: selectedReleaseBranch.replace('release/v', ''),\n environment: selectedEnv,\n services: selectedServices,\n skipTerraformDeploy: shouldSkipTerraform,\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/**\n * Parse available services from the workflow file\n * Services are defined as boolean inputs (excluding skip_terraform_deploy)\n */\nconst parseServicesFromWorkflow = async (): Promise<string[]> => {\n const projectRoot = await getProjectRoot()\n\n const workflowPath = resolve(projectRoot, '.github/workflows/deploy-selected-services.yml')\n\n const content = await fs.readFile(workflowPath, 'utf-8')\n const parsed = yaml.parse(content)\n\n const inputs = parsed.on.workflow_dispatch.inputs\n const services: string[] = []\n\n for (const [key, value] of Object.entries(inputs)) {\n // Filter for boolean type inputs, excluding non-service flags\n if ((value as { type: string }).type === 'boolean' && key !== 'skip_terraform_deploy') {\n services.push(key)\n }\n }\n\n return services\n}\n\n// MCP Tool Registration\nexport const ghReleaseDeploySelectedMcpTool = {\n name: 'gh-release-deploy-selected',\n description:\n 'Dispatch the deploy-selected-services.yml GitHub Actions workflow to deploy a chosen subset of services from a release branch to the given environment. Fire-and-forget \u2014 returns once GitHub accepts the workflow_dispatch, NOT when the deployment finishes; watch the workflow run for completion status. Service names are validated against the boolean inputs declared in the workflow. Use gh-release-deploy-all for every service. \"version\", \"env\", and \"services\" are all required when invoked via MCP (interactive pickers are unavailable without a TTY).',\n inputSchema: {\n version: z\n .string()\n .describe(\n 'Release version to deploy from (e.g. \"1.2.5\") \u2014 resolves to the release/vX.Y.Z branch. Pass \"dev\" to deploy from the dev branch instead. Required for MCP calls.',\n ),\n env: z\n .string()\n .describe(\n 'Target environment name \u2014 must match an env configured for the project (e.g. \"dev\", \"renana\", \"oriana\"). Required for MCP calls.',\n ),\n services: z\n .array(z.string())\n .describe(\n 'Service names to deploy. Each must match a boolean input declared in .github/workflows/deploy-selected-services.yml (e.g. \"client-be\", \"client-fe\"). Required for MCP calls.',\n ),\n skipTerraform: z.boolean().optional().describe('Skip the terraform deployment stage.'),\n },\n outputSchema: {\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 services: z.array(z.string()).describe('The services that were deployed'),\n skipTerraformDeploy: z.boolean().describe('Whether terraform deployment was skipped'),\n success: z.boolean().describe('Whether the deployment was successful'),\n },\n handler: ghReleaseDeploySelected,\n}\n", "import { z } from 'zod/v4'\n\nimport { getReleasePRsWithInfo } from 'src/integrations/gh'\nimport { logger } from 'src/lib/logger'\nimport { detectReleaseType, formatVersionLabel, getJiraDescriptions } from 'src/lib/release-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 getReleasePRsWithInfo()\n\n const releases = releasePRs.map((pr) => {\n return {\n version: pr.branch.replace('release/', ''),\n type: detectReleaseType(pr.title),\n }\n })\n\n const jiraDescriptions = await getJiraDescriptions()\n\n const maxVersionLength = Math.max(\n ...releases.map((r) => {\n return r.version.length\n }),\n )\n\n const formattedLines = releases.map((release) => {\n const label = formatVersionLabel(release.version, release.type, maxVersionLength)\n const description = jiraDescriptions.get(release.version)\n\n if (description) {\n return `${label} ${description}`\n }\n\n return label\n })\n\n logger.info('All release branches: \\n')\n logger.info(`\\n${formattedLines.join('\\n')}\\n`)\n\n const structuredContent = {\n releases: releases.map((release) => {\n return {\n version: release.version,\n type: release.type,\n description: jiraDescriptions.get(release.version) || null,\n }\n }),\n count: releases.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\nexport const ghReleaseListMcpTool = {\n name: 'gh-release-list',\n description:\n 'List every open release PR with its version, type (regular / hotfix), and associated Jira fix-version description. Read-only; sourced from GitHub and Jira.',\n inputSchema: {},\n outputSchema: {\n releases: z\n .array(\n z.object({\n version: z.string().describe('Release version'),\n type: z.enum(['regular', 'hotfix']).describe('Release type'),\n description: z.string().nullable().describe('Jira version description'),\n }),\n )\n .describe('List of all release branches'),\n count: z.number().describe('Number of release branches'),\n },\n handler: ghReleaseList,\n}\n", "import confirm from '@inquirer/confirm'\nimport select from '@inquirer/select'\nimport process from 'node:process'\nimport { z } from 'zod/v4'\nimport { question } from 'zx'\n\nimport { loadJiraConfig } from 'src/integrations/jira'\nimport { commandEcho } from 'src/lib/command-echo'\nimport { logger } from 'src/lib/logger'\nimport { createSingleRelease, prepareGitForRelease } from 'src/lib/release-utils'\nimport type { ReleaseType } from 'src/lib/release-utils'\nimport {\n NEXT_TOKEN,\n NoPriorVersionsError,\n computeNextVersion,\n loadExistingVersions,\n resolveVersionTokens,\n splitVersionInput,\n} from 'src/lib/version-utils'\nimport type { SemVer } from 'src/lib/version-utils'\nimport type { RequiredConfirmedOptionArg, ToolsExecutionResult } from 'src/types'\n\nimport { releaseCreateBatch } from '../release-create-batch/release-create-batch'\n\ninterface ReleaseCreateArgs extends RequiredConfirmedOptionArg {\n version?: string\n description?: string\n type?: ReleaseType\n}\n\nconst VERSION_PROMPT_HINT = '\"1.2.5\", \"next\", or \"next,next,1.2.7\"'\n\nconst promptForType = async (): Promise<ReleaseType> => {\n commandEcho.setInteractive()\n\n return select<ReleaseType>({\n message: 'Select release type:',\n choices: [\n { name: 'regular', value: 'regular' },\n { name: 'hotfix', value: 'hotfix' },\n ],\n default: 'regular',\n })\n}\n\nconst trySuggestNext = (known: SemVer[], type: ReleaseType): string | null => {\n try {\n return computeNextVersion(known, type)\n } catch (err) {\n if (err instanceof NoPriorVersionsError) return null\n\n throw err\n }\n}\n\nconst exitOnNoPrior = (err: unknown): never => {\n if (err instanceof NoPriorVersionsError) {\n logger.error(err.message)\n process.exit(1)\n }\n\n throw err\n}\n\ninterface ResolveTokensArgs {\n inputVersion: string | undefined\n type: ReleaseType\n ensureKnown: () => Promise<SemVer[]>\n}\n\nconst resolveRawTokens = async (args: ResolveTokensArgs): Promise<string[]> => {\n const { inputVersion, type, ensureKnown } = args\n\n if (inputVersion && inputVersion.trim() !== '') {\n return splitVersionInput(inputVersion)\n }\n\n commandEcho.setInteractive()\n\n const suggestion = trySuggestNext(await ensureKnown(), type)\n const defaultHint = suggestion ? ` [${suggestion}]` : ''\n const answer = (await question(`Enter version(s) (e.g. ${VERSION_PROMPT_HINT})${defaultHint}: `)).trim()\n\n if (answer === '') return suggestion ? [suggestion] : []\n\n return splitVersionInput(answer)\n}\n\nconst resolveVersionList = async (args: ResolveTokensArgs): Promise<string[]> => {\n const rawTokens = await resolveRawTokens(args)\n\n if (rawTokens.length === 0) {\n logger.error('No version provided. Exiting...')\n process.exit(1)\n }\n\n const needsKnown = rawTokens.some((t) => {\n return t.toLowerCase() === NEXT_TOKEN\n })\n\n try {\n return resolveVersionTokens(rawTokens, args.type, needsKnown ? await args.ensureKnown() : [])\n } catch (err) {\n return exitOnNoPrior(err)\n }\n}\n\nconst resolveDescription = async (input: string | undefined): Promise<string> => {\n if (input !== undefined) return input\n\n commandEcho.setInteractive()\n const answer = await question('Enter description (optional, press Enter to skip): ')\n\n return answer.trim()\n}\n\n/**\n * Create a single release branch for the specified version\n * Includes Jira version creation and GitHub release branch creation\n */\nexport const releaseCreate = async (args: ReleaseCreateArgs): Promise<ToolsExecutionResult> => {\n const { version: inputVersion, description: inputDescription, type: inputType, confirmedCommand } = args\n\n commandEcho.start('release-create')\n\n // Load Jira config - it is now mandatory\n const jiraConfig = await loadJiraConfig()\n\n const type: ReleaseType = inputType ?? (await promptForType())\n\n commandEcho.addOption('--type', type)\n\n let known: SemVer[] | null = null\n const ensureKnown = async (): Promise<SemVer[]> => {\n if (known === null) known = await loadExistingVersions()\n\n return known\n }\n\n const resolvedVersions = await resolveVersionList({ inputVersion, type, ensureKnown })\n\n if (resolvedVersions.length > 1) {\n logger.info(`Detected ${resolvedVersions.length} versions, routing to release-create-batch...`)\n\n return releaseCreateBatch({\n versions: resolvedVersions.join(','),\n type,\n confirmedCommand,\n })\n }\n\n const trimmedVersion = resolvedVersions[0] as string\n\n commandEcho.addOption('--version', trimmedVersion)\n\n const description = await resolveDescription(inputDescription)\n\n if (description) {\n commandEcho.addOption('--description', description)\n }\n\n const answer = confirmedCommand\n ? true\n : await confirm({\n message: `Are you sure you want to create release branch for version ${trimmedVersion}?`,\n })\n\n if (!confirmedCommand) {\n commandEcho.setInteractive()\n }\n\n if (!answer) {\n logger.info('Operation cancelled. Exiting...')\n process.exit(0)\n }\n\n // Track --yes flag if confirmation was interactive (user confirmed)\n commandEcho.addOption('--yes', true)\n\n await prepareGitForRelease(type)\n\n const release = await createSingleRelease({ version: trimmedVersion, jiraConfig, description, type })\n\n logger.info(`\u2705 Successfully created release: v${trimmedVersion}`)\n logger.info(`\uD83D\uDD17 GitHub PR: ${release.prUrl}`)\n logger.info(`\uD83D\uDD17 Jira Version: ${release.jiraVersionUrl}`)\n\n commandEcho.print()\n\n const structuredContent = {\n version: trimmedVersion,\n type,\n branchName: release.branchName,\n prUrl: release.prUrl,\n jiraVersionUrl: release.jiraVersionUrl,\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\nexport const releaseCreateMcpTool = {\n name: 'release-create',\n description:\n 'Create a new release: cuts the release branch off the appropriate base (dev for regular releases, main for hotfixes), opens a GitHub release PR, and creates the matching Jira fix version. Does not switch the working tree to the new branch \u2014 the caller stays on the base branch. Confirmation is auto-skipped for MCP calls, so the caller is responsible for gating. \"version\" is required when invoked via MCP (the interactive input prompt is unreachable without a TTY); pass \"next\" to auto-compute the next version (regular bumps minor + resets patch; hotfix bumps patch on the highest minor) using the union of remote release branches and Jira fix versions. \"type\" / \"description\" default to regular / empty when omitted. For multiple versions in one call, prefer release-create-batch.',\n inputSchema: {\n version: z\n .string()\n .describe(\n 'Version to create (e.g., \"1.2.5\") or the literal token \"next\" for auto-increment. Required for MCP calls.',\n ),\n description: z.string().optional().describe('Optional description for the Jira version'),\n type: z\n .enum(['regular', 'hotfix'])\n .optional()\n .default('regular')\n .describe('Release type: \"regular\" or \"hotfix\" (default: \"regular\")'),\n },\n outputSchema: {\n version: z.string().describe('Version number'),\n type: z.enum(['regular', 'hotfix']).describe('Release type'),\n branchName: z.string().describe('Release branch name'),\n prUrl: z.string().describe('GitHub PR URL'),\n jiraVersionUrl: z.string().describe('Jira version URL'),\n },\n handler: releaseCreate,\n}\n", "import confirm from '@inquirer/confirm'\nimport select from '@inquirer/select'\nimport process from 'node:process'\nimport { z } from 'zod/v4'\nimport { question } from 'zx'\n\nimport { loadJiraConfig } from 'src/integrations/jira'\nimport { commandEcho } from 'src/lib/command-echo'\nimport { logger } from 'src/lib/logger'\nimport { createSingleRelease, prepareGitForRelease } from 'src/lib/release-utils'\nimport type { ReleaseCreationResult, ReleaseType } from 'src/lib/release-utils'\nimport {\n NEXT_TOKEN,\n NoPriorVersionsError,\n loadExistingVersions,\n resolveVersionTokens,\n splitVersionInput,\n} from 'src/lib/version-utils'\nimport type { RequiredConfirmedOptionArg, ToolsExecutionResult } from 'src/types'\n\ninterface ReleaseCreateBatchArgs extends RequiredConfirmedOptionArg {\n versions: string\n type?: ReleaseType\n}\n\nconst VERSIONS_PROMPT_HINT = '\"1.2.5, 1.2.6\", \"next,next\", or \"next,next,1.2.7\"'\n\n/**\n * Gather and validate batch release inputs interactively if needed\n */\nconst resolveInputs = async (args: ReleaseCreateBatchArgs): Promise<{ versionsList: string[]; type: ReleaseType }> => {\n const { versions: inputVersions, type: inputType, confirmedCommand } = args\n\n let versionInput = inputVersions\n let type: ReleaseType = inputType || 'regular'\n\n if (!inputType) {\n commandEcho.setInteractive()\n\n type = await select<ReleaseType>({\n message: 'Select release type:',\n choices: [\n { name: 'regular', value: 'regular' },\n { name: 'hotfix', value: 'hotfix' },\n ],\n default: 'regular',\n })\n }\n\n commandEcho.addOption('--type', type)\n\n if (!versionInput) {\n commandEcho.setInteractive()\n versionInput = await question(`Enter versions by comma (e.g. ${VERSIONS_PROMPT_HINT}): `)\n }\n\n const rawTokens = splitVersionInput(versionInput)\n\n if (rawTokens.length === 0) {\n logger.error('No versions provided. Exiting...')\n process.exit(1)\n }\n\n const needsKnown = rawTokens.some((t) => {\n return t.toLowerCase() === NEXT_TOKEN\n })\n const known = needsKnown ? await loadExistingVersions() : []\n\n let versionsList: string[]\n\n try {\n versionsList = resolveVersionTokens(rawTokens, type, known)\n } catch (err) {\n if (err instanceof NoPriorVersionsError) {\n logger.error(err.message)\n process.exit(1)\n }\n\n throw err\n }\n\n commandEcho.addOption('--versions', versionsList.join(', '))\n\n if (versionsList.length === 1) {\n logger.warn('\uD83D\uDCA1 You are creating only one release. Consider using \"create-release\" command for single releases.')\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 (!confirmedCommand) {\n commandEcho.setInteractive()\n }\n\n if (!answer) {\n logger.info('Operation cancelled. Exiting...')\n process.exit(0)\n }\n\n commandEcho.addOption('--yes', true)\n\n return { versionsList, type }\n}\n\n/**\n * Create multiple release branches for the specified versions\n * Includes Jira version creation and GitHub release branch creation for each version\n */\nexport const releaseCreateBatch = async (args: ReleaseCreateBatchArgs): Promise<ToolsExecutionResult> => {\n commandEcho.start('release-create-batch')\n\n const jiraConfig = await loadJiraConfig()\n\n const { versionsList, type } = await resolveInputs(args)\n\n await prepareGitForRelease(type)\n\n const releases: ReleaseCreationResult[] = []\n const failedReleases: Array<{ version: string; error: string }> = []\n\n for (const version of versionsList) {\n try {\n // Create each release\n const release = await createSingleRelease({ version, jiraConfig, type })\n\n releases.push(release)\n\n logger.info(`\u2705 Successfully created release: v${version}`)\n logger.info(`\uD83D\uDD17 GitHub PR: ${release.prUrl}`)\n logger.info(`\uD83D\uDD17 Jira Version: ${release.jiraVersionUrl}\\n`)\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error)\n\n failedReleases.push({ version, error: errorMessage })\n\n logger.error(`\u274C Failed to create release: v${version}`)\n logger.error(` Error: ${errorMessage}\\n`)\n }\n }\n\n // Final summary\n const successCount = releases.length\n const failureCount = failedReleases.length\n\n if (successCount === versionsList.length) {\n logger.info(`\u2705 All ${versionsList.length} release branches were created successfully.`)\n } else if (successCount > 0) {\n logger.warn(`\u26A0\uFE0F ${successCount} of ${versionsList.length} release branches were created successfully.`)\n logger.warn(`\u274C ${failureCount} release(s) failed.`)\n } else {\n logger.error(`\u274C All ${versionsList.length} release branches failed to create.`)\n }\n\n commandEcho.print()\n\n const structuredContent = {\n createdBranches: releases.map((r) => {\n return r.branchName\n }),\n successCount,\n failureCount,\n releases,\n failedReleases,\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\nexport const releaseCreateBatchMcpTool = {\n name: 'release-create-batch',\n description:\n 'Create several releases in one pass: for each comma-separated version in \"versions\", cuts the release branch off the appropriate base (dev for regular releases, main for hotfixes), opens a GitHub PR, and creates the Jira fix version. The literal token \"next\" auto-increments from the latest known version (regular bumps minor + resets patch; hotfix bumps patch on the highest minor); multiple \"next\" tokens advance sequentially. Existing versions are unioned from remote release branches and Jira fix versions. Continues on per-version failure and reports which versions succeeded and which failed. Confirmation is auto-skipped for MCP calls, so the caller is responsible for gating. \"versions\" is required when invoked via MCP (the interactive input prompt is unreachable without a TTY). Use release-create for a single version with optional checkout.',\n inputSchema: {\n versions: z\n .string()\n .describe(\n 'Comma-separated versions to create (e.g., \"1.2.5, 1.2.6\", \"next,next\", or \"next,next,1.2.7\"). Required for MCP calls.',\n ),\n type: z\n .enum(['regular', 'hotfix'])\n .optional()\n .default('regular')\n .describe('Release type: \"regular\" or \"hotfix\" (default: \"regular\")'),\n },\n outputSchema: {\n createdBranches: z.array(z.string()).describe('List of created release branches'),\n successCount: z.number().describe('Number of releases created successfully'),\n failureCount: z.number().describe('Number of releases that failed'),\n releases: z\n .array(\n z.object({\n version: z.string().describe('Version number'),\n type: z.enum(['regular', 'hotfix']).describe('Release type'),\n branchName: z.string().describe('Release branch name'),\n prUrl: z.string().describe('GitHub PR URL'),\n jiraVersionUrl: z.string().describe('Jira version URL'),\n }),\n )\n .describe('Detailed information for each created release with URLs'),\n failedReleases: z\n .array(\n z.object({\n version: z.string().describe('Version number that failed'),\n error: z.string().describe('Error message'),\n }),\n )\n .describe('List of releases that failed with error messages'),\n },\n handler: releaseCreateBatch,\n}\n", "import { z } from 'zod/v4'\n\nimport { logger } from 'src/lib/logger'\nimport type { ToolsExecutionResult } from 'src/types'\n\nimport packageJson from '../../../package.json' with { type: 'json' }\n\n/**\n * Print the infra-kit CLI version\n */\nexport const version = async (): Promise<ToolsExecutionResult> => {\n const cliVersion = packageJson.version\n\n logger.info(cliVersion)\n\n const structuredContent = { version: cliVersion }\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\nexport const versionMcpTool = {\n name: 'version',\n description: 'Print the installed infra-kit CLI version',\n inputSchema: {},\n outputSchema: {\n version: z.string().describe('Installed infra-kit CLI version (from package.json)'),\n },\n handler: version,\n}\n", "{\n \"name\": \"infra-kit\",\n \"type\": \"module\",\n \"version\": \"0.1.98\",\n \"description\": \"infra-kit\",\n \"main\": \"dist/cli.js\",\n \"module\": \"dist/cli.js\",\n \"bin\": {\n \"infra-kit\": \"dist/cli.js\",\n \"ik\": \"dist/cli.js\"\n },\n \"engines\": {\n \"node\": \">=24.x\"\n },\n \"scripts\": {\n \"inspector\": \"npx @modelcontextprotocol/inspector node ./dist/mcp.js --debug\",\n \"build\": \"pnpm run clean-artifacts && node ./scripts/build.js\",\n \"clean-artifacts\": \"rm -rf dist\",\n \"clean-cache\": \"rm -rf node_modules/.cache .eslintcache tsconfig.tsbuildinfo .turbo .swc\",\n \"prettier-fix\": \"pnpm exec prettier **/* --write --no-error-on-unmatched-pattern --log-level warn --ignore-path ../../../.prettierignore\",\n \"prettier-check\": \"pnpm exec prettier **/* --check --no-error-on-unmatched-pattern --log-level warn --ignore-path ../../../.prettierignore\",\n \"eslint-check\": \"pnpm exec eslint --cache --quiet --report-unused-disable-directives ./src\",\n \"eslint-fix\": \"pnpm exec eslint --cache --quiet --report-unused-disable-directives ./src --fix\",\n \"ts-check\": \"tsc --noEmit\",\n \"test\": \"pnpm exec vitest run --reporter=dot\",\n \"test-watch\": \"pnpm exec vitest --watch\",\n \"test-ui\": \"pnpm exec vitest --ui\",\n \"test-report\": \"pnpm exec vitest run --coverage\",\n \"qa\": \"pnpm run prettier-check && pnpm run eslint-check && pnpm run ts-check && pnpm run test && echo \u2705 Success\",\n \"fix\": \"pnpm run prettier-fix && pnpm run eslint-fix && pnpm run qa\"\n },\n \"dependencies\": {\n \"@inquirer/checkbox\": \"^5.1.4\",\n \"@inquirer/confirm\": \"^6.0.12\",\n \"@inquirer/select\": \"^5.1.4\",\n \"@modelcontextprotocol/sdk\": \"^1.29.0\",\n \"commander\": \"^14.0.3\",\n \"pino\": \"^10.3.1\",\n \"pino-pretty\": \"^13.1.3\",\n \"yaml\": \"^2.8.4\",\n \"zod\": \"^3.25.76\",\n \"zx\": \"^8.8.5\"\n },\n \"devDependencies\": {\n \"@pkg/eslint-config\": \"workspace:*\",\n \"@pkg/vitest-config\": \"workspace:*\",\n \"esbuild\": \"^0.28.0\",\n \"typescript\": \"catalog:\"\n }\n}\n", "/* eslint-disable sonarjs/cognitive-complexity */\nimport checkbox from '@inquirer/checkbox'\nimport confirm from '@inquirer/confirm'\nimport select from '@inquirer/select'\nimport process from 'node:process'\nimport { z } from 'zod/v4'\nimport { $ } from 'zx'\n\nimport { buildCmuxWorkspaceTitle, openCmuxWorkspaceWithLayout } from 'src/integrations/cmux'\nimport { addFoldersToCursorWorkspace, resolveCursorWorkspacePath } from 'src/integrations/cursor'\nimport { getReleasePRsWithInfo } from 'src/integrations/gh'\nimport { commandEcho } from 'src/lib/command-echo'\nimport { WORKTREES_DIR_SUFFIX } from 'src/lib/constants'\nimport { getCurrentWorktrees, getProjectRoot, getRepoName } from 'src/lib/git-utils'\nimport { getInfraKitConfig } from 'src/lib/infra-kit-config'\nimport { logger } from 'src/lib/logger'\nimport { detectReleaseType, formatBranchChoices, getJiraDescriptions } from 'src/lib/release-utils'\nimport type { ReleaseType } from 'src/lib/release-utils'\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\nexport const CURSOR_MODES = ['workspace', 'windows', 'none'] as const\nexport type CursorMode = (typeof CURSOR_MODES)[number]\n\ninterface WorktreeManagementArgs extends RequiredConfirmedOptionArg {\n all: boolean\n versions?: string\n cursor?: CursorMode\n githubDesktop?: boolean\n cmux?: 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, versions, cursor, githubDesktop, cmux } = options\n\n commandEcho.start('worktrees-add')\n\n try {\n const currentWorktrees = await getCurrentWorktrees('release')\n const projectRoot = await getProjectRoot()\n\n const worktreeDir = `${projectRoot}${WORKTREES_DIR_SUFFIX}`\n\n await ensureWorktreeDirectory(`${worktreeDir}/${RELEASE_DIR}`)\n await ensureWorktreeDirectory(`${worktreeDir}/${FEATURE_DIR}`)\n\n let selectedReleaseBranches: string[] = []\n\n if (versions) {\n selectedReleaseBranches = versions.split(',').map((v) => {\n return `release/v${v.trim()}`\n })\n } else {\n const releasePRsInfo = await getReleasePRsWithInfo()\n\n const releasePRsList = releasePRsInfo.map((pr) => {\n return pr.branch\n })\n\n if (releasePRsList.length === 0) {\n logger.info('\u2139\uFE0F No open release branches found')\n\n commandEcho.print()\n\n return {\n content: [{ type: 'text', text: JSON.stringify({ createdWorktrees: [], count: 0 }, null, 2) }],\n structuredContent: { createdWorktrees: [], count: 0 },\n }\n }\n\n if (all) {\n selectedReleaseBranches = releasePRsList\n } else {\n commandEcho.setInteractive()\n\n const releaseTypes = new Map<string, ReleaseType>(\n releasePRsInfo.map((pr) => {\n return [pr.branch, detectReleaseType(pr.title)]\n }),\n )\n\n const descriptions = await getJiraDescriptions()\n\n selectedReleaseBranches = await checkbox({\n required: true,\n message: '\uD83C\uDF3F Select release branches',\n choices: formatBranchChoices({ branches: releasePRsList, descriptions, types: releaseTypes }),\n })\n }\n }\n\n // Track --all flag if all branches were selected (either via flag or interactively)\n if (all) {\n commandEcho.addOption('--all', true)\n } else {\n commandEcho.addOption(\n '--versions',\n selectedReleaseBranches.map((branch) => {\n return branch.replace('release/v', '')\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 (!confirmedCommand) {\n commandEcho.setInteractive()\n }\n\n if (!answer) {\n logger.info('Operation cancelled. Exiting...')\n process.exit(0)\n }\n\n // Track --yes flag if confirmation was interactive (user confirmed)\n if (!confirmedCommand) {\n commandEcho.addOption('--yes', true)\n }\n\n const cursorMode: CursorMode =\n cursor ??\n (await select<CursorMode>({\n message: 'Cursor mode for created worktrees?',\n default: 'workspace',\n choices: [\n {\n name: 'Add to workspace file',\n value: 'workspace',\n description: 'Append each worktree as a folder in ide.config.workspaceConfigPath, then open the workspace',\n },\n {\n name: 'Open separate windows',\n value: 'windows',\n description: 'Open each created worktree in its own Cursor window',\n },\n { name: 'Skip', value: 'none', description: 'Do not open Cursor' },\n ],\n }))\n\n if (typeof cursor === 'undefined') {\n commandEcho.setInteractive()\n }\n\n commandEcho.addOption('--cursor', cursorMode)\n\n const openInGithubDesktop =\n githubDesktop ?? (await confirm({ message: 'Open created worktrees in GitHub Desktop?' }))\n\n if (typeof githubDesktop === 'undefined') {\n commandEcho.setInteractive()\n }\n\n if (openInGithubDesktop) {\n commandEcho.addOption('--github-desktop', true)\n } else {\n commandEcho.addOption('--no-github-desktop', true)\n }\n\n const openInCmux = cmux ?? (await confirm({ message: 'Open created worktrees in cmux?' }))\n\n if (typeof cmux === 'undefined') {\n commandEcho.setInteractive()\n }\n\n if (openInCmux) {\n commandEcho.addOption('--cmux', true)\n } else {\n commandEcho.addOption('--no-cmux', true)\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 if (cursorMode === 'workspace') {\n const config = await getInfraKitConfig()\n const cursorConfig = config.ide?.provider === 'cursor' ? config.ide.config : undefined\n\n if (!cursorConfig?.workspaceConfigPath) {\n logger.warn('\u26A0\uFE0F Skipping Cursor: ide.config.workspaceConfigPath is not set in infra-kit.yml')\n } else {\n const workspacePath = resolveCursorWorkspacePath(cursorConfig.workspaceConfigPath, projectRoot)\n\n const folderPaths = createdWorktrees.map((branch) => {\n return `${worktreeDir}/${branch}`\n })\n\n const { added, skipped } = await addFoldersToCursorWorkspace({ workspacePath, folderPaths })\n\n const skippedSuffix = skipped.length > 0 ? ` (${skipped.length} already present)` : ''\n\n logger.info(`\u2705 Added ${added.length} folder(s) to ${workspacePath}${skippedSuffix}`)\n\n await $`cursor ${workspacePath}`\n }\n } else if (cursorMode === 'windows') {\n for (const branch of createdWorktrees) {\n await $`cursor ${worktreeDir}/${branch}`\n }\n }\n\n if (openInGithubDesktop) {\n for (const branch of createdWorktrees) {\n await $`github ${worktreeDir}/${branch}`\n await $`sleep 5`\n }\n }\n\n if (openInCmux) {\n const repoName = await getRepoName()\n\n for (const branch of createdWorktrees) {\n const title = buildCmuxWorkspaceTitle({ repoName, branch })\n\n await openCmuxWorkspaceWithLayout({\n cwd: `${worktreeDir}/${branch}`,\n title,\n })\n }\n }\n\n commandEcho.print()\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) => {\n return branch.startsWith(RELEASE_BRANCH_PREFIX)\n })\n\n const branchesToCreate = selectedReleaseBranches.filter((branch) => {\n return !currentBranchNames.includes(branch)\n })\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 results = await Promise.allSettled(\n branches.map(async (branch) => {\n const worktreePath = `${worktreeDir}/${branch}`\n\n await $`git worktree add ${worktreePath} ${branch}`\n await $({ cwd: worktreePath })`pnpm install`\n\n return branch\n }),\n )\n\n const created: string[] = []\n\n for (const [index, result] of results.entries()) {\n if (result.status === 'fulfilled') {\n created.push(result.value)\n } else {\n const branch = branches[index]\n\n logger.error({ error: result.reason }, `\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('\u2705 Created git worktrees:')\n for (const branch of created) {\n logger.info(branch)\n }\n logger.info('')\n } else {\n logger.info('\u2139\uFE0F No new git worktrees to create')\n }\n}\n\n// MCP Tool Registration\nexport const worktreesAddMcpTool = {\n name: 'worktrees-add',\n description:\n 'Create local git worktrees for release branches under the worktrees directory and run \"pnpm install\" in each. Mutates the local filesystem. When invoked via MCP, pass either \"versions\" (comma-separated) or all=true \u2014 the branch picker and \"open in Cursor / GitHub Desktop / cmux\" follow-up prompts are unreachable without a TTY, and the CLI confirmation is auto-skipped for MCP calls.',\n inputSchema: {\n all: z\n .boolean()\n .optional()\n .describe(\n 'Add worktrees for every open release branch. Either \"all\" or \"versions\" must be provided for MCP calls (the interactive picker is unavailable without a TTY). Ignored if \"versions\" is provided.',\n ),\n versions: z\n .string()\n .optional()\n .describe(\n 'Comma-separated release versions to target (e.g. \"1.2.5, 1.2.6\"). Either \"versions\" or all=true must be provided for MCP calls. Overrides \"all\" when set.',\n ),\n cursor: z\n .enum(CURSOR_MODES)\n .optional()\n .describe(\n 'Cursor open mode for created worktrees. \"workspace\" (default behavior when set interactively) appends each worktree as a folder to \"ide.config.workspaceConfigPath\" in infra-kit.yml and opens the workspace. \"windows\" opens each worktree in its own Cursor window. \"none\" skips Cursor. Defaults to \"none\" in MCP mode (the follow-up prompt is not shown).',\n ),\n githubDesktop: z\n .boolean()\n .optional()\n .describe(\n 'Open each created worktree in GitHub Desktop. Defaults to false in MCP mode (the follow-up prompt is not shown).',\n ),\n cmux: z\n .boolean()\n .optional()\n .describe(\n 'Open each created worktree in a new cmux workspace with a 3-pane layout (left-top, left-bottom, full-height right), all rooted at the worktree directory. Defaults to false in MCP mode (the follow-up prompt is not shown).',\n ),\n },\n outputSchema: {\n createdWorktrees: z.array(z.string()).describe('List of created git worktree branches'),\n count: z.number().describe('Number of git worktrees created'),\n },\n handler: worktreesAdd,\n}\n", "import { $ } from 'zx'\n\nimport { logger } from 'src/lib/logger'\n\n/**\n * Best-effort close of the cmux workspace whose title exactly matches `title`.\n * Silently no-ops if cmux isn't running, the workspace isn't found, or close fails.\n */\nexport const closeCmuxWorkspaceByTitle = async (title: string): Promise<void> => {\n try {\n const listOutput = (await $`cmux list-workspaces`.quiet()).stdout\n\n const ref = findWorkspaceRefByTitle(listOutput, title)\n\n if (!ref) {\n return\n }\n\n await $`cmux close-workspace --workspace ${ref}`.quiet()\n } catch (error) {\n logger.debug({ error, title }, 'cmux: skipped closing workspace')\n }\n}\n\n/**\n * Parses `cmux list-workspaces` output and returns the workspace ref whose\n * title exactly matches `title`, or undefined if no match.\n *\n * Each line looks like:\n * \" workspace:8 hulyo-monorepo v1.48.0\"\n * \"* workspace:6 obsidian-workspace [selected]\"\n */\nconst findWorkspaceRefByTitle = (output: string, title: string): string | undefined => {\n for (const rawLine of output.split('\\n')) {\n // eslint-disable-next-line sonarjs/slow-regex, regexp/no-super-linear-backtracking\n const match = rawLine.match(/^[* ]\\s*(workspace:\\d+)\\s+(.+?)(?:\\s+\\[selected\\])?\\s*$/)\n\n if (!match) {\n continue\n }\n\n const ref = match[1]\n const lineTitle = match[2]?.trim() ?? ''\n\n if (lineTitle === title) {\n return ref\n }\n }\n\n return undefined\n}\n", "import { $ } from 'zx'\n\nimport { logger } from 'src/lib/logger'\n\n/**\n * Returns the set of titles for all currently-open cmux workspaces.\n * Returns an empty set if cmux isn't running, the call fails, or the\n * output can't be parsed \u2014 callers should treat \"empty\" as \"unknown,\n * proceed as if nothing is open\".\n *\n * Each line of `cmux list-workspaces` looks like:\n * \" workspace:8 hulyo-monorepo v1.48.0\"\n * \"* workspace:6 obsidian-workspace [selected]\"\n */\nexport const listCmuxWorkspaceTitles = async (): Promise<Set<string>> => {\n try {\n const output = (await $`cmux list-workspaces`.quiet()).stdout\n\n const titles = new Set<string>()\n\n for (const rawLine of output.split('\\n')) {\n // eslint-disable-next-line sonarjs/slow-regex, regexp/no-super-linear-backtracking\n const match = rawLine.match(/^[* ]\\s*workspace:\\d+\\s+(.+?)(?:\\s+\\[selected\\])?\\s*$/)\n\n if (!match) {\n continue\n }\n\n const title = match[1]?.trim()\n\n if (title) {\n titles.add(title)\n }\n }\n\n return titles\n } catch (error) {\n logger.debug({ error }, 'cmux: skipped listing workspace titles')\n\n return new Set()\n }\n}\n", "import { $ } from 'zx'\n\ninterface OpenCmuxWorkspaceArgs {\n cwd: string\n title?: string\n}\n\n/**\n * Opens a new cmux workspace rooted at `cwd` with three panes:\n * left-top (primary) | right (full-height)\n * left-bottom |\n * All panes inherit `cwd` from the workspace.\n */\nexport const openCmuxWorkspaceWithLayout = async (args: OpenCmuxWorkspaceArgs): Promise<void> => {\n const { cwd, title } = args\n\n const newWorkspaceOutput = (await $`cmux new-workspace --cwd ${cwd}`).stdout\n\n const workspaceRef = parseWorkspaceRef(newWorkspaceOutput)\n\n const surfacesOutput = (await $`cmux list-pane-surfaces --workspace ${workspaceRef}`).stdout\n\n const leftTopRef = parseFirstSurfaceRef(surfacesOutput)\n\n await $`cmux new-split right --workspace ${workspaceRef} --surface ${leftTopRef}`\n await $`cmux new-split down --workspace ${workspaceRef} --surface ${leftTopRef}`\n\n if (title) {\n await $`cmux rename-workspace --workspace ${workspaceRef} ${title}`\n }\n}\n\n/**\n * Extracts the first `surface:<id>` reference from the output of\n * `cmux list-pane-surfaces`. Used to locate the initial (primary) pane\n * surface so subsequent splits can be anchored relative to it.\n *\n * @example\n * const output = 'surface:12 (active)\\nsurface:13\\n'\n * parseFirstSurfaceRef(output) // => 'surface:12'\n */\nconst parseFirstSurfaceRef = (output: string): string => {\n const match = output.match(/surface:\\d+/)\n\n if (!match) {\n throw new Error('cmux: could not locate initial surface in list-pane-surfaces output')\n }\n\n return match[0]\n}\n\n/**\n * Extracts the `workspace:<id>` reference from the output of\n * `cmux new-workspace`. The returned ref is used to target the newly\n * created workspace in follow-up `cmux` commands (splits, rename, etc.).\n *\n * @example\n * const output = 'created workspace:7\\n'\n * parseWorkspaceRef(output) // => 'workspace:7'\n */\nconst parseWorkspaceRef = (output: string): string => {\n const match = output.match(/workspace:\\d+/)\n\n if (!match) {\n throw new Error('cmux: could not locate workspace ref in new-workspace output')\n }\n\n return match[0]\n}\n", "interface BuildCmuxWorkspaceTitleArgs {\n repoName: string\n branch: string\n}\n\n/**\n * Builds the cmux workspace title used by `worktrees-add` and looked up by\n * `worktrees-remove`. The `release/` prefix is stripped so the title reads\n * e.g. `\"hulyo-monorepo v1.48.0\"` for branch `\"release/v1.48.0\"`.\n */\nexport const buildCmuxWorkspaceTitle = (args: BuildCmuxWorkspaceTitleArgs): string => {\n const { repoName, branch } = args\n\n const version = branch.replace('release/', '')\n\n return `${repoName} ${version}`\n}\n", "import fs from 'node:fs/promises'\nimport path from 'node:path'\n\ninterface AddFoldersToCursorWorkspaceArgs {\n workspacePath: string\n folderPaths: string[]\n}\n\ninterface AddFoldersToCursorWorkspaceResult {\n added: string[]\n skipped: string[]\n}\n\ninterface WorkspaceFolderEntry {\n path: string\n name?: string\n}\n\ninterface WorkspaceFile {\n folders?: WorkspaceFolderEntry[]\n [key: string]: unknown\n}\n\n/**\n * Adds folders to a Cursor (`.code-workspace`) file's `folders` array, skipping\n * entries that already point to the same absolute path. Folder paths are written\n * as relative to the workspace file's directory to match Cursor's default style.\n */\nexport const addFoldersToCursorWorkspace = async (\n args: AddFoldersToCursorWorkspaceArgs,\n): Promise<AddFoldersToCursorWorkspaceResult> => {\n const { workspacePath, folderPaths } = args\n\n const workspaceDir = path.dirname(workspacePath)\n\n let raw: string\n\n try {\n raw = await fs.readFile(workspacePath, 'utf-8')\n } catch (error) {\n throw new Error(`Cursor workspace file not found at ${workspacePath}: ${(error as Error).message}`)\n }\n\n let parsed: WorkspaceFile\n\n try {\n parsed = JSON.parse(raw) as WorkspaceFile\n } catch (error) {\n throw new Error(\n `Failed to parse ${workspacePath} as JSON. Comments (JSONC) are not supported. ${(error as Error).message}`,\n )\n }\n\n const existingFolders = parsed.folders ?? []\n const existingAbsolutePaths = new Set(\n existingFolders.map((entry) => {\n return path.resolve(workspaceDir, entry.path)\n }),\n )\n\n const added: string[] = []\n const skipped: string[] = []\n\n for (const folderPath of folderPaths) {\n const absolutePath = path.resolve(folderPath)\n\n if (existingAbsolutePaths.has(absolutePath)) {\n skipped.push(folderPath)\n continue\n }\n\n const relativePath = path.relative(workspaceDir, absolutePath)\n\n existingFolders.push({ path: relativePath })\n existingAbsolutePaths.add(absolutePath)\n added.push(folderPath)\n }\n\n parsed.folders = existingFolders\n\n await fs.writeFile(workspacePath, `${JSON.stringify(parsed, null, 2)}\\n`, 'utf-8')\n\n return { added, skipped }\n}\n", "import fs from 'node:fs/promises'\nimport path from 'node:path'\n\nimport { addFoldersToCursorWorkspace } from './add-folders-to-workspace'\nimport { removeFoldersFromCursorWorkspace } from './remove-folders-from-workspace'\n\ninterface ReconcileCursorWorkspaceFoldersArgs {\n workspacePath: string\n worktreeDir: string\n currentBranches: string[]\n}\n\ninterface ReconcileCursorWorkspaceFoldersResult {\n added: string[]\n removed: string[]\n}\n\ninterface WorkspaceFolderEntry {\n path: string\n name?: string\n}\n\ninterface WorkspaceFile {\n folders?: WorkspaceFolderEntry[]\n [key: string]: unknown\n}\n\n/**\n * Reconciles the configured Cursor workspace's `folders` array against the\n * actual set of release worktrees on disk:\n * - Adds any worktree folders that aren't already listed.\n * - Removes entries whose absolute path lives under `${worktreeDir}/release/`\n * but no longer corresponds to a current branch (drift from manual\n * `git worktree remove`, deleted branches, etc.).\n *\n * Non-worktree folder entries are left untouched.\n */\nexport const reconcileCursorWorkspaceFolders = async (\n args: ReconcileCursorWorkspaceFoldersArgs,\n): Promise<ReconcileCursorWorkspaceFoldersResult> => {\n const { workspacePath, worktreeDir, currentBranches } = args\n\n const workspaceDir = path.dirname(workspacePath)\n const releaseRoot = path.resolve(`${worktreeDir}/release`)\n\n const raw = await fs.readFile(workspacePath, 'utf-8')\n const parsed = JSON.parse(raw) as WorkspaceFile\n\n const existingFolders = parsed.folders ?? []\n\n const desiredAbsolutePaths = new Set(\n currentBranches.map((branch) => {\n return path.resolve(`${worktreeDir}/${branch}`)\n }),\n )\n\n const danglingFolderPaths: string[] = []\n\n for (const entry of existingFolders) {\n const entryAbsolutePath = path.resolve(workspaceDir, entry.path)\n\n const isReleaseShaped = entryAbsolutePath === releaseRoot || entryAbsolutePath.startsWith(`${releaseRoot}/`)\n\n if (isReleaseShaped && !desiredAbsolutePaths.has(entryAbsolutePath)) {\n danglingFolderPaths.push(entryAbsolutePath)\n }\n }\n\n let removed: string[] = []\n\n if (danglingFolderPaths.length > 0) {\n const result = await removeFoldersFromCursorWorkspace({\n workspacePath,\n folderPaths: danglingFolderPaths,\n })\n\n removed = result.removed\n }\n\n const desiredFolderPaths = currentBranches.map((branch) => {\n return `${worktreeDir}/${branch}`\n })\n\n const { added } =\n desiredFolderPaths.length > 0\n ? await addFoldersToCursorWorkspace({ workspacePath, folderPaths: desiredFolderPaths })\n : { added: [] as string[] }\n\n return { added, removed }\n}\n", "import fs from 'node:fs/promises'\nimport path from 'node:path'\n\ninterface RemoveFoldersFromCursorWorkspaceArgs {\n workspacePath: string\n folderPaths: string[]\n}\n\ninterface RemoveFoldersFromCursorWorkspaceResult {\n removed: string[]\n notFound: string[]\n}\n\ninterface WorkspaceFolderEntry {\n path: string\n name?: string\n}\n\ninterface WorkspaceFile {\n folders?: WorkspaceFolderEntry[]\n [key: string]: unknown\n}\n\n/**\n * Removes folders from a Cursor (`.code-workspace`) file's `folders` array. Entries\n * are matched by resolved absolute path, so relative and absolute entries pointing\n * at the same folder are both removed.\n */\nexport const removeFoldersFromCursorWorkspace = async (\n args: RemoveFoldersFromCursorWorkspaceArgs,\n): Promise<RemoveFoldersFromCursorWorkspaceResult> => {\n const { workspacePath, folderPaths } = args\n\n const workspaceDir = path.dirname(workspacePath)\n\n let raw: string\n\n try {\n raw = await fs.readFile(workspacePath, 'utf-8')\n } catch (error) {\n throw new Error(`Cursor workspace file not found at ${workspacePath}: ${(error as Error).message}`)\n }\n\n let parsed: WorkspaceFile\n\n try {\n parsed = JSON.parse(raw) as WorkspaceFile\n } catch (error) {\n throw new Error(\n `Failed to parse ${workspacePath} as JSON. Comments (JSONC) are not supported. ${(error as Error).message}`,\n )\n }\n\n const existingFolders = parsed.folders ?? []\n const targetAbsolutePaths = new Set(\n folderPaths.map((folderPath) => {\n return path.resolve(folderPath)\n }),\n )\n\n const removedAbsolutePaths = new Set<string>()\n\n const filteredFolders = existingFolders.filter((entry) => {\n const entryAbsolutePath = path.resolve(workspaceDir, entry.path)\n\n if (targetAbsolutePaths.has(entryAbsolutePath)) {\n removedAbsolutePaths.add(entryAbsolutePath)\n\n return false\n }\n\n return true\n })\n\n parsed.folders = filteredFolders\n\n await fs.writeFile(workspacePath, `${JSON.stringify(parsed, null, 2)}\\n`, 'utf-8')\n\n const removed: string[] = []\n const notFound: string[] = []\n\n for (const folderPath of folderPaths) {\n const absolutePath = path.resolve(folderPath)\n\n if (removedAbsolutePaths.has(absolutePath)) {\n removed.push(folderPath)\n } else {\n notFound.push(folderPath)\n }\n }\n\n return { removed, notFound }\n}\n", "import path from 'node:path'\n\n/**\n * Resolves the configured Cursor workspace path against the project root.\n * Absolute paths are returned unchanged.\n */\nexport const resolveCursorWorkspacePath = (configValue: string, projectRoot: string): string => {\n if (path.isAbsolute(configValue)) {\n return configValue\n }\n\n return path.resolve(projectRoot, configValue)\n}\n", "import { z } from 'zod/v4'\n\nimport { getReleasePRsWithInfo } from 'src/integrations/gh'\nimport { getCurrentWorktrees } from 'src/lib/git-utils'\nimport { logger } from 'src/lib/logger'\nimport { detectReleaseType, formatVersionLabel, getJiraDescriptions } from 'src/lib/release-utils'\nimport type { ReleaseType } from 'src/lib/release-utils'\nimport type { ToolsExecutionResult } from 'src/types'\n\ninterface WorktreeInfo {\n version: string\n type: ReleaseType\n description: string | null\n}\n\n/**\n * List all release git worktrees with version, type, and Jira description\n */\nexport const worktreesList = async (): Promise<ToolsExecutionResult> => {\n const currentWorktrees = await getCurrentWorktrees('release')\n\n if (currentWorktrees.length === 0) {\n logger.info('\u2139\uFE0F No active worktrees found')\n\n return {\n content: [{ type: 'text', text: JSON.stringify({ worktrees: [], count: 0 }, null, 2) }],\n structuredContent: { worktrees: [], count: 0 },\n }\n }\n\n const [releasePRsInfo, jiraDescriptions] = await Promise.all([getReleasePRsWithInfo(), getJiraDescriptions()])\n\n const releaseTypes = new Map<string, ReleaseType>(\n releasePRsInfo.map((pr) => {\n return [pr.branch, detectReleaseType(pr.title)]\n }),\n )\n\n const worktrees: WorktreeInfo[] = currentWorktrees.map((branch) => {\n const version = branch.replace('release/', '')\n const type = releaseTypes.get(branch) || 'regular'\n const description = jiraDescriptions.get(version) || null\n\n return { version, type, description }\n })\n\n // Log formatted output\n const maxVersionLength = Math.max(\n ...worktrees.map((w) => {\n return w.version.length\n }),\n )\n\n const formattedLines = worktrees.map((worktree) => {\n const label = formatVersionLabel(worktree.version, worktree.type, maxVersionLength)\n\n if (worktree.description) {\n return `${label} ${worktree.description}`\n }\n\n return label\n })\n\n logger.info('\uD83C\uDF3F Active worktrees:')\n logger.info(`\\n${formattedLines.join('\\n')}\\n`)\n\n const structuredContent = {\n worktrees,\n count: worktrees.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\nexport const worktreesListMcpTool = {\n name: 'worktrees-list',\n description:\n 'List existing release-branch worktrees with version, release type (regular / hotfix), and Jira fix-version description. Read-only.',\n inputSchema: {},\n outputSchema: {\n worktrees: z\n .array(\n z.object({\n version: z.string().describe('Release version'),\n type: z.enum(['regular', 'hotfix']).describe('Release type'),\n description: z.string().nullable().describe('Jira version description'),\n }),\n )\n .describe('List of all worktrees with details'),\n count: z.number().describe('Number of worktrees'),\n },\n handler: worktreesList,\n}\n", "import { z } from 'zod/v4'\nimport { $ } from 'zx'\n\nimport { buildCmuxWorkspaceTitle, listCmuxWorkspaceTitles, openCmuxWorkspaceWithLayout } from 'src/integrations/cmux'\nimport { reconcileCursorWorkspaceFolders, resolveCursorWorkspacePath } from 'src/integrations/cursor'\nimport { commandEcho } from 'src/lib/command-echo'\nimport { WORKTREES_DIR_SUFFIX } from 'src/lib/constants'\nimport { getCurrentWorktrees, getProjectRoot, getRepoName } from 'src/lib/git-utils'\nimport { getInfraKitConfig } from 'src/lib/infra-kit-config'\nimport { logger } from 'src/lib/logger'\nimport type { ToolsExecutionResult } from 'src/types'\n\ninterface WorktreesOpenResult {\n openedCmux: string[]\n skippedCmux: string[]\n cursorFoldersAdded: number\n cursorFoldersRemoved: number\n}\n\n/**\n * Cold-start restore command: reconciles `Main.code-workspace` against the set\n * of release worktrees on disk, opens Cursor against it, and ensures one cmux\n * workspace exists per worktree. Idempotent and additive \u2014 never removes\n * worktrees, never recreates running cmux workspaces.\n */\nexport const worktreesOpen = async (): Promise<ToolsExecutionResult> => {\n commandEcho.start('worktrees-open')\n\n try {\n const projectRoot = await getProjectRoot()\n const worktreeDir = `${projectRoot}${WORKTREES_DIR_SUFFIX}`\n const currentBranches = await getCurrentWorktrees('release')\n\n const cursorOutcome = await openCursor({ projectRoot, worktreeDir, currentBranches })\n const cmuxOutcome = await openCmux({ worktreeDir, currentBranches })\n\n const result: WorktreesOpenResult = {\n openedCmux: cmuxOutcome.opened,\n skippedCmux: cmuxOutcome.skipped,\n cursorFoldersAdded: cursorOutcome.added,\n cursorFoldersRemoved: cursorOutcome.removed,\n }\n\n logResults(result, { cursorRan: cursorOutcome.ran, cmuxRan: cmuxOutcome.ran })\n\n commandEcho.print()\n\n return {\n content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],\n structuredContent: { ...result },\n }\n } catch (error) {\n logger.error({ error }, '\u274C Error opening worktrees')\n throw error\n }\n}\n\ninterface OpenCursorArgs {\n projectRoot: string\n worktreeDir: string\n currentBranches: string[]\n}\n\ninterface OpenCursorOutcome {\n ran: boolean\n added: number\n removed: number\n}\n\nconst openCursor = async (args: OpenCursorArgs): Promise<OpenCursorOutcome> => {\n const { projectRoot, worktreeDir, currentBranches } = args\n\n const config = await getInfraKitConfig()\n const cursorConfig = config.ide?.provider === 'cursor' ? config.ide.config : undefined\n\n if (!cursorConfig || cursorConfig.mode !== 'workspace' || !cursorConfig.workspaceConfigPath) {\n logger.warn('\u26A0\uFE0F Skipping Cursor: ide.provider must be \"cursor\", mode \"workspace\", and workspaceConfigPath set.')\n\n return { ran: false, added: 0, removed: 0 }\n }\n\n const workspacePath = resolveCursorWorkspacePath(cursorConfig.workspaceConfigPath, projectRoot)\n\n try {\n const { added, removed } = await reconcileCursorWorkspaceFolders({\n workspacePath,\n worktreeDir,\n currentBranches,\n })\n\n await $`cursor ${workspacePath}`\n\n return { ran: true, added: added.length, removed: removed.length }\n } catch (error) {\n logger.warn({ error }, `\u26A0\uFE0F Failed to reconcile/open Cursor workspace at ${workspacePath}`)\n\n return { ran: false, added: 0, removed: 0 }\n }\n}\n\ninterface OpenCmuxArgs {\n worktreeDir: string\n currentBranches: string[]\n}\n\ninterface OpenCmuxOutcome {\n ran: boolean\n opened: string[]\n skipped: string[]\n}\n\nconst openCmux = async (args: OpenCmuxArgs): Promise<OpenCmuxOutcome> => {\n const { worktreeDir, currentBranches } = args\n\n if (currentBranches.length === 0) {\n return { ran: true, opened: [], skipped: [] }\n }\n\n const repoName = await getRepoName()\n const existingTitles = await listCmuxWorkspaceTitles()\n\n const opened: string[] = []\n const skipped: string[] = []\n\n for (const branch of currentBranches) {\n const title = buildCmuxWorkspaceTitle({ repoName, branch })\n\n if (existingTitles.has(title)) {\n skipped.push(title)\n continue\n }\n\n try {\n await openCmuxWorkspaceWithLayout({ cwd: `${worktreeDir}/${branch}`, title })\n opened.push(title)\n } catch (error) {\n logger.warn({ error, title }, `\u26A0\uFE0F Failed to open cmux workspace for ${branch}`)\n }\n }\n\n return { ran: true, opened, skipped }\n}\n\ninterface LogResultsContext {\n cursorRan: boolean\n cmuxRan: boolean\n}\n\nconst logResults = (result: WorktreesOpenResult, context: LogResultsContext): void => {\n if (context.cursorRan) {\n if (result.cursorFoldersAdded > 0) {\n logger.info(`\u2705 Added ${result.cursorFoldersAdded} folder(s) to Cursor workspace`)\n }\n\n if (result.cursorFoldersRemoved > 0) {\n logger.info(`\uD83E\uDDF9 Removed ${result.cursorFoldersRemoved} dangling folder(s) from Cursor workspace`)\n }\n }\n\n if (result.openedCmux.length > 0) {\n logger.info('\u2705 Opened cmux workspaces:')\n for (const title of result.openedCmux) {\n logger.info(title)\n }\n }\n\n if (result.skippedCmux.length > 0) {\n logger.info(`\u2139\uFE0F Skipped ${result.skippedCmux.length} cmux workspace(s) already open`)\n }\n\n if (\n !context.cursorRan &&\n result.openedCmux.length === 0 &&\n result.skippedCmux.length === 0 &&\n result.cursorFoldersAdded === 0 &&\n result.cursorFoldersRemoved === 0\n ) {\n logger.info('\u2139\uFE0F Nothing to open')\n }\n}\n\n// MCP Tool Registration\nexport const worktreesOpenMcpTool = {\n name: 'worktrees-open',\n description:\n 'Open Cursor against the configured workspace file and ensure a cmux workspace exists for each existing release worktree. Idempotent and additive \u2014 never removes worktrees, never recreates running cmux workspaces. Use after a cold start (Cursor + cmux closed). For stale-worktree cleanup, use worktrees-sync.',\n inputSchema: {},\n outputSchema: {\n openedCmux: z.array(z.string()).describe('Titles of cmux workspaces opened during this run'),\n skippedCmux: z.array(z.string()).describe('Titles of cmux workspaces that were already open'),\n cursorFoldersAdded: z.number().describe('Number of worktree folders added to the Cursor workspace file'),\n cursorFoldersRemoved: z\n .number()\n .describe('Number of dangling worktree folders removed from the Cursor workspace file'),\n },\n handler: worktreesOpen,\n}\n", "import checkbox from '@inquirer/checkbox'\nimport confirm from '@inquirer/confirm'\nimport process from 'node:process'\nimport { z } from 'zod/v4'\nimport { $ } from 'zx'\n\nimport { buildCmuxWorkspaceTitle, closeCmuxWorkspaceByTitle } from 'src/integrations/cmux'\nimport { removeFoldersFromCursorWorkspace, resolveCursorWorkspacePath } from 'src/integrations/cursor'\nimport { getReleasePRsWithInfo } from 'src/integrations/gh'\nimport { commandEcho } from 'src/lib/command-echo'\nimport { WORKTREES_DIR_SUFFIX } from 'src/lib/constants'\nimport { getCurrentWorktrees, getProjectRoot, getRepoName } from 'src/lib/git-utils'\nimport { getInfraKitConfig } from 'src/lib/infra-kit-config'\nimport { logger } from 'src/lib/logger'\nimport { detectReleaseType, formatBranchChoices, getJiraDescriptions } from 'src/lib/release-utils'\nimport type { ReleaseType } from 'src/lib/release-utils'\nimport type { RequiredConfirmedOptionArg, ToolsExecutionResult } from 'src/types'\n\n// Constants\ninterface WorktreeManagementArgs extends RequiredConfirmedOptionArg {\n all: boolean\n versions?: string\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, versions } = options\n\n commandEcho.start('worktrees-remove')\n\n try {\n const currentWorktrees = await getCurrentWorktrees('release')\n\n if (currentWorktrees.length === 0) {\n logger.info('\u2139\uFE0F No active worktrees to remove')\n\n commandEcho.print()\n\n return {\n content: [{ type: 'text', text: JSON.stringify({ removedWorktrees: [], count: 0 }, null, 2) }],\n structuredContent: { removedWorktrees: [], count: 0 },\n }\n }\n\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 if (versions) {\n selectedReleaseBranches = versions.split(',').map((v) => {\n return `release/v${v.trim()}`\n })\n } else {\n commandEcho.setInteractive()\n\n const [descriptions, prInfo] = await Promise.all([getJiraDescriptions(), getReleasePRsWithInfo()])\n\n const releaseTypes = new Map<string, ReleaseType>(\n prInfo.map((pr) => {\n return [pr.branch, detectReleaseType(pr.title)]\n }),\n )\n\n selectedReleaseBranches = await checkbox({\n required: true,\n message: '\uD83C\uDF3F Select release branches',\n choices: formatBranchChoices({ branches: currentWorktrees, descriptions, types: releaseTypes }),\n })\n }\n\n // Track --all flag if all branches were selected (either via flag or interactively)\n const allSelected = selectedReleaseBranches.length === currentWorktrees.length\n\n if (allSelected) {\n commandEcho.addOption('--all', true)\n } else {\n commandEcho.addOption(\n '--versions',\n selectedReleaseBranches.map((branch) => {\n return branch.replace('release/v', '')\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 (!confirmedCommand) {\n commandEcho.setInteractive()\n }\n\n if (!answer) {\n logger.info('Operation cancelled. Exiting...')\n process.exit(0)\n }\n\n // Track --yes flag if confirmation was interactive (user confirmed)\n if (!confirmedCommand) {\n commandEcho.addOption('--yes', true)\n }\n\n const repoName = await getRepoName()\n\n const removedWorktrees = await removeWorktrees({\n branches: selectedReleaseBranches,\n worktreeDir,\n repoName,\n allSelected,\n })\n\n await syncCursorWorkspaceOnRemove({ removedWorktrees, worktreeDir, projectRoot })\n\n logResults(removedWorktrees)\n\n commandEcho.print()\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 RemoveWorktreesArgs {\n branches: string[]\n worktreeDir: string\n repoName: string\n allSelected: boolean\n}\n\n/**\n * Remove worktrees for the specified branches and whole folder\n */\nconst removeWorktrees = async (args: RemoveWorktreesArgs): Promise<string[]> => {\n const { branches, worktreeDir, repoName, allSelected } = args\n\n const results = await Promise.allSettled(\n branches.map(async (branch) => {\n const worktreePath = `${worktreeDir}/${branch}`\n\n const title = buildCmuxWorkspaceTitle({ repoName, branch })\n\n await closeCmuxWorkspaceByTitle(title)\n\n await $`git worktree remove ${worktreePath}`\n\n return branch\n }),\n )\n\n const removed: string[] = []\n\n for (const [index, result] of results.entries()) {\n if (result.status === 'fulfilled') {\n removed.push(result.value)\n } else {\n const branch = branches[index]\n\n logger.error({ error: result.reason }, `\u274C Failed to remove worktree for ${branch}`)\n }\n }\n\n if (allSelected && removed.length === branches.length) {\n await $`git worktree prune`\n await $`rm -rf ${worktreeDir}`\n\n logger.info(`\uD83D\uDDD1\uFE0F Removed worktree folder: ${worktreeDir}`)\n logger.info('')\n }\n\n return removed\n}\n\ninterface SyncCursorWorkspaceOnRemoveArgs {\n removedWorktrees: string[]\n worktreeDir: string\n projectRoot: string\n}\n\n/**\n * Strip removed worktrees from the configured Cursor workspace's `folders` array.\n * No-op if Cursor isn't configured, mode isn't \"workspace\", or no worktrees were removed.\n */\nconst syncCursorWorkspaceOnRemove = async (args: SyncCursorWorkspaceOnRemoveArgs): Promise<void> => {\n const { removedWorktrees, worktreeDir, projectRoot } = args\n\n if (removedWorktrees.length === 0) {\n return\n }\n\n const config = await getInfraKitConfig()\n const cursorConfig = config.ide?.provider === 'cursor' ? config.ide.config : undefined\n\n if (!cursorConfig || cursorConfig.mode !== 'workspace' || !cursorConfig.workspaceConfigPath) {\n return\n }\n\n const workspacePath = resolveCursorWorkspacePath(cursorConfig.workspaceConfigPath, projectRoot)\n\n const folderPaths = removedWorktrees.map((branch) => {\n return `${worktreeDir}/${branch}`\n })\n\n try {\n const { removed } = await removeFoldersFromCursorWorkspace({ workspacePath, folderPaths })\n\n if (removed.length > 0) {\n logger.info(`\u2705 Removed ${removed.length} folder(s) from ${workspacePath}`)\n }\n } catch (error) {\n logger.warn({ error }, `\u26A0\uFE0F Failed to update Cursor workspace at ${workspacePath}`)\n }\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 for (const branch of removed) {\n logger.info(branch)\n }\n logger.info('')\n } else {\n logger.info('\u2139\uFE0F No unused worktrees to remove')\n }\n}\n\n// MCP Tool Registration\nexport const worktreesRemoveMcpTool = {\n name: 'worktrees-remove',\n description:\n 'Remove local git worktrees for release branches. When everything is removed, also runs \"git worktree prune\" and deletes the worktrees directory. When invoked via MCP, pass either \"versions\" (comma-separated) or all=true \u2014 the branch picker is unreachable without a TTY, and the CLI confirmation is auto-skipped for MCP calls, so the caller is responsible for gating.',\n inputSchema: {\n all: z\n .boolean()\n .optional()\n .describe(\n 'Remove every existing worktree. Either \"all\" or \"versions\" must be provided for MCP calls (the interactive picker is unavailable without a TTY). Ignored if \"versions\" is provided.',\n ),\n versions: z\n .string()\n .optional()\n .describe(\n 'Comma-separated release versions to target (e.g. \"1.2.5, 1.2.6\"). Either \"versions\" or all=true must be provided for MCP calls. Overrides \"all\" when set.',\n ),\n },\n outputSchema: {\n removedWorktrees: z.array(z.string()).describe('List of removed git worktree branches'),\n count: z.number().describe('Number of git worktrees removed'),\n },\n handler: worktreesRemove,\n}\n", "import confirm from '@inquirer/confirm'\nimport process from 'node:process'\nimport { z } from 'zod/v4'\nimport { $ } from 'zx'\n\nimport { buildCmuxWorkspaceTitle, closeCmuxWorkspaceByTitle } from 'src/integrations/cmux'\nimport { removeFoldersFromCursorWorkspace, resolveCursorWorkspacePath } from 'src/integrations/cursor'\nimport { getReleasePRs } from 'src/integrations/gh'\nimport { commandEcho } from 'src/lib/command-echo'\nimport { WORKTREES_DIR_SUFFIX } from 'src/lib/constants'\nimport { getCurrentWorktrees, getProjectRoot, getRepoName } from 'src/lib/git-utils'\nimport { getInfraKitConfig } from 'src/lib/infra-kit-config'\nimport { logger } from 'src/lib/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 *\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 commandEcho.start('worktrees-sync')\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 (!confirmedCommand) {\n commandEcho.setInteractive()\n }\n\n if (!answer) {\n logger.info('Operation cancelled. Exiting...')\n process.exit(0)\n }\n\n // Track --yes flag if confirmation was interactive (user confirmed)\n if (!confirmedCommand) {\n commandEcho.addOption('--yes', true)\n }\n\n const { branchesToRemove } = categorizeWorktrees({\n releasePRsList,\n currentWorktrees,\n })\n\n const repoName = await getRepoName()\n\n const removedWorktrees = await removeWorktrees({\n branches: branchesToRemove,\n worktreeDir,\n repoName,\n })\n\n await syncCursorWorkspaceOnRemove({ removedWorktrees, worktreeDir, projectRoot })\n\n logResults(removedWorktrees)\n\n commandEcho.print()\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) => {\n return branch.startsWith(RELEASE_BRANCH_PREFIX)\n })\n\n const branchesToRemove = currentBranchNames.filter((branch) => {\n return !releasePRsList.includes(branch)\n })\n\n return { branchesToRemove }\n}\n\ninterface RemoveWorktreesArgs {\n branches: string[]\n worktreeDir: string\n repoName: string\n}\n\n/**\n * Remove worktrees for the specified branches and close their cmux workspaces\n */\nconst removeWorktrees = async (args: RemoveWorktreesArgs): Promise<string[]> => {\n const { branches, worktreeDir, repoName } = args\n\n const removed: string[] = []\n\n for (const branch of branches) {\n try {\n const worktreePath = `${worktreeDir}/${branch}`\n\n const title = buildCmuxWorkspaceTitle({ repoName, branch })\n\n await closeCmuxWorkspaceByTitle(title)\n\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\ninterface SyncCursorWorkspaceOnRemoveArgs {\n removedWorktrees: string[]\n worktreeDir: string\n projectRoot: string\n}\n\n/**\n * Strip removed worktrees from the configured Cursor workspace's `folders` array.\n * No-op if Cursor isn't configured, mode isn't \"workspace\", or no worktrees were removed.\n */\nconst syncCursorWorkspaceOnRemove = async (args: SyncCursorWorkspaceOnRemoveArgs): Promise<void> => {\n const { removedWorktrees, worktreeDir, projectRoot } = args\n\n if (removedWorktrees.length === 0) {\n return\n }\n\n const config = await getInfraKitConfig()\n const cursorConfig = config.ide?.provider === 'cursor' ? config.ide.config : undefined\n\n if (!cursorConfig || cursorConfig.mode !== 'workspace' || !cursorConfig.workspaceConfigPath) {\n return\n }\n\n const workspacePath = resolveCursorWorkspacePath(cursorConfig.workspaceConfigPath, projectRoot)\n\n const folderPaths = removedWorktrees.map((branch) => {\n return `${worktreeDir}/${branch}`\n })\n\n try {\n const { removed: removedEntries } = await removeFoldersFromCursorWorkspace({ workspacePath, folderPaths })\n\n if (removedEntries.length > 0) {\n logger.info(`\u2705 Removed ${removedEntries.length} folder(s) from ${workspacePath}`)\n }\n } catch (error) {\n logger.warn({ error }, `\u26A0\uFE0F Failed to update Cursor workspace at ${workspacePath}`)\n }\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 for (const branch of removed) {\n logger.info(branch)\n }\n logger.info('')\n } else {\n logger.info('\u2139\uFE0F No unused worktrees to remove')\n }\n}\n\n// MCP Tool Registration\nexport const worktreesSyncMcpTool = {\n name: 'worktrees-sync',\n description:\n 'Remove worktrees whose release PR is no longer open (stale cleanup). Only removes \u2014 never creates; use worktrees-add to create worktrees for new releases. The CLI confirmation is auto-skipped for MCP calls, so the caller is responsible for gating.',\n inputSchema: {},\n outputSchema: {\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 handler: worktreesSync,\n}\n", "import { logger } from 'src/lib/logger'\nimport type { ToolsExecutionResult } from 'src/types'\n\ninterface ToolHandlerArgs {\n toolName: string\n handler: (params: any) => Promise<ToolsExecutionResult>\n}\n\nexport const createToolHandler = (args: ToolHandlerArgs) => {\n return 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}\n", "import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\n\nimport { envClearMcpTool } from 'src/commands/env-clear'\nimport { envListMcpTool } from 'src/commands/env-list'\nimport { envLoadMcpTool } from 'src/commands/env-load'\nimport { envStatusMcpTool } from 'src/commands/env-status'\nimport { ghMergeDevMcpTool } from 'src/commands/gh-merge-dev'\nimport { ghReleaseDeliverMcpTool } from 'src/commands/gh-release-deliver'\nimport { ghReleaseDeployAllMcpTool } from 'src/commands/gh-release-deploy-all'\nimport { ghReleaseDeploySelectedMcpTool } from 'src/commands/gh-release-deploy-selected'\nimport { ghReleaseListMcpTool } from 'src/commands/gh-release-list'\nimport { releaseCreateMcpTool } from 'src/commands/release-create'\nimport { releaseCreateBatchMcpTool } from 'src/commands/release-create-batch'\nimport { versionMcpTool } from 'src/commands/version'\nimport { worktreesAddMcpTool } from 'src/commands/worktrees-add'\nimport { worktreesListMcpTool } from 'src/commands/worktrees-list'\nimport { worktreesOpenMcpTool } from 'src/commands/worktrees-open'\nimport { worktreesRemoveMcpTool } from 'src/commands/worktrees-remove'\nimport { worktreesSyncMcpTool } from 'src/commands/worktrees-sync'\nimport { createToolHandler } from 'src/lib/tool-handler'\n\nconst tools = [\n envStatusMcpTool,\n envListMcpTool,\n envLoadMcpTool,\n envClearMcpTool,\n ghMergeDevMcpTool,\n releaseCreateMcpTool,\n releaseCreateBatchMcpTool,\n ghReleaseDeliverMcpTool,\n ghReleaseDeployAllMcpTool,\n ghReleaseDeploySelectedMcpTool,\n ghReleaseListMcpTool,\n versionMcpTool,\n worktreesAddMcpTool,\n worktreesListMcpTool,\n worktreesOpenMcpTool,\n worktreesRemoveMcpTool,\n worktreesSyncMcpTool,\n]\n\nexport const initializeTools = async (server: McpServer) => {\n for (const tool of tools) {\n server.registerTool(\n tool.name,\n {\n description: tool.description,\n inputSchema: tool.inputSchema,\n outputSchema: tool.outputSchema,\n },\n createToolHandler({ toolName: tool.name, handler: tool.handler }),\n )\n }\n}\n"],
5
- "mappings": "AAAA,OAAS,wBAAAA,OAA4B,4CACrC,OAAOC,OAAa,eCDpB,OAAOC,MAAa,eCApB,OAAOC,OAAa,eACpB,OAAOC,OAAU,OACjB,OAAOC,OAAY,cAGZ,IAAMC,GAAgB,yBAEhBC,GAAgB,IAAM,CACjC,IAAMC,EAAWL,GAAQ,KAAK,SAAS,SAAS,EAAI,QAAU,OAExDM,EAASL,GAAK,CAAE,MAAOI,CAAS,EAAGJ,GAAK,YAAY,CAAE,KAAME,EAAc,CAAC,CAAC,EAElF,OAAAG,EAAO,KAAK,kCAAkCD,CAAQ,iBAAiBF,EAAa,EAAE,EAE/EG,CACT,EAEaC,GAAgB,IAAM,CACjC,IAAMF,EAAWL,GAAQ,KAAK,SAAS,SAAS,EAAI,QAAU,OAExDQ,EAAe,CAAC,OAAQ,MAAO,UAAU,EAE/C,OAAIH,IAAa,SACfG,EAAa,KAAK,OAAO,EAGZP,GACb,CAAE,MAAOI,CAAS,EAClBH,GAAO,CACL,YAAa,EACb,OAAQM,EAAa,KAAK,GAAG,EAC7B,SAAU,EACZ,CAAC,CACH,CAGF,EAGaF,EAASC,GAAc,ED5B7B,IAAME,GAAsBC,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,E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AQ,KAAK,CAAC,CAChB,CACF,EAGAG,GAAmBT,CAAM,EAGzBE,GAAY",
6
- "names": ["StdioServerTransport", "process", "process", "process", "pino", "pretty", "LOG_FILE_PATH", "initLoggerMcp", "logLevel", "logger", "initLoggerCLI", "ignoreFields", "setupErrorHandlers", "logger", "process", "error", "LOG_FILE_PATH", "reason", "promise", "McpServer", "initializePrompts", "_server", "initializeResources", "_server", "fs", "path", "process", "z", "fs", "os", "path", "process", "ENV_LOAD_FILE", "ENV_CLEAR_FILE", "INFRA_KIT_SESSION_VAR", "INFRA_KIT_ENV_CONFIG_VAR", "INFRA_KIT_ENV_PROJECT_VAR", "INFRA_KIT_ENV_LOADED_AT_VAR", "ENV_VAR_LINE_PATTERN", "parseVarNamesFromEnvFile", "filePath", "content", "names", "line", "match", "getCacheRoot", "xdg", "base", "getSessionCacheDir", "session", "atomicWriteFileSync", "mode", "tmpPath", "error", "WORKTREES_DIR_SUFFIX", "envClear", "cacheDir", "getSessionCacheDir", "envLoadPath", "path", "ENV_LOAD_FILE", "fs", "varNames", "parseVarNamesFromEnvFile", "unsetLines", "v", "INFRA_KIT_ENV_CONFIG_VAR", "INFRA_KIT_ENV_PROJECT_VAR", "INFRA_KIT_ENV_LOADED_AT_VAR", "clearFilePath", "ENV_CLEAR_FILE", "atomicWriteFileSync", "process", "structuredContent", "envClearMcpTool", "z", "z", "fs", "os", "path", "yaml", "z", "path", "$", "getCurrentWorktrees", "type", "worktreeLines", "worktreePredicateMap", "releaseWorktreePredicate", "featureWorktreePredicate", "branch", "parseWorktreeBranch", "line", "trimmed", "open", "getProjectRoot", "getRepoName", "projectRoot", "INFRA_KIT_CONFIG_FILE", "USER_CONFIG_DIR_NAME", "USER_GLOBAL_CONFIG_FILE", "USER_PROJECTS_DIR", "dopplerEnvManagementSchema", "z", "envManagementSchema", "cursorIdeConfigSchema", "v", "cursorIdeSchema", "ideSchema", "jiraTaskManagerSchema", "taskManagerSchema", "infraKitConfigSchema", "infraKitOverrideConfigSchema", "cached", "getInfraKitConfigPaths", "projectRoot", "getProjectRoot", "projectName", "getRepoName", "userConfigDir", "path", "os", "getInfraKitConfig", "paths", "mainStat", "fs", "userGlobalStat", "userProjectStat", "statIfExists", "mtimes", "shallowEqual", "layers", "merged", "layer", "data", "loadLayer", "finalResult", "statIfExists", "filePath", "fs", "readIfExists", "shallowEqual", "a", "b", "keys", "k", "loadLayer", "layer", "raw", "parsedRaw", "yaml", "result", "infraKitOverrideConfigSchema", "z", "getDopplerProject", "envManagement", "getInfraKitConfig", "envList", "project", "getDopplerProject", "environments", "getInfraKitConfig", "logger", "env", "structuredContent", "envListMcpTool", "z", "select", "Buffer", "fs", "path", "process", "z", "$", "$", "validateDopplerCliAndAuth", "error", "createCommandEcho", "commandName", "options", "isInteractive", "name", "flag", "value", "formattedOptions", "opt", "logger", "commandEcho", "envLoad", "args", "validateDopplerCliAndAuth", "config", "commandEcho", "selectedConfig", "environments", "getInfraKitConfig", "select", "env", "process", "project", "getDopplerProject", "envContent", "downloadDopplerSecrets", "assertValidEnvContent", "loadedAt", "envFileLines", "INFRA_KIT_ENV_CONFIG_VAR", "shellSingleQuote", "INFRA_KIT_ENV_PROJECT_VAR", "INFRA_KIT_ENV_LOADED_AT_VAR", "cacheDir", "getSessionCacheDir", "envFilePath", "path", "ENV_LOAD_FILE", "fs", "atomicWriteFileSync", "varCount", "countEnvVarLines", "structuredContent", "DOPPLER_MAX_OUTPUT_BYTES", "DOPPLER_DOWNLOAD_TIMEOUT_MS", "prevQuiet", "$", "result", "assertDopplerOutputSize", "stdout", "bytes", "Buffer", "content", "line", "ENV_VAR_LINE_PATTERN", "SHELL_DIRECTIVE_LINES", "value", "trimmed", "envLoadMcpTool", "z", "path", "process", "z", "envStatus", "validateDopplerCliAndAuth", "logger", "cacheDir", "getSessionCacheDir", "sessionId", "process", "INFRA_KIT_SESSION_VAR", "envLoadPath", "path", "ENV_LOAD_FILE", "sessionLoadedCount", "sessionTotalCount", "sessionConfig", "INFRA_KIT_ENV_CONFIG_VAR", "sessionProject", "INFRA_KIT_ENV_PROJECT_VAR", "sessionLoadedAt", "INFRA_KIT_ENV_LOADED_AT_VAR", "varNames", "parseVarNamesFromEnvFile", "v", "loadedAtDisplay", "missing", "structuredContent", "envStatusMcpTool", "z", "checkbox", "confirm", "process", "z", "$", "$", "process", "$", "$", "process", "createJiraVersion", "params", "config", "baseUrl", "token", "email", "projectId", "requestBody", "url", "credentials", "response", "errorText", "logger", "error", "getProjectVersions", "findVersionByName", "versionName", "v", "updateJiraVersion", "deliverJiraRelease", "version", "loadJiraConfig", "process", "projectIdStr", "missingVars", "errorMessage", "loadJiraConfigOptional", "getBaseBranch", "type", "prepareGitForRelease", "baseBranch", "$", "createSingleRelease", "args", "version", "jiraConfig", "description", "versionName", "result", "createJiraVersion", "jiraVersionUrl", "releaseInfo", "createReleaseBranch", "getJiraDescriptions", "descriptions", "loadJiraConfigOptional", "versions", "getProjectVersions", "formatVersionLabel", "maxVersionLength", "padding", "tag", "detectReleaseType", "title", "formatBranchChoices", "branches", "types", "versionNames", "b", "maxLen", "v", "branch", "i", "desc", "name", "$", "parseVersion", "versionStr", "sortVersions", "versions", "a", "b", "majA", "minA", "patchA", "majB", "minB", "patchB", "NEXT_TOKEN", "VERSION_RE", "stripBranchPrefix", "raw", "tryParse", "cleaned", "match", "semverKey", "v", "collectKnownVersions", "sources", "all", "parsed", "seen", "key", "sortVersions", "s", "parseVersion", "NoPriorVersionsError", "computeNextVersion", "known", "type", "max", "major", "minor", "highestPatchOnMinor", "acc", "isNextToken", "token", "resolveVersionTokens", "tokens", "running", "resolved", "trimmed", "next", "explicit", "splitVersionInput", "input", "t", "parseRemoteRefs", "previousQuiet", "$", "line", "tab", "fetchJiraVersionNames", "config", "loadJiraConfigOptional", "getProjectVersions", "v", "loadExistingVersions", "branchesResult", "jiraResult", "logger", "collectKnownVersions", "fetchAllReleasePRs", "releasePRs", "$", "hotfixPRs", "all", "seen", "pr", "getReleasePRs", "prs", "logger", "process", "sortVersions", "error", "getReleasePRsWithInfo", "sortedBranches", "prByBranch", "branch", "createReleaseBranch", "args", "version", "jiraVersionUrl", "type", "description", "titlePrefix", "baseBranch", "getBaseBranch", "branchName", "body", "prLink", "ghMergeDev", "args", "all", "confirmedCommand", "commandEcho", "releasePRsList", "getReleasePRsWithInfo", "pr", "detectReleaseType", "logger", "selectedReleaseBranches", "descriptions", "getJiraDescriptions", "checkbox", "formatBranchChoices", "branch", "answer", "confirm", "process", "$", "failedBranches", "mergeDev", "structuredContent", "error", "ghMergeDevMcpTool", "z", "confirm", "select", "process", "z", "$", "ghReleaseDeliver", "args", "version", "confirmedCommand", "commandEcho", "releasePRsInfo", "getReleasePRsWithInfo", "branches", "pr", "releaseTypes", "detectReleaseType", "selectedReleaseBranch", "descriptions", "getJiraDescriptions", "select", "formatBranchChoices", "selectedVersion", "prInfo", "logger", "process", "releaseType", "answer", "confirm", "$", "jiraConfig", "loadJiraConfigOptional", "versionName", "deliverJiraRelease", "error", "structuredContent", "ghReleaseDeliverMcpTool", "z", "select", "process", "z", "$", "ghReleaseDeployAll", "args", "version", "env", "skipTerraform", "commandEcho", "selectedReleaseBranch", "releasePRsInfo", "getReleasePRsWithInfo", "branches", "pr", "releaseTypes", "detectReleaseType", "descriptions", "getJiraDescriptions", "select", "formatBranchChoices", "selectedVersion", "environments", "getInfraKitConfig", "selectedEnv", "logger", "process", "shouldSkipTerraform", "$", "structuredContent", "error", "ghReleaseDeployAllMcpTool", "z", "checkbox", "select", "fs", "resolve", "process", "yaml", "z", "$", "ghReleaseDeploySelected", "args", "version", "env", "services", "skipTerraform", "commandEcho", "selectedReleaseBranch", "releasePRsInfo", "getReleasePRsWithInfo", "branches", "pr", "releaseTypes", "detectReleaseType", "descriptions", "getJiraDescriptions", "select", "formatBranchChoices", "selectedVersion", "environments", "getInfraKitConfig", "selectedEnv", "logger", "process", "availableServices", "parseServicesFromWorkflow", "selectedServices", "checkbox", "svc", "invalidServices", "shouldSkipTerraform", "$", "serviceFlags", "structuredContent", "error", "projectRoot", "getProjectRoot", "workflowPath", "resolve", "content", "fs", "inputs", "yaml", "key", "value", "ghReleaseDeploySelectedMcpTool", "z", "z", "ghReleaseList", "releases", "getReleasePRsWithInfo", "pr", "detectReleaseType", "jiraDescriptions", "getJiraDescriptions", "maxVersionLength", "r", "formattedLines", "release", "label", "formatVersionLabel", "description", "logger", "structuredContent", "ghReleaseListMcpTool", "z", "confirm", "select", "process", "z", "question", "confirm", "select", "process", "z", "question", "VERSIONS_PROMPT_HINT", "resolveInputs", "args", "inputVersions", "inputType", "confirmedCommand", "versionInput", "type", "commandEcho", "select", "question", "rawTokens", "splitVersionInput", "logger", "process", "known", "t", "NEXT_TOKEN", "loadExistingVersions", "versionsList", "resolveVersionTokens", "err", "NoPriorVersionsError", "answer", "confirm", "releaseCreateBatch", "jiraConfig", "loadJiraConfig", "prepareGitForRelease", "releases", "failedReleases", "version", "release", "createSingleRelease", "error", "errorMessage", "successCount", "failureCount", "structuredContent", "r", "releaseCreateBatchMcpTool", "z", "VERSION_PROMPT_HINT", "promptForType", "commandEcho", "select", "trySuggestNext", "known", "type", "computeNextVersion", "err", "NoPriorVersionsError", "exitOnNoPrior", "logger", "process", "resolveRawTokens", "args", "inputVersion", "ensureKnown", "splitVersionInput", "suggestion", "defaultHint", "answer", "question", "resolveVersionList", "rawTokens", "needsKnown", "t", "NEXT_TOKEN", "resolveVersionTokens", "resolveDescription", "input", "releaseCreate", "inputDescription", "inputType", "confirmedCommand", "jiraConfig", "loadJiraConfig", "resolvedVersions", "loadExistingVersions", "releaseCreateBatch", "trimmedVersion", "description", "confirm", "prepareGitForRelease", "release", "createSingleRelease", "structuredContent", "releaseCreateMcpTool", "z", "z", "package_default", "version", "cliVersion", "package_default", "logger", "structuredContent", "versionMcpTool", "z", "checkbox", "confirm", "select", "process", "z", "$", "$", "closeCmuxWorkspaceByTitle", "title", "listOutput", "$", "ref", "findWorkspaceRefByTitle", "error", "logger", "output", "rawLine", "match", "$", "listCmuxWorkspaceTitles", "output", "$", "titles", "rawLine", "match", "title", "error", "logger", "$", "openCmuxWorkspaceWithLayout", "args", "cwd", "title", "newWorkspaceOutput", "workspaceRef", "parseWorkspaceRef", "surfacesOutput", "leftTopRef", "parseFirstSurfaceRef", "output", "match", "buildCmuxWorkspaceTitle", "args", "repoName", "branch", "version", "fs", "path", "addFoldersToCursorWorkspace", "args", "workspacePath", "folderPaths", "workspaceDir", "raw", "error", "parsed", "existingFolders", "existingAbsolutePaths", "entry", "added", "skipped", "folderPath", "absolutePath", "relativePath", "fs", "path", "fs", "path", "removeFoldersFromCursorWorkspace", "args", "workspacePath", "folderPaths", "workspaceDir", "raw", "error", "parsed", "existingFolders", "targetAbsolutePaths", "folderPath", "removedAbsolutePaths", "filteredFolders", "entry", "entryAbsolutePath", "removed", "notFound", "absolutePath", "reconcileCursorWorkspaceFolders", "args", "workspacePath", "worktreeDir", "currentBranches", "workspaceDir", "path", "releaseRoot", "raw", "fs", "existingFolders", "desiredAbsolutePaths", "branch", "danglingFolderPaths", "entry", "entryAbsolutePath", "removed", "removeFoldersFromCursorWorkspace", "desiredFolderPaths", "added", "addFoldersToCursorWorkspace", "path", "resolveCursorWorkspacePath", "configValue", "projectRoot", "FEATURE_DIR", "RELEASE_DIR", "RELEASE_BRANCH_PREFIX", "CURSOR_MODES", "worktreesAdd", "options", "confirmedCommand", "all", "versions", "cursor", "githubDesktop", "cmux", "commandEcho", "currentWorktrees", "getCurrentWorktrees", "projectRoot", "getProjectRoot", "worktreeDir", "WORKTREES_DIR_SUFFIX", "ensureWorktreeDirectory", "selectedReleaseBranches", "v", "releasePRsInfo", "getReleasePRsWithInfo", "releasePRsList", "pr", "logger", "releaseTypes", "detectReleaseType", "descriptions", "getJiraDescriptions", "checkbox", "formatBranchChoices", "branch", "answer", "confirm", "process", "cursorMode", "select", "openInGithubDesktop", "openInCmux", "branchesToCreate", "categorizeWorktrees", "createdWorktrees", "createWorktrees", "logResults", "config", "getInfraKitConfig", "cursorConfig", "workspacePath", "resolveCursorWorkspacePath", "folderPaths", "added", "skipped", "addFoldersToCursorWorkspace", "skippedSuffix", "$", "repoName", "getRepoName", "title", "buildCmuxWorkspaceTitle", "openCmuxWorkspaceWithLayout", "structuredContent", "error", "args", "currentBranchNames", "branches", "results", "worktreePath", "created", "index", "result", "worktreesAddMcpTool", "z", "z", "worktreesList", "currentWorktrees", "getCurrentWorktrees", "logger", "releasePRsInfo", "jiraDescriptions", "getReleasePRsWithInfo", "getJiraDescriptions", "releaseTypes", "pr", "detectReleaseType", "worktrees", "branch", "version", "type", "description", "maxVersionLength", "w", "formattedLines", "worktree", "label", "formatVersionLabel", "structuredContent", "worktreesListMcpTool", "z", "z", "$", "worktreesOpen", "commandEcho", "projectRoot", "getProjectRoot", "worktreeDir", "WORKTREES_DIR_SUFFIX", "currentBranches", "getCurrentWorktrees", "cursorOutcome", "openCursor", "cmuxOutcome", "openCmux", "result", "logResults", "error", "logger", "args", "config", "getInfraKitConfig", "cursorConfig", "workspacePath", "resolveCursorWorkspacePath", "added", "removed", "reconcileCursorWorkspaceFolders", "$", "repoName", "getRepoName", "existingTitles", "listCmuxWorkspaceTitles", "opened", "skipped", "branch", "title", "buildCmuxWorkspaceTitle", "openCmuxWorkspaceWithLayout", "context", "worktreesOpenMcpTool", "z", "checkbox", "confirm", "process", "z", "$", "worktreesRemove", "options", "confirmedCommand", "all", "versions", "commandEcho", "currentWorktrees", "getCurrentWorktrees", "logger", "projectRoot", "getProjectRoot", "worktreeDir", "WORKTREES_DIR_SUFFIX", "selectedReleaseBranches", "v", "descriptions", "prInfo", "getJiraDescriptions", "getReleasePRsWithInfo", "releaseTypes", "pr", "detectReleaseType", "checkbox", "formatBranchChoices", "allSelected", "branch", "answer", "confirm", "process", "repoName", "getRepoName", "removedWorktrees", "removeWorktrees", "syncCursorWorkspaceOnRemove", "logResults", "structuredContent", "error", "args", "branches", "results", "worktreePath", "title", "buildCmuxWorkspaceTitle", "closeCmuxWorkspaceByTitle", "$", "removed", "index", "result", "config", "getInfraKitConfig", "cursorConfig", "workspacePath", "resolveCursorWorkspacePath", "folderPaths", "removeFoldersFromCursorWorkspace", "worktreesRemoveMcpTool", "z", "confirm", "process", "z", "$", "RELEASE_BRANCH_PREFIX", "worktreesSync", "options", "confirmedCommand", "commandEcho", "currentWorktrees", "getCurrentWorktrees", "projectRoot", "getProjectRoot", "worktreeDir", "WORKTREES_DIR_SUFFIX", "releasePRsList", "getReleasePRs", "answer", "confirm", "logger", "process", "branchesToRemove", "categorizeWorktrees", "repoName", "getRepoName", "removedWorktrees", "removeWorktrees", "syncCursorWorkspaceOnRemove", "logResults", "structuredContent", "error", "args", "branch", "branches", "removed", "worktreePath", "title", "buildCmuxWorkspaceTitle", "closeCmuxWorkspaceByTitle", "$", "config", "getInfraKitConfig", "cursorConfig", "workspacePath", "resolveCursorWorkspacePath", "folderPaths", "removedEntries", "removeFoldersFromCursorWorkspace", "worktreesSyncMcpTool", "z", "createToolHandler", "args", "params", "toolName", "handler", "logger", "payload", "error", "tools", "envStatusMcpTool", "envListMcpTool", "envLoadMcpTool", "envClearMcpTool", "ghMergeDevMcpTool", "releaseCreateMcpTool", "releaseCreateBatchMcpTool", "ghReleaseDeliverMcpTool", "ghReleaseDeployAllMcpTool", "ghReleaseDeploySelectedMcpTool", "ghReleaseListMcpTool", "versionMcpTool", "worktreesAddMcpTool", "worktreesListMcpTool", "worktreesOpenMcpTool", "worktreesRemoveMcpTool", "worktreesSyncMcpTool", "initializeTools", "server", "tool", "createToolHandler", "createMcpServer", "server", "McpServer", "initializePrompts", "initializeResources", "initializeTools", "logger", "initLoggerMcp", "startServer", "server", "createMcpServer", "error", "process", "transport", "StdioServerTransport", "setupErrorHandlers"]
3
+ "sources": ["../src/entry/mcp.ts", "../src/lib/error-handlers/index.ts", "../src/lib/logger/index.ts", "../src/mcp/server.ts", "../src/mcp/prompts/index.ts", "../src/mcp/resources/index.ts", "../src/commands/env-clear/env-clear.ts", "../src/lib/constants.ts", "../src/commands/env-list/env-list.ts", "../src/lib/infra-kit-config/infra-kit-config.ts", "../src/lib/git-utils/git-utils.ts", "../src/integrations/doppler/doppler-project.ts", "../src/commands/env-load/env-load.ts", "../src/integrations/doppler/doppler-cli-auth.ts", "../src/lib/command-echo/command-echo.ts", "../src/commands/env-status/env-status.ts", "../src/commands/gh-merge-dev/gh-merge-dev.ts", "../src/integrations/gh/gh-cli-auth/gh-cli-auth.ts", "../src/integrations/gh/gh-release-prs/gh-release-prs.ts", "../src/lib/release-utils/release-utils.ts", "../src/integrations/jira/api.ts", "../src/lib/version-utils/load-existing-versions.ts", "../src/lib/version-utils/version-utils.ts", "../src/lib/version-utils/next-version.ts", "../src/commands/gh-release-deliver/gh-release-deliver.ts", "../src/commands/gh-release-deploy-all/gh-release-deploy-all.ts", "../src/commands/gh-release-deploy-selected/gh-release-deploy-selected.ts", "../src/commands/gh-release-list/gh-release-list.ts", "../src/commands/release-create/release-create.ts", "../src/commands/version/version.ts", "../package.json", "../src/commands/worktrees-add/worktrees-add.ts", "../src/integrations/cmux/close-workspace-by-title.ts", "../src/integrations/cmux/list-workspace-titles.ts", "../src/integrations/cmux/open-workspace-with-layout.ts", "../src/integrations/cmux/workspace-title.ts", "../src/integrations/cursor/add-folders-to-workspace.ts", "../src/integrations/cursor/reconcile-workspace-folders.ts", "../src/integrations/cursor/remove-folders-from-workspace.ts", "../src/integrations/cursor/resolve-workspace-path.ts", "../src/commands/worktrees-list/worktrees-list.ts", "../src/commands/worktrees-open/worktrees-open.ts", "../src/commands/worktrees-remove/worktrees-remove.ts", "../src/commands/worktrees-sync/worktrees-sync.ts", "../src/lib/tool-handler/tool-handler.ts", "../src/mcp/tools/index.ts"],
4
+ "sourcesContent": ["import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'\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\n try {\n server = await createMcpServer()\n\n logger.info('MCP Server instance created')\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 '../logger/index'\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", "import process from 'node:process'\nimport pino from 'pino'\nimport pretty from 'pino-pretty'\n\n// eslint-disable-next-line sonarjs/publicly-writable-directories\nexport const LOG_FILE_PATH = '/tmp/mcp-infra-kit.log'\n\nexport const initLoggerMcp = () => {\n const logLevel = process.argv.includes('--debug') ? 'debug' : 'info'\n\n const logger = pino({ level: logLevel }, pino.destination({ dest: LOG_FILE_PATH }))\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 destination: 2,\n ignore: ignoreFields.join(','),\n colorize: true,\n }),\n )\n\n return logger\n}\n\n// Singleton logger instance for CLI usage\nexport const logger = initLoggerCLI()\n", "import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\n\nimport { initializePrompts } from './prompts'\nimport { initializeResources } from './resources'\nimport { initializeTools } from './tools'\n\nexport async function createMcpServer() {\n const server = new McpServer(\n {\n name: 'infra-kit',\n version: '1.0.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 return server\n}\n", "import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\n\nexport const initializePrompts = async (_server: McpServer) => {}\n", "import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\n\nexport const initializeResources = async (_server: McpServer) => {}\n", "import fs from 'node:fs'\nimport path from 'node:path'\nimport process from 'node:process'\nimport { z } from 'zod/v4'\n\nimport {\n ENV_CLEAR_FILE,\n ENV_LOAD_FILE,\n INFRA_KIT_ENV_CONFIG_VAR,\n INFRA_KIT_ENV_LOADED_AT_VAR,\n INFRA_KIT_ENV_PROJECT_VAR,\n atomicWriteFileSync,\n getSessionCacheDir,\n parseVarNamesFromEnvFile,\n} from 'src/lib/constants'\nimport type { ToolsExecutionResult } from 'src/types'\n\n/**\n * Clear loaded env vars. Prints a file path to stdout that must be sourced to apply.\n * The env-clear shell alias does this automatically. Throws when no env is loaded\n * so CLI callers exit non-zero and MCP callers receive a structured tool error.\n */\nexport const envClear = async (): Promise<ToolsExecutionResult> => {\n const cacheDir = getSessionCacheDir()\n const envLoadPath = path.join(cacheDir, ENV_LOAD_FILE)\n\n if (!fs.existsSync(envLoadPath)) {\n throw new Error('No loaded environment found. Run `env-load` first.')\n }\n\n const varNames = parseVarNamesFromEnvFile(envLoadPath)\n\n const unsetLines = [\n ...varNames.map((v) => {\n return `unset ${v}`\n }),\n `unset ${INFRA_KIT_ENV_CONFIG_VAR}`,\n `unset ${INFRA_KIT_ENV_PROJECT_VAR}`,\n `unset ${INFRA_KIT_ENV_LOADED_AT_VAR}`,\n ]\n\n const clearFilePath = path.resolve(cacheDir, ENV_CLEAR_FILE)\n\n fs.mkdirSync(cacheDir, { recursive: true, mode: 0o700 })\n\n atomicWriteFileSync(clearFilePath, `${unsetLines.join('\\n')}\\n`, 0o600)\n\n // REQUIRED\n process.stdout.write(`${clearFilePath}\\n`)\n\n // Remove env load file so the next env-clear call correctly reports \"no env loaded\".\n fs.unlinkSync(envLoadPath)\n\n const structuredContent = {\n filePath: clearFilePath,\n variableCount: varNames.length,\n unsetStatements: unsetLines,\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\nexport const envClearMcpTool = {\n name: 'env-clear',\n description:\n 'Generate a shell script that unsets every env var previously loaded by env-load for this session, plus the infra-kit session metadata vars. Does NOT mutate the calling process. When `infra-kit init` has installed the zsh shell integration, the user\\'s terminal auto-sources the unset script on its next prompt (precmd hook) \u2014 so calling this via MCP will clear the vars in the shell that launched Claude Code automatically. Other callers must source \"<filePath>\" themselves or surface it to the user. Errors if no env is currently loaded.',\n inputSchema: {},\n outputSchema: {\n filePath: z.string().describe('Path to the file that must be sourced to apply'),\n variableCount: z.number().describe('Number of variables cleared'),\n unsetStatements: z.array(z.string()).describe('Unset statements generated'),\n },\n handler: envClear,\n}\n", "import fs from 'node:fs'\nimport os from 'node:os'\nimport path from 'node:path'\nimport process from 'node:process'\n\nexport const ENV_LOAD_FILE = 'env-load.sh'\nexport const ENV_CLEAR_FILE = 'env-clear.sh'\n\nexport const INFRA_KIT_SESSION_VAR = 'INFRA_KIT_SESSION'\nexport const INFRA_KIT_ENV_CONFIG_VAR = 'INFRA_KIT_ENV_CONFIG'\nexport const INFRA_KIT_ENV_PROJECT_VAR = 'INFRA_KIT_ENV_PROJECT'\nexport const INFRA_KIT_ENV_LOADED_AT_VAR = 'INFRA_KIT_ENV_LOADED_AT'\n\n/**\n * Matches a line of the form `KEY=...` where KEY is an env-var identifier\n * (letter or underscore, then word chars). Capture group 1 is the name. Shared\n * between env-load (validation, var counting) and parseVarNamesFromEnvFile.\n */\nexport const ENV_VAR_LINE_PATTERN = /^([A-Z_]\\w*)=/i\n\nexport const parseVarNamesFromEnvFile = (filePath: string): string[] => {\n if (!fs.existsSync(filePath)) return []\n\n const content = fs.readFileSync(filePath, 'utf-8')\n const names: string[] = []\n\n for (const line of content.split('\\n')) {\n const match = ENV_VAR_LINE_PATTERN.exec(line)\n\n if (match) {\n names.push(match[1]!)\n }\n }\n\n return names\n}\n\n/**\n * Root cache dir for infra-kit across all sessions. Resolved from\n * $XDG_CACHE_HOME when set, falling back to ~/.cache/infra-kit. Keep in sync\n * with the shell block emitted by `infra-kit init` (src/commands/init/init.ts).\n */\nexport const getCacheRoot = (): string => {\n const xdg = process.env.XDG_CACHE_HOME\n const base = xdg && xdg.length > 0 ? xdg : path.join(os.homedir(), '.cache')\n\n return path.join(base, 'infra-kit')\n}\n\nexport const getSessionCacheDir = (): string => {\n const session = process.env[INFRA_KIT_SESSION_VAR]\n\n if (!session) {\n throw new Error(`${INFRA_KIT_SESSION_VAR} is not set. Run \\`infra-kit init\\` then \\`source ~/.zshrc\\`.`)\n }\n\n return path.join(getCacheRoot(), session)\n}\n\n/**\n * Write content atomically: write to a pid-suffixed temp file in the same\n * directory, then rename. fs.renameSync is atomic on a single filesystem, so\n * concurrent writers can't produce a half-written secret file.\n */\nexport const atomicWriteFileSync = (filePath: string, content: string, mode: number): void => {\n const tmpPath = `${filePath}.tmp.${process.pid}`\n\n fs.writeFileSync(tmpPath, content, { mode })\n\n try {\n fs.renameSync(tmpPath, filePath)\n } catch (error) {\n fs.rmSync(tmpPath, { force: true })\n throw error\n }\n}\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 { z } from 'zod/v4'\n\nimport { getDopplerProject } from 'src/integrations/doppler/doppler-project'\nimport { getInfraKitConfig } from 'src/lib/infra-kit-config'\nimport { logger } from 'src/lib/logger'\nimport type { ToolsExecutionResult } from 'src/types'\n\n/**\n * List available Doppler configs for the detected project.\n *\n * Purely local: reads infra-kit.yml and does not call Doppler. We intentionally\n * do not run validateDopplerCliAndAuth here \u2014 users listing envs often do so\n * before `doppler login`, and a spurious auth error would be misleading.\n */\nexport const envList = async (): Promise<ToolsExecutionResult> => {\n const project = await getDopplerProject()\n const { environments } = await getInfraKitConfig()\n\n logger.info(`Doppler project: ${project}\\n`)\n logger.info('Available configs:')\n\n for (const env of environments) {\n logger.info(` - ${env}`)\n }\n\n const structuredContent = {\n project,\n configs: environments,\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\nexport const envListMcpTool = {\n name: 'env-list',\n description:\n 'List the environments the project is configured to support. Returns the `environments` list declared in infra-kit.yml at the project root (not a live fetch from Doppler) plus the Doppler project name resolved from the same file. Read-only.',\n inputSchema: {},\n outputSchema: {\n project: z.string().describe('Detected Doppler project name'),\n configs: z.array(z.string()).describe('Available environment configs'),\n },\n handler: envList,\n}\n", "import fs from 'node:fs/promises'\nimport os from 'node:os'\nimport path from 'node:path'\nimport yaml from 'yaml'\nimport { z } from 'zod/v4'\n\nimport { getProjectRoot, getRepoName } from 'src/lib/git-utils'\n\nconst INFRA_KIT_CONFIG_FILE = 'infra-kit.yml'\n\nconst USER_CONFIG_DIR_NAME = '.infra-kit'\nconst USER_GLOBAL_CONFIG_FILE = 'config.yml'\nconst USER_PROJECTS_DIR = 'projects'\n\n// envManagement\nconst dopplerEnvManagementSchema = z.object({\n provider: z.literal('doppler'),\n config: z.object({\n name: z.string().min(1),\n }),\n})\n\nconst envManagementSchema = z.discriminatedUnion('provider', [dopplerEnvManagementSchema])\n\n// ide\nconst cursorIdeConfigSchema = z\n .object({\n mode: z.enum(['workspace', 'windows']).default('workspace'),\n workspaceConfigPath: z.string().min(1).optional(),\n })\n .refine(\n (v) => {\n return v.mode !== 'workspace' || !!v.workspaceConfigPath\n },\n {\n message: 'workspaceConfigPath is required when mode is \"workspace\"',\n path: ['workspaceConfigPath'],\n },\n )\n\nconst cursorIdeSchema = z.object({\n provider: z.literal('cursor'),\n config: cursorIdeConfigSchema,\n})\n\nconst ideSchema = z.discriminatedUnion('provider', [cursorIdeSchema])\n\n// taskManager\nconst jiraTaskManagerSchema = z.object({\n provider: z.literal('jira'),\n config: z.object({\n baseUrl: z.string().url(),\n projectId: z.number().int().positive(),\n }),\n})\n\nconst taskManagerSchema = z.discriminatedUnion('provider', [jiraTaskManagerSchema])\n\n// worktrees prompt defaults\nconst worktreesConfigSchema = z.object({\n openInGithubDesktop: z.boolean().optional(),\n openInCmux: z.boolean().optional(),\n})\n\nconst infraKitConfigSchema = z.object({\n environments: z.array(z.string().min(1)).min(1),\n envManagement: envManagementSchema,\n ide: ideSchema.optional(),\n taskManager: taskManagerSchema.optional(),\n worktrees: worktreesConfigSchema.optional(),\n})\n\nconst infraKitOverrideConfigSchema = infraKitConfigSchema.partial()\n\nexport type InfraKitConfig = z.infer<typeof infraKitConfigSchema>\n\nexport interface InfraKitConfigPaths {\n /** Committed project config (required). */\n main: string\n /** User-scope global overrides applied to every project. */\n userGlobal: string\n /** User-scope per-project overrides \u2014 `<userProjectsDir>/<projectName>/infra-kit.yml`. */\n userProject: string\n /** Repo basename (`path.basename(projectRoot)`) used to namespace the user-project file. */\n projectName: string\n}\n\ninterface CacheEntry {\n mtimes: Record<keyof Omit<InfraKitConfigPaths, 'projectName'>, number | null>\n value: InfraKitConfig\n}\n\nlet cached: CacheEntry | null = null\n\n/**\n * Resolve every file path that participates in the config merge chain. Always\n * returns paths even for files that don't yet exist, so callers can use them\n * for \"where would my override go?\" prompts.\n *\n * @example\n * const paths = await getInfraKitConfigPaths()\n * // {\n * // main: '/Users/arthur/projects/api/infra-kit.yml',\n * // userGlobal: '/Users/arthur/.infra-kit/config.yml',\n * // userProject: '/Users/arthur/.infra-kit/projects/api/infra-kit.yml',\n * // projectName: 'api',\n * // }\n */\nexport const getInfraKitConfigPaths = async (): Promise<InfraKitConfigPaths> => {\n const projectRoot = await getProjectRoot()\n const projectName = await getRepoName()\n const userConfigDir = path.join(os.homedir(), USER_CONFIG_DIR_NAME)\n\n return {\n main: path.join(projectRoot, INFRA_KIT_CONFIG_FILE),\n userGlobal: path.join(userConfigDir, USER_GLOBAL_CONFIG_FILE),\n userProject: path.join(userConfigDir, USER_PROJECTS_DIR, projectName, INFRA_KIT_CONFIG_FILE),\n projectName,\n }\n}\n\n/**\n * Read and validate `infra-kit.yml`, with optional override layers shallow-merged\n * on top in this order (later wins):\n * 1. project `infra-kit.yml` \u2014 committed source of truth\n * 2. `~/.infra-kit/config.yml` \u2014 user-global defaults\n * 3. `~/.infra-kit/projects/<repo-name>/infra-kit.yml` \u2014 user-scope per-project overrides\n *\n * Top-level keys (entire capability sections like `ide`, `envManagement`)\n * replace wholesale. Results are cached per file mtimes so the long-running\n * MCP server picks up edits without a restart.\n *\n * @example\n * // infra-kit.yml: { environments: ['dev'], envManagement: { provider: 'doppler', config: { name: 'p' } } }\n * // ~/.infra-kit/config.yml: { ide: { provider: 'cursor', config: { mode: 'windows' } } }\n * const cfg = await getInfraKitConfig()\n * // => { environments: ['dev'], envManagement: {...}, ide: { provider: 'cursor', config: { mode: 'windows' } } }\n */\nexport const getInfraKitConfig = async (): Promise<InfraKitConfig> => {\n const paths = await getInfraKitConfigPaths()\n\n let mainStat: Awaited<ReturnType<typeof fs.stat>>\n\n try {\n mainStat = await fs.stat(paths.main)\n } catch {\n cached = null\n throw new Error(`infra-kit.yml not found at ${paths.main}`)\n }\n\n const [userGlobalStat, userProjectStat] = await Promise.all([\n statIfExists(paths.userGlobal),\n statIfExists(paths.userProject),\n ])\n\n const mtimes = {\n main: Number(mainStat.mtimeMs),\n userGlobal: userGlobalStat ? Number(userGlobalStat.mtimeMs) : null,\n userProject: userProjectStat ? Number(userProjectStat.mtimeMs) : null,\n }\n\n if (cached && shallowEqual(cached.mtimes, mtimes)) {\n return cached.value\n }\n\n const layers: ConfigLayer[] = [\n { label: 'infra-kit.yml', path: paths.main, required: true },\n { label: '~/.infra-kit/config.yml', path: paths.userGlobal, required: false },\n {\n label: `~/.infra-kit/projects/${paths.projectName}/infra-kit.yml`,\n path: paths.userProject,\n required: false,\n },\n ]\n\n let merged: Record<string, unknown> = {}\n\n for (const layer of layers) {\n const data = await loadLayer(layer)\n\n if (data === null) continue\n\n merged = { ...merged, ...data }\n }\n\n const finalResult = infraKitConfigSchema.safeParse(merged)\n\n if (!finalResult.success) {\n throw new Error(`Invalid merged infra-kit config: ${z.prettifyError(finalResult.error)}`)\n }\n\n cached = { mtimes, value: finalResult.data }\n\n return finalResult.data\n}\n\n/**\n * For tests \u2014 drops the in-memory cache so the next read hits disk.\n *\n * @example\n * resetInfraKitConfigCache()\n * await getInfraKitConfig() // re-reads files even if mtimes look unchanged\n */\nexport const resetInfraKitConfigCache = (): void => {\n cached = null\n}\n\n/**\n * `fs.stat` that returns `null` instead of throwing on ENOENT. Used so the\n * resolver can probe optional files in the merge chain without try/catch noise.\n *\n * @example\n * const stat = await statIfExists('/does/not/exist') // => null\n */\nconst statIfExists = async (filePath: string): Promise<Awaited<ReturnType<typeof fs.stat>> | null> => {\n try {\n return await fs.stat(filePath)\n } catch {\n return null\n }\n}\n\n/**\n * `fs.readFile` that returns `null` instead of throwing on ENOENT.\n *\n * @example\n * const raw = await readIfExists('/missing.yml') // => null\n * const raw = await readIfExists('/exists.yml') // => 'environments: [dev]\\n'\n */\nconst readIfExists = async (filePath: string): Promise<string | null> => {\n try {\n return await fs.readFile(filePath, 'utf-8')\n } catch {\n return null\n }\n}\n\n/**\n * Reference-equality comparison of every key in two flat records. Used to\n * cheaply detect whether the cached mtime fingerprint still matches.\n *\n * @example\n * shallowEqual({ a: 1, b: 2 }, { a: 1, b: 2 }) // => true\n * shallowEqual({ a: 1 }, { a: 1, b: 2 }) // => false\n * shallowEqual({ a: 1 }, { a: 2 }) // => false\n */\nconst shallowEqual = <T extends Record<string, unknown>>(a: T, b: T): boolean => {\n const keys = Object.keys(a)\n\n if (keys.length !== Object.keys(b).length) return false\n\n return keys.every((k) => {\n return a[k] === b[k]\n })\n}\n\ninterface ConfigLayer {\n label: string\n path: string\n required: boolean\n}\n\n/**\n * Read a single layer of the merge chain: parse the YAML if the file exists\n * and validate it against the override schema. Returns `null` if an optional\n * layer is missing; throws if the layer is required or invalid.\n *\n * @example\n * await loadLayer({ label: '~/.infra-kit/config.yml', path: '/missing.yml', required: false })\n * // => null\n *\n * @example\n * // /home/me/.infra-kit/config.yml: 'ide:\\n provider: cursor\\n config: { mode: windows }'\n * await loadLayer({ label: '~/.infra-kit/config.yml', path: '/home/me/.infra-kit/config.yml', required: false })\n * // => { ide: { provider: 'cursor', config: { mode: 'windows' } } }\n */\nconst loadLayer = async (layer: ConfigLayer): Promise<Record<string, unknown> | null> => {\n const raw = await readIfExists(layer.path)\n\n if (raw === null) {\n if (layer.required) {\n throw new Error(`${layer.label} not found at ${layer.path}`)\n }\n\n return null\n }\n\n const parsedRaw = yaml.parse(raw) ?? {}\n const result = infraKitOverrideConfigSchema.safeParse(parsedRaw)\n\n if (!result.success) {\n throw new Error(`Invalid ${layer.label} at ${layer.path}: ${z.prettifyError(result.error)}`)\n }\n\n return result.data as Record<string, unknown>\n}\n", "import path from 'node:path'\nimport { $ } 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\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) => {\n return branch !== null\n })\n}\n\n/**\n * Extract the branch name from a `git worktree list` output line.\n *\n * `git worktree list` formats each line as:\n * <path> <hash> [<branch>]\n *\n * Reads the branch from the trailing `[branch]` token so it works for the\n * main checkout too (whose path does not encode the branch name).\n */\nconst parseWorktreeBranch = (line: string): string | null => {\n const trimmed = line.trimEnd()\n\n if (!trimmed.endsWith(']')) return null\n\n const open = trimmed.lastIndexOf('[')\n\n if (open === -1) return null\n\n const branch = trimmed.slice(open + 1, -1)\n\n return branch.length > 0 ? branch : null\n}\n\n/**\n * Extract a release branch name from a `git worktree list` output line.\n *\n * Returns `null` for lines that are not release worktrees.\n *\n * @example\n * releaseWorktreePredicate('/path/to/release/v1.18.22 abc1234 [release/v1.18.22]')\n * // => 'release/v1.18.22'\n *\n * @example\n * releaseWorktreePredicate('/path/to/feature/login abc1234 [feature/login]')\n * // => null\n */\nconst releaseWorktreePredicate = (line: string): string | null => {\n const branch = parseWorktreeBranch(line)\n\n return branch?.startsWith('release/v') ? branch : null\n}\n\n/**\n * Extract a feature branch name from a `git worktree list` output line.\n *\n * Returns `null` for lines that are not feature worktrees.\n *\n * @example\n * featureWorktreePredicate('/path/to/feature/login-page abc1234 [feature/login-page]')\n * // => 'feature/login-page'\n *\n * @example\n * featureWorktreePredicate('/path/to/release/v1.18.22 abc1234 [release/v1.18.22]')\n * // => null\n */\nconst featureWorktreePredicate = (line: string): string | null => {\n const branch = parseWorktreeBranch(line)\n\n return branch?.startsWith('feature/') ? branch : null\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\n return result.stdout.trim()\n}\n\n/**\n * Get the current repository name (basename of the project root)\n */\nexport const getRepoName = async (): Promise<string> => {\n const projectRoot = await getProjectRoot()\n\n return path.basename(projectRoot)\n}\n", "import { getInfraKitConfig } from 'src/lib/infra-kit-config'\n\n/**\n * Resolve Doppler project name from infra-kit.yml at the project root\n */\nexport const getDopplerProject = async (): Promise<string> => {\n const { envManagement } = await getInfraKitConfig()\n\n return envManagement.config.name\n}\n", "import select from '@inquirer/select'\nimport { Buffer } from 'node:buffer'\nimport fs from 'node:fs'\nimport path from 'node:path'\nimport process from 'node:process'\nimport { z } from 'zod/v4'\nimport { $ } from 'zx'\n\nimport { validateDopplerCliAndAuth } from 'src/integrations/doppler'\nimport { getDopplerProject } from 'src/integrations/doppler/doppler-project'\nimport { commandEcho } from 'src/lib/command-echo'\nimport {\n ENV_LOAD_FILE,\n ENV_VAR_LINE_PATTERN,\n INFRA_KIT_ENV_CONFIG_VAR,\n INFRA_KIT_ENV_LOADED_AT_VAR,\n INFRA_KIT_ENV_PROJECT_VAR,\n atomicWriteFileSync,\n getSessionCacheDir,\n} from 'src/lib/constants'\nimport { getInfraKitConfig } from 'src/lib/infra-kit-config'\nimport type { ToolsExecutionResult } from 'src/types'\n\ninterface EnvLoadArgs {\n config?: string\n}\n\n/**\n * Load environment variables from Doppler for the given config\n */\nexport const envLoad = async (args: EnvLoadArgs): Promise<ToolsExecutionResult> => {\n await validateDopplerCliAndAuth()\n\n const { config } = args\n\n commandEcho.start('env-load')\n\n let selectedConfig = ''\n\n if (config) {\n selectedConfig = config\n } else {\n const { environments } = await getInfraKitConfig()\n\n commandEcho.setInteractive()\n selectedConfig = await select(\n {\n message: 'Select environment config',\n choices: environments.map((env) => {\n return { name: env, value: env }\n }),\n },\n // Render to stderr so the prompt is visible when stdout is captured via $() in the shell function.\n // Only env-load and env-clear use the $() stdout-capture shell pattern.\n { output: process.stderr },\n )\n }\n\n commandEcho.addOption('--config', selectedConfig)\n\n const project = await getDopplerProject()\n\n const envContent = await downloadDopplerSecrets(project, selectedConfig)\n\n assertValidEnvContent(envContent)\n\n // Build env file content in dotenv format\n const loadedAt = new Date().toISOString()\n const envFileLines = [\n 'set -a',\n envContent,\n `${INFRA_KIT_ENV_CONFIG_VAR}=${shellSingleQuote(selectedConfig)}`,\n `${INFRA_KIT_ENV_PROJECT_VAR}=${shellSingleQuote(project)}`,\n `${INFRA_KIT_ENV_LOADED_AT_VAR}=${shellSingleQuote(loadedAt)}`,\n 'set +a',\n ]\n\n const cacheDir = getSessionCacheDir()\n const envFilePath = path.resolve(cacheDir, ENV_LOAD_FILE)\n\n fs.mkdirSync(cacheDir, { recursive: true, mode: 0o700 })\n atomicWriteFileSync(envFilePath, `${envFileLines.join('\\n')}\\n`, 0o600)\n\n // REQUIRED\n process.stdout.write(`${envFilePath}\\n`)\n\n // Logs to stderr (pino \u2192 pretty-print), so it doesn't pollute the captured\n // file path that the shell wrapper reads from stdout.\n commandEcho.print()\n\n const varCount = countEnvVarLines(envContent)\n\n const structuredContent = {\n filePath: envFilePath,\n variableCount: varCount,\n project,\n config: selectedConfig,\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/**\n * Cap the Doppler stdout we're willing to accept. A well-formed env bundle is\n * O(10 KB); megabytes would indicate a service regression or the wrong stream\n * being captured, and we don't want to write that to disk or source it.\n */\nexport const DOPPLER_MAX_OUTPUT_BYTES = 1024 * 1024\n\n/**\n * Hard upper bound for the Doppler subprocess. Well under zx's default so a\n * hung call surfaces quickly instead of blocking an interactive shell or an\n * MCP tool handler.\n */\nconst DOPPLER_DOWNLOAD_TIMEOUT_MS = 30_000\n\nconst downloadDopplerSecrets = async (project: string, config: string): Promise<string> => {\n const prevQuiet = $.quiet\n\n $.quiet = true\n try {\n const result =\n await $`doppler secrets download --no-file --format env --project ${project} --config ${config}`.timeout(\n DOPPLER_DOWNLOAD_TIMEOUT_MS,\n )\n\n assertDopplerOutputSize(result.stdout)\n\n return result.stdout.trim()\n } finally {\n $.quiet = prevQuiet\n }\n}\n\nexport const assertDopplerOutputSize = (stdout: string): void => {\n const bytes = Buffer.byteLength(stdout, 'utf-8')\n\n if (bytes > DOPPLER_MAX_OUTPUT_BYTES) {\n throw new Error(\n `doppler returned unexpectedly large output (${bytes} bytes > ${DOPPLER_MAX_OUTPUT_BYTES}) \u2014 refusing to write to disk`,\n )\n }\n}\n\nconst countEnvVarLines = (content: string): number => {\n return content.split('\\n').filter((line) => {\n return ENV_VAR_LINE_PATTERN.test(line)\n }).length\n}\n\nconst SHELL_DIRECTIVE_LINES = new Set(['set -a', 'set +a'])\n\nexport const shellSingleQuote = (value: string): string => {\n const escaped = value.replaceAll(\"'\", \"'\\\\''\")\n\n return `'${escaped}'`\n}\n\n/**\n * Guard against Doppler returning non-env output (auth warnings on stdout,\n * partial downloads, HTML error pages, etc.). Every non-blank, non-directive\n * line must match KEY=VALUE \u2014 skipping directives keeps future format tweaks\n * cheap without loosening the check.\n */\nexport const assertValidEnvContent = (content: string): void => {\n if (content.trim().length === 0) {\n throw new Error('doppler returned empty output for env-load')\n }\n\n for (const line of content.split('\\n')) {\n const trimmed = line.trim()\n\n if (trimmed.length === 0 || SHELL_DIRECTIVE_LINES.has(trimmed)) continue\n\n if (!ENV_VAR_LINE_PATTERN.test(trimmed)) {\n throw new Error(\n `doppler returned unexpected output for env-load (expected KEY=value lines, got: ${JSON.stringify(trimmed.slice(0, 80))})`,\n )\n }\n }\n}\n\n// MCP Tool Registration\nexport const envLoadMcpTool = {\n name: 'env-load',\n description:\n 'Download the env vars for a Doppler config and write them to a temporary shell script. Does NOT mutate the calling process \u2014 returns the path to a script that must be sourced (\"source <filePath>\") for the vars to take effect. The infra-kit shell wrapper auto-sources; direct MCP callers must handle sourcing themselves or surface filePath to the user. \"config\" is required when invoked via MCP (the CLI interactive picker is unreachable without a TTY).',\n inputSchema: {\n config: z\n .string()\n .describe('Doppler config / environment name to load (e.g. \"dev\", \"arthur\", \"renana\"). Required for MCP calls.'),\n },\n outputSchema: {\n filePath: z.string().describe('Path to the file that must be sourced to apply variables'),\n variableCount: z.number().describe('Number of variables loaded'),\n project: z.string().describe('Doppler project name'),\n config: z.string().describe('Doppler config name'),\n },\n handler: envLoad,\n}\n", "import { $ } from 'zx'\n\n/**\n * Validate Doppler CLI installation and authentication status. Throws on failure\n * so callers (CLI entry, MCP tool handler) can translate to the right surface \u2014\n * CLI exits non-zero; MCP returns a structured tool error instead of tearing\n * down the server.\n */\nexport const validateDopplerCliAndAuth = async (): Promise<void> => {\n try {\n await $`doppler --version`\n } catch (error: unknown) {\n throw new Error('Doppler CLI is not installed. Install it from: https://docs.doppler.com/docs/install-cli', {\n cause: error,\n })\n }\n\n try {\n await $`doppler me`\n } catch (error: unknown) {\n throw new Error('Doppler CLI is not authenticated. Run: doppler login', { cause: error })\n }\n}\n", "import { logger } from 'src/lib/logger'\n\ninterface CommandOption {\n flag: string\n value: string | string[] | boolean\n}\n\nconst createCommandEcho = () => {\n let commandName = ''\n let options: CommandOption[] = []\n let isInteractive = false\n\n return {\n /**\n * Initialize command echo for a new command\n */\n start(name: string): void {\n commandName = name\n options = []\n isInteractive = false\n },\n\n /**\n * Mark that the command had interactive input (prompts)\n * Call this once when ANY prompt happens\n */\n setInteractive(): void {\n isInteractive = true\n },\n\n /**\n * Track an option selection\n * @param flag The CLI flag (e.g., \"--versions\")\n * @param value The selected value\n */\n addOption(flag: string, value: string | string[] | boolean): void {\n options.push({ flag, value })\n },\n\n /**\n * Print the equivalent CLI command if there was interactive input\n */\n print(): void {\n if (!isInteractive || options.length === 0) {\n return\n }\n\n const formattedOptions = options\n .map((opt) => {\n if (typeof opt.value === 'boolean') {\n return opt.value ? opt.flag : ''\n }\n\n if (Array.isArray(opt.value)) {\n return `${opt.flag} \"${opt.value.join(', ')}\"`\n }\n\n return `${opt.flag} \"${opt.value}\"`\n })\n .filter(Boolean)\n .join(' ')\n\n logger.info(`\uD83D\uDCDF Equivalent command: \\npnpm exec infra-kit ${commandName} ${formattedOptions}\\n`)\n },\n\n /**\n * Reset state (useful for testing)\n */\n reset(): void {\n commandName = ''\n options = []\n isInteractive = false\n },\n }\n}\n\n// Singleton instance (same pattern as logger)\nexport const commandEcho = createCommandEcho()\n", "import path from 'node:path'\nimport process from 'node:process'\nimport { z } from 'zod/v4'\n\nimport { validateDopplerCliAndAuth } from 'src/integrations/doppler'\nimport {\n ENV_LOAD_FILE,\n INFRA_KIT_ENV_CONFIG_VAR,\n INFRA_KIT_ENV_LOADED_AT_VAR,\n INFRA_KIT_ENV_PROJECT_VAR,\n INFRA_KIT_SESSION_VAR,\n getSessionCacheDir,\n parseVarNamesFromEnvFile,\n} from 'src/lib/constants'\nimport { logger } from 'src/lib/logger'\nimport type { ToolsExecutionResult } from 'src/types'\n\n/**\n * Show Doppler authentication status and detected project info\n */\nexport const envStatus = async (): Promise<ToolsExecutionResult> => {\n await validateDopplerCliAndAuth()\n\n logger.info('Environment session status:')\n\n // Check session-loaded vars \u2014 getSessionCacheDir() throws if INFRA_KIT_SESSION is unset\n const cacheDir = getSessionCacheDir()\n\n const sessionId = process.env[INFRA_KIT_SESSION_VAR]!\n const envLoadPath = path.join(cacheDir, ENV_LOAD_FILE)\n\n let sessionLoadedCount = 0\n let sessionTotalCount = 0\n\n const sessionConfig = process.env[INFRA_KIT_ENV_CONFIG_VAR] ?? null\n const sessionProject = process.env[INFRA_KIT_ENV_PROJECT_VAR] ?? null\n const sessionLoadedAt = process.env[INFRA_KIT_ENV_LOADED_AT_VAR] ?? null\n\n if (sessionConfig) {\n const varNames = parseVarNamesFromEnvFile(envLoadPath)\n\n if (varNames.length > 0) {\n sessionTotalCount = varNames.length\n sessionLoadedCount = varNames.filter((v) => {\n return v in process.env\n }).length\n }\n\n const loadedAtDisplay = sessionLoadedAt?.replace(/\\.\\d{3}Z$/, '') ?? null\n\n logger.info(\n ` ${sessionConfig}: ${sessionLoadedCount} of ${sessionTotalCount} vars loaded (project: ${sessionProject}, loadedAt: ${loadedAtDisplay}, session: ${sessionId})\\n`,\n )\n\n if (sessionTotalCount > 0 && sessionLoadedCount < sessionTotalCount) {\n const missing = sessionTotalCount - sessionLoadedCount\n\n logger.warn(\n ` ${missing} cached var(s) are not present in the current process \u2014 env-load needs to be re-sourced, or vars were unset manually.`,\n )\n }\n } else {\n logger.info(` Session ${sessionId}: no env loaded\\n`)\n }\n\n const structuredContent = {\n sessionId,\n sessionLoadedCount,\n sessionTotalCount,\n sessionConfig,\n sessionProject,\n sessionLoadedAt,\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\nexport const envStatusMcpTool = {\n name: 'env-status',\n description:\n 'Report which Doppler project/config is currently loaded in the terminal session, when it was loaded, and how many variables are cached. Read-only \u2014 use env-load / env-clear to change the terminal session.',\n inputSchema: {},\n outputSchema: {\n sessionId: z.string().describe('Current terminal session ID'),\n sessionLoadedCount: z.number().describe('Number of cached vars active in the current session'),\n sessionTotalCount: z.number().describe('Total number of cached var names'),\n sessionConfig: z.string().nullable().describe('Doppler config name of the loaded session (environment name)'),\n sessionProject: z.string().nullable().describe('Doppler project name of the loaded session'),\n sessionLoadedAt: z.string().nullable().describe('ISO 8601 timestamp of when the env was loaded'),\n },\n handler: envStatus,\n}\n", "/* eslint-disable sonarjs/cognitive-complexity */\nimport checkbox from '@inquirer/checkbox'\nimport confirm from '@inquirer/confirm'\nimport process from 'node:process'\nimport { z } from 'zod/v4'\nimport { $ } from 'zx'\n\nimport { getReleasePRsWithInfo } from 'src/integrations/gh'\nimport { commandEcho } from 'src/lib/command-echo'\nimport { logger } from 'src/lib/logger'\nimport { detectReleaseType, formatBranchChoices, getJiraDescriptions } from 'src/lib/release-utils'\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 commandEcho.start('merge-dev')\n\n // Only merge dev into regular releases (not hotfixes, which target main)\n const allPRs = await getReleasePRsWithInfo()\n const releasePRsList = allPRs\n .filter((pr) => {\n return detectReleaseType(pr.title) === 'regular'\n })\n .map((pr) => {\n return pr.branch\n })\n\n if (releasePRsList.length === 0) {\n logger.info('\u2139\uFE0F No open release branches found')\n\n commandEcho.print()\n\n return {\n content: [\n {\n type: 'text',\n text: JSON.stringify({ successfulMerges: 0, failedMerges: 0, failedBranches: [], totalBranches: 0 }, null, 2),\n },\n ],\n structuredContent: { successfulMerges: 0, failedMerges: 0, failedBranches: [], totalBranches: 0 },\n }\n }\n\n let selectedReleaseBranches: string[] = []\n\n if (all) {\n selectedReleaseBranches = releasePRsList\n } else {\n commandEcho.setInteractive()\n\n const descriptions = await getJiraDescriptions()\n\n selectedReleaseBranches = await checkbox({\n required: true,\n message: '\uD83C\uDF3F Select release branches',\n choices: formatBranchChoices({ branches: releasePRsList, descriptions }),\n })\n }\n\n // Track --all flag if all branches were selected (either via flag or interactively)\n const allSelected = selectedReleaseBranches.length === releasePRsList.length\n\n if (allSelected) {\n commandEcho.addOption('--all', true)\n } else {\n commandEcho.addOption(\n '--versions',\n selectedReleaseBranches.map((branch) => {\n return branch.replace('release/v', '')\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 (!confirmedCommand) {\n commandEcho.setInteractive()\n }\n\n if (!answer) {\n logger.info('Operation cancelled. Exiting...')\n process.exit(0)\n }\n\n // Track --yes flag if confirmation was interactive (user confirmed)\n if (!confirmedCommand) {\n commandEcho.addOption('--yes', true)\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 for (const branch of failedBranches) {\n logger.info(\n `# Merge dev into ${branch} and resolve conflicts if any \\n\\ngit switch ${branch} && git pull origin ${branch} && git merge origin/dev\\ngit push origin ${branch} && git switch dev\\n`,\n )\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\n commandEcho.print()\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 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(`Successfully merged dev into ${branch}`)\n\n return true\n } catch (error: unknown) {\n logger.error({ error, branch }, `Error merging dev into ${branch}`)\n\n await $`git reset --merge HEAD~1`\n\n return false\n }\n}\n\n// MCP Tool Registration\nexport const ghMergeDevMcpTool = {\n name: 'gh-merge-dev',\n description:\n 'Merge origin/dev into every open regular (non-hotfix) release branch and push the result. Mutates local git state and the remote release branches. When invoked via MCP, pass all=true \u2014 the branch picker is unreachable without a TTY, and the confirmation prompt is auto-skipped for MCP calls, so the caller is responsible for gating. Irreversible once pushed.',\n inputSchema: {\n all: z\n .boolean()\n .optional()\n .describe(\n 'Target every open regular release branch. Must be true for MCP calls (the interactive picker is unavailable without a TTY).',\n ),\n },\n outputSchema: {\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 handler: ghMergeDev,\n}\n", "import process from 'node:process'\nimport { $ } from 'zx'\n\nimport { logger } from 'src/lib/logger'\n\n/**\n * Validate GitHub CLI installation and authentication status and throw an error if not valid\n */\nexport const validateGitHubCliAndAuth = async () => {\n try {\n await $`gh --version`\n } catch (error: unknown) {\n logger.error({ error }, 'Error: GitHub CLI (gh) is not installed.')\n logger.error('Please install it from: https://cli.github.com/')\n process.exit(1)\n }\n\n try {\n await $`gh auth status`\n } catch (error: unknown) {\n logger.error({ error }, 'Error: GitHub CLI (gh) is not authenticated.')\n logger.error('Please authenticate it from: https://cli.github.com/manual/gh_auth_login or type \"gh auth login\"')\n process.exit(1)\n }\n}\n", "import process from 'node:process'\nimport { $ } from 'zx'\n\nimport { logger } from 'src/lib/logger'\nimport { getBaseBranch } from 'src/lib/release-utils'\nimport type { ReleaseType } from 'src/lib/release-utils'\nimport { sortVersions } from 'src/lib/version-utils'\n\ninterface ReleasePR {\n headRefName: string\n number: number\n state: string\n title: string\n baseRefName: string\n}\n\nexport interface ReleasePRInfo {\n branch: string\n title: string\n}\n\n/**\n * Fetch all open release/hotfix PRs from GitHub.\n * Searches both dev (regular) and main (hotfix) base branches.\n * Returns deduplicated ReleasePR objects.\n */\nconst fetchAllReleasePRs = async (): Promise<ReleasePR[]> => {\n const releasePRs =\n await $`gh pr list --search \"Release in:title\" --base dev --json number,title,headRefName,state,baseRefName`\n\n const hotfixPRs =\n await $`gh pr list --search \"Hotfix in:title\" --base main --json number,title,headRefName,state,baseRefName`\n\n const all: ReleasePR[] = [...JSON.parse(releasePRs.stdout), ...JSON.parse(hotfixPRs.stdout)]\n\n // Deduplicate by headRefName\n const seen = new Set<string>()\n\n return all.filter((pr) => {\n if (seen.has(pr.headRefName)) return false\n\n seen.add(pr.headRefName)\n\n return true\n })\n}\n\n/**\n * Fetch open release PRs from GitHub with 'Release' or 'Hotfix' in the title and base 'dev'.\n * Returns an array of headRefName strings sorted by semver in ascending order.\n *\n * @returns [release/v1.18.22, release/v1.18.23, release/v1.18.24] (sorted by semver)\n */\nexport const getReleasePRs = async (): Promise<string[]> => {\n try {\n const prs = await fetchAllReleasePRs()\n\n if (prs.length === 0) {\n logger.error('\u274C No release PRs found. Check the project folder for the script. Exiting...')\n\n process.exit(1)\n }\n\n return sortVersions(\n prs.map((pr) => {\n return pr.headRefName\n }),\n )\n } catch (error) {\n logger.error({ error }, '\u274C Error fetching release PRs')\n\n process.exit(1)\n }\n}\n\n/**\n * Fetch open release PRs with title info (for detecting release type).\n * Returns ReleasePRInfo objects sorted by semver.\n */\nexport const getReleasePRsWithInfo = async (): Promise<ReleasePRInfo[]> => {\n try {\n const prs = await fetchAllReleasePRs()\n\n if (prs.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 const sortedBranches = sortVersions(\n prs.map((pr) => {\n return pr.headRefName\n }),\n )\n const prByBranch = new Map(\n prs.map((pr) => {\n return [pr.headRefName, pr]\n }),\n )\n\n return sortedBranches.map((branch) => {\n return {\n branch,\n title: prByBranch.get(branch)!.title,\n }\n })\n } catch (error) {\n logger.error({ error }, '\u274C Error fetching release PRs')\n process.exit(1)\n }\n}\n\ninterface CreateReleaseBranchArgs {\n version: string\n jiraVersionUrl: string\n type: ReleaseType\n description?: string\n}\n\n// Function to create a release branch\nexport const createReleaseBranch = async (\n args: CreateReleaseBranchArgs,\n): Promise<{ branchName: string; prUrl: string }> => {\n const { version, jiraVersionUrl, type, description } = args\n const titlePrefix = type === 'hotfix' ? 'Hotfix' : 'Release'\n const baseBranch = getBaseBranch(type)\n\n const branchName = `release/v${version}`\n\n const body = description && description.trim() !== '' ? `${jiraVersionUrl}\\n\\n${description}` : `${jiraVersionUrl} \\n`\n\n try {\n $.quiet = true\n\n await $`git switch ${baseBranch}`\n await $`git pull origin ${baseBranch}`\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 and capture URL\n const prResult =\n await $`gh pr create --title \"${titlePrefix} v${version}\" --body ${body} --base ${baseBranch} --head ${branchName}`\n\n const prLink = prResult.stdout.trim()\n\n await $`git switch ${baseBranch}`\n\n $.quiet = false\n\n return {\n branchName,\n prUrl: prLink,\n }\n } catch (error: unknown) {\n logger.error({ error, branchName }, `Error creating release branch ${branchName}`)\n\n throw error\n }\n}\n", "import { $ } from 'zx'\n\nimport { createReleaseBranch } from 'src/integrations/gh'\nimport { createJiraVersion, getProjectVersions, loadJiraConfigOptional } from 'src/integrations/jira'\nimport type { JiraConfig } from 'src/integrations/jira'\n\nexport type ReleaseType = 'regular' | 'hotfix'\n\n/**\n * Get the base branch for a release type.\n * Regular releases branch from/to dev, hotfixes branch from/to main.\n */\nexport const getBaseBranch = (type: ReleaseType): string => {\n return type === 'hotfix' ? 'main' : 'dev'\n}\n\nexport interface ReleaseCreationResult {\n version: string\n type: ReleaseType\n branchName: string\n prUrl: string\n jiraVersionUrl: string\n}\n\n/**\n * Prepare git repository for release creation\n * Fetches latest changes, switches to base branch, and pulls latest\n */\nexport const prepareGitForRelease = async (type: ReleaseType = 'regular'): Promise<void> => {\n const baseBranch = getBaseBranch(type)\n\n $.quiet = true\n\n await $`git fetch origin`\n await $`git switch ${baseBranch}`\n await $`git pull origin ${baseBranch}`\n\n $.quiet = false\n}\n\ninterface CreateSingleReleaseArgs {\n version: string\n jiraConfig: JiraConfig\n description?: string\n type?: ReleaseType\n}\n\n/**\n * Create a single release by creating both Jira version and GitHub release branch\n */\nexport const createSingleRelease = async (args: CreateSingleReleaseArgs): Promise<ReleaseCreationResult> => {\n const { version, jiraConfig, description, type = 'regular' } = args\n // 1. Create Jira version (mandatory)\n const versionName = `v${version}`\n\n const result = await createJiraVersion(\n {\n name: versionName,\n projectId: jiraConfig.projectId,\n description: description || '',\n released: false,\n archived: false,\n },\n jiraConfig,\n )\n\n // Construct user-friendly Jira URL using project key from API response\n const jiraVersionUrl = `${jiraConfig.baseUrl}/projects/${result.version!.projectId}/versions/${result.version!.id}/tab/release-report-all-issues`\n\n // 2. Create GitHub release branch\n const releaseInfo = await createReleaseBranch({ version, jiraVersionUrl, type, description })\n\n return {\n version,\n type,\n branchName: releaseInfo.branchName,\n prUrl: releaseInfo.prUrl,\n jiraVersionUrl,\n }\n}\n\n/**\n * Fetch Jira version descriptions mapped by version name (e.g., \"v1.2.5\" \u2192 \"Some description\")\n * Gracefully returns empty map if Jira is unavailable\n */\nexport const getJiraDescriptions = async (): Promise<Map<string, string>> => {\n const descriptions = new Map<string, string>()\n\n const jiraConfig = await loadJiraConfigOptional()\n\n if (!jiraConfig) return descriptions\n\n try {\n const versions = await getProjectVersions(jiraConfig)\n\n for (const version of versions) {\n if (version.description) {\n descriptions.set(version.name, version.description)\n }\n }\n } catch {\n // Jira fetch failed, continue without descriptions\n }\n\n return descriptions\n}\n\n/**\n * Format a version string with its release type tag, e.g. \"1.2.5 [regular]\"\n * When maxVersionLength is provided, pads the version for alignment.\n */\nexport const formatVersionLabel = (version: string, type: ReleaseType, maxVersionLength?: number): string => {\n const padding = maxVersionLength ? ' '.repeat(maxVersionLength - version.length + 3) : ' '\n const tag = `[${type}]`.padEnd(11)\n\n return `${version}${padding}${tag}`\n}\n\n/**\n * Detect release type from PR title.\n * PRs titled \"Hotfix v...\" are hotfix, everything else is regular.\n */\nexport const detectReleaseType = (title: string): ReleaseType => {\n return title.toLowerCase().startsWith('hotfix') ? 'hotfix' : 'regular'\n}\n\ninterface FormatBranchChoicesArgs {\n branches: string[]\n descriptions: Map<string, string>\n types?: Map<string, ReleaseType>\n}\n\n/**\n * Format release branch names as checkbox choices with aligned type tags and Jira descriptions\n */\nexport const formatBranchChoices = (args: FormatBranchChoicesArgs): { name: string; value: string }[] => {\n const { branches, descriptions, types } = args\n\n const versionNames = branches.map((b) => {\n return b.replace('release/v', '')\n })\n\n const maxLen = Math.max(\n ...versionNames.map((v) => {\n return v.length\n }),\n )\n\n return branches.map((branch, i) => {\n const version = versionNames[i] as string\n const type = types ? types.get(branch) || 'regular' : undefined\n const desc = descriptions.get(`v${version}`)\n const padding = ' '.repeat(maxLen - version.length + 3)\n\n let name = type ? formatVersionLabel(version, type, maxLen) : version\n\n if (desc) {\n name = type ? `${name} ${desc}` : `${version}${padding}${desc}`\n }\n\n return { name, value: branch }\n })\n}\n", "import process from 'node:process'\n\nimport { logger } from 'src/lib/logger'\n\nimport type {\n CreateJiraVersionParams,\n CreateJiraVersionResult,\n DeliverJiraReleaseParams,\n DeliverJiraReleaseResult,\n JiraConfig,\n JiraVersion,\n UpdateJiraVersionParams,\n UpdateJiraVersionResult,\n} from './types.js'\n\n/**\n * Creates a new version in Jira using the REST API\n * @param params - Version creation parameters\n * @param config - Jira configuration (baseUrl, token, projectId)\n * @returns Result containing created version or error\n */\nexport const createJiraVersion = async (\n params: CreateJiraVersionParams,\n config: JiraConfig,\n): Promise<CreateJiraVersionResult> => {\n try {\n const { baseUrl, token, email, projectId } = config\n\n // Use current date if not provided\n // const releaseDate =\n // params.releaseDate || new Date().toISOString().split('T')[0] // 2025-12-06\n\n // Prepare request body\n const requestBody = {\n name: params.name,\n projectId: params.projectId || projectId,\n description: params.description || '',\n // releaseDate,\n released: params.released || false,\n archived: params.archived || false,\n }\n\n // logger.info(\n // { version: params.name, projectId: requestBody.projectId },\n // 'Creating Jira version',\n // )\n\n // Make API request\n const url = `${baseUrl}/rest/api/3/version`\n\n // Create Basic auth credentials\n const credentials = btoa(`${email}:${token}`)\n\n const response = await fetch(url, {\n method: 'POST',\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n Authorization: `Basic ${credentials}`,\n },\n body: JSON.stringify(requestBody),\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n\n logger.error(\n {\n status: response.status,\n statusText: response.statusText,\n error: errorText,\n },\n 'Failed to create Jira version',\n )\n\n throw new Error(`HTTP ${response.status}: ${response.statusText}`)\n }\n\n const version = (await response.json()) as JiraVersion\n\n // logger.info(\n // { versionId: version.id, versionName: version.name },\n // 'Successfully created Jira version',\n // )\n\n return {\n success: true,\n version,\n }\n } catch (error) {\n logger.error({ error }, 'Error creating Jira version')\n\n throw error\n }\n}\n\n/**\n * Gets all versions for a project from Jira\n * @param config - Jira configuration\n * @returns Array of JiraVersion objects\n */\nexport const getProjectVersions = async (config: JiraConfig): Promise<JiraVersion[]> => {\n try {\n const { baseUrl, token, email, projectId } = config\n\n const url = `${baseUrl}/rest/api/3/project/${projectId}/versions`\n const credentials = btoa(`${email}:${token}`)\n\n const response = await fetch(url, {\n method: 'GET',\n headers: {\n Accept: 'application/json',\n Authorization: `Basic ${credentials}`,\n },\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n\n logger.error(\n {\n status: response.status,\n statusText: response.statusText,\n error: errorText,\n },\n 'Failed to get Jira project versions',\n )\n\n throw new Error(`HTTP ${response.status}: ${response.statusText}`)\n }\n\n const versions = (await response.json()) as JiraVersion[]\n\n return versions\n } catch (error) {\n logger.error({ error }, 'Error getting Jira project versions')\n\n throw error\n }\n}\n\n/**\n * Finds a Jira version by name in the project\n * @param versionName - Name of the version to find (e.g., \"v1.33.10\")\n * @param config - Jira configuration\n * @returns JiraVersion if found, null otherwise\n */\nconst findVersionByName = async (versionName: string, config: JiraConfig): Promise<JiraVersion | null> => {\n try {\n const versions = await getProjectVersions(config)\n const version = versions.find((v) => {\n return v.name === versionName\n })\n\n return version || null\n } catch (error) {\n logger.error({ error, versionName }, 'Error finding Jira version by name')\n\n throw error\n }\n}\n\n/**\n * Updates an existing Jira version\n * @param params - Update parameters\n * @param config - Jira configuration\n * @returns Result containing updated version or error\n */\nconst updateJiraVersion = async (\n params: UpdateJiraVersionParams,\n config: JiraConfig,\n): Promise<UpdateJiraVersionResult> => {\n try {\n const { baseUrl, token, email } = config\n\n // Prepare request body - only include fields that are provided\n const requestBody: Record<string, any> = {\n released: params.released ?? true,\n archived: params.archived ?? false,\n }\n\n // Add releaseDate if provided, otherwise use current date when releasing\n if (params.releaseDate) {\n requestBody.releaseDate = params.releaseDate\n } else if (params.released !== false) {\n requestBody.releaseDate = new Date().toISOString().split('T')[0] // YYYY-MM-DD\n }\n\n if (params.description !== undefined) {\n requestBody.description = params.description\n }\n\n const url = `${baseUrl}/rest/api/3/version/${params.versionId}`\n const credentials = btoa(`${email}:${token}`)\n\n const response = await fetch(url, {\n method: 'PUT',\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n Authorization: `Basic ${credentials}`,\n },\n body: JSON.stringify(requestBody),\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n\n logger.error(\n {\n status: response.status,\n statusText: response.statusText,\n error: errorText,\n },\n 'Failed to update Jira version',\n )\n\n throw new Error(`HTTP ${response.status}: ${response.statusText}`)\n }\n\n const version = (await response.json()) as JiraVersion\n\n return {\n success: true,\n version,\n }\n } catch (error) {\n logger.error({ error }, 'Error updating Jira version')\n\n throw error\n }\n}\n\n/**\n * Delivers a Jira release by marking it as released with the current date\n * @param params - Parameters containing the version name\n * @param config - Jira configuration\n * @returns Result containing updated version\n * @throws Error if version not found or update fails\n */\nexport const deliverJiraRelease = async (\n params: DeliverJiraReleaseParams,\n config: JiraConfig,\n): Promise<DeliverJiraReleaseResult> => {\n try {\n const { versionName } = params\n\n // Find the version by name\n const version = await findVersionByName(versionName, config)\n\n if (!version) {\n logger.error({ versionName }, 'Jira version not found')\n throw new Error(`Version \"${versionName}\" not found in Jira project`)\n }\n\n // Update the version to mark it as released\n const result = await updateJiraVersion(\n {\n versionId: version.id,\n released: true,\n releaseDate: new Date().toISOString().split('T')[0], // Current date in YYYY-MM-DD format\n },\n config,\n )\n\n return result\n } catch (error) {\n logger.error({ error }, 'Error delivering Jira release')\n throw error\n }\n}\n\n/**\n * Loads Jira configuration from environment variables\n * @throws Error with detailed message if configuration is missing or invalid\n * @returns Promise<JiraConfig>\n */\nexport const loadJiraConfig = async (): Promise<JiraConfig> => {\n const baseUrl = process.env.JIRA_BASE_URL\n const token = process.env.JIRA_TOKEN || process.env.JIRA_API_TOKEN\n const projectIdStr = process.env.JIRA_PROJECT_ID\n const email = process.env.JIRA_EMAIL\n\n const missingVars: string[] = []\n\n if (!baseUrl) missingVars.push('JIRA_BASE_URL (e.g., https://your-domain.atlassian.net)')\n if (!token) missingVars.push('JIRA_TOKEN or JIRA_API_TOKEN (your Jira API token)')\n if (!projectIdStr) missingVars.push('JIRA_PROJECT_ID (numeric project ID)')\n if (!email) missingVars.push('JIRA_EMAIL (your Jira email address)')\n\n if (missingVars.length > 0) {\n const errorMessage = [\n 'Jira configuration is required but incomplete.',\n 'Please configure the following environment variables:',\n ...missingVars.map((v) => {\n return ` - ${v}`\n }),\n '',\n 'You can set these in your .env file or as environment variables.',\n ].join('\\n')\n\n throw new Error(errorMessage)\n }\n\n const projectId = Number.parseInt(projectIdStr!, 10)\n\n if (Number.isNaN(projectId)) {\n throw new TypeError(`Invalid JIRA_PROJECT_ID: \"${projectIdStr}\" must be a numeric value (e.g., 10001)`)\n }\n\n return {\n baseUrl: baseUrl!.replace(/\\/$/, ''), // Remove trailing slash\n token: token!,\n projectId,\n email: email!,\n }\n}\n\n/**\n * Attempts to load Jira configuration from environment variables\n * Returns null if configuration is missing or invalid (for optional Jira integration)\n * @returns Promise<JiraConfig | null>\n */\nexport const loadJiraConfigOptional = async (): Promise<JiraConfig | null> => {\n try {\n const config = await loadJiraConfig()\n\n return config\n } catch (error) {\n logger.warn({ error }, 'Jira configuration not available, skipping Jira integration')\n\n return null\n }\n}\n", "import { $ } from 'zx'\n\nimport { getProjectVersions, loadJiraConfigOptional } from 'src/integrations/jira'\nimport { logger } from 'src/lib/logger'\n\nimport { collectKnownVersions } from './next-version'\nimport type { SemVer } from './next-version'\n\nconst parseRemoteRefs = async (): Promise<string[]> => {\n const previousQuiet = $.quiet\n\n try {\n $.quiet = true\n const result = await $`git ls-remote --heads origin 'release/v*'`\n const lines = result.stdout.split('\\n')\n\n return lines\n .map((line) => {\n const tab = line.indexOf('\\t')\n\n if (tab === -1) return ''\n\n return line.slice(tab + 1).replace(/^refs\\/heads\\//, '')\n })\n .filter(Boolean)\n } finally {\n $.quiet = previousQuiet\n }\n}\n\nconst fetchJiraVersionNames = async (): Promise<string[]> => {\n const config = await loadJiraConfigOptional()\n\n if (!config) return []\n\n const versions = await getProjectVersions(config)\n\n return versions.map((v) => {\n return v.name\n })\n}\n\n/**\n * Load known release versions from the union of:\n * - remote release branches (`release/v*` on origin)\n * - Jira fix versions (when configured)\n *\n * Each source is queried in parallel; if either fails, we log a warning\n * and continue with the other so a transient outage doesn't block release\n * creation.\n */\nexport const loadExistingVersions = async (): Promise<SemVer[]> => {\n const [branchesResult, jiraResult] = await Promise.allSettled([parseRemoteRefs(), fetchJiraVersionNames()])\n\n if (branchesResult.status === 'rejected') {\n logger.warn({ error: branchesResult.reason }, 'Failed to list remote release branches; continuing without them')\n }\n\n if (jiraResult.status === 'rejected') {\n logger.warn({ error: jiraResult.reason }, 'Failed to fetch Jira versions; continuing without them')\n }\n\n return collectKnownVersions({\n remoteBranches: branchesResult.status === 'fulfilled' ? branchesResult.value : [],\n jiraVersions: jiraResult.status === 'fulfilled' ? jiraResult.value : [],\n })\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 * Note: Returns a new sorted array without mutating the original\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\n return (patchA ?? 0) - (patchB ?? 0)\n })\n}\n", "import type { ReleaseType } from 'src/lib/release-utils'\n\nimport { parseVersion, sortVersions } from './version-utils'\n\nexport const NEXT_TOKEN = 'next'\n\nexport type SemVer = readonly [number, number, number]\n\nexport interface ExistingVersionsSources {\n remoteBranches?: string[]\n jiraVersions?: string[]\n}\n\nconst VERSION_RE = /^v?(\\d+)\\.(\\d+)\\.(\\d+)$/\n\nconst stripBranchPrefix = (raw: string): string => {\n return raw.replace(/^.*release\\//, '')\n}\n\nconst tryParse = (raw: string): SemVer | null => {\n const cleaned = stripBranchPrefix(raw.trim())\n const match = VERSION_RE.exec(cleaned)\n\n if (!match) return null\n\n return [Number(match[1]), Number(match[2]), Number(match[3])]\n}\n\nconst semverKey = (v: SemVer): string => {\n return `${v[0]}.${v[1]}.${v[2]}`\n}\n\nexport const collectKnownVersions = (sources: ExistingVersionsSources): SemVer[] => {\n const all = [...(sources.remoteBranches ?? []), ...(sources.jiraVersions ?? [])]\n const parsed: SemVer[] = []\n const seen = new Set<string>()\n\n for (const raw of all) {\n const v = tryParse(raw)\n\n if (!v) continue\n\n const key = semverKey(v)\n\n if (seen.has(key)) continue\n\n seen.add(key)\n parsed.push(v)\n }\n\n return sortVersions(\n parsed.map((v) => {\n return semverKey(v)\n }),\n ).map((s) => {\n return parseVersion(`v${s}`)\n })\n}\n\nexport class NoPriorVersionsError extends Error {\n constructor() {\n super('No prior release versions found from git or Jira. Specify the version explicitly.')\n this.name = 'NoPriorVersionsError'\n }\n}\n\n/**\n * Compute the next semantic version based on release type.\n * - regular: bump minor, reset patch to 0\n * - hotfix: bump patch on the highest minor (any patch)\n *\n * Returns the version without the leading \"v\" (e.g. \"1.64.0\").\n */\nexport const computeNextVersion = (known: SemVer[], type: ReleaseType): string => {\n if (known.length === 0) throw new NoPriorVersionsError()\n\n const max = known[known.length - 1] as SemVer\n\n if (type === 'hotfix') {\n const [major, minor] = max\n\n const highestPatchOnMinor = known.reduce((acc, v) => {\n if (v[0] === major && v[1] === minor) return Math.max(acc, v[2])\n\n return acc\n }, 0)\n\n return `${major}.${minor}.${highestPatchOnMinor + 1}`\n }\n\n const [major, minor] = max\n\n return `${major}.${minor + 1}.0`\n}\n\nconst isNextToken = (token: string): boolean => {\n return token.trim().toLowerCase() === NEXT_TOKEN\n}\n\nexport interface ReleaseEntry {\n version: string\n type: ReleaseType\n description?: string\n}\n\nconst isReleaseType = (value: string): value is ReleaseType => {\n return value === 'regular' || value === 'hotfix'\n}\n\n/**\n * Parse a CLI release spec of the form `version[:type[:description]]`.\n * Type defaults to \"regular\". Description is everything after the second\n * colon, so colons inside descriptions are preserved.\n */\nexport const parseReleaseSpec = (raw: string): ReleaseEntry => {\n const spec = raw.trim()\n\n if (spec === '') throw new Error('Release spec is empty')\n\n const firstColon = spec.indexOf(':')\n\n if (firstColon === -1) {\n return { version: spec, type: 'regular' }\n }\n\n const version = spec.slice(0, firstColon).trim()\n const rest = spec.slice(firstColon + 1)\n const secondColon = rest.indexOf(':')\n\n const typeRaw = secondColon === -1 ? rest.trim() : rest.slice(0, secondColon).trim()\n const description = secondColon === -1 ? '' : rest.slice(secondColon + 1).trim()\n const typeLower = typeRaw.toLowerCase()\n\n if (!isReleaseType(typeLower)) {\n throw new Error(`Invalid release type \"${typeRaw}\". Expected \"regular\" or \"hotfix\".`)\n }\n\n const entry: ReleaseEntry = { version, type: typeLower }\n\n if (description !== '') entry.description = description\n\n return entry\n}\n\n/**\n * Resolve a list of release entries (each with its own type and optional\n * \"next\" version token) into entries with concrete versions. Each \"next\"\n * advances based on the running max so successive \"next\" tokens produce\n * sequential versions, even across mixed types.\n */\nexport const resolveReleaseEntries = (entries: ReleaseEntry[], known: SemVer[]): ReleaseEntry[] => {\n const running: SemVer[] = [...known]\n\n return entries.map((entry) => {\n const trimmed = entry.version.trim()\n\n if (trimmed === '') {\n throw new Error('Release entry has an empty version')\n }\n\n if (isNextToken(trimmed)) {\n const next = computeNextVersion(running, entry.type)\n\n running.push(parseVersion(`v${next}`))\n\n return { ...entry, version: next }\n }\n\n const parsed = tryParse(trimmed)\n\n if (!parsed) {\n throw new Error(`Invalid version \"${trimmed}\". Expected semver like \"1.2.5\" or the token \"next\".`)\n }\n\n const explicit = `${parsed[0]}.${parsed[1]}.${parsed[2]}`\n\n running.push(parsed)\n\n return { ...entry, version: explicit }\n })\n}\n\nexport const hasNextToken = (entries: ReleaseEntry[]): boolean => {\n return entries.some((e) => {\n return isNextToken(e.version)\n })\n}\n", "import confirm from '@inquirer/confirm'\nimport select from '@inquirer/select'\nimport process from 'node:process'\nimport { z } from 'zod/v4'\nimport { $ } from 'zx'\n\nimport { getReleasePRsWithInfo } from 'src/integrations/gh'\nimport { deliverJiraRelease, loadJiraConfigOptional } from 'src/integrations/jira'\nimport { commandEcho } from 'src/lib/command-echo'\nimport { logger } from 'src/lib/logger'\nimport { detectReleaseType, formatBranchChoices, getJiraDescriptions } from 'src/lib/release-utils'\nimport type { ReleaseType } from 'src/lib/release-utils'\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 commandEcho.start('release-deliver')\n\n const releasePRsInfo = await getReleasePRsWithInfo()\n\n const branches = releasePRsInfo.map((pr) => {\n return pr.branch\n })\n\n const releaseTypes = new Map<string, ReleaseType>(\n releasePRsInfo.map((pr) => {\n return [pr.branch, detectReleaseType(pr.title)]\n }),\n )\n\n let selectedReleaseBranch = '' // \"release/v1.8.0\"\n\n if (version) {\n selectedReleaseBranch = `release/v${version}`\n } else {\n commandEcho.setInteractive()\n\n const descriptions = await getJiraDescriptions()\n\n selectedReleaseBranch = await select({\n message: '\uD83C\uDF3F Select release branch',\n choices: formatBranchChoices({ branches, descriptions, types: releaseTypes }),\n })\n }\n\n const selectedVersion = selectedReleaseBranch.replace('release/v', '')\n\n commandEcho.addOption('--version', selectedVersion)\n\n // Check if release branch exists in the list\n const prInfo = releasePRsInfo.find((pr) => {\n return pr.branch === selectedReleaseBranch\n })\n\n if (!prInfo) {\n logger.error(`\u274C Release branch ${selectedReleaseBranch} not found in open PRs. Exiting...`)\n process.exit(1)\n }\n\n const releaseType: ReleaseType = detectReleaseType(prInfo.title)\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 (!confirmedCommand) {\n commandEcho.setInteractive()\n }\n\n if (!answer) {\n logger.info('Operation cancelled. Exiting...')\n process.exit(0)\n }\n\n // Track --yes flag if confirmation was interactive (user confirmed)\n commandEcho.addOption('--yes', true)\n\n try {\n $.quiet = true\n\n if (releaseType === 'hotfix') {\n // Hotfix: merge directly into main, deploy, sync back to dev\n await $`gh pr merge ${selectedReleaseBranch} --squash --admin --delete-branch`\n\n $.quiet = false\n\n await $`gh workflow run deploy-all.yml --ref main -f environment=prod`\n\n $.quiet = true\n\n // Sync main into dev\n await $`git switch main && git pull && git switch dev && git pull && git merge main --no-edit && git push`\n } else {\n // Regular: merge into dev, create RC PR to main, merge to main, deploy, sync\n await $`gh pr merge ${selectedReleaseBranch} --squash --admin --delete-branch`\n await $`gh pr create --base main --head dev --title \"Release v${selectedVersion} (RC)\" --body \"\"`\n await $`gh pr merge dev --squash --admin`\n\n $.quiet = false\n\n await $`gh workflow run deploy-all.yml --ref main -f environment=prod`\n\n $.quiet = true\n\n // Sync main into dev\n await $`git switch main && git pull && git switch dev && git pull && git merge main --no-edit && git push`\n }\n\n $.quiet = false\n\n // Deliver Jira release if Jira is configured\n const jiraConfig = await loadJiraConfigOptional()\n\n if (jiraConfig) {\n try {\n const versionName = selectedReleaseBranch.replace('release/', '')\n\n await deliverJiraRelease({ versionName }, jiraConfig)\n } catch (error) {\n logger.error({ error }, 'Failed to deliver Jira release (non-blocking)')\n }\n } else {\n logger.info('\uD83D\uDD14 Jira is not configured, skipping Jira release delivery')\n }\n\n logger.info(`Successfully delivered ${selectedReleaseBranch} to production!`)\n\n commandEcho.print()\n\n const structuredContent = {\n releaseBranch: selectedReleaseBranch,\n version: selectedReleaseBranch.replace('release/v', ''),\n type: releaseType,\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\nexport const ghReleaseDeliverMcpTool = {\n name: 'gh-release-deliver',\n description:\n 'Deliver a release to production. For hotfixes: squash-merges the release branch to main and dispatches the deploy-all workflow. For regular releases: squash-merges to dev, opens an RC PR, merges dev into main, dispatches the deploy-all workflow, then syncs main back to dev. Also releases the matching Jira fix version if Jira is configured. Dispatches the deploy workflow fire-and-forget \u2014 the tool returns once the workflow is accepted by GitHub, not when the deployment finishes. Irreversible production operation: the confirmation prompt is auto-skipped for MCP calls, so the caller is responsible for gating. \"version\" is required when invoked via MCP (the picker is unreachable without a TTY).',\n inputSchema: {\n version: z.string().describe('Release version to deliver to production (e.g., \"1.2.5\"). Required for MCP calls.'),\n },\n outputSchema: {\n releaseBranch: z.string().describe('The release branch that was delivered'),\n version: z.string().describe('The version that was delivered'),\n type: z.enum(['regular', 'hotfix']).describe('Release type'),\n success: z.boolean().describe('Whether the delivery was successful'),\n },\n handler: ghReleaseDeliver,\n}\n", "import select from '@inquirer/select'\nimport process from 'node:process'\nimport { z } from 'zod/v4'\nimport { $ } from 'zx'\n\nimport { getReleasePRsWithInfo } from 'src/integrations/gh'\nimport { commandEcho } from 'src/lib/command-echo'\nimport { getInfraKitConfig } from 'src/lib/infra-kit-config'\nimport { logger } from 'src/lib/logger'\nimport { detectReleaseType, formatBranchChoices, getJiraDescriptions } from 'src/lib/release-utils'\nimport type { ReleaseType } from 'src/lib/release-utils'\nimport type { ToolsExecutionResult } from 'src/types'\n\ninterface GhReleaseDeployAllArgs {\n version: string\n env: string\n skipTerraform?: boolean\n}\n\n/**\n * Deploy a release branch to an environment\n */\nexport const ghReleaseDeployAll = async (args: GhReleaseDeployAllArgs): Promise<ToolsExecutionResult> => {\n const { version, env, skipTerraform } = args\n\n commandEcho.start('release-deploy-all')\n\n let selectedReleaseBranch = '' // \"release/v1.8.0\"\n\n if (version) {\n selectedReleaseBranch = version === 'dev' ? 'dev' : `release/v${version}`\n } else {\n commandEcho.setInteractive()\n\n const releasePRsInfo = await getReleasePRsWithInfo()\n\n const branches = releasePRsInfo.map((pr) => {\n return pr.branch\n })\n\n const releaseTypes = new Map<string, ReleaseType>(\n releasePRsInfo.map((pr) => {\n return [pr.branch, detectReleaseType(pr.title)]\n }),\n )\n\n const descriptions = await getJiraDescriptions()\n\n selectedReleaseBranch = await select({\n message: '\uD83C\uDF3F Select release branch',\n choices: [{ name: 'dev', value: 'dev' }, ...formatBranchChoices({ branches, descriptions, types: releaseTypes })],\n })\n }\n\n const selectedVersion = selectedReleaseBranch === 'dev' ? 'dev' : selectedReleaseBranch.replace('release/v', '')\n\n commandEcho.addOption('--version', selectedVersion)\n\n const { environments } = await getInfraKitConfig()\n\n let selectedEnv = ''\n\n if (env) {\n selectedEnv = env\n } else {\n commandEcho.setInteractive()\n\n selectedEnv = await select({\n message: '\uD83E\uDDEA Select environment',\n choices: environments.map((env) => {\n return {\n name: env,\n value: env,\n }\n }),\n })\n }\n\n commandEcho.addOption('--env', selectedEnv)\n\n if (!environments.includes(selectedEnv)) {\n logger.error(`\u274C Invalid environment: ${selectedEnv}. Exiting...`)\n process.exit(1)\n }\n\n const shouldSkipTerraform = skipTerraform ?? false\n\n if (shouldSkipTerraform) {\n commandEcho.addOption('--skip-terraform', true)\n }\n\n try {\n $.quiet = true\n\n const skipTerraformFlag = shouldSkipTerraform ? ['-f', 'skip_terraform_deploy=true'] : []\n\n await $`gh workflow run deploy-all.yml --ref ${selectedReleaseBranch} -f environment=${selectedEnv} ${skipTerraformFlag}`\n\n $.quiet = false\n\n logger.info(\n `Successfully launched deploy-all workflow_dispatch for release branch: ${selectedReleaseBranch} and environment: ${selectedEnv}`,\n )\n\n commandEcho.print()\n\n const structuredContent = {\n releaseBranch: selectedReleaseBranch,\n version: selectedReleaseBranch.replace('release/v', ''),\n environment: selectedEnv,\n skipTerraformDeploy: shouldSkipTerraform,\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\nexport const ghReleaseDeployAllMcpTool = {\n name: 'gh-release-deploy-all',\n description:\n 'Dispatch the deploy-all.yml GitHub Actions workflow to deploy every service from a release branch to the given environment. Fire-and-forget \u2014 returns once GitHub accepts the workflow_dispatch, NOT when the deployment finishes; watch the workflow run for completion status. Use gh-release-deploy-selected for a subset of services. Pass version=\"dev\" to deploy from the dev branch instead of a release branch. Both \"version\" and \"env\" are required when invoked via MCP (interactive pickers are unavailable without a TTY).',\n inputSchema: {\n version: z\n .string()\n .describe(\n 'Release version to deploy from (e.g. \"1.2.5\") \u2014 resolves to the release/vX.Y.Z branch. Pass \"dev\" to deploy from the dev branch instead. Required for MCP calls.',\n ),\n env: z\n .string()\n .describe(\n 'Target environment name \u2014 must match an env configured for the project (e.g. \"dev\", \"renana\", \"oriana\"). Required for MCP calls.',\n ),\n skipTerraform: z.boolean().optional().describe('Skip the terraform deployment stage.'),\n },\n outputSchema: {\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 skipTerraformDeploy: z.boolean().describe('Whether terraform deployment was skipped'),\n success: z.boolean().describe('Whether the deployment was successful'),\n },\n handler: ghReleaseDeployAll,\n}\n", "import checkbox from '@inquirer/checkbox'\nimport select from '@inquirer/select'\nimport fs from 'node:fs/promises'\nimport { resolve } from 'node:path'\nimport process from 'node:process'\nimport yaml from 'yaml'\nimport { z } from 'zod/v4'\nimport { $ } from 'zx'\n\nimport { getReleasePRsWithInfo } from 'src/integrations/gh'\nimport { commandEcho } from 'src/lib/command-echo'\nimport { getProjectRoot } from 'src/lib/git-utils'\nimport { getInfraKitConfig } from 'src/lib/infra-kit-config'\nimport { logger } from 'src/lib/logger'\nimport { detectReleaseType, formatBranchChoices, getJiraDescriptions } from 'src/lib/release-utils'\nimport type { ReleaseType } from 'src/lib/release-utils'\nimport type { ToolsExecutionResult } from 'src/types'\n\ninterface GhReleaseDeploySelectedArgs {\n version: string\n env: string\n services: string[]\n skipTerraform?: boolean\n}\n\n/**\n * Deploy selected services from a release branch to an environment\n */\n// eslint-disable-next-line sonarjs/cognitive-complexity\nexport const ghReleaseDeploySelected = async (args: GhReleaseDeploySelectedArgs): Promise<ToolsExecutionResult> => {\n const { version, env, services, skipTerraform } = args\n\n commandEcho.start('release-deploy-selected')\n\n let selectedReleaseBranch = ''\n\n if (version) {\n selectedReleaseBranch = version === 'dev' ? 'dev' : `release/v${version}`\n } else {\n commandEcho.setInteractive()\n\n const releasePRsInfo = await getReleasePRsWithInfo()\n\n const branches = releasePRsInfo.map((pr) => {\n return pr.branch\n })\n\n const releaseTypes = new Map<string, ReleaseType>(\n releasePRsInfo.map((pr) => {\n return [pr.branch, detectReleaseType(pr.title)]\n }),\n )\n\n const descriptions = await getJiraDescriptions()\n\n selectedReleaseBranch = await select({\n message: '\uD83C\uDF3F Select release branch',\n choices: [{ name: 'dev', value: 'dev' }, ...formatBranchChoices({ branches, descriptions, types: releaseTypes })],\n })\n }\n\n const selectedVersion = selectedReleaseBranch === 'dev' ? 'dev' : selectedReleaseBranch.replace('release/v', '')\n\n commandEcho.addOption('--version', selectedVersion)\n\n const { environments } = await getInfraKitConfig()\n\n let selectedEnv = ''\n\n if (env) {\n selectedEnv = env\n } else {\n commandEcho.setInteractive()\n\n selectedEnv = await select({\n message: '\uD83E\uDDEA Select environment',\n choices: environments.map((env) => {\n return {\n name: env,\n value: env,\n }\n }),\n })\n }\n\n commandEcho.addOption('--env', selectedEnv)\n\n if (!environments.includes(selectedEnv)) {\n logger.error(`\u274C Invalid environment: ${selectedEnv}. Exiting...`)\n process.exit(1)\n }\n\n // Parse available services from workflow file\n const availableServices = await parseServicesFromWorkflow()\n\n if (availableServices.length === 0) {\n logger.error('\u274C No services found in workflow file. Exiting...')\n\n process.exit(1)\n }\n\n let selectedServices: string[] = []\n\n if (services && services.length > 0) {\n selectedServices = services\n } else {\n commandEcho.setInteractive()\n\n selectedServices = await checkbox({\n message: '\uD83D\uDE80 Select services to deploy (space to select, enter to confirm)',\n choices: availableServices.map((svc) => {\n return {\n name: svc,\n value: svc,\n }\n }),\n })\n }\n\n commandEcho.addOption('--services', selectedServices)\n\n if (selectedServices.length === 0) {\n logger.error('\u274C No services selected. Exiting...')\n process.exit(1)\n }\n\n // Validate all selected services\n const invalidServices = selectedServices.filter((svc) => {\n return !availableServices.includes(svc)\n })\n\n if (invalidServices.length > 0) {\n logger.error(\n `\u274C Invalid services: ${invalidServices.join(', ')}. Available services: ${availableServices.join(', ')}`,\n )\n process.exit(1)\n }\n\n const shouldSkipTerraform = skipTerraform ?? false\n\n if (shouldSkipTerraform) {\n commandEcho.addOption('--skip-terraform', true)\n }\n\n try {\n $.quiet = true\n\n // Build the workflow command with boolean flags for each selected service\n const serviceFlags = selectedServices.flatMap((svc) => {\n return ['-f', `${svc}=true`]\n })\n const skipTerraformFlag = shouldSkipTerraform ? ['-f', 'skip_terraform_deploy=true'] : []\n\n await $`gh workflow run deploy-selected-services.yml --ref ${selectedReleaseBranch} -f environment=${selectedEnv} ${serviceFlags} ${skipTerraformFlag}`\n\n $.quiet = false\n\n logger.info(\n `Successfully launched deploy-selected-services workflow_dispatch for release branch: ${selectedReleaseBranch}, environment: ${selectedEnv}, services: ${selectedServices.join(', ')}`,\n )\n\n commandEcho.print()\n\n const structuredContent = {\n releaseBranch: selectedReleaseBranch,\n version: selectedReleaseBranch.replace('release/v', ''),\n environment: selectedEnv,\n services: selectedServices,\n skipTerraformDeploy: shouldSkipTerraform,\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/**\n * Parse available services from the workflow file\n * Services are defined as boolean inputs (excluding skip_terraform_deploy)\n */\nconst parseServicesFromWorkflow = async (): Promise<string[]> => {\n const projectRoot = await getProjectRoot()\n\n const workflowPath = resolve(projectRoot, '.github/workflows/deploy-selected-services.yml')\n\n const content = await fs.readFile(workflowPath, 'utf-8')\n const parsed = yaml.parse(content)\n\n const inputs = parsed.on.workflow_dispatch.inputs\n const services: string[] = []\n\n for (const [key, value] of Object.entries(inputs)) {\n // Filter for boolean type inputs, excluding non-service flags\n if ((value as { type: string }).type === 'boolean' && key !== 'skip_terraform_deploy') {\n services.push(key)\n }\n }\n\n return services\n}\n\n// MCP Tool Registration\nexport const ghReleaseDeploySelectedMcpTool = {\n name: 'gh-release-deploy-selected',\n description:\n 'Dispatch the deploy-selected-services.yml GitHub Actions workflow to deploy a chosen subset of services from a release branch to the given environment. Fire-and-forget \u2014 returns once GitHub accepts the workflow_dispatch, NOT when the deployment finishes; watch the workflow run for completion status. Service names are validated against the boolean inputs declared in the workflow. Use gh-release-deploy-all for every service. \"version\", \"env\", and \"services\" are all required when invoked via MCP (interactive pickers are unavailable without a TTY).',\n inputSchema: {\n version: z\n .string()\n .describe(\n 'Release version to deploy from (e.g. \"1.2.5\") \u2014 resolves to the release/vX.Y.Z branch. Pass \"dev\" to deploy from the dev branch instead. Required for MCP calls.',\n ),\n env: z\n .string()\n .describe(\n 'Target environment name \u2014 must match an env configured for the project (e.g. \"dev\", \"renana\", \"oriana\"). Required for MCP calls.',\n ),\n services: z\n .array(z.string())\n .describe(\n 'Service names to deploy. Each must match a boolean input declared in .github/workflows/deploy-selected-services.yml (e.g. \"client-be\", \"client-fe\"). Required for MCP calls.',\n ),\n skipTerraform: z.boolean().optional().describe('Skip the terraform deployment stage.'),\n },\n outputSchema: {\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 services: z.array(z.string()).describe('The services that were deployed'),\n skipTerraformDeploy: z.boolean().describe('Whether terraform deployment was skipped'),\n success: z.boolean().describe('Whether the deployment was successful'),\n },\n handler: ghReleaseDeploySelected,\n}\n", "import { z } from 'zod/v4'\n\nimport { getReleasePRsWithInfo } from 'src/integrations/gh'\nimport { logger } from 'src/lib/logger'\nimport { detectReleaseType, formatVersionLabel, getJiraDescriptions } from 'src/lib/release-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 getReleasePRsWithInfo()\n\n const releases = releasePRs.map((pr) => {\n return {\n version: pr.branch.replace('release/', ''),\n type: detectReleaseType(pr.title),\n }\n })\n\n const jiraDescriptions = await getJiraDescriptions()\n\n const maxVersionLength = Math.max(\n ...releases.map((r) => {\n return r.version.length\n }),\n )\n\n const formattedLines = releases.map((release) => {\n const label = formatVersionLabel(release.version, release.type, maxVersionLength)\n const description = jiraDescriptions.get(release.version)\n\n if (description) {\n return `${label} ${description}`\n }\n\n return label\n })\n\n logger.info('All release branches: \\n')\n logger.info(`\\n${formattedLines.join('\\n')}\\n`)\n\n const structuredContent = {\n releases: releases.map((release) => {\n return {\n version: release.version,\n type: release.type,\n description: jiraDescriptions.get(release.version) || null,\n }\n }),\n count: releases.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\nexport const ghReleaseListMcpTool = {\n name: 'gh-release-list',\n description:\n 'List every open release PR with its version, type (regular / hotfix), and associated Jira fix-version description. Read-only; sourced from GitHub and Jira.',\n inputSchema: {},\n outputSchema: {\n releases: z\n .array(\n z.object({\n version: z.string().describe('Release version'),\n type: z.enum(['regular', 'hotfix']).describe('Release type'),\n description: z.string().nullable().describe('Jira version description'),\n }),\n )\n .describe('List of all release branches'),\n count: z.number().describe('Number of release branches'),\n },\n handler: ghReleaseList,\n}\n", "import confirm from '@inquirer/confirm'\nimport select from '@inquirer/select'\nimport process from 'node:process'\nimport { z } from 'zod/v4'\nimport { question } from 'zx'\n\nimport { loadJiraConfig } from 'src/integrations/jira'\nimport { commandEcho } from 'src/lib/command-echo'\nimport { logger } from 'src/lib/logger'\nimport { createSingleRelease, prepareGitForRelease } from 'src/lib/release-utils'\nimport type { ReleaseCreationResult, ReleaseType } from 'src/lib/release-utils'\nimport {\n NoPriorVersionsError,\n computeNextVersion,\n hasNextToken,\n loadExistingVersions,\n parseVersion,\n resolveReleaseEntries,\n} from 'src/lib/version-utils'\nimport type { ReleaseEntry, SemVer } from 'src/lib/version-utils'\nimport type { RequiredConfirmedOptionArg, ToolsExecutionResult } from 'src/types'\n\ninterface ReleaseCreateArgs extends RequiredConfirmedOptionArg {\n releases?: ReleaseEntry[]\n}\n\nconst VERSION_PROMPT_HINT = '\"1.2.5\" or \"next\"'\n\nconst trySuggestNext = (known: SemVer[], type: ReleaseType): string | null => {\n try {\n return computeNextVersion(known, type)\n } catch (err) {\n if (err instanceof NoPriorVersionsError) return null\n\n throw err\n }\n}\n\nconst resolveOrExit = (entries: ReleaseEntry[], known: SemVer[]): ReleaseEntry[] => {\n try {\n return resolveReleaseEntries(entries, known)\n } catch (err) {\n if (err instanceof NoPriorVersionsError) {\n logger.error(err.message)\n process.exit(1)\n }\n\n throw err\n }\n}\n\nconst promptForReleasesInteractive = async (ensureKnown: () => Promise<SemVer[]>): Promise<ReleaseEntry[]> => {\n commandEcho.setInteractive()\n\n const baseKnown = await ensureKnown()\n const running: SemVer[] = [...baseKnown]\n const entries: ReleaseEntry[] = []\n let addAnother = true\n\n while (addAnother) {\n const ordinal = entries.length + 1\n const type = await select<ReleaseType>({\n message: `Release #${ordinal} \u2014 select type:`,\n choices: [\n { name: 'regular', value: 'regular' },\n { name: 'hotfix', value: 'hotfix' },\n ],\n default: 'regular',\n })\n\n const suggestion = trySuggestNext(running, type)\n const defaultHint = suggestion ? ` [${suggestion}]` : ''\n const versionAnswer = (await question(` Version (e.g. ${VERSION_PROMPT_HINT})${defaultHint}: `)).trim()\n const versionInput = versionAnswer === '' ? (suggestion ?? '') : versionAnswer\n\n if (versionInput === '') {\n logger.error('No version provided. Exiting...')\n process.exit(1)\n }\n\n const resolved = resolveOrExit([{ version: versionInput, type }], running)[0] as ReleaseEntry\n\n running.push(parseVersion(`v${resolved.version}`))\n\n const description = (await question(' Description (optional, press Enter to skip): ')).trim()\n\n entries.push({ ...resolved, ...(description !== '' ? { description } : {}) })\n\n addAnother = await confirm({ message: 'Add another release?', default: false })\n }\n\n return entries\n}\n\nconst formatReleaseSummary = (entry: ReleaseEntry): string => {\n const parts = [`v${entry.version}`, entry.type]\n\n if (entry.description) parts.push(entry.description)\n\n return parts.join(' \u00B7 ')\n}\n\nconst echoReleases = (entries: ReleaseEntry[]): void => {\n for (const entry of entries) {\n const spec = entry.description\n ? `${entry.version}:${entry.type}:${entry.description}`\n : `${entry.version}:${entry.type}`\n\n commandEcho.addOption('--release', spec)\n }\n}\n\ninterface FailedRelease {\n version: string\n error: string\n}\n\nconst collectEntries = async (\n inputReleases: ReleaseEntry[] | undefined,\n ensureKnown: () => Promise<SemVer[]>,\n): Promise<ReleaseEntry[]> => {\n if (inputReleases && inputReleases.length > 0) {\n const known = hasNextToken(inputReleases) ? await ensureKnown() : []\n const resolved = resolveOrExit(inputReleases, known)\n\n echoReleases(resolved)\n\n return resolved\n }\n\n const interactive = await promptForReleasesInteractive(ensureKnown)\n\n echoReleases(interactive)\n\n return interactive\n}\n\nconst confirmReleases = async (entries: ReleaseEntry[], confirmedCommand: boolean): Promise<void> => {\n const summary = entries.map(formatReleaseSummary).join('\\n - ')\n const answer = confirmedCommand\n ? true\n : await confirm({\n message: `Create the following ${entries.length} release(s)?\\n - ${summary}\\n`,\n })\n\n if (!confirmedCommand) {\n commandEcho.setInteractive()\n }\n\n if (!answer) {\n logger.info('Operation cancelled. Exiting...')\n process.exit(0)\n }\n\n commandEcho.addOption('--yes', true)\n}\n\ninterface ExecuteOneArgs {\n entry: ReleaseEntry\n jiraConfig: Awaited<ReturnType<typeof loadJiraConfig>>\n}\n\nconst executeOne = async (\n args: ExecuteOneArgs,\n): Promise<{ result?: ReleaseCreationResult; failure?: FailedRelease }> => {\n const { entry, jiraConfig } = args\n\n try {\n await prepareGitForRelease(entry.type)\n\n const result = await createSingleRelease({\n version: entry.version,\n jiraConfig,\n description: entry.description,\n type: entry.type,\n })\n\n logger.info(`\u2705 Successfully created release: v${entry.version} (${entry.type})`)\n logger.info(`\uD83D\uDD17 GitHub PR: ${result.prUrl}`)\n logger.info(`\uD83D\uDD17 Jira Version: ${result.jiraVersionUrl}\\n`)\n\n return { result }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error)\n\n logger.error(`\u274C Failed to create release: v${entry.version}`)\n logger.error(` Error: ${errorMessage}\\n`)\n\n return { failure: { version: entry.version, error: errorMessage } }\n }\n}\n\nconst logFinalSummary = (total: number, successCount: number, failureCount: number): void => {\n if (successCount === total) {\n logger.info(`\u2705 All ${total} release branch(es) were created successfully.`)\n } else if (successCount > 0) {\n logger.warn(`\u26A0\uFE0F ${successCount} of ${total} release branches were created successfully.`)\n logger.warn(`\u274C ${failureCount} release(s) failed.`)\n } else {\n logger.error(`\u274C All ${total} release branch(es) failed to create.`)\n }\n}\n\n/**\n * Create one or more release branches. Each release carries its own type\n * (regular/hotfix) and optional Jira description, so a single invocation\n * may mix regular and hotfix releases off their respective base branches.\n */\nexport const releaseCreate = async (args: ReleaseCreateArgs): Promise<ToolsExecutionResult> => {\n const { releases: inputReleases, confirmedCommand } = args\n\n commandEcho.start('release-create')\n\n const jiraConfig = await loadJiraConfig()\n\n let known: SemVer[] | null = null\n const ensureKnown = async (): Promise<SemVer[]> => {\n if (known === null) known = await loadExistingVersions()\n\n return known\n }\n\n const entries = await collectEntries(inputReleases, ensureKnown)\n\n if (entries.length === 0) {\n logger.error('No releases provided. Exiting...')\n process.exit(1)\n }\n\n await confirmReleases(entries, Boolean(confirmedCommand))\n\n const created: ReleaseCreationResult[] = []\n const failed: FailedRelease[] = []\n\n for (const entry of entries) {\n const { result, failure } = await executeOne({ entry, jiraConfig })\n\n if (result) created.push(result)\n if (failure) failed.push(failure)\n }\n\n logFinalSummary(entries.length, created.length, failed.length)\n\n commandEcho.print()\n\n const structuredContent = {\n createdBranches: created.map((r) => {\n return r.branchName\n }),\n successCount: created.length,\n failureCount: failed.length,\n releases: created,\n failedReleases: failed,\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\nexport const releaseCreateMcpTool = {\n name: 'release-create',\n description:\n 'Create one or more releases in a single call. Each entry in \"releases\" carries its own version, type (regular|hotfix, default regular), and optional description, so regular and hotfix releases can be mixed in the same invocation. For each release this tool switches to the appropriate base branch (dev for regular, main for hotfix), cuts the release branch, opens a GitHub release PR, and creates the matching Jira fix version. The literal token \"next\" auto-increments from the union of remote release branches and Jira fix versions (regular bumps minor + resets patch; hotfix bumps patch on the highest minor); multiple \"next\" tokens advance sequentially across mixed types. Confirmation is auto-skipped for MCP calls, so the caller is responsible for gating. Continues on per-release failure and reports successes/failures.',\n inputSchema: {\n releases: z\n .array(\n z.object({\n version: z\n .string()\n .describe('Version to create (e.g., \"1.2.5\") or the literal token \"next\" for auto-increment.'),\n type: z\n .enum(['regular', 'hotfix'])\n .optional()\n .default('regular')\n .describe('Release type: \"regular\" (branches off dev) or \"hotfix\" (branches off main).'),\n description: z.string().optional().describe('Optional description for the Jira version.'),\n }),\n )\n .min(1)\n .describe('One or more releases to create. Each entry has its own version, type, and optional description.'),\n },\n outputSchema: {\n createdBranches: z.array(z.string()).describe('List of created release branch names'),\n successCount: z.number().describe('Number of releases created successfully'),\n failureCount: z.number().describe('Number of releases that failed'),\n releases: z\n .array(\n z.object({\n version: z.string().describe('Version number'),\n type: z.enum(['regular', 'hotfix']).describe('Release type'),\n branchName: z.string().describe('Release branch name'),\n prUrl: z.string().describe('GitHub PR URL'),\n jiraVersionUrl: z.string().describe('Jira version URL'),\n }),\n )\n .describe('Detailed information for each created release with URLs'),\n failedReleases: z\n .array(\n z.object({\n version: z.string().describe('Version number that failed'),\n error: z.string().describe('Error message'),\n }),\n )\n .describe('List of releases that failed with error messages'),\n },\n handler: releaseCreate,\n}\n", "import { z } from 'zod/v4'\n\nimport { logger } from 'src/lib/logger'\nimport type { ToolsExecutionResult } from 'src/types'\n\nimport packageJson from '../../../package.json' with { type: 'json' }\n\n/**\n * Print the infra-kit CLI version\n */\nexport const version = async (): Promise<ToolsExecutionResult> => {\n const cliVersion = packageJson.version\n\n logger.info(cliVersion)\n\n const structuredContent = { version: cliVersion }\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\nexport const versionMcpTool = {\n name: 'version',\n description: 'Print the installed infra-kit CLI version',\n inputSchema: {},\n outputSchema: {\n version: z.string().describe('Installed infra-kit CLI version (from package.json)'),\n },\n handler: version,\n}\n", "{\n \"name\": \"infra-kit\",\n \"type\": \"module\",\n \"version\": \"0.1.99\",\n \"description\": \"infra-kit\",\n \"main\": \"dist/cli.js\",\n \"module\": \"dist/cli.js\",\n \"bin\": {\n \"infra-kit\": \"dist/cli.js\",\n \"ik\": \"dist/cli.js\"\n },\n \"engines\": {\n \"node\": \">=24.x\"\n },\n \"scripts\": {\n \"inspector\": \"npx @modelcontextprotocol/inspector node ./dist/mcp.js --debug\",\n \"build\": \"pnpm run clean-artifacts && node ./scripts/build.js\",\n \"clean-artifacts\": \"rm -rf dist\",\n \"clean-cache\": \"rm -rf node_modules/.cache .eslintcache tsconfig.tsbuildinfo .turbo .swc\",\n \"prettier-fix\": \"pnpm exec prettier **/* --write --no-error-on-unmatched-pattern --log-level warn --ignore-path ../../../.prettierignore\",\n \"prettier-check\": \"pnpm exec prettier **/* --check --no-error-on-unmatched-pattern --log-level warn --ignore-path ../../../.prettierignore\",\n \"eslint-check\": \"pnpm exec eslint --cache --quiet --report-unused-disable-directives ./src\",\n \"eslint-fix\": \"pnpm exec eslint --cache --quiet --report-unused-disable-directives ./src --fix\",\n \"ts-check\": \"tsc --noEmit\",\n \"test\": \"pnpm exec vitest run --reporter=dot\",\n \"test-watch\": \"pnpm exec vitest --watch\",\n \"test-ui\": \"pnpm exec vitest --ui\",\n \"test-report\": \"pnpm exec vitest run --coverage\",\n \"qa\": \"pnpm run prettier-check && pnpm run eslint-check && pnpm run ts-check && pnpm run test && echo \u2705 Success\",\n \"fix\": \"pnpm run prettier-fix && pnpm run eslint-fix && pnpm run qa\"\n },\n \"dependencies\": {\n \"@inquirer/checkbox\": \"^5.1.4\",\n \"@inquirer/confirm\": \"^6.0.12\",\n \"@inquirer/select\": \"^5.1.4\",\n \"@modelcontextprotocol/sdk\": \"^1.29.0\",\n \"commander\": \"^14.0.3\",\n \"pino\": \"^10.3.1\",\n \"pino-pretty\": \"^13.1.3\",\n \"yaml\": \"^2.8.4\",\n \"zod\": \"^3.25.76\",\n \"zx\": \"^8.8.5\"\n },\n \"devDependencies\": {\n \"@pkg/eslint-config\": \"workspace:*\",\n \"@pkg/vitest-config\": \"workspace:*\",\n \"esbuild\": \"^0.28.0\",\n \"typescript\": \"catalog:\"\n }\n}\n", "/* eslint-disable sonarjs/cognitive-complexity */\nimport checkbox from '@inquirer/checkbox'\nimport confirm from '@inquirer/confirm'\nimport select from '@inquirer/select'\nimport process from 'node:process'\nimport { z } from 'zod/v4'\nimport { $ } from 'zx'\n\nimport { buildCmuxWorkspaceTitle, openCmuxWorkspaceWithLayout } from 'src/integrations/cmux'\nimport { addFoldersToCursorWorkspace, resolveCursorWorkspacePath } from 'src/integrations/cursor'\nimport { getReleasePRsWithInfo } from 'src/integrations/gh'\nimport { commandEcho } from 'src/lib/command-echo'\nimport { WORKTREES_DIR_SUFFIX } from 'src/lib/constants'\nimport { getCurrentWorktrees, getProjectRoot, getRepoName } from 'src/lib/git-utils'\nimport { getInfraKitConfig } from 'src/lib/infra-kit-config'\nimport { logger } from 'src/lib/logger'\nimport { detectReleaseType, formatBranchChoices, getJiraDescriptions } from 'src/lib/release-utils'\nimport type { ReleaseType } from 'src/lib/release-utils'\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\nexport const CURSOR_MODES = ['workspace', 'windows', 'none'] as const\nexport type CursorMode = (typeof CURSOR_MODES)[number]\n\ninterface WorktreeManagementArgs extends RequiredConfirmedOptionArg {\n all: boolean\n versions?: string\n cursor?: CursorMode\n githubDesktop?: boolean\n cmux?: 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, versions, cursor, githubDesktop, cmux } = options\n\n commandEcho.start('worktrees-add')\n\n try {\n const currentWorktrees = await getCurrentWorktrees('release')\n const projectRoot = await getProjectRoot()\n\n const worktreeDir = `${projectRoot}${WORKTREES_DIR_SUFFIX}`\n\n await ensureWorktreeDirectory(`${worktreeDir}/${RELEASE_DIR}`)\n await ensureWorktreeDirectory(`${worktreeDir}/${FEATURE_DIR}`)\n\n let selectedReleaseBranches: string[] = []\n\n if (versions) {\n selectedReleaseBranches = versions.split(',').map((v) => {\n return `release/v${v.trim()}`\n })\n } else {\n const releasePRsInfo = await getReleasePRsWithInfo()\n\n const releasePRsList = releasePRsInfo.map((pr) => {\n return pr.branch\n })\n\n if (releasePRsList.length === 0) {\n logger.info('\u2139\uFE0F No open release branches found')\n\n commandEcho.print()\n\n return {\n content: [{ type: 'text', text: JSON.stringify({ createdWorktrees: [], count: 0 }, null, 2) }],\n structuredContent: { createdWorktrees: [], count: 0 },\n }\n }\n\n if (all) {\n selectedReleaseBranches = releasePRsList\n } else {\n commandEcho.setInteractive()\n\n const releaseTypes = new Map<string, ReleaseType>(\n releasePRsInfo.map((pr) => {\n return [pr.branch, detectReleaseType(pr.title)]\n }),\n )\n\n const descriptions = await getJiraDescriptions()\n\n selectedReleaseBranches = await checkbox({\n required: true,\n message: '\uD83C\uDF3F Select release branches',\n choices: formatBranchChoices({ branches: releasePRsList, descriptions, types: releaseTypes }),\n })\n }\n }\n\n // Track --all flag if all branches were selected (either via flag or interactively)\n if (all) {\n commandEcho.addOption('--all', true)\n } else {\n commandEcho.addOption(\n '--versions',\n selectedReleaseBranches.map((branch) => {\n return branch.replace('release/v', '')\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 (!confirmedCommand) {\n commandEcho.setInteractive()\n }\n\n if (!answer) {\n logger.info('Operation cancelled. Exiting...')\n process.exit(0)\n }\n\n // Track --yes flag if confirmation was interactive (user confirmed)\n if (!confirmedCommand) {\n commandEcho.addOption('--yes', true)\n }\n\n const config = await getInfraKitConfig()\n const cursorConfig = config.ide?.provider === 'cursor' ? config.ide.config : undefined\n\n const cursorMode: CursorMode =\n cursor ??\n cursorConfig?.mode ??\n (await select<CursorMode>({\n message: 'Cursor mode for created worktrees?',\n default: 'workspace',\n choices: [\n {\n name: 'Add to workspace file',\n value: 'workspace',\n description: 'Append each worktree as a folder in ide.config.workspaceConfigPath, then open the workspace',\n },\n {\n name: 'Open separate windows',\n value: 'windows',\n description: 'Open each created worktree in its own Cursor window',\n },\n { name: 'Skip', value: 'none', description: 'Do not open Cursor' },\n ],\n }))\n\n if (typeof cursor === 'undefined' && !cursorConfig?.mode) {\n commandEcho.setInteractive()\n }\n\n commandEcho.addOption('--cursor', cursorMode)\n\n const openInGithubDesktop =\n githubDesktop ??\n config.worktrees?.openInGithubDesktop ??\n (await confirm({ message: 'Open created worktrees in GitHub Desktop?' }))\n\n if (typeof githubDesktop === 'undefined' && config.worktrees?.openInGithubDesktop === undefined) {\n commandEcho.setInteractive()\n }\n\n if (openInGithubDesktop) {\n commandEcho.addOption('--github-desktop', true)\n } else {\n commandEcho.addOption('--no-github-desktop', true)\n }\n\n const openInCmux =\n cmux ?? config.worktrees?.openInCmux ?? (await confirm({ message: 'Open created worktrees in cmux?' }))\n\n if (typeof cmux === 'undefined' && config.worktrees?.openInCmux === undefined) {\n commandEcho.setInteractive()\n }\n\n if (openInCmux) {\n commandEcho.addOption('--cmux', true)\n } else {\n commandEcho.addOption('--no-cmux', true)\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 if (cursorMode === 'workspace') {\n if (!cursorConfig?.workspaceConfigPath) {\n logger.warn('\u26A0\uFE0F Skipping Cursor: ide.config.workspaceConfigPath is not set in infra-kit config')\n } else {\n const workspacePath = resolveCursorWorkspacePath(cursorConfig.workspaceConfigPath, projectRoot)\n\n const folderPaths = createdWorktrees.map((branch) => {\n return `${worktreeDir}/${branch}`\n })\n\n const { added, skipped } = await addFoldersToCursorWorkspace({ workspacePath, folderPaths })\n\n const skippedSuffix = skipped.length > 0 ? ` (${skipped.length} already present)` : ''\n\n logger.info(`\u2705 Added ${added.length} folder(s) to ${workspacePath}${skippedSuffix}`)\n\n await $`cursor ${workspacePath}`\n }\n } else if (cursorMode === 'windows') {\n for (const branch of createdWorktrees) {\n await $`cursor ${worktreeDir}/${branch}`\n }\n }\n\n if (openInGithubDesktop) {\n for (const branch of createdWorktrees) {\n await $`github ${worktreeDir}/${branch}`\n await $`sleep 5`\n }\n }\n\n if (openInCmux) {\n const repoName = await getRepoName()\n\n for (const branch of createdWorktrees) {\n const title = buildCmuxWorkspaceTitle({ repoName, branch })\n\n await openCmuxWorkspaceWithLayout({\n cwd: `${worktreeDir}/${branch}`,\n title,\n })\n }\n }\n\n commandEcho.print()\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) => {\n return branch.startsWith(RELEASE_BRANCH_PREFIX)\n })\n\n const branchesToCreate = selectedReleaseBranches.filter((branch) => {\n return !currentBranchNames.includes(branch)\n })\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 results = await Promise.allSettled(\n branches.map(async (branch) => {\n const worktreePath = `${worktreeDir}/${branch}`\n\n await $`git worktree add ${worktreePath} ${branch}`\n await $({ cwd: worktreePath })`pnpm install`\n\n return branch\n }),\n )\n\n const created: string[] = []\n\n for (const [index, result] of results.entries()) {\n if (result.status === 'fulfilled') {\n created.push(result.value)\n } else {\n const branch = branches[index]\n\n logger.error({ error: result.reason }, `\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('\u2705 Created git worktrees:')\n for (const branch of created) {\n logger.info(branch)\n }\n logger.info('')\n } else {\n logger.info('\u2139\uFE0F No new git worktrees to create')\n }\n}\n\n// MCP Tool Registration\nexport const worktreesAddMcpTool = {\n name: 'worktrees-add',\n description:\n 'Create local git worktrees for release branches under the worktrees directory and run \"pnpm install\" in each. Mutates the local filesystem. When invoked via MCP, pass either \"versions\" (comma-separated) or all=true \u2014 the branch picker and \"open in Cursor / GitHub Desktop / cmux\" follow-up prompts are unreachable without a TTY, and the CLI confirmation is auto-skipped for MCP calls.',\n inputSchema: {\n all: z\n .boolean()\n .optional()\n .describe(\n 'Add worktrees for every open release branch. Either \"all\" or \"versions\" must be provided for MCP calls (the interactive picker is unavailable without a TTY). Ignored if \"versions\" is provided.',\n ),\n versions: z\n .string()\n .optional()\n .describe(\n 'Comma-separated release versions to target (e.g. \"1.2.5, 1.2.6\"). Either \"versions\" or all=true must be provided for MCP calls. Overrides \"all\" when set.',\n ),\n cursor: z\n .enum(CURSOR_MODES)\n .optional()\n .describe(\n 'Cursor open mode for created worktrees. \"workspace\" appends each worktree as a folder to \"ide.config.workspaceConfigPath\" in infra-kit config and opens the workspace. \"windows\" opens each worktree in its own Cursor window. \"none\" skips Cursor. Resolution order: this flag \u2192 \"ide.config.mode\" from infra-kit config \u2192 interactive prompt (CLI) / \"none\" (MCP, no TTY).',\n ),\n githubDesktop: z\n .boolean()\n .optional()\n .describe(\n 'Open each created worktree in GitHub Desktop. Resolution order: this flag \u2192 \"worktrees.openInGithubDesktop\" from infra-kit config \u2192 interactive prompt (CLI) / false (MCP, no TTY).',\n ),\n cmux: z\n .boolean()\n .optional()\n .describe(\n 'Open each created worktree in a new cmux workspace with a 3-pane layout (left-top, left-bottom, full-height right), all rooted at the worktree directory. Resolution order: this flag \u2192 \"worktrees.openInCmux\" from infra-kit config \u2192 interactive prompt (CLI) / false (MCP, no TTY).',\n ),\n },\n outputSchema: {\n createdWorktrees: z.array(z.string()).describe('List of created git worktree branches'),\n count: z.number().describe('Number of git worktrees created'),\n },\n handler: worktreesAdd,\n}\n", "import { $ } from 'zx'\n\nimport { logger } from 'src/lib/logger'\n\n/**\n * Best-effort close of the cmux workspace whose title exactly matches `title`.\n * Silently no-ops if cmux isn't running, the workspace isn't found, or close fails.\n */\nexport const closeCmuxWorkspaceByTitle = async (title: string): Promise<void> => {\n try {\n const listOutput = (await $`cmux list-workspaces`.quiet()).stdout\n\n const ref = findWorkspaceRefByTitle(listOutput, title)\n\n if (!ref) {\n return\n }\n\n await $`cmux close-workspace --workspace ${ref}`.quiet()\n } catch (error) {\n logger.debug({ error, title }, 'cmux: skipped closing workspace')\n }\n}\n\n/**\n * Parses `cmux list-workspaces` output and returns the workspace ref whose\n * title exactly matches `title`, or undefined if no match.\n *\n * Each line looks like:\n * \" workspace:8 hulyo-monorepo v1.48.0\"\n * \"* workspace:6 obsidian-workspace [selected]\"\n */\nconst findWorkspaceRefByTitle = (output: string, title: string): string | undefined => {\n for (const rawLine of output.split('\\n')) {\n // eslint-disable-next-line sonarjs/slow-regex, regexp/no-super-linear-backtracking\n const match = rawLine.match(/^[* ]\\s*(workspace:\\d+)\\s+(.+?)(?:\\s+\\[selected\\])?\\s*$/)\n\n if (!match) {\n continue\n }\n\n const ref = match[1]\n const lineTitle = match[2]?.trim() ?? ''\n\n if (lineTitle === title) {\n return ref\n }\n }\n\n return undefined\n}\n", "import { $ } from 'zx'\n\nimport { logger } from 'src/lib/logger'\n\n/**\n * Returns the set of titles for all currently-open cmux workspaces.\n * Returns an empty set if cmux isn't running, the call fails, or the\n * output can't be parsed \u2014 callers should treat \"empty\" as \"unknown,\n * proceed as if nothing is open\".\n *\n * Each line of `cmux list-workspaces` looks like:\n * \" workspace:8 hulyo-monorepo v1.48.0\"\n * \"* workspace:6 obsidian-workspace [selected]\"\n */\nexport const listCmuxWorkspaceTitles = async (): Promise<Set<string>> => {\n try {\n const output = (await $`cmux list-workspaces`.quiet()).stdout\n\n const titles = new Set<string>()\n\n for (const rawLine of output.split('\\n')) {\n // eslint-disable-next-line sonarjs/slow-regex, regexp/no-super-linear-backtracking\n const match = rawLine.match(/^[* ]\\s*workspace:\\d+\\s+(.+?)(?:\\s+\\[selected\\])?\\s*$/)\n\n if (!match) {\n continue\n }\n\n const title = match[1]?.trim()\n\n if (title) {\n titles.add(title)\n }\n }\n\n return titles\n } catch (error) {\n logger.debug({ error }, 'cmux: skipped listing workspace titles')\n\n return new Set()\n }\n}\n", "import { $ } from 'zx'\n\ninterface OpenCmuxWorkspaceArgs {\n cwd: string\n title?: string\n}\n\n/**\n * Opens a new cmux workspace rooted at `cwd` with three panes:\n * left-top (primary) | right (full-height)\n * left-bottom |\n * All panes inherit `cwd` from the workspace.\n */\nexport const openCmuxWorkspaceWithLayout = async (args: OpenCmuxWorkspaceArgs): Promise<void> => {\n const { cwd, title } = args\n\n const newWorkspaceOutput = (await $`cmux new-workspace --cwd ${cwd}`).stdout\n\n const workspaceRef = parseWorkspaceRef(newWorkspaceOutput)\n\n const surfacesOutput = (await $`cmux list-pane-surfaces --workspace ${workspaceRef}`).stdout\n\n const leftTopRef = parseFirstSurfaceRef(surfacesOutput)\n\n await $`cmux new-split right --workspace ${workspaceRef} --surface ${leftTopRef}`\n await $`cmux new-split down --workspace ${workspaceRef} --surface ${leftTopRef}`\n\n if (title) {\n await $`cmux rename-workspace --workspace ${workspaceRef} ${title}`\n }\n}\n\n/**\n * Extracts the first `surface:<id>` reference from the output of\n * `cmux list-pane-surfaces`. Used to locate the initial (primary) pane\n * surface so subsequent splits can be anchored relative to it.\n *\n * @example\n * const output = 'surface:12 (active)\\nsurface:13\\n'\n * parseFirstSurfaceRef(output) // => 'surface:12'\n */\nconst parseFirstSurfaceRef = (output: string): string => {\n const match = output.match(/surface:\\d+/)\n\n if (!match) {\n throw new Error('cmux: could not locate initial surface in list-pane-surfaces output')\n }\n\n return match[0]\n}\n\n/**\n * Extracts the `workspace:<id>` reference from the output of\n * `cmux new-workspace`. The returned ref is used to target the newly\n * created workspace in follow-up `cmux` commands (splits, rename, etc.).\n *\n * @example\n * const output = 'created workspace:7\\n'\n * parseWorkspaceRef(output) // => 'workspace:7'\n */\nconst parseWorkspaceRef = (output: string): string => {\n const match = output.match(/workspace:\\d+/)\n\n if (!match) {\n throw new Error('cmux: could not locate workspace ref in new-workspace output')\n }\n\n return match[0]\n}\n", "interface BuildCmuxWorkspaceTitleArgs {\n repoName: string\n branch: string\n}\n\n/**\n * Builds the cmux workspace title used by `worktrees-add` and looked up by\n * `worktrees-remove`. The `release/` prefix is stripped so the title reads\n * e.g. `\"hulyo-monorepo v1.48.0\"` for branch `\"release/v1.48.0\"`.\n */\nexport const buildCmuxWorkspaceTitle = (args: BuildCmuxWorkspaceTitleArgs): string => {\n const { repoName, branch } = args\n\n const version = branch.replace('release/', '')\n\n return `${repoName} ${version}`\n}\n", "import fs from 'node:fs/promises'\nimport path from 'node:path'\n\ninterface AddFoldersToCursorWorkspaceArgs {\n workspacePath: string\n folderPaths: string[]\n}\n\ninterface AddFoldersToCursorWorkspaceResult {\n added: string[]\n skipped: string[]\n}\n\ninterface WorkspaceFolderEntry {\n path: string\n name?: string\n}\n\ninterface WorkspaceFile {\n folders?: WorkspaceFolderEntry[]\n [key: string]: unknown\n}\n\n/**\n * Adds folders to a Cursor (`.code-workspace`) file's `folders` array, skipping\n * entries that already point to the same absolute path. Folder paths are written\n * as relative to the workspace file's directory to match Cursor's default style.\n */\nexport const addFoldersToCursorWorkspace = async (\n args: AddFoldersToCursorWorkspaceArgs,\n): Promise<AddFoldersToCursorWorkspaceResult> => {\n const { workspacePath, folderPaths } = args\n\n const workspaceDir = path.dirname(workspacePath)\n\n let raw: string\n\n try {\n raw = await fs.readFile(workspacePath, 'utf-8')\n } catch (error) {\n throw new Error(`Cursor workspace file not found at ${workspacePath}: ${(error as Error).message}`)\n }\n\n let parsed: WorkspaceFile\n\n try {\n parsed = JSON.parse(raw) as WorkspaceFile\n } catch (error) {\n throw new Error(\n `Failed to parse ${workspacePath} as JSON. Comments (JSONC) are not supported. ${(error as Error).message}`,\n )\n }\n\n const existingFolders = parsed.folders ?? []\n const existingAbsolutePaths = new Set(\n existingFolders.map((entry) => {\n return path.resolve(workspaceDir, entry.path)\n }),\n )\n\n const added: string[] = []\n const skipped: string[] = []\n\n for (const folderPath of folderPaths) {\n const absolutePath = path.resolve(folderPath)\n\n if (existingAbsolutePaths.has(absolutePath)) {\n skipped.push(folderPath)\n continue\n }\n\n const relativePath = path.relative(workspaceDir, absolutePath)\n\n existingFolders.push({ path: relativePath })\n existingAbsolutePaths.add(absolutePath)\n added.push(folderPath)\n }\n\n parsed.folders = existingFolders\n\n await fs.writeFile(workspacePath, `${JSON.stringify(parsed, null, 2)}\\n`, 'utf-8')\n\n return { added, skipped }\n}\n", "import fs from 'node:fs/promises'\nimport path from 'node:path'\n\nimport { addFoldersToCursorWorkspace } from './add-folders-to-workspace'\nimport { removeFoldersFromCursorWorkspace } from './remove-folders-from-workspace'\n\ninterface ReconcileCursorWorkspaceFoldersArgs {\n workspacePath: string\n worktreeDir: string\n currentBranches: string[]\n}\n\ninterface ReconcileCursorWorkspaceFoldersResult {\n added: string[]\n removed: string[]\n}\n\ninterface WorkspaceFolderEntry {\n path: string\n name?: string\n}\n\ninterface WorkspaceFile {\n folders?: WorkspaceFolderEntry[]\n [key: string]: unknown\n}\n\n/**\n * Reconciles the configured Cursor workspace's `folders` array against the\n * actual set of release worktrees on disk:\n * - Adds any worktree folders that aren't already listed.\n * - Removes entries whose absolute path lives under `${worktreeDir}/release/`\n * but no longer corresponds to a current branch (drift from manual\n * `git worktree remove`, deleted branches, etc.).\n *\n * Non-worktree folder entries are left untouched.\n */\nexport const reconcileCursorWorkspaceFolders = async (\n args: ReconcileCursorWorkspaceFoldersArgs,\n): Promise<ReconcileCursorWorkspaceFoldersResult> => {\n const { workspacePath, worktreeDir, currentBranches } = args\n\n const workspaceDir = path.dirname(workspacePath)\n const releaseRoot = path.resolve(`${worktreeDir}/release`)\n\n const raw = await fs.readFile(workspacePath, 'utf-8')\n const parsed = JSON.parse(raw) as WorkspaceFile\n\n const existingFolders = parsed.folders ?? []\n\n const desiredAbsolutePaths = new Set(\n currentBranches.map((branch) => {\n return path.resolve(`${worktreeDir}/${branch}`)\n }),\n )\n\n const danglingFolderPaths: string[] = []\n\n for (const entry of existingFolders) {\n const entryAbsolutePath = path.resolve(workspaceDir, entry.path)\n\n const isReleaseShaped = entryAbsolutePath === releaseRoot || entryAbsolutePath.startsWith(`${releaseRoot}/`)\n\n if (isReleaseShaped && !desiredAbsolutePaths.has(entryAbsolutePath)) {\n danglingFolderPaths.push(entryAbsolutePath)\n }\n }\n\n let removed: string[] = []\n\n if (danglingFolderPaths.length > 0) {\n const result = await removeFoldersFromCursorWorkspace({\n workspacePath,\n folderPaths: danglingFolderPaths,\n })\n\n removed = result.removed\n }\n\n const desiredFolderPaths = currentBranches.map((branch) => {\n return `${worktreeDir}/${branch}`\n })\n\n const { added } =\n desiredFolderPaths.length > 0\n ? await addFoldersToCursorWorkspace({ workspacePath, folderPaths: desiredFolderPaths })\n : { added: [] as string[] }\n\n return { added, removed }\n}\n", "import fs from 'node:fs/promises'\nimport path from 'node:path'\n\ninterface RemoveFoldersFromCursorWorkspaceArgs {\n workspacePath: string\n folderPaths: string[]\n}\n\ninterface RemoveFoldersFromCursorWorkspaceResult {\n removed: string[]\n notFound: string[]\n}\n\ninterface WorkspaceFolderEntry {\n path: string\n name?: string\n}\n\ninterface WorkspaceFile {\n folders?: WorkspaceFolderEntry[]\n [key: string]: unknown\n}\n\n/**\n * Removes folders from a Cursor (`.code-workspace`) file's `folders` array. Entries\n * are matched by resolved absolute path, so relative and absolute entries pointing\n * at the same folder are both removed.\n */\nexport const removeFoldersFromCursorWorkspace = async (\n args: RemoveFoldersFromCursorWorkspaceArgs,\n): Promise<RemoveFoldersFromCursorWorkspaceResult> => {\n const { workspacePath, folderPaths } = args\n\n const workspaceDir = path.dirname(workspacePath)\n\n let raw: string\n\n try {\n raw = await fs.readFile(workspacePath, 'utf-8')\n } catch (error) {\n throw new Error(`Cursor workspace file not found at ${workspacePath}: ${(error as Error).message}`)\n }\n\n let parsed: WorkspaceFile\n\n try {\n parsed = JSON.parse(raw) as WorkspaceFile\n } catch (error) {\n throw new Error(\n `Failed to parse ${workspacePath} as JSON. Comments (JSONC) are not supported. ${(error as Error).message}`,\n )\n }\n\n const existingFolders = parsed.folders ?? []\n const targetAbsolutePaths = new Set(\n folderPaths.map((folderPath) => {\n return path.resolve(folderPath)\n }),\n )\n\n const removedAbsolutePaths = new Set<string>()\n\n const filteredFolders = existingFolders.filter((entry) => {\n const entryAbsolutePath = path.resolve(workspaceDir, entry.path)\n\n if (targetAbsolutePaths.has(entryAbsolutePath)) {\n removedAbsolutePaths.add(entryAbsolutePath)\n\n return false\n }\n\n return true\n })\n\n parsed.folders = filteredFolders\n\n await fs.writeFile(workspacePath, `${JSON.stringify(parsed, null, 2)}\\n`, 'utf-8')\n\n const removed: string[] = []\n const notFound: string[] = []\n\n for (const folderPath of folderPaths) {\n const absolutePath = path.resolve(folderPath)\n\n if (removedAbsolutePaths.has(absolutePath)) {\n removed.push(folderPath)\n } else {\n notFound.push(folderPath)\n }\n }\n\n return { removed, notFound }\n}\n", "import path from 'node:path'\n\n/**\n * Resolves the configured Cursor workspace path against the project root.\n * Absolute paths are returned unchanged.\n */\nexport const resolveCursorWorkspacePath = (configValue: string, projectRoot: string): string => {\n if (path.isAbsolute(configValue)) {\n return configValue\n }\n\n return path.resolve(projectRoot, configValue)\n}\n", "import { z } from 'zod/v4'\n\nimport { getReleasePRsWithInfo } from 'src/integrations/gh'\nimport { getCurrentWorktrees } from 'src/lib/git-utils'\nimport { logger } from 'src/lib/logger'\nimport { detectReleaseType, formatVersionLabel, getJiraDescriptions } from 'src/lib/release-utils'\nimport type { ReleaseType } from 'src/lib/release-utils'\nimport type { ToolsExecutionResult } from 'src/types'\n\ninterface WorktreeInfo {\n version: string\n type: ReleaseType\n description: string | null\n}\n\n/**\n * List all release git worktrees with version, type, and Jira description\n */\nexport const worktreesList = async (): Promise<ToolsExecutionResult> => {\n const currentWorktrees = await getCurrentWorktrees('release')\n\n if (currentWorktrees.length === 0) {\n logger.info('\u2139\uFE0F No active worktrees found')\n\n return {\n content: [{ type: 'text', text: JSON.stringify({ worktrees: [], count: 0 }, null, 2) }],\n structuredContent: { worktrees: [], count: 0 },\n }\n }\n\n const [releasePRsInfo, jiraDescriptions] = await Promise.all([getReleasePRsWithInfo(), getJiraDescriptions()])\n\n const releaseTypes = new Map<string, ReleaseType>(\n releasePRsInfo.map((pr) => {\n return [pr.branch, detectReleaseType(pr.title)]\n }),\n )\n\n const worktrees: WorktreeInfo[] = currentWorktrees.map((branch) => {\n const version = branch.replace('release/', '')\n const type = releaseTypes.get(branch) || 'regular'\n const description = jiraDescriptions.get(version) || null\n\n return { version, type, description }\n })\n\n // Log formatted output\n const maxVersionLength = Math.max(\n ...worktrees.map((w) => {\n return w.version.length\n }),\n )\n\n const formattedLines = worktrees.map((worktree) => {\n const label = formatVersionLabel(worktree.version, worktree.type, maxVersionLength)\n\n if (worktree.description) {\n return `${label} ${worktree.description}`\n }\n\n return label\n })\n\n logger.info('\uD83C\uDF3F Active worktrees:')\n logger.info(`\\n${formattedLines.join('\\n')}\\n`)\n\n const structuredContent = {\n worktrees,\n count: worktrees.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\nexport const worktreesListMcpTool = {\n name: 'worktrees-list',\n description:\n 'List existing release-branch worktrees with version, release type (regular / hotfix), and Jira fix-version description. Read-only.',\n inputSchema: {},\n outputSchema: {\n worktrees: z\n .array(\n z.object({\n version: z.string().describe('Release version'),\n type: z.enum(['regular', 'hotfix']).describe('Release type'),\n description: z.string().nullable().describe('Jira version description'),\n }),\n )\n .describe('List of all worktrees with details'),\n count: z.number().describe('Number of worktrees'),\n },\n handler: worktreesList,\n}\n", "import { z } from 'zod/v4'\nimport { $ } from 'zx'\n\nimport { buildCmuxWorkspaceTitle, listCmuxWorkspaceTitles, openCmuxWorkspaceWithLayout } from 'src/integrations/cmux'\nimport { reconcileCursorWorkspaceFolders, resolveCursorWorkspacePath } from 'src/integrations/cursor'\nimport { commandEcho } from 'src/lib/command-echo'\nimport { WORKTREES_DIR_SUFFIX } from 'src/lib/constants'\nimport { getCurrentWorktrees, getProjectRoot, getRepoName } from 'src/lib/git-utils'\nimport { getInfraKitConfig } from 'src/lib/infra-kit-config'\nimport { logger } from 'src/lib/logger'\nimport type { ToolsExecutionResult } from 'src/types'\n\ninterface WorktreesOpenResult {\n openedCmux: string[]\n skippedCmux: string[]\n cursorFoldersAdded: number\n cursorFoldersRemoved: number\n}\n\n/**\n * Cold-start restore command: reconciles `Main.code-workspace` against the set\n * of release worktrees on disk, opens Cursor against it, and ensures one cmux\n * workspace exists per worktree. Idempotent and additive \u2014 never removes\n * worktrees, never recreates running cmux workspaces.\n */\nexport const worktreesOpen = async (): Promise<ToolsExecutionResult> => {\n commandEcho.start('worktrees-open')\n\n try {\n const projectRoot = await getProjectRoot()\n const worktreeDir = `${projectRoot}${WORKTREES_DIR_SUFFIX}`\n const currentBranches = await getCurrentWorktrees('release')\n\n const cursorOutcome = await openCursor({ projectRoot, worktreeDir, currentBranches })\n const cmuxOutcome = await openCmux({ worktreeDir, currentBranches })\n\n const result: WorktreesOpenResult = {\n openedCmux: cmuxOutcome.opened,\n skippedCmux: cmuxOutcome.skipped,\n cursorFoldersAdded: cursorOutcome.added,\n cursorFoldersRemoved: cursorOutcome.removed,\n }\n\n logResults(result, { cursorRan: cursorOutcome.ran, cmuxRan: cmuxOutcome.ran })\n\n commandEcho.print()\n\n return {\n content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],\n structuredContent: { ...result },\n }\n } catch (error) {\n logger.error({ error }, '\u274C Error opening worktrees')\n throw error\n }\n}\n\ninterface OpenCursorArgs {\n projectRoot: string\n worktreeDir: string\n currentBranches: string[]\n}\n\ninterface OpenCursorOutcome {\n ran: boolean\n added: number\n removed: number\n}\n\nconst openCursor = async (args: OpenCursorArgs): Promise<OpenCursorOutcome> => {\n const { projectRoot, worktreeDir, currentBranches } = args\n\n const config = await getInfraKitConfig()\n const cursorConfig = config.ide?.provider === 'cursor' ? config.ide.config : undefined\n\n if (!cursorConfig || cursorConfig.mode !== 'workspace' || !cursorConfig.workspaceConfigPath) {\n logger.warn('\u26A0\uFE0F Skipping Cursor: ide.provider must be \"cursor\", mode \"workspace\", and workspaceConfigPath set.')\n\n return { ran: false, added: 0, removed: 0 }\n }\n\n const workspacePath = resolveCursorWorkspacePath(cursorConfig.workspaceConfigPath, projectRoot)\n\n try {\n const { added, removed } = await reconcileCursorWorkspaceFolders({\n workspacePath,\n worktreeDir,\n currentBranches,\n })\n\n await $`cursor ${workspacePath}`\n\n return { ran: true, added: added.length, removed: removed.length }\n } catch (error) {\n logger.warn({ error }, `\u26A0\uFE0F Failed to reconcile/open Cursor workspace at ${workspacePath}`)\n\n return { ran: false, added: 0, removed: 0 }\n }\n}\n\ninterface OpenCmuxArgs {\n worktreeDir: string\n currentBranches: string[]\n}\n\ninterface OpenCmuxOutcome {\n ran: boolean\n opened: string[]\n skipped: string[]\n}\n\nconst openCmux = async (args: OpenCmuxArgs): Promise<OpenCmuxOutcome> => {\n const { worktreeDir, currentBranches } = args\n\n if (currentBranches.length === 0) {\n return { ran: true, opened: [], skipped: [] }\n }\n\n const repoName = await getRepoName()\n const existingTitles = await listCmuxWorkspaceTitles()\n\n const opened: string[] = []\n const skipped: string[] = []\n\n for (const branch of currentBranches) {\n const title = buildCmuxWorkspaceTitle({ repoName, branch })\n\n if (existingTitles.has(title)) {\n skipped.push(title)\n continue\n }\n\n try {\n await openCmuxWorkspaceWithLayout({ cwd: `${worktreeDir}/${branch}`, title })\n opened.push(title)\n } catch (error) {\n logger.warn({ error, title }, `\u26A0\uFE0F Failed to open cmux workspace for ${branch}`)\n }\n }\n\n return { ran: true, opened, skipped }\n}\n\ninterface LogResultsContext {\n cursorRan: boolean\n cmuxRan: boolean\n}\n\nconst logResults = (result: WorktreesOpenResult, context: LogResultsContext): void => {\n if (context.cursorRan) {\n if (result.cursorFoldersAdded > 0) {\n logger.info(`\u2705 Added ${result.cursorFoldersAdded} folder(s) to Cursor workspace`)\n }\n\n if (result.cursorFoldersRemoved > 0) {\n logger.info(`\uD83E\uDDF9 Removed ${result.cursorFoldersRemoved} dangling folder(s) from Cursor workspace`)\n }\n }\n\n if (result.openedCmux.length > 0) {\n logger.info('\u2705 Opened cmux workspaces:')\n for (const title of result.openedCmux) {\n logger.info(title)\n }\n }\n\n if (result.skippedCmux.length > 0) {\n logger.info(`\u2139\uFE0F Skipped ${result.skippedCmux.length} cmux workspace(s) already open`)\n }\n\n if (\n !context.cursorRan &&\n result.openedCmux.length === 0 &&\n result.skippedCmux.length === 0 &&\n result.cursorFoldersAdded === 0 &&\n result.cursorFoldersRemoved === 0\n ) {\n logger.info('\u2139\uFE0F Nothing to open')\n }\n}\n\n// MCP Tool Registration\nexport const worktreesOpenMcpTool = {\n name: 'worktrees-open',\n description:\n 'Open Cursor against the configured workspace file and ensure a cmux workspace exists for each existing release worktree. Idempotent and additive \u2014 never removes worktrees, never recreates running cmux workspaces. Use after a cold start (Cursor + cmux closed). For stale-worktree cleanup, use worktrees-sync.',\n inputSchema: {},\n outputSchema: {\n openedCmux: z.array(z.string()).describe('Titles of cmux workspaces opened during this run'),\n skippedCmux: z.array(z.string()).describe('Titles of cmux workspaces that were already open'),\n cursorFoldersAdded: z.number().describe('Number of worktree folders added to the Cursor workspace file'),\n cursorFoldersRemoved: z\n .number()\n .describe('Number of dangling worktree folders removed from the Cursor workspace file'),\n },\n handler: worktreesOpen,\n}\n", "import checkbox from '@inquirer/checkbox'\nimport confirm from '@inquirer/confirm'\nimport process from 'node:process'\nimport { z } from 'zod/v4'\nimport { $ } from 'zx'\n\nimport { buildCmuxWorkspaceTitle, closeCmuxWorkspaceByTitle } from 'src/integrations/cmux'\nimport { removeFoldersFromCursorWorkspace, resolveCursorWorkspacePath } from 'src/integrations/cursor'\nimport { getReleasePRsWithInfo } from 'src/integrations/gh'\nimport { commandEcho } from 'src/lib/command-echo'\nimport { WORKTREES_DIR_SUFFIX } from 'src/lib/constants'\nimport { getCurrentWorktrees, getProjectRoot, getRepoName } from 'src/lib/git-utils'\nimport { getInfraKitConfig } from 'src/lib/infra-kit-config'\nimport { logger } from 'src/lib/logger'\nimport { detectReleaseType, formatBranchChoices, getJiraDescriptions } from 'src/lib/release-utils'\nimport type { ReleaseType } from 'src/lib/release-utils'\nimport type { RequiredConfirmedOptionArg, ToolsExecutionResult } from 'src/types'\n\n// Constants\ninterface WorktreeManagementArgs extends RequiredConfirmedOptionArg {\n all: boolean\n versions?: string\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, versions } = options\n\n commandEcho.start('worktrees-remove')\n\n try {\n const currentWorktrees = await getCurrentWorktrees('release')\n\n if (currentWorktrees.length === 0) {\n logger.info('\u2139\uFE0F No active worktrees to remove')\n\n commandEcho.print()\n\n return {\n content: [{ type: 'text', text: JSON.stringify({ removedWorktrees: [], count: 0 }, null, 2) }],\n structuredContent: { removedWorktrees: [], count: 0 },\n }\n }\n\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 if (versions) {\n selectedReleaseBranches = versions.split(',').map((v) => {\n return `release/v${v.trim()}`\n })\n } else {\n commandEcho.setInteractive()\n\n const [descriptions, prInfo] = await Promise.all([getJiraDescriptions(), getReleasePRsWithInfo()])\n\n const releaseTypes = new Map<string, ReleaseType>(\n prInfo.map((pr) => {\n return [pr.branch, detectReleaseType(pr.title)]\n }),\n )\n\n selectedReleaseBranches = await checkbox({\n required: true,\n message: '\uD83C\uDF3F Select release branches',\n choices: formatBranchChoices({ branches: currentWorktrees, descriptions, types: releaseTypes }),\n })\n }\n\n // Track --all flag if all branches were selected (either via flag or interactively)\n const allSelected = selectedReleaseBranches.length === currentWorktrees.length\n\n if (allSelected) {\n commandEcho.addOption('--all', true)\n } else {\n commandEcho.addOption(\n '--versions',\n selectedReleaseBranches.map((branch) => {\n return branch.replace('release/v', '')\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 (!confirmedCommand) {\n commandEcho.setInteractive()\n }\n\n if (!answer) {\n logger.info('Operation cancelled. Exiting...')\n process.exit(0)\n }\n\n // Track --yes flag if confirmation was interactive (user confirmed)\n if (!confirmedCommand) {\n commandEcho.addOption('--yes', true)\n }\n\n const repoName = await getRepoName()\n\n const removedWorktrees = await removeWorktrees({\n branches: selectedReleaseBranches,\n worktreeDir,\n repoName,\n allSelected,\n })\n\n await syncCursorWorkspaceOnRemove({ removedWorktrees, worktreeDir, projectRoot })\n\n logResults(removedWorktrees)\n\n commandEcho.print()\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 RemoveWorktreesArgs {\n branches: string[]\n worktreeDir: string\n repoName: string\n allSelected: boolean\n}\n\n/**\n * Remove worktrees for the specified branches and whole folder\n */\nconst removeWorktrees = async (args: RemoveWorktreesArgs): Promise<string[]> => {\n const { branches, worktreeDir, repoName, allSelected } = args\n\n const results = await Promise.allSettled(\n branches.map(async (branch) => {\n const worktreePath = `${worktreeDir}/${branch}`\n\n const title = buildCmuxWorkspaceTitle({ repoName, branch })\n\n await closeCmuxWorkspaceByTitle(title)\n\n await $`git worktree remove ${worktreePath}`\n\n return branch\n }),\n )\n\n const removed: string[] = []\n\n for (const [index, result] of results.entries()) {\n if (result.status === 'fulfilled') {\n removed.push(result.value)\n } else {\n const branch = branches[index]\n\n logger.error({ error: result.reason }, `\u274C Failed to remove worktree for ${branch}`)\n }\n }\n\n if (allSelected && removed.length === branches.length) {\n await $`git worktree prune`\n await $`rm -rf ${worktreeDir}`\n\n logger.info(`\uD83D\uDDD1\uFE0F Removed worktree folder: ${worktreeDir}`)\n logger.info('')\n }\n\n return removed\n}\n\ninterface SyncCursorWorkspaceOnRemoveArgs {\n removedWorktrees: string[]\n worktreeDir: string\n projectRoot: string\n}\n\n/**\n * Strip removed worktrees from the configured Cursor workspace's `folders` array.\n * No-op if Cursor isn't configured, mode isn't \"workspace\", or no worktrees were removed.\n */\nconst syncCursorWorkspaceOnRemove = async (args: SyncCursorWorkspaceOnRemoveArgs): Promise<void> => {\n const { removedWorktrees, worktreeDir, projectRoot } = args\n\n if (removedWorktrees.length === 0) {\n return\n }\n\n const config = await getInfraKitConfig()\n const cursorConfig = config.ide?.provider === 'cursor' ? config.ide.config : undefined\n\n if (!cursorConfig || cursorConfig.mode !== 'workspace' || !cursorConfig.workspaceConfigPath) {\n return\n }\n\n const workspacePath = resolveCursorWorkspacePath(cursorConfig.workspaceConfigPath, projectRoot)\n\n const folderPaths = removedWorktrees.map((branch) => {\n return `${worktreeDir}/${branch}`\n })\n\n try {\n const { removed } = await removeFoldersFromCursorWorkspace({ workspacePath, folderPaths })\n\n if (removed.length > 0) {\n logger.info(`\u2705 Removed ${removed.length} folder(s) from ${workspacePath}`)\n }\n } catch (error) {\n logger.warn({ error }, `\u26A0\uFE0F Failed to update Cursor workspace at ${workspacePath}`)\n }\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 for (const branch of removed) {\n logger.info(branch)\n }\n logger.info('')\n } else {\n logger.info('\u2139\uFE0F No unused worktrees to remove')\n }\n}\n\n// MCP Tool Registration\nexport const worktreesRemoveMcpTool = {\n name: 'worktrees-remove',\n description:\n 'Remove local git worktrees for release branches. When everything is removed, also runs \"git worktree prune\" and deletes the worktrees directory. When invoked via MCP, pass either \"versions\" (comma-separated) or all=true \u2014 the branch picker is unreachable without a TTY, and the CLI confirmation is auto-skipped for MCP calls, so the caller is responsible for gating.',\n inputSchema: {\n all: z\n .boolean()\n .optional()\n .describe(\n 'Remove every existing worktree. Either \"all\" or \"versions\" must be provided for MCP calls (the interactive picker is unavailable without a TTY). Ignored if \"versions\" is provided.',\n ),\n versions: z\n .string()\n .optional()\n .describe(\n 'Comma-separated release versions to target (e.g. \"1.2.5, 1.2.6\"). Either \"versions\" or all=true must be provided for MCP calls. Overrides \"all\" when set.',\n ),\n },\n outputSchema: {\n removedWorktrees: z.array(z.string()).describe('List of removed git worktree branches'),\n count: z.number().describe('Number of git worktrees removed'),\n },\n handler: worktreesRemove,\n}\n", "import confirm from '@inquirer/confirm'\nimport process from 'node:process'\nimport { z } from 'zod/v4'\nimport { $ } from 'zx'\n\nimport { buildCmuxWorkspaceTitle, closeCmuxWorkspaceByTitle } from 'src/integrations/cmux'\nimport { removeFoldersFromCursorWorkspace, resolveCursorWorkspacePath } from 'src/integrations/cursor'\nimport { getReleasePRs } from 'src/integrations/gh'\nimport { commandEcho } from 'src/lib/command-echo'\nimport { WORKTREES_DIR_SUFFIX } from 'src/lib/constants'\nimport { getCurrentWorktrees, getProjectRoot, getRepoName } from 'src/lib/git-utils'\nimport { getInfraKitConfig } from 'src/lib/infra-kit-config'\nimport { logger } from 'src/lib/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 *\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 commandEcho.start('worktrees-sync')\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 (!confirmedCommand) {\n commandEcho.setInteractive()\n }\n\n if (!answer) {\n logger.info('Operation cancelled. Exiting...')\n process.exit(0)\n }\n\n // Track --yes flag if confirmation was interactive (user confirmed)\n if (!confirmedCommand) {\n commandEcho.addOption('--yes', true)\n }\n\n const { branchesToRemove } = categorizeWorktrees({\n releasePRsList,\n currentWorktrees,\n })\n\n const repoName = await getRepoName()\n\n const removedWorktrees = await removeWorktrees({\n branches: branchesToRemove,\n worktreeDir,\n repoName,\n })\n\n await syncCursorWorkspaceOnRemove({ removedWorktrees, worktreeDir, projectRoot })\n\n logResults(removedWorktrees)\n\n commandEcho.print()\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) => {\n return branch.startsWith(RELEASE_BRANCH_PREFIX)\n })\n\n const branchesToRemove = currentBranchNames.filter((branch) => {\n return !releasePRsList.includes(branch)\n })\n\n return { branchesToRemove }\n}\n\ninterface RemoveWorktreesArgs {\n branches: string[]\n worktreeDir: string\n repoName: string\n}\n\n/**\n * Remove worktrees for the specified branches and close their cmux workspaces\n */\nconst removeWorktrees = async (args: RemoveWorktreesArgs): Promise<string[]> => {\n const { branches, worktreeDir, repoName } = args\n\n const removed: string[] = []\n\n for (const branch of branches) {\n try {\n const worktreePath = `${worktreeDir}/${branch}`\n\n const title = buildCmuxWorkspaceTitle({ repoName, branch })\n\n await closeCmuxWorkspaceByTitle(title)\n\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\ninterface SyncCursorWorkspaceOnRemoveArgs {\n removedWorktrees: string[]\n worktreeDir: string\n projectRoot: string\n}\n\n/**\n * Strip removed worktrees from the configured Cursor workspace's `folders` array.\n * No-op if Cursor isn't configured, mode isn't \"workspace\", or no worktrees were removed.\n */\nconst syncCursorWorkspaceOnRemove = async (args: SyncCursorWorkspaceOnRemoveArgs): Promise<void> => {\n const { removedWorktrees, worktreeDir, projectRoot } = args\n\n if (removedWorktrees.length === 0) {\n return\n }\n\n const config = await getInfraKitConfig()\n const cursorConfig = config.ide?.provider === 'cursor' ? config.ide.config : undefined\n\n if (!cursorConfig || cursorConfig.mode !== 'workspace' || !cursorConfig.workspaceConfigPath) {\n return\n }\n\n const workspacePath = resolveCursorWorkspacePath(cursorConfig.workspaceConfigPath, projectRoot)\n\n const folderPaths = removedWorktrees.map((branch) => {\n return `${worktreeDir}/${branch}`\n })\n\n try {\n const { removed: removedEntries } = await removeFoldersFromCursorWorkspace({ workspacePath, folderPaths })\n\n if (removedEntries.length > 0) {\n logger.info(`\u2705 Removed ${removedEntries.length} folder(s) from ${workspacePath}`)\n }\n } catch (error) {\n logger.warn({ error }, `\u26A0\uFE0F Failed to update Cursor workspace at ${workspacePath}`)\n }\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 for (const branch of removed) {\n logger.info(branch)\n }\n logger.info('')\n } else {\n logger.info('\u2139\uFE0F No unused worktrees to remove')\n }\n}\n\n// MCP Tool Registration\nexport const worktreesSyncMcpTool = {\n name: 'worktrees-sync',\n description:\n 'Remove worktrees whose release PR is no longer open (stale cleanup). Only removes \u2014 never creates; use worktrees-add to create worktrees for new releases. The CLI confirmation is auto-skipped for MCP calls, so the caller is responsible for gating.',\n inputSchema: {},\n outputSchema: {\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 handler: worktreesSync,\n}\n", "import { logger } from 'src/lib/logger'\nimport type { ToolsExecutionResult } from 'src/types'\n\ninterface ToolHandlerArgs {\n toolName: string\n handler: (params: any) => Promise<ToolsExecutionResult>\n}\n\nexport const createToolHandler = (args: ToolHandlerArgs) => {\n return 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}\n", "import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\n\nimport { envClearMcpTool } from 'src/commands/env-clear'\nimport { envListMcpTool } from 'src/commands/env-list'\nimport { envLoadMcpTool } from 'src/commands/env-load'\nimport { envStatusMcpTool } from 'src/commands/env-status'\nimport { ghMergeDevMcpTool } from 'src/commands/gh-merge-dev'\nimport { ghReleaseDeliverMcpTool } from 'src/commands/gh-release-deliver'\nimport { ghReleaseDeployAllMcpTool } from 'src/commands/gh-release-deploy-all'\nimport { ghReleaseDeploySelectedMcpTool } from 'src/commands/gh-release-deploy-selected'\nimport { ghReleaseListMcpTool } from 'src/commands/gh-release-list'\nimport { releaseCreateMcpTool } from 'src/commands/release-create'\nimport { versionMcpTool } from 'src/commands/version'\nimport { worktreesAddMcpTool } from 'src/commands/worktrees-add'\nimport { worktreesListMcpTool } from 'src/commands/worktrees-list'\nimport { worktreesOpenMcpTool } from 'src/commands/worktrees-open'\nimport { worktreesRemoveMcpTool } from 'src/commands/worktrees-remove'\nimport { worktreesSyncMcpTool } from 'src/commands/worktrees-sync'\nimport { createToolHandler } from 'src/lib/tool-handler'\n\nconst tools = [\n envStatusMcpTool,\n envListMcpTool,\n envLoadMcpTool,\n envClearMcpTool,\n ghMergeDevMcpTool,\n releaseCreateMcpTool,\n ghReleaseDeliverMcpTool,\n ghReleaseDeployAllMcpTool,\n ghReleaseDeploySelectedMcpTool,\n ghReleaseListMcpTool,\n versionMcpTool,\n worktreesAddMcpTool,\n worktreesListMcpTool,\n worktreesOpenMcpTool,\n worktreesRemoveMcpTool,\n worktreesSyncMcpTool,\n]\n\nexport const initializeTools = async (server: McpServer) => {\n for (const tool of tools) {\n server.registerTool(\n tool.name,\n {\n description: tool.description,\n inputSchema: tool.inputSchema,\n outputSchema: tool.outputSchema,\n },\n createToolHandler({ toolName: tool.name, handler: tool.handler }),\n )\n }\n}\n"],
5
+ "mappings": "AAAA,OAAS,wBAAAA,OAA4B,4CACrC,OAAOC,OAAa,eCDpB,OAAOC,MAAa,eCApB,OAAOC,OAAa,eACpB,OAAOC,OAAU,OACjB,OAAOC,OAAY,cAGZ,IAAMC,GAAgB,yBAEhBC,GAAgB,IAAM,CACjC,IAAMC,EAAWL,GAAQ,KAAK,SAAS,SAAS,EAAI,QAAU,OAExDM,EAASL,GAAK,CAAE,MAAOI,CAAS,EAAGJ,GAAK,YAAY,CAAE,KAAME,EAAc,CAAC,CAAC,EAElF,OAAAG,EAAO,KAAK,kCAAkCD,CA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,CACF,CACF,EAEA,aAAMC,GAAkBF,CAAM,EAC9B,MAAMG,GAAoBH,CAAM,EAChC,MAAMI,GAAgBJ,CAAM,EAErBA,CACT,CHlBA,IAAMK,EAASC,GAAc,EAEvBC,GAAc,SAAY,CAC9B,IAAIC,EAEJ,GAAI,CACFA,EAAS,MAAMC,GAAgB,EAE/BJ,EAAO,KAAK,6BAA6B,CAC3C,OAASK,EAAO,CACdL,EAAO,MAAM,CAAE,IAAKK,EAAO,IAAK,6BAA8B,CAAC,EAC/DL,EAAO,MAAM,qCAAqC,EAElDM,GAAQ,KAAK,CAAC,CAChB,CAEA,GAAI,CACF,IAAMC,EAAY,IAAIC,GAEtB,MAAML,EAAO,QAAQI,CAAS,EAE9BP,EAAO,KAAK,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,GAAmBT,CAAM,EAGzBE,GAAY",
6
+ "names": ["StdioServerTransport", "process", "process", "process", "pino", "pretty", "LOG_FILE_PATH", "initLoggerMcp", "logLevel", "logger", "initLoggerCLI", "ignoreFields", "setupErrorHandlers", "logger", "process", "error", "LOG_FILE_PATH", "reason", "promise", "McpServer", "initializePrompts", "_server", "initializeResources", "_server", "fs", "path", "process", "z", "fs", "os", "path", "process", "ENV_LOAD_FILE", "ENV_CLEAR_FILE", "INFRA_KIT_SESSION_VAR", "INFRA_KIT_ENV_CONFIG_VAR", "INFRA_KIT_ENV_PROJECT_VAR", "INFRA_KIT_ENV_LOADED_AT_VAR", "ENV_VAR_LINE_PATTERN", "parseVarNamesFromEnvFile", "filePath", "content", "names", "line", "match", "getCacheRoot", "xdg", "base", "getSessionCacheDir", "session", "atomicWriteFileSync", "mode", "tmpPath", "error", "WORKTREES_DIR_SUFFIX", "envClear", "cacheDir", "getSessionCacheDir", "envLoadPath", "path", "ENV_LOAD_FILE", "fs", "varNames", "parseVarNamesFromEnvFile", "unsetLines", "v", "INFRA_KIT_ENV_CONFIG_VAR", "INFRA_KIT_ENV_PROJECT_VAR", "INFRA_KIT_ENV_LOADED_AT_VAR", "clearFilePath", "ENV_CLEAR_FILE", "atomicWriteFileSync", "process", "structuredContent", "envClearMcpTool", "z", "z", "fs", "os", "path", "yaml", "z", "path", "$", "getCurrentWorktrees", "type", "worktreeLines", "worktreePredicateMap", "releaseWorktreePredicate", "featureWorktreePredicate", "branch", "parseWorktreeBranch", "line", "trimmed", "open", "getProjectRoot", "getRepoName", "projectRoot", "INFRA_KIT_CONFIG_FILE", "USER_CONFIG_DIR_NAME", "USER_GLOBAL_CONFIG_FILE", "USER_PROJECTS_DIR", "dopplerEnvManagementSchema", "z", "envManagementSchema", "cursorIdeConfigSchema", "v", "cursorIdeSchema", "ideSchema", "jiraTaskManagerSchema", "taskManagerSchema", "worktreesConfigSchema", "infraKitConfigSchema", "infraKitOverrideConfigSchema", "cached", "getInfraKitConfigPaths", "projectRoot", "getProjectRoot", "projectName", "getRepoName", "userConfigDir", "path", "os", "getInfraKitConfig", "paths", "mainStat", "fs", "userGlobalStat", "userProjectStat", "statIfExists", "mtimes", "shallowEqual", "layers", "merged", "layer", "data", "loadLayer", "finalResult", "statIfExists", "filePath", "fs", "readIfExists", "shallowEqual", "a", "b", "keys", "k", "loadLayer", "layer", "raw", "parsedRaw", "yaml", "result", "infraKitOverrideConfigSchema", "z", "getDopplerProject", "envManagement", "getInfraKitConfig", "envList", "project", "getDopplerProject", "environments", "getInfraKitConfig", "logger", "env", "structuredContent", "envListMcpTool", "z", "select", "Buffer", "fs", "path", "process", "z", "$", "$", "validateDopplerCliAndAuth", "error", "createCommandEcho", "commandName", "options", "isInteractive", "name", "flag", "value", "formattedOptions", "opt", "logger", "commandEcho", "envLoad", "args", "validateDopplerCliAndAuth", "config", "commandEcho", "selectedConfig", "environments", "getInfraKitConfig", "select", "env", "process", "project", "getDopplerProject", "envContent", "downloadDopplerSecrets", "assertValidEnvContent", "loadedAt", "envFileLines", "INFRA_KIT_ENV_CONFIG_VAR", "shellSingleQuote", "INFRA_KIT_ENV_PROJECT_VAR", "INFRA_KIT_ENV_LOADED_AT_VAR", "cacheDir", "getSessionCacheDir", "envFilePath", "path", "ENV_LOAD_FILE", "fs", "atomicWriteFileSync", "varCount", "countEnvVarLines", "structuredContent", "DOPPLER_MAX_OUTPUT_BYTES", "DOPPLER_DOWNLOAD_TIMEOUT_MS", "prevQuiet", "$", "result", "assertDopplerOutputSize", "stdout", "bytes", "Buffer", "content", "line", "ENV_VAR_LINE_PATTERN", "SHELL_DIRECTIVE_LINES", "value", "trimmed", "envLoadMcpTool", "z", "path", "process", "z", "envStatus", "validateDopplerCliAndAuth", "logger", "cacheDir", "getSessionCacheDir", "sessionId", "process", "INFRA_KIT_SESSION_VAR", "envLoadPath", "path", "ENV_LOAD_FILE", "sessionLoadedCount", "sessionTotalCount", "sessionConfig", "INFRA_KIT_ENV_CONFIG_VAR", "sessionProject", "INFRA_KIT_ENV_PROJECT_VAR", "sessionLoadedAt", "INFRA_KIT_ENV_LOADED_AT_VAR", "varNames", "parseVarNamesFromEnvFile", "v", "loadedAtDisplay", "missing", "structuredContent", "envStatusMcpTool", "z", "checkbox", "confirm", "process", "z", "$", "$", "process", "$", "process", "createJiraVersion", "params", "config", "baseUrl", "token", "email", "projectId", "requestBody", "url", "credentials", "response", "errorText", "logger", "error", "getProjectVersions", "findVersionByName", "versionName", "v", "updateJiraVersion", "deliverJiraRelease", "version", "loadJiraConfig", "process", "projectIdStr", "missingVars", "errorMessage", "loadJiraConfigOptional", "getBaseBranch", "type", "prepareGitForRelease", "baseBranch", "$", "createSingleRelease", "args", "version", "jiraConfig", "description", "versionName", "result", "createJiraVersion", "jiraVersionUrl", "releaseInfo", "createReleaseBranch", "getJiraDescriptions", "descriptions", "loadJiraConfigOptional", "versions", "getProjectVersions", "formatVersionLabel", "maxVersionLength", "padding", "tag", "detectReleaseType", "title", "formatBranchChoices", "branches", "types", "versionNames", "b", "maxLen", "v", "branch", "i", "desc", "name", "$", "parseVersion", "versionStr", "sortVersions", "versions", "a", "b", "majA", "minA", "patchA", "majB", "minB", "patchB", "NEXT_TOKEN", "VERSION_RE", "stripBranchPrefix", "raw", "tryParse", "cleaned", "match", "semverKey", "v", "collectKnownVersions", "sources", "all", "parsed", "seen", "key", "sortVersions", "s", "parseVersion", "NoPriorVersionsError", "computeNextVersion", "known", "type", "max", "major", "minor", "highestPatchOnMinor", "acc", "isNextToken", "token", "resolveReleaseEntries", "entries", "known", "running", "entry", "trimmed", "isNextToken", "next", "computeNextVersion", "parseVersion", "parsed", "tryParse", "explicit", "hasNextToken", "e", "parseRemoteRefs", "previousQuiet", "$", "line", "tab", "fetchJiraVersionNames", "config", "loadJiraConfigOptional", "getProjectVersions", "v", "loadExistingVersions", "branchesResult", "jiraResult", "logger", "collectKnownVersions", "fetchAllReleasePRs", "releasePRs", "hotfixPRs", "all", "seen", "pr", "getReleasePRs", "prs", "logger", "process", "sortVersions", "error", "getReleasePRsWithInfo", "sortedBranches", "prByBranch", "branch", "createReleaseBranch", "args", "version", "jiraVersionUrl", "type", "description", "titlePrefix", "baseBranch", "getBaseBranch", "branchName", "body", "prLink", "ghMergeDev", "args", "all", "confirmedCommand", "commandEcho", "releasePRsList", "getReleasePRsWithInfo", "pr", "detectReleaseType", "logger", "selectedReleaseBranches", "descriptions", "getJiraDescriptions", "checkbox", "formatBranchChoices", "branch", "answer", "confirm", "process", "$", "failedBranches", "mergeDev", "structuredContent", "error", "ghMergeDevMcpTool", "z", "confirm", "select", "process", "z", "$", "ghReleaseDeliver", "args", "version", "confirmedCommand", "commandEcho", "releasePRsInfo", "getReleasePRsWithInfo", "branches", "pr", "releaseTypes", "detectReleaseType", "selectedReleaseBranch", "descriptions", "getJiraDescriptions", "select", "formatBranchChoices", "selectedVersion", "prInfo", "logger", "process", "releaseType", "answer", "confirm", "$", "jiraConfig", "loadJiraConfigOptional", "versionName", "deliverJiraRelease", "error", "structuredContent", "ghReleaseDeliverMcpTool", "z", "select", "process", "z", "$", "ghReleaseDeployAll", "args", "version", "env", "skipTerraform", "commandEcho", "selectedReleaseBranch", "releasePRsInfo", "getReleasePRsWithInfo", "branches", "pr", "releaseTypes", "detectReleaseType", "descriptions", "getJiraDescriptions", "select", "formatBranchChoices", "selectedVersion", "environments", "getInfraKitConfig", "selectedEnv", "logger", "process", "shouldSkipTerraform", "$", "structuredContent", "error", "ghReleaseDeployAllMcpTool", "z", "checkbox", "select", "fs", "resolve", "process", "yaml", "z", "$", "ghReleaseDeploySelected", "args", "version", "env", "services", "skipTerraform", "commandEcho", "selectedReleaseBranch", "releasePRsInfo", "getReleasePRsWithInfo", "branches", "pr", "releaseTypes", "detectReleaseType", "descriptions", "getJiraDescriptions", "select", "formatBranchChoices", "selectedVersion", "environments", "getInfraKitConfig", "selectedEnv", "logger", "process", "availableServices", "parseServicesFromWorkflow", "selectedServices", "checkbox", "svc", "invalidServices", "shouldSkipTerraform", "$", "serviceFlags", "structuredContent", "error", "projectRoot", "getProjectRoot", "workflowPath", "resolve", "content", "fs", "inputs", "yaml", "key", "value", "ghReleaseDeploySelectedMcpTool", "z", "z", "ghReleaseList", "releases", "getReleasePRsWithInfo", "pr", "detectReleaseType", "jiraDescriptions", "getJiraDescriptions", "maxVersionLength", "r", "formattedLines", "release", "label", "formatVersionLabel", "description", "logger", "structuredContent", "ghReleaseListMcpTool", "z", "confirm", "select", "process", "z", "question", "VERSION_PROMPT_HINT", "trySuggestNext", "known", "type", "computeNextVersion", "err", "NoPriorVersionsError", "resolveOrExit", "entries", "resolveReleaseEntries", "logger", "process", "promptForReleasesInteractive", "ensureKnown", "commandEcho", "running", "addAnother", "ordinal", "select", "suggestion", "defaultHint", "versionAnswer", "question", "versionInput", "resolved", "parseVersion", "description", "confirm", "formatReleaseSummary", "entry", "parts", "echoReleases", "spec", "collectEntries", "inputReleases", "hasNextToken", "interactive", "confirmReleases", "confirmedCommand", "summary", "answer", "executeOne", "args", "jiraConfig", "prepareGitForRelease", "result", "createSingleRelease", "error", "errorMessage", "logFinalSummary", "total", "successCount", "failureCount", "releaseCreate", "loadJiraConfig", "loadExistingVersions", "created", "failed", "failure", "structuredContent", "r", "releaseCreateMcpTool", "z", "z", "package_default", "version", "cliVersion", "package_default", "logger", "structuredContent", "versionMcpTool", "z", "checkbox", "confirm", "select", "process", "z", "$", "$", "closeCmuxWorkspaceByTitle", "title", "listOutput", "$", "ref", "findWorkspaceRefByTitle", "error", "logger", "output", "rawLine", "match", "$", "listCmuxWorkspaceTitles", "output", "$", "titles", "rawLine", "match", "title", "error", "logger", "$", "openCmuxWorkspaceWithLayout", "args", "cwd", "title", "newWorkspaceOutput", "workspaceRef", "parseWorkspaceRef", "surfacesOutput", "leftTopRef", "parseFirstSurfaceRef", "output", "match", "buildCmuxWorkspaceTitle", "args", "repoName", "branch", "version", "fs", "path", "addFoldersToCursorWorkspace", "args", "workspacePath", "folderPaths", "workspaceDir", "raw", "error", "parsed", "existingFolders", "existingAbsolutePaths", "entry", "added", "skipped", "folderPath", "absolutePath", "relativePath", "fs", "path", "fs", "path", "removeFoldersFromCursorWorkspace", "args", "workspacePath", "folderPaths", "workspaceDir", "raw", "error", "parsed", "existingFolders", "targetAbsolutePaths", "folderPath", "removedAbsolutePaths", "filteredFolders", "entry", "entryAbsolutePath", "removed", "notFound", "absolutePath", "reconcileCursorWorkspaceFolders", "args", "workspacePath", "worktreeDir", "currentBranches", "workspaceDir", "path", "releaseRoot", "raw", "fs", "existingFolders", "desiredAbsolutePaths", "branch", "danglingFolderPaths", "entry", "entryAbsolutePath", "removed", "removeFoldersFromCursorWorkspace", "desiredFolderPaths", "added", "addFoldersToCursorWorkspace", "path", "resolveCursorWorkspacePath", "configValue", "projectRoot", "FEATURE_DIR", "RELEASE_DIR", "RELEASE_BRANCH_PREFIX", "CURSOR_MODES", "worktreesAdd", "options", "confirmedCommand", "all", "versions", "cursor", "githubDesktop", "cmux", "commandEcho", "currentWorktrees", "getCurrentWorktrees", "projectRoot", "getProjectRoot", "worktreeDir", "WORKTREES_DIR_SUFFIX", "ensureWorktreeDirectory", "selectedReleaseBranches", "v", "releasePRsInfo", "getReleasePRsWithInfo", "releasePRsList", "pr", "logger", "releaseTypes", "detectReleaseType", "descriptions", "getJiraDescriptions", "checkbox", "formatBranchChoices", "branch", "answer", "confirm", "process", "config", "getInfraKitConfig", "cursorConfig", "cursorMode", "select", "openInGithubDesktop", "openInCmux", "branchesToCreate", "categorizeWorktrees", "createdWorktrees", "createWorktrees", "logResults", "workspacePath", "resolveCursorWorkspacePath", "folderPaths", "added", "skipped", "addFoldersToCursorWorkspace", "skippedSuffix", "$", "repoName", "getRepoName", "title", "buildCmuxWorkspaceTitle", "openCmuxWorkspaceWithLayout", "structuredContent", "error", "args", "currentBranchNames", "branches", "results", "worktreePath", "created", "index", "result", "worktreesAddMcpTool", "z", "z", "worktreesList", "currentWorktrees", "getCurrentWorktrees", "logger", "releasePRsInfo", "jiraDescriptions", "getReleasePRsWithInfo", "getJiraDescriptions", "releaseTypes", "pr", "detectReleaseType", "worktrees", "branch", "version", "type", "description", "maxVersionLength", "w", "formattedLines", "worktree", "label", "formatVersionLabel", "structuredContent", "worktreesListMcpTool", "z", "z", "$", "worktreesOpen", "commandEcho", "projectRoot", "getProjectRoot", "worktreeDir", "WORKTREES_DIR_SUFFIX", "currentBranches", "getCurrentWorktrees", "cursorOutcome", "openCursor", "cmuxOutcome", "openCmux", "result", "logResults", "error", "logger", "args", "config", "getInfraKitConfig", "cursorConfig", "workspacePath", "resolveCursorWorkspacePath", "added", "removed", "reconcileCursorWorkspaceFolders", "$", "repoName", "getRepoName", "existingTitles", "listCmuxWorkspaceTitles", "opened", "skipped", "branch", "title", "buildCmuxWorkspaceTitle", "openCmuxWorkspaceWithLayout", "context", "worktreesOpenMcpTool", "z", "checkbox", "confirm", "process", "z", "$", "worktreesRemove", "options", "confirmedCommand", "all", "versions", "commandEcho", "currentWorktrees", "getCurrentWorktrees", "logger", "projectRoot", "getProjectRoot", "worktreeDir", "WORKTREES_DIR_SUFFIX", "selectedReleaseBranches", "v", "descriptions", "prInfo", "getJiraDescriptions", "getReleasePRsWithInfo", "releaseTypes", "pr", "detectReleaseType", "checkbox", "formatBranchChoices", "allSelected", "branch", "answer", "confirm", "process", "repoName", "getRepoName", "removedWorktrees", "removeWorktrees", "syncCursorWorkspaceOnRemove", "logResults", "structuredContent", "error", "args", "branches", "results", "worktreePath", "title", "buildCmuxWorkspaceTitle", "closeCmuxWorkspaceByTitle", "$", "removed", "index", "result", "config", "getInfraKitConfig", "cursorConfig", "workspacePath", "resolveCursorWorkspacePath", "folderPaths", "removeFoldersFromCursorWorkspace", "worktreesRemoveMcpTool", "z", "confirm", "process", "z", "$", "RELEASE_BRANCH_PREFIX", "worktreesSync", "options", "confirmedCommand", "commandEcho", "currentWorktrees", "getCurrentWorktrees", "projectRoot", "getProjectRoot", "worktreeDir", "WORKTREES_DIR_SUFFIX", "releasePRsList", "getReleasePRs", "answer", "confirm", "logger", "process", "branchesToRemove", "categorizeWorktrees", "repoName", "getRepoName", "removedWorktrees", "removeWorktrees", "syncCursorWorkspaceOnRemove", "logResults", "structuredContent", "error", "args", "branch", "branches", "removed", "worktreePath", "title", "buildCmuxWorkspaceTitle", "closeCmuxWorkspaceByTitle", "$", "config", "getInfraKitConfig", "cursorConfig", "workspacePath", "resolveCursorWorkspacePath", "folderPaths", "removedEntries", "removeFoldersFromCursorWorkspace", "worktreesSyncMcpTool", "z", "createToolHandler", "args", "params", "toolName", "handler", "logger", "payload", "error", "tools", "envStatusMcpTool", "envListMcpTool", "envLoadMcpTool", "envClearMcpTool", "ghMergeDevMcpTool", "releaseCreateMcpTool", "ghReleaseDeliverMcpTool", "ghReleaseDeployAllMcpTool", "ghReleaseDeploySelectedMcpTool", "ghReleaseListMcpTool", "versionMcpTool", "worktreesAddMcpTool", "worktreesListMcpTool", "worktreesOpenMcpTool", "worktreesRemoveMcpTool", "worktreesSyncMcpTool", "initializeTools", "server", "tool", "createToolHandler", "createMcpServer", "server", "McpServer", "initializePrompts", "initializeResources", "initializeTools", "logger", "initLoggerMcp", "startServer", "server", "createMcpServer", "error", "process", "transport", "StdioServerTransport", "setupErrorHandlers"]
7
7
  }