@turri-dev/cli 0.2.4-next.240620d → 0.2.4-next.359b847

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 (134) hide show
  1. package/README.md +6 -7
  2. package/dist/bedrock-region.js +3 -3
  3. package/dist/chat-models.d.ts +1 -1
  4. package/dist/chat-models.js +1 -1
  5. package/dist/chat-scope.d.ts +1 -3
  6. package/dist/chat-skills.d.ts +1 -1
  7. package/dist/chat-skills.js +1 -1
  8. package/dist/chats.d.ts +44 -10
  9. package/dist/chats.js +125 -41
  10. package/dist/cli.js +10 -26
  11. package/dist/config-edit.d.ts +20 -8
  12. package/dist/config-edit.js +32 -24
  13. package/dist/config.d.ts +101 -58
  14. package/dist/config.js +265 -118
  15. package/dist/conform-cli.js +14 -3
  16. package/dist/conformance-switch.d.ts +7 -6
  17. package/dist/conformance-switch.js +19 -16
  18. package/dist/extension.d.ts +29 -3
  19. package/dist/extension.js +375 -351
  20. package/dist/genome.js +5 -1
  21. package/dist/host-session.d.ts +8 -7
  22. package/dist/host-session.js +4 -4
  23. package/dist/host.d.ts +3 -1
  24. package/dist/host.js +3 -3
  25. package/dist/identity.js +2 -2
  26. package/dist/init-config.d.ts +1 -1
  27. package/dist/init-config.js +8 -8
  28. package/dist/launch-agent.d.ts +51 -0
  29. package/dist/launch-agent.js +267 -0
  30. package/dist/{release-cli.js → launch-cli.js} +41 -24
  31. package/dist/launch-session.d.ts +68 -0
  32. package/dist/launch-session.js +217 -0
  33. package/dist/launch-tools.d.ts +28 -0
  34. package/dist/launch-tools.js +69 -0
  35. package/dist/launch-track.d.ts +125 -0
  36. package/dist/launch-track.js +320 -0
  37. package/dist/loop-cli.js +4 -4
  38. package/dist/loop-tools.d.ts +45 -21
  39. package/dist/loop-tools.js +152 -82
  40. package/dist/notice.d.ts +7 -6
  41. package/dist/parse-cli.js +2 -2
  42. package/dist/pi-launch.js +3 -0
  43. package/dist/pi-settings.d.ts +4 -0
  44. package/dist/pi-settings.js +39 -0
  45. package/dist/pi.js +6 -3
  46. package/dist/plain/check.d.ts +1 -1
  47. package/dist/plain/check.js +3 -1
  48. package/dist/plain-files.d.ts +2 -2
  49. package/dist/plain-files.js +7 -7
  50. package/dist/regenerate/agent-env.d.ts +1 -1
  51. package/dist/regenerate/agent-env.js +3 -3
  52. package/dist/regenerate/agent-shell.js +5 -3
  53. package/dist/regenerate/audit.js +9 -0
  54. package/dist/regenerate/base-folder.d.ts +2 -2
  55. package/dist/regenerate/base-folder.js +1 -1
  56. package/dist/regenerate/cases.js +7 -0
  57. package/dist/regenerate/chunk-plan.d.ts +5 -0
  58. package/dist/regenerate/chunk-plan.js +16 -1
  59. package/dist/regenerate/command-check.d.ts +7 -1
  60. package/dist/regenerate/command-check.js +43 -1
  61. package/dist/regenerate/delivery.d.ts +1 -1
  62. package/dist/regenerate/delivery.js +3 -3
  63. package/dist/regenerate/drift.d.ts +4 -0
  64. package/dist/regenerate/drift.js +26 -6
  65. package/dist/regenerate/job-panel.js +3 -1
  66. package/dist/regenerate/jobs.d.ts +2 -2
  67. package/dist/regenerate/jobs.js +10 -10
  68. package/dist/regenerate/launch.d.ts +154 -0
  69. package/dist/regenerate/{release.js → launch.js} +195 -51
  70. package/dist/regenerate/ledger.d.ts +33 -2
  71. package/dist/regenerate/lineage.d.ts +2 -0
  72. package/dist/regenerate/lineage.js +8 -0
  73. package/dist/regenerate/loop.d.ts +30 -10
  74. package/dist/regenerate/loop.js +166 -59
  75. package/dist/regenerate/model-names.d.ts +33 -0
  76. package/dist/regenerate/{engine.js → model-names.js} +2 -28
  77. package/dist/regenerate/paths.d.ts +3 -3
  78. package/dist/regenerate/paths.js +4 -4
  79. package/dist/regenerate/records.d.ts +11 -0
  80. package/dist/regenerate/records.js +15 -0
  81. package/dist/regenerate/regenerate.js +4 -1
  82. package/dist/regenerate/renames.js +4 -4
  83. package/dist/regenerate/requires.d.ts +7 -0
  84. package/dist/regenerate/requires.js +24 -18
  85. package/dist/regenerate/scripts-being-written.d.ts +4 -4
  86. package/dist/regenerate/scripts-being-written.js +3 -3
  87. package/dist/regenerate/spec-map.js +3 -3
  88. package/dist/regenerate/submit-work.d.ts +2 -0
  89. package/dist/regenerate/submit-work.js +8 -3
  90. package/dist/regenerate/test-scripts.d.ts +2 -1
  91. package/dist/regenerate/test-scripts.js +33 -23
  92. package/dist/regenerate/testing-steps.d.ts +6 -6
  93. package/dist/regenerate/testing-steps.js +8 -8
  94. package/dist/regenerate-cli.js +1 -1
  95. package/dist/self-invocation.d.ts +11 -0
  96. package/dist/self-invocation.js +36 -7
  97. package/dist/sentinel-check.d.ts +3 -3
  98. package/dist/sentinel-check.js +3 -3
  99. package/dist/sentinel.d.ts +18 -12
  100. package/dist/sentinel.js +72 -43
  101. package/dist/{config-command.d.ts → settings.d.ts} +13 -8
  102. package/dist/{config-command.js → settings.js} +155 -24
  103. package/dist/setup.d.ts +2 -2
  104. package/dist/setup.js +7 -7
  105. package/dist/turri-versions.js +2 -1
  106. package/docs/README.md +4 -4
  107. package/docs/chats.md +5 -6
  108. package/docs/claude-subscription.md +2 -2
  109. package/docs/config.md +58 -46
  110. package/docs/development.md +2 -2
  111. package/docs/headless.md +4 -4
  112. package/docs/hosting.md +20 -19
  113. package/docs/launch.md +67 -0
  114. package/docs/parser.md +2 -2
  115. package/docs/regenerating.md +21 -15
  116. package/docs/sandbox.md +3 -3
  117. package/docs/sentinel.md +26 -14
  118. package/docs/skills-and-gates.md +4 -4
  119. package/docs/using.md +19 -28
  120. package/genome/rules/project-model.md +2 -1
  121. package/genome/rules/turri-regeneration.md +5 -3
  122. package/genome/skills/implement-conformance-testing-script/SKILL.md +2 -2
  123. package/genome/skills/implement-unit-testing-script/SKILL.md +3 -3
  124. package/package.json +1 -1
  125. package/dist/regenerate/engine.d.ts +0 -52
  126. package/dist/regenerate/release.d.ts +0 -121
  127. package/dist/release-agent.d.ts +0 -43
  128. package/dist/release-agent.js +0 -130
  129. package/dist/release-tools.d.ts +0 -44
  130. package/dist/release-tools.js +0 -170
  131. package/dist/stacks.d.ts +0 -13
  132. package/dist/stacks.js +0 -96
  133. package/docs/deploy.md +0 -48
  134. /package/dist/{release-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
+ }
package/dist/loop-cli.js CHANGED
@@ -12,7 +12,7 @@ import { describeDiagnosis, diagnoseFailure } from "./regenerate/diagnose.js";
12
12
  import { createJobRegistry, pulseName } from "./regenerate/jobs.js";
13
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";
@@ -222,12 +222,12 @@ function refuseBuildDir(buildDir, projectDir) {
222
222
  /** The furthest-built codebase's last commit, exported into `dir` - or why nothing was. */
223
223
  function exportCode(plainFile, dir) {
224
224
  try {
225
- const deployment = exportModule(plainFile, undefined, dir);
225
+ const code = exportModule(plainFile, { into: dir });
226
226
  const files = listFiles(dir).length;
227
227
  // Its history began, and nothing landed in it yet: only the harness's own files, which are left out.
228
228
  if (files === 0)
229
- return { exported: false, dir, why: `nothing has landed in ${deployment.moduleName} yet: its codebase holds no code` };
230
- 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 };
231
231
  }
232
232
  catch (error) {
233
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 {};