@turri-dev/cli 0.2.4-next.bc1fc47 → 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 (115) hide show
  1. package/README.md +5 -6
  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 +7 -24
  11. package/dist/config-edit.d.ts +20 -8
  12. package/dist/config-edit.js +32 -24
  13. package/dist/config.d.ts +90 -60
  14. package/dist/config.js +224 -117
  15. package/dist/conform-cli.js +1 -1
  16. package/dist/conformance-switch.d.ts +7 -6
  17. package/dist/conformance-switch.js +16 -16
  18. package/dist/extension.d.ts +10 -1
  19. package/dist/extension.js +263 -306
  20. package/dist/genome.js +1 -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 +17 -16
  39. package/dist/loop-tools.js +69 -69
  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 +3 -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 +2 -2
  53. package/dist/regenerate/base-folder.d.ts +2 -2
  54. package/dist/regenerate/base-folder.js +1 -1
  55. package/dist/regenerate/command-check.d.ts +7 -1
  56. package/dist/regenerate/command-check.js +43 -1
  57. package/dist/regenerate/delivery.d.ts +1 -1
  58. package/dist/regenerate/delivery.js +3 -3
  59. package/dist/regenerate/jobs.d.ts +2 -2
  60. package/dist/regenerate/jobs.js +10 -10
  61. package/dist/regenerate/launch.d.ts +154 -0
  62. package/dist/regenerate/{release.js → launch.js} +195 -51
  63. package/dist/regenerate/ledger.d.ts +33 -2
  64. package/dist/regenerate/lineage.d.ts +2 -0
  65. package/dist/regenerate/lineage.js +8 -0
  66. package/dist/regenerate/loop.d.ts +9 -8
  67. package/dist/regenerate/loop.js +43 -40
  68. package/dist/regenerate/model-names.d.ts +33 -0
  69. package/dist/regenerate/{engine.js → model-names.js} +2 -28
  70. package/dist/regenerate/paths.d.ts +3 -3
  71. package/dist/regenerate/paths.js +4 -4
  72. package/dist/regenerate/scripts-being-written.d.ts +4 -4
  73. package/dist/regenerate/scripts-being-written.js +3 -3
  74. package/dist/regenerate/test-scripts.d.ts +2 -1
  75. package/dist/regenerate/test-scripts.js +33 -23
  76. package/dist/regenerate/testing-steps.d.ts +6 -6
  77. package/dist/regenerate/testing-steps.js +8 -8
  78. package/dist/self-invocation.js +7 -7
  79. package/dist/sentinel-check.d.ts +3 -3
  80. package/dist/sentinel-check.js +3 -3
  81. package/dist/sentinel.d.ts +18 -12
  82. package/dist/sentinel.js +68 -42
  83. package/dist/{config-command.d.ts → settings.d.ts} +13 -8
  84. package/dist/{config-command.js → settings.js} +155 -24
  85. package/dist/setup.d.ts +2 -2
  86. package/dist/setup.js +7 -7
  87. package/docs/README.md +4 -4
  88. package/docs/chats.md +5 -6
  89. package/docs/claude-subscription.md +2 -2
  90. package/docs/config.md +58 -46
  91. package/docs/development.md +2 -2
  92. package/docs/headless.md +2 -3
  93. package/docs/hosting.md +20 -19
  94. package/docs/launch.md +67 -0
  95. package/docs/parser.md +2 -2
  96. package/docs/regenerating.md +12 -12
  97. package/docs/sandbox.md +3 -3
  98. package/docs/sentinel.md +26 -14
  99. package/docs/skills-and-gates.md +4 -5
  100. package/docs/using.md +15 -24
  101. package/genome/rules/project-model.md +2 -1
  102. package/genome/rules/turri-regeneration.md +3 -2
  103. package/genome/skills/implement-conformance-testing-script/SKILL.md +2 -2
  104. package/genome/skills/implement-unit-testing-script/SKILL.md +3 -3
  105. package/package.json +1 -1
  106. package/dist/regenerate/engine.d.ts +0 -52
  107. package/dist/regenerate/release.d.ts +0 -121
  108. package/dist/release-agent.d.ts +0 -43
  109. package/dist/release-agent.js +0 -130
  110. package/dist/release-tools.d.ts +0 -44
  111. package/dist/release-tools.js +0 -170
  112. package/dist/stacks.d.ts +0 -13
  113. package/dist/stacks.js +0 -96
  114. package/docs/deploy.md +0 -48
  115. /package/dist/{release-cli.d.ts → launch-cli.d.ts} +0 -0
package/dist/extension.js CHANGED
@@ -9,7 +9,7 @@ import { allocateImageId, Box, getCapabilities, getPngDimensions, isKeyRelease,
9
9
  import { defineTool, getMarkdownTheme, UserMessageComponent } from "@earendil-works/pi-coding-agent";
10
10
  import { Type } from "typebox";
11
11
  import { CODING_MODEL_ENV } from "./chat-models.js";
12
- import { AGENT_ROLES, chosenStack, CONFIG_FILE, configForSpec, stackForModule, hasProjectConfig, LEGACY_CONFIG_FILE, projectConfigFile, stackConfigFileIn, stackOf, stacksOf, withStack, modelOnly, modelSpec, projectModels, readProjectConfig, roleModel, splitModelSpec, unknownConfigLines } from "./config.js";
12
+ import { AGENT_ROLES, CONFIG_FILE, configForSpec, readConfigFile, configModuleFor, hasProjectConfig, LEGACY_CONFIG_FILE, projectConfigFile, moduleConfigFile, moduleConfigFileIn, configModuleOf, moduleConfigsOf, withConfigModule, modelOnly, modelSpec, projectModels, readProjectConfig, roleModel, splitModelSpec, configLines } from "./config.js";
13
13
  import { projectDirOf, skillRunDir } from "./regenerate/paths.js";
14
14
  import { sweepOrphanedGroups } from "./regenerate/shell.js";
15
15
  import { readScript, scriptAgainstMachine, stackOnMachine, toolchainsBlock } from "./stack.js";
@@ -21,19 +21,20 @@ import { bannerWarnings } from "./turri-versions.js";
21
21
  import { CONFORMANCE_OFF_REFUSAL, conformanceBlock, conformanceTestsOn, conformanceTestsOnIn, turnOnConformanceTests } from "./conformance-switch.js";
22
22
  import { BACKGROUND_NOTE, doneLine, failedTask, ownChanges, runDetails, skillRunDelivery, startedText } from "./background-skills.js";
23
23
  import { createAskUserTool } from "./tools.js";
24
- import { asksFromScratch, asksWholeChain, driftTool, endWait, fromWorkingDir, haltTool, loopReply, startWait, toldByWaitingCall, MODEL_PARAM, regenerateTool, STACK_PARAM, stopJob, WAIT_PARAM, withCallStack, WORKING_DIR_PARAM } from "./loop-tools.js";
24
+ import { asksFromScratch, asksWholeChain, driftTool, endWait, fromWorkingDir, haltLaunched, haltTool, loopReply, startWait, toldByWaitingCall, MODEL_PARAM, regenerateTool, stopJob, WAIT_PARAM, whenBuildable, WORKING_DIR_PARAM } from "./loop-tools.js";
25
25
  import { createWebTools } from "./regenerate/web.js";
26
26
  import { describeGates, interruptedRun, runSkill } from "./genome.js";
27
27
  import { unqueue } from "./chat-waiting.js";
28
28
  import { skillStatus } from "./skill.js";
29
- import { runningDeployed, stopDeployed } from "./regenerate/release.js";
30
- import { createDeployState, createDeployTools, currentRelease } from "./release-tools.js";
29
+ import { runningLaunched, stopLaunched } from "./regenerate/launch.js";
30
+ import { launchTool } from "./launch-tools.js";
31
+ import { createSessionLaunches, launchedDir, launchedNote, replacedNote } from "./launch-session.js";
32
+ import { describeLaunchLine } from "./launch-track.js";
31
33
  import { checkedSpecs } from "./sentinel-check.js";
32
- import { runReleaseAgent } from "./release-agent.js";
33
34
  import { createSteeringStore, EVERY_MODULE, moduleNameOf, queueSectionOf, steeringFor } from "./regenerate/steer.js";
34
35
  import { askedForCommandLine, refusal, selfInvocation, TOOLS_NOT_CLI } from "./self-invocation.js";
35
36
  import { NEW_PROJECT } from "./new-project.js";
36
- import { describeChoices, describeResolution, modelFor, resolveModel } from "./regenerate/engine.js";
37
+ import { describeResolution, resolveModel } from "./regenerate/model-names.js";
37
38
  import { checkPlainFile, formatCheckResults } from "./plain/check.js";
38
39
  import { checkPlainTool } from "./parse-tool.js";
39
40
  import { changedFiles, projectFiles } from "./plain-files.js";
@@ -61,15 +62,14 @@ import { doctorTool } from "./doctor-tool.js";
61
62
  import { describeSpecConflict } from "./regenerate/stop-report.js";
62
63
  import { inheritProviders, inheritThinkingLevel } from "./pi.js";
63
64
  import { LOADING_PROVIDERS } from "./installed-providers.js";
64
- import { machineChange, machineChangeReason, writesPlain } from "./regenerate/command-check.js";
65
+ import { machineChange, machineChangeReason, runsBuiltCode, writesPlain } from "./regenerate/command-check.js";
65
66
  import { beginCapture, captureConsole, describeCaptured, dropNoise } from "./quiet.js";
66
67
  import { loadRules, renderRulesBlock } from "./rules.js";
67
- import { registerTurriConfig, ruleNames } from "./config-command.js";
68
+ import { registerSettings, ruleNames } from "./settings.js";
68
69
  import { writeSetting } from "./config-edit.js";
69
70
  import { describeStdlib } from "./stdlib.js";
70
71
  import { DECLINED, peekKeyListener, runAsk } from "./ask.js";
71
72
  import { QuestionDialog } from "./question-dialog.js";
72
- import { registerStacks } from "./stacks.js";
73
73
  import { catalogueLine, chosenCommand, createCommandGate, startPicked, discoverSkills, leftOutNote, startedByCommandOnly } from "./skills.js";
74
74
  import { supersededByTurri } from "./chat-skills.js";
75
75
  import { conversationIdentity } from "./identity.js";
@@ -337,8 +337,27 @@ export function createTurriCore(host = {}, options = {}) {
337
337
  core?.jobFinished(job);
338
338
  },
339
339
  });
340
+ // The session's launches (docs/launch.md): a codebase's one at a time, the newest commit winning, on the coding model
341
+ // of the codebase - and what the sentinel waits on of them.
342
+ const launches = createSessionLaunches({
343
+ cwd,
344
+ jobs,
345
+ model: (plainFile) => launchModel(workLoops.get(jobs)?.from.ctx, plainFile),
346
+ onChange: (launch) => {
347
+ core?.jobsChanged();
348
+ try {
349
+ host.onLaunch?.(launch);
350
+ }
351
+ catch {
352
+ /* a host that throws still has the launch in the track */
353
+ }
354
+ core?.launchChanged(launch);
355
+ },
356
+ });
357
+ sessionLaunches.set(jobs, launches);
340
358
  core = createChats({
341
359
  cwd,
360
+ launches,
342
361
  host,
343
362
  jobs,
344
363
  extension: (pi, link) => turriExtension(pi, core, link),
@@ -355,8 +374,6 @@ export function createTurriCore(host = {}, options = {}) {
355
374
  hosts.set(jobs, host);
356
375
  // What the model is told of where the person watches the work, deep in the tools too: the host's surface, or the terminal.
357
376
  setSurface(jobs, host.surface);
358
- // What release has shipped, module by module: release does nothing for a module whose last commit it already shipped.
359
- deployStates.set(jobs, createDeployState());
360
377
  // What this session does, as facts, in the project's .turri/ledger - a pulse's own in its project. Said once, in the
361
378
  // chat shown, when it cannot be written.
362
379
  if (ledgerWanted()) {
@@ -409,7 +426,7 @@ export function sessionLoop(session) {
409
426
  }
410
427
  /**
411
428
  * turri's extension, built into one chat of the session: its tools, commands and handlers run in the chat's scope -
412
- * its stack, its id on the pulses it asks for - on the session's job registry and work loop.
429
+ * its id on the pulses it asks for - on the session's job registry and work loop.
413
430
  */
414
431
  function turriExtension(api, session, link) {
415
432
  const pi = scopedToChat(api, link.scope);
@@ -445,7 +462,7 @@ function turriExtension(api, session, link) {
445
462
  // gets the full report as a hidden message that starts a turn of its own - at once when it is
446
463
  // idle, else as soon as the turn it is in ends (a follow-up, never cutting into a reply or an
447
464
  // interview) - so it reacts to every job that ends without waiting for the person to speak:
448
- // does what the project's guidance says to do then (release what was built, say), or says
465
+ // does what the project's guidance says to do then (launch what was built, say), or says
449
466
  // what finished. In the chat that asked for the pulse, shown or not.
450
467
  const announce = (job) => {
451
468
  announceJob(pi, job);
@@ -457,66 +474,59 @@ function turriExtension(api, session, link) {
457
474
  void pi.sendMessage({ customType: "turri_spec_conflict", content: specConflictTask(job.specConflict), display: false, details: { jobId: job.id } }, { triggerTurn: true });
458
475
  return;
459
476
  }
477
+ let launching = false;
478
+ try {
479
+ launching = readProjectConfig(cwd, job.configModule).launchAfterPulse === true;
480
+ }
481
+ catch {
482
+ /* a config that cannot be read launches nothing */
483
+ }
460
484
  void pi.sendMessage({
461
485
  customType: "turri_job",
462
- content: (job.status === "succeeded"
463
- ? `Pulse ${job.id} (${job.kind}) finished after ${formatDuration(job)}.\n\n${job.report ?? ""}`
464
- : job.status === "stopped"
465
- ? `Pulse ${job.id} (${job.kind}) was stopped after ${formatDuration(job)}. ${job.error ?? STOPPED_ON_REQUEST}${job.error === undefined || job.error === STOPPED_ON_REQUEST ? " The person stopped it; what it was building counts as not built." : ""}`
466
- : `Pulse ${job.id} (${job.kind}) failed after ${formatDuration(job)}.\n\n${job.error ?? ""}`) +
467
- `\n\n${JOB_FINISHED_REACTION}`,
486
+ content: pulseEndNote(job, { launching }),
468
487
  display: false,
469
488
  details: { jobId: job.id, status: job.status },
470
489
  }, { triggerTurn: true, deliverAs: "followUp" });
471
490
  };
472
491
  // The sentinel's: what a pulse that ended is, told to its agent in a conversation of its own for the pulse. The hidden
473
492
  // message is the conversation's first entry - a host splits the sentinel's work by pulse on it - so the pulse's end is
474
- // not drawn above it here: the person's chat shows it.
493
+ // not drawn above it here: the person's chat shows it. Told once what runs holds its commit (chats.ts readyFor).
475
494
  const brief = async (job, context) => {
476
- const config = readProjectConfig(cwd);
495
+ const launch = sessionLaunches.get(jobs)?.forPulse(job) ?? { later: [], laterSpecs: [], running: [] };
477
496
  const content = sentinelBrief(job, {
478
497
  project: cwd,
479
498
  ...(context.asked !== undefined ? { asked: context.asked } : {}),
480
499
  ...(context.focused !== undefined ? { focused: context.focused } : {}),
481
- released: runningDeployed(job.module),
482
- releaseAfterPulse: config.releaseAfterPulse === true,
500
+ launch,
483
501
  reaction: JOB_FINISHED_REACTION,
484
502
  });
485
503
  void pi.sendMessage({ customType: "turri_sentinel_pulse", content, display: false, details: { jobId: job.id, status: job.status } }, { triggerTurn: true });
486
504
  };
487
- // The sentinel's: functional specs a host asked it to check. The module is released first - as release-after-pulse
488
- // releases it - unless what runs is its own codebase's last commit; then told, in a conversation of its own for the
489
- // check, its hidden first message `turri_sentinel_check`. Why not, when the release failed: its agent is told nothing.
505
+ // The sentinel's: functional specs a host asked it to check, in what is launched of the module - told, in a
506
+ // conversation of its own for the check, its hidden first message `turri_sentinel_check`. It launches nothing.
490
507
  const briefCheck = async (check, context) => {
491
- const state = deployStates.get(jobs) ?? createDeployState();
492
- let releasedNow = false;
493
- if (currentRelease(state, check.plainFile, check.module) === undefined) {
494
- // Behind, never made, or what it started died: released afresh - the release tool would say it shipped that already.
495
- state.released.delete(check.module);
496
- let said;
497
- try {
498
- const ctx = contextNow();
499
- const model = ctx !== undefined ? releaseModel(ctx, check.plainFile) : undefined;
500
- said = await runReleaseAgent({ plainFile: check.plainFile, cwd, state, inModule: check.module, forCheck: { moduleName: check.module }, ...(model !== undefined ? { model } : {}) });
501
- }
502
- catch (error) {
503
- return error instanceof Error ? error.message : String(error);
504
- }
505
- if (currentRelease(state, check.plainFile, check.module) === undefined)
506
- return said.trim() || "its last commit was not released";
507
- releasedNow = true;
508
- }
509
- const commit = state.released.get(check.module)?.commit;
508
+ const current = sessionLaunches.get(jobs)?.track.current(check.module);
509
+ const commit = current?.short;
510
510
  const content = sentinelCheckBrief(check, {
511
511
  specs: checkedSpecs(check),
512
- released: runningDeployed(check.module),
513
- releasedNow,
512
+ running: runningLaunched(check.module),
514
513
  ...(commit !== undefined ? { commit } : {}),
514
+ ...(current?.status === "failed" ? { failed: { id: current.id, ...(current.summary !== undefined ? { summary: current.summary } : {}) } } : {}),
515
+ ...(current !== undefined ? { dir: launchedDir(current) } : {}),
515
516
  ...(context.focused !== undefined ? { focused: context.focused } : {}),
516
517
  });
517
518
  void pi.sendMessage({ customType: "turri_sentinel_check", content, display: false, details: { checkId: check.id, module: check.module, funcIds: check.funcIds } }, { triggerTurn: true });
518
- return undefined;
519
519
  };
520
+ // The sentinel's: its check carried on in the conversation it was in, once its codebase was launched again.
521
+ const resume = async (work) => {
522
+ const launches = sessionLaunches.get(jobs);
523
+ if (launches === undefined)
524
+ return;
525
+ const content = launches.resumeText(work);
526
+ void pi.sendMessage({ customType: "turri_sentinel_resume", content, display: false }, { triggerTurn: true });
527
+ };
528
+ // A launch this chat is to hear of ended: its agent told how it went, to tell the person.
529
+ const launched = (launch) => tellLaunch(pi, jobs, launch);
520
530
  // A pulse ended, with the sentinel on: said in the chat. One that landed is told to its agent too, to tell the person
521
531
  // it landed and what the sentinel does with it - and nothing more: the pulse is the sentinel's. ***plain that
522
532
  // contradicts itself is put to the person at once, by turri itself, as the chat would have been started on it.
@@ -528,7 +538,14 @@ function turriExtension(api, session, link) {
528
538
  return;
529
539
  // A host that shows the person the pulse's end itself: the chat knows of it - in order, with no turn of its own.
530
540
  const shown = host.pulseEndsShown === true;
531
- void pi.sendMessage({ customType: "turri_job_landed", content: landedNote(job, runningDeployed(job.module), { shown }), display: false, details: { jobId: job.id, status: job.status } }, shown ? { triggerTurn: false } : { triggerTurn: true, deliverAs: "followUp" });
541
+ let launching = false;
542
+ try {
543
+ launching = readProjectConfig(cwd, job.configModule).launchAfterPulse === true;
544
+ }
545
+ catch {
546
+ /* a config that cannot be read launches nothing */
547
+ }
548
+ void pi.sendMessage({ customType: "turri_job_landed", content: landedNote(job, { shown, launching }), display: false, details: { jobId: job.id, status: job.status } }, shown ? { triggerTurn: false } : { triggerTurn: true, deliverAs: "followUp" });
532
549
  };
533
550
  const notices = noticeDialogs(pi, session, link, contextNow);
534
551
  link.live({
@@ -536,6 +553,8 @@ function turriExtension(api, session, link) {
536
553
  landed,
537
554
  brief,
538
555
  briefCheck,
556
+ resume,
557
+ launched,
539
558
  notice: notices.put,
540
559
  noticeOver: notices.over,
541
560
  concluded: notices.concluded,
@@ -557,7 +576,7 @@ function turriExtension(api, session, link) {
557
576
  // With them, the instruction to do turri's work with its tools rather than its command
558
577
  // line - enforced below, not only asked for.
559
578
  const rules = loadRules(join(PACKAGE_ROOT, "genome", "rules"), readProjectConfig(cwd).rulesOff ?? []);
560
- // Laid out again once rules-off changes - /turri-config changes it as turri runs - and the same block in between.
579
+ // Laid out again once rules-off changes - /settings changes it as turri runs - and the same block in between.
561
580
  let rulesKept = { off: (readProjectConfig(cwd).rulesOff ?? []).join(","), block: chatRulesBlock(rules) };
562
581
  const rulesBlock = () => {
563
582
  const off = readProjectConfig(cwd).rulesOff ?? [];
@@ -633,6 +652,14 @@ function turriExtension(api, session, link) {
633
652
  const plain = isSentinel ? writesPlain(command) : undefined;
634
653
  if (plain !== undefined)
635
654
  return { block: true, reason: `${plain} is ***plain: the sentinel never changes it - put what it needs to the person with notify_person.` };
655
+ // Nor does a host's terminal start the code in plain_modules for it: what it tests is what is launched.
656
+ const built = isSentinel && event.toolName !== "bash" ? runsBuiltCode(command) : undefined;
657
+ if (built !== undefined) {
658
+ return {
659
+ block: true,
660
+ reason: `${built} is in plain_modules - the code a pulse may be writing, which nobody launched: the sentinel never runs it, nor starts a server of its own. Test what is launched, from where its brief says; a server that should run and does not is your finding.`,
661
+ };
662
+ }
636
663
  }
637
664
  if (event.toolName === "bash" && typeof command === "string") {
638
665
  const what = selfInvocation(command);
@@ -717,11 +744,9 @@ function turriExtension(api, session, link) {
717
744
  registerRegenerate(pi, cwd, jobs);
718
745
  registerDrift(pi, cwd, jobs);
719
746
  registerBind(pi, cwd, jobs, (plainFile) => turnOnConformance(session, plainFile));
720
- registerRenderModels(pi);
721
- registerDeploy(pi, cwd, jobs, deployStates.get(jobs) ?? createDeployState());
747
+ registerLaunch(pi, cwd, jobs);
722
748
  registerSteering(pi, cwd);
723
749
  registerSideQuestions(pi, cwd, jobs);
724
- registerStacks(pi, cwd);
725
750
  // More chats beside this one, in the terminal: /chat, alt+n, alt+1…9 (chat-commands.ts).
726
751
  if (session.terminal)
727
752
  registerChats(pi, session);
@@ -753,17 +778,17 @@ function turriExtension(api, session, link) {
753
778
  if (backgroundSkillRuns.has(key)) {
754
779
  return { text: `${skill.name} is running in the background already; what it does comes back to this chat when it ends. Nothing new was started.`, details: { background: true, started: false } };
755
780
  }
756
- const model = skill.model === "coding" ? jobModel(ctx, "spec_changes", undefined, plainFile) : conversationModel(ctx);
757
- const stack = plainFile !== undefined ? stackForModule(plainFile) : chosenStack();
781
+ const model = skill.model === "coding" ? jobModel(ctx, undefined, plainFile) : conversationModel(ctx);
782
+ const configModule = plainFile !== undefined ? configModuleFor(plainFile) : undefined;
758
783
  const kind = scriptKindOfSkill(skill.name);
759
784
  const shown = plainFile !== undefined ? relative(cwd, plainFile) || basename(plainFile) : undefined;
760
785
  // While it writes a testing script, the modules that need it wait for it rather than fail for want of it.
761
- const written = kind !== undefined ? writingScript({ project: plainFile !== undefined ? projectDirOf(plainFile) : cwd, kind, ...(stack !== undefined ? { stack } : {}) }) : () => { };
786
+ const written = kind !== undefined ? writingScript({ project: plainFile !== undefined ? projectDirOf(plainFile) : cwd, kind, ...(configModule !== undefined ? { configModule } : {}) }) : () => { };
762
787
  const controller = new AbortController();
763
788
  backgroundSkillRuns.set(key, controller);
764
789
  const context = [
765
790
  conversationContext(ctx, params.context),
766
- shown !== undefined ? `It is for ${shown}${stack !== undefined ? `, on the stack ${stack}` : ""}.` : undefined,
791
+ shown !== undefined ? `It is for ${shown}${configModule !== undefined ? `, built with ${moduleConfigFile(configModule)} over ${CONFIG_FILE}` : ""}.` : undefined,
767
792
  BACKGROUND_NOTE,
768
793
  ]
769
794
  .filter((part) => part !== undefined && part.trim() !== "")
@@ -775,7 +800,7 @@ function turriExtension(api, session, link) {
775
800
  const end = (ended) => skillRunEnds.put(ended.ok
776
801
  ? { skill: skill.name, ok: true, line: doneLine(skill.name, ended.changed, kind), ...about }
777
802
  : { skill: skill.name, ok: false, line: `${skill.name} ${ended.why}.`, task: failedTask(skill.name, ended.why, ended.output, kind), ...about });
778
- void captureConsole(() => withStack(stack, () => runSkill({
803
+ void captureConsole(() => withConfigModule(configModule, () => runSkill({
779
804
  skillDir: skill.dir,
780
805
  signal: controller.signal,
781
806
  cwd,
@@ -847,7 +872,7 @@ function turriExtension(api, session, link) {
847
872
  description: "Start a new run even though an interrupted one exists here, discarding it.",
848
873
  })),
849
874
  plainFile: Type.Optional(Type.String({
850
- description: "The module the skill's work is for - its .plain file, e.g. backend.plain: a testing script is written for that module's stack, " +
875
+ description: "The module the skill's work is for - its .plain file, e.g. backend.plain: a testing script is written for that module, named in its config, " +
851
876
  "on its coding model. Omitted: the project's.",
852
877
  })),
853
878
  }),
@@ -994,7 +1019,7 @@ function turriExtension(api, session, link) {
994
1019
  },
995
1020
  };
996
1021
  // What the run changes in the project's ***plain - its specs, resources, scripts - is said with its result: a skill
997
- // that writes nothing is not taken for one that did its work. Only those: a release or a running app changes other
1022
+ // that writes nothing is not taken for one that did its work. Only those: a launch or a running app changes other
998
1023
  // files while it runs, and they are not its doing.
999
1024
  const filesBefore = projectFiles(cwd);
1000
1025
  // A side question asked while it runs is told what it has done so far.
@@ -1002,8 +1027,8 @@ function turriExtension(api, session, link) {
1002
1027
  // A testing script being written - here to its end, in print mode - holds the modules it is for, as in the background:
1003
1028
  // a pulse started meanwhile, by a regenerate called beside it, would run against the script as it was.
1004
1029
  const kind = scriptKindOfSkill(skill.name);
1005
- const stack = plainFile !== undefined ? stackForModule(plainFile) : chosenStack();
1006
- const written = kind !== undefined ? writingScript({ project: plainFile !== undefined ? projectDirOf(plainFile) : cwd, kind, ...(stack !== undefined ? { stack } : {}) }) : () => { };
1030
+ const configModule = plainFile !== undefined ? configModuleFor(plainFile) : undefined;
1031
+ const written = kind !== undefined ? writingScript({ project: plainFile !== undefined ? projectDirOf(plainFile) : cwd, kind, ...(configModule !== undefined ? { configModule } : {}) }) : () => { };
1007
1032
  const ended = () => {
1008
1033
  written();
1009
1034
  ran_();
@@ -1026,20 +1051,20 @@ function turriExtension(api, session, link) {
1026
1051
  push(` A: ${answer}`);
1027
1052
  recordExchange(pi, { skill: skill.name, question, answer, ...(said !== undefined && said.trim() !== "" ? { said: said.trim() } : {}) });
1028
1053
  }, (question) => askOnTheSide(pi, ctx, cwd, jobs, question), dialogs),
1029
- model: skill.model === "coding" ? jobModel(ctx, "spec_changes", undefined, plainFile) : conversationModel(ctx),
1054
+ model: skill.model === "coding" ? jobModel(ctx, undefined, plainFile) : conversationModel(ctx),
1030
1055
  // Renders queued by a step land in the same registry as everything else, so
1031
1056
  // pulses sees them without knowing a skill started them.
1032
1057
  // Asked per job as it is queued, so a model chosen mid-interview applies from then on.
1033
1058
  renderQueue: workLoopFor(jobs, cwd, ctx),
1034
1059
  // The person answers the skill's agent while it runs, so it can take "render these with ..." too.
1035
1060
  // parse too: a skill parses what it wrote with the same check the conversation has.
1036
- sharedTools: [setRenderModelTool(pi, ctx), checkPlainTool(cwd), ...createWebTools()],
1061
+ sharedTools: [checkPlainTool(cwd), ...createWebTools()],
1037
1062
  // The conversation's own regenerate, drift, halt and conform, on its loop: a skill waits for nothing, and regenerates on the model chosen.
1038
1063
  loopTools: [
1039
- regenerateTool({ cwd, jobs, loop: () => workLoopFor(jobs, cwd, ctx), model: (_skill, plainFile, named, work) => jobModel(ctx, work ?? "spec_changes", named, plainFile), wait: () => false }),
1064
+ regenerateTool({ cwd, jobs, loop: () => workLoopFor(jobs, cwd, ctx), model: (_skill, plainFile, named) => jobModel(ctx, named, plainFile), wait: () => false }),
1040
1065
  driftTool({ cwd, jobs, loop: () => workLoopFor(jobs, cwd, ctx) }),
1041
- haltTool({ jobs, workLoop: () => workLoops.get(jobs)?.loop }),
1042
- conformTool({ cwd, jobs, loop: () => workLoopFor(jobs, cwd, ctx), model: (_skill, plainFile, named) => jobModel(ctx, "spec_changes", named, plainFile), wait: () => false }),
1066
+ haltTool({ jobs, workLoop: () => workLoops.get(jobs)?.loop, ...(sessionLaunches.get(jobs) !== undefined ? { launches: sessionLaunches.get(jobs).track } : {}) }),
1067
+ conformTool({ cwd, jobs, loop: () => workLoopFor(jobs, cwd, ctx), model: (_skill, plainFile, named) => jobModel(ctx, named, plainFile), wait: () => false }),
1043
1068
  ],
1044
1069
  // The escalation becomes a real dialog - the host's own, when it has them. Without one there is nobody to ask,
1045
1070
  // so the gate stands.
@@ -1127,7 +1152,7 @@ function registerRegenerate(pi, cwd, jobs) {
1127
1152
  cwd,
1128
1153
  jobs,
1129
1154
  loop: (ctx) => workLoopFor(jobs, cwd, ctx),
1130
- model: (ctx, plainFile, named, work) => jobModel(ctx, work ?? "spec_changes", named, plainFile),
1155
+ model: (ctx, plainFile, named) => jobModel(ctx, named, plainFile),
1131
1156
  wait: (ctx, asked) => shouldWait(ctx.mode, asked),
1132
1157
  }));
1133
1158
  // /regenerate: the same as the tool, from the person - a module brought up to its spec as it is now, cut into pulses
@@ -1156,7 +1181,7 @@ function registerRegenerate(pi, cwd, jobs) {
1156
1181
  return;
1157
1182
  }
1158
1183
  const loop = workLoopFor(jobs, cwd, ctx);
1159
- const model = jobModel(ctx, again.length > 0 ? "functionalities" : "spec_changes", undefined, plainFile);
1184
+ const model = jobModel(ctx, undefined, plainFile);
1160
1185
  const request = { ...(model !== undefined ? { model } : {}), ...(guidance !== "" ? { guidance } : {}) };
1161
1186
  // Said at once, and kept in the chat: what follows takes a while - the planner is an agent - and the person sees it
1162
1187
  // began, not a chat that stays empty until the first pulse starts. The plan is said under it once it is made.
@@ -1171,8 +1196,8 @@ function registerRegenerate(pi, cwd, jobs) {
1171
1196
  const target = plainFile;
1172
1197
  void (async () => {
1173
1198
  try {
1174
- // Built with the stack chosen now - pinned to its pulses - or refused, a project of stacks built with none.
1175
- const statuses = await withCallStack(target, undefined, () => scratch
1199
+ // Refused when its config cannot be told, or would build it with no testing script.
1200
+ const statuses = await whenBuildable(target, () => scratch
1176
1201
  ? loop.fromScratch(target, { ...request, chain })
1177
1202
  : again.length > 0
1178
1203
  ? loop.regenerateAgain(target, again, request)
@@ -1272,7 +1297,7 @@ echoed = false, react) {
1272
1297
  */
1273
1298
  export const COMMAND_STARTED_REACTION = "My pulses are running from the person's command, in the background. Tell the person, in a line or two, what " +
1274
1299
  "runs and what is planned - and that the two of us can go on with the ***plain, or anything else, meanwhile: they need " +
1275
- "not wait for it. Start nothing for it: no regenerate, no check, no release - its end is told when it comes.";
1300
+ "not wait for it. Start nothing for it: no regenerate, no check, no launch - its end is told when it comes.";
1276
1301
  /**
1277
1302
  * What the agent does when /conform started nothing: answers it at once - why, and what would let it start - and offers
1278
1303
  * to do that, rather than leave the person with a refusal and a silent chat.
@@ -1338,7 +1363,7 @@ function registerBind(pi, cwd, jobs, turnOn) {
1338
1363
  cwd,
1339
1364
  jobs,
1340
1365
  loop: (ctx) => workLoopFor(jobs, cwd, ctx),
1341
- model: (ctx, plainFile, named) => jobModel(ctx, "spec_changes", named, plainFile),
1366
+ model: (ctx, plainFile, named) => jobModel(ctx, named, plainFile),
1342
1367
  wait: (ctx, asked) => shouldWait(ctx.mode, asked),
1343
1368
  }));
1344
1369
  // /conform: the same as the tool, from the person - a module's conformance tests written and run now, for the
@@ -1388,7 +1413,7 @@ function registerBind(pi, cwd, jobs, turnOn) {
1388
1413
  // ***plain alone, before anything is said.
1389
1414
  let refusal;
1390
1415
  try {
1391
- refusal = withCallStack(plainFile, undefined, () => conformanceRefusal(plainFile, funcIds.length > 0 ? funcIds : undefined));
1416
+ refusal = whenBuildable(plainFile, () => conformanceRefusal(plainFile, funcIds.length > 0 ? funcIds : undefined));
1392
1417
  }
1393
1418
  catch (error) {
1394
1419
  refusal = error instanceof Error ? error.message : String(error);
@@ -1398,7 +1423,7 @@ function registerBind(pi, cwd, jobs, turnOn) {
1398
1423
  return;
1399
1424
  }
1400
1425
  const module = basename(plainFile).replace(/\.plain$/, "");
1401
- const model = jobModel(ctx, "spec_changes", undefined, plainFile);
1426
+ const model = jobModel(ctx, undefined, plainFile);
1402
1427
  const starting = scratch !== undefined
1403
1428
  ? `Writing ${module}'s conformance tests${scratch === "chain" ? " and its whole chain's" : ""} again from scratch…`
1404
1429
  : `Starting ${funcIds.length > 0 ? `the conformance tests of ${funcIds.join(", ")}` : `${module}'s conformance tests`}…`;
@@ -1407,7 +1432,7 @@ function registerBind(pi, cwd, jobs, turnOn) {
1407
1432
  // In the background, as /regenerate: a codebase built on the module may be stopped and deleted first.
1408
1433
  void (async () => {
1409
1434
  try {
1410
- const statuses = await withCallStack(plainFile, undefined, () => workLoopFor(jobs, cwd, ctx).conformance(plainFile, {
1435
+ const statuses = await whenBuildable(plainFile, () => workLoopFor(jobs, cwd, ctx).conformance(plainFile, {
1411
1436
  ...(funcIds.length > 0 ? { funcIds } : {}),
1412
1437
  ...(model !== undefined ? { model } : {}),
1413
1438
  ...(separately ? { separately: true } : {}),
@@ -1449,7 +1474,7 @@ function conformTool(options) {
1449
1474
  "the tip of each chain it is built in, as regenerate from scratch does its code. A " +
1450
1475
  "functional spec with no scenarios - no test plain file - is refused: there is nothing to test until scenarios " +
1451
1476
  "are written. So is one the spec does not have, and a module with scenarios that skipped a step of adding tests - " +
1452
- "no test reqs, or no conformance testing script for its stack: the refusal names the next step. While conformance tests " +
1477
+ "no test reqs, or no conformance testing script: the refusal names the next step. While conformance tests " +
1453
1478
  "are off it is refused too: they make each change take about twice as long, and turning them on is the person's - " +
1454
1479
  "with /conform - never yours.",
1455
1480
  promptSnippet: "conform: write and run the conformance tests of functional specs with scenarios",
@@ -1472,7 +1497,6 @@ function conformTool(options) {
1472
1497
  '"chain": written again from nothing - every functional spec of the chain\'s tests',
1473
1498
  })),
1474
1499
  one_by_one: Type.Optional(Type.Boolean({ description: "Only when the user asks for it: a pulse a functional spec. Omitted: every functional spec tested in one pulse, as far as the size guardrail lets" })),
1475
- stack: STACK_PARAM,
1476
1500
  model: MODEL_PARAM,
1477
1501
  wait: WAIT_PARAM,
1478
1502
  }),
@@ -1480,7 +1504,7 @@ function conformTool(options) {
1480
1504
  const params = fromWorkingDir(cwd, given);
1481
1505
  const plainFile = resolve(params.base, params.plain_file);
1482
1506
  refuseTestPlainFile(plainFile);
1483
- return withCallStack(plainFile, params.stack, async () => {
1507
+ return whenBuildable(plainFile, async () => {
1484
1508
  // Off: the person's to turn on, never the chat's - it is told to say why it wants them, and they decide.
1485
1509
  if (!conformanceTestsOn(plainFile))
1486
1510
  return { content: [{ type: "text", text: CONFORMANCE_OFF_REFUSAL }], details: { refused: true } };
@@ -1507,9 +1531,9 @@ function conformTool(options) {
1507
1531
  },
1508
1532
  });
1509
1533
  }
1510
- /** The config a spec is built with - its project's, with the chosen stack's over it - or, with no spec, the session folder's. */
1534
+ /** The config a spec is built with - its project's, with its module's own file over it - or, with no spec, the session folder's. */
1511
1535
  function configOf(plainFile) {
1512
- return plainFile !== undefined ? configForSpec(resolve(process.cwd(), plainFile)) : readProjectConfig(process.cwd(), stackOf(process.cwd()));
1536
+ return plainFile !== undefined ? configForSpec(resolve(process.cwd(), plainFile)) : readProjectConfig(process.cwd(), configModuleOf(process.cwd()));
1513
1537
  }
1514
1538
  /**
1515
1539
  * How many jobs the chat runs at once: `parallel-jobs:` in the session folder's config.turri.yaml - the only place it
@@ -1619,74 +1643,77 @@ export function projectConfigBlock(root) {
1619
1643
  if (projects.length === 0)
1620
1644
  return "";
1621
1645
  const describe = (dir) => {
1622
- const stacks = stacksOf(dir);
1623
- const chosen = stackOf(dir);
1646
+ const modules = moduleConfigsOf(dir);
1624
1647
  const where = dir === root ? "" : ` (paths relative to ${relative(root, dir)}/)`;
1625
1648
  const at = (name) => (dir === root ? name : `${relative(root, dir)}/${name}`);
1626
1649
  return [
1627
- ...settings(readProjectConfig(dir), withStack(undefined, () => findTestScripts(dir)), dir === root ? `${projectConfigFile(dir)}, for the specs here:` : `${relative(root, dir)}/${projectConfigFile(dir)}, for the specs in ${relative(root, dir)}/ - built in ${relative(root, dir)}/plain_modules:`, where, stacks.length > 0 ? "project of stacks" : "project"),
1628
- ...(stacks.length > 0
1629
- ? ["", `Stacks: ${stacks.join(", ")} - chosen now: ${chosen ?? "none, so the project's file alone"}. Each module is built with the stack of its part, pinned to its pulses whatever is chosen after: a stack named after the module is its own - backend.plain is built with config.turri.backend.yaml - with nothing to choose. For a module whose stack has another name, pass it as stack to regenerate, conform and pulses. Choose one for this chat with the stack tool only when the user asks.`]
1630
- : []),
1631
- // A stack: its file over the project's, for everything built while it is chosen.
1632
- ...stacks.flatMap((stack) => [
1650
+ ...settings(readProjectConfig(dir), withConfigModule(undefined, () => findTestScripts(dir)), dir === root ? `${projectConfigFile(dir)}, for the specs here:` : `${relative(root, dir)}/${projectConfigFile(dir)}, for the specs in ${relative(root, dir)}/ - built in ${relative(root, dir)}/plain_modules:`, where, modules.length > 0 ? "project of module files" : "project"),
1651
+ // A module's own file: over the project's, for it and every module built on it that has no file of its own.
1652
+ ...modules.flatMap((module) => [
1633
1653
  "",
1634
- ...settings(readProjectConfig(dir, stack), withStack(stack, () => findTestScripts(dir)), `${at(stackConfigFileIn(dir, stack))}, over ${projectConfigFile(dir)}, for everything built while the stack ${stack} is chosen${chosen === stack ? " - as it is now" : ""}:`, where, "stack"),
1654
+ ...settings(readProjectConfig(dir, module), withConfigModule(module, () => findTestScripts(dir)), `${at(moduleConfigFileIn(dir, module))}, over ${projectConfigFile(dir)}, for ${module}.plain and every module built on it that has no file of its own - what it sets itself, and the testing scripts it builds with; the rest is ${projectConfigFile(dir)}'s:`, where, "module", readConfigFile(join(dir, moduleConfigFileIn(dir, module)))),
1635
1655
  ]),
1636
1656
  ];
1637
1657
  };
1638
1658
  const settings = (config, scripts, heading, where,
1639
- /** The project's file, and whether it has stacks - whose scripts are theirs - or a stack's. */
1640
- of) => {
1641
- const perModule = of === "project of stacks";
1659
+ /** The project's file, and whether modules have files of their own - whose scripts are theirs - or a module's. */
1660
+ of,
1661
+ /** A module's file as written: only what it sets itself is said - an inherited setting said again reads as its own. */
1662
+ own) => {
1663
+ const perModule = of === "project of module files";
1664
+ const sets = (set) => own === undefined || set;
1642
1665
  return [
1643
1666
  heading,
1644
1667
  ...[
1645
- config.module !== undefined && of !== "stack" ? `- module: ${config.module}${where} - the module to build when the user does not name one.` : undefined,
1646
- of !== "stack"
1668
+ config.module !== undefined && of !== "module" ? `- module: ${config.module}${where} - the module to build when the user does not name one.` : undefined,
1669
+ of !== "module"
1647
1670
  ? "- conformance tests: written for every functional spec with scenarios - the conformance and acceptance scenarios of its test plain file - once the module's code is built, before anything is built on it. A functional spec with an empty test plain file is not tested. To have one tested, write its scenarios with the file tools, then call regenerate."
1648
1671
  : undefined,
1649
- config.review === true
1650
- ? "- review: true - the code and its tests are reviewed once they pass: two reviews at most, the arbiter weighing the second."
1651
- : `- review: ${config.review === false ? "false" : "not set, so off"} - the code and its tests are not reviewed: a pulse lands once its tests pass.`,
1672
+ !sets(own?.review !== undefined)
1673
+ ? undefined
1674
+ : config.review === true
1675
+ ? "- review: true - the code and its tests are reviewed once they pass: two reviews at most, the arbiter weighing the second."
1676
+ : `- review: ${config.review === false ? "false" : "not set, so off"} - the code and its tests are not reviewed: a pulse lands once its tests pass.`,
1652
1677
  ...(() => {
1653
1678
  // Each as it holds, with what it inherits: judge from coding, coding from harness.
1654
1679
  const models = projectModels(config);
1655
1680
  const shown = (choice) => modelSpec(choice) ?? "";
1656
1681
  return [
1657
- models.coding !== undefined ? `- coding-model: ${shown(models.coding)}${config.codingModel === undefined ? " (from harness-model)" : ""} - what renders run on, unless engine chose another in this session.` : undefined,
1658
- models.judge !== undefined ? `- judge-model: ${shown(models.judge)}${config.judgeModel === undefined ? " (from coding-model)" : ""} - the judge and the test review in a conformance run.` : undefined,
1659
- models.harness !== undefined && of !== "stack" ? `- harness-model: ${shown(models.harness)} - the model you start with.` : undefined,
1682
+ models.coding !== undefined && sets(own?.codingModel !== undefined || own?.models?.coding !== undefined || own?.models?.default !== undefined) ? `- coding-model: ${shown(models.coding)}${config.codingModel === undefined ? " (from harness-model)" : ""} - what pulses run on, unless a call names another model.` : undefined,
1683
+ models.judge !== undefined && sets(own?.judgeModel !== undefined || own?.models?.judge !== undefined) ? `- judge-model: ${shown(models.judge)}${config.judgeModel === undefined ? " (from coding-model)" : ""} - the judge and the test review in a conformance run.` : undefined,
1684
+ models.harness !== undefined && of !== "module" ? `- harness-model: ${shown(models.harness)} - the model you start with.` : undefined,
1660
1685
  // The other roles' own, where models: names them.
1661
1686
  ...AGENT_ROLES.filter((role) => role !== "coding" && role !== "chat").flatMap((role) => {
1662
- const own = roleModel(config, role);
1663
- return own !== undefined ? [`- models: ${role}: ${shown(own)}`] : [];
1687
+ const named = roleModel(config, role);
1688
+ return named !== undefined && sets(own?.models?.[role] !== undefined) ? [`- models: ${role}: ${shown(named)}`] : [];
1664
1689
  }),
1665
1690
  ...(() => {
1666
1691
  const limits = AGENT_ROLES.flatMap((role) => (config.models?.[role]?.turnLimit !== undefined ? [`${role} ${config.models[role].turnLimit}s`] : []));
1667
1692
  const all = config.models?.default?.turnLimit ?? config.turnLimit;
1668
- return all !== undefined || limits.length > 0 ? [`- turn limits: ${all !== undefined ? `${all}s each` : "two minutes each"}${limits.length > 0 ? `; ${limits.join(", ")}` : ""}.`] : [];
1693
+ return (all !== undefined || limits.length > 0) && sets(own?.turnLimit !== undefined || own?.models !== undefined) ? [`- turn limits: ${all !== undefined ? `${all}s each` : "two minutes each"}${limits.length > 0 ? `; ${limits.join(", ")}` : ""}.`] : [];
1669
1694
  })(),
1670
1695
  ];
1671
1696
  })(),
1672
- `- unit testing script: ${scripts.unit !== undefined ? relative(root, scripts.unit) : perModule ? "none for the whole project - each stack's file below names its own" : "none found - every build stops until there is one"}`,
1673
- `- conformance testing script: ${scripts.conformance !== undefined ? relative(root, scripts.conformance) : perModule ? "none for the whole project - see each stack's file" : "none found"}`,
1697
+ `- unit testing script: ${scripts.unit !== undefined ? relative(root, scripts.unit) : perModule ? "none for the whole project - each module's file below names its own" : "none found - every build stops until there is one"}`,
1698
+ `- conformance testing script: ${scripts.conformance !== undefined ? relative(root, scripts.conformance) : perModule ? "none for the whole project - see each module's file" : "none found"}`,
1674
1699
  scripts.prepare !== undefined ? `- prepare script: ${relative(root, scripts.prepare)} - run on the build before every conformance testing script run, which runs only once it passes` : undefined,
1675
- config.testingScriptsRunOn === "copy"
1676
- ? "- testing-scripts-run-on: copy - the testing scripts run on this machine, on a fresh copy of each module's code; `testing-scripts-run-on: in-place` (the default) runs them on the code in place."
1677
- : "- testing-scripts-run-on: in-place - the testing scripts run on this machine on the code in place, from the project, against the host codebase; `testing-scripts-run-on: copy` runs them on a fresh copy of each module's code.",
1700
+ !sets(own?.testingScriptsRunOn !== undefined)
1701
+ ? undefined
1702
+ : config.testingScriptsRunOn === "copy"
1703
+ ? "- testing-scripts-run-on: copy - the testing scripts run on this machine, on a fresh copy of each module's code; `testing-scripts-run-on: in-place` (the default) runs them on the code in place."
1704
+ : "- testing-scripts-run-on: in-place - the testing scripts run on this machine on the code in place, from the project, against the host codebase; `testing-scripts-run-on: copy` runs them on a fresh copy of each module's code.",
1678
1705
  ].filter((line) => line !== undefined),
1679
1706
  ];
1680
1707
  };
1681
1708
  return [
1682
1709
  `<project config>`,
1683
- `A project's ${CONFIG_FILE} sets how its specs are built - and a stack's config.turri.<stack>.yaml, over it, how everything is built`,
1684
- "while that stack is chosen: its testing scripts, toolchains, models and conformance - a backend and a frontend each with their own scripts.",
1685
- "One stack is chosen at a time, in each chat for that chat: the render tools follow the project's file with the chosen stack's over it;",
1686
- `a project with no ${CONFIG_FILE} yet is read from its ${LEGACY_CONFIG_FILE} (and config.<stack>.yaml): to change a setting there, copy`,
1687
- `${LEGACY_CONFIG_FILE} to ${CONFIG_FILE} - and each config.<stack>.yaml to config.turri.<stack>.yaml - first, then edit the copy; never edit ${LEGACY_CONFIG_FILE}.`,
1688
- "answer questions about the project's settings from it, and say when a render will differ from it because the user",
1689
- "asked. Name a spec by its path from here - plain/hubspot.plain - and it is built in its own project.",
1710
+ `A project's ${CONFIG_FILE} sets how its modules are built - and a module's own config.turri.<module>.yaml, over it, how that`,
1711
+ "module is built, and every module built on it that has no file of its own: its testing scripts, toolchains, models and conformance -",
1712
+ "a backend and a frontend each with their own scripts. Nobody chooses it: each module is built with its own file, else the one of",
1713
+ "a module it requires, else the project's alone - two among the modules it requires is an error to fix. A project with no",
1714
+ `${CONFIG_FILE} yet is read from its ${LEGACY_CONFIG_FILE} (and config.<module>.yaml). Change a setting with the settings tool,`,
1715
+ "never by editing these files; answer questions about the project's settings from what follows, and say when a pulse will",
1716
+ "differ from it because the user asked. Name a spec by its path from here - plain/hubspot.plain - and it is built in its own project.",
1690
1717
  ...projects.flatMap((dir) => ["", ...describe(dir)]),
1691
1718
  `</project config>`,
1692
1719
  ].join("\n");
@@ -1707,9 +1734,19 @@ function conversationModel(ctx, override) {
1707
1734
  * The chat's model, read now - it can change while a skill runs - or, from a context that has
1708
1735
  * gone stale since, the model it had when it was last readable.
1709
1736
  */
1710
- /** The model a release runs on - a pulse's last stage, and a check's: the one that regenerated the module. A release follows steps, and a small model thinking little does that well. */
1711
- function releaseModel(ctx, plainFile) {
1712
- return modelFor(chosenModels, "spec_changes", projectModel(ctx, plainFile) ?? chatModelOf(ctx));
1737
+ /**
1738
+ * The model a launch runs on: the coding model of the codebase - a launch follows steps, and a small model thinking little
1739
+ * does that well. Without a chat's context yet, the config's as it names it.
1740
+ */
1741
+ function launchModel(ctx, plainFile) {
1742
+ try {
1743
+ if (ctx !== undefined)
1744
+ return projectModel(ctx, plainFile) ?? chatModelOf(ctx);
1745
+ }
1746
+ catch {
1747
+ /* a name the chat cannot resolve: the config's, as it is */
1748
+ }
1749
+ return modelSpec(projectModels(configForSpec(plainFile)).coding);
1713
1750
  }
1714
1751
  function chatModelOf(ctx) {
1715
1752
  try {
@@ -1725,7 +1762,7 @@ let lastChatModel;
1725
1762
  /**
1726
1763
  * Conformance tests turned on, for the session: `conformance-tests: true` written where the module's value comes from
1727
1764
  * (conformance-switch.ts) - what /conform does when they are off, and a host's turnOnConformance. Every chat is told at
1728
- * its next turn. `plainFile`, absolute or from the project, picks the module whose stack's file
1765
+ * its next turn. `plainFile`, absolute or from the project, picks the module whose own file
1729
1766
  * is written when that names the key. Returns the file written, from the project. Starts no conformance pulse.
1730
1767
  */
1731
1768
  export function turnOnConformance(core, plainFile) {
@@ -1734,24 +1771,14 @@ export function turnOnConformance(core, plainFile) {
1734
1771
  }
1735
1772
  /** The skills running in the background, by project and skill - one at a time each, whichever chat started it - with what stops them. */
1736
1773
  const backgroundSkillRuns = new Map();
1737
- /** The models chosen in this session, by kind of work - for every chat. Saved in the chat they were chosen in, so reopening it keeps them. */
1738
- const chosenModels = {};
1739
- /** When they were last chosen: a chat reopened with older choices of its own leaves them be. */
1740
- let chosenModelsAt = 0;
1741
- const MODEL_CHOICE_ENTRY = "turri_render_models";
1742
1774
  /**
1743
- * The model a job's agents run on: the one named on the call, checked now so a wrong name fails
1744
- * here and not minutes later in the background; else the one chosen for its kind of work; else
1745
- * the conversation's.
1775
+ * The model a pulse's agents run on: the one named on the call, checked now so a wrong name fails here and not minutes
1776
+ * later in the background; else the coding model - `--coding-model`, or the module's config - else the conversation's.
1746
1777
  */
1747
- /**
1748
- * The model a render job runs on: the one asked for, or the one chosen in this session for its kind
1749
- * of work, or the project's - `model:` in config.turri.yaml - or the conversation's.
1750
- */
1751
- function jobModel(ctx, work, named, plainFile) {
1752
- const model = jobModelOf(ctx, work, named, plainFile);
1778
+ function jobModel(ctx, named, plainFile) {
1779
+ const model = jobModelOf(ctx, named, plainFile);
1753
1780
  // The AWS region worked out again, with every model a job ran on this session: the config's may have changed since,
1754
- // and one chosen in the session counts as the config's do - two needing two regions are said, not flipped between.
1781
+ // and one named on a call counts as the config's do - two needing two regions are said, not flipped between.
1755
1782
  if (model !== undefined)
1756
1783
  jobModels.add(model);
1757
1784
  applyBedrockRegion(plainFile !== undefined ? projectDirOf(plainFile) : process.cwd(), { also: [...jobModels] });
@@ -1759,14 +1786,14 @@ function jobModel(ctx, work, named, plainFile) {
1759
1786
  }
1760
1787
  /** Every model a job ran on in this session. */
1761
1788
  const jobModels = new Set();
1762
- function jobModelOf(ctx, work, named, plainFile) {
1789
+ function jobModelOf(ctx, named, plainFile) {
1763
1790
  if (named !== undefined && named.trim() !== "") {
1764
1791
  const resolved = resolveModel(named, ctx.modelRegistry);
1765
1792
  if (!resolved.ok)
1766
1793
  throw new Error(describeResolution(resolved));
1767
1794
  return resolved.model;
1768
1795
  }
1769
- return modelFor(chosenModels, work, projectModel(ctx, plainFile) ?? chatModelOf(ctx));
1796
+ return projectModel(ctx, plainFile) ?? chatModelOf(ctx);
1770
1797
  }
1771
1798
  /**
1772
1799
  * The coding model this session starts from, and where it was given: `turri
@@ -1799,107 +1826,6 @@ function projectModel(ctx, plainFile) {
1799
1826
  }
1800
1827
  return modelSpec({ model: resolved.model, thinking });
1801
1828
  }
1802
- /** The default coding model for showing, with where it came from - never an error. */
1803
- function projectModelLabel(ctx) {
1804
- const given = codingModelDefault();
1805
- if (given === undefined)
1806
- return undefined;
1807
- try {
1808
- return { model: projectModel(ctx), from: given.from };
1809
- }
1810
- catch {
1811
- return { model: `${given.named} - which cannot be used here`, from: given.from };
1812
- }
1813
- }
1814
- /**
1815
- * engine, for the conversation's agent and for a skill's agent - whom the person talks
1816
- * to while the skill runs - alike: both write the same choice. `conversation` is the context to
1817
- * read models and the chat's model from; omitted, the one the tool is called with.
1818
- */
1819
- function setRenderModelTool(pi, conversation) {
1820
- return defineTool({
1821
- name: "engine",
1822
- label: "Engine",
1823
- description: "The engine: which model the agents that regenerate the code run on. With no model, say which it is. With one, choose it " +
1824
- "for the rest of this session: for spec changes (every pulse the work loop plans, conformance tests included), for " +
1825
- "functionalities (regenerate with funcIds named), or for everything. By default " +
1826
- "each runs on the model the project's config.turri.yaml names, or else the conversation's model. The model may be given as provider/model-id or by name as " +
1827
- "the user said it; a name that fits more than one model, or none with credentials, comes back as a " +
1828
- "list - ask the user which they meant, never pick one yourself. Pulses already queued keep their model.",
1829
- promptSnippet: "the engine: show or choose the model that regenerates the code",
1830
- promptGuidelines: [
1831
- "When the user says which model should regenerate or build something, call engine with it - once; it holds for the rest of the session. To say which one it is, call engine with no model.",
1832
- "If engine returns several candidates, ask the user which one with ask_user or in your reply, then call it again with the exact provider/model-id.",
1833
- "Say which model a pulse will run on when you start one on something other than the conversation's model.",
1834
- ],
1835
- parameters: Type.Object({
1836
- work: Type.Optional(Type.Union([Type.Literal("spec_changes"), Type.Literal("functionalities"), Type.Literal("all")], {
1837
- description: "spec_changes, functionalities, or all of it. Omitted: all",
1838
- })),
1839
- model: Type.Optional(Type.String({
1840
- description: 'provider/model-id, or the model\'s name as the user said it. "chat" goes back to the conversation\'s model. Omitted: say which it is, changing nothing',
1841
- })),
1842
- }),
1843
- async execute(_id, given, _signal, _onUpdate, called) {
1844
- const ctx = conversation ?? called;
1845
- if (given.model === undefined) {
1846
- const text = `The engine:\n${describeChoices(chosenModels, chatModelOf(ctx), projectModelLabel(ctx))}`;
1847
- return { content: [{ type: "text", text }], details: { ...chosenModels } };
1848
- }
1849
- const params = { work: given.work ?? "all", model: given.model };
1850
- const works = params.work === "all" ? ["all", "spec_changes", "functionalities"] : [params.work];
1851
- if (/^(chat|default|conversation)$/i.test(params.model.trim())) {
1852
- for (const work of works)
1853
- delete chosenModels[work];
1854
- }
1855
- else {
1856
- const resolved = resolveModel(params.model, ctx.modelRegistry);
1857
- if (!resolved.ok)
1858
- throw new Error(describeResolution(resolved));
1859
- if (params.work === "all") {
1860
- delete chosenModels.spec_changes;
1861
- delete chosenModels.functionalities;
1862
- }
1863
- chosenModels[params.work] = resolved.model;
1864
- }
1865
- chosenModelsAt = Date.now();
1866
- pi.appendEntry(MODEL_CHOICE_ENTRY, { ...chosenModels });
1867
- const text = `The engine now:\n${describeChoices(chosenModels, chatModelOf(ctx), projectModelLabel(ctx))}`;
1868
- return { content: [{ type: "text", text }], details: { ...chosenModels } };
1869
- },
1870
- });
1871
- }
1872
- /** Choosing which model renders what, for the rest of the session. */
1873
- function registerRenderModels(pi) {
1874
- // The session's choices, every chat's: a chat reopened brings back what it chose, when that is newer than what the
1875
- // session has - and a fresh chat starts with the session's.
1876
- let started = false;
1877
- pi.on("session_start", (_event, ctx) => {
1878
- if (started)
1879
- return;
1880
- started = true;
1881
- const saved = ctx.sessionManager
1882
- .getBranch()
1883
- .filter((entry) => entry.type === "custom" && entry.customType === MODEL_CHOICE_ENTRY)
1884
- .at(-1);
1885
- const at = Date.parse(saved?.timestamp ?? "") || 1;
1886
- if (saved === undefined || at <= chosenModelsAt)
1887
- return;
1888
- chosenModelsAt = at;
1889
- for (const key of Object.keys(chosenModels))
1890
- delete chosenModels[key];
1891
- Object.assign(chosenModels, saved.data ?? {});
1892
- });
1893
- pi.registerTool(setRenderModelTool(pi));
1894
- pi.registerCommand("engine", {
1895
- description: "Show the engine: which model regenerates spec changes and functionalities. To change it, say so in the conversation.",
1896
- handler: async (_args, ctx) => {
1897
- const text = `The engine:\n${describeChoices(chosenModels, chatModelOf(ctx), projectModelLabel(ctx))}\n\nTo change it, say so - e.g. "regenerate spec changes with gpt 5.5".`;
1898
- if (ctx.hasUI)
1899
- ctx.ui.notify(text, "info");
1900
- },
1901
- });
1902
- }
1903
1829
  /**
1904
1830
  * Run the work now, or start it as a background job and hand back an id.
1905
1831
  *
@@ -1911,8 +1837,8 @@ function registerRenderModels(pi) {
1911
1837
  const workLoops = new WeakMap();
1912
1838
  /** How the conversation wants the work planned, for the session - set with steer. */
1913
1839
  const steeringStore = createSteeringStore();
1914
- /** What release has shipped in a conversation, by its jobs: shared by the chat's release and a pulse's own. */
1915
- const deployStates = new WeakMap();
1840
+ /** A session's launches, by its jobs: the launch track every chat's launch tool and every pulse's launch share. */
1841
+ const sessionLaunches = new WeakMap();
1916
1842
  function workLoopFor(jobs, cwd, ctx) {
1917
1843
  let shared = workLoops.get(jobs);
1918
1844
  if (shared === undefined) {
@@ -1920,24 +1846,14 @@ function workLoopFor(jobs, cwd, ctx) {
1920
1846
  const loop = createWorkLoop({
1921
1847
  registry: jobs,
1922
1848
  cwd,
1923
- modelFor: (plainFile) => modelFor(chosenModels, "spec_changes", projectModel(from.ctx, plainFile) ?? chatModelOf(from.ctx)),
1849
+ modelFor: (plainFile) => projectModel(from.ctx, plainFile) ?? chatModelOf(from.ctx),
1924
1850
  // The planner reasons about the whole of the work: it runs on the chat's model.
1925
1851
  plannerModel: () => chatModelOf(from.ctx),
1926
1852
  // How the work is to be planned: the conversation's steering, and AGENTS.md's - read afresh each plan.
1927
1853
  steering: (plainFile) => steeringFor(plainFile, cwd, steeringStore),
1928
- // Under release-after-pulse, a pulse releases what it landed itself, before the next starts - on the model that
1929
- // regenerated it: a release follows steps, and a small model thinking little does that well.
1930
- release: ({ plainFile, moduleName, title, onDelta }) => {
1931
- const model = releaseModel(from.ctx, plainFile);
1932
- return runReleaseAgent({
1933
- plainFile,
1934
- cwd,
1935
- state: deployStates.get(jobs) ?? createDeployState(),
1936
- afterPulse: { moduleName, subject: title },
1937
- onDelta,
1938
- ...(model !== undefined ? { model } : {}),
1939
- });
1940
- },
1854
+ // A pulse landed: its commit kept for the sentinel - and, under launch-after-pulse, launched in the background, the
1855
+ // codebase's next pulse not waiting on it.
1856
+ landed: (input) => sessionLaunches.get(jobs)?.landed(input),
1941
1857
  });
1942
1858
  shared = { loop, from };
1943
1859
  workLoops.set(jobs, shared);
@@ -2011,7 +1927,7 @@ function registerJobTools(pi, jobs, cwd) {
2011
1927
  name: "pulses",
2012
1928
  label: "Pulses",
2013
1929
  description: "Pulses in every tense - earlier sessions', this session's, running now and what runs next. With no parameter: every pulse of " +
2014
- "this session - finished, running, and planned, those of a look ahead marked as waiting for regenerate - what activate started, " +
1930
+ "this session - finished, running, and planned, those of a look ahead marked as waiting for regenerate - the launches and what they started, " +
2015
1931
  "and the last runs of earlier sessions, a line a pulse - how each ended, how long, what it cost. With job_id, one pulse: " +
2016
1932
  "running, whether it still is and its latest output; finished, its report and what the ledger recorded of it - its rounds " +
2017
1933
  "and test runs (how many failed the same way), the verdicts, the healers, the model provider's trouble, what turri refused, " +
@@ -2034,7 +1950,6 @@ function registerJobTools(pi, jobs, cwd) {
2034
1950
  })),
2035
1951
  plain_file: Type.Optional(Type.String({ description: "A look ahead: the .plain file of the module to plan, starting nothing. Not with job_id. Omitted: no look ahead" })),
2036
1952
  working_dir: WORKING_DIR_PARAM,
2037
- stack: STACK_PARAM,
2038
1953
  wait: Type.Optional(Type.Boolean({ description: "With a pulse started: block until it finishes instead of reporting its current state (default false)" })),
2039
1954
  runs: Type.Optional(Type.Number({ description: `With no parameter: how many runs of earlier sessions to list (default ${EARLIER_RUNS})` })),
2040
1955
  }),
@@ -2045,7 +1960,7 @@ function registerJobTools(pi, jobs, cwd) {
2045
1960
  const given = fromWorkingDir(cwd, params);
2046
1961
  const plainFile = resolve(given.base, given.plain_file);
2047
1962
  refuseTestPlainFile(plainFile);
2048
- return withCallStack(plainFile, params.stack, async () => {
1963
+ return whenBuildable(plainFile, async () => {
2049
1964
  const loop = workLoopFor(jobs, cwd, ctx);
2050
1965
  const statuses = await loop.lookAhead(plainFile);
2051
1966
  return { content: [{ type: "text", text: describeLookAhead(loop, statuses) }], details: { status: "looked ahead" } };
@@ -2090,33 +2005,43 @@ function registerJobTools(pi, jobs, cwd) {
2090
2005
  // The panel is compact and ctrl+o only lasts as long as the work does. This is the whole
2091
2006
  // list, finished jobs included, put in the transcript where it stays.
2092
2007
  pi.registerCommand("halt", {
2093
- description: "Halt a queued or running pulse, a module's planned pulses, or what activate started: /halt [pulse id | module | activated <name>]",
2008
+ description: "Halt a queued or running pulse, a module's planned pulses, a launch, or what a launch started: /halt [pulse id | module | launched <name | module>]",
2094
2009
  handler: async (args, ctx) => {
2095
2010
  if (!ctx.hasUI)
2096
2011
  return;
2097
2012
  const live = jobs.list().filter((job) => job.status === "running" || job.status === "queued");
2098
- const deployed = runningDeployed();
2013
+ const servers = runningLaunched();
2014
+ const track = sessionLaunches.get(jobs)?.track;
2015
+ const underWay = (track?.list() ?? []).filter((launch) => launch.status === "running" || launch.status === "waiting");
2099
2016
  const loop = workLoops.get(jobs)?.loop;
2100
2017
  // A module's planned pulses, one line a module: halting one halts the module.
2101
2018
  const plannedRows = loop?.planned() ?? [];
2102
2019
  const planned = [...new Set(plannedRows.map((row) => row.module ?? ""))].filter((module) => module !== "");
2103
2020
  let id = args.trim();
2104
2021
  if (id === "") {
2105
- if (live.length === 0 && deployed.length === 0 && planned.length === 0)
2106
- return ctx.ui.notify("Nothing is regenerating, queued or planned.", "info");
2022
+ if (live.length === 0 && servers.length === 0 && underWay.length === 0 && planned.length === 0)
2023
+ return ctx.ui.notify("Nothing is regenerating, queued, planned or launched.", "info");
2107
2024
  const label = (job) => `${job.id} ${job.status.padEnd(8)} ${pulseName(job)}`;
2108
2025
  const plannedLabel = (module) => {
2109
2026
  const rows = plannedRows.filter((row) => row.module === module);
2110
2027
  const waiting = rows.find((row) => row.id.endsWith("-waiting"));
2111
2028
  return `${module} ${waiting !== undefined ? waiting.summary : `${rows.length} planned`} - halts the module`;
2112
2029
  };
2113
- const labels = [...live.map(label), ...planned.map(plannedLabel), ...deployed.map((item) => deployedLabel(item.name, item.url ?? item.command))];
2030
+ const labels = [
2031
+ ...live.map(label),
2032
+ ...planned.map(plannedLabel),
2033
+ ...underWay.map(describeLaunchLine),
2034
+ ...servers.map((item) => launchedLabel(item.name, item.url ?? item.command)),
2035
+ ];
2114
2036
  const picked = await ctx.ui.select("Halt which?", labels);
2115
2037
  const job = live.find((candidate) => picked !== undefined && label(candidate) === picked);
2116
2038
  const module = planned.find((name) => picked !== undefined && plannedLabel(name) === picked);
2117
- const server = deployed.find((item) => picked !== undefined && deployedLabel(item.name, item.url ?? item.command) === picked);
2039
+ const launch = underWay.find((candidate) => picked !== undefined && describeLaunchLine(candidate) === picked);
2040
+ const server = servers.find((item) => picked !== undefined && launchedLabel(item.name, item.url ?? item.command) === picked);
2118
2041
  if (server !== undefined)
2119
- id = `activated ${server.name}`;
2042
+ id = `launched ${server.name}`;
2043
+ else if (launch !== undefined)
2044
+ id = `launched ${launch.codebase}`;
2120
2045
  else if (job !== undefined)
2121
2046
  id = job.id;
2122
2047
  else if (module !== undefined)
@@ -2124,11 +2049,9 @@ function registerJobTools(pi, jobs, cwd) {
2124
2049
  else
2125
2050
  return;
2126
2051
  }
2127
- const name = /^(?:activated|deploy)\s+(.+)$/.exec(id)?.[1]?.trim();
2128
- if (name !== undefined) {
2129
- const stopped = await stopDeployed({ name });
2130
- return shownAfterCommand(pi, ctx, `/halt ${id}`, stopped.length > 0 ? `Halted ${stopped.join(", ")}.` : `Nothing activate started is running as ${name}.`, "info");
2131
- }
2052
+ const name = /^launched\s+(.+)$/.exec(id)?.[1]?.trim();
2053
+ if (name !== undefined)
2054
+ return shownAfterCommand(pi, ctx, `/halt ${id}`, await haltLaunched(name, track), "info");
2132
2055
  ctx.ui.notify(stopJob(jobs, id, undefined, loop), "info");
2133
2056
  },
2134
2057
  });
@@ -2192,9 +2115,9 @@ function registerJobTools(pi, jobs, cwd) {
2192
2115
  openPanel(ctx);
2193
2116
  },
2194
2117
  });
2195
- // /turri-config: every setting of config.turri.yaml from the chat, each taking effect as it says - what turri fixed at its
2118
+ // /settings: every setting of config.turri.yaml from the chat, each taking effect as it says - what turri fixed at its
2196
2119
  // start changed here, as it runs.
2197
- registerTurriConfig(pi, {
2120
+ registerSettings(pi, {
2198
2121
  cwd,
2199
2122
  rules: ruleNames,
2200
2123
  chatSpec: () => modelSpec(projectModels(readProjectConfig(cwd)).harness),
@@ -2223,11 +2146,6 @@ function registerJobTools(pi, jobs, cwd) {
2223
2146
  dropped.push(`--coding-model ${process.env[CODING_MODEL_ENV]}`);
2224
2147
  delete process.env[CODING_MODEL_ENV];
2225
2148
  }
2226
- chosenModelsAt = Date.now();
2227
- for (const work of Object.keys(chosenModels)) {
2228
- dropped.push(`the engine's ${work === "all" ? "" : `${work.replace(/_/g, " ")} `}model ${chosenModels[work]}`);
2229
- delete chosenModels[work];
2230
- }
2231
2149
  return dropped.length === 0 ? undefined : `Chosen this session, and given way to the config: ${dropped.join("; ")}.`;
2232
2150
  },
2233
2151
  parallelJobs: (count) => {
@@ -2240,18 +2158,42 @@ function registerJobTools(pi, jobs, cwd) {
2240
2158
  }
2241
2159
  export { fromWorkingDir };
2242
2160
  const WATCH_REDRAW_MS = 500;
2161
+ /**
2162
+ * What a chat's agent is told of a pulse it asked for that ended, with the sentinel off. One that landed under
2163
+ * launch-after-pulse is being launched as it is told: it says so, and offers nothing else for it - it is told once the
2164
+ * launch ends.
2165
+ */
2166
+ export function pulseEndNote(job, options = {}) {
2167
+ const head = job.status === "succeeded"
2168
+ ? `Pulse ${job.id} (${job.kind}) finished after ${formatDuration(job)}.\n\n${job.report ?? ""}`
2169
+ : job.status === "stopped"
2170
+ ? `Pulse ${job.id} (${job.kind}) was stopped after ${formatDuration(job)}. ${job.error ?? STOPPED_ON_REQUEST}${job.error === undefined || job.error === STOPPED_ON_REQUEST ? " The person stopped it; what it was building counts as not built." : ""}`
2171
+ : `Pulse ${job.id} (${job.kind}) failed after ${formatDuration(job)}.\n\n${job.error ?? ""}`;
2172
+ const landed = job.status === "succeeded" && job.details?.landed === true;
2173
+ if (!landed || options.launching !== true)
2174
+ return `${head}\n\n${JOB_FINISHED_REACTION}`;
2175
+ return [
2176
+ head,
2177
+ "",
2178
+ "It landed, and turri is launching the commit it landed now, in the background (launch-after-pulse): you are told once",
2179
+ "that launch ends - where it runs, or why it did not come up. React to this now - the person has not asked, and need",
2180
+ "not: say in a line or two what landed and that it is being launched. Offer nothing else for it - do not call launch,",
2181
+ "open it, run it or test it, and never say nothing runs - and start no other work, unless guidance for this project",
2182
+ "(its AGENTS.md, a skill, what the person said) says to do something besides launching it when a pulse finishes: do",
2183
+ "that. When you are told it is launched, do what you were told to do once something is launched.",
2184
+ ].join("\n");
2185
+ }
2243
2186
  /**
2244
2187
  * What the agent is to do with a job that just ended, unasked: what the project's guidance says to do then, or else say
2245
2188
  * in a line or two what ended - the person saw it end already, in the transcript.
2246
2189
  */
2247
2190
  export const JOB_FINISHED_REACTION = [
2248
2191
  "React to this now - the person has not asked, and need not. If guidance for this project - its AGENTS.md, a skill,",
2249
- "what the person said earlier - says what to do when a pulse finishes (release what was built, run something, tell",
2192
+ "what the person said earlier - says what to do when a pulse finishes (launch what was built, run something, tell",
2250
2193
  "someone), do that, as it says. Otherwise say in a line or two what finished and what it means for the person - the",
2251
2194
  "report is theirs to read in full; do not repeat it - and, when it failed, what they can do. Start no other work.",
2252
- "A report that says \"Released after the pulse\" was released by turri itself, as the pulse's last stage: do not call",
2253
- "release for it. Say in a line what was released, or why nothing was - then, when it was released, do what you were",
2254
- "told to do once something is released (opening it where the person can watch it, saying what to test), if anything.",
2195
+ "Under launch-after-pulse turri launches what a pulse lands itself, in the background: do not call launch for it - you",
2196
+ "are told once it is launched, and do then what you were told to do once something is launched.",
2255
2197
  "A pulse that stopped on its environment - \"stopped: turri's sandbox kept its agents from…\" or \"stopped: the",
2256
2198
  "environment lacks…\" - stops the same way again until that is fixed: never regenerate it before. Heal it, then regenerate the",
2257
2199
  "module to resume:",
@@ -2566,9 +2508,9 @@ function modulesWithHistory(cwd) {
2566
2508
  }
2567
2509
  /** Stop a job by id or id prefix, and say what that means for the queue. */
2568
2510
  /** Every job, in the order it was started, with what a queued one is waiting for. */
2569
- /** What deploy started, as /halt offers it. */
2570
- function deployedLabel(name, what) {
2571
- return `deploy ${name} running ${what}`;
2511
+ /** What a launch started, as /halt offers it. */
2512
+ function launchedLabel(name, what) {
2513
+ return `launched ${name} running ${what}`;
2572
2514
  }
2573
2515
  /** The jobs as the person is shown them: those started, and those the work loop has planned after them. */
2574
2516
  function shownJobs(jobs) {
@@ -2576,8 +2518,10 @@ function shownJobs(jobs) {
2576
2518
  }
2577
2519
  function listJobs(jobs, cwd, runs = EARLIER_RUNS) {
2578
2520
  const all = [...shownJobs(jobs)].reverse().filter((job) => job.replacedBy === undefined);
2579
- const deployed = runningDeployed().map((item) => `deploy ${item.name} running ${item.moduleName}: ${item.url ?? item.command} (pid ${item.pid}, output in ${relative(process.cwd(), item.log) || item.log})`);
2580
- const listed = deployed.length > 0 ? `\n\nActivated from dist - /halt activated <name> halts one:\n${deployed.join("\n")}` : "";
2521
+ const servers = runningLaunched().map((item) => `launched ${item.name} running ${item.moduleName}: ${item.url ?? item.command} (pid ${item.pid}, output in ${relative(process.cwd(), item.log) || item.log})`);
2522
+ const launches = (sessionLaunches.get(jobs)?.track.list() ?? []).slice(-10).reverse().map(describeLaunchLine);
2523
+ const listed = (launches.length > 0 ? `\n\nLaunches, newest first - /halt launched <module> halts one under way:\n${launches.join("\n")}` : "") +
2524
+ (servers.length > 0 ? `\n\nWhat launches started - /halt launched <name> halts one:\n${servers.join("\n")}` : "");
2581
2525
  const before = earlierRuns(jobs, cwd, runs);
2582
2526
  if (all.length === 0)
2583
2527
  return `No pulses have been started in this session.${listed}${before}`;
@@ -2704,11 +2648,6 @@ function registerSteering(pi, cwd) {
2704
2648
  },
2705
2649
  });
2706
2650
  }
2707
- /**
2708
- * Deploy: the conversation puts what is built out in dist/<module> and starts it on this machine (see
2709
- * regenerate/release.ts), installing what it needs in its own shell - nothing is put to the person. What it
2710
- * started is stopped when the session ends.
2711
- */
2712
2651
  const SIDE_ENTRY = "turri_btw";
2713
2652
  /** A message the person sent while a skill ran in the chat, read by the skill's agent: drawn as the message it is. */
2714
2653
  const SKILL_MESSAGE_ENTRY = "turri_skill_message";
@@ -2781,20 +2720,37 @@ async function askOnTheSide(pi, ctx, cwd, jobs, question) {
2781
2720
  }
2782
2721
  return answer;
2783
2722
  }
2784
- function registerDeploy(pi, cwd, jobs, state) {
2785
- const tools = createDeployTools({
2786
- cwd,
2787
- state,
2788
- jobs,
2789
- workLoop: () => workLoops.get(jobs)?.loop,
2790
- defaultPlainFile: () => readProjectConfig(cwd).module,
2791
- });
2792
- for (const tool of tools)
2793
- pi.registerTool(tool);
2794
- // What activate started runs until turri ends - not when a chat is opened, closed, forked or reloaded.
2723
+ /** A launch ended, told to a chat's agent - to tell the person where it runs, or why it did not come up. */
2724
+ function tellLaunch(pi, jobs, launch) {
2725
+ const job = "pulse" in launch.cause ? jobs.get(launch.cause.pulse) : undefined;
2726
+ void pi.sendMessage({ customType: "turri_launch", content: launchedNote(launch, job), display: false, details: { launch: launch.id, status: launch.status } }, { triggerTurn: true, deliverAs: "followUp" });
2727
+ }
2728
+ /** A newer launch took the place of one a chat asked for, told to its agent: it hears that one's end instead. */
2729
+ function tellReplaced(pi, jobs, launch, next) {
2730
+ const job = "pulse" in next.cause ? jobs.get(next.cause.pulse) : undefined;
2731
+ void pi.sendMessage({ customType: "turri_launch", content: replacedNote(launch, next, job), display: false, details: { launch: launch.id, status: launch.status, replacedBy: next.id } }, { triggerTurn: true, deliverAs: "followUp" });
2732
+ }
2733
+ function registerLaunch(pi, cwd, jobs) {
2734
+ const launches = sessionLaunches.get(jobs);
2735
+ if (launches !== undefined) {
2736
+ pi.registerTool(launchTool({
2737
+ cwd,
2738
+ track: launches.track,
2739
+ defaultPlainFile: () => readProjectConfig(cwd).module,
2740
+ chat: () => currentChat()?.id,
2741
+ // Told in the chat that asked, as a launch after a pulse is with the sentinel off.
2742
+ ended: (launch) => tellLaunch(pi, jobs, launch),
2743
+ replaced: (launch, next) => tellReplaced(pi, jobs, launch, next),
2744
+ wait: (ctx) => shouldWait(ctx.mode, undefined),
2745
+ }));
2746
+ }
2747
+ pi.registerTool(haltTool({ jobs, workLoop: () => workLoops.get(jobs)?.loop, ...(launches !== undefined ? { launches: launches.track } : {}) }));
2748
+ // What launches started runs until turri ends - not when a chat is opened, closed, forked or reloaded.
2795
2749
  pi.on("session_shutdown", async (event) => {
2796
- if (event.reason === "quit")
2797
- await stopDeployed();
2750
+ if (event.reason !== "quit")
2751
+ return;
2752
+ await launches?.track.stop();
2753
+ await stopLaunched();
2798
2754
  });
2799
2755
  }
2800
2756
  const MILESTONE_ENTRY = "turri_milestone";
@@ -3015,10 +2971,11 @@ function registerBranding(pi, skills) {
3015
2971
  (data.commit !== undefined ? theme.fg("dim", ` from a clone, ${data.commit}${data.changed ? " with changes" : ""}`) : ""),
3016
2972
  // A newer turri out, or one installed and hidden behind this one: said first, under the version it is about.
3017
2973
  ...(data.versions ?? []).map((line) => theme.fg("warning", line)),
3018
- ...(data.config ?? []).map((line) => theme.fg("warning", line)),
2974
+ // A key renamed is information; the rest are the person's to take out.
2975
+ ...(data.config ?? []).map((line) => theme.fg(line.kind === "renamed" ? "muted" : "warning", line.text)),
3019
2976
  `${theme.fg("text", "the first coding agent with the power of ")}${brandPink(theme)("regenerative software")}`,
3020
2977
  // Where the settings are changed, without leaving the chat.
3021
- theme.fg("muted", "configure with /turri-config"),
2978
+ theme.fg("muted", "configure with /settings"),
3022
2979
  // Only what is wrong: skills that did not load, and agents' commands less fenced than they should be.
3023
2980
  ...(data.pending > 0 ? [theme.fg("warning", `${data.pending} skill${data.pending === 1 ? "" : "s"} failed to load`)] : []),
3024
2981
  ...(data.sandbox !== undefined && data.sandbox.level !== "ok" ? [theme.fg(data.sandbox.level === "limited" ? "warning" : "error", data.sandbox.text)] : []),
@@ -3067,7 +3024,7 @@ function registerBranding(pi, skills) {
3067
3024
  pending: skills.pending.length,
3068
3025
  sandbox: sandboxSummary(),
3069
3026
  versions: versions.lines,
3070
- config: unknownConfigLines(ctx.cwd),
3027
+ config: configLines(ctx.cwd),
3071
3028
  });
3072
3029
  }
3073
3030
  catch {