@agent-plan/core 0.2.19-next.20 ā 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/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/plan-store.d.ts +49 -6
- package/dist/plan-store.d.ts.map +1 -1
- package/dist/plan-store.js +117 -25
- package/dist/schema.d.ts +395 -194
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +18 -0
- package/dist/task-context.d.ts +2 -2
- package/dist/task-context.d.ts.map +1 -1
- package/dist/task-context.js +26 -9
- 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 +1 -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmBhC,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;;;IAK5B;;mFAE+E;;;;;;;;;;;;;;;;;;;;;;;;;;EAM/E,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;EAM9B,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAE5B,CAAC;A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G,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,GAAG;IAAE,MAAM,EAAE,WAAW,CAAA;CAAE,CAAC;AAC1E,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,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
|
@@ -76,6 +76,22 @@ export const AcceptedDecisionSchema = z.object({
|
|
|
76
76
|
implementationNotes: z.string().default(""),
|
|
77
77
|
acceptedAt: TimestampSchema,
|
|
78
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
|
+
});
|
|
79
95
|
export const ProjectSchema = z.object({
|
|
80
96
|
name: z.string().min(1),
|
|
81
97
|
goal: z.string().default(""),
|
|
@@ -95,6 +111,8 @@ export const ProjectSchema = z.object({
|
|
|
95
111
|
nextFeatureNumber: z.number().int().positive().default(1),
|
|
96
112
|
nextPhaseNumber: z.number().int().positive().default(1),
|
|
97
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([]),
|
|
98
116
|
});
|
|
99
117
|
export const SubtaskStatusSchema = z.enum(["planned", "in-progress", "done", "blocked", "canceled", "rejected", "deferred", "waiting"]);
|
|
100
118
|
export const TaskStatusSchema = z.enum(["planned", "in-progress", "done", "blocked", "canceled", "rejected", "deferred", "waiting"]);
|
package/dist/task-context.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Feature, Phase } from "./schema.js";
|
|
1
|
+
import type { Feature, Phase, Requirement } from "./schema.js";
|
|
2
2
|
/**
|
|
3
3
|
* Build a compact, agent-facing context block that surfaces the PARENT PHASE
|
|
4
4
|
* (and grandparent FEATURE) description when a task is started. The phase
|
|
@@ -12,5 +12,5 @@ import type { Feature, Phase } from "./schema.js";
|
|
|
12
12
|
* Harness-agnostic: returns a plain markdown string. Both the Pi adapter and
|
|
13
13
|
* the MCP server append this to their `task_start` confirmation text.
|
|
14
14
|
*/
|
|
15
|
-
export declare function buildPhaseContextBlock(phase: Phase, feature: Feature | undefined): string;
|
|
15
|
+
export declare function buildPhaseContextBlock(phase: Phase, feature: Feature | undefined, linkedRequirements?: Requirement[], featureRequirements?: Requirement[]): string;
|
|
16
16
|
//# sourceMappingURL=task-context.d.ts.map
|
|
@@ -1 +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,MAAM,aAAa,CAAC;
|
|
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"}
|
package/dist/task-context.js
CHANGED
|
@@ -12,11 +12,33 @@ import { formatPhaseRef } from "./naming.js";
|
|
|
12
12
|
* Harness-agnostic: returns a plain markdown string. Both the Pi adapter and
|
|
13
13
|
* the MCP server append this to their `task_start` confirmation text.
|
|
14
14
|
*/
|
|
15
|
-
export function buildPhaseContextBlock(phase, feature) {
|
|
15
|
+
export function buildPhaseContextBlock(phase, feature, linkedRequirements = [], featureRequirements = []) {
|
|
16
16
|
const lines = [];
|
|
17
17
|
const phaseRef = formatPhaseRef(phase.number, feature?.number);
|
|
18
|
-
|
|
19
|
-
|
|
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}`);
|
|
20
42
|
if (phase.summary && phase.summary.trim()) {
|
|
21
43
|
lines.push(`Summary: ${phase.summary.trim()}`);
|
|
22
44
|
}
|
|
@@ -37,12 +59,7 @@ export function buildPhaseContextBlock(phase, feature) {
|
|
|
37
59
|
bullet("Open questions", phase.openQuestions);
|
|
38
60
|
bullet("Decisions", phase.decisions);
|
|
39
61
|
bullet("Completion criteria", phase.completionCriteria);
|
|
40
|
-
|
|
41
|
-
lines.push(`\nFeature F${String(feature.number).padStart(3, "0")} ā ${feature.name}`);
|
|
42
|
-
if (feature.description && feature.description.trim()) {
|
|
43
|
-
lines.push(`\nFeature description:\n${feature.description.trim()}`);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
62
|
+
requirementsBlock("Phase linked requirements", linkedRequirements, "None linked to this phase.");
|
|
46
63
|
lines.push(`\n(End of phase context. Now proceed with the task.)`);
|
|
47
64
|
return lines.join("\n");
|
|
48
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