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