@ambystech/ambykit 1.5.0 → 2.0.0-rc.1
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/CHANGELOG.md +190 -1
- package/README.md +12 -7
- package/dist/cli/add.js +9 -0
- package/dist/cli/add.js.map +1 -1
- package/dist/cli/analyze.js +25 -4
- package/dist/cli/analyze.js.map +1 -1
- package/dist/cli/base-command.d.ts +8 -0
- package/dist/cli/base-command.js +30 -0
- package/dist/cli/base-command.js.map +1 -1
- package/dist/cli/check.d.ts +2 -0
- package/dist/cli/check.js +38 -4
- package/dist/cli/check.js.map +1 -1
- package/dist/cli/dashboard.d.ts +5 -2
- package/dist/cli/dashboard.js +95 -24
- package/dist/cli/dashboard.js.map +1 -1
- package/dist/cli/edit.d.ts +17 -0
- package/dist/cli/edit.js +71 -0
- package/dist/cli/edit.js.map +1 -0
- package/dist/cli/fleet.d.ts +2 -0
- package/dist/cli/fleet.js +23 -1
- package/dist/cli/fleet.js.map +1 -1
- package/dist/cli/index.d.ts +1 -5
- package/dist/cli/index.js +21 -109
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/init.js +9 -0
- package/dist/cli/init.js.map +1 -1
- package/dist/cli/lane.d.ts +38 -3
- package/dist/cli/lane.js +124 -108
- package/dist/cli/lane.js.map +1 -1
- package/dist/cli/main.d.ts +6 -0
- package/dist/cli/main.js +111 -0
- package/dist/cli/main.js.map +1 -0
- package/dist/cli/mcp.d.ts +2 -0
- package/dist/cli/mcp.js +4 -0
- package/dist/cli/mcp.js.map +1 -1
- package/dist/cli/migrate.d.ts +17 -0
- package/dist/cli/migrate.js +67 -0
- package/dist/cli/migrate.js.map +1 -0
- package/dist/cli/node-guard.d.ts +4 -0
- package/dist/cli/node-guard.js +12 -0
- package/dist/cli/node-guard.js.map +1 -0
- package/dist/cli/run-budget.d.ts +25 -0
- package/dist/cli/run-budget.js +112 -0
- package/dist/cli/run-budget.js.map +1 -0
- package/dist/cli/run-control.d.ts +40 -0
- package/dist/cli/run-control.js +161 -0
- package/dist/cli/run-control.js.map +1 -0
- package/dist/cli/run-files.d.ts +96 -0
- package/dist/cli/run-files.js +120 -0
- package/dist/cli/run-files.js.map +1 -0
- package/dist/cli/run-fleet-control.d.ts +16 -0
- package/dist/cli/run-fleet-control.js +23 -0
- package/dist/cli/run-fleet-control.js.map +1 -0
- package/dist/cli/run-fleet-loop.d.ts +77 -0
- package/dist/cli/run-fleet-loop.js +156 -0
- package/dist/cli/run-fleet-loop.js.map +1 -0
- package/dist/cli/run-fleet-merge.d.ts +22 -0
- package/dist/cli/run-fleet-merge.js +69 -0
- package/dist/cli/run-fleet-merge.js.map +1 -0
- package/dist/cli/run-fleet-prepare.d.ts +35 -0
- package/dist/cli/run-fleet-prepare.js +58 -0
- package/dist/cli/run-fleet-prepare.js.map +1 -0
- package/dist/cli/run-fleet.d.ts +28 -0
- package/dist/cli/run-fleet.js +382 -0
- package/dist/cli/run-fleet.js.map +1 -0
- package/dist/cli/run-gates.d.ts +25 -0
- package/dist/cli/run-gates.js +45 -0
- package/dist/cli/run-gates.js.map +1 -0
- package/dist/cli/run-launch.d.ts +17 -0
- package/dist/cli/run-launch.js +106 -0
- package/dist/cli/run-launch.js.map +1 -0
- package/dist/cli/run-loop.d.ts +39 -0
- package/dist/cli/run-loop.js +197 -0
- package/dist/cli/run-loop.js.map +1 -0
- package/dist/cli/run-merger.d.ts +18 -0
- package/dist/cli/run-merger.js +126 -0
- package/dist/cli/run-merger.js.map +1 -0
- package/dist/cli/run-phase-check.d.ts +32 -0
- package/dist/cli/run-phase-check.js +173 -0
- package/dist/cli/run-phase-check.js.map +1 -0
- package/dist/cli/run-plan.d.ts +28 -0
- package/dist/cli/run-plan.js +62 -0
- package/dist/cli/run-plan.js.map +1 -0
- package/dist/cli/run-process.d.ts +45 -0
- package/dist/cli/run-process.js +111 -0
- package/dist/cli/run-process.js.map +1 -0
- package/dist/cli/run-protocol-prompts.d.ts +17 -0
- package/dist/cli/run-protocol-prompts.js +63 -0
- package/dist/cli/run-protocol-prompts.js.map +1 -0
- package/dist/cli/run-protocol.d.ts +17 -0
- package/dist/cli/run-protocol.js +128 -0
- package/dist/cli/run-protocol.js.map +1 -0
- package/dist/cli/run-script.d.ts +11 -0
- package/dist/cli/run-script.js +67 -0
- package/dist/cli/run-script.js.map +1 -0
- package/dist/cli/run-session.d.ts +93 -0
- package/dist/cli/run-session.js +21 -0
- package/dist/cli/run-session.js.map +1 -0
- package/dist/cli/run-stages.d.ts +11 -0
- package/dist/cli/run-stages.js +34 -0
- package/dist/cli/run-stages.js.map +1 -0
- package/dist/cli/run-supervisor.d.ts +20 -0
- package/dist/cli/run-supervisor.js +167 -0
- package/dist/cli/run-supervisor.js.map +1 -0
- package/dist/cli/run.d.ts +81 -0
- package/dist/cli/run.js +437 -0
- package/dist/cli/run.js.map +1 -0
- package/dist/cli/sync.js +10 -5
- package/dist/cli/sync.js.map +1 -1
- package/dist/cli/ui/dashboard/empty-state.d.ts +5 -0
- package/dist/cli/ui/dashboard/empty-state.js +7 -0
- package/dist/cli/ui/dashboard/empty-state.js.map +1 -1
- package/dist/cli/ui/dashboard/filter-line.d.ts +13 -0
- package/dist/cli/ui/dashboard/filter-line.js +20 -0
- package/dist/cli/ui/dashboard/filter-line.js.map +1 -0
- package/dist/cli/ui/dashboard/fleet-tab.d.ts +25 -0
- package/dist/cli/ui/dashboard/fleet-tab.js +91 -0
- package/dist/cli/ui/dashboard/fleet-tab.js.map +1 -0
- package/dist/cli/ui/dashboard/fleet-tokens.d.ts +404 -0
- package/dist/cli/ui/dashboard/fleet-tokens.js +405 -0
- package/dist/cli/ui/dashboard/fleet-tokens.js.map +1 -0
- package/dist/cli/ui/dashboard/fleet-view.d.ts +51 -0
- package/dist/cli/ui/dashboard/fleet-view.js +211 -0
- package/dist/cli/ui/dashboard/fleet-view.js.map +1 -0
- package/dist/cli/ui/dashboard/help-overlay.d.ts +3 -1
- package/dist/cli/ui/dashboard/help-overlay.js +36 -3
- package/dist/cli/ui/dashboard/help-overlay.js.map +1 -1
- package/dist/cli/ui/dashboard/layout.d.ts +15 -0
- package/dist/cli/ui/dashboard/layout.js +22 -0
- package/dist/cli/ui/dashboard/layout.js.map +1 -1
- package/dist/cli/ui/dashboard/metrics-panel.d.ts +15 -0
- package/dist/cli/ui/dashboard/metrics-panel.js +143 -0
- package/dist/cli/ui/dashboard/metrics-panel.js.map +1 -0
- package/dist/cli/ui/dashboard/tab-bar.d.ts +14 -0
- package/dist/cli/ui/dashboard/tab-bar.js +37 -0
- package/dist/cli/ui/dashboard/tab-bar.js.map +1 -0
- package/dist/cli/ui/dashboard/tab-frame.d.ts +43 -0
- package/dist/cli/ui/dashboard/tab-frame.js +68 -0
- package/dist/cli/ui/dashboard/tab-frame.js.map +1 -0
- package/dist/cli/ui/dashboard/tab-tokens.d.ts +569 -0
- package/dist/cli/ui/dashboard/tab-tokens.js +570 -0
- package/dist/cli/ui/dashboard/tab-tokens.js.map +1 -0
- package/dist/cli/ui/icons.d.ts +22 -0
- package/dist/cli/ui/icons.js +17 -0
- package/dist/cli/ui/icons.js.map +1 -0
- package/dist/cli/ui/interactive/fleet-actions.d.ts +24 -0
- package/dist/cli/ui/interactive/fleet-actions.js +30 -0
- package/dist/cli/ui/interactive/fleet-actions.js.map +1 -0
- package/dist/cli/ui/interactive/fleet.d.ts +54 -0
- package/dist/cli/ui/interactive/fleet.js +98 -0
- package/dist/cli/ui/interactive/fleet.js.map +1 -0
- package/dist/cli/ui/interactive/fullscreen.js +38 -10
- package/dist/cli/ui/interactive/fullscreen.js.map +1 -1
- package/dist/cli/ui/interactive/list-filter.d.ts +25 -0
- package/dist/cli/ui/interactive/list-filter.js +38 -0
- package/dist/cli/ui/interactive/list-filter.js.map +1 -0
- package/dist/cli/ui/interactive/live.d.ts +8 -0
- package/dist/cli/ui/interactive/live.js +13 -0
- package/dist/cli/ui/interactive/live.js.map +1 -1
- package/dist/cli/ui/interactive/overview.d.ts +52 -3
- package/dist/cli/ui/interactive/overview.js +354 -15
- package/dist/cli/ui/interactive/overview.js.map +1 -1
- package/dist/cli/ui/interactive/tabs.d.ts +15 -0
- package/dist/cli/ui/interactive/tabs.js +27 -0
- package/dist/cli/ui/interactive/tabs.js.map +1 -0
- package/dist/cli/ui/tool-options.d.ts +5 -1
- package/dist/cli/ui/tool-options.js +9 -3
- package/dist/cli/ui/tool-options.js.map +1 -1
- package/dist/cli/update.js +13 -2
- package/dist/cli/update.js.map +1 -1
- package/dist/core/analyze.d.ts +11 -0
- package/dist/core/analyze.js +33 -3
- package/dist/core/analyze.js.map +1 -1
- package/dist/core/burndown.d.ts +1 -1
- package/dist/core/burndown.js +2 -2
- package/dist/core/burndown.js.map +1 -1
- package/dist/core/checkouts.js +3 -2
- package/dist/core/checkouts.js.map +1 -1
- package/dist/core/config-schema.d.ts +45 -0
- package/dist/core/config-schema.js +63 -0
- package/dist/core/config-schema.js.map +1 -0
- package/dist/core/config.d.ts +6 -0
- package/dist/core/config.js +16 -0
- package/dist/core/config.js.map +1 -1
- package/dist/core/dashboard.js +3 -2
- package/dist/core/dashboard.js.map +1 -1
- package/dist/core/decisions.d.ts +12 -1
- package/dist/core/decisions.js +7 -2
- package/dist/core/decisions.js.map +1 -1
- package/dist/core/deprecation.d.ts +15 -0
- package/dist/core/deprecation.js +27 -0
- package/dist/core/deprecation.js.map +1 -0
- package/dist/core/features.js +11 -5
- package/dist/core/features.js.map +1 -1
- package/dist/core/fleet/fleet-text.d.ts +2 -0
- package/dist/core/fleet/fleet-text.js +41 -0
- package/dist/core/fleet/fleet-text.js.map +1 -0
- package/dist/core/fleet/fleet-view.d.ts +35 -0
- package/dist/core/fleet/fleet-view.js +43 -0
- package/dist/core/fleet/fleet-view.js.map +1 -0
- package/dist/core/fleet/fleets.d.ts +18 -0
- package/dist/core/fleet/fleets.js +64 -0
- package/dist/core/fleet/fleets.js.map +1 -0
- package/dist/core/fleet/flow-input.js +3 -4
- package/dist/core/fleet/flow-input.js.map +1 -1
- package/dist/core/fleet/index.d.ts +3 -0
- package/dist/core/fleet/index.js +3 -0
- package/dist/core/fleet/index.js.map +1 -1
- package/dist/core/fleet/runs.d.ts +18 -2
- package/dist/core/fleet/runs.js +67 -16
- package/dist/core/fleet/runs.js.map +1 -1
- package/dist/core/fleet-plan/budget.d.ts +18 -0
- package/dist/core/fleet-plan/budget.js +13 -0
- package/dist/core/fleet-plan/budget.js.map +1 -0
- package/dist/core/fleet-plan/contain.d.ts +10 -0
- package/dist/core/fleet-plan/contain.js +37 -0
- package/dist/core/fleet-plan/contain.js.map +1 -0
- package/dist/core/fleet-plan/format.d.ts +4 -0
- package/dist/core/fleet-plan/format.js +52 -0
- package/dist/core/fleet-plan/format.js.map +1 -0
- package/dist/core/fleet-plan/index.d.ts +7 -0
- package/dist/core/fleet-plan/index.js +8 -0
- package/dist/core/fleet-plan/index.js.map +1 -0
- package/dist/core/fleet-plan/order.d.ts +30 -0
- package/dist/core/fleet-plan/order.js +96 -0
- package/dist/core/fleet-plan/order.js.map +1 -0
- package/dist/core/fleet-plan/ownership.d.ts +12 -0
- package/dist/core/fleet-plan/ownership.js +36 -0
- package/dist/core/fleet-plan/ownership.js.map +1 -0
- package/dist/core/fleet-plan/plan.d.ts +23 -0
- package/dist/core/fleet-plan/plan.js +40 -0
- package/dist/core/fleet-plan/plan.js.map +1 -0
- package/dist/core/fleet-plan/read.d.ts +19 -0
- package/dist/core/fleet-plan/read.js +35 -0
- package/dist/core/fleet-plan/read.js.map +1 -0
- package/dist/core/fleet-plan/schedule.d.ts +15 -0
- package/dist/core/fleet-plan/schedule.js +27 -0
- package/dist/core/fleet-plan/schedule.js.map +1 -0
- package/dist/core/fleet-plan/select.d.ts +20 -0
- package/dist/core/fleet-plan/select.js +64 -0
- package/dist/core/fleet-plan/select.js.map +1 -0
- package/dist/core/fleet-plan/types.d.ts +123 -0
- package/dist/core/fleet-plan/types.js +2 -0
- package/dist/core/fleet-plan/types.js.map +1 -0
- package/dist/core/fleet-view/derive.d.ts +14 -0
- package/dist/core/fleet-view/derive.js +54 -0
- package/dist/core/fleet-view/derive.js.map +1 -0
- package/dist/core/fleet-view/group.d.ts +51 -0
- package/dist/core/fleet-view/group.js +73 -0
- package/dist/core/fleet-view/group.js.map +1 -0
- package/dist/core/fleet-view/json.d.ts +37 -0
- package/dist/core/fleet-view/json.js +25 -0
- package/dist/core/fleet-view/json.js.map +1 -0
- package/dist/core/fleet-view/read.d.ts +8 -0
- package/dist/core/fleet-view/read.js +44 -0
- package/dist/core/fleet-view/read.js.map +1 -0
- package/dist/core/fleet-view/types.d.ts +52 -0
- package/dist/core/fleet-view/types.js +2 -0
- package/dist/core/fleet-view/types.js.map +1 -0
- package/dist/core/graph-format.d.ts +2 -0
- package/dist/core/graph-format.js +4 -3
- package/dist/core/graph-format.js.map +1 -1
- package/dist/core/graph-types.d.ts +4 -0
- package/dist/core/graph.js +38 -1
- package/dist/core/graph.js.map +1 -1
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.js +1 -0
- package/dist/core/index.js.map +1 -1
- package/dist/core/lane-merge.d.ts +29 -0
- package/dist/core/lane-merge.js +105 -0
- package/dist/core/lane-merge.js.map +1 -0
- package/dist/core/lanes.d.ts +53 -0
- package/dist/core/lanes.js +131 -0
- package/dist/core/lanes.js.map +1 -1
- package/dist/core/legacy.d.ts +2 -1
- package/dist/core/legacy.js +7 -2
- package/dist/core/legacy.js.map +1 -1
- package/dist/core/markers.d.ts +7 -0
- package/dist/core/markers.js +3 -2
- package/dist/core/markers.js.map +1 -1
- package/dist/core/metrics/cycle.d.ts +3 -0
- package/dist/core/metrics/cycle.js +47 -0
- package/dist/core/metrics/cycle.js.map +1 -0
- package/dist/core/metrics/gap.d.ts +9 -0
- package/dist/core/metrics/gap.js +35 -0
- package/dist/core/metrics/gap.js.map +1 -0
- package/dist/core/metrics/index.d.ts +21 -0
- package/dist/core/metrics/index.js +67 -0
- package/dist/core/metrics/index.js.map +1 -0
- package/dist/core/metrics/model.d.ts +23 -0
- package/dist/core/metrics/model.js +46 -0
- package/dist/core/metrics/model.js.map +1 -0
- package/dist/core/metrics/revisions.d.ts +22 -0
- package/dist/core/metrics/revisions.js +88 -0
- package/dist/core/metrics/revisions.js.map +1 -0
- package/dist/core/metrics/types.d.ts +74 -0
- package/dist/core/metrics/types.js +3 -0
- package/dist/core/metrics/types.js.map +1 -0
- package/dist/core/migrate/convert-spec.d.ts +19 -0
- package/dist/core/migrate/convert-spec.js +99 -0
- package/dist/core/migrate/convert-spec.js.map +1 -0
- package/dist/core/migrate/convert-tasks.d.ts +16 -0
- package/dist/core/migrate/convert-tasks.js +121 -0
- package/dist/core/migrate/convert-tasks.js.map +1 -0
- package/dist/core/migrate/run.d.ts +36 -0
- package/dist/core/migrate/run.js +178 -0
- package/dist/core/migrate/run.js.map +1 -0
- package/dist/core/migrate/safety.d.ts +33 -0
- package/dist/core/migrate/safety.js +199 -0
- package/dist/core/migrate/safety.js.map +1 -0
- package/dist/core/migrate/summary.d.ts +36 -0
- package/dist/core/migrate/summary.js +140 -0
- package/dist/core/migrate/summary.js.map +1 -0
- package/dist/core/moved-targets.d.ts +73 -8
- package/dist/core/moved-targets.js +79 -1
- package/dist/core/moved-targets.js.map +1 -1
- package/dist/core/overview-types.d.ts +7 -0
- package/dist/core/overview-types.js.map +1 -1
- package/dist/core/overview.js +4 -0
- package/dist/core/overview.js.map +1 -1
- package/dist/core/query.js +3 -2
- package/dist/core/query.js.map +1 -1
- package/dist/core/run-gate-actions.d.ts +51 -0
- package/dist/core/run-gate-actions.js +105 -0
- package/dist/core/run-gate-actions.js.map +1 -0
- package/dist/core/run-launch-plan.d.ts +53 -0
- package/dist/core/run-launch-plan.js +32 -0
- package/dist/core/run-launch-plan.js.map +1 -0
- package/dist/core/run-prompt.d.ts +89 -0
- package/dist/core/run-prompt.js +73 -0
- package/dist/core/run-prompt.js.map +1 -0
- package/dist/core/run-result.d.ts +42 -0
- package/dist/core/run-result.js +163 -0
- package/dist/core/run-result.js.map +1 -0
- package/dist/core/run-review.d.ts +50 -0
- package/dist/core/run-review.js +20 -0
- package/dist/core/run-review.js.map +1 -0
- package/dist/core/run-schedule.d.ts +23 -0
- package/dist/core/run-schedule.js +40 -0
- package/dist/core/run-schedule.js.map +1 -0
- package/dist/core/run-stability.d.ts +23 -0
- package/dist/core/run-stability.js +38 -0
- package/dist/core/run-stability.js.map +1 -0
- package/dist/core/run-supervise.d.ts +71 -0
- package/dist/core/run-supervise.js +61 -0
- package/dist/core/run-supervise.js.map +1 -0
- package/dist/core/runners.d.ts +114 -0
- package/dist/core/runners.js +146 -0
- package/dist/core/runners.js.map +1 -0
- package/dist/core/sibling-reads.d.ts +41 -0
- package/dist/core/sibling-reads.js +100 -0
- package/dist/core/sibling-reads.js.map +1 -0
- package/dist/core/spec-format/blocks.d.ts +19 -0
- package/dist/core/spec-format/blocks.js +58 -0
- package/dist/core/spec-format/blocks.js.map +1 -0
- package/dist/core/spec-format/detect.d.ts +14 -0
- package/dist/core/spec-format/detect.js +30 -0
- package/dist/core/spec-format/detect.js.map +1 -0
- package/dist/core/spec-format/dispatch.d.ts +13 -0
- package/dist/core/spec-format/dispatch.js +64 -0
- package/dist/core/spec-format/dispatch.js.map +1 -0
- package/dist/core/spec-format/frontmatter.d.ts +18 -0
- package/dist/core/spec-format/frontmatter.js +37 -0
- package/dist/core/spec-format/frontmatter.js.map +1 -0
- package/dist/core/spec-format/legacy.d.ts +40 -0
- package/dist/core/spec-format/legacy.js +91 -0
- package/dist/core/spec-format/legacy.js.map +1 -0
- package/dist/core/spec-format/meta.d.ts +3 -0
- package/dist/core/spec-format/meta.js +24 -0
- package/dist/core/spec-format/meta.js.map +1 -0
- package/dist/core/spec-format/model.d.ts +50 -0
- package/dist/core/spec-format/model.js +9 -0
- package/dist/core/spec-format/model.js.map +1 -0
- package/dist/core/spec-format/read-spec.d.ts +4 -0
- package/dist/core/spec-format/read-spec.js +102 -0
- package/dist/core/spec-format/read-spec.js.map +1 -0
- package/dist/core/spec-format/read-tasks.d.ts +2 -0
- package/dist/core/spec-format/read-tasks.js +146 -0
- package/dist/core/spec-format/read-tasks.js.map +1 -0
- package/dist/core/spec-format/write.d.ts +23 -0
- package/dist/core/spec-format/write.js +382 -0
- package/dist/core/spec-format/write.js.map +1 -0
- package/dist/core/subagents.js +0 -2
- package/dist/core/subagents.js.map +1 -1
- package/dist/core/tasks-edit.d.ts +4 -1
- package/dist/core/tasks-edit.js +19 -6
- package/dist/core/tasks-edit.js.map +1 -1
- package/dist/core/types.d.ts +21 -0
- package/dist/emitters/index.d.ts +0 -4
- package/dist/emitters/index.js +0 -10
- package/dist/emitters/index.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/plugins/api.d.ts +14 -8
- package/dist/plugins/api.js +9 -8
- package/dist/plugins/api.js.map +1 -1
- package/dist/plugins/index.d.ts +3 -2
- package/dist/plugins/index.js +3 -2
- package/dist/plugins/index.js.map +1 -1
- package/dist/plugins/loader.d.ts +8 -0
- package/dist/plugins/loader.js +36 -6
- package/dist/plugins/loader.js.map +1 -1
- package/dist/plugins/report.d.ts +1 -1
- package/dist/plugins/report.js +3 -4
- package/dist/plugins/report.js.map +1 -1
- package/dist/plugins/session.d.ts +1 -0
- package/dist/plugins/session.js +1 -1
- package/dist/plugins/session.js.map +1 -1
- package/dist/testkit/index.d.ts +1 -1
- package/docs/architecture.md +16 -1
- package/docs/artifacts/decision-record.md +15 -0
- package/docs/artifacts/spec.md +35 -6
- package/docs/artifacts/tasks.md +67 -16
- package/docs/cli-reference.md +274 -5
- package/docs/contributing.md +6 -0
- package/docs/migration.md +191 -0
- package/docs/plugin-api.md +21 -13
- package/docs/plugin-split.md +5 -3
- package/docs/plugin-trust.md +2 -2
- package/docs/plugins-release.md +105 -0
- package/docs/release.md +103 -0
- package/docs/stability.md +152 -0
- package/docs/tool-compatibility.md +41 -3
- package/docs/workflow.md +10 -6
- package/package.json +4 -2
- package/src/agents/worker.md +2 -1
- package/src/prompts/converge.md +2 -2
- package/src/prompts/implement.md +13 -11
- package/src/prompts/revise.md +5 -2
- package/src/prompts/run.md +7 -4
- package/src/prompts/specify.md +5 -3
- package/src/prompts/tasks.md +9 -8
- package/src/templates/spec.md +10 -4
- package/src/templates/tasks.md +35 -13
- package/dist/emitters/antigravity-cli.d.ts +0 -15
- package/dist/emitters/antigravity-cli.js +0 -20
- package/dist/emitters/antigravity-cli.js.map +0 -1
- package/dist/emitters/antigravity.d.ts +0 -20
- package/dist/emitters/antigravity.js +0 -24
- package/dist/emitters/antigravity.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate.js","sourceRoot":"","sources":["../../src/cli/migrate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,IAAI,EAAmB,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAEzD,2FAA2F;AAC3F,MAAM,CAAC,MAAM,WAAW,GACtB,4HAA4H;IAC5H,+HAA+H,CAAC;AAElI;;;;;GAKG;AACH,MAAM,OAAO,cAAe,SAAQ,WAAW;IACpC,IAAI,GAAG,SAAS,CAAC;IACjB,OAAO,GAAG,8FAA8F,CAAC;IACzG,KAAK,GAAG,+DAA+D,CAAC;IAEjF,iFAAiF;IACjF,IAAuB,kBAAkB;QACvC,OAAO,KAAK,CAAC;IACf,CAAC;IAES,KAAK,CAAC,OAAO,CAAC,IAAgB;QACtC,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACxC,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QACrC,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;QACpC,MAAM,MAAM,GAAG,cAAc,CAAC,IAAI,E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AM,KAAK,OAAO,EAAE,CAAC;YAC5B,IAAI,CAAC,IAAI,CAAC,aAAa,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,kBAAkB,IAAI,CAAC,EAAE,6CAA6C,CAAC,CAAC;QACzK,CAAC;aAAM,IAAI,IAAI,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;YACpC,IAAI,CAAC,IAAI,CAAC,WAAW,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;QACtC,CAAC;QAED,IAAI,MAAM,CAAC,MAAM,CAAC,SAAS,GAAG,CAAC,EAAE,CAAC;YAChC,IAAI,CAAC,IAAI,CAAC,KAAK,WAAW,EAAE,CAAC,CAAC;YAC9B,IAAI,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC;gBAAE,IAAI,CAAC,IAAI,CAAC,yHAAyH,CAAC,CAAC;QACrK,CAAC;QACD,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,GAAG,CAAC,EAAE,CAAC;YAC9B,IAAI,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,qFAAqF,CAAC,CAAC;QAC3H,CAAC;QACD,IAAI,MAAM,CAAC,MAAM,CAAC,SAAS,KAAK,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,KAAK,CAAC;YAAE,IAAI,CAAC,OAAO,CAAC,6DAA6D,CAAC,CAAC;QAC9I,OAAO,CAAC,CAAC;IACX,CAAC;CACF"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** The minimum Node major AmbyKit 2 supports. */
|
|
2
|
+
export declare const MIN_NODE_MAJOR = 22;
|
|
3
|
+
/** The message to print when `version` (e.g. `process.versions.node`) is below the minimum; null when it is fine. */
|
|
4
|
+
export declare function checkNode(version: string): string | null;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Node version guard (030:FR-015). Pure and import-free so the launcher can run it before the CLI's module graph loads:
|
|
2
|
+
// on an older Node a newer-syntax import would otherwise fail with a SyntaxError that hides the message.
|
|
3
|
+
/** The minimum Node major AmbyKit 2 supports. */
|
|
4
|
+
export const MIN_NODE_MAJOR = 22;
|
|
5
|
+
/** The message to print when `version` (e.g. `process.versions.node`) is below the minimum; null when it is fine. */
|
|
6
|
+
export function checkNode(version) {
|
|
7
|
+
const major = Number.parseInt(version.split(".")[0] ?? "", 10);
|
|
8
|
+
if (Number.isFinite(major) && major >= MIN_NODE_MAJOR)
|
|
9
|
+
return null;
|
|
10
|
+
return `AmbyKit 2 needs Node.js ${MIN_NODE_MAJOR} or newer (found ${version || "unknown"}). Upgrade Node.js, then run this command again.`;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=node-guard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-guard.js","sourceRoot":"","sources":["../../src/cli/node-guard.ts"],"names":[],"mappings":"AAAA,wHAAwH;AACxH,yGAAyG;AAEzG,iDAAiD;AACjD,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,CAAC;AAEjC,qHAAqH;AACrH,MAAM,UAAU,SAAS,CAAC,OAAe;IACvC,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;IAC/D,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,cAAc;QAAE,OAAO,IAAI,CAAC;IACnE,OAAO,2BAA2B,cAAc,oBAAoB,OAAO,IAAI,SAAS,kDAAkD,CAAC;AAC7I,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type Session } from "./run-session.js";
|
|
2
|
+
/**
|
|
3
|
+
* Budgets (feature 028, FR-013, FR-014). Wall-clock and task count are always enforced; a token ceiling only
|
|
4
|
+
* where every runner reports usage, and the run says so when it cannot be. Exceeding a budget stops launching,
|
|
5
|
+
* writes a `stop` directive for each running lane (through spec 025's single writer), records why in the run
|
|
6
|
+
* state, and terminates a lane that has not reported once the stop grace is over.
|
|
7
|
+
*/
|
|
8
|
+
/** Count restarts and fix rounds as task events: the budget has room for rework (default 2 × open tasks). */
|
|
9
|
+
export declare function addTaskEvents(s: Session, n: number): void;
|
|
10
|
+
/** Add the tokens a runner reported for one process (033: the claude runner's JSON result), so a token ceiling holds. */
|
|
11
|
+
export declare function addTokens(s: Session, n: number): void;
|
|
12
|
+
/**
|
|
13
|
+
* Advance the meter: add elapsed time, count newly checked tasks once (a continued run does not count them
|
|
14
|
+
* again) and release their claims (spec 025: claims are advisory and end at check-off).
|
|
15
|
+
*/
|
|
16
|
+
export declare function meter(s: Session, dtMs: number): void;
|
|
17
|
+
/** Check the budgets; on the first overrun, begin the stop. Returns the reason once, then `undefined`. */
|
|
18
|
+
export declare function enforceBudgets(s: Session): string | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Begin a budget stop: nothing new launches, running lanes get a `stop` directive through 025's writer and the run
|
|
21
|
+
* is recorded as paused with the reason. Shared by the run's own budgets and by a fleet's (feature 031, FR-011).
|
|
22
|
+
*/
|
|
23
|
+
export declare function beginStop(s: Session, reason: string, unenforced?: string[]): void;
|
|
24
|
+
/** Terminate every running lane (used when a budget stop has run out its grace, and on interrupt). */
|
|
25
|
+
export declare function stopAll(s: Session, signal?: "SIGTERM" | "SIGKILL"): void;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { writeDirective, readRun, updateRun, releaseTaskClaims } from "../core/fleet/index.js";
|
|
2
|
+
import { budgetDecision } from "../core/run-supervise.js";
|
|
3
|
+
import { pendingGates } from "../core/run-gate-actions.js";
|
|
4
|
+
import { laneOpenTasks } from "./run-plan.js";
|
|
5
|
+
import { readBudget, writeBudget } from "./run-files.js";
|
|
6
|
+
import { event, isRunning, stopProcess } from "./run-session.js";
|
|
7
|
+
import { stopPhaseCheck } from "./run-phase-check.js";
|
|
8
|
+
/**
|
|
9
|
+
* Budgets (feature 028, FR-013, FR-014). Wall-clock and task count are always enforced; a token ceiling only
|
|
10
|
+
* where every runner reports usage, and the run says so when it cannot be. Exceeding a budget stops launching,
|
|
11
|
+
* writes a `stop` directive for each running lane (through spec 025's single writer), records why in the run
|
|
12
|
+
* state, and terminates a lane that has not reported once the stop grace is over.
|
|
13
|
+
*/
|
|
14
|
+
/** Count restarts and fix rounds as task events: the budget has room for rework (default 2 × open tasks). */
|
|
15
|
+
export function addTaskEvents(s, n) {
|
|
16
|
+
const b = readBudget(s.root, s.run);
|
|
17
|
+
writeBudget(s.root, s.run, { ...b, tasksUsed: b.tasksUsed + n });
|
|
18
|
+
}
|
|
19
|
+
/** Add the tokens a runner reported for one process (033: the claude runner's JSON result), so a token ceiling holds. */
|
|
20
|
+
export function addTokens(s, n) {
|
|
21
|
+
if (!(n > 0))
|
|
22
|
+
return;
|
|
23
|
+
const b = readBudget(s.root, s.run);
|
|
24
|
+
writeBudget(s.root, s.run, { ...b, tokensUsed: (b.tokensUsed ?? 0) + n });
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Advance the meter: add elapsed time, count newly checked tasks once (a continued run does not count them
|
|
28
|
+
* again) and release their claims (spec 025: claims are advisory and end at check-off).
|
|
29
|
+
*/
|
|
30
|
+
export function meter(s, dtMs) {
|
|
31
|
+
const b = readBudget(s.root, s.run);
|
|
32
|
+
const counted = new Set(b.counted);
|
|
33
|
+
let added = 0;
|
|
34
|
+
for (const rt of s.lanes) {
|
|
35
|
+
const open = new Set(laneOpenTasks(rt.ref));
|
|
36
|
+
for (const t of rt.ref.manifest.tasks) {
|
|
37
|
+
if (open.has(t.id) || counted.has(`${rt.ref.name}:${t.id}`))
|
|
38
|
+
continue;
|
|
39
|
+
counted.add(`${rt.ref.name}:${t.id}`);
|
|
40
|
+
added += 1;
|
|
41
|
+
releaseTaskClaims(s.root, s.feature, t.id);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const dt = waitingForPerson(s) ? 0 : Math.max(0, dtMs);
|
|
45
|
+
writeBudget(s.root, s.run, { ...b, elapsedMs: b.elapsedMs + dt, tasksUsed: b.tasksUsed + added, counted: [...counted] });
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Lane states that wait for a person (a resume, a merge resolved by hand, a decision after a failed turn, or a turn that
|
|
49
|
+
* ended with tasks open: the 2.0 dogfood re-run counted 18 hours overnight on an `unfinished` lane).
|
|
50
|
+
*/
|
|
51
|
+
const WAITS_FOR_PERSON = new Set(["paused", "conflict", "escalated", "failed", "unfinished"]);
|
|
52
|
+
/**
|
|
53
|
+
* Time a run spends waiting for a person costs no assistant work, so it is not wall-clock budget: the meter stands
|
|
54
|
+
* still while no lane process is running and the run waits at a story checkpoint or on a lane that needs a person.
|
|
55
|
+
*/
|
|
56
|
+
function waitingForPerson(s) {
|
|
57
|
+
if (s.lanes.some((rt) => isRunning(s, rt)))
|
|
58
|
+
return false;
|
|
59
|
+
if (s.lanes.some((rt) => WAITS_FOR_PERSON.has(rt.file.status)))
|
|
60
|
+
return true;
|
|
61
|
+
const rec = readRun(s.root, s.run);
|
|
62
|
+
return !!rec && pendingGates(rec).length > 0;
|
|
63
|
+
}
|
|
64
|
+
/** Check the budgets; on the first overrun, begin the stop. Returns the reason once, then `undefined`. */
|
|
65
|
+
export function enforceBudgets(s) {
|
|
66
|
+
if (s.stopReason)
|
|
67
|
+
return undefined;
|
|
68
|
+
const b = readBudget(s.root, s.run);
|
|
69
|
+
const d = budgetDecision(s.budgets, {
|
|
70
|
+
elapsedMs: b.elapsedMs,
|
|
71
|
+
tasksUsed: b.tasksUsed,
|
|
72
|
+
reportsUsage: s.reportsUsage,
|
|
73
|
+
...(b.tokensUsed !== undefined ? { tokensUsed: b.tokensUsed } : {}),
|
|
74
|
+
});
|
|
75
|
+
if (!d.exceeded || !d.reason)
|
|
76
|
+
return undefined;
|
|
77
|
+
const note = d.unenforced.length > 0 ? ` (${d.unenforced.join("; ")})` : "";
|
|
78
|
+
s.say(`Budget exceeded: ${d.reason}${note}. Stopping the run: no new lanes start and running lanes are asked to stop.`);
|
|
79
|
+
beginStop(s, d.reason, d.unenforced);
|
|
80
|
+
return d.reason;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Begin a budget stop: nothing new launches, running lanes get a `stop` directive through 025's writer and the run
|
|
84
|
+
* is recorded as paused with the reason. Shared by the run's own budgets and by a fleet's (feature 031, FR-011).
|
|
85
|
+
*/
|
|
86
|
+
export function beginStop(s, reason, unenforced = []) {
|
|
87
|
+
if (s.stopReason)
|
|
88
|
+
return;
|
|
89
|
+
s.stopReason = reason;
|
|
90
|
+
event(s, "budget-exceeded", undefined, reason);
|
|
91
|
+
for (const rt of s.lanes) {
|
|
92
|
+
if (!isRunning(s, rt))
|
|
93
|
+
continue;
|
|
94
|
+
rt.stopAskedMs = s.now();
|
|
95
|
+
writeDirective(s.root, { feature: s.feature, lane: rt.file.lane, action: "stop", run: s.run, now: new Date(s.now()) });
|
|
96
|
+
}
|
|
97
|
+
const rec = readRun(s.root, s.run);
|
|
98
|
+
if (rec) {
|
|
99
|
+
updateRun(s.root, s.run, {
|
|
100
|
+
status: "paused",
|
|
101
|
+
escalations: [...rec.escalations, { kind: "budget", reason, unenforced, at: new Date(s.now()).toISOString() }],
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
/** Terminate every running lane (used when a budget stop has run out its grace, and on interrupt). */
|
|
106
|
+
export function stopAll(s, signal = "SIGTERM") {
|
|
107
|
+
for (const rt of s.lanes)
|
|
108
|
+
if (isRunning(s, rt))
|
|
109
|
+
stopProcess(s, rt, signal);
|
|
110
|
+
stopPhaseCheck(s, signal);
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=run-budget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-budget.js","source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AC,EAAE,CAAC,CAAC;IACzH,CAAC;IACD,MAAM,GAAG,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;IACnC,IAAI,GAAG,EAAE,CAAC;QACR,SAAS,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,EAAE;YACvB,MAAM,EAAE,QAAQ;YAChB,WAAW,EAAE,CAAC,GAAG,GAAG,CAAC,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,EAAE,IAAI,IAAI,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC;SAC/G,CAAC,CAAC;IACL,CAAC;AACH,CAAC;AAED,sGAAsG;AACtG,MAAM,UAAU,OAAO,CAAC,CAAU,EAAE,MAAM,GAA0B,SAAS;IAC3E,KAAK,MAAM,EAAE,IAAI,CAAC,CAAC,KAAK;QAAE,IAAI,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC;YAAE,WAAW,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;IAC3E,cAAc,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;AAC5B,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type Session } from "./run-session.js";
|
|
2
|
+
/**
|
|
3
|
+
* Directives (feature 028, FR-016). A person pauses, resumes or stops a lane from any host (`ambykit
|
|
4
|
+
* directive`, the dashboard, `/amby.run`); the only writer is spec 025's `writeDirective`, and this module only
|
|
5
|
+
* *reads* them (through `laneStatus` and `readDirective`). A worker finishes its current task and obeys at its
|
|
6
|
+
* next report; the run records when it did. A paused lane's process ends (it does not start another task); a
|
|
7
|
+
* `continue` written after the pause puts the lane back in the queue. Nothing here sends a signal: a directive
|
|
8
|
+
* is advice a worker follows, and only the stop grace (in the supervisor) terminates a lane that ignores it.
|
|
9
|
+
*/
|
|
10
|
+
/** Apply each lane's directive to its supervision state. Call once per tick. */
|
|
11
|
+
export declare function applyDirectives(s: Session): void;
|
|
12
|
+
/**
|
|
13
|
+
* `--continue-run` (FR-016, SC-005): bring a run back from where it stopped. Lanes that were stopped (a budget,
|
|
14
|
+
* a stop directive), ended with tasks open, failed to start, or were running when the supervisor died go back
|
|
15
|
+
* in the queue; a lane whose process is still alive from the earlier session is adopted as it is. Lanes
|
|
16
|
+
* waiting for a person (paused, merge conflict, escalated review) stay as they are. A `continue` directive is
|
|
17
|
+
* written (through spec 025's writer) for any lane that still carries a pause or stop, so the first tick does
|
|
18
|
+
* not obey a stale one. The prompt of a restarted lane lists only unchecked tasks, so no completed task repeats.
|
|
19
|
+
*/
|
|
20
|
+
export declare function reviveForContinue(s: Session): string[];
|
|
21
|
+
/**
|
|
22
|
+
* FR-009: a lane moves to a different assistant only when a person approved it. A paused lane with a
|
|
23
|
+
* `reassign` approval newer than its pause goes back in the queue on the approved assistant (if that assistant
|
|
24
|
+
* has a verified runner), with its restarts reset. Without an approval nothing here ever changes an assistant.
|
|
25
|
+
*/
|
|
26
|
+
export declare function applyReassignments(s: Session): void;
|
|
27
|
+
/**
|
|
28
|
+
* The whole run is held: every one of its lanes, merged ones included, has a pause or stop directive (a fleet pause
|
|
29
|
+
* writes one to each). Nothing new starts while it holds: no worker, no review, no next stage (the 2.0 dogfood: a
|
|
30
|
+
* paused fleet still started a QA review). A pause of a single lane holds only that lane (see `jobHeld`).
|
|
31
|
+
*/
|
|
32
|
+
export declare function runHeld(s: Session): boolean;
|
|
33
|
+
/** May no new job (worker or review) start for this lane? Its own pause or stop directive, or the whole run held. */
|
|
34
|
+
export declare function jobHeld(s: Session, rt: {
|
|
35
|
+
file: {
|
|
36
|
+
lane: string;
|
|
37
|
+
};
|
|
38
|
+
}): boolean;
|
|
39
|
+
/** Lanes a person has paused or stopped that have not started: they must not launch. */
|
|
40
|
+
export declare function heldByDirective(s: Session): Set<string>;
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { laneStatus, readDirective, readRun, updateRun, writeDirective } from "../core/fleet/index.js";
|
|
2
|
+
import { reassignGate } from "../core/run-supervise.js";
|
|
3
|
+
import { runnable } from "../core/runners.js";
|
|
4
|
+
import { isFailed } from "../core/query.js";
|
|
5
|
+
import { event, isRunning, save } from "./run-session.js";
|
|
6
|
+
/**
|
|
7
|
+
* Directives (feature 028, FR-016). A person pauses, resumes or stops a lane from any host (`ambykit
|
|
8
|
+
* directive`, the dashboard, `/amby.run`); the only writer is spec 025's `writeDirective`, and this module only
|
|
9
|
+
* *reads* them (through `laneStatus` and `readDirective`). A worker finishes its current task and obeys at its
|
|
10
|
+
* next report; the run records when it did. A paused lane's process ends (it does not start another task); a
|
|
11
|
+
* `continue` written after the pause puts the lane back in the queue. Nothing here sends a signal: a directive
|
|
12
|
+
* is advice a worker follows, and only the stop grace (in the supervisor) terminates a lane that ignores it.
|
|
13
|
+
*/
|
|
14
|
+
/** Apply each lane's directive to its supervision state. Call once per tick. */
|
|
15
|
+
export function applyDirectives(s) {
|
|
16
|
+
for (const rt of s.lanes) {
|
|
17
|
+
const directive = readDirective(s.root, s.run, rt.file.lane);
|
|
18
|
+
if (!directive)
|
|
19
|
+
continue;
|
|
20
|
+
const st = laneStatus(s.root, { feature: s.feature, lane: rt.file.lane, run: s.run, now: s.now() });
|
|
21
|
+
const status = isFailed(st) ? "none" : st.directive.status;
|
|
22
|
+
const running = isRunning(s, rt);
|
|
23
|
+
if (directive.action === "pause" || directive.action === "stop") {
|
|
24
|
+
if (rt.stopAskedMs === undefined && directive.action === "stop")
|
|
25
|
+
rt.stopAskedMs = Date.parse(directive.at);
|
|
26
|
+
// Recorded once per directive: the worker obeyed (it reported paused, or its process ended).
|
|
27
|
+
const obeyed = status === "paused" || status === "obeyed" || (!running && rt.file.status !== "queued");
|
|
28
|
+
if (obeyed && rt.obeyedAt !== directive.at) {
|
|
29
|
+
rt.obeyedAt = directive.at;
|
|
30
|
+
event(s, "obeyed", rt, directive.action);
|
|
31
|
+
s.say(`${rt.file.lane}: obeyed ${directive.action}`);
|
|
32
|
+
}
|
|
33
|
+
if (!running && (rt.file.status === "running" || rt.file.status === "queued")) {
|
|
34
|
+
// the process is gone (or never started): a paused or stopped lane is not "unfinished"
|
|
35
|
+
rt.file.status = directive.action === "stop" ? "stopped" : "paused";
|
|
36
|
+
rt.file.pausedAt = directive.at;
|
|
37
|
+
save(s, rt);
|
|
38
|
+
}
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
// continue: a lane paused earlier than this directive goes back in the queue (no restart is counted). A
|
|
42
|
+
// lane whose review never converged (`escalated`) is a person's decision too: `resume` gives it a fresh
|
|
43
|
+
// set of review rounds. A lane that failed (a refused tool, a failed turn) goes back too, but only for a
|
|
44
|
+
// directive written after it exited, so an older `continue` never re-runs a fresh failure.
|
|
45
|
+
const waiting = rt.file.status === "paused" || rt.file.status === "escalated";
|
|
46
|
+
const failedBefore = rt.file.status === "failed" && rt.file.exitedAt !== undefined && Date.parse(directive.at) > Date.parse(rt.file.exitedAt);
|
|
47
|
+
if (failedBefore || (waiting && (!rt.file.pausedAt || Date.parse(directive.at) > Date.parse(rt.file.pausedAt)))) {
|
|
48
|
+
if (rt.file.status === "escalated") {
|
|
49
|
+
rt.file.failedRounds = 0;
|
|
50
|
+
rt.round = 1;
|
|
51
|
+
}
|
|
52
|
+
rt.file.status = "queued";
|
|
53
|
+
delete rt.file.reason;
|
|
54
|
+
delete rt.file.pausedAt;
|
|
55
|
+
save(s, rt);
|
|
56
|
+
event(s, "resumed", rt, "continue directive");
|
|
57
|
+
s.say(`${rt.file.lane}: resumed`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* `--continue-run` (FR-016, SC-005): bring a run back from where it stopped. Lanes that were stopped (a budget,
|
|
63
|
+
* a stop directive), ended with tasks open, failed to start, or were running when the supervisor died go back
|
|
64
|
+
* in the queue; a lane whose process is still alive from the earlier session is adopted as it is. Lanes
|
|
65
|
+
* waiting for a person (paused, merge conflict, escalated review) stay as they are. A `continue` directive is
|
|
66
|
+
* written (through spec 025's writer) for any lane that still carries a pause or stop, so the first tick does
|
|
67
|
+
* not obey a stale one. The prompt of a restarted lane lists only unchecked tasks, so no completed task repeats.
|
|
68
|
+
*/
|
|
69
|
+
export function reviveForContinue(s) {
|
|
70
|
+
const revived = [];
|
|
71
|
+
for (const rt of s.lanes) {
|
|
72
|
+
const st = rt.file.status;
|
|
73
|
+
const alive = rt.file.pid !== undefined && s.port.isAlive(rt.file.pid);
|
|
74
|
+
const requeue = st === "stopped" || st === "unfinished" || st === "failed" || ((st === "running" || st === "reviewing") && !alive);
|
|
75
|
+
if (!requeue)
|
|
76
|
+
continue;
|
|
77
|
+
rt.file.status = "queued";
|
|
78
|
+
delete rt.file.reason;
|
|
79
|
+
delete rt.file.pid;
|
|
80
|
+
delete rt.file.pausedAt;
|
|
81
|
+
delete rt.stopAskedMs;
|
|
82
|
+
save(s, rt);
|
|
83
|
+
const d = readDirective(s.root, s.run, rt.file.lane);
|
|
84
|
+
if (d && d.action !== "continue")
|
|
85
|
+
writeDirective(s.root, { feature: s.feature, lane: rt.file.lane, action: "continue", run: s.run, now: new Date(s.now()) });
|
|
86
|
+
event(s, "revived", rt, `was ${st}`);
|
|
87
|
+
revived.push(rt.file.lane);
|
|
88
|
+
}
|
|
89
|
+
return revived;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* FR-009: a lane moves to a different assistant only when a person approved it. A paused lane with a
|
|
93
|
+
* `reassign` approval newer than its pause goes back in the queue on the approved assistant (if that assistant
|
|
94
|
+
* has a verified runner), with its restarts reset. Without an approval nothing here ever changes an assistant.
|
|
95
|
+
*/
|
|
96
|
+
export function applyReassignments(s) {
|
|
97
|
+
const rec = readRun(s.root, s.run);
|
|
98
|
+
if (!rec)
|
|
99
|
+
return;
|
|
100
|
+
for (const rt of s.lanes) {
|
|
101
|
+
if (rt.file.status !== "paused")
|
|
102
|
+
continue;
|
|
103
|
+
const approval = [...rec.approvals]
|
|
104
|
+
.reverse()
|
|
105
|
+
.map((a) => a)
|
|
106
|
+
.find((a) => a?.kind === "reassign" && a.lane === rt.file.lane && a.to && a.at && (!rt.file.pausedAt || Date.parse(a.at) > Date.parse(rt.file.pausedAt)));
|
|
107
|
+
if (!approval?.to)
|
|
108
|
+
continue;
|
|
109
|
+
const gate = reassignGate(rec.approvals, rt.file.lane, approval.to);
|
|
110
|
+
if (!gate.allowed)
|
|
111
|
+
continue;
|
|
112
|
+
const can = runnable(approval.to, s.registry);
|
|
113
|
+
if (!can.ok) {
|
|
114
|
+
s.say(`${rt.file.lane}: cannot move to ${approval.to}: ${can.reason}`);
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
const from = rt.assistant;
|
|
118
|
+
rt.assistant = approval.to;
|
|
119
|
+
rt.file.assistant = approval.to;
|
|
120
|
+
rt.file.restarts = 0;
|
|
121
|
+
rt.file.status = "queued";
|
|
122
|
+
delete rt.file.reason;
|
|
123
|
+
delete rt.file.pausedAt;
|
|
124
|
+
save(s, rt);
|
|
125
|
+
const lanes = rec.lanes.map((l) => (l.lane === rt.ref.name ? { ...l, assistant: approval.to, restarts: 0 } : l));
|
|
126
|
+
updateRun(s.root, s.run, { lanes, status: "active", needsDecision: false });
|
|
127
|
+
event(s, "reassigned", rt, `${from} to ${approval.to}, approved by a person`);
|
|
128
|
+
s.say(`${rt.file.lane}: moved from ${from} to ${approval.to} (approved)`);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* The whole run is held: every one of its lanes, merged ones included, has a pause or stop directive (a fleet pause
|
|
133
|
+
* writes one to each). Nothing new starts while it holds: no worker, no review, no next stage (the 2.0 dogfood: a
|
|
134
|
+
* paused fleet still started a QA review). A pause of a single lane holds only that lane (see `jobHeld`).
|
|
135
|
+
*/
|
|
136
|
+
export function runHeld(s) {
|
|
137
|
+
if (s.lanes.length === 0)
|
|
138
|
+
return false;
|
|
139
|
+
return s.lanes.every((rt) => {
|
|
140
|
+
const d = readDirective(s.root, s.run, rt.file.lane);
|
|
141
|
+
return d !== null && (d.action === "pause" || d.action === "stop");
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
/** May no new job (worker or review) start for this lane? Its own pause or stop directive, or the whole run held. */
|
|
145
|
+
export function jobHeld(s, rt) {
|
|
146
|
+
const d = readDirective(s.root, s.run, rt.file.lane);
|
|
147
|
+
if (d && (d.action === "pause" || d.action === "stop"))
|
|
148
|
+
return true;
|
|
149
|
+
return runHeld(s);
|
|
150
|
+
}
|
|
151
|
+
/** Lanes a person has paused or stopped that have not started: they must not launch. */
|
|
152
|
+
export function heldByDirective(s) {
|
|
153
|
+
const held = new Set();
|
|
154
|
+
for (const rt of s.lanes) {
|
|
155
|
+
const d = readDirective(s.root, s.run, rt.file.lane);
|
|
156
|
+
if (d && (d.action === "pause" || d.action === "stop"))
|
|
157
|
+
held.add(rt.file.lane);
|
|
158
|
+
}
|
|
159
|
+
return held;
|
|
160
|
+
}
|
|
161
|
+
//# sourceMappingURL=run-control.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-control.js","sourceRoot":"","sources":["../../src/cli/run-control.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACvG,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAgB,MAAM,kBAAkB,CAAC;AAExE;;;;;;;GAOG;AAEH,gFAAgF;AAChF,MAAM,UAAU,eAAe,CAAC,CAAU;IACxC,KAAK,MAAM,EAAE,IAAI,CAAC,C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IAAI,CAAC,CAAC;QACrD,OAAO,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,MAAM,KAAK,OAAO,IAAI,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC;IACrE,CAAC,CAAC,CAAC;AACL,CAAC;AAED,qHAAqH;AACrH,MAAM,UAAU,OAAO,CAAC,CAAU,EAAE,EAA8B;IAChE,MAAM,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACrD,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,KAAK,OAAO,IAAI,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC;QAAE,OAAO,IAAI,CAAC;IACpE,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC;AAED,wFAAwF;AACxF,MAAM,UAAU,eAAe,CAAC,CAAU;IACxC,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,KAAK,MAAM,EAAE,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC;QACzB,MAAM,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrD,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,KAAK,OAAO,IAAI,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC;YAAE,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjF,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { type RunLane, type RunRecord, type RunResult } from "../core/fleet/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* 028's own supervision files, kept inside spec 025's run directory (`.amby/fleet/<run>/`) and written through
|
|
4
|
+
* 025's atomic writer: `lanes/<lane>.json`, `events.jsonl`, `prompts/<lane>.md`, `budget.json` and `run.lock`.
|
|
5
|
+
* Run creation, `run.json` and everything else about run state is 025's (`createRun`, `updateRun`, ...); this
|
|
6
|
+
* file keeps no run-id or state logic of its own (FR-017, FR-020: nothing leaves the project).
|
|
7
|
+
*/
|
|
8
|
+
export type LaneRunStatus = "queued" | "running" | "finished" | "reviewing" | "merged" | "paused" | "failed" | "unfinished" | "stopped" | "conflict" | "ready" | "escalated";
|
|
9
|
+
export interface LaneFile {
|
|
10
|
+
/** Short lane name `lane-p-k`. */
|
|
11
|
+
lane: string;
|
|
12
|
+
/** Full lane name `NNN-slug.lane-p-k`. */
|
|
13
|
+
full: string;
|
|
14
|
+
assistant: string;
|
|
15
|
+
status: LaneRunStatus;
|
|
16
|
+
restarts: number;
|
|
17
|
+
pid?: number;
|
|
18
|
+
startedAt?: string;
|
|
19
|
+
exitedAt?: string;
|
|
20
|
+
exit?: {
|
|
21
|
+
code: number | null;
|
|
22
|
+
signal: string | null;
|
|
23
|
+
};
|
|
24
|
+
reason?: string;
|
|
25
|
+
/** When the lane was paused, so a later `continue` directive can be told from an earlier one. */
|
|
26
|
+
pausedAt?: string;
|
|
27
|
+
/** Review rounds that failed so far (the loop's counter). */
|
|
28
|
+
failedRounds?: number;
|
|
29
|
+
}
|
|
30
|
+
export declare const lanesDir: (root: string, run: string) => string;
|
|
31
|
+
export declare function readLaneFile(root: string, run: string, lane: string): LaneFile | null;
|
|
32
|
+
export declare function writeLaneFile(root: string, run: string, file: LaneFile): void;
|
|
33
|
+
export declare function listLaneFiles(root: string, run: string): LaneFile[];
|
|
34
|
+
export interface RunEvent {
|
|
35
|
+
at: string;
|
|
36
|
+
kind: string;
|
|
37
|
+
lane?: string;
|
|
38
|
+
detail?: string;
|
|
39
|
+
}
|
|
40
|
+
/** Append-only audit trail (`events.jsonl`): every start, restart, merge, gate and obeyed directive. */
|
|
41
|
+
export declare function appendEvent(root: string, run: string, event: Omit<RunEvent, "at"> & {
|
|
42
|
+
at?: string;
|
|
43
|
+
}): void;
|
|
44
|
+
export declare function readEvents(root: string, run: string): RunEvent[];
|
|
45
|
+
/** The prompt a lane was started with, kept as a file so a person can read what the assistant was told. */
|
|
46
|
+
export declare function writePromptFile(root: string, run: string, name: string, text: string): string;
|
|
47
|
+
export interface BudgetFile {
|
|
48
|
+
/** Wall-clock time the run has been supervised, across continued sessions. */
|
|
49
|
+
elapsedMs: number;
|
|
50
|
+
/** Task events used: check-offs seen, plus restarts and fix rounds. */
|
|
51
|
+
tasksUsed: number;
|
|
52
|
+
/** Tokens used, only for runners that report usage (input plus output tokens from each process's result). */
|
|
53
|
+
tokensUsed?: number;
|
|
54
|
+
/** Check-offs already counted, so a continued run does not count them twice. */
|
|
55
|
+
counted: string[];
|
|
56
|
+
}
|
|
57
|
+
export declare function readBudget(root: string, run: string): BudgetFile;
|
|
58
|
+
export declare function writeBudget(root: string, run: string, b: BudgetFile): void;
|
|
59
|
+
export interface RunLock {
|
|
60
|
+
pid: number;
|
|
61
|
+
at: string;
|
|
62
|
+
}
|
|
63
|
+
export declare const lockFile: (root: string, run: string) => string;
|
|
64
|
+
export declare function readRunLock(root: string, run: string): RunLock | null;
|
|
65
|
+
export type LockResult = {
|
|
66
|
+
ok: true;
|
|
67
|
+
} | {
|
|
68
|
+
ok: false;
|
|
69
|
+
reason: string;
|
|
70
|
+
};
|
|
71
|
+
/** One supervisor per run: refuse while the pid in `run.lock` is alive; a dead pid's lock is taken over. */
|
|
72
|
+
export declare function acquireRunLock(root: string, run: string, pid: number, isAlive: (pid: number) => boolean, now?: Date): LockResult;
|
|
73
|
+
export declare function releaseRunLock(root: string, run: string, pid: number): void;
|
|
74
|
+
/**
|
|
75
|
+
* A feature may have one live run at a time (FR-017, US-2 AC): a second `ambykit run` on the same feature
|
|
76
|
+
* refuses while an unfinished run exists. A run whose supervisor died is not restarted by a new run; the
|
|
77
|
+
* message points at `--continue-run`.
|
|
78
|
+
*/
|
|
79
|
+
export declare function guardNewRun(root: string, feature: string, isAlive: (pid: number) => boolean): LockResult;
|
|
80
|
+
/** Create `<feature>.<n>` on explicit request through 025's store, with the lanes of the prepared sets. */
|
|
81
|
+
export declare function bootstrapRun(root: string, feature: string, lanes: RunLane[], isAlive: (pid: number) => boolean, phase?: number): RunResult | {
|
|
82
|
+
ok: false;
|
|
83
|
+
warning: string;
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Open an existing run to continue it (`--continue-run`). A run whose `run.json` is missing or corrupt is
|
|
87
|
+
* rebuilt from `tasks.md` through 025's `rebuildFromTasks`; checked tasks stay checked (FR-017).
|
|
88
|
+
*/
|
|
89
|
+
export declare function openRun(root: string, run: string): {
|
|
90
|
+
ok: true;
|
|
91
|
+
record: RunRecord;
|
|
92
|
+
rebuilt: boolean;
|
|
93
|
+
} | {
|
|
94
|
+
ok: false;
|
|
95
|
+
reason: string;
|
|
96
|
+
};
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, appendFileSync } from "node:fs";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { UNFINISHED, createRun, damagedRuns, listRuns, readRun, rebuildFromTasks, restoreRun, runDir, writeFileAtomic, readFlowInput, } from "../core/fleet/index.js";
|
|
4
|
+
import { primaryRoot } from "../core/checkouts.js";
|
|
5
|
+
import { loadConfig, fleetSettings } from "../core/config.js";
|
|
6
|
+
const read = (file) => {
|
|
7
|
+
try {
|
|
8
|
+
return JSON.parse(readFileSync(file, "utf8"));
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
const write = (file, data) => writeFileAtomic(file, JSON.stringify(data, null, 2) + "\n");
|
|
15
|
+
export const lanesDir = (root, run) => join(runDir(root, run), "lanes");
|
|
16
|
+
export function readLaneFile(root, run, lane) {
|
|
17
|
+
return read(join(lanesDir(root, run), `${lane}.json`));
|
|
18
|
+
}
|
|
19
|
+
export function writeLaneFile(root, run, file) {
|
|
20
|
+
write(join(lanesDir(root, run), `${file.lane}.json`), file);
|
|
21
|
+
}
|
|
22
|
+
export function listLaneFiles(root, run) {
|
|
23
|
+
const dir = lanesDir(root, run);
|
|
24
|
+
if (!existsSync(dir))
|
|
25
|
+
return [];
|
|
26
|
+
return readdirSync(dir)
|
|
27
|
+
.filter((n) => n.endsWith(".json"))
|
|
28
|
+
.map((n) => read(join(dir, n)))
|
|
29
|
+
.filter((f) => f !== null)
|
|
30
|
+
.sort((a, b) => a.lane.localeCompare(b.lane));
|
|
31
|
+
}
|
|
32
|
+
/** Append-only audit trail (`events.jsonl`): every start, restart, merge, gate and obeyed directive. */
|
|
33
|
+
export function appendEvent(root, run, event) {
|
|
34
|
+
const file = join(runDir(root, run), "events.jsonl");
|
|
35
|
+
mkdirSync(dirname(file), { recursive: true });
|
|
36
|
+
appendFileSync(file, JSON.stringify({ at: event.at ?? new Date().toISOString(), kind: event.kind, ...(event.lane ? { lane: event.lane } : {}), ...(event.detail ? { detail: event.detail } : {}) }) + "\n");
|
|
37
|
+
}
|
|
38
|
+
export function readEvents(root, run) {
|
|
39
|
+
try {
|
|
40
|
+
return readFileSync(join(runDir(root, run), "events.jsonl"), "utf8")
|
|
41
|
+
.split(/\r?\n/)
|
|
42
|
+
.filter(Boolean)
|
|
43
|
+
.map((l) => JSON.parse(l));
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
return [];
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/** The prompt a lane was started with, kept as a file so a person can read what the assistant was told. */
|
|
50
|
+
export function writePromptFile(root, run, name, text) {
|
|
51
|
+
const file = join(runDir(root, run), "prompts", `${name}.md`);
|
|
52
|
+
writeFileAtomic(file, text.endsWith("\n") ? text : `${text}\n`);
|
|
53
|
+
return file;
|
|
54
|
+
}
|
|
55
|
+
export function readBudget(root, run) {
|
|
56
|
+
return read(join(runDir(root, run), "budget.json")) ?? { elapsedMs: 0, tasksUsed: 0, counted: [] };
|
|
57
|
+
}
|
|
58
|
+
export function writeBudget(root, run, b) {
|
|
59
|
+
write(join(runDir(root, run), "budget.json"), b);
|
|
60
|
+
}
|
|
61
|
+
export const lockFile = (root, run) => join(runDir(root, run), "run.lock");
|
|
62
|
+
export function readRunLock(root, run) {
|
|
63
|
+
return read(lockFile(root, run));
|
|
64
|
+
}
|
|
65
|
+
/** One supervisor per run: refuse while the pid in `run.lock` is alive; a dead pid's lock is taken over. */
|
|
66
|
+
export function acquireRunLock(root, run, pid, isAlive, now = new Date()) {
|
|
67
|
+
const held = readRunLock(root, run);
|
|
68
|
+
if (held && held.pid !== pid && isAlive(held.pid)) {
|
|
69
|
+
return { ok: false, reason: `run ${run} is already supervised by process ${held.pid}` };
|
|
70
|
+
}
|
|
71
|
+
write(lockFile(root, run), { pid, at: now.toISOString() });
|
|
72
|
+
return { ok: true };
|
|
73
|
+
}
|
|
74
|
+
export function releaseRunLock(root, run, pid) {
|
|
75
|
+
const held = readRunLock(root, run);
|
|
76
|
+
if (held && held.pid === pid)
|
|
77
|
+
rmSync(lockFile(root, run), { force: true });
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* A feature may have one live run at a time (FR-017, US-2 AC): a second `ambykit run` on the same feature
|
|
81
|
+
* refuses while an unfinished run exists. A run whose supervisor died is not restarted by a new run; the
|
|
82
|
+
* message points at `--continue-run`.
|
|
83
|
+
*/
|
|
84
|
+
export function guardNewRun(root, feature, isAlive) {
|
|
85
|
+
for (const r of listRuns(root, feature)) {
|
|
86
|
+
if (!UNFINISHED.includes(r.status))
|
|
87
|
+
continue;
|
|
88
|
+
const lock = readRunLock(root, r.run);
|
|
89
|
+
if (lock && isAlive(lock.pid))
|
|
90
|
+
return { ok: false, reason: `${feature} already has run ${r.run} in progress (process ${lock.pid}); wait for it or stop it first` };
|
|
91
|
+
return { ok: false, reason: `${feature} has an unfinished run ${r.run}; continue it with --continue-run=${r.run}` };
|
|
92
|
+
}
|
|
93
|
+
return { ok: true };
|
|
94
|
+
}
|
|
95
|
+
// --- bootstrap (T010) -----------------------------------------------------------------
|
|
96
|
+
/** Create `<feature>.<n>` on explicit request through 025's store, with the lanes of the prepared sets. */
|
|
97
|
+
export function bootstrapRun(root, feature, lanes, isAlive, phase = 0) {
|
|
98
|
+
const guard = guardNewRun(root, feature, isAlive);
|
|
99
|
+
if (!guard.ok)
|
|
100
|
+
return { ok: false, warning: guard.reason };
|
|
101
|
+
return createRun(root, feature, { lanes, phase });
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Open an existing run to continue it (`--continue-run`). A run whose `run.json` is missing or corrupt is
|
|
105
|
+
* rebuilt from `tasks.md` through 025's `rebuildFromTasks`; checked tasks stay checked (FR-017).
|
|
106
|
+
*/
|
|
107
|
+
export function openRun(root, run) {
|
|
108
|
+
const primary = primaryRoot(root);
|
|
109
|
+
const have = readRun(root, run);
|
|
110
|
+
if (have)
|
|
111
|
+
return { ok: true, record: have, rebuilt: false };
|
|
112
|
+
const feature = run.slice(0, run.lastIndexOf("."));
|
|
113
|
+
if (!damagedRuns(root, feature).includes(run))
|
|
114
|
+
return { ok: false, reason: `run '${run}' not found` };
|
|
115
|
+
const settings = fleetSettings(loadConfig(primary));
|
|
116
|
+
const record = rebuildFromTasks(readFlowInput(root, feature), { run, feature, limit: settings.roundLimit });
|
|
117
|
+
const restored = restoreRun(root, record);
|
|
118
|
+
return restored.ok ? { ok: true, record: restored.run, rebuilt: true } : { ok: false, reason: restored.warning };
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=run-files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-files.js","sourceRoot":"","sources":["../../src/cli/run-files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACnG,OAAO,EAAE,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