ftown 0.26.0 → 0.28.0

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.
Files changed (83) hide show
  1. package/dist/attention-cli.d.ts +32 -0
  2. package/dist/attention-cli.js +310 -0
  3. package/dist/attention-cli.js.map +1 -0
  4. package/dist/attention-events.d.ts +2 -1
  5. package/dist/attention-events.js.map +1 -1
  6. package/dist/attention-store.d.ts +6 -3
  7. package/dist/attention-store.js +60 -2
  8. package/dist/attention-store.js.map +1 -1
  9. package/dist/brief-cli.d.ts +10 -0
  10. package/dist/brief-cli.js +163 -0
  11. package/dist/brief-cli.js.map +1 -0
  12. package/dist/command-rpc.d.ts +11 -0
  13. package/dist/command-rpc.js +83 -16
  14. package/dist/command-rpc.js.map +1 -1
  15. package/dist/coordination/attention-routing.d.ts +37 -0
  16. package/dist/coordination/attention-routing.js +154 -0
  17. package/dist/coordination/attention-routing.js.map +1 -0
  18. package/dist/coordination/board.js +82 -3
  19. package/dist/coordination/board.js.map +1 -1
  20. package/dist/coordination/contract-b.d.ts +206 -0
  21. package/dist/coordination/contract-b.js +58 -0
  22. package/dist/coordination/contract-b.js.map +1 -0
  23. package/dist/coordination/contract-c.d.ts +117 -0
  24. package/dist/coordination/contract-c.js +47 -0
  25. package/dist/coordination/contract-c.js.map +1 -0
  26. package/dist/coordination/contract.d.ts +8 -1
  27. package/dist/coordination/contract.js +1 -1
  28. package/dist/coordination/contract.js.map +1 -1
  29. package/dist/coordination/format.js +51 -12
  30. package/dist/coordination/format.js.map +1 -1
  31. package/dist/coordination/plan.d.ts +74 -0
  32. package/dist/coordination/plan.js +534 -0
  33. package/dist/coordination/plan.js.map +1 -0
  34. package/dist/coordination/routes-brief.d.ts +10 -0
  35. package/dist/coordination/routes-brief.js +149 -0
  36. package/dist/coordination/routes-brief.js.map +1 -0
  37. package/dist/coordination/routes-plan.d.ts +13 -0
  38. package/dist/coordination/routes-plan.js +182 -0
  39. package/dist/coordination/routes-plan.js.map +1 -0
  40. package/dist/coordination/routes-worktrees.d.ts +29 -0
  41. package/dist/coordination/routes-worktrees.js +138 -0
  42. package/dist/coordination/routes-worktrees.js.map +1 -0
  43. package/dist/coordination/wiring.d.ts +17 -2
  44. package/dist/coordination/wiring.js +81 -11
  45. package/dist/coordination/wiring.js.map +1 -1
  46. package/dist/coordination-cli.d.ts +6 -1
  47. package/dist/coordination-cli.js +23 -7
  48. package/dist/coordination-cli.js.map +1 -1
  49. package/dist/create-ftown-session.d.ts +26 -1
  50. package/dist/create-ftown-session.js +208 -104
  51. package/dist/create-ftown-session.js.map +1 -1
  52. package/dist/ftown-cli.js +14 -2
  53. package/dist/ftown-cli.js.map +1 -1
  54. package/dist/index.js +29 -0
  55. package/dist/index.js.map +1 -1
  56. package/dist/local-api-server.d.ts +24 -0
  57. package/dist/local-api-server.js +473 -32
  58. package/dist/local-api-server.js.map +1 -1
  59. package/dist/mail-delivery.d.ts +18 -4
  60. package/dist/mail-delivery.js +50 -8
  61. package/dist/mail-delivery.js.map +1 -1
  62. package/dist/plan-cli.d.ts +52 -0
  63. package/dist/plan-cli.js +357 -0
  64. package/dist/plan-cli.js.map +1 -0
  65. package/dist/security/bridge/permissions.js +55 -5
  66. package/dist/security/bridge/permissions.js.map +1 -1
  67. package/dist/session-controller.d.ts +17 -1
  68. package/dist/session-controller.js +93 -2
  69. package/dist/session-controller.js.map +1 -1
  70. package/dist/sessions-commands.js +75 -5
  71. package/dist/sessions-commands.js.map +1 -1
  72. package/dist/types.d.ts +9 -1
  73. package/dist/worktrees-cli.d.ts +39 -0
  74. package/dist/worktrees-cli.js +168 -0
  75. package/dist/worktrees-cli.js.map +1 -0
  76. package/dist/worktrees.d.ts +16 -0
  77. package/dist/worktrees.js +292 -0
  78. package/dist/worktrees.js.map +1 -0
  79. package/hooks/ftown-antigravity-hook.sh +12 -6
  80. package/package.json +2 -2
  81. package/skills/ftown/SKILL.md +88 -5
  82. package/skills/ftown/references/orchestrator.md +32 -29
  83. package/skills/ftown/references/sessions.md +155 -12
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Plan list: precedence ordering, pure edits, and the session-backed store.
3
+ * Ordering follows PLAN_ORDER_RULE. Ids are `p<seq>` allocated from SessionPlan.seq
4
+ * and then incremented, so a removed id is never reused. A plan that does not exist
5
+ * yet starts at seq 1 (first item `p1`).
6
+ */
7
+ import type { Session } from '../types.js';
8
+ import { type PlanItem, type PlanPriority, type PlanState, type PlanView, type SessionPlan } from './contract-c.js';
9
+ export interface PlanAddInput {
10
+ title: string;
11
+ note?: string;
12
+ after?: string[];
13
+ priority?: PlanPriority;
14
+ }
15
+ export interface PlanPatchInput {
16
+ title?: string;
17
+ note?: string | null;
18
+ after?: string[];
19
+ priority?: PlanPriority;
20
+ state?: PlanState;
21
+ sessionId?: string | null;
22
+ }
23
+ export interface PlanStoreDeps {
24
+ loadSession(id: string): Promise<Session | null>;
25
+ saveSession(session: Session): Promise<void>;
26
+ publishSession(session: Session): void | Promise<void>;
27
+ emit(parent: Session, summary: string): Promise<void>;
28
+ now(): number;
29
+ }
30
+ /**
31
+ * Ready, then waiting, then started, then done, then dropped.
32
+ * Ready and waiting: priority ascending, then createdAt ascending.
33
+ * Started: updatedAt ascending. Done and dropped: updatedAt descending.
34
+ * Id number breaks remaining ties.
35
+ */
36
+ export declare function orderPlan(items: readonly PlanItem[]): PlanView;
37
+ /** Ids of todo items whose every `after` dependency is done or dropped, in plan order. */
38
+ export declare function readyIds(items: readonly PlanItem[]): string[];
39
+ /** Ids that are ready in `after` and were not ready in `before`, in the new ready order. */
40
+ export declare function newlyReady(before: readonly PlanItem[], after: readonly PlanItem[]): string[];
41
+ export declare function applyAdd(plan: SessionPlan | null | undefined, input: unknown, now: string): SessionPlan;
42
+ /** Validates a patch and returns the updated plan. `applyPatch` delegates here. */
43
+ export declare function validatePatch(plan: SessionPlan | null | undefined, input: unknown, now: string): SessionPlan;
44
+ export declare function applyPatch(plan: SessionPlan | null | undefined, input: unknown, now: string): SessionPlan;
45
+ export declare function applyRemove(plan: SessionPlan | null | undefined, input: unknown, now: string): SessionPlan;
46
+ /**
47
+ * Reloads the parent before every save. Each successful change publishes the saved
48
+ * session, then emits one `plan` summary — `<id> <state>: <title>`, plus
49
+ * ` → ready: <id>, <id>` when items became ready. An emit failure is warned and
50
+ * does not undo the publish.
51
+ */
52
+ export declare class PlanStore {
53
+ private readonly deps;
54
+ constructor(deps: PlanStoreDeps);
55
+ get(parentId: string): Promise<SessionPlan | null>;
56
+ add(parentId: string, input: PlanAddInput): Promise<PlanItem>;
57
+ patch(parentId: string, itemId: string, input: PlanPatchInput): Promise<PlanItem>;
58
+ remove(parentId: string, itemId: string): Promise<void>;
59
+ /** Binds a todo item to a child: state `started`, sessionId = childId. */
60
+ startForChild(parentId: string, itemId: string, childId: string): Promise<void>;
61
+ /**
62
+ * Marks every item with this child and state `started` as `done`.
63
+ * No match, or a missing parent, is a no-op: a failed card stays `started` for the manager.
64
+ */
65
+ completeForChild(parentId: string, childId: string): Promise<void>;
66
+ /**
67
+ * Returns every item with this child and state `started` to `todo` and clears sessionId.
68
+ * No match, or a missing parent, is a no-op. One event: `<id> todo: <title> (session removed)`.
69
+ */
70
+ releaseForChild(parentId: string, childId: string): Promise<void>;
71
+ private stamp;
72
+ private change;
73
+ private persist;
74
+ }
@@ -0,0 +1,534 @@
1
+ import { PLAN_LIMITS, PLAN_STATES, PlanValidationError, } from './contract-c.js';
2
+ const ITEM_ID_RE = /^p(\d{1,6})$/;
3
+ const SESSION_ID_RE = /^[A-Za-z0-9_-]{1,200}$/;
4
+ const ADD_KEYS = new Set(['title', 'note', 'after', 'priority']);
5
+ const PATCH_KEYS = new Set(['id', 'title', 'note', 'after', 'priority', 'state', 'sessionId']);
6
+ function hasOwn(record, key) {
7
+ return Object.prototype.hasOwnProperty.call(record, key);
8
+ }
9
+ function emptyPlan() {
10
+ return { items: [], seq: 1 };
11
+ }
12
+ function requireNow(now) {
13
+ if (typeof now !== 'string' || now.trim() === '' || Number.isNaN(Date.parse(now))) {
14
+ throw new PlanValidationError('now must be an ISO timestamp');
15
+ }
16
+ return now;
17
+ }
18
+ function asRecord(input, label) {
19
+ if (typeof input !== 'object' || input === null || Array.isArray(input)) {
20
+ throw new PlanValidationError(`${label} must be an object`);
21
+ }
22
+ return input;
23
+ }
24
+ function asPlan(plan) {
25
+ if (plan == null)
26
+ return emptyPlan();
27
+ if (typeof plan !== 'object' || !Array.isArray(plan.items) || !Number.isInteger(plan.seq)) {
28
+ throw new PlanValidationError('plan is invalid');
29
+ }
30
+ return plan;
31
+ }
32
+ /** Control characters become spaces, then whitespace runs collapse. Length is in code points. */
33
+ function cleanText(value, field, minLength, maxLength) {
34
+ if (typeof value !== 'string')
35
+ throw new PlanValidationError(`${field} must be a string`);
36
+ const withoutControls = [...value].map((char) => {
37
+ const code = char.codePointAt(0) ?? 0;
38
+ return code <= 31 || code === 127 ? ' ' : char;
39
+ }).join('');
40
+ const cleaned = withoutControls.replace(/\s+/g, ' ').trim();
41
+ const cleanedLength = [...cleaned].length;
42
+ if (cleanedLength < minLength)
43
+ throw new PlanValidationError(`${field} must not be empty`);
44
+ if (cleanedLength > maxLength)
45
+ throw new PlanValidationError(`${field} must be at most ${maxLength} characters`);
46
+ return cleaned;
47
+ }
48
+ function cloneItem(item) {
49
+ const copy = {
50
+ id: item.id,
51
+ title: item.title,
52
+ after: [...item.after],
53
+ priority: item.priority,
54
+ state: item.state,
55
+ createdAt: item.createdAt,
56
+ updatedAt: item.updatedAt,
57
+ };
58
+ if (item.note !== undefined)
59
+ copy.note = item.note;
60
+ if (item.sessionId !== undefined)
61
+ copy.sessionId = item.sessionId;
62
+ return copy;
63
+ }
64
+ function compareText(left, right) {
65
+ if (left < right)
66
+ return -1;
67
+ if (left > right)
68
+ return 1;
69
+ return 0;
70
+ }
71
+ function compareId(left, right) {
72
+ const leftMatch = ITEM_ID_RE.exec(left);
73
+ const rightMatch = ITEM_ID_RE.exec(right);
74
+ if (leftMatch && rightMatch) {
75
+ const delta = Number(leftMatch[1]) - Number(rightMatch[1]);
76
+ if (delta !== 0)
77
+ return delta;
78
+ }
79
+ return compareText(left, right);
80
+ }
81
+ function comparePrecedence(left, right) {
82
+ return left.priority - right.priority || compareText(left.createdAt, right.createdAt) || compareId(left.id, right.id);
83
+ }
84
+ function compareUpdatedAsc(left, right) {
85
+ return compareText(left.updatedAt, right.updatedAt) || compareId(left.id, right.id);
86
+ }
87
+ function compareUpdatedDesc(left, right) {
88
+ return compareText(right.updatedAt, left.updatedAt) || compareId(left.id, right.id);
89
+ }
90
+ function isSatisfied(item) {
91
+ return item?.state === 'done' || item?.state === 'dropped';
92
+ }
93
+ function isReady(item, byId) {
94
+ for (const id of item.after) {
95
+ if (!isSatisfied(byId.get(id)))
96
+ return false;
97
+ }
98
+ return true;
99
+ }
100
+ function partition(items) {
101
+ const byId = new Map(items.map((item) => [item.id, item]));
102
+ const groups = {
103
+ ready: [],
104
+ waiting: [],
105
+ started: [],
106
+ done: [],
107
+ dropped: [],
108
+ };
109
+ for (const item of items) {
110
+ if (item.state === 'todo')
111
+ groups[isReady(item, byId) ? 'ready' : 'waiting'].push(item);
112
+ else
113
+ groups[item.state].push(item);
114
+ }
115
+ groups.ready.sort(comparePrecedence);
116
+ groups.waiting.sort(comparePrecedence);
117
+ groups.started.sort(compareUpdatedAsc);
118
+ groups.done.sort(compareUpdatedDesc);
119
+ groups.dropped.sort(compareUpdatedDesc);
120
+ return groups;
121
+ }
122
+ /**
123
+ * Ready, then waiting, then started, then done, then dropped.
124
+ * Ready and waiting: priority ascending, then createdAt ascending.
125
+ * Started: updatedAt ascending. Done and dropped: updatedAt descending.
126
+ * Id number breaks remaining ties.
127
+ */
128
+ export function orderPlan(items) {
129
+ const groups = partition(items);
130
+ return {
131
+ items: [...groups.ready, ...groups.waiting, ...groups.started, ...groups.done, ...groups.dropped],
132
+ ready: groups.ready.map((item) => item.id),
133
+ };
134
+ }
135
+ /** Ids of todo items whose every `after` dependency is done or dropped, in plan order. */
136
+ export function readyIds(items) {
137
+ return orderPlan(items).ready;
138
+ }
139
+ /** Ids that are ready in `after` and were not ready in `before`, in the new ready order. */
140
+ export function newlyReady(before, after) {
141
+ const previous = new Set(readyIds(before));
142
+ return readyIds(after).filter((id) => !previous.has(id));
143
+ }
144
+ function withReady(base, before, after) {
145
+ const ready = newlyReady(before, after);
146
+ if (ready.length === 0)
147
+ return base;
148
+ return `${base} → ready: ${ready.join(', ')}`;
149
+ }
150
+ function eventSummary(item, before, after) {
151
+ return withReady(`${item.id} ${item.state}: ${item.title}`, before, after);
152
+ }
153
+ function rejectUnknown(record, allowed) {
154
+ const keys = Object.keys(record).filter((key) => record[key] !== undefined);
155
+ for (const key of keys) {
156
+ if (!allowed.has(key))
157
+ throw new PlanValidationError(`Unknown plan field: ${key}`);
158
+ }
159
+ return keys;
160
+ }
161
+ function parsePriority(value) {
162
+ if (value !== 1 && value !== 2 && value !== 3)
163
+ throw new PlanValidationError('priority must be 1, 2 or 3');
164
+ return value;
165
+ }
166
+ function parseState(value) {
167
+ if (typeof value !== 'string' || !PLAN_STATES.includes(value)) {
168
+ throw new PlanValidationError(`state must be one of: ${PLAN_STATES.join(', ')}`);
169
+ }
170
+ return value;
171
+ }
172
+ function parseSessionId(value) {
173
+ if (value === null)
174
+ return null;
175
+ if (typeof value !== 'string')
176
+ throw new PlanValidationError('sessionId must be a string');
177
+ if (!SESSION_ID_RE.test(value))
178
+ throw new PlanValidationError('sessionId is invalid');
179
+ return value;
180
+ }
181
+ function parseItemId(value) {
182
+ if (typeof value !== 'string' || !ITEM_ID_RE.test(value))
183
+ throw new PlanValidationError('plan item id is invalid');
184
+ return value;
185
+ }
186
+ /**
187
+ * `selfId`, when set, is the item being edited (or the id about to be allocated).
188
+ * Existence is checked against `items`, which does not include an item still being added.
189
+ */
190
+ function parseAfter(value, items, selfId) {
191
+ if (!Array.isArray(value) || value.some((id) => typeof id !== 'string')) {
192
+ throw new PlanValidationError('after must be an array of item ids');
193
+ }
194
+ const ids = value;
195
+ if (ids.length > PLAN_LIMITS.after) {
196
+ throw new PlanValidationError(`after must list at most ${PLAN_LIMITS.after} items`);
197
+ }
198
+ const known = new Set(items.map((item) => item.id));
199
+ const seen = new Set();
200
+ for (const id of ids) {
201
+ if (!ITEM_ID_RE.test(id))
202
+ throw new PlanValidationError(`after id ${id} is invalid`);
203
+ if (seen.has(id))
204
+ throw new PlanValidationError(`duplicate after id ${id}`);
205
+ seen.add(id);
206
+ if (selfId !== null && id === selfId)
207
+ throw new PlanValidationError('plan item cannot depend on itself');
208
+ if (!known.has(id))
209
+ throw new PlanValidationError(`after id ${id} does not exist`);
210
+ }
211
+ return [...ids];
212
+ }
213
+ /** Depth-first search from the edited item. A back-edge to a visiting node is a cycle. */
214
+ function assertNoCycle(items, startId) {
215
+ const edges = new Map(items.map((item) => [item.id, item.after]));
216
+ const color = new Map();
217
+ const stack = [startId];
218
+ const nextIndex = [0];
219
+ color.set(startId, 1);
220
+ while (stack.length > 0) {
221
+ const depth = stack.length - 1;
222
+ const id = stack[depth];
223
+ const after = id === undefined ? [] : edges.get(id) ?? [];
224
+ const index = nextIndex[depth] ?? 0;
225
+ if (id === undefined || index >= after.length) {
226
+ if (id !== undefined)
227
+ color.set(id, 2);
228
+ stack.pop();
229
+ nextIndex.pop();
230
+ continue;
231
+ }
232
+ nextIndex[depth] = index + 1;
233
+ const next = after[index];
234
+ if (next === undefined)
235
+ continue;
236
+ const mark = color.get(next);
237
+ if (mark === 1)
238
+ throw new PlanValidationError('plan after contains a cycle');
239
+ if (mark === 2 || !edges.has(next))
240
+ continue;
241
+ color.set(next, 1);
242
+ stack.push(next);
243
+ nextIndex.push(0);
244
+ }
245
+ }
246
+ function buildItem(fields) {
247
+ const item = {
248
+ id: fields.id,
249
+ title: fields.title,
250
+ after: fields.after,
251
+ priority: fields.priority,
252
+ state: fields.state,
253
+ createdAt: fields.createdAt,
254
+ updatedAt: fields.updatedAt,
255
+ };
256
+ if (fields.note !== undefined)
257
+ item.note = fields.note;
258
+ if (fields.sessionId !== undefined)
259
+ item.sessionId = fields.sessionId;
260
+ return item;
261
+ }
262
+ export function applyAdd(plan, input, now) {
263
+ const stamp = requireNow(now);
264
+ const current = asPlan(plan);
265
+ const record = asRecord(input, 'plan add');
266
+ const keys = rejectUnknown(record, ADD_KEYS);
267
+ if (!keys.includes('title'))
268
+ throw new PlanValidationError('title is required');
269
+ if (current.items.length >= PLAN_LIMITS.items) {
270
+ throw new PlanValidationError(`plan is limited to ${PLAN_LIMITS.items} items`);
271
+ }
272
+ const id = `p${current.seq}`;
273
+ if (!ITEM_ID_RE.test(id))
274
+ throw new PlanValidationError('plan sequence is exhausted');
275
+ if (current.items.some((item) => item.id === id))
276
+ throw new PlanValidationError(`plan id ${id} already exists`);
277
+ const title = cleanText(record.title, 'title', 1, PLAN_LIMITS.title);
278
+ // A note that cleans to nothing is omitted. Patch still rejects an empty note; null clears there.
279
+ let note;
280
+ if (keys.includes('note')) {
281
+ const cleaned = cleanText(record.note, 'note', 0, PLAN_LIMITS.note);
282
+ if (cleaned !== '')
283
+ note = cleaned;
284
+ }
285
+ const after = keys.includes('after') ? parseAfter(record.after, current.items, id) : [];
286
+ const priority = keys.includes('priority') ? parsePriority(record.priority) : 2;
287
+ const created = buildItem({
288
+ id,
289
+ title,
290
+ after,
291
+ priority,
292
+ state: 'todo',
293
+ ...(note !== undefined ? { note } : {}),
294
+ createdAt: stamp,
295
+ updatedAt: stamp,
296
+ });
297
+ const items = [...current.items.map(cloneItem), created];
298
+ assertNoCycle(items, id);
299
+ return { seq: current.seq + 1, items };
300
+ }
301
+ function parsePatch(input) {
302
+ const record = asRecord(input, 'plan update');
303
+ const keys = rejectUnknown(record, PATCH_KEYS);
304
+ if (!keys.includes('id'))
305
+ throw new PlanValidationError('plan item id is invalid');
306
+ const parsed = {
307
+ id: parseItemId(record.id),
308
+ hasTitle: keys.includes('title'),
309
+ hasNote: keys.includes('note'),
310
+ hasAfter: keys.includes('after'),
311
+ hasPriority: keys.includes('priority'),
312
+ hasState: keys.includes('state'),
313
+ hasSessionId: keys.includes('sessionId'),
314
+ };
315
+ if (!parsed.hasTitle && !parsed.hasNote && !parsed.hasAfter && !parsed.hasPriority && !parsed.hasState && !parsed.hasSessionId) {
316
+ throw new PlanValidationError('Empty plan update');
317
+ }
318
+ if (parsed.hasTitle)
319
+ parsed.title = cleanText(record.title, 'title', 1, PLAN_LIMITS.title);
320
+ if (parsed.hasNote) {
321
+ parsed.note = record.note === null ? null : cleanText(record.note, 'note', 1, PLAN_LIMITS.note);
322
+ }
323
+ if (parsed.hasPriority)
324
+ parsed.priority = parsePriority(record.priority);
325
+ // Any state may follow any other state. There is no transition table.
326
+ if (parsed.hasState)
327
+ parsed.state = parseState(record.state);
328
+ if (parsed.hasSessionId)
329
+ parsed.sessionId = parseSessionId(record.sessionId);
330
+ return parsed;
331
+ }
332
+ /** Validates a patch and returns the updated plan. `applyPatch` delegates here. */
333
+ export function validatePatch(plan, input, now) {
334
+ const stamp = requireNow(now);
335
+ const current = asPlan(plan);
336
+ const parsed = parsePatch(input);
337
+ // `after` existence uses the pre-edit items. Parse before replacing the target.
338
+ const existing = current.items.find((item) => item.id === parsed.id);
339
+ if (!existing)
340
+ throw new PlanValidationError(`Plan item ${parsed.id} does not exist`);
341
+ if (parsed.hasAfter)
342
+ parsed.after = parseAfter(recordAfter(input), current.items, parsed.id);
343
+ const title = parsed.hasTitle ? parsed.title ?? existing.title : existing.title;
344
+ let note = existing.note;
345
+ if (parsed.hasNote)
346
+ note = parsed.note === null ? undefined : parsed.note;
347
+ const after = parsed.hasAfter ? parsed.after ?? [] : [...existing.after];
348
+ const priority = parsed.hasPriority ? parsed.priority ?? existing.priority : existing.priority;
349
+ const state = parsed.hasState ? parsed.state ?? existing.state : existing.state;
350
+ let sessionId = existing.sessionId;
351
+ if (parsed.hasSessionId)
352
+ sessionId = parsed.sessionId === null ? undefined : parsed.sessionId;
353
+ // Setting state to todo drops the child link. An explicit sessionId in the same patch does not keep it.
354
+ if (parsed.hasState && parsed.state === 'todo')
355
+ sessionId = undefined;
356
+ const updated = buildItem({
357
+ id: existing.id,
358
+ title,
359
+ after,
360
+ priority,
361
+ state,
362
+ ...(note !== undefined ? { note } : {}),
363
+ ...(sessionId !== undefined ? { sessionId } : {}),
364
+ createdAt: existing.createdAt,
365
+ updatedAt: stamp,
366
+ });
367
+ const items = current.items.map((item) => (item.id === existing.id ? updated : cloneItem(item)));
368
+ if (parsed.hasAfter)
369
+ assertNoCycle(items, existing.id);
370
+ return { seq: current.seq, items };
371
+ }
372
+ function recordAfter(input) {
373
+ const record = asRecord(input, 'plan update');
374
+ return record.after;
375
+ }
376
+ export function applyPatch(plan, input, now) {
377
+ return validatePatch(plan, input, now);
378
+ }
379
+ export function applyRemove(plan, input, now) {
380
+ requireNow(now);
381
+ const current = asPlan(plan);
382
+ const id = typeof input === 'string' || input == null || typeof input !== 'object'
383
+ ? parseItemId(input)
384
+ : parseItemId(asRecord(input, 'plan remove').id);
385
+ if (!current.items.some((item) => item.id === id))
386
+ throw new PlanValidationError(`Plan item ${id} does not exist`);
387
+ // Survivors keep their timestamps. Only the dependency edge is removed, so a pure
388
+ // unlink does not reshuffle started/done/dropped order.
389
+ const items = current.items
390
+ .filter((item) => item.id !== id)
391
+ .map((item) => cloneItem({ ...item, after: item.after.filter((afterId) => afterId !== id) }));
392
+ return { seq: current.seq, items };
393
+ }
394
+ /**
395
+ * Reloads the parent before every save. Each successful change publishes the saved
396
+ * session, then emits one `plan` summary — `<id> <state>: <title>`, plus
397
+ * ` → ready: <id>, <id>` when items became ready. An emit failure is warned and
398
+ * does not undo the publish.
399
+ */
400
+ export class PlanStore {
401
+ deps;
402
+ constructor(deps) {
403
+ this.deps = deps;
404
+ }
405
+ async get(parentId) {
406
+ const session = await this.deps.loadSession(parentId);
407
+ if (!session?.plan || !Array.isArray(session.plan.items))
408
+ return null;
409
+ return { seq: session.plan.seq, items: session.plan.items.map(cloneItem) };
410
+ }
411
+ async add(parentId, input) {
412
+ const change = await this.change(parentId, (plan) => {
413
+ const next = applyAdd(plan, input, this.stamp());
414
+ const created = next.items.find((item) => !plan.items.some((existing) => existing.id === item.id));
415
+ if (!created)
416
+ throw new PlanValidationError('plan item was not created');
417
+ return { plan: next, summary: eventSummary(created, plan.items, next.items), item: created };
418
+ });
419
+ if (!change.item)
420
+ throw new PlanValidationError('plan item was not created');
421
+ return change.item;
422
+ }
423
+ async patch(parentId, itemId, input) {
424
+ const change = await this.change(parentId, (plan) => {
425
+ const next = validatePatch(plan, { ...input, id: itemId }, this.stamp());
426
+ const updated = next.items.find((item) => item.id === itemId);
427
+ if (!updated)
428
+ throw new PlanValidationError(`Plan item ${itemId} does not exist`);
429
+ return { plan: next, summary: eventSummary(updated, plan.items, next.items), item: updated };
430
+ });
431
+ if (!change.item)
432
+ throw new PlanValidationError(`Plan item ${itemId} does not exist`);
433
+ return change.item;
434
+ }
435
+ async remove(parentId, itemId) {
436
+ await this.change(parentId, (plan) => {
437
+ const existing = plan.items.find((item) => item.id === itemId);
438
+ if (!existing)
439
+ throw new PlanValidationError(`Plan item ${itemId} does not exist`);
440
+ const next = applyRemove(plan, itemId, this.stamp());
441
+ return { plan: next, summary: withReady(`${existing.id} removed: ${existing.title}`, plan.items, next.items) };
442
+ });
443
+ }
444
+ /** Binds a todo item to a child: state `started`, sessionId = childId. */
445
+ async startForChild(parentId, itemId, childId) {
446
+ await this.change(parentId, (plan) => {
447
+ const current = plan.items.find((item) => item.id === itemId);
448
+ if (!current)
449
+ throw new PlanValidationError(`Plan item ${itemId} does not exist`);
450
+ if (current.state !== 'todo')
451
+ throw new PlanValidationError(`Plan item ${itemId} is ${current.state}, not todo`);
452
+ const next = applyPatch(plan, { id: itemId, state: 'started', sessionId: childId }, this.stamp());
453
+ const updated = next.items.find((item) => item.id === itemId);
454
+ if (!updated)
455
+ throw new PlanValidationError(`Plan item ${itemId} does not exist`);
456
+ return { plan: next, summary: eventSummary(updated, plan.items, next.items), item: updated };
457
+ });
458
+ }
459
+ /**
460
+ * Marks every item with this child and state `started` as `done`.
461
+ * No match, or a missing parent, is a no-op: a failed card stays `started` for the manager.
462
+ */
463
+ async completeForChild(parentId, childId) {
464
+ const seen = await this.deps.loadSession(parentId);
465
+ if (!seen)
466
+ return;
467
+ const fresh = await this.deps.loadSession(parentId);
468
+ if (!fresh?.plan)
469
+ return;
470
+ const matches = fresh.plan.items.filter((item) => item.sessionId === childId && item.state === 'started');
471
+ if (matches.length === 0)
472
+ return;
473
+ const stamp = this.stamp();
474
+ let next = fresh.plan;
475
+ for (const match of matches) {
476
+ next = applyPatch(next, { id: match.id, state: 'done' }, stamp);
477
+ }
478
+ const primary = next.items.find((item) => item.id === matches[0]?.id);
479
+ if (!primary)
480
+ return;
481
+ await this.persist(fresh, { plan: next, summary: eventSummary(primary, fresh.plan.items, next.items), item: primary });
482
+ }
483
+ /**
484
+ * Returns every item with this child and state `started` to `todo` and clears sessionId.
485
+ * No match, or a missing parent, is a no-op. One event: `<id> todo: <title> (session removed)`.
486
+ */
487
+ async releaseForChild(parentId, childId) {
488
+ const seen = await this.deps.loadSession(parentId);
489
+ if (!seen)
490
+ return;
491
+ const fresh = await this.deps.loadSession(parentId);
492
+ if (!fresh?.plan)
493
+ return;
494
+ const matches = fresh.plan.items.filter((item) => item.sessionId === childId && item.state === 'started');
495
+ if (matches.length === 0)
496
+ return;
497
+ const stamp = this.stamp();
498
+ let next = fresh.plan;
499
+ for (const match of matches) {
500
+ next = applyPatch(next, { id: match.id, state: 'todo' }, stamp);
501
+ }
502
+ const primary = next.items.find((item) => item.id === matches[0]?.id);
503
+ if (!primary)
504
+ return;
505
+ const summary = withReady(`${primary.id} todo: ${primary.title} (session removed)`, fresh.plan.items, next.items);
506
+ await this.persist(fresh, { plan: next, summary, item: primary });
507
+ }
508
+ stamp() {
509
+ return new Date(this.deps.now()).toISOString();
510
+ }
511
+ async change(parentId, mutate) {
512
+ const seen = await this.deps.loadSession(parentId);
513
+ if (!seen)
514
+ throw new Error('Session not found');
515
+ const fresh = await this.deps.loadSession(parentId);
516
+ if (!fresh)
517
+ throw new Error('Session not found');
518
+ const result = mutate(fresh.plan ?? emptyPlan());
519
+ await this.persist(fresh, result);
520
+ return result;
521
+ }
522
+ async persist(fresh, result) {
523
+ const saved = { ...fresh, plan: result.plan };
524
+ await this.deps.saveSession(saved);
525
+ await this.deps.publishSession(saved);
526
+ try {
527
+ await this.deps.emit(saved, result.summary);
528
+ }
529
+ catch (error) {
530
+ console.warn('PlanStore emit failed', error);
531
+ }
532
+ }
533
+ }
534
+ //# sourceMappingURL=plan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan.js","sourceRoot":"","sources":["../../src/coordination/plan.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,WAAW,EACX,WAAW,EACX,mBAAmB,GAMpB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,UAAU,GAAG,cAAc,CAAC;AAClC,MAAM,aAAa,GAAG,wBAAwB,CAAC;AAC/C,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC;AACjE,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC;AAgD/F,SAAS,MAAM,CAAC,MAA+B,EAAE,GAAW;IAC1D,OAAO,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAC3D,CAAC;AAED,SAAS,SAAS;IAChB,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;AAC/B,CAAC;AAED,SAAS,UAAU,CAAC,GAAW;IAC7B,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI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AAI,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QACnD,IAAI,CAAC,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;QAChD,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QACpD,IAAI,CAAC,KAAK;YAAE,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;QACjD,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,IAAI,SAAS,EAAE,CAAC,CAAC;QACjD,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAClC,OAAO,MAAM,CAAC;IAChB,CAAC;IAEO,KAAK,CAAC,OAAO,CAAC,KAAc,EAAE,MAAc;QAClD,MAAM,KAAK,GAAY,EAAE,GAAG,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;QACvD,MAAM,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QACnC,MAAM,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;QACtC,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;QAC9C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,IAAI,CAAC,uBAAuB,EAAE,KAAK,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,10 @@
1
+ import { type RouteContext } from './contract-b.js';
2
+ /**
3
+ * Route module for BRIEF_ROUTES:
4
+ * GET /api/sessions/:id/brief → { brief: SessionBrief | null }
5
+ * PUT /api/sessions/:id/brief → { brief } (body { text: string | null })
6
+ * DELETE /api/sessions/:id/brief → { ok: true }
7
+ * POST /api/sessions/:id/brief/notes → { brief } (body { text: string })
8
+ * Returns false when the path does not match. Throws RouteError for HTTP errors.
9
+ */
10
+ export declare function handleBriefRoutes(ctx: RouteContext): Promise<boolean>;