@ambystech/ambykit 1.6.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 +154 -1
- package/README.md +12 -8
- 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 +1 -1
- package/dist/cli/dashboard.js +55 -14
- 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 -111
- 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 -1
- package/dist/cli/lane.js +116 -5
- 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 +7 -0
- package/dist/cli/run-budget.js +42 -5
- package/dist/cli/run-budget.js.map +1 -1
- package/dist/cli/run-control.d.ts +12 -0
- package/dist/cli/run-control.js +24 -2
- package/dist/cli/run-control.js.map +1 -1
- package/dist/cli/run-files.d.ts +1 -1
- 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.js +2 -2
- package/dist/cli/run-gates.js.map +1 -1
- package/dist/cli/run-launch.js +22 -5
- package/dist/cli/run-launch.js.map +1 -1
- package/dist/cli/run-loop.d.ts +2 -0
- package/dist/cli/run-loop.js +51 -4
- package/dist/cli/run-loop.js.map +1 -1
- package/dist/cli/run-merger.d.ts +6 -0
- package/dist/cli/run-merger.js +40 -2
- package/dist/cli/run-merger.js.map +1 -1
- 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 +1 -1
- package/dist/cli/run-plan.js +24 -11
- package/dist/cli/run-plan.js.map +1 -1
- package/dist/cli/run-process.d.ts +6 -0
- package/dist/cli/run-process.js +17 -5
- package/dist/cli/run-process.js.map +1 -1
- package/dist/cli/run-protocol-prompts.d.ts +11 -1
- package/dist/cli/run-protocol-prompts.js +32 -5
- package/dist/cli/run-protocol-prompts.js.map +1 -1
- package/dist/cli/run-protocol.d.ts +8 -1
- package/dist/cli/run-protocol.js +35 -6
- package/dist/cli/run-protocol.js.map +1 -1
- package/dist/cli/run-script.js +3 -2
- package/dist/cli/run-script.js.map +1 -1
- package/dist/cli/run-session.d.ts +33 -0
- package/dist/cli/run-session.js.map +1 -1
- 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.js +26 -3
- package/dist/cli/run-supervisor.js.map +1 -1
- package/dist/cli/run.d.ts +11 -3
- package/dist/cli/run.js +86 -12
- package/dist/cli/run.js.map +1 -1
- 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-view.d.ts +1 -0
- package/dist/cli/ui/dashboard/fleet-view.js +1 -1
- package/dist/cli/ui/dashboard/fleet-view.js.map +1 -1
- package/dist/cli/ui/dashboard/help-overlay.d.ts +3 -1
- package/dist/cli/ui/dashboard/help-overlay.js +27 -5
- 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/interactive/fullscreen.js +13 -3
- 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/overview.d.ts +37 -2
- package/dist/cli/ui/interactive/overview.js +321 -31
- 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 +3 -0
- package/dist/core/config.js +10 -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/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/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/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-launch-plan.d.ts +2 -0
- package/dist/core/run-launch-plan.js +6 -1
- package/dist/core/run-launch-plan.js.map +1 -1
- package/dist/core/run-prompt.d.ts +43 -1
- package/dist/core/run-prompt.js +40 -4
- package/dist/core/run-prompt.js.map +1 -1
- 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-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/runners.d.ts +58 -3
- package/dist/core/runners.js +99 -13
- package/dist/core/runners.js.map +1 -1
- 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 +14 -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 +205 -12
- 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 +27 -6
- 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,30 @@
|
|
|
1
|
+
import type { DepEdge, Ownership, PlanError, WaitsFor } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* The fleet's order (feature 031, FR-004, FR-005, FR-007, FR-008). Pure. A feature waits for what it depends on
|
|
4
|
+
* (feature-level `depends-on` and story edges, spec 023's graph) and, when two features share a file or either's
|
|
5
|
+
* ownership is unknown, for the earlier one of the pair: earlier = dependency order, then feature number. The
|
|
6
|
+
* wait is never added twice, and never creates a cycle (it always points at the earlier feature).
|
|
7
|
+
*/
|
|
8
|
+
export interface OrderInput {
|
|
9
|
+
/** Features in the fleet, any order. */
|
|
10
|
+
features: {
|
|
11
|
+
feature: string;
|
|
12
|
+
ownership: Ownership;
|
|
13
|
+
}[];
|
|
14
|
+
/** Dependency edges of the fleet's features (from the graph); edges to features outside the fleet are checked below. */
|
|
15
|
+
deps: DepEdge[];
|
|
16
|
+
/** Features that are already done (a dependency on one is satisfied without being in the fleet). */
|
|
17
|
+
done?: ReadonlySet<string>;
|
|
18
|
+
}
|
|
19
|
+
export interface OrderOutput {
|
|
20
|
+
/** Planned start order. */
|
|
21
|
+
order: string[];
|
|
22
|
+
waitsFor: Map<string, WaitsFor[]>;
|
|
23
|
+
}
|
|
24
|
+
export declare function orderFleet(input: OrderInput): {
|
|
25
|
+
ok: true;
|
|
26
|
+
value: OrderOutput;
|
|
27
|
+
} | {
|
|
28
|
+
ok: false;
|
|
29
|
+
errors: PlanError[];
|
|
30
|
+
};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { compareFeatureDirs } from "../features.js";
|
|
2
|
+
import { conflicts, sharedFiles } from "./ownership.js";
|
|
3
|
+
export function orderFleet(input) {
|
|
4
|
+
const members = new Set(input.features.map((f) => f.feature));
|
|
5
|
+
const done = input.done ?? new Set();
|
|
6
|
+
const errors = [];
|
|
7
|
+
const direct = new Map();
|
|
8
|
+
for (const f of members)
|
|
9
|
+
direct.set(f, []);
|
|
10
|
+
const seen = new Set();
|
|
11
|
+
for (const d of [...input.deps].sort((a, b) => compareFeatureDirs(a.feature, b.feature) || compareFeatureDirs(a.on, b.on))) {
|
|
12
|
+
if (!members.has(d.feature) || d.feature === d.on)
|
|
13
|
+
continue;
|
|
14
|
+
if (!members.has(d.on)) {
|
|
15
|
+
if (!done.has(d.on)) {
|
|
16
|
+
errors.push({ kind: "missing-dependency", feature: d.feature, on: d.on, message: `${d.feature} depends on ${d.on}, which is not in the fleet and not done. Add it to the fleet or finish it first.` });
|
|
17
|
+
}
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
const key = `${d.feature}>${d.on}`;
|
|
21
|
+
if (seen.has(key))
|
|
22
|
+
continue; // a declared and a derived edge between the same two features count once
|
|
23
|
+
seen.add(key);
|
|
24
|
+
direct.get(d.feature).push({ feature: d.on, why: d.why });
|
|
25
|
+
}
|
|
26
|
+
const cycle = findCycle(members, direct);
|
|
27
|
+
if (cycle)
|
|
28
|
+
errors.push({ kind: "cycle", cycle, message: `Dependency cycle between features: ${cycle.join(" -> ")}.` });
|
|
29
|
+
if (errors.length > 0)
|
|
30
|
+
return { ok: false, errors };
|
|
31
|
+
// Topological order, ties by feature number (dependency order first, then number).
|
|
32
|
+
const order = [];
|
|
33
|
+
const placed = new Set();
|
|
34
|
+
const remaining = [...members].sort(compareFeatureDirs);
|
|
35
|
+
while (remaining.length > 0) {
|
|
36
|
+
const i = remaining.findIndex((f) => direct.get(f).every((w) => placed.has(w.feature)));
|
|
37
|
+
const next = remaining.splice(i, 1)[0];
|
|
38
|
+
order.push(next);
|
|
39
|
+
placed.add(next);
|
|
40
|
+
}
|
|
41
|
+
// Serialize features that share files, or whose ownership is unknown: the later waits for the earlier.
|
|
42
|
+
const owner = new Map(input.features.map((f) => [f.feature, f.ownership]));
|
|
43
|
+
const waitsFor = new Map(order.map((f) => [f, [...direct.get(f)]]));
|
|
44
|
+
const reach = (from) => {
|
|
45
|
+
const out = new Set();
|
|
46
|
+
const stack = [from];
|
|
47
|
+
while (stack.length > 0) {
|
|
48
|
+
for (const w of waitsFor.get(stack.pop()) ?? [])
|
|
49
|
+
if (!out.has(w.feature))
|
|
50
|
+
(out.add(w.feature), stack.push(w.feature));
|
|
51
|
+
}
|
|
52
|
+
return out;
|
|
53
|
+
};
|
|
54
|
+
for (let j = 0; j < order.length; j++) {
|
|
55
|
+
for (let i = 0; i < j; i++) {
|
|
56
|
+
const early = order[i];
|
|
57
|
+
const late = order[j];
|
|
58
|
+
const a = owner.get(early);
|
|
59
|
+
const b = owner.get(late);
|
|
60
|
+
if (!conflicts(a, b) || reach(late).has(early))
|
|
61
|
+
continue;
|
|
62
|
+
const files = sharedFiles(a, b);
|
|
63
|
+
waitsFor.get(late).push({ feature: early, why: "shared-files", files });
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return { ok: true, value: { order, waitsFor } };
|
|
67
|
+
}
|
|
68
|
+
function findCycle(members, edges) {
|
|
69
|
+
const state = new Map();
|
|
70
|
+
const stack = [];
|
|
71
|
+
const visit = (f) => {
|
|
72
|
+
state.set(f, 1);
|
|
73
|
+
stack.push(f);
|
|
74
|
+
for (const w of edges.get(f) ?? []) {
|
|
75
|
+
if (state.get(w.feature) === 1)
|
|
76
|
+
return [...stack.slice(stack.indexOf(w.feature)), w.feature];
|
|
77
|
+
if (!state.has(w.feature)) {
|
|
78
|
+
const c = visit(w.feature);
|
|
79
|
+
if (c)
|
|
80
|
+
return c;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
stack.pop();
|
|
84
|
+
state.set(f, 2);
|
|
85
|
+
return null;
|
|
86
|
+
};
|
|
87
|
+
for (const f of [...members].sort(compareFeatureDirs)) {
|
|
88
|
+
if (!state.has(f)) {
|
|
89
|
+
const c = visit(f);
|
|
90
|
+
if (c)
|
|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
|
|
1
|
+
import type { FeatureModel, Ownership } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* File ownership of a feature (feature 031, FR-004..FR-006). The set is the union of the declared paths of its
|
|
4
|
+
* open tasks, from the model the 030 reader gives (so 1.x trailing groups and 2.x `files` blocks agree). An open
|
|
5
|
+
* task with no usable ownership (`missing`, or a glob that cannot be compared) is listed in `unknown`: the feature
|
|
6
|
+
* is then treated as owning everything it could touch (conservative; never assumed independent).
|
|
7
|
+
*/
|
|
8
|
+
export declare function ownershipOf(feature: Pick<FeatureModel, "tasks">): Ownership;
|
|
9
|
+
/** The paths of `a` that overlap a path of `b` (either side's path, so a directory covers its files). Sorted, unique. */
|
|
10
|
+
export declare function sharedFiles(a: Ownership, b: Ownership): string[];
|
|
11
|
+
/** Two features conflict when they share a file, or either one's ownership is unknown. */
|
|
12
|
+
export declare function conflicts(a: Ownership, b: Ownership): boolean;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { overlaps } from "../lanes.js";
|
|
2
|
+
/**
|
|
3
|
+
* File ownership of a feature (feature 031, FR-004..FR-006). The set is the union of the declared paths of its
|
|
4
|
+
* open tasks, from the model the 030 reader gives (so 1.x trailing groups and 2.x `files` blocks agree). An open
|
|
5
|
+
* task with no usable ownership (`missing`, or a glob that cannot be compared) is listed in `unknown`: the feature
|
|
6
|
+
* is then treated as owning everything it could touch (conservative; never assumed independent).
|
|
7
|
+
*/
|
|
8
|
+
export function ownershipOf(feature) {
|
|
9
|
+
const files = new Set();
|
|
10
|
+
const unknown = [];
|
|
11
|
+
for (const t of feature.tasks) {
|
|
12
|
+
if (t.done)
|
|
13
|
+
continue;
|
|
14
|
+
if (t.pathIssue || t.paths.length === 0) {
|
|
15
|
+
unknown.push(t.id);
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
for (const p of t.paths)
|
|
19
|
+
files.add(p);
|
|
20
|
+
}
|
|
21
|
+
return { files: [...files].sort(), unknown };
|
|
22
|
+
}
|
|
23
|
+
/** The paths of `a` that overlap a path of `b` (either side's path, so a directory covers its files). Sorted, unique. */
|
|
24
|
+
export function sharedFiles(a, b) {
|
|
25
|
+
const out = new Set();
|
|
26
|
+
for (const x of a.files)
|
|
27
|
+
for (const y of b.files)
|
|
28
|
+
if (overlaps(x, y))
|
|
29
|
+
out.add(x.length >= y.length ? x : y);
|
|
30
|
+
return [...out].sort();
|
|
31
|
+
}
|
|
32
|
+
/** Two features conflict when they share a file, or either one's ownership is unknown. */
|
|
33
|
+
export function conflicts(a, b) {
|
|
34
|
+
return a.unknown.length > 0 || b.unknown.length > 0 || sharedFiles(a, b).length > 0;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=ownership.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ownership.js","sourceRoot":"","sources":["../../../src/core/fleet-plan/ownership.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGvC;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,OAAoC;IAC9D,MAAM,KAAK,GAAG,IAAI,GAAG,EAAU,CAAC;IAChC,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,KAAK,MAAM,CAAC,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;QAC9B,IAAI,CAAC,CAAC,IAAI;YAAE,SAAS;QACrB,IAAI,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;YACnB,SAAS;QACX,CAAC;QACD,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK;YAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACxC,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,CAAC;AAC/C,CAAC;AAED,yHAAyH;AACzH,MAAM,UAAU,WAAW,CAAC,CAAY,EAAE,CAAY;IACpD,MAAM,GAAG,GAAG,IAAI,GAAG,EAAU,CAAC;IAC9B,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK;QAAE,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK;YAAE,IAAI,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC;gBAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5G,OAAO,CAAC,GAAG,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;AACzB,CAAC;AAED,0FAA0F;AAC1F,MAAM,UAAU,SAAS,CAAC,CAAY,EAAE,CAAY;IAClD,OAAO,CAAC,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;AACtF,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { DepEdge, FeatureModel, FleetBudgets, FleetCaps, FleetPlan, Planned } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* One fleet plan (feature 031, FR-001..FR-008, FR-016): select, ownership, order and caps. Pure: it gets the
|
|
4
|
+
* project's models and edges from `read.ts` and returns what the preview prints and `fleet.json` stores.
|
|
5
|
+
*/
|
|
6
|
+
export interface PlanInput {
|
|
7
|
+
/** Feature numbers or names as given; ignored with `allReady`. */
|
|
8
|
+
args: readonly string[];
|
|
9
|
+
allReady?: boolean;
|
|
10
|
+
models: readonly FeatureModel[];
|
|
11
|
+
deps: readonly DepEdge[];
|
|
12
|
+
done: ReadonlySet<string>;
|
|
13
|
+
caps: FleetCaps;
|
|
14
|
+
budgets: FleetBudgets;
|
|
15
|
+
/** Lanes the fleet prepares for a feature that has none (clarification C-2). */
|
|
16
|
+
lanesToPrepare?: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* What the plan was made from, not how far the work has got: task ids, their declared paths and ownership issues,
|
|
20
|
+
* and the feature's dependency edges. Ticking a task does not change it; editing a task list or a dependency does.
|
|
21
|
+
*/
|
|
22
|
+
export declare function fingerprintOf(m: FeatureModel, deps: readonly DepEdge[]): string;
|
|
23
|
+
export declare function buildFleetPlan(input: PlanInput): Planned<FleetPlan>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { orderFleet } from "./order.js";
|
|
3
|
+
import { ownershipOf } from "./ownership.js";
|
|
4
|
+
import { selectFeatures } from "./select.js";
|
|
5
|
+
/**
|
|
6
|
+
* What the plan was made from, not how far the work has got: task ids, their declared paths and ownership issues,
|
|
7
|
+
* and the feature's dependency edges. Ticking a task does not change it; editing a task list or a dependency does.
|
|
8
|
+
*/
|
|
9
|
+
export function fingerprintOf(m, deps) {
|
|
10
|
+
const body = JSON.stringify({
|
|
11
|
+
tasks: m.tasks.map((t) => [t.id, t.phase, t.parallel, t.paths, t.pathIssue ?? ""]),
|
|
12
|
+
deps: deps.filter((d) => d.feature === m.dir).map((d) => `${d.on}:${d.why}`).sort(),
|
|
13
|
+
});
|
|
14
|
+
return createHash("sha1").update(body).digest("hex").slice(0, 12);
|
|
15
|
+
}
|
|
16
|
+
export function buildFleetPlan(input) {
|
|
17
|
+
const picked = selectFeatures(input.args, input.models, { ...(input.allReady ? { allReady: true } : {}) });
|
|
18
|
+
if (picked.errors.length > 0)
|
|
19
|
+
return { ok: false, errors: picked.errors };
|
|
20
|
+
const ownership = new Map(picked.selected.map((m) => [m.dir, ownershipOf(m)]));
|
|
21
|
+
const ordered = orderFleet({
|
|
22
|
+
features: picked.selected.map((m) => ({ feature: m.dir, ownership: ownership.get(m.dir) })),
|
|
23
|
+
deps: [...input.deps],
|
|
24
|
+
done: input.done,
|
|
25
|
+
});
|
|
26
|
+
if (!ordered.ok)
|
|
27
|
+
return ordered;
|
|
28
|
+
const byDir = new Map(picked.selected.map((m) => [m.dir, m]));
|
|
29
|
+
const features = ordered.value.order.map((dir) => ({
|
|
30
|
+
feature: dir,
|
|
31
|
+
state: "waiting",
|
|
32
|
+
waitsFor: ordered.value.waitsFor.get(dir) ?? [],
|
|
33
|
+
ownership: ownership.get(dir),
|
|
34
|
+
fingerprint: fingerprintOf(byDir.get(dir), input.deps),
|
|
35
|
+
}));
|
|
36
|
+
const laneCounts = Object.fromEntries(picked.selected.map((m) => [m.dir, m.lanes]));
|
|
37
|
+
const prepare = picked.selected.filter((m) => m.lanes === 0).map((m) => ({ feature: m.dir, lanes: input.lanesToPrepare ?? 2 }));
|
|
38
|
+
return { ok: true, value: { features, caps: input.caps, budgets: input.budgets, skipped: picked.skipped, prepare, laneCounts } };
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=plan.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan.js","sourceRoot":"","sources":["../../../src/core/fleet-plan/plan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAqB7C;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,CAAe,EAAE,IAAwB;IACrE,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC;QAC1B,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAA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AE,KAAK,EAAE,KAAK,CAAC,cAAc,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IAChI,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,EAAE,CAAC;AACnI,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { FeatureSnapshot } from "../overview-types.js";
|
|
2
|
+
import type { DepEdge, FeatureModel } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* The one adapter between the fleet planner and the structured spec data (feature 031, FR-020, FR-022). It reads
|
|
5
|
+
* features through spec 030's per-file reader (`readFeatures` -> `readSpec`/`readTasks`, 1.x and 2.x alike) and the
|
|
6
|
+
* dependencies through spec 023's graph (feature-level `depends-on` and story edges). Nothing in `fleet-plan/`
|
|
7
|
+
* parses markdown or YAML itself (a test scans the sources for it), so a migration needs no change here.
|
|
8
|
+
*/
|
|
9
|
+
export interface FleetInput {
|
|
10
|
+
models: FeatureModel[];
|
|
11
|
+
deps: DepEdge[];
|
|
12
|
+
/** Features that are done: status `done`, or tasks all checked. */
|
|
13
|
+
done: Set<string>;
|
|
14
|
+
}
|
|
15
|
+
/** A snapshot as the planner sees it. Exported so tests can model features without files. */
|
|
16
|
+
export declare function toModel(root: string, f: FeatureSnapshot, status?: string): FeatureModel;
|
|
17
|
+
export declare function isDone(m: Pick<FeatureModel, "status" | "tasks">): boolean;
|
|
18
|
+
/** Every feature of the project as a model, the dependency edges among them, and which are done. */
|
|
19
|
+
export declare function readFleetInput(root: string): FleetInput;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { readFeatures } from "../features.js";
|
|
4
|
+
import { buildGraph } from "../graph.js";
|
|
5
|
+
import { laneRefs } from "../query.js";
|
|
6
|
+
import { readSpec } from "../spec-format/dispatch.js";
|
|
7
|
+
const specStatus = (root, dir) => {
|
|
8
|
+
const file = join(root, "specs", dir, "spec.md");
|
|
9
|
+
if (!existsSync(file))
|
|
10
|
+
return "";
|
|
11
|
+
return readSpec(dir, readFileSync(file, "utf8"), { file: `specs/${dir}/spec.md` }).meta.status ?? "";
|
|
12
|
+
};
|
|
13
|
+
/** A snapshot as the planner sees it. Exported so tests can model features without files. */
|
|
14
|
+
export function toModel(root, f, status = specStatus(root, f.dir)) {
|
|
15
|
+
return {
|
|
16
|
+
dir: f.dir,
|
|
17
|
+
ref: f.ref,
|
|
18
|
+
status,
|
|
19
|
+
tasks: f.tasks ?? [],
|
|
20
|
+
artifacts: { spec: f.artifacts.spec, plan: f.artifacts.plan, tasks: f.artifacts.tasks },
|
|
21
|
+
lanes: laneRefs(root, f.dir).length,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export function isDone(m) {
|
|
25
|
+
return m.status === "done" || (m.tasks.length > 0 && m.tasks.every((t) => t.done));
|
|
26
|
+
}
|
|
27
|
+
/** Every feature of the project as a model, the dependency edges among them, and which are done. */
|
|
28
|
+
export function readFleetInput(root) {
|
|
29
|
+
const { features } = readFeatures(root);
|
|
30
|
+
const graph = buildGraph(features);
|
|
31
|
+
const models = features.map((f) => toModel(root, f));
|
|
32
|
+
const deps = graph.featureEdges.map((e) => ({ feature: e.from, on: e.to, why: e.declared ? "depends-on" : "story-edge" }));
|
|
33
|
+
return { models, deps, done: new Set(models.filter(isDone).map((m) => m.dir)) };
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=read.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read.js","sourceRoot":"","sources":["../../../src/core/fleet-plan/read.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,O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D,OAAO,CAAC,CAAC,MAAM,KAAK,MAAM,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AACrF,CAAC;AAED,oGAAoG;AACpG,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,MAAM,EAAE,QAAQ,EAAE,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IACxC,MAAM,KAAK,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;IACnC,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IACrD,MAAM,IAAI,GAAc,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;IACtI,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;AAClF,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type QueuedLane } from "../run-schedule.js";
|
|
2
|
+
import type { FleetCaps, FleetFeature } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* What may start (feature 031, FR-007, FR-010, FR-012). Pure.
|
|
5
|
+
*
|
|
6
|
+
* A feature starts only when it is waiting, nothing holds it, and every feature it waits for is done (for a
|
|
7
|
+
* `shared-files` wait that means the earlier feature's lanes are merged into its branch, clarification C-1).
|
|
8
|
+
* Lanes start under the fleet-wide caps: `nextToStart` from spec 028 is given the lanes running in EVERY
|
|
9
|
+
* feature, so the total and per-type caps hold across the fleet, not per feature.
|
|
10
|
+
*/
|
|
11
|
+
export declare function startableFeatures(features: readonly FleetFeature[]): FleetFeature[];
|
|
12
|
+
/** Why a waiting feature is not startable now, for the status view ("waiting for 030-base (depends-on)"). */
|
|
13
|
+
export declare function blockedBy(feature: FleetFeature, features: readonly FleetFeature[]): string[];
|
|
14
|
+
/** Lanes to start now: `queue` is every startable queued lane in fleet order, `running` every running lane of every feature. */
|
|
15
|
+
export declare function fleetLaneStarts(queue: QueuedLane[], running: QueuedLane[], caps: FleetCaps, held?: ReadonlySet<string>): QueuedLane[];
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { nextToStart } from "../run-schedule.js";
|
|
2
|
+
/**
|
|
3
|
+
* What may start (feature 031, FR-007, FR-010, FR-012). Pure.
|
|
4
|
+
*
|
|
5
|
+
* A feature starts only when it is waiting, nothing holds it, and every feature it waits for is done (for a
|
|
6
|
+
* `shared-files` wait that means the earlier feature's lanes are merged into its branch, clarification C-1).
|
|
7
|
+
* Lanes start under the fleet-wide caps: `nextToStart` from spec 028 is given the lanes running in EVERY
|
|
8
|
+
* feature, so the total and per-type caps hold across the fleet, not per feature.
|
|
9
|
+
*/
|
|
10
|
+
export function startableFeatures(features) {
|
|
11
|
+
const state = new Map(features.map((f) => [f.feature, f.state]));
|
|
12
|
+
return features.filter((f) => f.state === "waiting" &&
|
|
13
|
+
f.heldBy === undefined &&
|
|
14
|
+
f.waitsFor.every((w) => state.get(w.feature) === "done" || state.get(w.feature) === "skipped" || !state.has(w.feature)));
|
|
15
|
+
}
|
|
16
|
+
/** Why a waiting feature is not startable now, for the status view ("waiting for 030-base (depends-on)"). */
|
|
17
|
+
export function blockedBy(feature, features) {
|
|
18
|
+
if (feature.heldBy)
|
|
19
|
+
return [`held by ${feature.heldBy}`];
|
|
20
|
+
const state = new Map(features.map((f) => [f.feature, f.state]));
|
|
21
|
+
return feature.waitsFor.filter((w) => state.get(w.feature) !== "done" && state.get(w.feature) !== "skipped" && state.has(w.feature)).map((w) => `${w.feature} (${w.why})`);
|
|
22
|
+
}
|
|
23
|
+
/** Lanes to start now: `queue` is every startable queued lane in fleet order, `running` every running lane of every feature. */
|
|
24
|
+
export function fleetLaneStarts(queue, running, caps, held = new Set()) {
|
|
25
|
+
return nextToStart(queue, running, caps, held);
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=schedule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schedule.js","sourceRoot":"","sources":["../../../src/core/fleet-plan/schedule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAmB,MAAM,oBAAoB,CAAC;AAGlE;;;;;;;GAOG;AAEH,MAAM,UAAU,iBAAiB,CAAC,QAAiC;IACjE,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACjE,OAAO,QAAQ,CAAC,MAAM,CACpB,CAAC,CAAC,EAAE,EAAE,CACJ,CAAC,CAAC,KAAK,KAAK,SAAS;QACrB,CAAC,CAAC,MAAM,KAAK,SAAS;QACtB,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAC1H,CAAC;AACJ,CAAC;AAED,6GAA6G;AAC7G,MAAM,UAAU,SAAS,CAAC,OAAqB,EAAE,QAAiC;IAChF,IAAI,OAAO,CAAC,MAAM;QAAE,OAAO,CAAC,WAAW,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACzD,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACjE,OAAO,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,SAAS,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC;AAC7K,CAAC;AAED,gIAAgI;AAChI,MAAM,UAAU,eAAe,CAAC,KAAmB,EAAE,OAAqB,EAAE,IAAe,EAAE,IAAI,GAAwB,IAAI,GAAG,EAAE;IAChI,OAAO,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { FeatureModel, PlanError, Skipped } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Which features a fleet runs (feature 031, FR-001..FR-003, FR-016). Pure. Named features are resolved by number,
|
|
4
|
+
* directory name or reference, de-duplicated (a feature listed twice is scheduled once), and each must be ready:
|
|
5
|
+
* the spec approved (`ready` or `in-progress`), a plan and a task list present, and work left to do. `--all-ready`
|
|
6
|
+
* selects every ready feature and reports the skipped ones with the reason (features already done are not listed:
|
|
7
|
+
* they are finished, not skipped).
|
|
8
|
+
*/
|
|
9
|
+
export interface SelectResult {
|
|
10
|
+
selected: FeatureModel[];
|
|
11
|
+
errors: PlanError[];
|
|
12
|
+
skipped: Skipped[];
|
|
13
|
+
}
|
|
14
|
+
/** Why a feature cannot run now, or null when it is ready. */
|
|
15
|
+
export declare function notReadyReason(m: FeatureModel): string | null;
|
|
16
|
+
/** A feature by directory name, number or reference; undefined when it matches none. */
|
|
17
|
+
export declare function resolveFeature(arg: string, models: readonly FeatureModel[]): FeatureModel | undefined;
|
|
18
|
+
export declare function selectFeatures(args: readonly string[], models: readonly FeatureModel[], opts?: {
|
|
19
|
+
allReady?: boolean;
|
|
20
|
+
}): SelectResult;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
const APPROVED = new Set(["ready", "in-progress"]);
|
|
2
|
+
/** Why a feature cannot run now, or null when it is ready. */
|
|
3
|
+
export function notReadyReason(m) {
|
|
4
|
+
if (!m.artifacts.spec)
|
|
5
|
+
return "no spec.md";
|
|
6
|
+
if (!APPROVED.has(m.status))
|
|
7
|
+
return `spec status is '${m.status || "unset"}' (needs 'ready' or 'in-progress')`;
|
|
8
|
+
if (!m.artifacts.plan)
|
|
9
|
+
return "no plan.md";
|
|
10
|
+
if (!m.artifacts.tasks)
|
|
11
|
+
return "no tasks.md";
|
|
12
|
+
if (m.tasks.length === 0)
|
|
13
|
+
return "tasks.md has no tasks";
|
|
14
|
+
if (m.tasks.every((t) => t.done))
|
|
15
|
+
return "every task is already checked off";
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
/** A feature by directory name, number or reference; undefined when it matches none. */
|
|
19
|
+
export function resolveFeature(arg, models) {
|
|
20
|
+
const byName = models.find((m) => m.dir === arg);
|
|
21
|
+
if (byName)
|
|
22
|
+
return byName;
|
|
23
|
+
if (/^\d+$/.test(arg))
|
|
24
|
+
return models.find((m) => Number(m.ref) === Number(arg));
|
|
25
|
+
return models.find((m) => m.ref === arg);
|
|
26
|
+
}
|
|
27
|
+
export function selectFeatures(args, models, opts = {}) {
|
|
28
|
+
const errors = [];
|
|
29
|
+
const skipped = [];
|
|
30
|
+
const selected = [];
|
|
31
|
+
if (opts.allReady) {
|
|
32
|
+
for (const m of models) {
|
|
33
|
+
const why = notReadyReason(m);
|
|
34
|
+
if (why === null)
|
|
35
|
+
selected.push(m);
|
|
36
|
+
else if (!(m.tasks.length > 0 && m.tasks.every((t) => t.done)) && m.status !== "done")
|
|
37
|
+
skipped.push({ feature: m.dir, reason: why });
|
|
38
|
+
}
|
|
39
|
+
if (selected.length === 0)
|
|
40
|
+
errors.push({ kind: "no-features", message: "No feature is ready to run, so nothing was started." });
|
|
41
|
+
return { selected, errors, skipped };
|
|
42
|
+
}
|
|
43
|
+
const seen = new Set();
|
|
44
|
+
for (const arg of args) {
|
|
45
|
+
const m = resolveFeature(arg, models);
|
|
46
|
+
if (!m) {
|
|
47
|
+
errors.push({ kind: "not-found", feature: arg, message: `Feature '${arg}' not found. Use a feature number or directory name from specs/.` });
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
if (seen.has(m.dir))
|
|
51
|
+
continue;
|
|
52
|
+
seen.add(m.dir);
|
|
53
|
+
const why = notReadyReason(m);
|
|
54
|
+
if (why !== null) {
|
|
55
|
+
errors.push({ kind: "not-ready", feature: m.dir, message: `${m.dir} is not ready to run: ${why}.` });
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
selected.push(m);
|
|
59
|
+
}
|
|
60
|
+
if (selected.length === 0 && errors.length === 0)
|
|
61
|
+
errors.push({ kind: "no-features", message: "No features given." });
|
|
62
|
+
return { selected, errors, skipped };
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=select.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select.js","sourceRoot":"","sources":["../../../src/core/fleet-plan/select.ts"],"names":[],"mappings":"AAgBA,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,CAAC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G,EAAE,OAAO,EAAE,YAAY,GAAG,kEAAkE,EAAE,CAAC,CAAC;YAC7I,SAAS;QACX,CAAC;QACD,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;YAAE,SAAS;QAC9B,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QAChB,MAAM,GAAG,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC;QAC9B,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;YACjB,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC,GAAG,yBAAyB,GAAG,GAAG,EAAE,CAAC,CAAC;YACrG,SAAS;QACX,CAAC;QACD,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACnB,CAAC;IACD,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,oBAAoB,EAAE,CAAC,CAAC;IACtH,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;AACvC,CAAC"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import type { TaskLine } from "../dashboard.js";
|
|
2
|
+
/**
|
|
3
|
+
* Fleet plan types (feature 031). Pure data: nothing here reads a file or starts a process. The shapes of
|
|
4
|
+
* `FleetRecord` and `FleetFeature` are `specs/031-multi-feature-fleets/data-model.md`.
|
|
5
|
+
*/
|
|
6
|
+
/** What the planner needs to know about one feature, as read through spec 030's per-file reader. */
|
|
7
|
+
export interface FeatureModel {
|
|
8
|
+
/** Directory name `NNN-slug`. */
|
|
9
|
+
dir: string;
|
|
10
|
+
/** Leading number (`031`), else the directory name. */
|
|
11
|
+
ref: string;
|
|
12
|
+
/** Spec frontmatter status (`draft | ready | in-progress | blocked | done`), `""` when absent. */
|
|
13
|
+
status: string;
|
|
14
|
+
/** Tasks with their declared `paths` and `pathIssue` (1.x trailing groups and 2.x `files` blocks give the same model). */
|
|
15
|
+
tasks: TaskLine[];
|
|
16
|
+
artifacts: {
|
|
17
|
+
spec: boolean;
|
|
18
|
+
plan: boolean;
|
|
19
|
+
tasks: boolean;
|
|
20
|
+
};
|
|
21
|
+
/** Prepared lane worktrees (`ambykit lane`): 0 means the fleet prepares them (clarification C-2). */
|
|
22
|
+
lanes: number;
|
|
23
|
+
}
|
|
24
|
+
/** `feature` waits for `on`, declared by a feature-level `depends-on` or derived from a story edge (`NNN:US-#`). */
|
|
25
|
+
export interface DepEdge {
|
|
26
|
+
feature: string;
|
|
27
|
+
on: string;
|
|
28
|
+
why: "depends-on" | "story-edge";
|
|
29
|
+
}
|
|
30
|
+
/** The files a feature may edit. `unknown` lists the open tasks with no usable ownership (FR-006). */
|
|
31
|
+
export interface Ownership {
|
|
32
|
+
files: string[];
|
|
33
|
+
unknown: string[];
|
|
34
|
+
}
|
|
35
|
+
export type WaitWhy = "depends-on" | "story-edge" | "shared-files";
|
|
36
|
+
export interface WaitsFor {
|
|
37
|
+
feature: string;
|
|
38
|
+
why: WaitWhy;
|
|
39
|
+
/** The shared files behind a `shared-files` wait (FR-005); empty when the cause is unknown ownership. */
|
|
40
|
+
files?: string[];
|
|
41
|
+
}
|
|
42
|
+
export type FleetFeatureState = "waiting" | "running" | "paused" | "done" | "skipped";
|
|
43
|
+
export interface FleetFeature {
|
|
44
|
+
feature: string;
|
|
45
|
+
/** `<feature>.<n>` once started; the directory is nested in `fleet-<n>/`. */
|
|
46
|
+
run?: string;
|
|
47
|
+
state: FleetFeatureState;
|
|
48
|
+
waitsFor: WaitsFor[];
|
|
49
|
+
/** The feature whose pause holds this one. */
|
|
50
|
+
heldBy?: string;
|
|
51
|
+
/** Why the feature is paused (a lane waiting for a person, a merge conflict before start), when it is. */
|
|
52
|
+
cause?: string;
|
|
53
|
+
ownership: Ownership;
|
|
54
|
+
/** Hash of what the plan was made from (spec and tasks through the 030 reader, plus the ownership set). */
|
|
55
|
+
fingerprint: string;
|
|
56
|
+
}
|
|
57
|
+
export type FleetStatus = "active" | "paused" | "waiting-person" | "done";
|
|
58
|
+
export interface FleetCaps {
|
|
59
|
+
total: number;
|
|
60
|
+
perType: number;
|
|
61
|
+
}
|
|
62
|
+
export interface FleetBudgets {
|
|
63
|
+
wallClockMinutes: number;
|
|
64
|
+
maxTasks: number;
|
|
65
|
+
maxTokens?: number;
|
|
66
|
+
}
|
|
67
|
+
/** `.amby/fleet/fleet-<n>/fleet.json`. */
|
|
68
|
+
export interface FleetRecord {
|
|
69
|
+
fleet: string;
|
|
70
|
+
status: FleetStatus;
|
|
71
|
+
createdAt: string;
|
|
72
|
+
/** In planned start order. */
|
|
73
|
+
features: FleetFeature[];
|
|
74
|
+
caps: FleetCaps;
|
|
75
|
+
budgets: FleetBudgets;
|
|
76
|
+
unattended: boolean;
|
|
77
|
+
}
|
|
78
|
+
export interface Skipped {
|
|
79
|
+
feature: string;
|
|
80
|
+
reason: string;
|
|
81
|
+
}
|
|
82
|
+
/** What `buildFleetPlan` returns and the preview prints: every feature, its order and why it waits. */
|
|
83
|
+
export interface FleetPlan {
|
|
84
|
+
features: FleetFeature[];
|
|
85
|
+
caps: FleetCaps;
|
|
86
|
+
budgets: FleetBudgets;
|
|
87
|
+
skipped: Skipped[];
|
|
88
|
+
/** Features whose lanes the fleet prepares before starting (clarification C-2), with the lane count. */
|
|
89
|
+
prepare: {
|
|
90
|
+
feature: string;
|
|
91
|
+
lanes: number;
|
|
92
|
+
}[];
|
|
93
|
+
/** Lanes already prepared per feature (0 for a feature in `prepare`). */
|
|
94
|
+
laneCounts: Record<string, number>;
|
|
95
|
+
}
|
|
96
|
+
export type PlanError = {
|
|
97
|
+
kind: "not-found";
|
|
98
|
+
feature: string;
|
|
99
|
+
message: string;
|
|
100
|
+
} | {
|
|
101
|
+
kind: "not-ready";
|
|
102
|
+
feature: string;
|
|
103
|
+
message: string;
|
|
104
|
+
} | {
|
|
105
|
+
kind: "missing-dependency";
|
|
106
|
+
feature: string;
|
|
107
|
+
on: string;
|
|
108
|
+
message: string;
|
|
109
|
+
} | {
|
|
110
|
+
kind: "cycle";
|
|
111
|
+
cycle: string[];
|
|
112
|
+
message: string;
|
|
113
|
+
} | {
|
|
114
|
+
kind: "no-features";
|
|
115
|
+
message: string;
|
|
116
|
+
};
|
|
117
|
+
export type Planned<T> = {
|
|
118
|
+
ok: true;
|
|
119
|
+
value: T;
|
|
120
|
+
} | {
|
|
121
|
+
ok: false;
|
|
122
|
+
errors: PlanError[];
|
|
123
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/core/fleet-plan/types.ts"],"names":[],"mappings":""}
|