@agent-plan/core 0.2.19-next.2 → 0.2.19-next.21
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/checklist.d.ts +16 -0
- package/dist/checklist.d.ts.map +1 -0
- package/dist/checklist.js +52 -0
- package/dist/display-status.d.ts +99 -0
- package/dist/display-status.d.ts.map +1 -0
- package/dist/display-status.js +176 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/naming.d.ts +21 -3
- package/dist/naming.d.ts.map +1 -1
- package/dist/naming.js +45 -3
- package/dist/plan-store.d.ts +205 -22
- package/dist/plan-store.d.ts.map +1 -1
- package/dist/plan-store.js +940 -187
- package/dist/recap.d.ts.map +1 -1
- package/dist/recap.js +35 -9
- package/dist/refs.d.ts +23 -0
- package/dist/refs.d.ts.map +1 -1
- package/dist/refs.js +81 -0
- package/dist/schema.d.ts +806 -128
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +73 -4
- package/dist/task-context.d.ts +16 -0
- package/dist/task-context.d.ts.map +1 -0
- package/dist/task-context.js +65 -0
- package/dist/task-selection.d.ts +23 -0
- package/dist/task-selection.d.ts.map +1 -0
- package/dist/task-selection.js +66 -0
- package/package.json +4 -1
package/dist/schema.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,eAAe,aAAwB,CAAC;AACrD,eAAO,MAAM,UAAU,aAAiD,CAAC;AAEzE,eAAO,MAAM,kBAAkB;;;;;;;;;EAG7B,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;EAK7B,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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Ae,CAAC,CAAC;AACxD,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAC5D,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAC9E,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAC,GAAG;IAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IAAC,QAAQ,EAAE,gBAAgB,CAAA;CAAE,CAAC"}
|
package/dist/schema.js
CHANGED
|
@@ -37,6 +37,10 @@ export const ResumeFocusSchema = z.object({
|
|
|
37
37
|
currentPhaseId: z.string().default(""),
|
|
38
38
|
inProgressTaskIds: z.array(z.string().min(1)).default([]),
|
|
39
39
|
nextSteps: z.array(z.string().min(1)).default([]),
|
|
40
|
+
/** When `nextSteps` last changed (free-text can go stale; the recap surfaces
|
|
41
|
+
* this so staleness is visible). Preserved across refreshResume (which keeps
|
|
42
|
+
* existing nextSteps); bumped only when saveResume receives new nextSteps. */
|
|
43
|
+
nextStepsUpdatedAt: z.string().default(""),
|
|
40
44
|
blockers: z.array(z.string().min(1)).default([]),
|
|
41
45
|
notes: z.string().default(""),
|
|
42
46
|
lastSessionSummary: z.string().default(""),
|
|
@@ -72,6 +76,22 @@ export const AcceptedDecisionSchema = z.object({
|
|
|
72
76
|
implementationNotes: z.string().default(""),
|
|
73
77
|
acceptedAt: TimestampSchema,
|
|
74
78
|
});
|
|
79
|
+
export const WorkDeviationSchema = z.object({
|
|
80
|
+
id: z.string().min(1),
|
|
81
|
+
/** Task the priority selector recommended when the deviation was approved. */
|
|
82
|
+
recommendedTaskId: z.string().min(1),
|
|
83
|
+
/** Task intentionally chosen instead of the recommendation. */
|
|
84
|
+
temporaryTaskId: z.string().min(1),
|
|
85
|
+
/** Task to surface explicitly after the temporary work is resolved. */
|
|
86
|
+
resumeTaskId: z.string().min(1),
|
|
87
|
+
reason: z.string().default(""),
|
|
88
|
+
requestedBy: z.enum(["agent", "user"]).default("agent"),
|
|
89
|
+
approvedBy: z.string().default("user"),
|
|
90
|
+
state: z.enum(["approved", "active", "resolved", "canceled"]).default("approved"),
|
|
91
|
+
createdAt: TimestampSchema,
|
|
92
|
+
activatedAt: z.string().default(""),
|
|
93
|
+
resolvedAt: z.string().default(""),
|
|
94
|
+
});
|
|
75
95
|
export const ProjectSchema = z.object({
|
|
76
96
|
name: z.string().min(1),
|
|
77
97
|
goal: z.string().default(""),
|
|
@@ -87,6 +107,12 @@ export const ProjectSchema = z.object({
|
|
|
87
107
|
chatLanguage: z.string().default(""),
|
|
88
108
|
workflowRules: WorkflowRulesSchema,
|
|
89
109
|
acceptedDecisions: z.array(AcceptedDecisionSchema).default([]),
|
|
110
|
+
/** Monotonic global sequence counters — assigned at creation, never reused (gaps on delete). */
|
|
111
|
+
nextFeatureNumber: z.number().int().positive().default(1),
|
|
112
|
+
nextPhaseNumber: z.number().int().positive().default(1),
|
|
113
|
+
nextTaskNumber: z.number().int().positive().default(1),
|
|
114
|
+
/** Ordered history of approved temporary work deviations; active entries form a resumable stack. */
|
|
115
|
+
workDeviations: z.array(WorkDeviationSchema).default([]),
|
|
90
116
|
});
|
|
91
117
|
export const SubtaskStatusSchema = z.enum(["planned", "in-progress", "done", "blocked", "canceled", "rejected", "deferred", "waiting"]);
|
|
92
118
|
export const TaskStatusSchema = z.enum(["planned", "in-progress", "done", "blocked", "canceled", "rejected", "deferred", "waiting"]);
|
|
@@ -103,6 +129,10 @@ export const SubtaskSchema = z.object({
|
|
|
103
129
|
});
|
|
104
130
|
export const ChecklistItemSchema = z.object({
|
|
105
131
|
id: z.string().min(1),
|
|
132
|
+
/** Per-task 1-based position, displayed as C{number} (C1, C2, ...). Default 0
|
|
133
|
+
* so legacy on-disk items without a number still parse; the TaskSchema
|
|
134
|
+
* transform overwrites it with the real index+1. */
|
|
135
|
+
number: z.number().int().nonnegative().default(0),
|
|
106
136
|
title: z.string().min(1),
|
|
107
137
|
checked: z.boolean().default(false),
|
|
108
138
|
});
|
|
@@ -134,9 +164,22 @@ export const StatusLogEntrySchema = z.object({
|
|
|
134
164
|
title: z.string().min(1),
|
|
135
165
|
description: z.string().default(""),
|
|
136
166
|
});
|
|
167
|
+
/** Like StatusLogEntrySchema but for the DERIVED PHASE status, which includes
|
|
168
|
+
* the "draft" and "discovery" lifecycle states absent from TaskStatus. */
|
|
169
|
+
export const PhaseStatusLogEntrySchema = z.object({
|
|
170
|
+
id: z.string().min(1),
|
|
171
|
+
date: TimestampSchema,
|
|
172
|
+
fromStatus: PhaseStatusSchema,
|
|
173
|
+
toStatus: PhaseStatusSchema,
|
|
174
|
+
title: z.string().min(1),
|
|
175
|
+
description: z.string().default(""),
|
|
176
|
+
});
|
|
137
177
|
export const TaskSchema = z.object({
|
|
138
178
|
id: z.string(),
|
|
139
|
-
|
|
179
|
+
/** MUST be a phase UUID (not a ref like "P003"). Validated at the schema
|
|
180
|
+
* layer so no adapter can persist an unresolved ref string. */
|
|
181
|
+
phaseId: z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i, "phaseId must be a UUID, not a ref string like P003"),
|
|
182
|
+
/** Global project-wide task sequence (assigned once at creation from project.nextTaskNumber; stable, gaps on delete). Bare T00x is unambiguous. */
|
|
140
183
|
number: z.number().int().nonnegative().default(0),
|
|
141
184
|
shortId: z.string().regex(/^(|[A-Z2-9]{5})$/).default(""),
|
|
142
185
|
priority: z.number().int().nonnegative().default(0),
|
|
@@ -159,13 +202,24 @@ export const TaskSchema = z.object({
|
|
|
159
202
|
...task,
|
|
160
203
|
checklist: task.checklist
|
|
161
204
|
.map((item, index) => typeof item === "string"
|
|
162
|
-
? { id: createChecklistItemId(task.id, index + 1, item), title: item.trim(), checked: false }
|
|
163
|
-
: { ...item, id: item.id || createChecklistItemId(task.id, index + 1, item.title), title: item.title.trim(), checked: item.checked ?? false })
|
|
205
|
+
? { id: createChecklistItemId(task.id, index + 1, item), number: index + 1, title: item.trim(), checked: false }
|
|
206
|
+
: { ...item, id: item.id || createChecklistItemId(task.id, index + 1, item.title), number: index + 1, title: item.title.trim(), checked: item.checked ?? false })
|
|
164
207
|
.filter((item) => item.title.length > 0),
|
|
165
208
|
}));
|
|
209
|
+
export const HandoffHistoryEntrySchema = z.object({
|
|
210
|
+
/** Relative path under .planner/.local/handoff-archive/ (e.g. <phaseId>-<ISO>.md). */
|
|
211
|
+
file: z.string().default(""),
|
|
212
|
+
clearedAt: TimestampSchema,
|
|
213
|
+
/** Why the handoff was cleared: "task-started" | "phase-done" | "manual" | "superseded" | "imported". */
|
|
214
|
+
reason: z.string().default(""),
|
|
215
|
+
});
|
|
166
216
|
export const PhaseSchema = z.object({
|
|
167
217
|
id: z.string(),
|
|
168
|
-
|
|
218
|
+
/** MUST be a feature UUID (not a ref like "F005"). Validated at the schema
|
|
219
|
+
* layer so no adapter can persist an unresolved ref string. Optional only
|
|
220
|
+
* for legacy pre-feature phases. */
|
|
221
|
+
featureId: z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i, "featureId must be a UUID, not a ref string like F005").optional(),
|
|
222
|
+
/** Global project-wide phase sequence (assigned once at creation from project.nextPhaseNumber; stable, gaps on delete). Bare P00x is unambiguous. */
|
|
169
223
|
number: z.number().int().positive(),
|
|
170
224
|
shortId: z.string().regex(/^(|[A-Z2-9]{5})$/).default(""),
|
|
171
225
|
priority: z.number().int().nonnegative().default(0),
|
|
@@ -195,9 +249,22 @@ export const PhaseSchema = z.object({
|
|
|
195
249
|
updatedAt: TimestampSchema,
|
|
196
250
|
handoff: z.string().default(""),
|
|
197
251
|
handoffUpdatedAt: z.string().default(""),
|
|
252
|
+
/** When the handoff was last read/acknowledged on recap (ISO). Non-empty means
|
|
253
|
+
* the agent has seen it; the recap won't re-prompt every turn. The handoff
|
|
254
|
+
* content is KEPT until a task in the phase starts (auto-clear) or the phase
|
|
255
|
+
* completes — so a restart between read and resume does not lose context. */
|
|
256
|
+
handoffReadAt: z.string().default(""),
|
|
257
|
+
/** Metadata for recently-cleared handoffs (newest-first, capped at 5). The
|
|
258
|
+
* full content lives as .md files in .planner/.local/handoff-archive/ (gitignored);
|
|
259
|
+
* this array only holds the pointer + clear reason + timestamp, so the phase
|
|
260
|
+
* JSON stays lean and the archive is recoverable. */
|
|
261
|
+
handoffHistory: z.array(HandoffHistoryEntrySchema).default([]),
|
|
262
|
+
/** Chronological audit trail of the DERIVED status (planned/in-progress/blocked/done/...). Appended ONLY when the derived status changes during a rollup; `status` itself is NOT persisted (still computed from child tasks at read time). Empty = no transition recorded yet (treated as "planned"). */
|
|
263
|
+
statusLog: z.array(PhaseStatusLogEntrySchema).default([]),
|
|
198
264
|
});
|
|
199
265
|
export const FeatureSchema = z.object({
|
|
200
266
|
id: z.string(),
|
|
267
|
+
/** Global project-wide feature sequence (assigned once at creation from project.nextFeatureNumber; stable, gaps on delete). */
|
|
201
268
|
number: z.number().int().nonnegative().default(0),
|
|
202
269
|
shortId: z.string().regex(/^(|[A-Z2-9]{5})$/).default(""),
|
|
203
270
|
priority: z.number().int().nonnegative().default(0),
|
|
@@ -215,6 +282,8 @@ export const FeatureSchema = z.object({
|
|
|
215
282
|
acceptedDecisions: z.array(AcceptedDecisionSchema).default([]),
|
|
216
283
|
phaseIds: z.array(z.string().min(1)).default([]),
|
|
217
284
|
dependsOn: z.array(z.string().min(1)).default([]),
|
|
285
|
+
/** Chronological audit trail of the DERIVED status (computed from child phases at read time). Appended ONLY when the derived status changes during a rollup; `status` itself is NOT persisted. Empty = no transition recorded yet (treated as "planned"). */
|
|
286
|
+
statusLog: z.array(StatusLogEntrySchema).default([]),
|
|
218
287
|
createdAt: TimestampSchema,
|
|
219
288
|
updatedAt: TimestampSchema,
|
|
220
289
|
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Feature, Phase, Requirement } from "./schema.js";
|
|
2
|
+
/**
|
|
3
|
+
* Build a compact, agent-facing context block that surfaces the PARENT PHASE
|
|
4
|
+
* (and grandparent FEATURE) description when a task is started. The phase
|
|
5
|
+
* description carries the shared design context (file:line refs, architecture,
|
|
6
|
+
* current state, behaviors to preserve) that EVERY task in the phase inherits.
|
|
7
|
+
*
|
|
8
|
+
* Injecting this into the `task_start` tool response guarantees the agent sees
|
|
9
|
+
* the phase-level context in the exact moment it begins work — instead of
|
|
10
|
+
* relying on the agent to voluntarily read it beforehand.
|
|
11
|
+
*
|
|
12
|
+
* Harness-agnostic: returns a plain markdown string. Both the Pi adapter and
|
|
13
|
+
* the MCP server append this to their `task_start` confirmation text.
|
|
14
|
+
*/
|
|
15
|
+
export declare function buildPhaseContextBlock(phase: Phase, feature: Feature | undefined, linkedRequirements?: Requirement[], featureRequirements?: Requirement[]): string;
|
|
16
|
+
//# sourceMappingURL=task-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task-context.d.ts","sourceRoot":"","sources":["../src/task-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/D;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,GAAG,SAAS,EAC5B,kBAAkB,GAAE,WAAW,EAAO,EACtC,mBAAmB,GAAE,WAAW,EAAO,GACtC,MAAM,CAkDR"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { formatPhaseRef } from "./naming.js";
|
|
2
|
+
/**
|
|
3
|
+
* Build a compact, agent-facing context block that surfaces the PARENT PHASE
|
|
4
|
+
* (and grandparent FEATURE) description when a task is started. The phase
|
|
5
|
+
* description carries the shared design context (file:line refs, architecture,
|
|
6
|
+
* current state, behaviors to preserve) that EVERY task in the phase inherits.
|
|
7
|
+
*
|
|
8
|
+
* Injecting this into the `task_start` tool response guarantees the agent sees
|
|
9
|
+
* the phase-level context in the exact moment it begins work — instead of
|
|
10
|
+
* relying on the agent to voluntarily read it beforehand.
|
|
11
|
+
*
|
|
12
|
+
* Harness-agnostic: returns a plain markdown string. Both the Pi adapter and
|
|
13
|
+
* the MCP server append this to their `task_start` confirmation text.
|
|
14
|
+
*/
|
|
15
|
+
export function buildPhaseContextBlock(phase, feature, linkedRequirements = [], featureRequirements = []) {
|
|
16
|
+
const lines = [];
|
|
17
|
+
const phaseRef = formatPhaseRef(phase.number, feature?.number);
|
|
18
|
+
const requirementsBlock = (label, requirements, empty) => {
|
|
19
|
+
lines.push(`\n${label} (${requirements.length}):`);
|
|
20
|
+
if (requirements.length === 0) {
|
|
21
|
+
lines.push(` - ${empty}`);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
for (const requirement of requirements) {
|
|
25
|
+
lines.push(` - ${requirement.title}${requirement.description?.trim() ? ` — ${requirement.description.trim()}` : ""}`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
lines.push(`\n📋 Task context — read this BEFORE touching code:`);
|
|
30
|
+
if (feature) {
|
|
31
|
+
lines.push(`Feature F${String(feature.number).padStart(3, "0")} — ${feature.name}`);
|
|
32
|
+
if (feature.description && feature.description.trim()) {
|
|
33
|
+
lines.push(`\nFeature description:\n${feature.description.trim()}`);
|
|
34
|
+
}
|
|
35
|
+
requirementsBlock("Feature linked requirements", featureRequirements, "None linked to this feature.");
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
lines.push("Feature context: no parent feature linked to this phase.");
|
|
39
|
+
requirementsBlock("Feature linked requirements", [], "None linked to this feature.");
|
|
40
|
+
}
|
|
41
|
+
lines.push(`\nPhase ${phaseRef} — ${phase.title}`);
|
|
42
|
+
if (phase.summary && phase.summary.trim()) {
|
|
43
|
+
lines.push(`Summary: ${phase.summary.trim()}`);
|
|
44
|
+
}
|
|
45
|
+
if (phase.description && phase.description.trim()) {
|
|
46
|
+
lines.push(`\nPhase description:\n${phase.description.trim()}`);
|
|
47
|
+
}
|
|
48
|
+
const bullet = (label, items) => {
|
|
49
|
+
if (items && items.length > 0) {
|
|
50
|
+
lines.push(`\n${label}:`);
|
|
51
|
+
for (const it of items)
|
|
52
|
+
lines.push(` - ${it}`);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
bullet("Goals", phase.goals);
|
|
56
|
+
bullet("Non-goals", phase.nonGoals);
|
|
57
|
+
bullet("Dependencies", phase.dependencies);
|
|
58
|
+
bullet("Risks", phase.risks);
|
|
59
|
+
bullet("Open questions", phase.openQuestions);
|
|
60
|
+
bullet("Decisions", phase.decisions);
|
|
61
|
+
bullet("Completion criteria", phase.completionCriteria);
|
|
62
|
+
requirementsBlock("Phase linked requirements", linkedRequirements, "None linked to this phase.");
|
|
63
|
+
lines.push(`\n(End of phase context. Now proceed with the task.)`);
|
|
64
|
+
return lines.join("\n");
|
|
65
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Feature, Phase, Task, WorkDeviation } from "./schema.js";
|
|
2
|
+
export type TaskRecommendationKind = "active" | "resume" | "priority" | "conflict" | "none";
|
|
3
|
+
export interface TaskCandidate {
|
|
4
|
+
feature: Feature | undefined;
|
|
5
|
+
phase: Phase;
|
|
6
|
+
task: Task;
|
|
7
|
+
}
|
|
8
|
+
export interface TaskRecommendation {
|
|
9
|
+
kind: TaskRecommendationKind;
|
|
10
|
+
candidate?: TaskCandidate;
|
|
11
|
+
/** Multiple active tasks make an autonomous selection unsafe. */
|
|
12
|
+
activeCandidates?: TaskCandidate[];
|
|
13
|
+
/** The approved override that caused this recommendation, when applicable. */
|
|
14
|
+
deviation?: WorkDeviation;
|
|
15
|
+
reason: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Pure, harness-agnostic work selector. It never mutates plan state: adapters
|
|
19
|
+
* may use its recommendation as a default while still allowing an explicitly
|
|
20
|
+
* approved temporary deviation.
|
|
21
|
+
*/
|
|
22
|
+
export declare function recommendNextTask(features: Feature[], phases: Phase[], deviations?: WorkDeviation[]): TaskRecommendation;
|
|
23
|
+
//# sourceMappingURL=task-selection.d.ts.map
|
|
@@ -0,0 +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;IAC1B,iEAAiE;IACjE,gBAAgB,CAAC,EAAE,aAAa,EAAE,CAAC;IACnC,8EAA8E;IAC9E,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;CAChB;AAQD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,OAAO,EAAE,EACnB,MAAM,EAAE,KAAK,EAAE,EACf,UAAU,GAAE,aAAa,EAAO,GAC/B,kBAAkB,CAuDpB"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
const unavailable = new Set(["blocked", "waiting", "deferred", "canceled", "rejected"]);
|
|
2
|
+
const terminal = new Set(["done", "canceled", "rejected"]);
|
|
3
|
+
const priority = (entity) => entity.priority && entity.priority > 0 ? entity.priority : Number.MAX_SAFE_INTEGER;
|
|
4
|
+
const compare = (a, b) => priority(a) - priority(b) || a.number - b.number;
|
|
5
|
+
/**
|
|
6
|
+
* Pure, harness-agnostic work selector. It never mutates plan state: adapters
|
|
7
|
+
* may use its recommendation as a default while still allowing an explicitly
|
|
8
|
+
* approved temporary deviation.
|
|
9
|
+
*/
|
|
10
|
+
export function recommendNextTask(features, phases, deviations = []) {
|
|
11
|
+
const featureById = new Map(features.map((feature) => [feature.id, feature]));
|
|
12
|
+
const candidates = phases.flatMap((phase) => phase.tasks.map((task) => ({ feature: phase.featureId ? featureById.get(phase.featureId) : undefined, phase, task })));
|
|
13
|
+
const byTaskId = new Map(candidates.map((candidate) => [candidate.task.id, candidate]));
|
|
14
|
+
const active = candidates.filter(({ task }) => task.status === "in-progress");
|
|
15
|
+
if (active.length > 1)
|
|
16
|
+
return { kind: "conflict", activeCandidates: active, reason: "More than one task is in progress; resolve the active-work conflict before autonomous selection." };
|
|
17
|
+
if (active.length === 1)
|
|
18
|
+
return { kind: "active", candidate: active[0], reason: "Resume the single active task." };
|
|
19
|
+
const newestFirst = (left, right) => right.createdAt.localeCompare(left.createdAt);
|
|
20
|
+
const resumable = (candidate) => candidate
|
|
21
|
+
&& (candidate.task.status === "planned" || candidate.task.status === "waiting");
|
|
22
|
+
const open = deviations
|
|
23
|
+
.filter((deviation) => deviation.state === "approved" || deviation.state === "active")
|
|
24
|
+
.sort(newestFirst);
|
|
25
|
+
const top = open[0];
|
|
26
|
+
if (top) {
|
|
27
|
+
const temporary = byTaskId.get(top.temporaryTaskId);
|
|
28
|
+
const resume = byTaskId.get(top.resumeTaskId);
|
|
29
|
+
if (temporary && terminal.has(temporary.task.status) && resume && (resume.task.status === "planned" || resume.task.status === "waiting")) {
|
|
30
|
+
return { kind: "resume", candidate: resume, deviation: top, reason: "Resume the task preserved by the most recent approved deviation." };
|
|
31
|
+
}
|
|
32
|
+
// A deviation explicitly makes its temporary task eligible while it is
|
|
33
|
+
// planned or paused. Normal priority selection still excludes waiting work.
|
|
34
|
+
if (temporary && (temporary.task.status === "planned" || temporary.task.status === "waiting")) {
|
|
35
|
+
return { kind: "resume", candidate: temporary, deviation: top, reason: "Continue the temporary task of the most recent approved deviation." };
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
// A completed temporary task resolves its record, but its explicit resume
|
|
39
|
+
// target remains the next recommendation until that target itself changes.
|
|
40
|
+
const resolved = deviations
|
|
41
|
+
.filter((deviation) => deviation.state === "resolved")
|
|
42
|
+
.sort(newestFirst)
|
|
43
|
+
.find((deviation) => resumable(byTaskId.get(deviation.resumeTaskId)));
|
|
44
|
+
if (resolved) {
|
|
45
|
+
const candidate = byTaskId.get(resolved.resumeTaskId);
|
|
46
|
+
if (candidate && resumable(candidate)) {
|
|
47
|
+
return {
|
|
48
|
+
kind: "resume",
|
|
49
|
+
candidate,
|
|
50
|
+
deviation: resolved,
|
|
51
|
+
reason: "Resume the task preserved by the most recently resolved deviation.",
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const ready = candidates.filter(({ feature, phase, task }) => {
|
|
56
|
+
if (task.status !== "planned")
|
|
57
|
+
return false;
|
|
58
|
+
if (unavailable.has(phase.status) || (feature && unavailable.has(feature.status)))
|
|
59
|
+
return false;
|
|
60
|
+
return task.dependsOn.every((id) => byTaskId.get(id)?.task.status === "done");
|
|
61
|
+
});
|
|
62
|
+
ready.sort((a, b) => compare(a.feature ?? { priority: 0, number: 0 }, b.feature ?? { priority: 0, number: 0 }) || compare(a.phase, b.phase) || compare(a.task, b.task));
|
|
63
|
+
return ready[0]
|
|
64
|
+
? { kind: "priority", candidate: ready[0], reason: "Highest-priority ready task by feature, phase, then task." }
|
|
65
|
+
: { kind: "none", reason: "No ready task is available." };
|
|
66
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-plan/core",
|
|
3
|
-
"version": "0.2.19-next.
|
|
3
|
+
"version": "0.2.19-next.21",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Harness-agnostic core for Agent Plan: schemas, persistence, ordering, status rollups, and markdown rendering.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -40,6 +40,9 @@
|
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"zod": "^3.24.0"
|
|
42
42
|
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"zod-to-json-schema": "^3.25.2"
|
|
45
|
+
},
|
|
43
46
|
"scripts": {
|
|
44
47
|
"build": "tsc -p tsconfig.json",
|
|
45
48
|
"check": "tsc -p tsconfig.json --noEmit",
|