@aurorajs.dev/catalyst-cli 3.1.2 → 3.1.3
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/README.md +1 -1
- package/dist/ai/domain/skills-scanner.js +7 -2
- package/dist/deploy/domain/curl-config.js +1 -1
- package/dist/deploy/domain/playbook-vars.js +1 -1
- package/dist/generator/domain/frontend-composition.js +4 -4
- package/dist/generator/domain/property-filters.d.ts +8 -0
- package/dist/generator/domain/property-filters.js +17 -6
- package/dist/generator/handlers/front.handler.js +10 -1
- package/dist/sheets/domain/auth.js +10 -5
- package/dist/sheets/sync/sheet-to-yaml.d.ts +1 -0
- package/dist/sheets/sync/sheet-to-yaml.js +19 -3
- package/dist/templates/backend/application/.claude/skills/catalyst-tools/SKILL.md +5 -3
- package/dist/templates/backend/application/src/@aurora/modules/manual/application/manual-catalog-section-reader.spec.ts +4 -0
- package/dist/templates/backend/application/src/@aurora/modules/manual/application/manual-find-index.handler.spec.ts +2 -0
- package/dist/templates/backend/application/src/@aurora/modules/manual/application/manual-find-index.handler.ts +2 -1
- package/dist/templates/backend/application/src/@aurora/modules/manual/domain/manual-section-reader.port.ts +2 -0
- package/dist/templates/backend/application/src/@aurora/modules/manual/domain/manual.types.ts +2 -0
- package/dist/templates/backend/application/src/@aurora/modules/manual/graphql/manual-graphql-schema.spec.ts +10 -2
- package/dist/templates/backend/application/src/@aurora/modules/manual/graphql/manual.graphql +4 -0
- package/dist/templates/backend/business-rules/business-partner-portal/supplier-document.md +96 -6
- package/dist/templates/backend/business-rules/tools/assistant-usage.md +60 -0
- package/dist/templates/backend/manual/business-partner-portal/CONTEXT.md +5 -5
- package/dist/templates/backend/manual/business-partner-portal/en/purchase-invoice-header.md +5 -1
- package/dist/templates/backend/manual/business-partner-portal/es/purchase-invoice-header.md +5 -1
- package/dist/templates/backend/manual/production-planning/en/planner.md +1 -1
- package/dist/templates/backend/manual/production-planning/en/production-order-position-event.md +8 -5
- package/dist/templates/backend/manual/production-planning/es/planner.md +1 -1
- package/dist/templates/backend/manual/production-planning/es/production-order-position-event.md +8 -5
- package/dist/templates/backend/manual/reporting/en/report.md +40 -0
- package/dist/templates/backend/manual/reporting/es/report.md +40 -0
- package/dist/templates/backend/manual/tools/CONTEXT.md +1 -0
- package/dist/templates/backend/manual/tools/actions.yaml +11 -0
- package/dist/templates/backend/manual/tools/en/assistant-conversation.md +38 -0
- package/dist/templates/backend/manual/tools/en/assistant-usage-policy.md +46 -0
- package/dist/templates/backend/manual/tools/en/assistant-usage.md +28 -0
- package/dist/templates/backend/manual/tools/en/file-storage.md +83 -0
- package/dist/templates/backend/manual/tools/es/assistant-conversation.md +38 -0
- package/dist/templates/backend/manual/tools/es/assistant-usage-policy.md +46 -0
- package/dist/templates/backend/manual/tools/es/assistant-usage.md +28 -0
- package/dist/templates/backend/manual/tools/es/file-storage.md +83 -0
- package/dist/templates/backend/packages/business-partner-portal/src/@app/business-partner-portal/anthropic/infrastructure/business-partner-portal-anthropic-extraction-step-two.service.spec.ts +2 -1
- package/dist/templates/backend/packages/business-partner-portal/src/@app/business-partner-portal/anthropic/shared/functions/business-partner-portal-anthropic-build-step-one-request.function.spec.ts +9 -2
- package/dist/templates/backend/packages/business-partner-portal/src/@app/business-partner-portal/anthropic/shared/functions/business-partner-portal-anthropic-build-step-one-request.function.ts +6 -3
- package/dist/templates/backend/packages/business-partner-portal/src/@app/business-partner-portal/anthropic/shared/functions/business-partner-portal-anthropic-build-step-two-request.function.spec.ts +19 -2
- package/dist/templates/backend/packages/business-partner-portal/src/@app/business-partner-portal/anthropic/shared/functions/business-partner-portal-anthropic-build-step-two-request.function.ts +15 -2
- package/dist/templates/backend/packages/business-partner-portal/src/@app/business-partner-portal/anthropic/shared/functions/business-partner-portal-anthropic-map-step-one-answer.function.ts +1 -1
- package/dist/templates/backend/packages/business-partner-portal/src/@app/business-partner-portal/anthropic/shared/types/business-partner-portal-anthropic-step-one-answer.types.ts +1 -1
- package/dist/templates/backend/packages/business-partner-portal/src/@app/business-partner-portal/shared/extraction-step-two/business-partner-portal-extraction-step-two-context.service.spec.ts +63 -0
- package/dist/templates/backend/packages/business-partner-portal/src/@app/business-partner-portal/shared/extraction-step-two/business-partner-portal-extraction-step-two-context.service.ts +25 -3
- package/dist/templates/backend/packages/business-partner-portal/src/@app/business-partner-portal/shared/extraction-step-two/business-partner-portal-extraction-step-two-empty.service.spec.ts +1 -0
- package/dist/templates/backend/packages/business-partner-portal/src/@app/business-partner-portal/shared/extraction-step-two/business-partner-portal-extraction-step-two.types.ts +5 -0
- package/dist/templates/backend/packages/business-partner-portal/src/@app/business-partner-portal/shared/purchase-invoice-extraction/business-partner-portal-map-invoice-ocr-result-to-purchase-invoice.function.spec.ts +1 -1
- package/dist/templates/backend/packages/business-partner-portal/src/@app/business-partner-portal/shared/purchase-invoice-extraction/business-partner-portal-map-invoice-ocr-result-to-purchase-invoice.function.ts +1 -1
- package/dist/templates/backend/packages/production-planning/src/@app/production-planning/production-order-position/application/get-processes/production-planning-get-processes-production-order-position.handler.spec.ts +5 -2
- package/dist/templates/backend/packages/production-planning/src/@app/production-planning/production-order-position/application/get-processes/production-planning-get-processes-production-order-position.handler.ts +4 -0
- package/dist/templates/backend/packages/reporting/src/@api/reporting/report/dto/reporting-create-report.dto.ts +0 -21
- package/dist/templates/backend/packages/reporting/src/@api/reporting/report/dto/reporting-report.dto.ts +3 -3
- package/dist/templates/backend/packages/reporting/src/@api/reporting/report/dto/reporting-update-report-by-id.dto.ts +0 -48
- package/dist/templates/backend/packages/reporting/src/@api/reporting/report/dto/reporting-update-reports.dto.ts +0 -48
- package/dist/templates/backend/packages/reporting/src/@api/reporting/report/graphql/reporting-report.graphql +3 -20
- package/dist/templates/backend/packages/reporting/src/@app/reporting/report/application/create/reporting-create-report.service.ts +2 -2
- package/dist/templates/backend/packages/reporting/src/@app/reporting/report/application/reporting-report.payload-types.ts +33 -0
- package/dist/templates/backend/packages/reporting/src/@app/reporting/report/application/update/reporting-update-report-by-id.handler.spec.ts +77 -0
- package/dist/templates/backend/packages/reporting/src/@app/reporting/report/application/update/reporting-update-report-by-id.service.ts +2 -2
- package/dist/templates/backend/packages/reporting/src/@app/reporting/report/application/update/reporting-update-reports.service.ts +2 -2
- package/dist/templates/backend/packages/reporting/src/@app/reporting/report/application/update-execution-cache/reporting-update-report-execution-cache.handler.spec.ts +35 -0
- package/dist/templates/backend/packages/reporting/src/@app/reporting/report/domain/reporting-report.field-schema.ts +7 -0
- package/dist/templates/backend/packages/reporting/src/@app/reporting/report/index.ts +5 -0
- package/dist/templates/backend/packages/tools/src/@api/tools/assistant-conversation/dto/tools-assistant-conversation.dto.ts +8 -1
- package/dist/templates/backend/packages/tools/src/@api/tools/assistant-conversation/dto/tools-update-assistant-conversation-by-id.dto.ts +8 -1
- package/dist/templates/backend/packages/tools/src/@api/tools/assistant-conversation/dto/tools-update-assistant-conversations.dto.ts +8 -1
- package/dist/templates/backend/packages/tools/src/@api/tools/assistant-conversation/graphql/tools-assistant-conversation.graphql +8 -1
- package/dist/templates/backend/packages/tools/src/@api/tools/assistant-usage/controllers/tools-ask-assistant-assistant-usage.controller.ts +1 -0
- package/dist/templates/backend/packages/tools/src/@api/tools/assistant-usage/dto/tools-ask-assistant.dto.ts +47 -0
- package/dist/templates/backend/packages/tools/src/@api/tools/assistant-usage/dto/tools-assistant-answer.dto.ts +1 -0
- package/dist/templates/backend/packages/tools/src/@api/tools/assistant-usage/dto/tools-assistant-usage.dto.ts +8 -1
- package/dist/templates/backend/packages/tools/src/@api/tools/assistant-usage/dto/tools-update-assistant-usage-by-id.dto.ts +8 -1
- package/dist/templates/backend/packages/tools/src/@api/tools/assistant-usage/dto/tools-update-assistant-usages.dto.ts +8 -1
- package/dist/templates/backend/packages/tools/src/@api/tools/assistant-usage/graphql/tools-assistant-usage.graphql +45 -1
- package/dist/templates/backend/packages/tools/src/@api/tools/assistant-usage/resolvers/tools-ask-assistant-assistant-usage.resolver.ts +1 -0
- package/dist/templates/backend/packages/tools/src/@app/tools/anthropic/infrastructure/tools-anthropic-assistant-model.service.spec.ts +1 -0
- package/dist/templates/backend/packages/tools/src/@app/tools/anthropic/shared/functions/tools-anthropic-build-assistant-request.function.spec.ts +145 -0
- package/dist/templates/backend/packages/tools/src/@app/tools/anthropic/shared/functions/tools-anthropic-build-assistant-request.function.ts +44 -2
- package/dist/templates/backend/packages/tools/src/@app/tools/anthropic/shared/types/tools-anthropic-assistant-answer.types.ts +3 -2
- package/dist/templates/backend/packages/tools/src/@app/tools/assistant-conversation/domain/tools-assistant-conversation.field-schema.ts +6 -0
- package/dist/templates/backend/packages/tools/src/@app/tools/assistant-conversation/infrastructure/drizzle/tools-drizzle-assistant-conversation.schema.ts +1 -0
- package/dist/templates/backend/packages/tools/src/@app/tools/assistant-usage/application/ask-assistant/tools-ask-assistant-assistant-usage.handler.spec.ts +105 -5
- package/dist/templates/backend/packages/tools/src/@app/tools/assistant-usage/application/ask-assistant/tools-ask-assistant-assistant-usage.handler.ts +40 -23
- package/dist/templates/backend/packages/tools/src/@app/tools/assistant-usage/application/ask-assistant/tools-assistant-errors.function.ts +8 -0
- package/dist/templates/backend/packages/tools/src/@app/tools/assistant-usage/application/ask-assistant/tools-assistant-read-screen.function.spec.ts +257 -0
- package/dist/templates/backend/packages/tools/src/@app/tools/assistant-usage/application/ask-assistant/tools-assistant-read-screen.function.ts +200 -0
- package/dist/templates/backend/packages/tools/src/@app/tools/assistant-usage/application/quota/tools-assistant-quota.service.spec.ts +7 -2
- package/dist/templates/backend/packages/tools/src/@app/tools/assistant-usage/application/quota/tools-assistant-quota.service.ts +7 -2
- package/dist/templates/backend/packages/tools/src/@app/tools/assistant-usage/domain/tools-assistant-model.port.ts +44 -0
- package/dist/templates/backend/packages/tools/src/@app/tools/assistant-usage/domain/tools-assistant-usage.field-schema.ts +6 -0
- package/dist/templates/backend/packages/tools/src/@app/tools/assistant-usage/infrastructure/drizzle/tools-drizzle-assistant-usage.repository.spec.ts +25 -0
- package/dist/templates/backend/packages/tools/src/@app/tools/assistant-usage/infrastructure/drizzle/tools-drizzle-assistant-usage.repository.ts +3 -0
- package/dist/templates/backend/packages/tools/src/@app/tools/assistant-usage/infrastructure/drizzle/tools-drizzle-assistant-usage.schema.ts +1 -0
- package/dist/templates/backend/packages/tools/test/acceptance/tools/assistant-ask.e2e-spec.ts +16 -1
- package/dist/templates/backend/packages/tools/test/acceptance/tools/assistant-usage-increment.e2e-spec.ts +52 -5
- package/dist/templates/codegen/frontend/module/__module_name__/features/__module_name__-list.component.ts.eta +7 -1
- package/dist/templates/codegen/frontend/module/__module_name__/features/index.ts.eta +1 -1
- package/dist/templates/frontend/application/.claude/skills/catalyst-project-structure/SKILL.md +3 -0
- package/dist/templates/frontend/application/libs/ui/command/src/lib/hlm-command-item.ts +1 -1
- package/dist/templates/frontend/application/src/@aurora/modules/assisted-form/README.md +2 -0
- package/dist/templates/frontend/application/src/@aurora/modules/command-palette/command-palette-trigger.component.ts +1 -0
- package/dist/templates/frontend/application/src/@aurora/modules/guided-action/README.md +4 -0
- package/dist/templates/frontend/application/src/@aurora/modules/guided-action/guided-action-runner.service.spec.ts +69 -0
- package/dist/templates/frontend/application/src/@aurora/modules/guided-action/guided-action-runner.service.ts +13 -4
- package/dist/templates/frontend/application/src/@aurora/modules/index.ts +1 -0
- package/dist/templates/frontend/application/src/@aurora/modules/manual/manual.graphql.ts +1 -0
- package/dist/templates/frontend/application/src/@aurora/modules/screen-context/README.md +36 -0
- package/dist/templates/frontend/application/src/@aurora/modules/screen-context/index.ts +2 -0
- package/dist/templates/frontend/application/src/@aurora/modules/screen-context/screen-context.service.spec.ts +137 -0
- package/dist/templates/frontend/application/src/@aurora/modules/screen-context/screen-context.service.ts +60 -0
- package/dist/templates/frontend/application/src/@aurora/modules/screen-context/screen-context.types.ts +47 -0
- package/dist/templates/frontend/application/src/app/domains/admin/layout/site-header.ts +1 -1
- package/dist/templates/frontend/application/tsconfig.json +1 -0
- package/dist/templates/frontend/navigation-i18n/reporting/en.json +1 -1
- package/dist/templates/frontend/navigation-i18n/reporting/es.json +1 -1
- package/dist/templates/frontend/packages/automation/src/app/domains/admin/apps/automation/state-machine-history/features/index.ts +0 -1
- package/dist/templates/frontend/packages/automation/src/app/domains/admin/apps/automation/state-machine-history/features/state-machine-history-list.component.ts +0 -13
- package/dist/templates/frontend/packages/business-partner-portal/public/i18n/business-partner-portal/en.json +11 -0
- package/dist/templates/frontend/packages/business-partner-portal/public/i18n/business-partner-portal/es.json +11 -0
- package/dist/templates/frontend/packages/business-partner-portal/src/app/domains/admin/apps/business-partner-portal/purchase-invoice-header/data-access/purchase-invoice-review-context.derive.spec.ts +420 -0
- package/dist/templates/frontend/packages/business-partner-portal/src/app/domains/admin/apps/business-partner-portal/purchase-invoice-header/data-access/purchase-invoice-review-context.derive.ts +237 -0
- package/dist/templates/frontend/packages/business-partner-portal/src/app/domains/admin/apps/business-partner-portal/purchase-invoice-header/data-access/purchase-invoice-review.derive.spec.ts +181 -26
- package/dist/templates/frontend/packages/business-partner-portal/src/app/domains/admin/apps/business-partner-portal/purchase-invoice-header/data-access/purchase-invoice-review.derive.ts +143 -25
- package/dist/templates/frontend/packages/business-partner-portal/src/app/domains/admin/apps/business-partner-portal/purchase-invoice-header/features/purchase-invoice-header-detail.component.spec.ts +42 -0
- package/dist/templates/frontend/packages/business-partner-portal/src/app/domains/admin/apps/business-partner-portal/purchase-invoice-header/features/purchase-invoice-header-detail.component.ts +32 -8
- package/dist/templates/frontend/packages/business-partner-portal/src/app/domains/admin/apps/business-partner-portal/purchase-invoice-header/features/purchase-invoice-header-form.component.ts +32 -1
- package/dist/templates/frontend/packages/business-partner-portal/src/app/domains/admin/apps/business-partner-portal/purchase-invoice-header/features/purchase-invoice-header-list-actions-cell.component.ts +4 -1
- package/dist/templates/frontend/packages/business-partner-portal/src/app/domains/admin/apps/business-partner-portal/purchase-invoice-header/ui/purchase-invoice-breakdown.component.ts +7 -32
- package/dist/templates/frontend/packages/business-partner-portal/src/app/domains/admin/apps/business-partner-portal/purchase-invoice-header/ui/purchase-invoice-lines-grid.component.ts +12 -8
- package/dist/templates/frontend/packages/business-partner-portal/src/app/domains/admin/apps/business-partner-portal/purchase-invoice-trace/features/index.ts +0 -1
- package/dist/templates/frontend/packages/business-partner-portal/src/app/domains/admin/apps/business-partner-portal/purchase-invoice-trace/features/purchase-invoice-trace-list.component.ts +0 -13
- package/dist/templates/frontend/packages/identity/src/app/domains/admin/apps/iam/account/features/account-form.component.spec.ts +26 -1
- package/dist/templates/frontend/packages/identity/src/app/domains/admin/apps/iam/account/features/account-form.component.ts +45 -0
- package/dist/templates/frontend/packages/production-planning/public/i18n/production-planning/en.json +15 -4
- package/dist/templates/frontend/packages/production-planning/public/i18n/production-planning/es.json +15 -4
- package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/planner/data-access/index.ts +1 -0
- package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/planner/data-access/planner-process-weights.derive.spec.ts +57 -0
- package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/planner/data-access/planner-process-weights.derive.ts +39 -0
- package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/planner/data-access/planner.derive.spec.ts +15 -0
- package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/planner/data-access/planner.derive.ts +7 -3
- package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/planner/data-access/planner.graphql.ts +23 -0
- package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/planner/features/planner-process-weights-dialog.component.ts +137 -0
- package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/planner/features/planner.component.ts +41 -4
- package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/production-dashboard/data-access/production-dashboard.derive.spec.ts +0 -30
- package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/production-dashboard/data-access/production-dashboard.derive.ts +0 -21
- package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/production-dashboard/data-access/production-dashboard.resolvers.spec.ts +24 -0
- package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/production-dashboard/data-access/production-dashboard.resolvers.ts +3 -1
- package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/production-dashboard/features/batch-detail-sheet.component.ts +22 -10
- package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/production-dashboard/features/event-form-sheet.component.spec.ts +142 -0
- package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/production-dashboard/features/event-form-sheet.component.ts +95 -59
- package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/production-dashboard/features/event-list.component.ts +121 -123
- package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/production-dashboard/features/production-dashboard.component.ts +52 -19
- package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/production-order-position/features/production-order-position-list.component.ts +8 -2
- package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/production-order-position-event/features/production-order-position-event-list.component.ts +4 -0
- package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/production-order-position-event/production-order-position-event.columns.spec.ts +104 -4
- package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/production-order-position-event/production-order-position-event.columns.ts +121 -69
- package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/shared/dialogs/finish-event-dialog.component.ts +3 -3
- package/dist/templates/frontend/packages/production-planning/src/app/domains/admin/apps/production-planning/shared/dialogs/weight-input-dialog.component.ts +3 -3
- package/dist/templates/frontend/packages/reporting/public/i18n/reporting/en.json +1 -1
- package/dist/templates/frontend/packages/reporting/public/i18n/reporting/es.json +1 -1
- package/dist/templates/frontend/packages/reporting/src/app/domains/admin/apps/reporting/report/data-access/report.detail-config.ts +1 -2
- package/dist/templates/frontend/packages/reporting/src/app/domains/admin/apps/reporting/report/data-access/report.graphql.ts +0 -14
- package/dist/templates/frontend/packages/reporting/src/app/domains/admin/apps/reporting/report/features/report-form.component.spec.ts +96 -0
- package/dist/templates/frontend/packages/reporting/src/app/domains/admin/apps/reporting/report/features/report-form.component.ts +46 -69
- package/dist/templates/frontend/packages/reporting/src/app/domains/admin/apps/reporting/report/features/report-list.component.ts +2 -22
- package/dist/templates/frontend/packages/reporting/src/app/domains/admin/apps/reporting/report/report.columns.ts +0 -1
- package/dist/templates/frontend/packages/reporting/src/app/domains/admin/apps/reporting/reporting-icons.providers.ts +2 -1
- package/dist/templates/frontend/packages/reporting/src/app/domains/admin/apps/reporting/reporting.navigation.ts +7 -0
- package/dist/templates/frontend/packages/tools/public/i18n/tools/en.json +4 -2
- package/dist/templates/frontend/packages/tools/public/i18n/tools/es.json +4 -2
- package/dist/templates/frontend/packages/tools/src/app/domains/admin/apps/tools/assistant/tools-assistant.service.spec.ts +82 -7
- package/dist/templates/frontend/packages/tools/src/app/domains/admin/apps/tools/assistant/tools-assistant.service.ts +12 -2
- package/dist/templates/frontend/packages/tools/src/app/domains/admin/apps/tools/assistant-conversation/assistant-conversation.columns.ts +13 -0
- package/dist/templates/frontend/packages/tools/src/app/domains/admin/apps/tools/assistant-conversation/data-access/assistant-conversation.graphql.ts +1 -0
- package/dist/templates/frontend/packages/tools/src/app/domains/admin/apps/tools/assistant-conversation/features/assistant-conversation-form.component.ts +18 -0
- package/dist/templates/frontend/packages/tools/src/app/domains/admin/apps/tools/assistant-conversation/features/assistant-conversation-list.component.ts +0 -13
- package/dist/templates/frontend/packages/tools/src/app/domains/admin/apps/tools/assistant-conversation/features/index.ts +0 -1
- package/dist/templates/frontend/packages/tools/src/app/domains/admin/apps/tools/assistant-usage/assistant-usage.columns.ts +13 -0
- package/dist/templates/frontend/packages/tools/src/app/domains/admin/apps/tools/assistant-usage/data-access/assistant-usage.graphql.ts +2 -0
- package/dist/templates/frontend/packages/tools/src/app/domains/admin/apps/tools/assistant-usage/features/assistant-usage-form.component.ts +18 -0
- package/dist/templates/frontend/packages/tools/src/app/domains/admin/apps/tools/assistant-usage/features/assistant-usage-list.component.ts +0 -13
- package/dist/templates/frontend/packages/tools/src/app/domains/admin/apps/tools/assistant-usage/features/index.ts +0 -1
- package/dist/templates/monorepo/.claude/commands/business-rules/promote.md +5 -1
- package/dist/templates/monorepo/.claude/hooks/__fixtures__/br-hr-regression-baseline.txt +2 -2
- package/dist/templates/monorepo/.claude/hooks/check-required-setup.ts +4 -4
- package/dist/templates/monorepo/.claude/hooks/inject-prompt-context.ts +1 -1
- package/dist/templates/monorepo/.claude/scripts/generate-skills-index.test.ts +29 -1
- package/dist/templates/monorepo/.claude/scripts/generate-skills-index.ts +7 -1
- package/dist/templates/monorepo/.claude/skills/REGISTRY.md +2 -2
- package/dist/templates/monorepo/.claude/skills/catalyst-backlog/SKILL.md +19 -4
- package/dist/templates/monorepo/.claude/skills/catalyst-backlog/frontier-worker-addendum.md +3 -3
- package/dist/templates/monorepo/.claude/skills/catalyst-business-rules-guard/SKILL.md +8 -5
- package/dist/templates/monorepo/.claude/skills/catalyst-business-rules-guard/references/workflow.md +10 -6
- package/dist/templates/monorepo/.claude/skills/catalyst-delegation/SKILL.md +1 -1
- package/dist/templates/monorepo/.claude/skills/catalyst-harness-rules-guard/SKILL.md +6 -6
- package/dist/templates/monorepo/.claude/skills/catalyst-harness-rules-guard/references/enforcement.md +3 -3
- package/dist/templates/monorepo/.claude/skills/catalyst-harness-rules-guard/references/format.md +3 -3
- package/dist/templates/monorepo/.claude/skills/catalyst-update-skill-registry/SKILL.md +4 -4
- package/dist/templates/monorepo/.claude/skills/catalyst-user-manual/SKILL.md +48 -2
- package/dist/templates/monorepo/.claude/skills/openspec-apply-change/SKILL.md +28 -10
- package/dist/templates/monorepo/.claude/skills/openspec-archive-change/SKILL.md +52 -13
- package/dist/templates/monorepo/.claude/skills/openspec-explore/SKILL.md +59 -14
- package/dist/templates/monorepo/.claude/skills/openspec-propose/SKILL.md +38 -12
- package/dist/templates/monorepo/.claude/skills/openspec-sync-specs/SKILL.md +31 -3
- package/dist/templates/monorepo/CLAUDE.md +14 -14
- package/dist/templates/monorepo/docs/business-rules/ARCHITECTURE.md +16 -13
- package/dist/templates/monorepo/docs/business-rules/MIGRATION.md +5 -5
- package/dist/templates/monorepo/docs/manual/en/04-asistente.md +71 -0
- package/dist/templates/monorepo/docs/manual/es/04-asistente.md +71 -0
- package/dist/templates/monorepo/openspec/config.yaml +25 -5
- package/dist/templates/monorepo/package.json +3 -1
- package/dist/templates/monorepo/scripts/backlog/prompt.test.ts +5 -5
- package/dist/templates/monorepo/scripts/backlog/prompt.ts +1 -1
- package/dist/templates/monorepo/scripts/business-rules/audit.ts +1 -1
- package/dist/templates/monorepo/scripts/manual/compile.test.ts +78 -0
- package/dist/templates/monorepo/scripts/manual/compile.ts +36 -9
- package/dist/templates/monorepo/scripts/worktree/prune.test.ts +517 -0
- package/dist/templates/monorepo/scripts/worktree/prune.ts +331 -0
- package/oclif.manifest.json +85 -85
- package/package.json +15 -17
- package/dist/templates/frontend/packages/automation/src/app/domains/admin/apps/automation/state-machine-history/features/state-machine-history-list-actions-cell.component.ts +0 -44
- package/dist/templates/frontend/packages/business-partner-portal/src/app/domains/admin/apps/business-partner-portal/purchase-invoice-trace/features/purchase-invoice-trace-list-actions-cell.component.ts +0 -44
- package/dist/templates/frontend/packages/tools/src/app/domains/admin/apps/tools/assistant-conversation/features/assistant-conversation-list-actions-cell.component.ts +0 -44
- package/dist/templates/frontend/packages/tools/src/app/domains/admin/apps/tools/assistant-usage/features/assistant-usage-list-actions-cell.component.ts +0 -43
- package/dist/templates/monorepo/.claude/commands/opsx/apply.md +0 -184
- package/dist/templates/monorepo/.claude/commands/opsx/archive.md +0 -225
- package/dist/templates/monorepo/.claude/commands/opsx/explore.md +0 -196
- package/dist/templates/monorepo/.claude/commands/opsx/propose.md +0 -145
- package/dist/templates/monorepo/.claude/commands/opsx/sync.md +0 -258
|
@@ -1020,6 +1020,84 @@ export const navigationData = () => ({
|
|
|
1020
1020
|
});
|
|
1021
1021
|
});
|
|
1022
1022
|
|
|
1023
|
+
describe('guided actions detail mode', () => {
|
|
1024
|
+
const actionsPath = 'cliter/alpha/actions.yaml';
|
|
1025
|
+
const modulePath = 'cliter/alpha/widget.module.yaml';
|
|
1026
|
+
|
|
1027
|
+
beforeEach(() => {
|
|
1028
|
+
for (const lang of ['es', 'en']) {
|
|
1029
|
+
write(`cliter/alpha/manual/${lang}/widget.md`, chapter('/alpha/widget', '# Widgets\n\n## Create\n\nText\n'));
|
|
1030
|
+
}
|
|
1031
|
+
write(
|
|
1032
|
+
actionsPath,
|
|
1033
|
+
[
|
|
1034
|
+
'- { id: create-widget, route: /alpha/widget, kind: create, label: { es: Crear, en: Create } }',
|
|
1035
|
+
'- { id: open-widgets, route: /alpha/widget, kind: open, label: { es: Abrir, en: Open } }',
|
|
1036
|
+
'',
|
|
1037
|
+
].join('\n'),
|
|
1038
|
+
);
|
|
1039
|
+
});
|
|
1040
|
+
|
|
1041
|
+
const detailModeOf = async (lang: 'en' | 'es' = 'en', id = 'create-widget'): Promise<unknown> => {
|
|
1042
|
+
const compiled = await compileManual(roots);
|
|
1043
|
+
const action = compiled[lang].sections.flatMap((section) => section.actions).find((candidate) => candidate.id === id);
|
|
1044
|
+
return action && 'detailMode' in action ? action.detailMode : undefined;
|
|
1045
|
+
};
|
|
1046
|
+
|
|
1047
|
+
it('reads dialog from the module front config', async () => {
|
|
1048
|
+
write(modulePath, 'moduleName: widget\nfront:\n detailMode: dialog\n');
|
|
1049
|
+
|
|
1050
|
+
assert.equal(await detailModeOf(), 'dialog');
|
|
1051
|
+
});
|
|
1052
|
+
|
|
1053
|
+
it('reads view when the module declares it', async () => {
|
|
1054
|
+
write(modulePath, 'moduleName: widget\nfront:\n detailMode: view\n');
|
|
1055
|
+
|
|
1056
|
+
assert.equal(await detailModeOf(), 'view');
|
|
1057
|
+
});
|
|
1058
|
+
|
|
1059
|
+
it('falls back to view, the generator default, when the module declares no detail mode', async () => {
|
|
1060
|
+
write(modulePath, 'moduleName: widget\nfront:\n gender: M\n');
|
|
1061
|
+
assert.equal(await detailModeOf(), 'view');
|
|
1062
|
+
|
|
1063
|
+
write(modulePath, 'moduleName: widget\n');
|
|
1064
|
+
assert.equal(await detailModeOf(), 'view');
|
|
1065
|
+
});
|
|
1066
|
+
|
|
1067
|
+
it('declares nothing for a create action whose route has no module YAML', async () => {
|
|
1068
|
+
assert.equal(await detailModeOf(), undefined);
|
|
1069
|
+
});
|
|
1070
|
+
|
|
1071
|
+
it('declares nothing for an open action even when the module declares a mode', async () => {
|
|
1072
|
+
write(modulePath, 'moduleName: widget\nfront:\n detailMode: dialog\n');
|
|
1073
|
+
|
|
1074
|
+
assert.equal(await detailModeOf('en', 'open-widgets'), undefined);
|
|
1075
|
+
});
|
|
1076
|
+
|
|
1077
|
+
it('carries the mode in every language and in the index output', async () => {
|
|
1078
|
+
write(modulePath, 'moduleName: widget\nfront:\n detailMode: dialog\n');
|
|
1079
|
+
|
|
1080
|
+
const compiled = await compileManual(roots);
|
|
1081
|
+
|
|
1082
|
+
for (const lang of ['es', 'en'] as const) {
|
|
1083
|
+
const created = compiled[lang].index.find((entry) => entry.id === 'alpha.widget')?.actions.find((action) => action.id === 'create-widget');
|
|
1084
|
+
assert.equal(created?.detailMode, 'dialog');
|
|
1085
|
+
}
|
|
1086
|
+
});
|
|
1087
|
+
|
|
1088
|
+
it('still fails when the catalog declares a detailMode key', async () => {
|
|
1089
|
+
write(
|
|
1090
|
+
actionsPath,
|
|
1091
|
+
'- { id: create-widget, route: /alpha/widget, kind: create, label: { es: X, en: X }, detailMode: dialog }\n',
|
|
1092
|
+
);
|
|
1093
|
+
|
|
1094
|
+
await assert.rejects(
|
|
1095
|
+
compileManual(roots),
|
|
1096
|
+
(error: Error) => /actions\.yaml/.test(error.message) && error.message.includes('detailMode'),
|
|
1097
|
+
);
|
|
1098
|
+
});
|
|
1099
|
+
});
|
|
1100
|
+
|
|
1023
1101
|
describe('general tours', () => {
|
|
1024
1102
|
const LIST_TOUR = [
|
|
1025
1103
|
'screen: list',
|
|
@@ -49,8 +49,17 @@ export interface ManualAction {
|
|
|
49
49
|
permission: string | null;
|
|
50
50
|
/** Fields the assistant may fill in the creation form, with the values each accepts, computed from the module YAML; empty when nothing is fillable. */
|
|
51
51
|
prefill: ManualPrefillField[];
|
|
52
|
+
/**
|
|
53
|
+
* How the creation form opens, read from `front.detailMode` of the module YAML (`view` when it
|
|
54
|
+
* declares none, the generator's default): `view` is its own page at `<route>/new`, `dialog` a
|
|
55
|
+
* dialog over the list. Only on a `create` action whose route has a module YAML.
|
|
56
|
+
*/
|
|
57
|
+
detailMode?: ManualDetailMode;
|
|
52
58
|
}
|
|
53
59
|
|
|
60
|
+
/** Values of `front.detailMode` in the module YAML. */
|
|
61
|
+
export type ManualDetailMode = 'view' | 'dialog';
|
|
62
|
+
|
|
54
63
|
/** A fillable field and its options as wire strings (`'true'`/`'false'` for a boolean). */
|
|
55
64
|
export interface ManualPrefillField {
|
|
56
65
|
field: string;
|
|
@@ -529,6 +538,27 @@ const ACTION_KINDS: readonly string[] = ['open', 'create'];
|
|
|
529
538
|
/** Property types the assistant can fill; `password` and `encrypted` are never among them. */
|
|
530
539
|
const PREFILL_TYPES: readonly string[] = ['enum', 'boolean'];
|
|
531
540
|
|
|
541
|
+
/**
|
|
542
|
+
* The module YAML behind `route` (`/<bc>/<module>` is `cliter/<bc>/<module>.module.yaml`); `null`
|
|
543
|
+
* for a route with no such file, such as a screen built by hand.
|
|
544
|
+
*/
|
|
545
|
+
const readModuleDefinition = (boundedContextsDir: string, route: string): Record<string, unknown> | null => {
|
|
546
|
+
const [boundedContext, moduleName] = route.split('/').filter(Boolean);
|
|
547
|
+
if (!boundedContext || !moduleName) return null;
|
|
548
|
+
const moduleFile = join(boundedContextsDir, boundedContext, `${moduleName}.module.yaml`);
|
|
549
|
+
if (!existsSync(moduleFile)) return null;
|
|
550
|
+
const definition: unknown = parseYaml(readFileSync(moduleFile, 'utf8'));
|
|
551
|
+
return isRecord(definition) ? definition : null;
|
|
552
|
+
};
|
|
553
|
+
|
|
554
|
+
/**
|
|
555
|
+
* Where the creation form of the module opens: `dialog` only when `front.detailMode` says so, and
|
|
556
|
+
* `view` otherwise, the default the CLI generates (`DETAIL_MODE.VIEW`); the compile infers nothing
|
|
557
|
+
* from the frontend router.
|
|
558
|
+
*/
|
|
559
|
+
const computeDetailMode = (definition: Record<string, unknown>): ManualDetailMode =>
|
|
560
|
+
isRecord(definition.front) && definition.front.detailMode === 'dialog' ? 'dialog' : 'view';
|
|
561
|
+
|
|
532
562
|
/**
|
|
533
563
|
* The fields the assistant may fill in the creation form of `route` (`/<bc>/<module>`), read from
|
|
534
564
|
* `cliter/<bc>/<module>.module.yaml`: the `enum` and `boolean` properties, in declaration order, of a
|
|
@@ -539,14 +569,8 @@ const PREFILL_TYPES: readonly string[] = ['enum', 'boolean'];
|
|
|
539
569
|
* YAML. The flags are compared strictly: the CLI validates them as literal booleans when it loads
|
|
540
570
|
* the module.
|
|
541
571
|
*/
|
|
542
|
-
const computePrefill = (
|
|
543
|
-
|
|
544
|
-
if (!boundedContext || !moduleName) return [];
|
|
545
|
-
const moduleFile = join(boundedContextsDir, boundedContext, `${moduleName}.module.yaml`);
|
|
546
|
-
if (!existsSync(moduleFile)) return [];
|
|
547
|
-
|
|
548
|
-
const definition: unknown = parseYaml(readFileSync(moduleFile, 'utf8'));
|
|
549
|
-
if (!isRecord(definition) || definition.hasAssistant !== true) return [];
|
|
572
|
+
const computePrefill = (definition: Record<string, unknown> | null): ManualPrefillField[] => {
|
|
573
|
+
if (!definition || definition.hasAssistant !== true) return [];
|
|
550
574
|
const properties = Array.isArray(definition.aggregateProperties) ? definition.aggregateProperties : [];
|
|
551
575
|
|
|
552
576
|
return properties
|
|
@@ -615,7 +639,9 @@ const readActions = (
|
|
|
615
639
|
return fail(`${named} needs "tourId" to be a non-empty string`);
|
|
616
640
|
}
|
|
617
641
|
if (!isRecord(raw.label)) return fail(`${named} needs "label" to be a mapping of language to text`);
|
|
618
|
-
const
|
|
642
|
+
const definition = raw.kind === 'create' ? readModuleDefinition(boundedContextsDir, route) : null;
|
|
643
|
+
const prefill = computePrefill(definition);
|
|
644
|
+
const detailMode = definition ? computeDetailMode(definition) : undefined;
|
|
619
645
|
|
|
620
646
|
for (const lang of langs) {
|
|
621
647
|
const label = raw.label[lang];
|
|
@@ -633,6 +659,7 @@ const readActions = (
|
|
|
633
659
|
label: label.trim(),
|
|
634
660
|
permission: entry.permission,
|
|
635
661
|
prefill: prefill.map((entry) => ({ field: entry.field, options: [...entry.options] })),
|
|
662
|
+
...(detailMode ? { detailMode } : {}),
|
|
636
663
|
});
|
|
637
664
|
}
|
|
638
665
|
});
|
|
@@ -0,0 +1,517 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { describe, it } from 'node:test';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
classify,
|
|
6
|
+
run,
|
|
7
|
+
parseWorktreeList,
|
|
8
|
+
type ClassifyInput,
|
|
9
|
+
type Decision,
|
|
10
|
+
type PruneIO,
|
|
11
|
+
type PullRequest,
|
|
12
|
+
type WorktreeEntry,
|
|
13
|
+
} from './prune.ts';
|
|
14
|
+
|
|
15
|
+
const PORCELAIN = [
|
|
16
|
+
'worktree /repo',
|
|
17
|
+
'HEAD aaaaaaa1111111111111111111111111111111aa',
|
|
18
|
+
'branch refs/heads/main',
|
|
19
|
+
'',
|
|
20
|
+
'worktree /repo/.claude/worktrees/T-398',
|
|
21
|
+
'HEAD bbbbbbb2222222222222222222222222222222bb',
|
|
22
|
+
'branch refs/heads/task/T-398',
|
|
23
|
+
'',
|
|
24
|
+
'worktree /repo/.claude/worktrees/dispatch-a',
|
|
25
|
+
'HEAD ccccccc3333333333333333333333333333333cc',
|
|
26
|
+
'detached',
|
|
27
|
+
'',
|
|
28
|
+
].join('\n');
|
|
29
|
+
|
|
30
|
+
describe('parseWorktreeList', () => {
|
|
31
|
+
it('reads path, head and branch name without the refs/heads/ prefix', () => {
|
|
32
|
+
const [main, second] = parseWorktreeList(PORCELAIN);
|
|
33
|
+
assert.deepEqual(main, {
|
|
34
|
+
path: '/repo',
|
|
35
|
+
head: 'aaaaaaa1111111111111111111111111111111aa',
|
|
36
|
+
branch: 'main',
|
|
37
|
+
prunable: false,
|
|
38
|
+
locked: false,
|
|
39
|
+
});
|
|
40
|
+
assert.equal(second.path, '/repo/.claude/worktrees/T-398');
|
|
41
|
+
assert.equal(second.branch, 'task/T-398');
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('reports a detached HEAD as a null branch', () => {
|
|
45
|
+
const entries = parseWorktreeList(PORCELAIN);
|
|
46
|
+
assert.equal(entries[2].branch, null);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('reads the prunable and locked markers', () => {
|
|
50
|
+
const entries = parseWorktreeList(
|
|
51
|
+
[
|
|
52
|
+
'worktree /repo',
|
|
53
|
+
'HEAD a',
|
|
54
|
+
'branch refs/heads/main',
|
|
55
|
+
'',
|
|
56
|
+
'worktree /repo/.claude/worktrees/gone',
|
|
57
|
+
'HEAD b',
|
|
58
|
+
'branch refs/heads/task/T-1',
|
|
59
|
+
'prunable gitdir file points to non-existent location',
|
|
60
|
+
'',
|
|
61
|
+
'worktree /repo/.claude/worktrees/pinned',
|
|
62
|
+
'HEAD c',
|
|
63
|
+
'branch refs/heads/task/T-2',
|
|
64
|
+
'locked reason',
|
|
65
|
+
'',
|
|
66
|
+
].join('\n'),
|
|
67
|
+
);
|
|
68
|
+
assert.equal(entries[1].prunable, true);
|
|
69
|
+
assert.equal(entries[1].locked, false);
|
|
70
|
+
assert.equal(entries[2].locked, true);
|
|
71
|
+
assert.equal(entries[2].prunable, false);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('keeps the entry order, so the first one is the main checkout', () => {
|
|
75
|
+
const entries = parseWorktreeList(PORCELAIN);
|
|
76
|
+
assert.deepEqual(
|
|
77
|
+
entries.map((entry) => entry.path),
|
|
78
|
+
['/repo', '/repo/.claude/worktrees/T-398', '/repo/.claude/worktrees/dispatch-a'],
|
|
79
|
+
);
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const MAIN_ROOT = '/repo';
|
|
84
|
+
const WORKTREES_DIR = '/repo/.claude/worktrees';
|
|
85
|
+
|
|
86
|
+
const mainCheckout: WorktreeEntry = { path: MAIN_ROOT, head: 'main0000', branch: 'main', prunable: false, locked: false };
|
|
87
|
+
|
|
88
|
+
function worktree(name: string, branch: string | null, head = 'e3bcc6c'): WorktreeEntry {
|
|
89
|
+
return { path: `${WORKTREES_DIR}/${name}`, head, branch, prunable: false, locked: false };
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function pr(number: number, state: PullRequest['state'], branch: string, headRefOid = 'e3bcc6c'): PullRequest {
|
|
93
|
+
return { number, state, headRefName: branch, headRefOid };
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function input(overrides: Partial<ClassifyInput>): ClassifyInput {
|
|
97
|
+
return {
|
|
98
|
+
worktrees: [mainCheckout],
|
|
99
|
+
branches: [{ name: 'main', head: 'main0000' }],
|
|
100
|
+
dirtyPaths: [],
|
|
101
|
+
pullRequests: [],
|
|
102
|
+
currentRoot: MAIN_ROOT,
|
|
103
|
+
defaultBranch: 'main',
|
|
104
|
+
...overrides,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function only(decisions: Decision[]): Decision {
|
|
109
|
+
assert.equal(decisions.length, 1, `expected one decision, got ${JSON.stringify(decisions)}`);
|
|
110
|
+
return decisions[0];
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
describe('classify - worktrees', () => {
|
|
114
|
+
const wt = worktree('T-398', 'task/T-398');
|
|
115
|
+
|
|
116
|
+
it('removes a worktree whose PR is merged, head matches and tree is clean', () => {
|
|
117
|
+
const decision = only(
|
|
118
|
+
classify(input({ worktrees: [mainCheckout, wt], pullRequests: [pr(706, 'MERGED', 'task/T-398')] })),
|
|
119
|
+
);
|
|
120
|
+
assert.equal(decision.kind, 'worktree');
|
|
121
|
+
assert.equal(decision.action, 'remove');
|
|
122
|
+
assert.equal(decision.target, wt.path);
|
|
123
|
+
assert.equal(decision.branch, 'task/T-398');
|
|
124
|
+
assert.equal(decision.prNumber, 706);
|
|
125
|
+
assert.match(decision.reason, /#706/);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it('keeps it when the local head differs from the merged PR head (commits after the merge)', () => {
|
|
129
|
+
const decision = only(
|
|
130
|
+
classify(
|
|
131
|
+
input({ worktrees: [mainCheckout, wt], pullRequests: [pr(706, 'MERGED', 'task/T-398', 'otherhead')] }),
|
|
132
|
+
),
|
|
133
|
+
);
|
|
134
|
+
assert.equal(decision.action, 'keep');
|
|
135
|
+
assert.match(decision.reason, /commits after the merge/);
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it('keeps it when the tree has uncommitted or untracked changes', () => {
|
|
139
|
+
const decision = only(
|
|
140
|
+
classify(
|
|
141
|
+
input({
|
|
142
|
+
worktrees: [mainCheckout, wt],
|
|
143
|
+
dirtyPaths: [wt.path],
|
|
144
|
+
pullRequests: [pr(706, 'MERGED', 'task/T-398')],
|
|
145
|
+
}),
|
|
146
|
+
),
|
|
147
|
+
);
|
|
148
|
+
assert.equal(decision.action, 'keep');
|
|
149
|
+
assert.match(decision.reason, /uncommitted changes/);
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
it('keeps it when the PR is open', () => {
|
|
153
|
+
const decision = only(
|
|
154
|
+
classify(input({ worktrees: [mainCheckout, wt], pullRequests: [pr(611, 'OPEN', 'task/T-398')] })),
|
|
155
|
+
);
|
|
156
|
+
assert.equal(decision.action, 'keep');
|
|
157
|
+
assert.match(decision.reason, /pull request is open/);
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
it('keeps it when the only PR was closed without merge', () => {
|
|
161
|
+
const decision = only(
|
|
162
|
+
classify(input({ worktrees: [mainCheckout, wt], pullRequests: [pr(5, 'CLOSED', 'task/T-398')] })),
|
|
163
|
+
);
|
|
164
|
+
assert.equal(decision.action, 'keep');
|
|
165
|
+
assert.match(decision.reason, /closed without merge/);
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
it('keeps it when the branch has no PR', () => {
|
|
169
|
+
const decision = only(classify(input({ worktrees: [mainCheckout, wt] })));
|
|
170
|
+
assert.equal(decision.action, 'keep');
|
|
171
|
+
assert.match(decision.reason, /no pull request/);
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
it('ignores PRs of other branches', () => {
|
|
175
|
+
const decision = only(
|
|
176
|
+
classify(input({ worktrees: [mainCheckout, wt], pullRequests: [pr(9, 'MERGED', 'task/T-1')] })),
|
|
177
|
+
);
|
|
178
|
+
assert.equal(decision.action, 'keep');
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
it('does not list dispatcher slots, detached worktrees, worktrees outside .claude/worktrees or the main checkout', () => {
|
|
182
|
+
const decisions = classify(
|
|
183
|
+
input({
|
|
184
|
+
worktrees: [
|
|
185
|
+
mainCheckout,
|
|
186
|
+
worktree('dispatch-a', null),
|
|
187
|
+
worktree('dispatch-b', 'task/T-7'),
|
|
188
|
+
worktree('detached-one', null),
|
|
189
|
+
{ path: '/elsewhere/other', head: 'e3bcc6c', branch: 'task/T-8', prunable: false, locked: false },
|
|
190
|
+
{ path: `${MAIN_ROOT}/.claude/worktrees-old/x`, head: 'e3bcc6c', branch: 'task/T-9', prunable: false, locked: false },
|
|
191
|
+
],
|
|
192
|
+
pullRequests: [pr(1, 'MERGED', 'task/T-7'), pr(2, 'MERGED', 'task/T-8'), pr(3, 'MERGED', 'task/T-9')],
|
|
193
|
+
}),
|
|
194
|
+
);
|
|
195
|
+
assert.deepEqual(
|
|
196
|
+
decisions.filter((decision) => decision.kind === 'worktree'),
|
|
197
|
+
[],
|
|
198
|
+
);
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
it('keeps a prunable worktree (directory missing) and never removes it', () => {
|
|
202
|
+
const gone: WorktreeEntry = { ...wt, prunable: true };
|
|
203
|
+
const decision = only(
|
|
204
|
+
classify(input({ worktrees: [mainCheckout, gone], pullRequests: [pr(706, 'MERGED', 'task/T-398')] })),
|
|
205
|
+
);
|
|
206
|
+
assert.equal(decision.action, 'keep');
|
|
207
|
+
assert.match(decision.reason, /directory is missing/);
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
it('keeps the worktree the command runs from, even when it qualifies', () => {
|
|
211
|
+
const decision = only(
|
|
212
|
+
classify(
|
|
213
|
+
input({
|
|
214
|
+
worktrees: [mainCheckout, wt],
|
|
215
|
+
currentRoot: wt.path,
|
|
216
|
+
pullRequests: [pr(706, 'MERGED', 'task/T-398')],
|
|
217
|
+
}),
|
|
218
|
+
),
|
|
219
|
+
);
|
|
220
|
+
assert.equal(decision.action, 'keep');
|
|
221
|
+
assert.match(decision.reason, /command runs from it/);
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
it('an OPEN PR wins over a merged one for the same branch', () => {
|
|
225
|
+
const decision = only(
|
|
226
|
+
classify(
|
|
227
|
+
input({
|
|
228
|
+
worktrees: [mainCheckout, wt],
|
|
229
|
+
pullRequests: [pr(700, 'MERGED', 'task/T-398'), pr(650, 'OPEN', 'task/T-398')],
|
|
230
|
+
}),
|
|
231
|
+
),
|
|
232
|
+
);
|
|
233
|
+
assert.equal(decision.action, 'keep');
|
|
234
|
+
assert.match(decision.reason, /pull request is open/);
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
it('without an open PR the highest number decides: merged latest removes', () => {
|
|
238
|
+
const decision = only(
|
|
239
|
+
classify(
|
|
240
|
+
input({
|
|
241
|
+
worktrees: [mainCheckout, wt],
|
|
242
|
+
pullRequests: [pr(700, 'CLOSED', 'task/T-398'), pr(710, 'MERGED', 'task/T-398')],
|
|
243
|
+
}),
|
|
244
|
+
),
|
|
245
|
+
);
|
|
246
|
+
assert.equal(decision.action, 'remove');
|
|
247
|
+
assert.equal(decision.prNumber, 710);
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
it('without an open PR the highest number decides: closed latest keeps', () => {
|
|
251
|
+
const decision = only(
|
|
252
|
+
classify(
|
|
253
|
+
input({
|
|
254
|
+
worktrees: [mainCheckout, wt],
|
|
255
|
+
pullRequests: [pr(700, 'MERGED', 'task/T-398'), pr(710, 'CLOSED', 'task/T-398')],
|
|
256
|
+
}),
|
|
257
|
+
),
|
|
258
|
+
);
|
|
259
|
+
assert.equal(decision.action, 'keep');
|
|
260
|
+
assert.match(decision.reason, /closed without merge/);
|
|
261
|
+
});
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
describe('classify - orphan branches', () => {
|
|
265
|
+
it('removes a merged local branch with no worktree when the head matches', () => {
|
|
266
|
+
const decision = only(
|
|
267
|
+
classify(
|
|
268
|
+
input({
|
|
269
|
+
branches: [
|
|
270
|
+
{ name: 'main', head: 'main0000' },
|
|
271
|
+
{ name: 'feat/bpp', head: 'e3bcc6c' },
|
|
272
|
+
],
|
|
273
|
+
pullRequests: [pr(649, 'MERGED', 'feat/bpp')],
|
|
274
|
+
}),
|
|
275
|
+
),
|
|
276
|
+
);
|
|
277
|
+
assert.equal(decision.kind, 'branch');
|
|
278
|
+
assert.equal(decision.action, 'remove');
|
|
279
|
+
assert.equal(decision.target, 'feat/bpp');
|
|
280
|
+
assert.match(decision.reason, /#649/);
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
it('keeps a merged orphan branch whose head differs from the PR head', () => {
|
|
284
|
+
const decision = only(
|
|
285
|
+
classify(
|
|
286
|
+
input({
|
|
287
|
+
branches: [{ name: 'feat/bpp', head: 'later' }],
|
|
288
|
+
pullRequests: [pr(649, 'MERGED', 'feat/bpp')],
|
|
289
|
+
}),
|
|
290
|
+
),
|
|
291
|
+
);
|
|
292
|
+
assert.equal(decision.action, 'keep');
|
|
293
|
+
assert.match(decision.reason, /commits after the merge/);
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
it('keeps an orphan branch with an open PR, a closed PR or no PR', () => {
|
|
297
|
+
const decisions = classify(
|
|
298
|
+
input({
|
|
299
|
+
branches: [
|
|
300
|
+
{ name: 'a', head: 'e3bcc6c' },
|
|
301
|
+
{ name: 'b', head: 'e3bcc6c' },
|
|
302
|
+
{ name: 'c', head: 'e3bcc6c' },
|
|
303
|
+
],
|
|
304
|
+
pullRequests: [pr(1, 'OPEN', 'a'), pr(2, 'CLOSED', 'b')],
|
|
305
|
+
}),
|
|
306
|
+
);
|
|
307
|
+
assert.deepEqual(
|
|
308
|
+
decisions.map((decision) => decision.action),
|
|
309
|
+
['keep', 'keep', 'keep'],
|
|
310
|
+
);
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
it('never lists the default branch, even when the main checkout sits on another branch', () => {
|
|
314
|
+
const decisions = classify(
|
|
315
|
+
input({
|
|
316
|
+
worktrees: [{ ...mainCheckout, branch: 'chore/housekeeping' }],
|
|
317
|
+
branches: [
|
|
318
|
+
{ name: 'main', head: 'main0000' },
|
|
319
|
+
{ name: 'chore/housekeeping', head: 'x' },
|
|
320
|
+
],
|
|
321
|
+
pullRequests: [pr(1, 'MERGED', 'main', 'main0000')],
|
|
322
|
+
}),
|
|
323
|
+
);
|
|
324
|
+
assert.deepEqual(decisions, []);
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
it('never lists a branch checked out in any worktree as an orphan, including dispatcher slots', () => {
|
|
328
|
+
const decisions = classify(
|
|
329
|
+
input({
|
|
330
|
+
worktrees: [mainCheckout, worktree('dispatch-a', 'task/T-7'), worktree('T-398', 'task/T-398')],
|
|
331
|
+
branches: [
|
|
332
|
+
{ name: 'task/T-7', head: 'e3bcc6c' },
|
|
333
|
+
{ name: 'task/T-398', head: 'e3bcc6c' },
|
|
334
|
+
],
|
|
335
|
+
pullRequests: [pr(1, 'MERGED', 'task/T-7'), pr(2, 'MERGED', 'task/T-398')],
|
|
336
|
+
}),
|
|
337
|
+
);
|
|
338
|
+
assert.equal(decisions.filter((decision) => decision.kind === 'branch').length, 0);
|
|
339
|
+
assert.equal(decisions.length, 1);
|
|
340
|
+
});
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
interface FakeIO extends PruneIO {
|
|
344
|
+
calls: string[];
|
|
345
|
+
lines: string[];
|
|
346
|
+
errors: string[];
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
function fakeIO(overrides: Partial<PruneIO> = {}): FakeIO {
|
|
350
|
+
const calls: string[] = [];
|
|
351
|
+
const lines: string[] = [];
|
|
352
|
+
const errors: string[] = [];
|
|
353
|
+
return {
|
|
354
|
+
calls,
|
|
355
|
+
lines,
|
|
356
|
+
errors,
|
|
357
|
+
listWorktreesPorcelain: () =>
|
|
358
|
+
[
|
|
359
|
+
`worktree ${MAIN_ROOT}`,
|
|
360
|
+
'HEAD main0000',
|
|
361
|
+
'branch refs/heads/main',
|
|
362
|
+
'',
|
|
363
|
+
`worktree ${WORKTREES_DIR}/T-398`,
|
|
364
|
+
'HEAD e3bcc6c',
|
|
365
|
+
'branch refs/heads/task/T-398',
|
|
366
|
+
'',
|
|
367
|
+
`worktree ${WORKTREES_DIR}/T-399`,
|
|
368
|
+
'HEAD e3bcc6d',
|
|
369
|
+
'branch refs/heads/task/T-399',
|
|
370
|
+
'',
|
|
371
|
+
].join('\n'),
|
|
372
|
+
listLocalBranches: () => [
|
|
373
|
+
{ name: 'main', head: 'main0000' },
|
|
374
|
+
{ name: 'task/T-398', head: 'e3bcc6c' },
|
|
375
|
+
{ name: 'task/T-399', head: 'e3bcc6d' },
|
|
376
|
+
{ name: 'feat/bpp', head: 'e3bcc6c' },
|
|
377
|
+
],
|
|
378
|
+
isDirty: () => false,
|
|
379
|
+
listPullRequests: () => [
|
|
380
|
+
pr(706, 'MERGED', 'task/T-398'),
|
|
381
|
+
pr(649, 'MERGED', 'feat/bpp'),
|
|
382
|
+
pr(800, 'OPEN', 'task/T-399'),
|
|
383
|
+
],
|
|
384
|
+
currentRoot: () => MAIN_ROOT,
|
|
385
|
+
removeWorktree: (path) => calls.push(`worktree remove ${path}`),
|
|
386
|
+
deleteBranch: (name) => calls.push(`branch -D ${name}`),
|
|
387
|
+
pruneWorktrees: () => calls.push('worktree prune'),
|
|
388
|
+
log: (line) => lines.push(line),
|
|
389
|
+
error: (line) => errors.push(line),
|
|
390
|
+
...overrides,
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
describe('run', () => {
|
|
395
|
+
it('fails with a non-zero exit and removes nothing when the pull requests cannot be read', () => {
|
|
396
|
+
const io = fakeIO({
|
|
397
|
+
listPullRequests: () => {
|
|
398
|
+
throw new Error('gh: not logged in');
|
|
399
|
+
},
|
|
400
|
+
});
|
|
401
|
+
const exitCode = run(['--yes'], io);
|
|
402
|
+
assert.equal(exitCode, 1);
|
|
403
|
+
assert.deepEqual(io.calls, []);
|
|
404
|
+
assert.ok(io.errors.some((line) => line.includes('gh: not logged in')));
|
|
405
|
+
});
|
|
406
|
+
|
|
407
|
+
it('dry run lists decisions and calls no removal', () => {
|
|
408
|
+
const io = fakeIO();
|
|
409
|
+
const exitCode = run([], io);
|
|
410
|
+
assert.equal(exitCode, 0);
|
|
411
|
+
assert.deepEqual(io.calls, []);
|
|
412
|
+
assert.ok(io.lines.some((line) => line.includes('remove') && line.includes('worktree') && line.includes('#706')));
|
|
413
|
+
assert.ok(io.lines.some((line) => line.includes('remove') && line.includes('feat/bpp') && line.includes('#649')));
|
|
414
|
+
assert.ok(io.lines.some((line) => line.includes('keep') && line.includes('T-399') && line.includes('#800')));
|
|
415
|
+
});
|
|
416
|
+
|
|
417
|
+
it('with --yes removes the worktree, then its branch, then the orphan branch, then prunes', () => {
|
|
418
|
+
const io = fakeIO();
|
|
419
|
+
const exitCode = run(['--yes'], io);
|
|
420
|
+
assert.equal(exitCode, 0);
|
|
421
|
+
assert.deepEqual(io.calls, [
|
|
422
|
+
`worktree remove ${WORKTREES_DIR}/T-398`,
|
|
423
|
+
'branch -D task/T-398',
|
|
424
|
+
'branch -D feat/bpp',
|
|
425
|
+
'worktree prune',
|
|
426
|
+
]);
|
|
427
|
+
});
|
|
428
|
+
|
|
429
|
+
it('reports a failed removal, skips that branch, continues and exits non-zero', () => {
|
|
430
|
+
const io = fakeIO({
|
|
431
|
+
removeWorktree: (path) => {
|
|
432
|
+
throw new Error(`cannot remove ${path}`);
|
|
433
|
+
},
|
|
434
|
+
});
|
|
435
|
+
const exitCode = run(['--yes'], io);
|
|
436
|
+
assert.equal(exitCode, 1);
|
|
437
|
+
assert.ok(!io.calls.includes('branch -D task/T-398'));
|
|
438
|
+
assert.ok(io.calls.includes('branch -D feat/bpp'));
|
|
439
|
+
assert.ok(io.errors.some((line) => line.includes('cannot remove') && line.includes('T-398')));
|
|
440
|
+
});
|
|
441
|
+
|
|
442
|
+
it('never dirty-checks prunable worktrees, dispatcher slots or the current worktree, and still lists the rest', () => {
|
|
443
|
+
const checked: string[] = [];
|
|
444
|
+
const io = fakeIO({
|
|
445
|
+
listWorktreesPorcelain: () =>
|
|
446
|
+
[
|
|
447
|
+
`worktree ${MAIN_ROOT}`,
|
|
448
|
+
'HEAD main0000',
|
|
449
|
+
'branch refs/heads/main',
|
|
450
|
+
'',
|
|
451
|
+
`worktree ${WORKTREES_DIR}/gone`,
|
|
452
|
+
'HEAD e3bcc6c',
|
|
453
|
+
'branch refs/heads/task/T-1',
|
|
454
|
+
'prunable gitdir file points to non-existent location',
|
|
455
|
+
'',
|
|
456
|
+
`worktree ${WORKTREES_DIR}/dispatch-a`,
|
|
457
|
+
'HEAD e3bcc6c',
|
|
458
|
+
'detached',
|
|
459
|
+
'',
|
|
460
|
+
`worktree ${WORKTREES_DIR}/T-398`,
|
|
461
|
+
'HEAD e3bcc6c',
|
|
462
|
+
'branch refs/heads/task/T-398',
|
|
463
|
+
'',
|
|
464
|
+
`worktree ${WORKTREES_DIR}/T-399`,
|
|
465
|
+
'HEAD e3bcc6d',
|
|
466
|
+
'branch refs/heads/task/T-399',
|
|
467
|
+
'',
|
|
468
|
+
].join('\n'),
|
|
469
|
+
currentRoot: () => `${WORKTREES_DIR}/T-399`,
|
|
470
|
+
isDirty: (path) => {
|
|
471
|
+
checked.push(path);
|
|
472
|
+
if (path.endsWith('/gone') || path.includes('dispatch-') || path.endsWith('/T-399')) {
|
|
473
|
+
throw new Error(`ENOENT ${path}`);
|
|
474
|
+
}
|
|
475
|
+
return false;
|
|
476
|
+
},
|
|
477
|
+
});
|
|
478
|
+
const exitCode = run([], io);
|
|
479
|
+
assert.equal(exitCode, 0);
|
|
480
|
+
assert.deepEqual(checked, [`${WORKTREES_DIR}/T-398`]);
|
|
481
|
+
assert.ok(io.lines.some((line) => line.includes('remove') && line.includes('T-398')));
|
|
482
|
+
assert.ok(io.lines.some((line) => line.includes('keep') && line.includes('gone') && line.includes('directory is missing')));
|
|
483
|
+
});
|
|
484
|
+
|
|
485
|
+
it('fails with a non-zero exit and removes nothing when git cannot list the worktrees', () => {
|
|
486
|
+
const io = fakeIO({
|
|
487
|
+
listWorktreesPorcelain: () => {
|
|
488
|
+
throw new Error('git: not a repository');
|
|
489
|
+
},
|
|
490
|
+
});
|
|
491
|
+
assert.equal(run(['--yes'], io), 1);
|
|
492
|
+
assert.deepEqual(io.calls, []);
|
|
493
|
+
});
|
|
494
|
+
|
|
495
|
+
it('fails with a non-zero exit and removes nothing when a candidate dirty check throws', () => {
|
|
496
|
+
const io = fakeIO({
|
|
497
|
+
isDirty: () => {
|
|
498
|
+
throw new Error('git status failed');
|
|
499
|
+
},
|
|
500
|
+
});
|
|
501
|
+
assert.equal(run(['--yes'], io), 1);
|
|
502
|
+
assert.deepEqual(io.calls, []);
|
|
503
|
+
});
|
|
504
|
+
|
|
505
|
+
it('keeps the worktree it runs from', () => {
|
|
506
|
+
const io = fakeIO({ currentRoot: () => `${WORKTREES_DIR}/T-398` });
|
|
507
|
+
run(['--yes'], io);
|
|
508
|
+
assert.ok(!io.calls.includes(`worktree remove ${WORKTREES_DIR}/T-398`));
|
|
509
|
+
});
|
|
510
|
+
|
|
511
|
+
it('rejects an unknown argument without touching anything', () => {
|
|
512
|
+
const io = fakeIO();
|
|
513
|
+
const exitCode = run(['--force'], io);
|
|
514
|
+
assert.equal(exitCode, 1);
|
|
515
|
+
assert.deepEqual(io.calls, []);
|
|
516
|
+
});
|
|
517
|
+
});
|