@turri-dev/cli 0.2.4-next.8422d0f → 0.2.4-next.d779410

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 (175) hide show
  1. package/README.md +7 -8
  2. package/dist/bedrock-region.js +3 -3
  3. package/dist/chat-idle.d.ts +2 -2
  4. package/dist/chat-idle.js +2 -2
  5. package/dist/chat-models.d.ts +1 -1
  6. package/dist/chat-models.js +1 -1
  7. package/dist/chat-scope.d.ts +1 -3
  8. package/dist/chat-skills.d.ts +1 -1
  9. package/dist/chat-skills.js +1 -1
  10. package/dist/chats.d.ts +44 -20
  11. package/dist/chats.js +125 -64
  12. package/dist/cli.js +12 -31
  13. package/dist/config-edit.d.ts +20 -8
  14. package/dist/config-edit.js +32 -26
  15. package/dist/config.d.ts +106 -78
  16. package/dist/config.js +267 -133
  17. package/dist/conform-cli.js +14 -3
  18. package/dist/conformance-switch.d.ts +13 -22
  19. package/dist/conformance-switch.js +37 -59
  20. package/dist/drift-cli.js +1 -1
  21. package/dist/extension.d.ts +17 -10
  22. package/dist/extension.js +435 -532
  23. package/dist/genome.js +10 -49
  24. package/dist/graph.js +3 -5
  25. package/dist/host-session.d.ts +11 -21
  26. package/dist/host-session.js +6 -8
  27. package/dist/host.d.ts +4 -4
  28. package/dist/host.js +4 -7
  29. package/dist/identity.js +2 -3
  30. package/dist/init-config.d.ts +1 -2
  31. package/dist/init-config.js +10 -17
  32. package/dist/installed-providers.d.ts +1 -1
  33. package/dist/installed-providers.js +1 -1
  34. package/dist/launch-agent.d.ts +51 -0
  35. package/dist/launch-agent.js +267 -0
  36. package/dist/{release-cli.js → launch-cli.js} +41 -24
  37. package/dist/launch-session.d.ts +68 -0
  38. package/dist/launch-session.js +217 -0
  39. package/dist/launch-tools.d.ts +28 -0
  40. package/dist/launch-tools.js +69 -0
  41. package/dist/launch-track.d.ts +125 -0
  42. package/dist/launch-track.js +320 -0
  43. package/dist/loop-cli.d.ts +4 -3
  44. package/dist/loop-cli.js +17 -15
  45. package/dist/loop-tools.d.ts +45 -21
  46. package/dist/loop-tools.js +155 -90
  47. package/dist/new-project.js +2 -2
  48. package/dist/notice.d.ts +7 -6
  49. package/dist/parse-cli.js +2 -2
  50. package/dist/pi-launch.js +4 -1
  51. package/dist/pi-settings.d.ts +4 -0
  52. package/dist/pi-settings.js +39 -0
  53. package/dist/pi.js +12 -9
  54. package/dist/plain/check.d.ts +2 -9
  55. package/dist/plain/check.js +6 -39
  56. package/dist/plain-files.d.ts +2 -2
  57. package/dist/plain-files.js +7 -7
  58. package/dist/regenerate/activity.d.ts +0 -7
  59. package/dist/regenerate/activity.js +2 -20
  60. package/dist/regenerate/agent-env.d.ts +1 -1
  61. package/dist/regenerate/agent-env.js +3 -3
  62. package/dist/regenerate/agent-shell.js +5 -3
  63. package/dist/regenerate/audit.js +9 -0
  64. package/dist/regenerate/base-folder.d.ts +2 -2
  65. package/dist/regenerate/base-folder.js +1 -1
  66. package/dist/regenerate/cases.js +7 -0
  67. package/dist/regenerate/chunk-plan.d.ts +5 -0
  68. package/dist/regenerate/chunk-plan.js +16 -1
  69. package/dist/regenerate/command-check.d.ts +7 -1
  70. package/dist/regenerate/command-check.js +43 -1
  71. package/dist/regenerate/delivery.d.ts +1 -1
  72. package/dist/regenerate/delivery.js +3 -3
  73. package/dist/regenerate/drift.d.ts +4 -0
  74. package/dist/regenerate/drift.js +26 -6
  75. package/dist/regenerate/failure-reports.d.ts +28 -0
  76. package/dist/regenerate/failure-reports.js +79 -0
  77. package/dist/regenerate/job-panel.js +3 -1
  78. package/dist/regenerate/jobs-tree.js +1 -1
  79. package/dist/regenerate/jobs.d.ts +4 -2
  80. package/dist/regenerate/jobs.js +14 -10
  81. package/dist/regenerate/launch.d.ts +154 -0
  82. package/dist/regenerate/{release.js → launch.js} +195 -51
  83. package/dist/regenerate/ledger-view.d.ts +11 -24
  84. package/dist/regenerate/ledger-view.js +14 -60
  85. package/dist/regenerate/ledger.d.ts +34 -16
  86. package/dist/regenerate/ledger.js +1 -1
  87. package/dist/regenerate/lineage.d.ts +2 -0
  88. package/dist/regenerate/lineage.js +8 -0
  89. package/dist/regenerate/loop.d.ts +54 -67
  90. package/dist/regenerate/loop.js +312 -148
  91. package/dist/regenerate/model-names.d.ts +33 -0
  92. package/dist/regenerate/{engine.js → model-names.js} +2 -28
  93. package/dist/regenerate/paths.d.ts +3 -3
  94. package/dist/regenerate/paths.js +4 -4
  95. package/dist/regenerate/records.d.ts +11 -0
  96. package/dist/regenerate/records.js +15 -0
  97. package/dist/regenerate/regenerate.d.ts +0 -2
  98. package/dist/regenerate/regenerate.js +4 -15
  99. package/dist/regenerate/renames.js +4 -4
  100. package/dist/regenerate/requires.d.ts +7 -0
  101. package/dist/regenerate/requires.js +24 -18
  102. package/dist/regenerate/scripts-being-written.d.ts +4 -4
  103. package/dist/regenerate/scripts-being-written.js +3 -3
  104. package/dist/regenerate/spec-map.js +3 -3
  105. package/dist/regenerate/standing.js +1 -1
  106. package/dist/regenerate/submit-work.d.ts +2 -0
  107. package/dist/regenerate/submit-work.js +8 -3
  108. package/dist/regenerate/test-scripts.d.ts +2 -1
  109. package/dist/regenerate/test-scripts.js +33 -23
  110. package/dist/regenerate/testing-steps.d.ts +16 -5
  111. package/dist/regenerate/testing-steps.js +28 -9
  112. package/dist/regenerate-cli.js +18 -9
  113. package/dist/self-invocation.d.ts +11 -0
  114. package/dist/self-invocation.js +36 -10
  115. package/dist/sentinel-check.d.ts +3 -3
  116. package/dist/sentinel-check.js +3 -3
  117. package/dist/sentinel.d.ts +18 -12
  118. package/dist/sentinel.js +75 -46
  119. package/dist/{config-command.d.ts → settings.d.ts} +13 -8
  120. package/dist/{config-command.js → settings.js} +155 -24
  121. package/dist/setup.d.ts +2 -2
  122. package/dist/setup.js +7 -7
  123. package/dist/skill.d.ts +0 -11
  124. package/dist/skill.js +0 -9
  125. package/dist/tools.js +2 -3
  126. package/dist/turri-versions.js +2 -1
  127. package/docs/README.md +4 -6
  128. package/docs/authoring-plain.md +3 -3
  129. package/docs/chats.md +6 -9
  130. package/docs/claude-subscription.md +2 -2
  131. package/docs/config.md +61 -51
  132. package/docs/development.md +4 -5
  133. package/docs/headless.md +7 -6
  134. package/docs/hosting.md +25 -24
  135. package/docs/launch.md +67 -0
  136. package/docs/parser.md +3 -3
  137. package/docs/regenerating.md +30 -22
  138. package/docs/sandbox.md +3 -3
  139. package/docs/sentinel.md +28 -16
  140. package/docs/skills-and-gates.md +6 -11
  141. package/docs/using.md +25 -42
  142. package/genome/rules/project-model.md +2 -1
  143. package/genome/rules/test-plain-files.md +15 -7
  144. package/genome/rules/turri-regeneration.md +7 -10
  145. package/genome/skills/convert-old-syntax/SKILL.md +5 -5
  146. package/genome/skills/implement-conformance-testing-script/SKILL.md +2 -2
  147. package/genome/skills/implement-unit-testing-script/SKILL.md +3 -3
  148. package/package.json +1 -1
  149. package/dist/advisor-chat.d.ts +0 -63
  150. package/dist/advisor-chat.js +0 -290
  151. package/dist/change-plain-cli.js +0 -55
  152. package/dist/ledger-cli.d.ts +0 -1
  153. package/dist/ledger-cli.js +0 -50
  154. package/dist/ledger-tools.d.ts +0 -10
  155. package/dist/ledger-tools.js +0 -64
  156. package/dist/regenerate/advisor-records.d.ts +0 -93
  157. package/dist/regenerate/advisor-records.js +0 -110
  158. package/dist/regenerate/advisor-runs.d.ts +0 -87
  159. package/dist/regenerate/advisor-runs.js +0 -327
  160. package/dist/regenerate/engine.d.ts +0 -52
  161. package/dist/regenerate/release.d.ts +0 -121
  162. package/dist/regenerate/test-advisor.d.ts +0 -101
  163. package/dist/regenerate/test-advisor.js +0 -379
  164. package/dist/release-agent.d.ts +0 -43
  165. package/dist/release-agent.js +0 -130
  166. package/dist/release-cli.d.ts +0 -1
  167. package/dist/release-tools.d.ts +0 -44
  168. package/dist/release-tools.js +0 -170
  169. package/dist/spec-tools.d.ts +0 -36
  170. package/dist/spec-tools.js +0 -128
  171. package/dist/stacks.d.ts +0 -13
  172. package/dist/stacks.js +0 -96
  173. package/docs/deploy.md +0 -48
  174. package/docs/test-advisor.md +0 -110
  175. /package/dist/{change-plain-cli.d.ts → launch-cli.d.ts} +0 -0
@@ -0,0 +1,320 @@
1
+ import { dirname, join } from "node:path";
2
+ import { codeTreeOf, describeLeftBehind, exportModule, holdsCommit, hostDirOf, launchTarget, listLaunched, runningLaunched, stopLaunched, stopLeftBehind } from "./regenerate/launch.js";
3
+ import { projectDirOf } from "./regenerate/paths.js";
4
+ import { record } from "./regenerate/ledger.js";
5
+ /** How many ended launches are kept to list. */
6
+ const KEPT = 50;
7
+ export function createLaunchTrack(options) {
8
+ const codebases = new Map();
9
+ const launches = [];
10
+ const ends = new Map();
11
+ const takenOver = new Map();
12
+ let count = 0;
13
+ const stateOf = (codebase, moduleDir) => {
14
+ let state = codebases.get(codebase);
15
+ if (state === undefined) {
16
+ state = { moduleDir, settledWaiters: [] };
17
+ codebases.set(codebase, state);
18
+ }
19
+ state.moduleDir = moduleDir;
20
+ return state;
21
+ };
22
+ const changed = (launch) => {
23
+ try {
24
+ options.onChange?.(launch);
25
+ }
26
+ catch {
27
+ /* one that listens and fails is left out of this change */
28
+ }
29
+ };
30
+ const ended = (launch) => ends.get(launch.id)?.resolve(launch);
31
+ /** `next` takes `launch`'s place: whoever waits on `launch` hears `next`'s end, and that it took over, now. */
32
+ const handOn = (launch, next) => {
33
+ takenOver.get(launch.id)?.resolve(next);
34
+ void track.done(next.id).then((last) => ends.get(launch.id)?.resolve(last));
35
+ };
36
+ const finished = (launch) => record({ kind: "launch.finished", launch: launch.id, commit: launch.short, status: launch.status, ms: (launch.finishedAt ?? Date.now()) - (launch.startedAt ?? launch.queuedAt) }, place(launch));
37
+ const place = (launch) => ({ project: options.cwd, module: launch.codebase });
38
+ /** What an earlier session left running and was stopped, by codebase, not yet said in a launch's summary. */
39
+ const leftBehind = new Map();
40
+ const noteLeftBehind = (stopped) => {
41
+ if (stopped.length === 0)
42
+ return;
43
+ record({ kind: "launch.left-behind", stopped: stopped.map((each) => ({ name: each.name, pid: each.pid, module: each.moduleName, ...(each.url !== undefined ? { url: each.url } : {}) })) }, { project: options.cwd });
44
+ for (const each of stopped)
45
+ leftBehind.set(each.moduleName, [...(leftBehind.get(each.moduleName) ?? []), each]);
46
+ };
47
+ /**
48
+ * What runs for the codebase is the commit's code: the same code, nothing it started has ended. Guidance is not
49
+ * compared: the agent finds the project's itself, and the chat passing it on says nothing new - `again` launches anew.
50
+ */
51
+ const isOut = (state, commit) => {
52
+ const current = state.current;
53
+ if (current === undefined || current.status !== "launched")
54
+ return undefined;
55
+ if (!holdsCommit(state.moduleDir, current.commit, commit) && !holdsCommit(state.moduleDir, commit, current.commit))
56
+ return undefined;
57
+ const tree = codeTreeOf(state.moduleDir, commit);
58
+ if (tree === undefined || tree !== codeTreeOf(state.moduleDir, current.commit))
59
+ return undefined;
60
+ const since = current.serversSince ?? current.startedAt ?? 0;
61
+ const started = listLaunched().filter((item) => item.moduleName === current.codebase && item.startedAt >= since);
62
+ return started.some((item) => item.exited !== undefined) ? undefined : current;
63
+ };
64
+ const settle = (state) => {
65
+ if (state.running !== undefined || state.waiting !== undefined)
66
+ return;
67
+ for (const resolve of state.settledWaiters.splice(0))
68
+ resolve();
69
+ };
70
+ const keep = (launch) => {
71
+ launches.push(launch);
72
+ while (launches.length > KEPT) {
73
+ const first = launches.findIndex((each) => each.status !== "waiting" && each.status !== "running");
74
+ if (first === -1)
75
+ break;
76
+ launches.splice(first, 1);
77
+ }
78
+ };
79
+ /**
80
+ * A launch whose commit's code is what runs already - a pulse that landed only tests, say, or the chat asking for what
81
+ * runs: ended as launched at once, `already`, nothing stopped or started - nor anyone told it is launching. What runs
82
+ * is its own from then on, when its commit is built on what ran: it holds both. Told as any launch's end is.
83
+ */
84
+ const outAlready = (state, launch, out) => {
85
+ launch.status = "launched";
86
+ launch.already = true;
87
+ launch.startedAt = Date.now();
88
+ launch.serversSince = out.serversSince ?? out.startedAt ?? 0;
89
+ launch.summary = out.summary ?? `${launch.codebase} at ${out.short} runs already.`;
90
+ launch.finishedAt = Date.now();
91
+ if (holdsCommit(state.moduleDir, out.commit, launch.commit))
92
+ state.current = launch;
93
+ finish(state, launch);
94
+ };
95
+ const start = (state, launch) => {
96
+ // Found out already as it waited.
97
+ const out = launch.again === true ? undefined : isOut(state, launch.commit);
98
+ if (out !== undefined) {
99
+ outAlready(state, launch, out);
100
+ return;
101
+ }
102
+ const abort = new AbortController();
103
+ state.running = { launch, abort };
104
+ launch.status = "running";
105
+ launch.startedAt = Date.now();
106
+ changed(launch);
107
+ record({ kind: "launch.started", launch: launch.id, commit: launch.short, ...("pulse" in launch.cause ? { pulse: launch.cause.pulse } : {}) }, place(launch));
108
+ void runIt(state, launch, abort);
109
+ };
110
+ const runIt = async (state, launch, abort) => {
111
+ // Halted, it is let go at once: what the agent does after is nobody's.
112
+ const halted = new Promise((_, reject) => abort.signal.addEventListener("abort", () => reject(new Error("stopped")), { once: true }));
113
+ halted.catch(() => undefined);
114
+ try {
115
+ // What the last launch started runs from what is about to be replaced - and what an earlier session's left, which
116
+ // would hold its ports.
117
+ noteLeftBehind(await stopLeftBehind(projectDirOf(launch.plainFile), launch.codebase));
118
+ await stopLaunched({ moduleName: launch.codebase });
119
+ const code = exportModule(launch.plainFile, { ...(launch.inModule !== undefined ? { inModule: launch.inModule } : {}), commit: launch.commit });
120
+ launch.code = code;
121
+ launch.serversSince = Date.now();
122
+ changed(launch);
123
+ if (abort.signal.aborted)
124
+ throw new Error("stopped");
125
+ const outcome = await Promise.race([options.run(launch, code, abort.signal), halted]);
126
+ if (abort.signal.aborted)
127
+ throw new Error("stopped");
128
+ launch.status = outcome.launched ? "launched" : "failed";
129
+ launch.summary = outcome.summary.trim();
130
+ }
131
+ catch (error) {
132
+ launch.status = abort.signal.aborted ? "stopped" : "failed";
133
+ launch.summary = abort.signal.aborted ? "Stopped on request." : error instanceof Error ? error.message : String(error);
134
+ }
135
+ const left = leftBehind.get(launch.codebase);
136
+ if (left !== undefined) {
137
+ leftBehind.delete(launch.codebase);
138
+ launch.summary = `${describeLeftBehind(left)}\n${launch.summary ?? ""}`.trim();
139
+ }
140
+ launch.finishedAt = Date.now();
141
+ // What runs is this launch's - or, stopped, nothing of it.
142
+ state.current = launch.status === "stopped" ? undefined : launch;
143
+ finish(state, launch);
144
+ };
145
+ /**
146
+ * A launch ended: the track free for the next - before anyone hears it ended - then it is told, and the next started.
147
+ * With a newer one waiting that will stop what it started - not out already - it is replaced: whoever asked for it
148
+ * hears the newer one's end instead, never that it is up only for it to be stopped the next moment.
149
+ */
150
+ const finish = (state, launch) => {
151
+ if (state.running?.launch === launch)
152
+ state.running = undefined;
153
+ const next = state.waiting;
154
+ state.waiting = undefined;
155
+ const replaces = next !== undefined && launch.status !== "stopped" && (next.again === true || isOut(state, next.commit) === undefined);
156
+ if (replaces)
157
+ launch.replacedBy = next.id;
158
+ finished(launch);
159
+ changed(launch);
160
+ if (replaces)
161
+ handOn(launch, next);
162
+ else
163
+ ended(launch);
164
+ if (next !== undefined)
165
+ start(state, next);
166
+ else
167
+ settle(state);
168
+ };
169
+ const track = {
170
+ request(input) {
171
+ const target = launchTarget(input.plainFile, { ...(input.inModule !== undefined ? { inModule: input.inModule } : {}), ...(input.commit !== undefined ? { commit: input.commit } : {}) });
172
+ const codebase = target.entry.moduleName;
173
+ const state = stateOf(codebase, dirname(target.entry.buildDir));
174
+ const said = input.guidance?.trim();
175
+ if (said !== undefined && said !== "")
176
+ state.guidance = said;
177
+ const guidance = state.guidance;
178
+ const launch = {
179
+ id: `launch-${++count}`,
180
+ codebase,
181
+ moduleDir: state.moduleDir,
182
+ plainFile: target.entry.plainFile,
183
+ ...(input.inModule !== undefined ? { inModule: input.inModule } : {}),
184
+ commit: target.commit,
185
+ short: target.commit.slice(0, 7),
186
+ hostDir: hostDirOf(target.entry.plainFile, options.cwd),
187
+ ...(guidance !== undefined ? { guidance } : {}),
188
+ cause: input.cause,
189
+ status: "waiting",
190
+ queuedAt: Date.now(),
191
+ ...(input.again === true ? { again: true } : {}),
192
+ };
193
+ let resolve;
194
+ const promise = new Promise((done) => (resolve = done));
195
+ ends.set(launch.id, { promise, resolve });
196
+ let resolveTaken;
197
+ const taken = new Promise((done) => (resolveTaken = done));
198
+ takenOver.set(launch.id, { promise: taken, resolve: resolveTaken });
199
+ // Nothing under way, and its code out already: nothing to do - but it ends as any launch does, told to the host
200
+ // (onChange) with its own cause and the commit asked for, and what runs is its own when that commit is newer.
201
+ if (input.again !== true && state.running === undefined && state.waiting === undefined) {
202
+ const out = isOut(state, launch.commit);
203
+ if (out !== undefined) {
204
+ keep(launch);
205
+ outAlready(state, launch, out);
206
+ return { launch, already: true };
207
+ }
208
+ }
209
+ keep(launch);
210
+ if (state.running === undefined)
211
+ start(state, launch);
212
+ else {
213
+ // The newest wins: what waited is never launched - this one holds its code.
214
+ const older = state.waiting;
215
+ if (older !== undefined) {
216
+ older.status = "superseded";
217
+ older.supersededBy = launch.id;
218
+ older.finishedAt = Date.now();
219
+ changed(older);
220
+ handOn(older, launch);
221
+ }
222
+ state.waiting = launch;
223
+ changed(launch);
224
+ }
225
+ return { launch, already: false };
226
+ },
227
+ current: (codebase) => codebases.get(codebase)?.current,
228
+ pending(codebase) {
229
+ const state = codebases.get(codebase);
230
+ return state?.running?.launch ?? state?.waiting;
231
+ },
232
+ settled(codebase) {
233
+ const state = codebases.get(codebase);
234
+ if (state === undefined || (state.running === undefined && state.waiting === undefined))
235
+ return Promise.resolve();
236
+ return new Promise((resolve) => state.settledWaiters.push(resolve));
237
+ },
238
+ done(id) {
239
+ const end = ends.get(id);
240
+ if (end !== undefined)
241
+ return end.promise;
242
+ const known = launches.find((launch) => launch.id === id);
243
+ return known !== undefined ? Promise.resolve(known) : Promise.reject(new Error(`No launch ${id}.`));
244
+ },
245
+ replaced(id) {
246
+ const taken = takenOver.get(id);
247
+ return taken !== undefined ? taken.promise : Promise.reject(new Error(`No launch ${id}.`));
248
+ },
249
+ holds(codebase, commit) {
250
+ const state = codebases.get(codebase);
251
+ const current = state?.current;
252
+ if (state === undefined || current === undefined)
253
+ return false;
254
+ return holdsCommit(state.moduleDir, commit, current.commit);
255
+ },
256
+ async stop(codebase) {
257
+ const stopped = [];
258
+ for (const [name, state] of codebases) {
259
+ if (codebase !== undefined && name !== codebase)
260
+ continue;
261
+ const waiting = state.waiting;
262
+ if (waiting !== undefined) {
263
+ state.waiting = undefined;
264
+ waiting.status = "stopped";
265
+ waiting.summary = "Stopped on request, before it started.";
266
+ waiting.finishedAt = Date.now();
267
+ changed(waiting);
268
+ ended(waiting);
269
+ stopped.push(`${waiting.id} (${name})`);
270
+ }
271
+ if (state.running !== undefined) {
272
+ state.running.abort.abort();
273
+ stopped.push(`${state.running.launch.id} (${name})`);
274
+ }
275
+ settle(state);
276
+ }
277
+ return stopped;
278
+ },
279
+ halted(codebase) {
280
+ const stopped = [];
281
+ for (const [name, state] of codebases) {
282
+ if (codebase !== undefined && name !== codebase)
283
+ continue;
284
+ const current = state.current;
285
+ if (current === undefined || current.status !== "launched" || runningLaunched(name).length > 0)
286
+ continue;
287
+ current.status = "stopped";
288
+ current.summary = "Stopped on request.";
289
+ current.finishedAt = Date.now();
290
+ state.current = undefined;
291
+ finished(current);
292
+ changed(current);
293
+ stopped.push(current.id);
294
+ }
295
+ return stopped;
296
+ },
297
+ list: () => [...launches],
298
+ async sweep() {
299
+ const stopped = await stopLeftBehind(projectDirOf(join(options.cwd, "turri.plain")));
300
+ noteLeftBehind(stopped);
301
+ return stopped;
302
+ },
303
+ running: (codebase) => runningLaunched(codebase),
304
+ };
305
+ return track;
306
+ }
307
+ /** A launch in a line: its codebase, commit, how it stands - for /halt, pulses and the panel. */
308
+ export function describeLaunchLine(launch) {
309
+ const why = "pulse" in launch.cause ? ` after pulse ${launch.cause.pulse}` : "";
310
+ const how = launch.status === "waiting"
311
+ ? "waiting"
312
+ : launch.status === "running"
313
+ ? "launching"
314
+ : launch.status === "launched"
315
+ ? launch.already === true
316
+ ? "out already"
317
+ : "launched"
318
+ : launch.status;
319
+ return `${launch.id} ${how} ${launch.codebase} at ${launch.short}${why}`;
320
+ }
@@ -1,11 +1,11 @@
1
1
  import { type DriftReport, type ModuleStatus, type WorkLoop } from "./regenerate/loop.ts";
2
2
  import { type ModuleState } from "./run-report.ts";
3
3
  /**
4
- * What every command that builds - `turri regenerate`, `conform`, `change-plain` - does around its own
4
+ * What every command that builds - `turri regenerate`, `conform` - does around its own
5
5
  * request of the work loop, as the chat does it: the project's models, a job that fails run once more and, failing again,
6
6
  * diagnosed, a line as each job starts and ends; then the loop run until nothing more can start, how each job ended,
7
- * and exit 1 when any failed or a module is not complete. With `dryRun`, the work is planned and the prompt of the first job each codebase would
8
- * start printed, and nothing runs.
7
+ * and exit 1 when any failed or a module is not complete. With `dryRun`, `ask` is a look ahead (`WorkLoop.lookAhead`): the work is
8
+ * planned, the prompt of the next pulse of each codebase printed from the plan kept, and nothing runs.
9
9
  */
10
10
  export declare function runLoop(options: {
11
11
  plainFile: string;
@@ -15,6 +15,7 @@ export declare function runLoop(options: {
15
15
  report?: string;
16
16
  /** The command, as the report gives it: its name and its arguments. */
17
17
  command?: string[];
18
+ /** Plan and print the next pulses, starting nothing - `ask` a look ahead. */
18
19
  dryRun?: boolean;
19
20
  /** Start over, unasked, a codebase that has to be on a module it now requires (`--start-over`). */
20
21
  startOver?: boolean;
package/dist/loop-cli.js CHANGED
@@ -10,18 +10,18 @@ import { ledgerWanted, startLedger } from "./regenerate/ledger.js";
10
10
  import { tryItCommand } from "./regenerate/delivery.js";
11
11
  import { describeDiagnosis, diagnoseFailure } from "./regenerate/diagnose.js";
12
12
  import { createJobRegistry, pulseName } from "./regenerate/jobs.js";
13
- import { createWorkLoop, describeModules, functionalityCompletion, promptOf } from "./regenerate/loop.js";
13
+ import { createWorkLoop, describeModules, functionalityCompletion } from "./regenerate/loop.js";
14
14
  import { MODULES_DIR, projectDirOf } from "./regenerate/paths.js";
15
- import { exportModule } from "./regenerate/release.js";
15
+ import { exportModule } from "./regenerate/launch.js";
16
16
  import { listFiles } from "./regenerate/testing.js";
17
17
  import { startRunReport } from "./run-report.js";
18
18
  import { configKeyOptions, optionValue } from "./cli-options.js";
19
19
  /**
20
- * What every command that builds - `turri regenerate`, `conform`, `change-plain` - does around its own
20
+ * What every command that builds - `turri regenerate`, `conform` - does around its own
21
21
  * request of the work loop, as the chat does it: the project's models, a job that fails run once more and, failing again,
22
22
  * diagnosed, a line as each job starts and ends; then the loop run until nothing more can start, how each job ended,
23
- * and exit 1 when any failed or a module is not complete. With `dryRun`, the work is planned and the prompt of the first job each codebase would
24
- * start printed, and nothing runs.
23
+ * and exit 1 when any failed or a module is not complete. With `dryRun`, `ask` is a look ahead (`WorkLoop.lookAhead`): the work is
24
+ * planned, the prompt of the next pulse of each codebase printed from the plan kept, and nothing runs.
25
25
  */
26
26
  export async function runLoop(options) {
27
27
  const plainFile = resolve(options.plainFile);
@@ -110,7 +110,6 @@ async function runLoopReporting(options) {
110
110
  cwd: process.cwd(),
111
111
  ...(model !== undefined ? { modelFor: () => model } : {}),
112
112
  ...(planner !== undefined ? { plannerModel: planner } : {}),
113
- ...(options.dryRun === true ? { dryRun: true } : {}),
114
113
  });
115
114
  report?.attach({
116
115
  jobs: () => registry.list(),
@@ -146,13 +145,16 @@ async function runLoopReporting(options) {
146
145
  }
147
146
  }
148
147
  if (options.dryRun === true) {
149
- for (const first of loop.firsts()) {
150
- console.log(`\n${c.bold(`${first.module}: ${first.planned.title}`)}${first.planned.track === "conformance" ? c.dim(" (conformance)") : ""}`);
151
- if (first.planned.track === "conformance") {
152
- console.log(c.dim("A conformance job's prompt is built from what the code it tests holds once it is built: not shown before."));
148
+ // The next pulse of each codebase, from the plan the look ahead kept - the one regenerate would start.
149
+ for (const status of planned) {
150
+ const first = status.planned[0];
151
+ if (first === undefined || first.afterCode === true || first.planning === true)
153
152
  continue;
154
- }
155
- console.log((await promptOf(first)) ?? "(no task)");
153
+ const next = await loop.plannedPulse(`planned-${status.module}-1`);
154
+ if (next === undefined)
155
+ continue;
156
+ console.log(`\n${c.bold(`${next.module}: ${next.title}`)}${next.track === "conformance" ? c.dim(" (conformance)") : ""}`);
157
+ console.log(next.task ?? c.dim(next.why ?? "(no task)"));
156
158
  }
157
159
  process.exit(0);
158
160
  }
@@ -220,12 +222,12 @@ function refuseBuildDir(buildDir, projectDir) {
220
222
  /** The furthest-built codebase's last commit, exported into `dir` - or why nothing was. */
221
223
  function exportCode(plainFile, dir) {
222
224
  try {
223
- const deployment = exportModule(plainFile, undefined, dir);
225
+ const code = exportModule(plainFile, { into: dir });
224
226
  const files = listFiles(dir).length;
225
227
  // Its history began, and nothing landed in it yet: only the harness's own files, which are left out.
226
228
  if (files === 0)
227
- return { exported: false, dir, why: `nothing has landed in ${deployment.moduleName} yet: its codebase holds no code` };
228
- return { exported: true, dir, module: deployment.moduleName, commit: deployment.commit, files };
229
+ return { exported: false, dir, why: `nothing has landed in ${code.moduleName} yet: its codebase holds no code` };
230
+ return { exported: true, dir, module: code.moduleName, commit: code.short, files };
229
231
  }
230
232
  catch (error) {
231
233
  return { exported: false, dir, why: error instanceof Error ? error.message : String(error) };
@@ -1,8 +1,8 @@
1
1
  import { type ExtensionContext, type ToolDefinition } from "@earendil-works/pi-coding-agent";
2
2
  import { Type } from "typebox";
3
3
  import { type ModuleStatus, type WorkLoop } from "./regenerate/loop.ts";
4
- import type { RenderWork } from "./regenerate/engine.ts";
5
- import { type JobRegistry } from "./regenerate/jobs.ts";
4
+ import { type Job, type JobRegistry } from "./regenerate/jobs.ts";
5
+ import type { LaunchTrack } from "./launch-track.ts";
6
6
  /**
7
7
  * The tools that act on the work loop - `regenerate`, `drift` and `halt` - defined once, for the conversation and for the
8
8
  * skills alike: a skill that regenerates what a spec holds, or reads how far it is regenerated, uses the conversation's
@@ -13,18 +13,15 @@ type AnyTool = ToolDefinition<any, any, any>;
13
13
  export declare const GUIDANCE_PARAM: Type.TOptional<Type.TString>;
14
14
  export declare const WORKING_DIR_PARAM: Type.TOptional<Type.TString>;
15
15
  export declare const MODEL_PARAM: Type.TOptional<Type.TString>;
16
- export declare const STACK_PARAM: Type.TOptional<Type.TString>;
17
16
  /**
18
- * Why a module asked for with no stack named cannot be built: a project of stacks where it has no stack of its own and
19
- * none is chosen, and config.turri.yaml alone names no unit testing script - every pulse would stop for want of one.
20
- * The stacks and the script each names, and what to do. Undefined when it can be built.
17
+ * Why a module cannot be built with the config it would be built with: two of the modules it requires have a config
18
+ * file of their own (`configModuleFor`); or, in a project where modules have their own files, it has none - nor any
19
+ * module it requires - and config.turri.yaml alone names no unit testing script, so every pulse would stop for want of
20
+ * one. The files there are and the script each names, and what to do. Undefined when it can be built.
21
21
  */
22
- export declare function stacklessBuild(plainFile: string): string | undefined;
23
- /**
24
- * `work` with the stack a call names chosen for it - or, none named, as it is: each module is then built with its own
25
- * (`stackForModule`). A module that could not be built that way is refused before anything is planned (`stacklessBuild`).
26
- */
27
- export declare function withCallStack<T>(plainFile: string, named: string | undefined, work: () => T): T;
22
+ export declare function unbuildableConfig(plainFile: string): string | undefined;
23
+ /** `work`, once the module asked for can be built with the config it would be built with - refused before anything is planned otherwise (`unbuildableConfig`). */
24
+ export declare function whenBuildable<T>(plainFile: string, work: () => T): T;
28
25
  export declare const WAIT_PARAM: Type.TOptional<Type.TBoolean>;
29
26
  /**
30
27
  * A render tool's arguments as if turri had been started in `working_dir`: the .plain file
@@ -37,8 +34,31 @@ export declare function fromWorkingDir<T extends {
37
34
  }>(cwd: string, params: T): T & {
38
35
  base: string;
39
36
  };
40
- /** What the loop is doing for a spec's modules, for the conversation - and, waiting, how each module ended. */
41
- export declare function loopReply(loop: WorkLoop, statuses: ModuleStatus[], wait: boolean): Promise<{
37
+ /**
38
+ * A call that waits for its pulses - print, json and rpc modes, or `wait: true` - in the chat it was made in: every pulse
39
+ * of that chat that was not there when it was made, and ends while it waits, is told in its reply.
40
+ */
41
+ export interface Wait {
42
+ chat: string | undefined;
43
+ before: ReadonlySet<string>;
44
+ }
45
+ /** A call in this chat starts waiting, from the pulses there are now. */
46
+ export declare function startWait(jobs: JobRegistry): Wait;
47
+ /** A call is done waiting: what ends now is told as any pulse's end is. */
48
+ export declare function endWait(jobs: JobRegistry, wait: Wait): void;
49
+ /**
50
+ * Whether a pulse that ended is told by a call still waiting in its chat - its agent is told it in that call's reply, so
51
+ * a turn of its own to say it again would only repeat it.
52
+ */
53
+ export declare function toldByWaitingCall(jobs: JobRegistry, job: Job): boolean;
54
+ /**
55
+ * What the loop is doing for a spec's modules, for the conversation - and, waiting, the pulses that ran meanwhile and how
56
+ * each ended, then how each module stands: `ran` is the registry and the call's wait (startWait).
57
+ */
58
+ export declare function loopReply(loop: WorkLoop, statuses: ModuleStatus[], wait: boolean, ran?: {
59
+ jobs: JobRegistry;
60
+ wait: Wait;
61
+ }): Promise<{
42
62
  content: {
43
63
  type: "text";
44
64
  text: string;
@@ -52,18 +72,18 @@ export declare function stopJob(jobs: JobRegistry, named: string, reason?: strin
52
72
  export interface LoopToolsOptions {
53
73
  /** Where turri was started: the folder plain_file and working_dir are relative to. */
54
74
  cwd: string;
55
- /** The pulses `halt` stops. Without them - the release agent's - it stops only what activate started. */
75
+ /** The pulses the tools act on. */
56
76
  jobs?: JobRegistry;
57
77
  /** The work loop the tools act on - the conversation's, for a call in it. */
58
78
  loop?: (ctx: ExtensionContext) => WorkLoop;
59
- /** The model a pulse of this call regenerates on: the one named, or the one chosen for the work. Default: the one named. */
60
- model?: (ctx: ExtensionContext, plainFile: string, named?: string, work?: RenderWork) => string | undefined;
79
+ /** The model a pulse of this call regenerates on: the one named, or the module's coding model. Default: the one named. */
80
+ model?: (ctx: ExtensionContext, plainFile: string, named?: string) => string | undefined;
61
81
  /** Whether a call waits for its work to finish, given what it asked. Default: only when it asked to. */
62
82
  wait?: (ctx: ExtensionContext, asked?: boolean) => boolean;
63
83
  }
64
- /** Whether a /regenerate's words ask for the module from scratch: its code deleted, and all of it regenerated again. */
84
+ /** Whether a /regenerate's words ask for the module from scratch - its code deleted, and all of it regenerated again - or a /conform's, for its conformance tests written again. */
65
85
  export declare function asksFromScratch(words: string): boolean;
66
- /** Whether a /regenerate asking for its module from scratch asks for its whole requires chain with it. */
86
+ /** Whether a /regenerate or /conform asking for its module from scratch asks for its whole requires chain with it. */
67
87
  export declare function asksWholeChain(words: string): boolean;
68
88
  /** regenerate: regenerate a module's code up to its spec as it is now. */
69
89
  export declare function regenerateTool(options: LoopToolsOptions & {
@@ -73,8 +93,12 @@ export declare function regenerateTool(options: LoopToolsOptions & {
73
93
  export declare function driftTool(options: LoopToolsOptions & {
74
94
  loop: (ctx: ExtensionContext) => WorkLoop;
75
95
  }): AnyTool;
76
- /** halt: stop a pulse, or what activate started. */
77
- export declare function haltTool(options: Pick<LoopToolsOptions, "jobs"> & {
96
+ /** halt: stop a pulse, a module's planned pulses, a launch under way, or what a launch started. */
97
+ export declare function haltTool(options: {
98
+ jobs: JobRegistry;
78
99
  workLoop?: () => WorkLoop | undefined;
100
+ launches?: LaunchTrack;
79
101
  }): AnyTool;
102
+ /** Halt what a launch started by its name, a module's launch under way and what it started, or every one: what was halted, said. */
103
+ export declare function haltLaunched(which: string, launches: LaunchTrack | undefined): Promise<string>;
80
104
  export {};