@agent-plan/core 0.2.19-next.21 → 0.2.19-next.22
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/dist/task-selection.d.ts
CHANGED
|
@@ -14,6 +14,17 @@ export interface TaskRecommendation {
|
|
|
14
14
|
deviation?: WorkDeviation;
|
|
15
15
|
reason: string;
|
|
16
16
|
}
|
|
17
|
+
/** Whether a user-explicit task start is valid, independent of priority advice. */
|
|
18
|
+
export interface ExplicitTaskStartEligibility {
|
|
19
|
+
eligible: boolean;
|
|
20
|
+
reason: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Validate an explicitly requested task start. Priority and existing active
|
|
24
|
+
* work remain advisory for explicit user choices; availability and dependency
|
|
25
|
+
* invariants remain mandatory.
|
|
26
|
+
*/
|
|
27
|
+
export declare function checkExplicitTaskStart(features: Feature[], phases: Phase[], taskId: string, deviations?: WorkDeviation[]): ExplicitTaskStartEligibility;
|
|
17
28
|
/**
|
|
18
29
|
* Pure, harness-agnostic work selector. It never mutates plan state: adapters
|
|
19
30
|
* may use its recommendation as a default while still allowing an explicitly
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task-selection.d.ts","sourceRoot":"","sources":["../src/task-selection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEvE,MAAM,MAAM,sBAAsB,GAAG,QAAQ,GAAG,QAAQ,GAAG,UAAU,GAAG,UAAU,GAAG,MAAM,CAAC;AAE5F,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,GAAG,SAAS,CAAC;IAC7B,KAAK,EAAE,KAAK,CAAC;IACb,IAAI,EAAE,IAAI,CAAC;CACZ;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,sBAAsB,CAAC;IAC7B,SAAS,CAAC,EAAE,aAAa,CAAC;I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package/dist/task-selection.js
CHANGED
|
@@ -1,7 +1,36 @@
|
|
|
1
1
|
const unavailable = new Set(["blocked", "waiting", "deferred", "canceled", "rejected"]);
|
|
2
|
+
const hardUnavailable = new Set(["blocked", "deferred", "canceled", "rejected"]);
|
|
2
3
|
const terminal = new Set(["done", "canceled", "rejected"]);
|
|
3
4
|
const priority = (entity) => entity.priority && entity.priority > 0 ? entity.priority : Number.MAX_SAFE_INTEGER;
|
|
4
5
|
const compare = (a, b) => priority(a) - priority(b) || a.number - b.number;
|
|
6
|
+
/**
|
|
7
|
+
* Validate an explicitly requested task start. Priority and existing active
|
|
8
|
+
* work remain advisory for explicit user choices; availability and dependency
|
|
9
|
+
* invariants remain mandatory.
|
|
10
|
+
*/
|
|
11
|
+
export function checkExplicitTaskStart(features, phases, taskId, deviations = []) {
|
|
12
|
+
const featureById = new Map(features.map((feature) => [feature.id, feature]));
|
|
13
|
+
const candidates = phases.flatMap((phase) => phase.tasks.map((task) => ({ feature: phase.featureId ? featureById.get(phase.featureId) : undefined, phase, task })));
|
|
14
|
+
const candidate = candidates.find(({ task }) => task.id === taskId);
|
|
15
|
+
if (!candidate)
|
|
16
|
+
return { eligible: false, reason: "Requested task no longer exists." };
|
|
17
|
+
const isTemporaryOverride = deviations.some((deviation) => (deviation.state === "approved" || deviation.state === "active")
|
|
18
|
+
&& deviation.temporaryTaskId === taskId);
|
|
19
|
+
const startableStatus = candidate.task.status === "planned"
|
|
20
|
+
|| (candidate.task.status === "waiting" && isTemporaryOverride);
|
|
21
|
+
if (!startableStatus)
|
|
22
|
+
return { eligible: false, reason: `Task is not startable from ${candidate.task.status}.` };
|
|
23
|
+
const parentHasHardBlock = hardUnavailable.has(candidate.phase.status)
|
|
24
|
+
|| (candidate.feature && hardUnavailable.has(candidate.feature.status));
|
|
25
|
+
if (parentHasHardBlock || (!isTemporaryOverride && (unavailable.has(candidate.phase.status) || (candidate.feature && unavailable.has(candidate.feature.status))))) {
|
|
26
|
+
return { eligible: false, reason: "Task belongs to an unavailable phase or feature." };
|
|
27
|
+
}
|
|
28
|
+
const taskById = new Map(candidates.map((entry) => [entry.task.id, entry]));
|
|
29
|
+
if (!isTemporaryOverride && !candidate.task.dependsOn.every((id) => taskById.get(id)?.task.status === "done")) {
|
|
30
|
+
return { eligible: false, reason: "Task dependencies are not complete." };
|
|
31
|
+
}
|
|
32
|
+
return { eligible: true, reason: "Explicit task request is startable." };
|
|
33
|
+
}
|
|
5
34
|
/**
|
|
6
35
|
* Pure, harness-agnostic work selector. It never mutates plan state: adapters
|
|
7
36
|
* may use its recommendation as a default while still allowing an explicitly
|
package/package.json
CHANGED