@astrosheep/keiyaku 4.5.5 → 4.5.7

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 (41) hide show
  1. package/build/integrations/marketplace/plugins/keiyaku/opencode.js +1 -1
  2. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku/SKILL.md +1 -0
  3. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-babysit/SKILL.md +114 -0
  4. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-task/SKILL.md +15 -19
  5. package/build/src/akuma/body.d.ts +1 -1
  6. package/build/src/akuma/body.js +20 -33
  7. package/build/src/akuma/heart/index.d.ts +2 -2
  8. package/build/src/akuma/heart/index.js +2 -2
  9. package/build/src/akuma/heart/request-authority.d.ts +1 -0
  10. package/build/src/akuma/heart/request-authority.js +11 -1
  11. package/build/src/akuma/heart/storage.d.ts +0 -1
  12. package/build/src/akuma/heart/storage.js +0 -54
  13. package/build/src/akuma/publication.js +75 -13
  14. package/build/src/akuma/request-lifecycle.js +9 -22
  15. package/build/src/akuma/request-serve.js +17 -2
  16. package/build/src/cli/commands/task-invoke.d.ts +6 -2
  17. package/build/src/cli/commands/task-invoke.js +56 -24
  18. package/build/src/cli/commands/task.d.ts +1 -1
  19. package/build/src/cli/commands/task.js +28 -6
  20. package/build/src/cli/coordinates.d.ts +2 -0
  21. package/build/src/cli/coordinates.js +18 -2
  22. package/build/src/cli/invoke.js +1 -0
  23. package/build/src/cli/render/task.js +31 -6
  24. package/build/src/cli/square-edge.js +2 -2
  25. package/build/src/git/repository.d.ts +2 -0
  26. package/build/src/git/repository.js +34 -21
  27. package/build/src/git/target-placement.js +0 -6
  28. package/build/src/protocol/attempt.js +9 -4
  29. package/build/src/runtime/proc/windows-launch.exe +0 -0
  30. package/build/src/task/compose-language.d.ts +47 -0
  31. package/build/src/task/compose-language.js +328 -0
  32. package/build/src/task/compose-parser.d.ts +32 -0
  33. package/build/src/task/compose-parser.js +180 -0
  34. package/build/src/task/compose.d.ts +29 -9
  35. package/build/src/task/compose.js +126 -287
  36. package/build/src/task/context.d.ts +7 -1
  37. package/build/src/task/context.js +25 -6
  38. package/build/src/task/index.d.ts +10 -4
  39. package/build/src/task/index.js +14 -3
  40. package/build/src/task/operations.d.ts +6 -1
  41. package/package.json +2 -2
@@ -0,0 +1,328 @@
1
+ import { serializeTaskDocument } from "./document.js";
2
+ import { allocateLocalId, deriveLocalStem, formatTaskId, parseTaskId, sameNamespace } from "./identity.js";
3
+ import { parseTaskComposition } from "./compose-parser.js";
4
+ import { advanceTaskTimestamp } from "./operations.js";
5
+ export function taskCompositionNamespaceHeader(markdown) {
6
+ const parsed = parseTaskComposition(markdown);
7
+ return {
8
+ specified: parsed.namespaceSpecified,
9
+ ...(parsed.namespace === undefined ? {} : { namespace: parsed.namespace }),
10
+ };
11
+ }
12
+ function diagnostic(line, reason, token) {
13
+ return { line, reason, token };
14
+ }
15
+ function occupied(board, namespace) {
16
+ return new Set([...board.tasks.values()].flatMap((task) => {
17
+ const coordinate = parseTaskId(task.id);
18
+ return sameNamespace(coordinate.namespace, namespace) ? [coordinate.localId] : [];
19
+ }));
20
+ }
21
+ function createdTask(id, title, at, actor) {
22
+ return {
23
+ id,
24
+ title,
25
+ state: "open",
26
+ priority: 2,
27
+ needs: [],
28
+ parent: null,
29
+ supersedes: [],
30
+ relates: [],
31
+ note: "",
32
+ ...(actor === undefined ? {} : { createdBy: actor }),
33
+ createdAt: at,
34
+ updatedAt: at,
35
+ body: "",
36
+ };
37
+ }
38
+ function aliasFor(node) {
39
+ return node.assignments.find((item) => item.field === "as");
40
+ }
41
+ function allocateNodes(input, diagnostics) {
42
+ const ids = occupied(input.board, input.namespace);
43
+ const allocations = new Map();
44
+ for (const node of input.parsed.nodes) {
45
+ if (node.kind !== "new")
46
+ continue;
47
+ try {
48
+ const localId = allocateLocalId(deriveLocalStem(node.title), ids);
49
+ ids.add(localId);
50
+ const id = formatTaskId({ namespace: input.namespace, localId });
51
+ allocations.set(node.index, createdTask(id, node.title, input.at, input.actor));
52
+ }
53
+ catch (error) {
54
+ diagnostics.push(diagnostic(node.line, error instanceof Error ? error.message : String(error), node.title));
55
+ }
56
+ }
57
+ return allocations;
58
+ }
59
+ function collectAliases(nodes, allocations, diagnostics) {
60
+ const aliases = new Map();
61
+ for (const node of nodes) {
62
+ const declarations = node.assignments.filter((item) => item.field === "as");
63
+ for (const duplicate of declarations.slice(1)) {
64
+ diagnostics.push(diagnostic(duplicate.line, "alias is assigned more than once", duplicate.token));
65
+ }
66
+ const declaration = declarations[0];
67
+ if (declaration === undefined)
68
+ continue;
69
+ if (node.kind !== "new") {
70
+ diagnostics.push(diagnostic(declaration.line, "only a new task may declare an alias", declaration.token));
71
+ continue;
72
+ }
73
+ if (declaration.operator !== "=" || !/^[a-z0-9-]+$/u.test(declaration.value)) {
74
+ diagnostics.push(diagnostic(declaration.line, "alias must use as = [a-z0-9-]+", declaration.token));
75
+ continue;
76
+ }
77
+ if (aliases.has(declaration.value)) {
78
+ diagnostics.push(diagnostic(declaration.line, "alias must be unique in the composition", declaration.value));
79
+ continue;
80
+ }
81
+ const allocated = allocations.get(node.index);
82
+ if (allocated !== undefined)
83
+ aliases.set(declaration.value, allocated.id);
84
+ }
85
+ return aliases;
86
+ }
87
+ function resolveReference(raw, line, board, aliases, diagnostics) {
88
+ if (raw.startsWith("^")) {
89
+ const alias = raw.slice(1);
90
+ const resolved = aliases.get(alias);
91
+ if (resolved === undefined)
92
+ diagnostics.push(diagnostic(line, "new-task alias is not declared", raw));
93
+ return resolved;
94
+ }
95
+ if (!raw.startsWith("@task/")) {
96
+ diagnostics.push(diagnostic(line, "reference must be @task/... or ^alias", raw));
97
+ return undefined;
98
+ }
99
+ try {
100
+ const id = raw.slice(1);
101
+ parseTaskId(id);
102
+ if (!board.tasks.has(id))
103
+ diagnostics.push(diagnostic(line, "@ reference must name a pre-existing task", raw));
104
+ return board.tasks.has(id) ? id : undefined;
105
+ }
106
+ catch (error) {
107
+ diagnostics.push(diagnostic(line, error instanceof Error ? error.message : String(error), raw));
108
+ return undefined;
109
+ }
110
+ }
111
+ function referenceList(assignment, board, aliases, diagnostics) {
112
+ if (assignment.value === "")
113
+ return [];
114
+ const raw = assignment.value.split(",").map((item) => item.trim());
115
+ if (raw.some((item) => item.length === 0)) {
116
+ diagnostics.push(diagnostic(assignment.line, "reference list contains an empty item", assignment.token));
117
+ return undefined;
118
+ }
119
+ const resolved = raw.map((item) => resolveReference(item, assignment.line, board, aliases, diagnostics));
120
+ if (resolved.some((item) => item === undefined))
121
+ return undefined;
122
+ const ids = resolved;
123
+ if (new Set(ids).size !== ids.length) {
124
+ diagnostics.push(diagnostic(assignment.line, "reference list contains a duplicate", assignment.token));
125
+ return undefined;
126
+ }
127
+ return ids;
128
+ }
129
+ function patchRelation(current, assignment, values, diagnostics) {
130
+ if (assignment.operator === "=")
131
+ return values;
132
+ if (assignment.operator === "+=")
133
+ return [...current, ...values.filter((id) => !current.includes(id))];
134
+ const missing = values.filter((id) => !current.includes(id));
135
+ for (const id of missing)
136
+ diagnostics.push(diagnostic(assignment.line, "cannot remove an absent relation", `@${id}`));
137
+ return missing.length === 0 ? current.filter((id) => !values.includes(id)) : current;
138
+ }
139
+ function applyAssignments(node, base, board, aliases, diagnostics) {
140
+ let next = base;
141
+ const scalar = new Set();
142
+ for (const assignment of node.assignments) {
143
+ if (assignment.field === "as")
144
+ continue;
145
+ if (assignment.field === "pri" || assignment.field === "parent") {
146
+ if (scalar.has(assignment.field)) {
147
+ diagnostics.push(diagnostic(assignment.line, `${assignment.field} is assigned more than once`, assignment.token));
148
+ }
149
+ scalar.add(assignment.field);
150
+ }
151
+ if (assignment.field === "pri") {
152
+ if (assignment.operator !== "=" || !/^[0-3]$/u.test(assignment.value)) {
153
+ diagnostics.push(diagnostic(assignment.line, "pri must use = with a value from 0 through 3", assignment.token));
154
+ }
155
+ else
156
+ next = { ...next, priority: Number(assignment.value) };
157
+ continue;
158
+ }
159
+ if (assignment.field === "parent") {
160
+ if (assignment.operator !== "=") {
161
+ diagnostics.push(diagnostic(assignment.line, "parent accepts only =", assignment.token));
162
+ }
163
+ else if (assignment.value === "")
164
+ next = { ...next, parent: null };
165
+ else {
166
+ const id = resolveReference(assignment.value.trim(), assignment.line, board, aliases, diagnostics);
167
+ if (id !== undefined)
168
+ next = { ...next, parent: id };
169
+ }
170
+ continue;
171
+ }
172
+ const values = referenceList(assignment, board, aliases, diagnostics);
173
+ if (values === undefined)
174
+ continue;
175
+ if (assignment.operator !== "=" && values.length === 0) {
176
+ diagnostics.push(diagnostic(assignment.line, `${assignment.operator} requires at least one reference`, assignment.token));
177
+ continue;
178
+ }
179
+ next = { ...next, [assignment.field]: patchRelation(next[assignment.field], assignment, values, diagnostics) };
180
+ }
181
+ if (node.body !== undefined)
182
+ next = { ...next, body: node.body.value };
183
+ for (const field of ["needs", "supersedes", "relates"]) {
184
+ if (next[field].includes(next.id))
185
+ diagnostics.push(diagnostic(node.line, `${field} cannot reference the task itself`, next.id));
186
+ }
187
+ if (next.parent === next.id)
188
+ diagnostics.push(diagnostic(node.line, "parent cannot reference the task itself", next.id));
189
+ return next;
190
+ }
191
+ function relationTargets(document, relation) {
192
+ return relation === "needs" ? document.needs : document.parent === null ? [] : [document.parent];
193
+ }
194
+ function pathExists(board, start, goal, relation) {
195
+ const seen = new Set();
196
+ const pending = [start];
197
+ while (pending.length > 0) {
198
+ const id = pending.pop();
199
+ if (id === goal)
200
+ return true;
201
+ if (seen.has(id))
202
+ continue;
203
+ seen.add(id);
204
+ const task = board.tasks.get(id);
205
+ if (task !== undefined)
206
+ pending.push(...relationTargets(task, relation));
207
+ }
208
+ return false;
209
+ }
210
+ function diagnoseIntroducedCycles(after, tasks, diagnostics) {
211
+ for (const task of tasks) {
212
+ for (const relation of ["needs", "parent"]) {
213
+ const old = task.before === null ? [] : relationTargets(task.before, relation);
214
+ for (const target of relationTargets(task.after, relation)) {
215
+ if (!old.includes(target) && pathExists(after, target, task.after.id, relation)) {
216
+ diagnostics.push(diagnostic(task.line, `${relation} edge creates a cycle`, `${task.after.id} -> ${target}`));
217
+ }
218
+ }
219
+ }
220
+ }
221
+ }
222
+ function changed(task) {
223
+ return (task.before === null ||
224
+ !Buffer.from(serializeTaskDocument(task.before)).equals(Buffer.from(serializeTaskDocument(task.after))));
225
+ }
226
+ function stableAdmissionOrder(tasks, diagnostics) {
227
+ const candidates = tasks.filter(changed);
228
+ const byId = new Map(candidates.map((task) => [task.after.id, task]));
229
+ const dependencies = new Map(candidates.map((task) => [task.after.id, new Set()]));
230
+ for (const task of candidates) {
231
+ const targets = [...task.after.needs, ...(task.after.parent === null ? [] : [task.after.parent])];
232
+ for (const target of targets) {
233
+ const plannedTarget = byId.get(target);
234
+ if (plannedTarget?.before === null)
235
+ dependencies.get(task.after.id).add(target);
236
+ }
237
+ }
238
+ const remaining = new Set(candidates.map((task) => task.after.id));
239
+ const ordered = [];
240
+ while (remaining.size > 0) {
241
+ const ready = candidates.find((task) => remaining.has(task.after.id) && [...dependencies.get(task.after.id)].every((id) => !remaining.has(id)));
242
+ if (ready === undefined) {
243
+ const first = candidates.find((task) => remaining.has(task.after.id));
244
+ diagnostics.push(diagnostic(first.line, "needs and parent references create an admission cycle", first.after.id));
245
+ return [];
246
+ }
247
+ remaining.delete(ready.after.id);
248
+ ordered.push(ready);
249
+ }
250
+ return ordered;
251
+ }
252
+ function bodyPreview(node, id) {
253
+ if (node.body?.kind !== "replace")
254
+ return null;
255
+ const lines = node.body.value.split(/\r\n|\n|\r/u);
256
+ return {
257
+ taskId: id,
258
+ bytes: Buffer.byteLength(node.body.value),
259
+ firstLine: lines[0] ?? "",
260
+ lastLine: lines.at(-1) ?? "",
261
+ };
262
+ }
263
+ export function planTaskComposition(input) {
264
+ const parsed = parseTaskComposition(input.markdown);
265
+ const diagnostics = [...parsed.diagnostics];
266
+ const namespace = parsed.namespace ?? input.namespace;
267
+ const allocationInput = {
268
+ parsed,
269
+ board: input.board,
270
+ namespace,
271
+ at: input.at,
272
+ ...(input.actor === undefined ? {} : { actor: input.actor }),
273
+ };
274
+ const allocations = allocateNodes(allocationInput, diagnostics);
275
+ const aliases = collectAliases(parsed.nodes, allocations, diagnostics);
276
+ const addressed = new Set();
277
+ const tasks = [];
278
+ for (const node of parsed.nodes) {
279
+ const before = node.kind === "new" ? null : (input.board.tasks.get(node.id) ?? null);
280
+ const base = node.kind === "new" ? allocations.get(node.index) : before;
281
+ if (base === null || base === undefined) {
282
+ diagnostics.push(diagnostic(node.line, "existing task does not exist before composition", `@${node.id}`));
283
+ continue;
284
+ }
285
+ if (addressed.has(base.id)) {
286
+ diagnostics.push(diagnostic(node.line, "task is addressed more than once", base.id));
287
+ continue;
288
+ }
289
+ addressed.add(base.id);
290
+ let after = applyAssignments(node, base, input.board, aliases, diagnostics);
291
+ if (before !== null && changed({ index: node.index, line: node.line, kind: node.kind, before, after })) {
292
+ after = { ...after, updatedAt: advanceTaskTimestamp(before.updatedAt, input.at) };
293
+ }
294
+ tasks.push({
295
+ index: node.index,
296
+ line: node.line,
297
+ kind: node.kind,
298
+ ...(aliasFor(node) === undefined ? {} : { alias: aliasFor(node).value }),
299
+ before,
300
+ after,
301
+ });
302
+ }
303
+ const post = new Map(input.board.tasks);
304
+ for (const task of tasks)
305
+ post.set(task.after.id, task.after);
306
+ diagnoseIntroducedCycles({ tasks: post }, tasks, diagnostics);
307
+ const ordered = stableAdmissionOrder(tasks, diagnostics);
308
+ if (diagnostics.length > 0)
309
+ return { kind: "refused", diagnostics };
310
+ const aliasBindings = [...aliases].map(([alias, taskId]) => ({ alias, taskId }));
311
+ const bodies = parsed.nodes.flatMap((node) => {
312
+ const task = tasks.find((candidate) => candidate.index === node.index);
313
+ if (task === undefined)
314
+ return [];
315
+ const preview = bodyPreview(node, task.after.id);
316
+ return preview === null ? [] : [preview];
317
+ });
318
+ return {
319
+ kind: "planned",
320
+ plan: {
321
+ namespace,
322
+ aliases: aliasBindings,
323
+ admissionOrder: ordered.map((task) => task.after.id),
324
+ bodies,
325
+ tasks: ordered,
326
+ },
327
+ };
328
+ }
@@ -0,0 +1,32 @@
1
+ import { type TaskId } from "./identity.js";
2
+ import type { TaskCompositionDiagnostic } from "./operations.js";
3
+ export type RelationField = "needs" | "supersedes" | "relates";
4
+ export type Assignment = Readonly<{
5
+ field: "as" | "parent" | "pri" | RelationField;
6
+ operator: "=" | "+=" | "-=";
7
+ value: string;
8
+ line: number;
9
+ token: string;
10
+ }>;
11
+ export type BodyAssignment = Readonly<{
12
+ kind: "clear" | "replace";
13
+ value: string;
14
+ line: number;
15
+ token: string;
16
+ }>;
17
+ export type ParsedNode = Readonly<{
18
+ index: number;
19
+ line: number;
20
+ kind: "new" | "existing";
21
+ title?: string;
22
+ id?: TaskId;
23
+ assignments: readonly Assignment[];
24
+ body?: BodyAssignment;
25
+ }>;
26
+ export type ParsedComposition = Readonly<{
27
+ namespace?: readonly string[];
28
+ namespaceSpecified: boolean;
29
+ nodes: readonly ParsedNode[];
30
+ diagnostics: readonly TaskCompositionDiagnostic[];
31
+ }>;
32
+ export declare function parseTaskComposition(source: string): ParsedComposition;
@@ -0,0 +1,180 @@
1
+ import { parseTaskId } from "./identity.js";
2
+ function diagnostic(line, reason, token) {
3
+ return { line, reason, token };
4
+ }
5
+ function sourceLines(source) {
6
+ const lines = [];
7
+ let start = 0;
8
+ let number = 1;
9
+ while (start < source.length) {
10
+ let cursor = start;
11
+ while (cursor < source.length && source[cursor] !== "\n" && source[cursor] !== "\r")
12
+ cursor += 1;
13
+ let end = cursor;
14
+ if (source[cursor] === "\r" && source[cursor + 1] === "\n")
15
+ end += 2;
16
+ else if (cursor < source.length)
17
+ end += 1;
18
+ lines.push({ number, start, end, text: source.slice(start, cursor) });
19
+ start = end;
20
+ number += 1;
21
+ }
22
+ if (source.length === 0 || source.endsWith("\n") || source.endsWith("\r")) {
23
+ lines.push({ number, start: source.length, end: source.length, text: "" });
24
+ }
25
+ return lines;
26
+ }
27
+ function withoutFenceSeparator(value) {
28
+ if (value.endsWith("\r\n"))
29
+ return value.slice(0, -2);
30
+ if (value.endsWith("\n") || value.endsWith("\r"))
31
+ return value.slice(0, -1);
32
+ return value;
33
+ }
34
+ function parseNamespace(value) {
35
+ if (value === "/")
36
+ return [];
37
+ if (value === "")
38
+ throw new Error("empty compose namespace; use ns=/ for root");
39
+ return parseTaskId(`task/${value}/placeholder`).namespace;
40
+ }
41
+ function parseAssignment(text, line) {
42
+ const matched = /^(as|parent|pri|needs|supersedes|relates)\s*(=|\+=|-=)\s*(.*)$/u.exec(text);
43
+ if (matched === null)
44
+ return null;
45
+ return {
46
+ field: matched[1],
47
+ operator: matched[2],
48
+ value: matched[3],
49
+ line,
50
+ token: text,
51
+ };
52
+ }
53
+ function parseNode(text, line, index) {
54
+ if (text.startsWith("+ ")) {
55
+ const title = text.slice(2);
56
+ return title.trim().length === 0
57
+ ? diagnostic(line, "new task title must be nonblank", text)
58
+ : { index, line, kind: "new", title, assignments: [] };
59
+ }
60
+ if (!text.startsWith("@task/"))
61
+ return diagnostic(line, "node must begin with + or @task/", text);
62
+ try {
63
+ const id = text.slice(1);
64
+ parseTaskId(id);
65
+ return { index, line, kind: "existing", id, assignments: [] };
66
+ }
67
+ catch (error) {
68
+ return diagnostic(line, error instanceof Error ? error.message : String(error), text);
69
+ }
70
+ }
71
+ function withAssignment(node, assignment) {
72
+ return { ...node, assignments: [...node.assignments, assignment] };
73
+ }
74
+ function withBody(node, body) {
75
+ return { ...node, body };
76
+ }
77
+ function replaceNode(nodes, node) {
78
+ nodes[node.index] = node;
79
+ }
80
+ function parseBodyAssignment(input, diagnostics) {
81
+ const fence = /^body\s+<<(.+)$/u.exec(input.text);
82
+ if (fence !== null) {
83
+ const token = fence[1];
84
+ if (!/^[A-Z][A-Z0-9_]{2,31}$/u.test(token)) {
85
+ diagnostics.push(diagnostic(input.line.number, "body token must match [A-Z][A-Z0-9_]* with length 3..32", token));
86
+ return { handled: true };
87
+ }
88
+ const close = input.lines.findIndex((candidate, candidateIndex) => candidateIndex > input.index && candidate.text === token);
89
+ if (close < 0) {
90
+ diagnostics.push(diagnostic(input.line.number, "body fence is not closed", token));
91
+ return { handled: true, stop: true };
92
+ }
93
+ const body = withoutFenceSeparator(input.source.slice(input.line.end, input.lines[close].start));
94
+ if (input.current.body !== undefined) {
95
+ diagnostics.push(diagnostic(input.line.number, "body is assigned more than once", input.text));
96
+ return { handled: true, close };
97
+ }
98
+ return {
99
+ handled: true,
100
+ node: withBody(input.current, { kind: "replace", value: body, line: input.line.number, token }),
101
+ close,
102
+ };
103
+ }
104
+ if (!/^body\s*=\s*$/u.test(input.text))
105
+ return { handled: false };
106
+ if (input.current.body !== undefined) {
107
+ diagnostics.push(diagnostic(input.line.number, "body is assigned more than once", input.text));
108
+ return { handled: true };
109
+ }
110
+ return {
111
+ handled: true,
112
+ node: withBody(input.current, { kind: "clear", value: "", line: input.line.number, token: input.text }),
113
+ };
114
+ }
115
+ export function parseTaskComposition(source) {
116
+ const lines = sourceLines(source);
117
+ const diagnostics = [];
118
+ const nodes = [];
119
+ let namespace;
120
+ let current;
121
+ let sawNode = false;
122
+ let sawNamespace = false;
123
+ for (let index = 0; index < lines.length; index += 1) {
124
+ const line = lines[index];
125
+ const text = line.text.trimStart();
126
+ if (text.trim().length === 0)
127
+ continue;
128
+ if (text.startsWith("ns=")) {
129
+ if (sawNode || sawNamespace)
130
+ diagnostics.push(diagnostic(line.number, "namespace must be the first nonblank line", text));
131
+ else {
132
+ try {
133
+ namespace = parseNamespace(text.slice(3));
134
+ }
135
+ catch (error) {
136
+ diagnostics.push(diagnostic(line.number, error instanceof Error ? error.message : String(error), text));
137
+ }
138
+ }
139
+ sawNamespace = true;
140
+ continue;
141
+ }
142
+ if (text.startsWith("+ ") || text.startsWith("@task/")) {
143
+ const parsed = parseNode(text, line.number, nodes.length);
144
+ if ("reason" in parsed) {
145
+ diagnostics.push(parsed);
146
+ current = undefined;
147
+ }
148
+ else {
149
+ nodes.push(parsed);
150
+ current = parsed;
151
+ }
152
+ sawNode = true;
153
+ continue;
154
+ }
155
+ if (current === undefined) {
156
+ diagnostics.push(diagnostic(line.number, "property must follow a task node", text));
157
+ continue;
158
+ }
159
+ const body = parseBodyAssignment({ text, line, index, lines, source, current }, diagnostics);
160
+ if (body.handled) {
161
+ if (body.node !== undefined) {
162
+ current = body.node;
163
+ replaceNode(nodes, current);
164
+ }
165
+ if (body.close !== undefined)
166
+ index = body.close;
167
+ if (body.stop === true)
168
+ break;
169
+ continue;
170
+ }
171
+ const assignment = parseAssignment(text, line.number);
172
+ if (assignment === null)
173
+ diagnostics.push(diagnostic(line.number, "unknown compose property", text));
174
+ else {
175
+ current = withAssignment(current, assignment);
176
+ replaceNode(nodes, current);
177
+ }
178
+ }
179
+ return { ...(namespace === undefined ? {} : { namespace }), namespaceSpecified: sawNamespace, nodes, diagnostics };
180
+ }
@@ -1,18 +1,32 @@
1
- import { type TaskId } from "./identity.js";
2
1
  import type { WorldRoot } from "../world.js";
3
- import { type TaskRefusal, type TaskRetry } from "./operations.js";
4
- type TaskDocumentChange = Readonly<{
2
+ import { type TaskCompositionAlias, type TaskCompositionBodyPreview } from "./compose-language.js";
3
+ import type { TaskId } from "./identity.js";
4
+ import type { TaskRefusal, TaskRetry } from "./operations.js";
5
+ export type { TaskCompositionAlias, TaskCompositionBodyPreview } from "./compose-language.js";
6
+ export { taskCompositionNamespaceHeader } from "./compose-language.js";
7
+ export type TaskDocumentChange = Readonly<{
5
8
  taskId: TaskId;
6
9
  kind: "created" | "updated";
7
10
  documentDiff: string;
8
11
  }>;
12
+ export type TaskCompositionFacts = Readonly<{
13
+ aliases: readonly TaskCompositionAlias[];
14
+ admissionOrder: readonly TaskId[];
15
+ }>;
9
16
  export type TaskCompositionResult = Readonly<{
17
+ kind: "planned";
18
+ aliases: readonly TaskCompositionAlias[];
19
+ admissionOrder: readonly TaskId[];
20
+ bodies: readonly TaskCompositionBodyPreview[];
21
+ }> | Readonly<{
10
22
  kind: "accepted";
11
23
  documentChanges: readonly TaskDocumentChange[];
12
- }> | Readonly<{
24
+ } & TaskCompositionFacts> | Readonly<{
13
25
  kind: "refused";
14
- refusal: TaskRefusal;
15
- }> | Readonly<{
26
+ refusal: Extract<TaskRefusal, {
27
+ kind: "invalid-composition";
28
+ }>;
29
+ }> | (Readonly<{
16
30
  kind: "incomplete";
17
31
  documentChanges: readonly TaskDocumentChange[];
18
32
  stopped: TaskRefusal | Readonly<{
@@ -20,6 +34,12 @@ export type TaskCompositionResult = Readonly<{
20
34
  reason: TaskRetry;
21
35
  }>;
22
36
  draft: string;
23
- }>;
24
- export declare function composeTasks(world: WorldRoot, markdown: string, signal?: AbortSignal, actor?: string, defaultNamespace?: readonly string[]): Promise<TaskCompositionResult>;
25
- export {};
37
+ }> & TaskCompositionFacts);
38
+ export declare function composeTasks(input: Readonly<{
39
+ world: WorldRoot;
40
+ markdown: string;
41
+ signal?: AbortSignal;
42
+ actor?: string;
43
+ defaultNamespace?: readonly string[];
44
+ planOnly?: boolean;
45
+ }>): Promise<TaskCompositionResult>;