@mastra/factory 0.28.0-alpha.2 → 0.28.0-alpha.4
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 +329 -154
- package/dist/boards/board-events.d.ts +23 -3
- package/dist/boards/board-events.d.ts.map +1 -1
- package/dist/boards/board-events.js +44 -7
- package/dist/boards/board-events.js.map +1 -1
- package/dist/boards/board-writes.d.ts +1 -1
- package/dist/boards/board-writes.d.ts.map +1 -1
- package/dist/boards/board-writes.js +16 -1
- package/dist/boards/board-writes.js.map +1 -1
- package/dist/boards/card-facts.d.ts +3 -1
- package/dist/boards/card-facts.d.ts.map +1 -1
- package/dist/boards/card-facts.js +30 -4
- package/dist/boards/card-facts.js.map +1 -1
- package/dist/boards/default-board.d.ts +7 -0
- package/dist/boards/default-board.d.ts.map +1 -0
- package/dist/boards/default-board.js +10 -0
- package/dist/boards/default-board.js.map +1 -0
- package/dist/boards/define-board.d.ts +40 -18
- package/dist/boards/define-board.d.ts.map +1 -1
- package/dist/boards/define-board.js +64 -42
- package/dist/boards/define-board.js.map +1 -1
- package/dist/boards/index.d.ts +5 -8
- package/dist/boards/index.d.ts.map +1 -1
- package/dist/boards/index.js +5 -19
- package/dist/boards/intake-routing.d.ts +29 -9
- package/dist/boards/intake-routing.d.ts.map +1 -1
- package/dist/boards/intake-routing.js +72 -20
- package/dist/boards/intake-routing.js.map +1 -1
- package/dist/boards/legacy-plan-role.d.ts.map +1 -1
- package/dist/boards/legacy-plan-role.js +7 -2
- package/dist/boards/legacy-plan-role.js.map +1 -1
- package/dist/boards/phase-automation.d.ts +7 -0
- package/dist/boards/phase-automation.d.ts.map +1 -1
- package/dist/boards/phase-automation.js +16 -5
- package/dist/boards/phase-automation.js.map +1 -1
- package/dist/boards/phase-runner.d.ts +18 -10
- package/dist/boards/phase-runner.d.ts.map +1 -1
- package/dist/boards/phase-runner.js +39 -34
- package/dist/boards/phase-runner.js.map +1 -1
- package/dist/boards/project-boards.d.ts +27 -7
- package/dist/boards/project-boards.d.ts.map +1 -1
- package/dist/boards/project-boards.js +94 -19
- package/dist/boards/project-boards.js.map +1 -1
- package/dist/boards/registry.d.ts.map +1 -1
- package/dist/boards/registry.js +3 -1
- package/dist/boards/registry.js.map +1 -1
- package/dist/boards/relocate.d.ts +1 -1
- package/dist/boards/relocate.d.ts.map +1 -1
- package/dist/boards/relocate.js +3 -2
- package/dist/boards/relocate.js.map +1 -1
- package/dist/boards/review.d.ts +5 -2
- package/dist/boards/review.d.ts.map +1 -1
- package/dist/boards/review.js +12 -11
- package/dist/boards/review.js.map +1 -1
- package/dist/boards/semantics.d.ts +159 -20
- package/dist/boards/semantics.d.ts.map +1 -1
- package/dist/boards/semantics.js +254 -23
- package/dist/boards/semantics.js.map +1 -1
- package/dist/boards/stored-board.d.ts +32 -18
- package/dist/boards/stored-board.d.ts.map +1 -1
- package/dist/boards/stored-board.js +31 -97
- package/dist/boards/stored-board.js.map +1 -1
- package/dist/boards/work-migrations.d.ts +42 -0
- package/dist/boards/work-migrations.d.ts.map +1 -0
- package/dist/boards/work-migrations.js +352 -0
- package/dist/boards/work-migrations.js.map +1 -0
- package/dist/boards/work-routes.d.ts +58 -0
- package/dist/boards/work-routes.d.ts.map +1 -0
- package/dist/boards/work-routes.js +270 -0
- package/dist/boards/work-routes.js.map +1 -0
- package/dist/boards/work.d.ts +8 -19
- package/dist/boards/work.d.ts.map +1 -1
- package/dist/boards/work.js +38 -270
- package/dist/boards/work.js.map +1 -1
- package/dist/factory.d.ts +26 -3
- package/dist/factory.d.ts.map +1 -1
- package/dist/factory.js +105 -62
- package/dist/factory.js.map +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/integrations/base.d.ts +6 -2
- package/dist/integrations/base.d.ts.map +1 -1
- package/dist/integrations/closing-references.d.ts +15 -0
- package/dist/integrations/closing-references.d.ts.map +1 -0
- package/dist/integrations/closing-references.js +69 -0
- package/dist/integrations/closing-references.js.map +1 -0
- package/dist/integrations/github/default-rules.d.ts +15 -66
- package/dist/integrations/github/default-rules.d.ts.map +1 -1
- package/dist/integrations/github/default-rules.js +129 -73
- package/dist/integrations/github/default-rules.js.map +1 -1
- package/dist/integrations/github/issue-reconciler.d.ts.map +1 -1
- package/dist/integrations/github/issue-reconciler.js +3 -1
- package/dist/integrations/github/issue-reconciler.js.map +1 -1
- package/dist/integrations/github/pull-request-source.d.ts +8 -0
- package/dist/integrations/github/pull-request-source.d.ts.map +1 -0
- package/dist/integrations/github/pull-request-source.js +17 -0
- package/dist/integrations/github/pull-request-source.js.map +1 -0
- package/dist/integrations/github/review-status-reporter.d.ts.map +1 -1
- package/dist/integrations/github/review-status-reporter.js +7 -3
- package/dist/integrations/github/review-status-reporter.js.map +1 -1
- package/dist/integrations/github/routes.js +1 -1
- package/dist/integrations/github/rules.d.ts +12 -7
- package/dist/integrations/github/rules.d.ts.map +1 -1
- package/dist/integrations/github/rules.js +214 -93
- package/dist/integrations/github/rules.js.map +1 -1
- package/dist/integrations/github/session-subscriptions.js +2 -2
- package/dist/integrations/github/session-subscriptions.js.map +1 -1
- package/dist/integrations/github/token-refresh.d.ts +2 -1
- package/dist/integrations/github/token-refresh.d.ts.map +1 -1
- package/dist/integrations/github/token-refresh.js.map +1 -1
- package/dist/integrations/gitlab/agent-tools.js +1 -1
- package/dist/integrations/gitlab/default-rules.d.ts +73 -31
- package/dist/integrations/gitlab/default-rules.d.ts.map +1 -1
- package/dist/integrations/gitlab/default-rules.js +106 -43
- package/dist/integrations/gitlab/default-rules.js.map +1 -1
- package/dist/integrations/gitlab/issue-reconciler.d.ts.map +1 -1
- package/dist/integrations/gitlab/issue-reconciler.js +2 -1
- package/dist/integrations/gitlab/issue-reconciler.js.map +1 -1
- package/dist/integrations/gitlab/merge-request-reconciler.d.ts.map +1 -1
- package/dist/integrations/gitlab/merge-request-reconciler.js +11 -4
- package/dist/integrations/gitlab/merge-request-reconciler.js.map +1 -1
- package/dist/integrations/gitlab/routes.d.ts.map +1 -1
- package/dist/integrations/gitlab/routes.js +1 -3
- package/dist/integrations/gitlab/routes.js.map +1 -1
- package/dist/integrations/gitlab/rules.d.ts +6 -1
- package/dist/integrations/gitlab/rules.d.ts.map +1 -1
- package/dist/integrations/gitlab/rules.js +115 -27
- package/dist/integrations/gitlab/rules.js.map +1 -1
- package/dist/integrations/gitlab/session-subscriptions.js +1 -1
- package/dist/integrations/incidentio/agent-tools.js +6 -6
- package/dist/integrations/incidentio/agent-tools.js.map +1 -1
- package/dist/integrations/incidentio/default-rules.d.ts.map +1 -1
- package/dist/integrations/incidentio/default-rules.js +3 -3
- package/dist/integrations/incidentio/default-rules.js.map +1 -1
- package/dist/integrations/incidentio/issue-reconciler.d.ts.map +1 -1
- package/dist/integrations/incidentio/issue-reconciler.js +2 -1
- package/dist/integrations/incidentio/issue-reconciler.js.map +1 -1
- package/dist/integrations/incidentio/routes.d.ts +2 -2
- package/dist/integrations/incidentio/routes.d.ts.map +1 -1
- package/dist/integrations/incidentio/routes.js +10 -13
- package/dist/integrations/incidentio/routes.js.map +1 -1
- package/dist/integrations/incidentio/rules.d.ts +4 -4
- package/dist/integrations/incidentio/rules.d.ts.map +1 -1
- package/dist/integrations/incidentio/rules.js +13 -12
- package/dist/integrations/incidentio/rules.js.map +1 -1
- package/dist/integrations/jira/agent-tools.js +1 -1
- package/dist/integrations/jira/binding-scope.d.ts +5 -6
- package/dist/integrations/jira/binding-scope.d.ts.map +1 -1
- package/dist/integrations/jira/binding-scope.js +9 -11
- package/dist/integrations/jira/binding-scope.js.map +1 -1
- package/dist/integrations/jira/default-rules.d.ts.map +1 -1
- package/dist/integrations/jira/default-rules.js +3 -3
- package/dist/integrations/jira/default-rules.js.map +1 -1
- package/dist/integrations/jira/issue-reconciler.d.ts.map +1 -1
- package/dist/integrations/jira/issue-reconciler.js +2 -1
- package/dist/integrations/jira/issue-reconciler.js.map +1 -1
- package/dist/integrations/jira/routes.d.ts.map +1 -1
- package/dist/integrations/jira/routes.js +3 -5
- package/dist/integrations/jira/routes.js.map +1 -1
- package/dist/integrations/jira/rules.d.ts +4 -4
- package/dist/integrations/jira/rules.d.ts.map +1 -1
- package/dist/integrations/jira/rules.js +13 -12
- package/dist/integrations/jira/rules.js.map +1 -1
- package/dist/integrations/linear/agent-tools.d.ts +9 -1
- package/dist/integrations/linear/agent-tools.d.ts.map +1 -1
- package/dist/integrations/linear/agent-tools.js +80 -2
- package/dist/integrations/linear/agent-tools.js.map +1 -1
- package/dist/integrations/linear/default-rules.d.ts.map +1 -1
- package/dist/integrations/linear/default-rules.js +3 -3
- package/dist/integrations/linear/default-rules.js.map +1 -1
- package/dist/integrations/linear/integration.d.ts +4 -1
- package/dist/integrations/linear/integration.d.ts.map +1 -1
- package/dist/integrations/linear/integration.js +21 -1
- package/dist/integrations/linear/integration.js.map +1 -1
- package/dist/integrations/linear/issue-reconciler.d.ts.map +1 -1
- package/dist/integrations/linear/issue-reconciler.js +2 -1
- package/dist/integrations/linear/issue-reconciler.js.map +1 -1
- package/dist/integrations/linear/routes.d.ts +2 -1
- package/dist/integrations/linear/routes.d.ts.map +1 -1
- package/dist/integrations/linear/routes.js +15 -17
- package/dist/integrations/linear/routes.js.map +1 -1
- package/dist/integrations/linear/rules.d.ts +4 -4
- package/dist/integrations/linear/rules.d.ts.map +1 -1
- package/dist/integrations/linear/rules.js +14 -13
- package/dist/integrations/linear/rules.js.map +1 -1
- package/dist/integrations/platform/connect/session-tools.d.ts +5 -0
- package/dist/integrations/platform/connect/session-tools.d.ts.map +1 -1
- package/dist/integrations/platform/connect/session-tools.js +5 -0
- package/dist/integrations/platform/connect/session-tools.js.map +1 -1
- package/dist/integrations/platform/github/integration.d.ts.map +1 -1
- package/dist/integrations/platform/github/integration.js +33 -21
- package/dist/integrations/platform/github/integration.js.map +1 -1
- package/dist/integrations/platform/jira/agent-tools.js +1 -1
- package/dist/integrations/platform/jira/routes.d.ts.map +1 -1
- package/dist/integrations/platform/jira/routes.js +3 -5
- package/dist/integrations/platform/jira/routes.js.map +1 -1
- package/dist/integrations/platform/linear/integration.d.ts +1 -1
- package/dist/integrations/platform/linear/integration.d.ts.map +1 -1
- package/dist/integrations/platform/linear/integration.js +6 -5
- package/dist/integrations/platform/linear/integration.js.map +1 -1
- package/dist/integrations/slack/chat-tools.js +1 -1
- package/dist/integrations/slack/reply-tool.js +1 -1
- package/dist/integrations/slack/share-file-tool.js +1 -1
- package/dist/integrations/slack/slack.d.ts +10 -4
- package/dist/integrations/slack/slack.d.ts.map +1 -1
- package/dist/integrations/slack/slack.js +19 -9
- package/dist/integrations/slack/slack.js.map +1 -1
- package/dist/links.d.ts.map +1 -1
- package/dist/links.js +3 -2
- package/dist/links.js.map +1 -1
- package/dist/mcp/routes.js +2 -2
- package/dist/routes/attention-parked.d.ts +1 -0
- package/dist/routes/attention-parked.d.ts.map +1 -1
- package/dist/routes/attention-parked.js +1 -1
- package/dist/routes/attention-parked.js.map +1 -1
- package/dist/routes/automation-runs.d.ts +5 -1
- package/dist/routes/automation-runs.d.ts.map +1 -1
- package/dist/routes/automation-runs.js +15 -0
- package/dist/routes/automation-runs.js.map +1 -1
- package/dist/routes/boards.d.ts +1 -1
- package/dist/routes/boards.d.ts.map +1 -1
- package/dist/routes/boards.js +1 -17
- package/dist/routes/boards.js.map +1 -1
- package/dist/routes/config.d.ts +4 -0
- package/dist/routes/config.d.ts.map +1 -1
- package/dist/routes/config.js +15 -0
- package/dist/routes/config.js.map +1 -1
- package/dist/routes/contracts.d.ts +128 -24
- package/dist/routes/contracts.d.ts.map +1 -1
- package/dist/routes/contracts.js +45 -24
- package/dist/routes/contracts.js.map +1 -1
- package/dist/routes/fs.d.ts +4 -0
- package/dist/routes/fs.d.ts.map +1 -1
- package/dist/routes/fs.js +8 -4
- package/dist/routes/fs.js.map +1 -1
- package/dist/routes/intake-routes.d.ts.map +1 -1
- package/dist/routes/intake-routes.js +6 -1
- package/dist/routes/intake-routes.js.map +1 -1
- package/dist/routes/intake.d.ts +0 -23
- package/dist/routes/intake.d.ts.map +1 -1
- package/dist/routes/intake.js +13 -309
- package/dist/routes/intake.js.map +1 -1
- package/dist/routes/projects.d.ts.map +1 -1
- package/dist/routes/projects.js +9 -3
- package/dist/routes/projects.js.map +1 -1
- package/dist/routes/provider-credentials.d.ts.map +1 -1
- package/dist/routes/provider-credentials.js +10 -5
- package/dist/routes/provider-credentials.js.map +1 -1
- package/dist/routes/running-packages.d.ts +13 -0
- package/dist/routes/running-packages.d.ts.map +1 -0
- package/dist/routes/running-packages.js +45 -0
- package/dist/routes/running-packages.js.map +1 -0
- package/dist/routes/surface.d.ts +10 -1
- package/dist/routes/surface.d.ts.map +1 -1
- package/dist/routes/surface.js +104 -37
- package/dist/routes/surface.js.map +1 -1
- package/dist/routes/work-items.d.ts.map +1 -1
- package/dist/routes/work-items.js +23 -3
- package/dist/routes/work-items.js.map +1 -1
- package/dist/rules/binding-context.d.ts.map +1 -1
- package/dist/rules/binding-context.js +1 -0
- package/dist/rules/binding-context.js.map +1 -1
- package/dist/rules/dispatcher.d.ts +0 -6
- package/dist/rules/dispatcher.d.ts.map +1 -1
- package/dist/rules/dispatcher.js +354 -60
- package/dist/rules/dispatcher.js.map +1 -1
- package/dist/rules/event-rules.d.ts +33 -2
- package/dist/rules/event-rules.d.ts.map +1 -1
- package/dist/rules/event-rules.js +46 -11
- package/dist/rules/event-rules.js.map +1 -1
- package/dist/rules/index.d.ts +2 -4
- package/dist/rules/index.d.ts.map +1 -1
- package/dist/rules/index.js +2 -3
- package/dist/rules/phase-goal.d.ts +54 -0
- package/dist/rules/phase-goal.d.ts.map +1 -0
- package/dist/rules/phase-goal.js +70 -0
- package/dist/rules/phase-goal.js.map +1 -0
- package/dist/rules/phase-tools.d.ts +11 -0
- package/dist/rules/phase-tools.d.ts.map +1 -0
- package/dist/rules/phase-tools.js +19 -0
- package/dist/rules/phase-tools.js.map +1 -0
- package/dist/rules/processor.d.ts.map +1 -1
- package/dist/rules/processor.js +112 -11
- package/dist/rules/processor.js.map +1 -1
- package/dist/rules/review-source-tool.d.ts +4 -1
- package/dist/rules/review-source-tool.d.ts.map +1 -1
- package/dist/rules/review-source-tool.js +24 -4
- package/dist/rules/review-source-tool.js.map +1 -1
- package/dist/rules/rule-group.d.ts +1 -1
- package/dist/rules/rule-group.d.ts.map +1 -1
- package/dist/rules/rule-group.js +15 -6
- package/dist/rules/rule-group.js.map +1 -1
- package/dist/rules/start-coordinator.d.ts +5 -1
- package/dist/rules/start-coordinator.d.ts.map +1 -1
- package/dist/rules/start-coordinator.js +9 -3
- package/dist/rules/start-coordinator.js.map +1 -1
- package/dist/rules/tools.d.ts.map +1 -1
- package/dist/rules/tools.js +39 -28
- package/dist/rules/tools.js.map +1 -1
- package/dist/rules/transition-service.d.ts +4 -10
- package/dist/rules/transition-service.d.ts.map +1 -1
- package/dist/rules/transition-service.js +61 -55
- package/dist/rules/transition-service.js.map +1 -1
- package/dist/rules/types.d.ts +86 -36
- package/dist/rules/types.d.ts.map +1 -1
- package/dist/rules/types.js +5 -41
- package/dist/rules/types.js.map +1 -1
- package/dist/rules/validation.d.ts.map +1 -1
- package/dist/rules/validation.js +32 -2
- package/dist/rules/validation.js.map +1 -1
- package/dist/secret-encryption.d.ts +21 -0
- package/dist/secret-encryption.d.ts.map +1 -1
- package/dist/secret-encryption.js +31 -4
- package/dist/secret-encryption.js.map +1 -1
- package/dist/session/self-review-gate.d.ts +6 -4
- package/dist/session/self-review-gate.d.ts.map +1 -1
- package/dist/session/self-review-gate.js +9 -12
- package/dist/session/self-review-gate.js.map +1 -1
- package/dist/session/session-threads.d.ts +2 -3
- package/dist/session/session-threads.d.ts.map +1 -1
- package/dist/session/session-threads.js.map +1 -1
- package/dist/session/source-control-tools.d.ts +39 -13
- package/dist/session/source-control-tools.d.ts.map +1 -1
- package/dist/session/source-control-tools.js +55 -61
- package/dist/session/source-control-tools.js.map +1 -1
- package/dist/session/work-item-state-processor.d.ts +24 -0
- package/dist/session/work-item-state-processor.d.ts.map +1 -0
- package/dist/session/work-item-state-processor.js +275 -0
- package/dist/session/work-item-state-processor.js.map +1 -0
- package/dist/storage/domains/boards/base.d.ts +70 -31
- package/dist/storage/domains/boards/base.d.ts.map +1 -1
- package/dist/storage/domains/boards/base.js +99 -126
- package/dist/storage/domains/boards/base.js.map +1 -1
- package/dist/storage/domains/boards/schemas.d.ts.map +1 -1
- package/dist/storage/domains/boards/schemas.js +12 -0
- package/dist/storage/domains/boards/schemas.js.map +1 -1
- package/dist/storage/domains/intake/base.d.ts +5 -45
- package/dist/storage/domains/intake/base.d.ts.map +1 -1
- package/dist/storage/domains/intake/base.js +11 -89
- package/dist/storage/domains/intake/base.js.map +1 -1
- package/dist/storage/domains/projects/base.d.ts +17 -9
- package/dist/storage/domains/projects/base.d.ts.map +1 -1
- package/dist/storage/domains/projects/base.js +15 -7
- package/dist/storage/domains/projects/base.js.map +1 -1
- package/dist/storage/domains/work-items/base.d.ts +39 -4
- package/dist/storage/domains/work-items/base.d.ts.map +1 -1
- package/dist/storage/domains/work-items/base.js +113 -26
- package/dist/storage/domains/work-items/base.js.map +1 -1
- package/dist/storage/domains/work-items/cards.d.ts +24 -2
- package/dist/storage/domains/work-items/cards.d.ts.map +1 -1
- package/dist/storage/domains/work-items/cards.js +118 -8
- package/dist/storage/domains/work-items/cards.js.map +1 -1
- package/dist/storage/domains/work-items/legacy-review.d.ts +63 -0
- package/dist/storage/domains/work-items/legacy-review.d.ts.map +1 -0
- package/dist/storage/domains/work-items/legacy-review.js +95 -0
- package/dist/storage/domains/work-items/legacy-review.js.map +1 -0
- package/dist/storage/domains/work-items/metrics.d.ts +12 -4
- package/dist/storage/domains/work-items/metrics.d.ts.map +1 -1
- package/dist/storage/domains/work-items/metrics.js +14 -32
- package/dist/storage/domains/work-items/metrics.js.map +1 -1
- package/dist/storage/domains/work-items/work-item-schema.d.ts +2 -0
- package/dist/storage/domains/work-items/work-item-schema.d.ts.map +1 -1
- package/dist/storage/domains/work-items/work-item-schema.js +5 -0
- package/dist/storage/domains/work-items/work-item-schema.js.map +1 -1
- package/dist/tools/approval-tools.d.ts.map +1 -1
- package/dist/tools/approval-tools.js +28 -9
- package/dist/tools/approval-tools.js.map +1 -1
- package/dist/tools/index.d.ts +1 -1
- package/dist/tools/index.js +1 -1
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/messaging-tools.d.ts +3 -0
- package/dist/tools/messaging-tools.d.ts.map +1 -1
- package/dist/tools/messaging-tools.js +2 -1
- package/dist/tools/messaging-tools.js.map +1 -1
- package/dist/tools/read-tools.d.ts +8 -2
- package/dist/tools/read-tools.d.ts.map +1 -1
- package/dist/tools/read-tools.js +83 -23
- package/dist/tools/read-tools.js.map +1 -1
- package/dist/tools/reports.d.ts +1 -0
- package/dist/tools/reports.d.ts.map +1 -1
- package/dist/tools/reports.js +2 -1
- package/dist/tools/reports.js.map +1 -1
- package/dist/tools/run-watch.d.ts +1 -1
- package/dist/tools/run-watch.d.ts.map +1 -1
- package/dist/tools/run-watch.js +1 -0
- package/dist/tools/run-watch.js.map +1 -1
- package/dist/tools/sandbox-tools.js +1 -1
- package/dist/tools/session-tools.js +1 -1
- package/dist/tools/sessions-state-processor.d.ts +2 -0
- package/dist/tools/sessions-state-processor.d.ts.map +1 -1
- package/dist/tools/sessions-state-processor.js +4 -2
- package/dist/tools/sessions-state-processor.js.map +1 -1
- package/dist/tools/side-sessions.d.ts +2 -0
- package/dist/tools/side-sessions.d.ts.map +1 -1
- package/dist/tools/side-sessions.js +2 -1
- package/dist/tools/side-sessions.js.map +1 -1
- package/dist/tools/work-item-tools.js +3 -3
- package/dist/tools/work-item-tools.js.map +1 -1
- package/dist/work-item-branch.d.ts +13 -0
- package/dist/work-item-branch.d.ts.map +1 -1
- package/dist/work-item-branch.js +16 -1
- package/dist/work-item-branch.js.map +1 -1
- package/dist/work-items/create-work-item.d.ts +6 -0
- package/dist/work-items/create-work-item.d.ts.map +1 -1
- package/dist/work-items/create-work-item.js +25 -1
- package/dist/work-items/create-work-item.js.map +1 -1
- package/dist/work-items/providers/base.d.ts +4 -1
- package/dist/work-items/providers/base.d.ts.map +1 -1
- package/dist/work-items/providers/base.js +6 -1
- package/dist/work-items/providers/base.js.map +1 -1
- package/dist/work-items/providers/github.d.ts.map +1 -1
- package/dist/work-items/providers/github.js +2 -1
- package/dist/work-items/providers/github.js.map +1 -1
- package/dist/work-items/providers/gitlab.d.ts.map +1 -1
- package/dist/work-items/providers/gitlab.js +2 -1
- package/dist/work-items/providers/gitlab.js.map +1 -1
- package/dist/work-items/providers/jira.d.ts.map +1 -1
- package/dist/work-items/providers/jira.js +3 -2
- package/dist/work-items/providers/jira.js.map +1 -1
- package/dist/work-items/providers/linear.d.ts.map +1 -1
- package/dist/work-items/providers/linear.js +3 -2
- package/dist/work-items/providers/linear.js.map +1 -1
- package/dist/work-items/providers/types.d.ts +6 -0
- package/dist/work-items/providers/types.d.ts.map +1 -1
- package/dist/work-items/split-migration.d.ts.map +1 -1
- package/dist/work-items/split-migration.js +1 -0
- package/dist/work-items/split-migration.js.map +1 -1
- package/dist/workspace.d.ts.map +1 -1
- package/dist/workspace.js +53 -10
- package/dist/workspace.js.map +1 -1
- package/factory-skills/configure-factory-rules/SKILL.md +12 -10
- package/factory-skills/factory-build/SKILL.md +64 -0
- package/factory-skills/factory-gitlab-rereview/SKILL.md +2 -2
- package/factory-skills/factory-gitlab-review/SKILL.md +3 -3
- package/factory-skills/factory-plan/SKILL.md +8 -10
- package/factory-skills/factory-rereview/SKILL.md +5 -5
- package/factory-skills/factory-review/SKILL.md +16 -6
- package/factory-skills/factory-self-review/SKILL.md +31 -11
- package/factory-skills/factory-triage/SKILL.md +25 -10
- package/package.json +11 -11
- package/dist/boards/index.js.map +0 -1
- package/dist/boards/pull-request-review.d.ts +0 -14
- package/dist/boards/pull-request-review.d.ts.map +0 -1
- package/dist/boards/pull-request-review.js +0 -81
- package/dist/boards/pull-request-review.js.map +0 -1
- package/dist/boards/work-tool-rules.d.ts +0 -8
- package/dist/boards/work-tool-rules.d.ts.map +0 -1
- package/dist/boards/work-tool-rules.js +0 -19
- package/dist/boards/work-tool-rules.js.map +0 -1
- package/dist/rules/resolve.d.ts +0 -15
- package/dist/rules/resolve.d.ts.map +0 -1
- package/dist/rules/resolve.js +0 -22
- package/dist/rules/resolve.js.map +0 -1
- package/factory-skills/factory-complete-issue/SKILL.md +0 -24
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import type { FactoryRuleBoardClosure, FactoryRulePhaseContext } from '../rules/types.js';
|
|
1
|
+
import type { FactoryRuleBoardClosure, FactoryRuleBoardFlow, FactoryRuleIntakeTarget, FactoryRulePhaseContext } from '../rules/types.js';
|
|
2
2
|
import type { Card } from '../storage/domains/work-items/base.js';
|
|
3
|
+
import type { MetricsPhaseOutcomes } from '../storage/domains/work-items/metrics.js';
|
|
4
|
+
import type { WorkItemSourceRow } from '../storage/domains/work-items/work-item-schema.js';
|
|
3
5
|
import type { BoardEventIntegration, BoardEventRules, BoardPhaseKind, BoardToolResultRuleHandler } from './define-board.js';
|
|
4
|
-
import type { BoardRegistry } from './registry.js';
|
|
6
|
+
import type { BoardRegistry, InstalledBoard } from './registry.js';
|
|
5
7
|
export interface PhaseSemantics {
|
|
6
8
|
readonly kind: BoardPhaseKind;
|
|
7
9
|
/** Seat that carries a working phase; absent for resting and terminal phases. */
|
|
@@ -9,30 +11,154 @@ export interface PhaseSemantics {
|
|
|
9
11
|
}
|
|
10
12
|
/**
|
|
11
13
|
* Board that owns a work item. Rows created before boards were persisted carry no `board`;
|
|
12
|
-
* they belong to
|
|
13
|
-
*
|
|
14
|
+
* they belong to the default board. (Pull requests used to default to the retired Review board;
|
|
15
|
+
* storage reads those rows as the default board, and keeps cards stored on Review there only in a
|
|
16
|
+
* project that still uses it.)
|
|
14
17
|
*/
|
|
15
|
-
export declare function boardForWorkItem(item: Pick<Card, 'board'
|
|
18
|
+
export declare function boardForWorkItem(item: Pick<Card, 'board'>): string;
|
|
16
19
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
20
|
+
* The phases a board's pull request loop runs through, read from what each phase declares
|
|
21
|
+
* rather than from its key:
|
|
22
|
+
*
|
|
23
|
+
* Only phases running in the {@link REVIEW_CONTEXT} seat count as reviews: it is the only seat
|
|
24
|
+
* that records verdicts.
|
|
25
|
+
*
|
|
26
|
+
* - `pullRequestReview`: the first phase that grants `factory_review_source`. It takes pull
|
|
27
|
+
* requests: a pull request's own card is reviewed there, an attached pull request is reviewed
|
|
28
|
+
* there, verdicts on pull requests are recorded there, and a push or review request re-enters it.
|
|
29
|
+
* - `selfReview`: the first working phase that grants `factory_record_review_verdict` without
|
|
30
|
+
* `factory_review_source`: an independent review of the builder's branch before a pull request.
|
|
31
|
+
* - `triage`: on a board with a `build` phase, the first working phase that neither builds (runs
|
|
32
|
+
* in `buildRole`) nor reviews: it sorts new cards before anyone accepts them. A board that
|
|
33
|
+
* builds nothing has no triage phase.
|
|
34
|
+
* - `build`: the last working phase, in declaration order, that is neither of those and can move
|
|
35
|
+
* into the review that follows it (`selfReview`, else `pullRequestReview`). Self-review sends
|
|
36
|
+
* requested changes back here, and its seat (`buildRole`) is woken by pull request feedback.
|
|
37
|
+
*
|
|
38
|
+
* A board without a `factory_review_source` phase has no pull request loop.
|
|
39
|
+
*/
|
|
40
|
+
export declare function boardFlow(board: InstalledBoard | undefined): FactoryRuleBoardFlow;
|
|
41
|
+
/**
|
|
42
|
+
* Where integrations file new items: the project's default board's initial phase, from which its
|
|
43
|
+
* intake routes place them. Undefined when the default board is not installed.
|
|
44
|
+
*/
|
|
45
|
+
export declare function intakeTarget(boards: Pick<BoardRegistry, 'get'>): FactoryRuleIntakeTarget | undefined;
|
|
46
|
+
/** {@link intakeTarget} as a rule context field. */
|
|
47
|
+
export declare function withIntakeTarget(boards: Pick<BoardRegistry, 'get'>): {
|
|
48
|
+
intake?: FactoryRuleIntakeTarget;
|
|
49
|
+
};
|
|
50
|
+
/** {@link boardFlow} of the board a card sits on. */
|
|
51
|
+
export declare function cardBoardFlow(boards: Pick<BoardRegistry, 'get'>, item: Pick<Card, 'board'> | undefined): FactoryRuleBoardFlow;
|
|
52
|
+
/**
|
|
53
|
+
* Whether a card in `stage` is still waiting for someone to accept it: it rests, or it is being
|
|
54
|
+
* triaged. Approval labels hold only such cards.
|
|
55
|
+
*/
|
|
56
|
+
export declare function awaitsAcceptance(board: InstalledBoard | undefined, stage: string): boolean;
|
|
57
|
+
/** Whether `stage` is the phase where the board reviews pull requests. */
|
|
58
|
+
export declare function isPullRequestReviewPhase(board: InstalledBoard | undefined, stage: string | undefined): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Why a move breaks the shape of a card on a board with a pull request loop, or undefined when it
|
|
61
|
+
* does not: a pull request's own card is only reviewed, so it enters no other working phase, and
|
|
62
|
+
* the pull request review phase holds only cards that carry a pull request (their own, or one
|
|
63
|
+
* attached to their issue). `nextPhases` cannot say this: a resting phase may lead to both, and
|
|
64
|
+
* which one fits depends on the card.
|
|
65
|
+
*/
|
|
66
|
+
export declare function pullRequestCardRejection(board: InstalledBoard, card: {
|
|
67
|
+
readonly standalonePullRequest: boolean;
|
|
68
|
+
readonly hasPullRequest: boolean;
|
|
69
|
+
}, toStage: string): string | undefined;
|
|
70
|
+
/** `{ flow }` for spreading into an integration rule context, or `{}` for an unbound evaluation. */
|
|
71
|
+
export declare function withBoardFlow(boards: Pick<BoardRegistry, 'get'>, item: Pick<Card, 'board'> | undefined): {
|
|
72
|
+
flow?: FactoryRuleBoardFlow;
|
|
73
|
+
};
|
|
74
|
+
interface SourcedItem {
|
|
75
|
+
readonly workItem?: {
|
|
76
|
+
readonly sources?: readonly WorkItemSourceRow[];
|
|
77
|
+
} | null;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* A card whose own primary source is a pull or merge request: an outside contributor's
|
|
81
|
+
* PR filed on its own card, or a PR card filed before PRs attached to their issue's card.
|
|
82
|
+
* An issue card with an attached PR is not one; see {@link hasPullRequest}.
|
|
19
83
|
*/
|
|
20
84
|
export declare function isPullRequestCard(item: {
|
|
21
85
|
readonly source: string;
|
|
22
86
|
}): boolean;
|
|
23
|
-
/**
|
|
87
|
+
/** Every pull or merge request source on a card, oldest first. */
|
|
88
|
+
export declare function pullRequestSources(item: SourcedItem): WorkItemSourceRow[];
|
|
89
|
+
/** Whether a card carries a pull or merge request: its own, or one attached to its issue. */
|
|
90
|
+
export declare function hasPullRequest(item: SourcedItem & {
|
|
91
|
+
readonly source?: string;
|
|
92
|
+
}): boolean;
|
|
93
|
+
/** A source row's external id without the type/workspace scope storage prefixes it with. */
|
|
94
|
+
export declare function sourceExternalId(source: Pick<WorkItemSourceRow, 'sourceType' | 'workspaceId' | 'externalId'>): string;
|
|
95
|
+
/** The provider number (GitHub PR number, GitLab MR IID) a pull request source names. */
|
|
96
|
+
export declare function pullRequestSourceNumber(source: Pick<WorkItemSourceRow, 'metadata'>): number | undefined;
|
|
97
|
+
/**
|
|
98
|
+
* The pull request a PR review pass on this card reviews: the one the card's
|
|
99
|
+
* `openPullRequestNumber` names, else the newest open one, else the newest one.
|
|
100
|
+
*/
|
|
101
|
+
export declare function reviewedPullRequest(item: SourcedItem & {
|
|
102
|
+
readonly metadata?: Record<string, unknown> | null;
|
|
103
|
+
}): WorkItemSourceRow | undefined;
|
|
104
|
+
/** The newest still-open pull request on a card other than `except`, for re-pointing `openPullRequestNumber`. */
|
|
105
|
+
export declare function newestOpenPullRequestNumber(item: SourcedItem, except?: number): number | null;
|
|
106
|
+
interface SessionedItem {
|
|
107
|
+
readonly sessions: Readonly<Record<string, {
|
|
108
|
+
readonly branch?: string | null;
|
|
109
|
+
} | undefined>>;
|
|
110
|
+
}
|
|
111
|
+
type BranchedItem = Pick<Card, 'id' | 'externalSource'> & {
|
|
112
|
+
readonly workItem: Pick<Card['workItem'], 'metadata'>;
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* Whether a pull request from `headBranch` was opened by the card's own sessions: the head is
|
|
116
|
+
* one of its session branches, or the branch Factory builds the card on (stable even after its
|
|
117
|
+
* session is deleted).
|
|
118
|
+
*/
|
|
119
|
+
export declare function cardOwnsBranch(item: SessionedItem & BranchedItem, headBranch: string | undefined): boolean;
|
|
120
|
+
/** The newest open pull request the card's own sessions opened, other than `except`. */
|
|
121
|
+
export declare function newestOwnedOpenPullRequestNumber(item: SourcedItem & SessionedItem & BranchedItem, except?: number): number | null;
|
|
122
|
+
/** The pull or merge request a card's PR review covers, whichever card shape carries it. */
|
|
123
|
+
export interface ReviewedChangeRequest {
|
|
124
|
+
readonly provider: 'github' | 'gitlab';
|
|
125
|
+
readonly number: number | undefined;
|
|
126
|
+
readonly url: string | null;
|
|
127
|
+
readonly headBranch: string | undefined;
|
|
128
|
+
/** The card is the change request's own card rather than an issue card it is attached to. */
|
|
129
|
+
readonly standalone: boolean;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* What a PR review on this card reviews: the card's own change request when the card is one,
|
|
133
|
+
* otherwise the attached one {@link reviewedPullRequest} picks. Undefined for a card with none.
|
|
134
|
+
*/
|
|
135
|
+
export declare function reviewedChangeRequest(item: {
|
|
136
|
+
readonly source: string;
|
|
137
|
+
readonly url?: string | null;
|
|
138
|
+
readonly metadata?: Record<string, unknown> | null;
|
|
139
|
+
readonly workItem: {
|
|
140
|
+
readonly url?: string | null;
|
|
141
|
+
readonly metadata?: Record<string, unknown> | null;
|
|
142
|
+
readonly sources?: readonly WorkItemSourceRow[];
|
|
143
|
+
};
|
|
144
|
+
}): ReviewedChangeRequest | undefined;
|
|
145
|
+
/**
|
|
146
|
+
* Whether a pass already recorded a verdict on `change`. An issue card can carry
|
|
147
|
+
* several pull requests, so a verdict stamped for another one doesn't count; a
|
|
148
|
+
* verdict with no number (a standalone card, or one stamped before verdicts named
|
|
149
|
+
* their pull request) covers the card.
|
|
150
|
+
*/
|
|
151
|
+
export declare function hasRecordedVerdict(item: Parameters<typeof reviewedChangeRequest>[0], change?: Pick<ReviewedChangeRequest, 'number'> | undefined): boolean;
|
|
152
|
+
/**
|
|
153
|
+
* Whether the rule's card carries a change request its board reviews: the card has one, and its
|
|
154
|
+
* board has a phase that takes pull requests ({@link boardFlow}).
|
|
155
|
+
*/
|
|
24
156
|
export declare function reviewsPullRequest(context: {
|
|
25
|
-
readonly
|
|
26
|
-
readonly item?: {
|
|
157
|
+
readonly flow?: Pick<FactoryRuleBoardFlow, 'pullRequestReview'>;
|
|
158
|
+
readonly item?: SourcedItem & {
|
|
27
159
|
readonly source: string;
|
|
28
160
|
};
|
|
29
161
|
}): boolean;
|
|
30
|
-
/**
|
|
31
|
-
* The phase a pull or merge request's own card is reviewed in: Work's `pr-review`, or Review's
|
|
32
|
-
* `review` for cards filed on the Review board before pull requests moved to Work. Work's own
|
|
33
|
-
* `review` phase is the builder's self-review, which a pull request card never enters.
|
|
34
|
-
*/
|
|
35
|
-
export declare function pullRequestReviewPhase(board: string | undefined): 'review' | 'pr-review';
|
|
36
162
|
/**
|
|
37
163
|
* What the installed board says `phase` means. Returns undefined when the board is not
|
|
38
164
|
* installed or does not declare the phase; callers must fail closed on undefined rather
|
|
@@ -63,14 +189,21 @@ export declare function eventBoardId(context: {
|
|
|
63
189
|
/** What a card's single current phase means on its installed board, for integration rule contexts. */
|
|
64
190
|
export declare function rulePhaseContext(boards: Pick<BoardRegistry, 'get'>, item: Pick<Card, 'board' | 'externalSource' | 'stages'>): FactoryRulePhaseContext | undefined;
|
|
65
191
|
/**
|
|
66
|
-
* Whether a persisted card has finished, judged by the board it sits on: the installed
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
* released from ownership on the board's own say-so.
|
|
192
|
+
* Whether a persisted card has finished, judged by the board it sits on: the installed board's
|
|
193
|
+
* phase kind first, then, for rows whose board is not installed, the phase kinds of the default
|
|
194
|
+
* board Factory seeds or of the retired Review board. Unknown boards or phases are never terminal,
|
|
195
|
+
* so a card is only ever released from ownership on the board's own say-so.
|
|
70
196
|
*/
|
|
71
197
|
export declare function isTerminalWorkItem(boards: BoardRegistry, item: Pick<Card, 'board' | 'externalSource' | 'stages'>): boolean;
|
|
72
198
|
/** Semantics of the single stage a work item currently occupies; undefined for multi-stage rows. */
|
|
73
199
|
export declare function workItemPhaseSemantics(boards: BoardRegistry, item: Pick<Card, 'board' | 'externalSource' | 'stages'>): PhaseSemantics | undefined;
|
|
200
|
+
/**
|
|
201
|
+
* Flow-metric outcomes of each board's phases: the phase the board closes completed sources into
|
|
202
|
+
* (else its first terminal phase) completes a card, other terminal phases cancel it, resting
|
|
203
|
+
* phases queue it, and anything else (working, or a phase the board no longer declares) is in
|
|
204
|
+
* flight.
|
|
205
|
+
*/
|
|
206
|
+
export declare function boardPhaseOutcomes(boards: Pick<BoardRegistry, 'get'>): MetricsPhaseOutcomes;
|
|
74
207
|
/**
|
|
75
208
|
* Where source-closed rules send a persisted card: the `sourceClosed` mapping its installed
|
|
76
209
|
* board declares, plus whether the card already sits in a terminal phase. Undefined when the
|
|
@@ -85,4 +218,10 @@ export declare function withBoardClosure(boards: BoardRegistry, item: Pick<Card,
|
|
|
85
218
|
export declare function rulePhaseField(boards: Pick<BoardRegistry, 'get'>, item: Pick<Card, 'board' | 'externalSource' | 'stages'>): {
|
|
86
219
|
readonly phase?: FactoryRulePhaseContext;
|
|
87
220
|
};
|
|
221
|
+
/**
|
|
222
|
+
* The change request a review session on this card may publish checks for: the card's own one,
|
|
223
|
+
* or, for an issue card in its board's pull request review phase, the pull request attached to it.
|
|
224
|
+
*/
|
|
225
|
+
export declare function boundChangeRequestNumber(boards: Pick<BoardRegistry, 'get'>, item: Card): string | undefined;
|
|
226
|
+
export {};
|
|
88
227
|
//# sourceMappingURL=semantics.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"semantics.d.ts","sourceRoot":"","sources":["../../src/boards/semantics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"semantics.d.ts","sourceRoot":"","sources":["../../src/bo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oG;AACpG,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,aAAa,EACrB,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,GAAG,gBAAgB,GAAG,QAAQ,CAAC,GACtD,cAAc,GAAG,SAAS,CAI5B;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,IAAI,CAAC,aAAa,EAAE,KAAK,CAAC,GAAG,oBAAoB,CAS3F;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,aAAa,EACrB,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,GAAG,gBAAgB,GAAG,QAAQ,CAAC,GACtD,uBAAuB,GAAG,SAAS,CAUrC;AAED,oGAAoG;AACpG,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,aAAa,EACrB,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,GAAG,gBAAgB,GAAG,QAAQ,CAAC,GACtD;IAAE,YAAY,CAAC,EAAE,uBAAuB,CAAA;CAAE,CAG5C;AAED,qGAAqG;AACrG,wBAAgB,cAAc,CAC5B,MAAM,EAAE,IAAI,CAAC,aAAa,EAAE,KAAK,CAAC,EAClC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,GAAG,gBAAgB,GAAG,QAAQ,CAAC,GACtD;IAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,uBAAuB,CAAA;CAAE,CAG9C;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,IAAI,CAAC,aAAa,EAAE,KAAK,CAAC,EAAE,IAAI,EAAE,IAAI,GAAG,MAAM,GAAG,SAAS,CAU3G"}
|
package/dist/boards/semantics.js
CHANGED
|
@@ -1,31 +1,233 @@
|
|
|
1
|
+
import { workItemBranch, workItemBranchSource } from "../work-item-branch.js";
|
|
2
|
+
import { DEFAULT_BOARD_ID } from "./default-board.js";
|
|
3
|
+
import "./define-board.js";
|
|
4
|
+
import { reviewBoard } from "./review.js";
|
|
5
|
+
import { workBoard } from "./work.js";
|
|
1
6
|
// src/boards/semantics.ts
|
|
2
7
|
/**
|
|
3
8
|
* Board that owns a work item. Rows created before boards were persisted carry no `board`;
|
|
4
|
-
* they belong to
|
|
5
|
-
*
|
|
9
|
+
* they belong to the default board. (Pull requests used to default to the retired Review board;
|
|
10
|
+
* storage reads those rows as the default board, and keeps cards stored on Review there only in a
|
|
11
|
+
* project that still uses it.)
|
|
6
12
|
*/
|
|
7
13
|
function boardForWorkItem(item) {
|
|
8
|
-
return item.board ??
|
|
14
|
+
return item.board ?? "work";
|
|
9
15
|
}
|
|
16
|
+
const flows = /* @__PURE__ */ new WeakMap();
|
|
10
17
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
18
|
+
* The phases a board's pull request loop runs through, read from what each phase declares
|
|
19
|
+
* rather than from its key:
|
|
20
|
+
*
|
|
21
|
+
* Only phases running in the {@link REVIEW_CONTEXT} seat count as reviews: it is the only seat
|
|
22
|
+
* that records verdicts.
|
|
23
|
+
*
|
|
24
|
+
* - `pullRequestReview`: the first phase that grants `factory_review_source`. It takes pull
|
|
25
|
+
* requests: a pull request's own card is reviewed there, an attached pull request is reviewed
|
|
26
|
+
* there, verdicts on pull requests are recorded there, and a push or review request re-enters it.
|
|
27
|
+
* - `selfReview`: the first working phase that grants `factory_record_review_verdict` without
|
|
28
|
+
* `factory_review_source`: an independent review of the builder's branch before a pull request.
|
|
29
|
+
* - `triage`: on a board with a `build` phase, the first working phase that neither builds (runs
|
|
30
|
+
* in `buildRole`) nor reviews: it sorts new cards before anyone accepts them. A board that
|
|
31
|
+
* builds nothing has no triage phase.
|
|
32
|
+
* - `build`: the last working phase, in declaration order, that is neither of those and can move
|
|
33
|
+
* into the review that follows it (`selfReview`, else `pullRequestReview`). Self-review sends
|
|
34
|
+
* requested changes back here, and its seat (`buildRole`) is woken by pull request feedback.
|
|
35
|
+
*
|
|
36
|
+
* A board without a `factory_review_source` phase has no pull request loop.
|
|
37
|
+
*/
|
|
38
|
+
function boardFlow(board) {
|
|
39
|
+
if (!board) return Object.freeze({});
|
|
40
|
+
const cached = flows.get(board);
|
|
41
|
+
if (cached) return cached;
|
|
42
|
+
const entries = Object.entries(board.phases);
|
|
43
|
+
const grants = (phase, tool) => phase.kind === "working" && phase.runner.context === "review" && (phase.tools ?? []).some((granted) => granted === tool);
|
|
44
|
+
const pullRequestReview = entries.find(([, phase]) => grants(phase, "factory_review_source"))?.[0];
|
|
45
|
+
const selfReview = entries.find(([key, phase]) => key !== pullRequestReview && grants(phase, "factory_record_review_verdict") && !grants(phase, "factory_review_source"))?.[0];
|
|
46
|
+
const handoff = selfReview ?? pullRequestReview;
|
|
47
|
+
const build = handoff ? entries.findLast(([key, phase]) => phase.kind === "working" && key !== pullRequestReview && key !== selfReview && board.allowsTransition(key, handoff))?.[0] : void 0;
|
|
48
|
+
const buildRole = build ? board.roleForPhase(build) : void 0;
|
|
49
|
+
const triage = build ? entries.find(([key, phase]) => phase.kind === "working" && key !== build && phase.runner.context !== "review" && phase.runner.context !== buildRole)?.[0] : void 0;
|
|
50
|
+
const terminals = entries.filter(([, phase]) => phase.kind === "terminal").map(([key]) => key);
|
|
51
|
+
const completed = board.sourceClosed?.completed ?? terminals[0];
|
|
52
|
+
const canceled = board.sourceClosed?.canceled ?? terminals.find((key) => key !== completed) ?? completed;
|
|
53
|
+
const ref = (phase) => Object.freeze({
|
|
54
|
+
phase,
|
|
55
|
+
title: board.phases[phase].name
|
|
56
|
+
});
|
|
57
|
+
const flow = Object.freeze({
|
|
58
|
+
initialPhase: board.initialPhase,
|
|
59
|
+
...completed ? { completed: ref(completed) } : {},
|
|
60
|
+
...canceled ? { canceled: ref(canceled) } : {},
|
|
61
|
+
...triage ? { triage } : {},
|
|
62
|
+
...pullRequestReview ? { pullRequestReview } : {},
|
|
63
|
+
...selfReview ? { selfReview } : {},
|
|
64
|
+
...build ? { build } : {},
|
|
65
|
+
...buildRole ? { buildRole } : {}
|
|
66
|
+
});
|
|
67
|
+
flows.set(board, flow);
|
|
68
|
+
return flow;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Where integrations file new items: the project's default board's initial phase, from which its
|
|
72
|
+
* intake routes place them. Undefined when the default board is not installed.
|
|
73
|
+
*/
|
|
74
|
+
function intakeTarget(boards) {
|
|
75
|
+
const target = boards.get(DEFAULT_BOARD_ID);
|
|
76
|
+
if (!target) return void 0;
|
|
77
|
+
return Object.freeze({
|
|
78
|
+
board: target.id,
|
|
79
|
+
initialPhase: target.initialPhase
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
/** {@link intakeTarget} as a rule context field. */
|
|
83
|
+
function withIntakeTarget(boards) {
|
|
84
|
+
const intake = intakeTarget(boards);
|
|
85
|
+
return intake ? { intake } : {};
|
|
86
|
+
}
|
|
87
|
+
/** {@link boardFlow} of the board a card sits on. */
|
|
88
|
+
function cardBoardFlow(boards, item) {
|
|
89
|
+
return item ? boardFlow(boards.get(boardForWorkItem(item))) : Object.freeze({});
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Whether a card in `stage` is still waiting for someone to accept it: it rests, or it is being
|
|
93
|
+
* triaged. Approval labels hold only such cards.
|
|
94
|
+
*/
|
|
95
|
+
function awaitsAcceptance(board, stage) {
|
|
96
|
+
if (!board) return false;
|
|
97
|
+
return board.phaseKind(stage) === "resting" || stage === boardFlow(board).triage;
|
|
98
|
+
}
|
|
99
|
+
/** Whether `stage` is the phase where the board reviews pull requests. */
|
|
100
|
+
function isPullRequestReviewPhase(board, stage) {
|
|
101
|
+
const phase = boardFlow(board).pullRequestReview;
|
|
102
|
+
return phase !== void 0 && phase === stage;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Why a move breaks the shape of a card on a board with a pull request loop, or undefined when it
|
|
106
|
+
* does not: a pull request's own card is only reviewed, so it enters no other working phase, and
|
|
107
|
+
* the pull request review phase holds only cards that carry a pull request (their own, or one
|
|
108
|
+
* attached to their issue). `nextPhases` cannot say this: a resting phase may lead to both, and
|
|
109
|
+
* which one fits depends on the card.
|
|
110
|
+
*/
|
|
111
|
+
function pullRequestCardRejection(board, card, toStage) {
|
|
112
|
+
const review = boardFlow(board).pullRequestReview;
|
|
113
|
+
if (!review) return void 0;
|
|
114
|
+
const reviewName = board.phases[review]?.name ?? review;
|
|
115
|
+
if (!card.hasPullRequest && toStage === review) return `${reviewName} holds only cards with a pull request; this work item enters it once a pull request is attached to it.`;
|
|
116
|
+
if (!card.standalonePullRequest || toStage === review || !board.isWorking(toStage)) return void 0;
|
|
117
|
+
const exits = [review, ...Object.keys(board.phases).filter((key) => board.isTerminal(key))];
|
|
118
|
+
return `A pull request card is only reviewed on the ${board.name} board; it cannot enter ${toStage}. Move it to ${exits.join(", ")}.`;
|
|
119
|
+
}
|
|
120
|
+
/** `{ flow }` for spreading into an integration rule context, or `{}` for an unbound evaluation. */
|
|
121
|
+
function withBoardFlow(boards, item) {
|
|
122
|
+
return item ? { flow: cardBoardFlow(boards, item) } : {};
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* A card whose own primary source is a pull or merge request: an outside contributor's
|
|
126
|
+
* PR filed on its own card, or a PR card filed before PRs attached to their issue's card.
|
|
127
|
+
* An issue card with an attached PR is not one; see {@link hasPullRequest}.
|
|
13
128
|
*/
|
|
14
129
|
function isPullRequestCard(item) {
|
|
15
130
|
return item.source === "github-pr" || item.source === "gitlab-pr";
|
|
16
131
|
}
|
|
17
|
-
/**
|
|
18
|
-
function
|
|
19
|
-
|
|
20
|
-
|
|
132
|
+
/** Every pull or merge request source on a card, oldest first. */
|
|
133
|
+
function pullRequestSources(item) {
|
|
134
|
+
return (item.workItem?.sources ?? []).filter((source) => source.sourceType === "pull-request");
|
|
135
|
+
}
|
|
136
|
+
/** Whether a card carries a pull or merge request: its own, or one attached to its issue. */
|
|
137
|
+
function hasPullRequest(item) {
|
|
138
|
+
return item.source !== void 0 && isPullRequestCard({ source: item.source }) || pullRequestSources(item).length > 0;
|
|
139
|
+
}
|
|
140
|
+
/** A source row's external id without the type/workspace scope storage prefixes it with. */
|
|
141
|
+
function sourceExternalId(source) {
|
|
142
|
+
const prefix = `${source.sourceType}:${source.workspaceId ? `${source.workspaceId}:` : ""}`;
|
|
143
|
+
return source.externalId.startsWith(prefix) ? source.externalId.slice(prefix.length) : source.externalId;
|
|
144
|
+
}
|
|
145
|
+
/** The provider number (GitHub PR number, GitLab MR IID) a pull request source names. */
|
|
146
|
+
function pullRequestSourceNumber(source) {
|
|
147
|
+
const metadata = source.metadata ?? {};
|
|
148
|
+
const value = metadata.githubPullRequestNumber ?? metadata.gitlabMergeRequestIid ?? metadata.number;
|
|
149
|
+
return typeof value === "number" && Number.isInteger(value) && value > 0 ? value : void 0;
|
|
150
|
+
}
|
|
151
|
+
function openSource(source) {
|
|
152
|
+
const state = source.state ?? source.metadata?.state;
|
|
153
|
+
return state !== "closed" && state !== "merged" && source.metadata?.merged !== true;
|
|
21
154
|
}
|
|
22
155
|
/**
|
|
23
|
-
* The
|
|
24
|
-
* `
|
|
25
|
-
* `review` phase is the builder's self-review, which a pull request card never enters.
|
|
156
|
+
* The pull request a PR review pass on this card reviews: the one the card's
|
|
157
|
+
* `openPullRequestNumber` names, else the newest open one, else the newest one.
|
|
26
158
|
*/
|
|
27
|
-
function
|
|
28
|
-
|
|
159
|
+
function reviewedPullRequest(item) {
|
|
160
|
+
const sources = pullRequestSources(item);
|
|
161
|
+
const pointer = item.metadata?.openPullRequestNumber;
|
|
162
|
+
return (typeof pointer === "number" ? sources.find((source) => pullRequestSourceNumber(source) === pointer) : void 0) ?? sources.findLast(openSource) ?? sources.at(-1);
|
|
163
|
+
}
|
|
164
|
+
/** The newest still-open pull request on a card other than `except`, for re-pointing `openPullRequestNumber`. */
|
|
165
|
+
function newestOpenPullRequestNumber(item, except) {
|
|
166
|
+
const open = pullRequestSources(item).filter((source) => openSource(source) && pullRequestSourceNumber(source) !== except);
|
|
167
|
+
return (open.length ? pullRequestSourceNumber(open.at(-1)) : void 0) ?? null;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Whether a pull request from `headBranch` was opened by the card's own sessions: the head is
|
|
171
|
+
* one of its session branches, or the branch Factory builds the card on (stable even after its
|
|
172
|
+
* session is deleted).
|
|
173
|
+
*/
|
|
174
|
+
function cardOwnsBranch(item, headBranch) {
|
|
175
|
+
if (!headBranch) return false;
|
|
176
|
+
return workItemBranch({
|
|
177
|
+
id: item.id,
|
|
178
|
+
source: workItemBranchSource(item.externalSource),
|
|
179
|
+
metadata: item.workItem.metadata
|
|
180
|
+
}) === headBranch || Object.values(item.sessions).some((session) => session?.branch === headBranch);
|
|
181
|
+
}
|
|
182
|
+
/** The newest open pull request the card's own sessions opened, other than `except`. */
|
|
183
|
+
function newestOwnedOpenPullRequestNumber(item, except) {
|
|
184
|
+
const open = pullRequestSources(item).filter((source) => openSource(source) && pullRequestSourceNumber(source) !== except && typeof source.metadata?.headBranch === "string" && cardOwnsBranch(item, source.metadata.headBranch));
|
|
185
|
+
return (open.length ? pullRequestSourceNumber(open.at(-1)) : void 0) ?? null;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* What a PR review on this card reviews: the card's own change request when the card is one,
|
|
189
|
+
* otherwise the attached one {@link reviewedPullRequest} picks. Undefined for a card with none.
|
|
190
|
+
*/
|
|
191
|
+
function reviewedChangeRequest(item) {
|
|
192
|
+
if (isPullRequestCard(item)) {
|
|
193
|
+
const metadata = item.workItem.metadata ?? {};
|
|
194
|
+
const gitlab = item.source === "gitlab-pr";
|
|
195
|
+
const value = (gitlab ? metadata.gitlabMergeRequestIid : metadata.githubPullRequestNumber) ?? metadata.number;
|
|
196
|
+
return {
|
|
197
|
+
provider: gitlab ? "gitlab" : "github",
|
|
198
|
+
number: typeof value === "number" && Number.isInteger(value) && value > 0 ? value : void 0,
|
|
199
|
+
url: item.url ?? item.workItem.url ?? null,
|
|
200
|
+
headBranch: typeof metadata.headBranch === "string" ? metadata.headBranch : void 0,
|
|
201
|
+
standalone: true
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
const source = reviewedPullRequest(item);
|
|
205
|
+
if (!source) return void 0;
|
|
206
|
+
return {
|
|
207
|
+
provider: source.integrationId === "gitlab" ? "gitlab" : "github",
|
|
208
|
+
number: pullRequestSourceNumber(source),
|
|
209
|
+
url: source.url ?? null,
|
|
210
|
+
headBranch: typeof source.metadata?.headBranch === "string" ? source.metadata.headBranch : void 0,
|
|
211
|
+
standalone: false
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Whether a pass already recorded a verdict on `change`. An issue card can carry
|
|
216
|
+
* several pull requests, so a verdict stamped for another one doesn't count; a
|
|
217
|
+
* verdict with no number (a standalone card, or one stamped before verdicts named
|
|
218
|
+
* their pull request) covers the card.
|
|
219
|
+
*/
|
|
220
|
+
function hasRecordedVerdict(item, change = reviewedChangeRequest(item)) {
|
|
221
|
+
const covered = item.metadata?.reviewedPullRequestNumber;
|
|
222
|
+
const reviewedAnother = typeof covered === "number" && change?.number !== void 0 && covered !== change.number;
|
|
223
|
+
return typeof item.metadata?.reviewVerdict === "string" && !reviewedAnother;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Whether the rule's card carries a change request its board reviews: the card has one, and its
|
|
227
|
+
* board has a phase that takes pull requests ({@link boardFlow}).
|
|
228
|
+
*/
|
|
229
|
+
function reviewsPullRequest(context) {
|
|
230
|
+
return context.flow?.pullRequestReview !== void 0 && context.item !== void 0 && hasPullRequest(context.item);
|
|
29
231
|
}
|
|
30
232
|
/**
|
|
31
233
|
* What the installed board says `phase` means. Returns undefined when the board is not
|
|
@@ -81,23 +283,23 @@ function rulePhaseContext(boards, item) {
|
|
|
81
283
|
context,
|
|
82
284
|
role: context
|
|
83
285
|
},
|
|
84
|
-
nextPhases: Object.freeze([...phase?.nextPhases ?? []])
|
|
85
|
-
outcomes: Object.freeze(Object.keys(phase?.outcomes ?? {}))
|
|
286
|
+
nextPhases: Object.freeze([...phase?.nextPhases ?? []])
|
|
86
287
|
});
|
|
87
288
|
}
|
|
88
289
|
/**
|
|
89
|
-
* Whether a persisted card has finished, judged by the board it sits on: the installed
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
* released from ownership on the board's own say-so.
|
|
290
|
+
* Whether a persisted card has finished, judged by the board it sits on: the installed board's
|
|
291
|
+
* phase kind first, then, for rows whose board is not installed, the phase kinds of the default
|
|
292
|
+
* board Factory seeds or of the retired Review board. Unknown boards or phases are never terminal,
|
|
293
|
+
* so a card is only ever released from ownership on the board's own say-so.
|
|
93
294
|
*/
|
|
94
295
|
function isTerminalWorkItem(boards, item) {
|
|
95
296
|
const semantics = workItemPhaseSemantics(boards, item);
|
|
96
297
|
if (semantics) return semantics.kind === "terminal";
|
|
97
298
|
const board = boardForWorkItem(item);
|
|
98
|
-
if (board
|
|
299
|
+
if (boards.has(board)) return false;
|
|
300
|
+
const seed = board === "work" ? workBoard : board === reviewBoard.id ? reviewBoard : void 0;
|
|
99
301
|
const stage = item.stages.length === 1 ? item.stages[0] : void 0;
|
|
100
|
-
return stage
|
|
302
|
+
return stage !== void 0 && seed !== void 0 && seed.isTerminal(stage);
|
|
101
303
|
}
|
|
102
304
|
/** Semantics of the single stage a work item currently occupies; undefined for multi-stage rows. */
|
|
103
305
|
function workItemPhaseSemantics(boards, item) {
|
|
@@ -106,6 +308,21 @@ function workItemPhaseSemantics(boards, item) {
|
|
|
106
308
|
return resolvePhaseSemantics(boards, boardForWorkItem(item), stage);
|
|
107
309
|
}
|
|
108
310
|
/**
|
|
311
|
+
* Flow-metric outcomes of each board's phases: the phase the board closes completed sources into
|
|
312
|
+
* (else its first terminal phase) completes a card, other terminal phases cancel it, resting
|
|
313
|
+
* phases queue it, and anything else (working, or a phase the board no longer declares) is in
|
|
314
|
+
* flight.
|
|
315
|
+
*/
|
|
316
|
+
function boardPhaseOutcomes(boards) {
|
|
317
|
+
return (item, stage) => {
|
|
318
|
+
const board = boards.get(boardForWorkItem(item));
|
|
319
|
+
const kind = board?.phaseKind(stage);
|
|
320
|
+
if (!board || kind === void 0 || kind === "working") return "pipeline";
|
|
321
|
+
if (kind === "resting") return "queued";
|
|
322
|
+
return stage === (board.sourceClosed?.completed ?? Object.keys(board.phases).find((key) => board.isTerminal(key))) ? "completed" : "canceled";
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
109
326
|
* Where source-closed rules send a persisted card: the `sourceClosed` mapping its installed
|
|
110
327
|
* board declares, plus whether the card already sits in a terminal phase. Undefined when the
|
|
111
328
|
* board is not installed or declares no mapping, so closing the source leaves the card alone.
|
|
@@ -137,6 +354,20 @@ function rulePhaseField(boards, item) {
|
|
|
137
354
|
const phase = rulePhaseContext(boards, item);
|
|
138
355
|
return phase ? { phase } : {};
|
|
139
356
|
}
|
|
140
|
-
|
|
357
|
+
/**
|
|
358
|
+
* The change request a review session on this card may publish checks for: the card's own one,
|
|
359
|
+
* or, for an issue card in its board's pull request review phase, the pull request attached to it.
|
|
360
|
+
*/
|
|
361
|
+
function boundChangeRequestNumber(boards, item) {
|
|
362
|
+
const source = workItemBranchSource(item.externalSource);
|
|
363
|
+
if (!isPullRequestCard({ source }) && (item.stages.length !== 1 || cardBoardFlow(boards, item).pullRequestReview !== item.stages[0])) return;
|
|
364
|
+
const number = reviewedChangeRequest({
|
|
365
|
+
...item,
|
|
366
|
+
source
|
|
367
|
+
})?.number;
|
|
368
|
+
if (number !== void 0) return String(number);
|
|
369
|
+
return source === "github-pr" ? /(\d+)$/.exec(item.externalSource?.externalId ?? "")?.[1] : void 0;
|
|
370
|
+
}
|
|
371
|
+
export { awaitsAcceptance, boardEventHandlers, boardFlow, boardForWorkItem, boardPhaseOutcomes, boundChangeRequestNumber, cardBoardFlow, cardOwnsBranch, eventBoardId, hasPullRequest, hasRecordedVerdict, intakeTarget, isPullRequestCard, isPullRequestReviewPhase, isTerminalWorkItem, newestOpenPullRequestNumber, newestOwnedOpenPullRequestNumber, pullRequestCardRejection, pullRequestSourceNumber, pullRequestSources, resolveBoardClosure, resolveBoardToolRule, resolvePhaseSemantics, reviewedChangeRequest, reviewedPullRequest, reviewsPullRequest, rulePhaseContext, rulePhaseField, sourceExternalId, withBoardClosure, withBoardFlow, withIntakeTarget, workItemPhaseSemantics };
|
|
141
372
|
|
|
142
373
|
//# sourceMappingURL=semantics.js.map
|