@agent-plan/core 0.3.0 → 0.3.2

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.
@@ -0,0 +1,64 @@
1
+ import { featureNumberOfPhase, formatFeatureRef, formatPhaseRef } from "./naming.js";
2
+ import { buildBoundedAcceptedDecisionContext } from "./task-context.js";
3
+ export const PLANNER_LOAD_RECAP_HEADING = "## Recap — show this to the user verbatim";
4
+ export const PLANNER_LOAD_AGENT_HEADING = "## Agent-only context — read and keep it; never quote it in the recap";
5
+ /** Split a load reply's text back into the recap the user sees and the
6
+ * agent-only context. Any client (or test) that must show only the recap
7
+ * uses this instead of guessing at the layout. */
8
+ export function splitPlannerLoadText(text) {
9
+ const agentAt = text.indexOf(PLANNER_LOAD_AGENT_HEADING);
10
+ const recapStart = text.startsWith(PLANNER_LOAD_RECAP_HEADING) ? PLANNER_LOAD_RECAP_HEADING.length : 0;
11
+ if (agentAt < 0)
12
+ return { recap: text.slice(recapStart).trim(), agentContext: "" };
13
+ return { recap: text.slice(recapStart, agentAt).trim(), agentContext: text.slice(agentAt + PLANNER_LOAD_AGENT_HEADING.length).trim() };
14
+ }
15
+ export function buildPlannerLoadReply(input) {
16
+ const guide = input.plannerGuide;
17
+ const guideBlock = guide.mode === "include"
18
+ ? ["### Agent Plan operating guide", guide.customized ? guide.message : "", guide.content].filter(Boolean).join("\n\n")
19
+ : [
20
+ "### Agent Plan operating guide",
21
+ `Follow the Agent Plan operating guide. If it is not already in this conversation (the /planner command includes it), read ${guide.path}.`,
22
+ guide.customized ? guide.message : "",
23
+ ].filter(Boolean).join("\n");
24
+ const blocks = [
25
+ PLANNER_LOAD_RECAP_HEADING,
26
+ input.recap,
27
+ PLANNER_LOAD_AGENT_HEADING,
28
+ "### Project context",
29
+ input.projectContext.text,
30
+ ];
31
+ if (input.scopedDecisions && input.scopedDecisions.total > 0) {
32
+ blocks.push("### Accepted decisions for features, phases and tasks", input.scopedDecisions.content);
33
+ }
34
+ blocks.push(guideBlock);
35
+ return {
36
+ text: blocks.join("\n\n"),
37
+ structured: {
38
+ loaded: true,
39
+ projectContext: input.projectContext.structured,
40
+ plannerGuide: guide.mode === "include"
41
+ ? { mode: "include", customized: guide.customized }
42
+ : { mode: "pointer", path: guide.path, customized: guide.customized },
43
+ scopedDecisions: input.scopedDecisions
44
+ ? { total: input.scopedDecisions.total, truncated: input.scopedDecisions.truncated }
45
+ : { total: 0, truncated: false },
46
+ },
47
+ };
48
+ }
49
+ /** Accepted Decisions owned by features, phases and tasks, bounded for a
50
+ * load reply. Project decisions are left out: the project context already
51
+ * carries them. */
52
+ export function buildScopedDecisionContext(plan) {
53
+ const features = plan.features.features;
54
+ const phaseRef = (phase) => formatPhaseRef(phase.number, featureNumberOfPhase(phase, features));
55
+ const { content, total, truncated } = buildBoundedAcceptedDecisionContext([
56
+ ...features.map((feature) => ({ scope: `feature ${formatFeatureRef(feature.number)}`, decisions: feature.acceptedDecisions })),
57
+ ...plan.phases.map((phase) => ({ scope: `phase ${phaseRef(phase)}`, decisions: phase.acceptedDecisions })),
58
+ ...plan.phases.flatMap((phase) => phase.tasks.map((task) => ({
59
+ scope: `task ${phaseRef(phase)}/T${String(task.number).padStart(3, "0")}`,
60
+ decisions: task.acceptedDecisions,
61
+ }))),
62
+ ]);
63
+ return { content, total, truncated };
64
+ }
@@ -0,0 +1,59 @@
1
+ import type { Feature, Phase } from "./schema.js";
2
+ /**
3
+ * On-hold work that may be ready to resume.
4
+ *
5
+ * A task parked as deferred, waiting or blocked keeps its reason in the
6
+ * status log ("Resume once P097 lands"). Nothing used to look at those
7
+ * reasons again, so work whose blocker had finished stayed parked until a
8
+ * person noticed. This module is the one place that lists on-hold tasks
9
+ * with their reasons and checks the ones whose reason names planner refs:
10
+ * the recommendation and the load recap both read it, so they cannot
11
+ * disagree.
12
+ */
13
+ export declare const ON_HOLD_STATUSES: Set<string>;
14
+ export interface OnHoldRef {
15
+ /** The ref as written in the reason, normalized (e.g. `P097(F003)`, `T468`). */
16
+ ref: string;
17
+ /** Whether the named phase or task exists and is finished. */
18
+ finished: boolean;
19
+ /** False when the ref names nothing in this plan. */
20
+ found: boolean;
21
+ }
22
+ export interface OnHoldTask {
23
+ taskId: string;
24
+ ref: string;
25
+ title: string;
26
+ status: string;
27
+ phaseId: string;
28
+ phaseRef: string;
29
+ /** Why it was put on hold: the motivation of the status change that parked it. */
30
+ reason: string;
31
+ heldSince: string;
32
+ /** Planner refs the task is actually waiting on: refs named in the hold
33
+ * reason, plus its own dependsOn edges (by composite ref) — deduplicated,
34
+ * so a dependency already spelled out in the reason is not double-listed.
35
+ * Each is checked against the plan. */
36
+ namedRefs: OnHoldRef[];
37
+ /** True when there is at least one ref to wait on (named in the reason or
38
+ * a dependsOn edge) and every one of them is finished. */
39
+ readyToResume: boolean;
40
+ }
41
+ /** Resolve every planner ref named in `text`, by number only (never by title). */
42
+ export declare function refsNamedIn(text: string, phases: Phase[], features: Feature[], selfTaskId?: string): OnHoldRef[];
43
+ /**
44
+ * Every on-hold task, ready-to-resume ones first. Pass `phaseIds` to limit
45
+ * the list to the phases a caller is about to act on.
46
+ */
47
+ export declare function listOnHoldWork(features: Feature[], phases: Phase[], phaseIds?: Set<string>): OnHoldTask[];
48
+ /**
49
+ * The phases whose on-hold work matters now: phases where work has started
50
+ * (some task finished or in progress) but not every task is finished. A
51
+ * phase nobody has started yet keeps its on-hold tasks out of the way.
52
+ */
53
+ export declare function startedOpenPhaseIds(phases: Phase[]): Set<string>;
54
+ /**
55
+ * One bounded text block for any reply. Ready-to-resume tasks first; each
56
+ * line carries the reason so the agent can re-check it against the plan.
57
+ */
58
+ export declare function renderOnHoldWork(items: OnHoldTask[], limit?: number): string;
59
+ //# sourceMappingURL=on-hold.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"on-hold.d.ts","sourceRoot":"","sources":["../src/on-hold.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAQ,M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js";
2
+ /**
3
+ * On-hold work that may be ready to resume.
4
+ *
5
+ * A task parked as deferred, waiting or blocked keeps its reason in the
6
+ * status log ("Resume once P097 lands"). Nothing used to look at those
7
+ * reasons again, so work whose blocker had finished stayed parked until a
8
+ * person noticed. This module is the one place that lists on-hold tasks
9
+ * with their reasons and checks the ones whose reason names planner refs:
10
+ * the recommendation and the load recap both read it, so they cannot
11
+ * disagree.
12
+ */
13
+ export const ON_HOLD_STATUSES = new Set(["deferred", "waiting", "blocked"]);
14
+ const FINISHED = new Set(["done", "canceled", "rejected"]);
15
+ // A phase ref with optional feature and task, in either spelling
16
+ // (`P097`, `P097(F003)`, `F003/P097`, `P094(F011)/T449`, `F011/P094/T449`),
17
+ // or a bare task ref (`T468`). Word-bounded so prose like "HTTP2" or
18
+ // "T-shirt" never matches.
19
+ const REF_IN_TEXT = /\b(?:F(\d{1,4})\/)?P(\d{1,4})(?:\(F(\d{1,4})\))?(?:\/T(\d{1,4}))?(?!\w)|\bT(\d{1,4})(?!\w)/g;
20
+ const pad = (n) => String(n).padStart(3, "0");
21
+ function holdEntry(task) {
22
+ const entry = [...(task.statusLog ?? [])].reverse().find((log) => log.toStatus === task.status);
23
+ const reason = (entry?.description ?? "").replace(/^Motivation:\s*/i, "").trim();
24
+ return { reason, at: entry?.date ?? task.updatedAt ?? "" };
25
+ }
26
+ /** Resolve every planner ref named in `text`, by number only (never by title). */
27
+ export function refsNamedIn(text, phases, features, selfTaskId = "") {
28
+ const phaseByNumber = new Map(phases.map((phase) => [phase.number, phase]));
29
+ const taskByNumber = new Map(phases.flatMap((phase) => phase.tasks.map((task) => [task.number, { phase, task }])));
30
+ const featureByNumber = new Map(features.map((feature) => [feature.number, feature]));
31
+ const seen = new Map();
32
+ for (const match of text.matchAll(REF_IN_TEXT)) {
33
+ const [, leadingFeatureNum, phaseNum, trailingFeatureNum, phaseTaskNum, bareTaskNum] = match;
34
+ const featureNum = trailingFeatureNum ?? leadingFeatureNum;
35
+ if (bareTaskNum || phaseTaskNum) {
36
+ const taskNum = Number(bareTaskNum ?? phaseTaskNum);
37
+ const hit = taskByNumber.get(taskNum);
38
+ const parentOk = !phaseNum || hit?.phase.number === Number(phaseNum);
39
+ const featureOk = !featureNum || (hit && hit.phase.featureId === featureByNumber.get(Number(featureNum))?.id);
40
+ const ref = phaseNum
41
+ ? `P${pad(Number(phaseNum))}${featureNum ? `(F${pad(Number(featureNum))})` : ""}/T${pad(taskNum)}`
42
+ : `T${pad(taskNum)}`;
43
+ if (hit?.task.id === selfTaskId)
44
+ continue;
45
+ const found = Boolean(hit && parentOk && featureOk);
46
+ seen.set(ref, { ref, found, finished: found && FINISHED.has(hit.task.status) });
47
+ continue;
48
+ }
49
+ const phase = phaseByNumber.get(Number(phaseNum));
50
+ const featureOk = !featureNum || (phase && phase.featureId === featureByNumber.get(Number(featureNum))?.id);
51
+ const ref = `P${pad(Number(phaseNum))}${featureNum ? `(F${pad(Number(featureNum))})` : ""}`;
52
+ const found = Boolean(phase && featureOk);
53
+ const finished = found && phase.tasks.length > 0 && phase.tasks.every((task) => FINISHED.has(task.status));
54
+ seen.set(ref, { ref, found, finished });
55
+ }
56
+ return [...seen.values()];
57
+ }
58
+ /** Resolve a task's dependsOn edges to composite refs, checked against the
59
+ * plan the same way refsNamedIn checks a ref found in text. A dependsOn id
60
+ * always resolves (dependencies are validated at creation — see
61
+ * PlanStore.addTaskDependency), but a defensive `found: false` covers a
62
+ * dangling edge from an older plan rather than throwing. */
63
+ function dependencyRefsFor(task, phases, features) {
64
+ return (task.dependsOn ?? []).map((dependencyId) => {
65
+ for (const phase of phases) {
66
+ const dependency = phase.tasks.find((candidate) => candidate.id === dependencyId);
67
+ if (dependency) {
68
+ const ref = `${formatPhaseRef(phase.number, featureNumberOfPhase(phase, features))}/T${pad(dependency.number)}`;
69
+ return { ref, found: true, finished: FINISHED.has(dependency.status) };
70
+ }
71
+ }
72
+ return { ref: dependencyId, found: false, finished: false };
73
+ });
74
+ }
75
+ /**
76
+ * Every on-hold task, ready-to-resume ones first. Pass `phaseIds` to limit
77
+ * the list to the phases a caller is about to act on.
78
+ */
79
+ export function listOnHoldWork(features, phases, phaseIds) {
80
+ const items = [];
81
+ for (const phase of phases) {
82
+ if (phaseIds && !phaseIds.has(phase.id))
83
+ continue;
84
+ const phaseRef = formatPhaseRef(phase.number, featureNumberOfPhase(phase, features));
85
+ for (const task of phase.tasks) {
86
+ if (!ON_HOLD_STATUSES.has(task.status))
87
+ continue;
88
+ const { reason, at } = holdEntry(task);
89
+ // A parked task waits on whatever its reason names AND whatever it
90
+ // depends on — merged by ref so a dependency already spelled out in
91
+ // the reason is not counted, or shown, twice.
92
+ const namedRefs = refsNamedIn(reason, phases, features, task.id);
93
+ const seenRefs = new Set(namedRefs.map((named) => named.ref));
94
+ for (const dependencyRef of dependencyRefsFor(task, phases, features)) {
95
+ if (seenRefs.has(dependencyRef.ref))
96
+ continue;
97
+ seenRefs.add(dependencyRef.ref);
98
+ namedRefs.push(dependencyRef);
99
+ }
100
+ items.push({
101
+ taskId: task.id,
102
+ ref: `${phaseRef}/T${pad(task.number)}`,
103
+ title: task.title,
104
+ status: task.status,
105
+ phaseId: phase.id,
106
+ phaseRef,
107
+ reason,
108
+ heldSince: at,
109
+ namedRefs,
110
+ readyToResume: namedRefs.length > 0 && namedRefs.every((named) => named.finished),
111
+ });
112
+ }
113
+ }
114
+ return items.sort((left, right) => Number(right.readyToResume) - Number(left.readyToResume));
115
+ }
116
+ /**
117
+ * The phases whose on-hold work matters now: phases where work has started
118
+ * (some task finished or in progress) but not every task is finished. A
119
+ * phase nobody has started yet keeps its on-hold tasks out of the way.
120
+ */
121
+ export function startedOpenPhaseIds(phases) {
122
+ return new Set(phases
123
+ .filter((phase) => phase.tasks.some((task) => FINISHED.has(task.status) || task.status === "in-progress"))
124
+ .filter((phase) => phase.tasks.some((task) => !FINISHED.has(task.status)))
125
+ .map((phase) => phase.id));
126
+ }
127
+ const REASON_PREVIEW_CHARS = 160;
128
+ /**
129
+ * One bounded text block for any reply. Ready-to-resume tasks first; each
130
+ * line carries the reason so the agent can re-check it against the plan.
131
+ */
132
+ export function renderOnHoldWork(items, limit = 8) {
133
+ if (items.length === 0)
134
+ return "";
135
+ const shown = items.slice(0, limit);
136
+ const lines = shown.map((item) => {
137
+ const reason = item.reason
138
+ ? item.reason.length > REASON_PREVIEW_CHARS ? `${item.reason.slice(0, REASON_PREVIEW_CHARS).trimEnd()}…` : item.reason
139
+ : "(no reason recorded)";
140
+ const check = item.readyToResume
141
+ ? ` — MAY BE READY: everything its reason names is finished (${item.namedRefs.map((named) => named.ref).join(", ")}); re-check and resume it if nothing else holds it`
142
+ : item.namedRefs.some((named) => !named.finished)
143
+ ? ` — still waiting on ${item.namedRefs.filter((named) => !named.finished).map((named) => named.found ? named.ref : `${named.ref} (not found)`).join(", ")}`
144
+ : "";
145
+ return `- ${item.ref} — ${item.title} [${item.status}]${check}\n Reason: ${reason}`;
146
+ });
147
+ const more = items.length > shown.length ? `\n(${items.length - shown.length} more on hold; list them with the phase's task list.)` : "";
148
+ const ready = items.filter((item) => item.readyToResume).length;
149
+ return `On hold — check whether these can resume (${items.length} on hold${ready ? `, ${ready} may be ready` : ""}):\n${lines.join("\n")}${more}`;
150
+ }
@@ -8,4 +8,17 @@ export interface RuntimePackageVersion {
8
8
  export declare function packageVersionFromModule(moduleUrlOrPath: string, expectedName: string): RuntimePackageVersion;
9
9
  /** Resolve a dependency exactly as the caller loaded it, then read its manifest. */
10
10
  export declare function resolvedPackageVersion(packageName: string, fromModuleUrl: string): RuntimePackageVersion;
11
+ /**
12
+ * A long-lived process (an MCP server a session started, a Pi extension)
13
+ * keeps running the code it loaded. After an upgrade it silently runs old
14
+ * code, so an already-fixed bug looks like it came back. This returns a
15
+ * checker that re-reads the loaded package's manifest — one small file, at
16
+ * most once per `intervalMs` — and returns a one-line notice while the
17
+ * version on disk differs from the one loaded. It never throws: an
18
+ * unreadable manifest means no notice.
19
+ */
20
+ export declare function createStaleProcessCheck(loaded: RuntimePackageVersion, { intervalMs, now }?: {
21
+ intervalMs?: number;
22
+ now?: () => number;
23
+ }): () => string | undefined;
11
24
  //# sourceMappingURL=package-version.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"package-version.d.ts","sourceRoot":"","sources":["../src/package-version.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,+EAA+E;IAC/E,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAaD,wEAAwE;AACxE,wBAAgB,wBAAwB,CACtC,eAAe,EAAE,MAAM,EACvB,YAAY,EAAE,MAAM,GACnB,qBAAqB,CAqBvB;AAED,oFAAoF;AACpF,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,MAAM,EACnB,aAAa,EAAE,MAAM,GACpB,qBAAqB,CAGvB"}
1
+ {"version":3,"file":"package-version.d.ts","sourceRoot":"","sources":["../src/package-version.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,+EAA+E;IAC/E,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAaD,wEAAwE;AACxE,wBAAgB,wBAAwB,CACtC,eAAe,EAAE,MAAM,EACvB,YAAY,EAAE,MAAM,GACnB,qBAAqB,CAqBvB;AAED,oFAAoF;AACpF,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,MAAM,EACnB,aAAa,EAAE,MAAM,GACpB,qBAAqB,CAGvB;AAED;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,qBAAqB,EAC7B,EAAE,UAAwB,EAAE,GAAsB,EAAE,GAAE;IAAE,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAA;CAAO,GACrG,MAAM,MAAM,GAAG,SAAS,CAmB1B"}
@@ -33,3 +33,35 @@ export function resolvedPackageVersion(packageName, fromModuleUrl) {
33
33
  const entryPath = createRequire(fromModuleUrl).resolve(packageName);
34
34
  return packageVersionFromModule(entryPath, packageName);
35
35
  }
36
+ /**
37
+ * A long-lived process (an MCP server a session started, a Pi extension)
38
+ * keeps running the code it loaded. After an upgrade it silently runs old
39
+ * code, so an already-fixed bug looks like it came back. This returns a
40
+ * checker that re-reads the loaded package's manifest — one small file, at
41
+ * most once per `intervalMs` — and returns a one-line notice while the
42
+ * version on disk differs from the one loaded. It never throws: an
43
+ * unreadable manifest means no notice.
44
+ */
45
+ export function createStaleProcessCheck(loaded, { intervalMs = 10 * 60_000, now = () => Date.now() } = {}) {
46
+ let checkedAt = Number.NEGATIVE_INFINITY;
47
+ let notice;
48
+ return () => {
49
+ if (!loaded.packageJsonPath)
50
+ return undefined;
51
+ const time = now();
52
+ if (time - checkedAt < intervalMs)
53
+ return notice;
54
+ checkedAt = time;
55
+ notice = undefined;
56
+ try {
57
+ const manifest = JSON.parse(readFileSync(loaded.packageJsonPath, "utf-8"));
58
+ if (typeof manifest.version === "string" && manifest.version.trim() && manifest.version !== loaded.version) {
59
+ notice = `⚠️ This session is running ${loaded.name} ${loaded.version}, but ${manifest.version} is now installed. Restart the session (in Claude Code: /mcp, then reconnect agent-plan) to use it; until then, fixes made after ${loaded.version} are not active here.`;
60
+ }
61
+ }
62
+ catch {
63
+ notice = undefined;
64
+ }
65
+ return notice;
66
+ };
67
+ }
@@ -1,7 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { type Project, type RequirementsDocument } from "./schema.js";
3
3
  export declare const PROJECT_CONTEXT_DELIVERY_VERSION = 1;
4
- export declare const DEFAULT_PROJECT_CONTEXT_CHUNK_CHARS = 16000;
4
+ export declare const DEFAULT_PROJECT_CONTEXT_CHUNK_CHARS = 32000;
5
5
  export declare const ProjectContextReadAttestationSchema: z.ZodObject<{
6
6
  sessionId: z.ZodString;
7
7
  createdAt: z.ZodString;
@@ -375,9 +375,11 @@ export declare function renderProjectContext(snapshot: ProjectContextSnapshot):
375
375
  * Every adapter (Pi, MCP, and any future harness) must deliver the same
376
376
  * complete project-level context, so the reply is shaped once here instead
377
377
  * of once per adapter — the same placement rule as handoff-reply.ts (AGENTS.md
378
- * rule 4). Both channels carry the full snapshot on a complete delivery:
379
- * some hosts surface only `text` to the agent, others only structuredContent
380
- * ("structuredContent-only host compatibility"), so neither is optional.
378
+ * rule 4). The snapshot is carried once, as rendered `text`; `structured`
379
+ * holds only the delivery status (complete or not, fingerprint, next
380
+ * actions). A host that shows the agent only structuredContent still gets
381
+ * the text: the MCP server folds every reply's text into its structured
382
+ * part (foldTextIntoStructured in plan-mcp).
381
383
  */
382
384
  export interface ProjectContextReply {
383
385
  text: string;
@@ -1 +1 @@
1
- {"version":3,"file":"project-context.d.ts","sourceRoot":"","sources":["../src/project-context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAIL,KAAK,OAAO,EACZ,KAAK,oBAAoB,EAE1B,MAAM,aAAa,CAAC;AAGrB,eAAO,MAAM,gCAAgC,IAAI,CAAC;AAClD,eAAO,MAAM,mCAAmC,QAAS,CAAC;AAE1D,eAAO,MAAM,mCAAmC;;;;;;;;;;;;EAI9C,CAAC;AAEH,eAAO,MAAM,qCAAqC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGhD,CAAC;AAEH,MAAM,MAAM,6BAA6B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mCAAmC,CAAC,CAAC;AAChG,MAAM,MAAM,+BAA+B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qCAAqC,CAAC,CAAC;AAYpG,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AED,mFAAmF;AACnF,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,sBAAsB,GAAG,MAAM,CA0C7E;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACrC;AAED;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAAC,QAAQ,EAAE,8BAA8B,EAAE,QAAQ,EAAE,MAAM,GAAG,mBAAmB,CA0B5H"}
@@ -3,7 +3,7 @@ import { z } from "zod";
3
3
  import { AcceptedDecisionSchema, DescriptionRefSchema, MacroTaskSchema, TimestampSchema, } from "./schema.js";
4
4
  import { renderAcceptedDecisionsSection } from "./task-context.js";
5
5
  export const PROJECT_CONTEXT_DELIVERY_VERSION = 1;
6
- export const DEFAULT_PROJECT_CONTEXT_CHUNK_CHARS = 16_000;
6
+ export const DEFAULT_PROJECT_CONTEXT_CHUNK_CHARS = 32_000;
7
7
  export const ProjectContextReadAttestationSchema = z.object({
8
8
  sessionId: z.string().min(1),
9
9
  createdAt: TimestampSchema,
@@ -287,9 +287,8 @@ export function buildProjectContextLoadReply(delivery, maxChars) {
287
287
  structured: {
288
288
  loaded: true,
289
289
  contextComplete: true,
290
- project: delivery.snapshot.project,
291
- requirements: delivery.snapshot.requirements,
292
290
  fingerprint: delivery.evidence.fingerprint,
291
+ requirementCount: delivery.snapshot.requirements.length,
293
292
  },
294
293
  };
295
294
  }
@@ -1 +1 @@
1
- {"version":3,"file":"recap.d.ts","sourceRoot":"","sources":["../src/recap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAMjD;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC3B;AAED,yEAAyE;AACzE,MAAM,MAAM,YAAY,GAAG,IAAI,GAAG,KAAK,CAAC;AAExC,MAAM,WAAW,YAAY;IAC3B,OAAO,CAAC,EAAE,YAAY,CAAC;CACxB;AAKD;;;;;;;;;;;;;GAaG;AACH,wBAAsB,UAAU,CAAC,EAAE,EAAE,SAAS,EAAE,GAAG,GAAE,YAAiB,EAAE,IAAI,GAAE,YAAiB,GAAG,OAAO,CAAC,MAAM,CAAC,CA2ShH"}
1
+ {"version":3,"file":"recap.d.ts","sourceRoot":"","sources":["../src/recap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAOjD;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC3B;AAED,yEAAyE;AACzE,MAAM,MAAM,YAAY,GAAG,IAAI,GAAG,KAAK,CAAC;AAExC,MAAM,WAAW,YAAY;IAC3B,OAAO,CAAC,EAAE,YAAY,CAAC;CACxB;AAKD;;;;;;;;;;;;;GAaG;AACH,wBAAsB,UAAU,CAAC,EAAE,EAAE,SAAS,EAAE,GAAG,GAAE,YAAiB,EAAE,IAAI,GAAE,YAAiB,GAAG,OAAO,CAAC,MAAM,CAAC,CAgThH"}
package/dist/recap.js CHANGED
@@ -2,6 +2,7 @@ import { formatPhaseRef, formatTwoDigitNumber } from "./naming.js";
2
2
  import { buildPhaseWorkMap } from "./task-context.js";
3
3
  import { recommendNextTask } from "./task-selection.js";
4
4
  import { listOpenPhaseWork, openPhaseWorkLines } from "./stranded-phase.js";
5
+ import { listOnHoldWork, renderOnHoldWork, startedOpenPhaseIds } from "./on-hold.js";
5
6
  const fref = (n) => `F${formatTwoDigitNumber(n)}`;
6
7
  const tref = (n) => `T${formatTwoDigitNumber(n)}`;
7
8
  /**
@@ -85,6 +86,11 @@ export async function buildRecap(st, web = {}, opts = {}) {
85
86
  if (openPhaseWorkText) {
86
87
  lines.push("", italian ? "In-progress: fasi con lavoro rimanente (ordine di priorità):" : "In-progress phases with work left (priority order):", openPhaseWorkText);
87
88
  }
89
+ // Parked work in phases already under way, with its reason and whether
90
+ // what it waits on has finished — the same list task_recommend shows.
91
+ const onHoldText = renderOnHoldWork(listOnHoldWork(feats, phases, startedOpenPhaseIds(phases)), 5);
92
+ if (onHoldText)
93
+ lines.push("", onHoldText);
88
94
  if (activeTasks.length > 1) {
89
95
  const conflicts = activeTasks.map(({ phase, task }) => {
90
96
  const feature = feats.find((entry) => entry.id === phase.featureId);
@@ -1 +1 @@
1
- {"version":3,"file":"recommend-reply.d.ts","sourceRoot":"","sources":["../src/recommend-reply.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,KAAK,EAAE,sBAAsB,EAAiB,MAAM,qBAAqB,CAAC;AAEjF,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACrC;AAED;wDACwD;AACxD,MAAM,WAAW,8BAA8B;IAC7C,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAwBD;;;;;;;;;;;GAWG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,sBAAsB,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,cAAc,CAsD5G"}
1
+ {"version":3,"file":"recommend-reply.d.ts","sourceRoot":"","sources":["../src/recommend-reply.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,KAAK,EAAE,sBAAsB,EAAiB,MAAM,qBAAqB,CAAC;AAGjF,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACrC;AAED;wDACwD;AACxD,MAAM,WAAW,8BAA8B;IAC7C,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAwBD;;;;;;;;;;;GAWG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,sBAAsB,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,cAAc,CA8D5G"}
@@ -1,4 +1,5 @@
1
1
  import { featureNumberOfPhase, formatPhaseRef } from "./naming.js";
2
+ import { renderOnHoldWork } from "./on-hold.js";
2
3
  function compositeTaskRef(candidate, features) {
3
4
  const featureNumber = featureNumberOfPhase(candidate.phase, features);
4
5
  return `${formatPhaseRef(candidate.phase.number, featureNumber)}/T${String(candidate.task.number).padStart(3, "0")}`;
@@ -32,7 +33,13 @@ function renderClaimsText(claims) {
32
33
  */
33
34
  export function buildRecommendationReply(result, features) {
34
35
  const { selection } = result;
35
- const claimsText = renderClaimsText(result.claims);
36
+ const onHoldBlock = renderOnHoldWork(result.onHold ?? []);
37
+ const claimsText = `${renderClaimsText(result.claims)}${onHoldBlock ? `\n\n${onHoldBlock}` : ""}`;
38
+ // Counts and refs only: the reasons are in the text.
39
+ const onHoldSummary = {
40
+ total: (result.onHold ?? []).length,
41
+ readyToResume: (result.onHold ?? []).filter((item) => item.readyToResume).map((item) => item.ref),
42
+ };
36
43
  if (!selection.candidate) {
37
44
  const activeCandidates = selection.activeCandidates ?? [];
38
45
  return {
@@ -46,6 +53,7 @@ export function buildRecommendationReply(result, features) {
46
53
  nextPhase: result.nextPhase,
47
54
  nextTask: result.nextTask,
48
55
  claims: result.claims,
56
+ onHold: onHoldSummary,
49
57
  selection: {
50
58
  kind: selection.kind,
51
59
  reason: selection.reason,
@@ -73,6 +81,7 @@ export function buildRecommendationReply(result, features) {
73
81
  nextPhase: result.nextPhase,
74
82
  nextTask: result.nextTask,
75
83
  claims: result.claims,
84
+ onHold: onHoldSummary,
76
85
  selection: {
77
86
  kind: selection.kind,
78
87
  reason: selection.reason,
@@ -1 +1 @@
1
- {"version":3,"file":"task-context.d.ts","sourceRoot":"","sources":["../src/task-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAIhG,eAAO,MAAM,mCAAmC,OAAQ,CAAC;AACzD,eAAO,MAAM,wBAAwB,OAAQ,CAAC;AAE9C,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,wBAAwB,EAAE,OAAO,CAAC;IAClC,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,sHAAsH;IACtH,OAAO,EAAE,iBAAiB,EAAE,CAAC;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,S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,SAA2B,GAClC,YAAY,CA6Dd;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,GAAG,SAAS,EAC5B,kBAAkB,GAAE,WAAW,EAAO,EACtC,mBAAmB,GAAE,WAAW,EAAO,EACvC,IAAI,CAAC,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,GAAG,mBAAmB,CAAC,EAC7C,OAAO,CAAC,EAAE,IAAI,CAAC,OAAO,EAAE,mBAAmB,CAAC,GAC3C,MAAM,CA0DR"}
@@ -74,19 +74,29 @@ export function buildPhaseWorkMap(phase, featureNumber, currentTaskId, maxChars
74
74
  remainingCapabilityOwner: !["done", "canceled", "rejected"].includes(task.status),
75
75
  current: task.id === currentTaskId,
76
76
  }));
77
- const header = `Phase work map — canonical sibling capability ownership (${entries.length}, priority order):`;
78
- const rendered = entries.map((entry) => ({
79
- entry,
80
- block: [
81
- `- ${entry.ref}${entry.current ? " (current)" : ""} — ${entry.title} [priority ${entry.priority}; ${entry.status}]`,
82
- ` Goal: ${entry.conciseGoal}`,
83
- ` Depends on: ${entry.dependencies.length > 0 ? entry.dependencies.join(", ") : "None."}`,
84
- entry.remainingCapabilityOwner
85
- ? ` Ownership: ${entry.ref} owns this remaining capability; do not duplicate it in another task.`
86
- : " Ownership: no remaining capability ownership (terminal task).",
87
- ].join("\n"),
88
- }));
89
- const truncationNotice = (withheldCount) => `[Phase work map truncated for transport safety: ${withheldCount} lower-priority ${withheldCount === 1 ? "entry" : "entries"} withheld. Read the canonical phase and task full views before proposing work; place deeper context under .planner/docs/.]`;
77
+ // Open work first, in full: that is what the agent must not duplicate and
78
+ // may pick up. Finished tasks follow as one line each — enough to see a
79
+ // capability already exists — so a long phase does not spend the reply on
80
+ // closed work, and the budget cuts finished lines before open ones.
81
+ const open = entries.filter((entry) => entry.remainingCapabilityOwner);
82
+ const closed = entries.filter((entry) => !entry.remainingCapabilityOwner);
83
+ const header = `Phase work map — canonical sibling capability ownership (${open.length} open, ${closed.length} finished; open first, priority order):`;
84
+ const rendered = [
85
+ ...open.map((entry) => ({
86
+ entry,
87
+ block: [
88
+ `- ${entry.ref}${entry.current ? " (current)" : ""} — ${entry.title} [priority ${entry.priority}; ${entry.status}]`,
89
+ ` Goal: ${entry.conciseGoal}`,
90
+ ` Depends on: ${entry.dependencies.length > 0 ? entry.dependencies.join(", ") : "None."}`,
91
+ ` Ownership: ${entry.ref} owns this remaining capability; do not duplicate it in another task.`,
92
+ ].join("\n"),
93
+ })),
94
+ ...closed.map((entry, index) => ({
95
+ entry,
96
+ block: `${index === 0 ? "Finished (already built; do not redo):\n" : ""}- ${entry.ref} — ${entry.title} [${entry.status}]`,
97
+ })),
98
+ ];
99
+ const truncationNotice = (withheldCount) => `[Phase work map truncated for transport safety: ${withheldCount} ${withheldCount === 1 ? "entry" : "entries"} withheld, finished ones first. Read the canonical phase and task full views before proposing work; place deeper context under .planner/docs/.]`;
90
100
  // Reserve space using the full task count as the withheld-count placeholder: since the
91
101
  // eventual withheld count can never exceed it, this reservation is always a safe upper
92
102
  // bound on the final notice length, so shrinking it afterward cannot overflow maxChars.
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Move one or more tasks to a different phase without recreating them.
3
+ *
4
+ * Before this, moving a task meant deleting it and creating a new one in
5
+ * the target phase — losing its id, statusLog, checklist ticks, accepted
6
+ * decisions, pause history, and every dependsOn edge pointing at it (see
7
+ * P108(F005): heca's P082(F003)/T468, T470, T471, T472, T513 are on hold
8
+ * until work in P094 lands, but belong in P094 as its closing steps, and
9
+ * recreating five ~4,000-character tasks loses all of that history). This
10
+ * module is the one place that moves a task: only `phaseId`, `statusLog`
11
+ * (one appended entry) and `updatedAt` change. Everything else — id,
12
+ * number, shortId, status, checklist, subtasks, acceptedDecisions,
13
+ * pauseSnapshot/pauseHistory, notes, description/descriptionRef and
14
+ * dependsOn — survives untouched because the task object is spread, never
15
+ * rebuilt field by field. Other tasks' dependsOn keep resolving because
16
+ * task ids never change; only the composite ref they'd print as changes.
17
+ *
18
+ * Reply size is deliberately independent of task size: a moved task's
19
+ * description can be tens of thousands of characters, and a caller moving
20
+ * five tasks already has that text — it must not pay to receive it again.
21
+ * buildTaskMoveReply (below) echoes only ref/id/shortId/title/status per
22
+ * task, never the task body.
23
+ *
24
+ * Both phase files change together or neither: this runs inside
25
+ * `store.runBatch` and mirrors the rollback-on-error shape the MCP/Pi
26
+ * `planner-task-switch` / `task_switch` tools already use for a two-phase
27
+ * write (pause a task in one phase, start one in another) — collect the
28
+ * exact task objects removed from each source phase, and if any later step
29
+ * throws, add them straight back rather than reconstructing the phase's
30
+ * task array (which could clobber a concurrent unrelated write to that
31
+ * file).
32
+ */
33
+ import type { PlanStore } from "./plan-store.js";
34
+ import type { MutationReply } from "./mutation-reply.js";
35
+ export type MoveTasksErrorCode = "NO_TASKS_GIVEN" | "TARGET_PHASE_NOT_FOUND" | "TASK_NOT_FOUND" | "SOURCE_EQUALS_TARGET" | "TARGET_PHASE_TERMINAL";
36
+ /** One moved task, named only by ref/identity — never its description,
37
+ * checklist, statusLog or any other field a caller already has. */
38
+ export interface TaskMoveSummary {
39
+ taskId: string;
40
+ shortId: string;
41
+ title: string;
42
+ status: string;
43
+ oldRef: string;
44
+ newRef: string;
45
+ }
46
+ export interface MoveTasksResult {
47
+ targetPhaseRef: string;
48
+ moves: TaskMoveSummary[];
49
+ /** Refs of source phases that had a pending handoff at the time of the
50
+ * move. A handoff is free prose and may name the moved task by ref; it
51
+ * is NOT rewritten here (see buildTaskMoveReply — the reply just flags
52
+ * it so a caller knows to check). */
53
+ sourcePhaseRefsWithHandoff: string[];
54
+ }
55
+ export type MoveTasksOutcome = {
56
+ ok: true;
57
+ result: MoveTasksResult;
58
+ } | {
59
+ ok: false;
60
+ errorCode: MoveTasksErrorCode;
61
+ error: string;
62
+ };
63
+ /**
64
+ * Move `taskIds` (task UUIDs, already resolved by the caller) into
65
+ * `targetPhaseId` (a phase UUID). Validates target-exists, source != target
66
+ * per task, and refuses a terminal target phase — a terminal phase is
67
+ * closed, and reopening it by dropping new work in is not this operation's
68
+ * job (accepted decision on P108(F005)/T443: no override flag; unlink or
69
+ * reopen the phase first). An in-progress task MAY move; the reply says so.
70
+ */
71
+ export declare function moveTasks(store: PlanStore, taskIds: string[], targetPhaseId: string, timestamp?: string): Promise<MoveTasksOutcome>;
72
+ /**
73
+ * The one reply planner-task-move / task_move return. Deliberately NOT
74
+ * built with buildMutationReply: that helper echoes one entity's changed
75
+ * field values, and the only value that changed here — phaseId — is not
76
+ * something a caller refers to directly. What a caller needs per task is
77
+ * its old ref, its new ref, and enough identity (id/shortId/title/status)
78
+ * to confirm it moved — never the description, checklist or statusLog it
79
+ * already has and did not ask to resend.
80
+ */
81
+ export declare function buildTaskMoveReply(result: MoveTasksResult, readBackCommand: string): MutationReply;
82
+ //# sourceMappingURL=task-move.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task-move.d.ts","sourceRoot":"","sources":["../src/task-move.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAGjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,MAAM,MAAM,kBAAkB,GAC1B,gBAAgB,GAChB,wBAAwB,GACxB,gBAAgB,GAChB,sBAAsB,GACtB,uBAAuB,CAAC;AAM5B;oEACoE;AACpE,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,eAAe;IAC9B,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,eAAe,EAAE,CAAC;I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