@turri-dev/cli 0.4.3-next.620bae9 → 0.4.3-next.7ada234

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 (122) hide show
  1. package/README.md +1 -0
  2. package/dist/background-skills.d.ts +4 -1
  3. package/dist/background-skills.js +9 -1
  4. package/dist/capture/agents.d.ts +406 -0
  5. package/dist/capture/agents.js +379 -0
  6. package/dist/capture/area.d.ts +58 -0
  7. package/dist/capture/area.js +197 -0
  8. package/dist/capture/assemble.d.ts +112 -0
  9. package/dist/capture/assemble.js +453 -0
  10. package/dist/capture/capture.d.ts +116 -0
  11. package/dist/capture/capture.js +1315 -0
  12. package/dist/capture/chat.d.ts +29 -0
  13. package/dist/capture/chat.js +94 -0
  14. package/dist/capture/checks.d.ts +142 -0
  15. package/dist/capture/checks.js +649 -0
  16. package/dist/capture/config.d.ts +13 -0
  17. package/dist/capture/config.js +66 -0
  18. package/dist/capture/interface.d.ts +71 -0
  19. package/dist/capture/interface.js +199 -0
  20. package/dist/capture/map.d.ts +56 -0
  21. package/dist/capture/map.js +530 -0
  22. package/dist/capture/models.d.ts +4 -0
  23. package/dist/capture/models.js +16 -0
  24. package/dist/capture/plan.d.ts +7 -0
  25. package/dist/capture/plan.js +13 -0
  26. package/dist/capture/progress.d.ts +111 -0
  27. package/dist/capture/progress.js +266 -0
  28. package/dist/capture/python-interface.d.ts +3 -0
  29. package/dist/capture/python-interface.js +17 -0
  30. package/dist/capture/report.d.ts +75 -0
  31. package/dist/capture/report.js +268 -0
  32. package/dist/capture/runners.d.ts +6 -0
  33. package/dist/capture/runners.js +59 -0
  34. package/dist/capture/scripts.d.ts +26 -0
  35. package/dist/capture/scripts.js +38 -0
  36. package/dist/capture/state.d.ts +310 -0
  37. package/dist/capture/state.js +43 -0
  38. package/dist/capture/trial.d.ts +34 -0
  39. package/dist/capture/trial.js +89 -0
  40. package/dist/capture-cli.d.ts +1 -0
  41. package/dist/capture-cli.js +77 -0
  42. package/dist/chat-tab-header.d.ts +3 -2
  43. package/dist/chat-tab-header.js +22 -9
  44. package/dist/chat-tabs.d.ts +7 -1
  45. package/dist/chat-tabs.js +10 -6
  46. package/dist/chat-terminal.js +27 -6
  47. package/dist/chats.d.ts +14 -8
  48. package/dist/chats.js +46 -20
  49. package/dist/cli.js +32 -14
  50. package/dist/config-edit.js +5 -2
  51. package/dist/config.d.ts +15 -2
  52. package/dist/config.js +62 -3
  53. package/dist/extension.d.ts +2 -1
  54. package/dist/extension.js +225 -68
  55. package/dist/identity.js +2 -1
  56. package/dist/init-config.d.ts +4 -1
  57. package/dist/init-config.js +31 -4
  58. package/dist/loop-cli.js +5 -1
  59. package/dist/loop-tools.js +5 -1
  60. package/dist/new-project.d.ts +5 -0
  61. package/dist/new-project.js +11 -0
  62. package/dist/pi-launch.js +2 -0
  63. package/dist/pi-themes.d.ts +3 -0
  64. package/dist/pi-themes.js +21 -0
  65. package/dist/pi.d.ts +2 -2
  66. package/dist/pi.js +4 -4
  67. package/dist/plain-code-blocks.d.ts +14 -0
  68. package/dist/plain-code-blocks.js +56 -0
  69. package/dist/pointer-hover.d.ts +1 -1
  70. package/dist/pointer-hover.js +4 -0
  71. package/dist/question-dialog.d.ts +5 -0
  72. package/dist/question-dialog.js +26 -3
  73. package/dist/regenerate/agent-env.js +5 -1
  74. package/dist/regenerate/command-check.js +80 -11
  75. package/dist/regenerate/job-panel.d.ts +5 -107
  76. package/dist/regenerate/job-panel.js +4 -289
  77. package/dist/regenerate/loop.js +9 -1
  78. package/dist/regenerate/side-panel.d.ts +2 -0
  79. package/dist/regenerate/side-panel.js +32 -5
  80. package/dist/regenerate/spec-map-view.d.ts +2 -2
  81. package/dist/regenerate/test-scripts.d.ts +5 -0
  82. package/dist/regenerate/test-scripts.js +4 -0
  83. package/dist/reopen.d.ts +29 -0
  84. package/dist/reopen.js +47 -0
  85. package/dist/sentinel-chat.js +7 -2
  86. package/dist/sentinel.d.ts +1 -1
  87. package/dist/sentinel.js +3 -1
  88. package/dist/setup.js +9 -1
  89. package/dist/terminal-notifications.d.ts +37 -0
  90. package/dist/terminal-notifications.js +164 -0
  91. package/docs/README.md +2 -0
  92. package/docs/capture.md +227 -0
  93. package/docs/chats.md +6 -3
  94. package/docs/config.md +18 -4
  95. package/docs/development.md +4 -1
  96. package/docs/hosting.md +2 -2
  97. package/docs/launch.md +2 -2
  98. package/docs/regenerating.md +1 -1
  99. package/docs/sandbox.md +4 -2
  100. package/docs/sentinel.md +11 -11
  101. package/docs/theming.md +3 -3
  102. package/docs/using.md +7 -3
  103. package/genome/capture/capture.md +26 -0
  104. package/genome/capture/check-conventions.md +5 -0
  105. package/genome/capture/check-reference.md +12 -0
  106. package/genome/capture/compact.md +7 -0
  107. package/genome/capture/concepts.md +3 -0
  108. package/genome/capture/divide.md +9 -0
  109. package/genome/capture/feature.md +45 -0
  110. package/genome/capture/interface.md +9 -0
  111. package/genome/capture/modules.md +25 -0
  112. package/genome/capture/outline.md +11 -0
  113. package/genome/capture/python-interface.py +111 -0
  114. package/genome/capture/readability.md +12 -0
  115. package/genome/capture/reference.md +10 -0
  116. package/genome/capture/runners/python-requirements.sh +67 -0
  117. package/genome/capture/split.md +9 -0
  118. package/genome/capture/survey.md +39 -0
  119. package/genome/capture/trial.md +18 -0
  120. package/genome/capture/verify.md +7 -0
  121. package/genome/rules/turri-regeneration.md +1 -1
  122. package/package.json +1 -1
package/dist/extension.js CHANGED
@@ -20,6 +20,12 @@ import { applyBedrockRegion } from "./bedrock-region.js";
20
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
+ import { runCapture } from "./capture/capture.js";
24
+ import { captureEnded, captureFailed, captureGoesOn, captureOpenQuestion, captureRefusal, captureStartedText, readReopenedAfterCapture, reopenedAfterCapture } from "./capture/chat.js";
25
+ import { reportFile as captureReportFile } from "./capture/state.js";
26
+ import { canReopen, REOPENED_AFTER_CAPTURE, reopenIn } from "./reopen.js";
27
+ import { captureStatusLines, duration } from "./capture/progress.js";
28
+ import { highlightPlainCodeBlocks } from "./plain-code-blocks.js";
23
29
  import { createAskUserTool } from "./tools.js";
24
30
  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
31
  import { createWebTools } from "./regenerate/web.js";
@@ -32,7 +38,7 @@ import { createSessionLaunches, launchedDir, launchedNote, replacedNote } from "
32
38
  import { describeLaunchLine, launchText } from "./launch-track.js";
33
39
  import { checkedSpecs } from "./sentinel-check.js";
34
40
  import { askedForCommandLine, refusal, selfInvocation, TOOLS_NOT_CLI } from "./self-invocation.js";
35
- import { NEW_PROJECT } from "./new-project.js";
41
+ import { CAPTURE_HINT, NEW_PROJECT } from "./new-project.js";
36
42
  import { describeResolution, resolveModel } from "./regenerate/model-names.js";
37
43
  import { checkPlainFile, formatCheckResults } from "./plain/check.js";
38
44
  import { checkPlainTool } from "./parse-tool.js";
@@ -42,7 +48,7 @@ import { didNotLand } from "./regenerate/failure-reports.js";
42
48
  import { conformanceRefusal, createWorkLoop, TestingStepsMissing, describeModules, isUpToDate } from "./regenerate/loop.js";
43
49
  import { brandNeon, brandPink, plainPaint } from "./regenerate/plain-palette.js";
44
50
  import { halfBlocks, JELLYFISH_FRAME_MS, JELLYFISH_REST, JELLYFISH_SEQUENCE, JELLYFISH_TEXT_FRAMES } from "./jellyfish.js";
45
- import { createJobPanel, didNotPass, keyPressed, PANEL_KEY, spinner } from "./regenerate/job-panel.js";
51
+ import { didNotPass, PANEL_KEY, spinner } from "./regenerate/job-panel.js";
46
52
  import { clickToFocus, dockedWidth, narrowChat, shade, shadeChat } from "./regenerate/panel-dock.js";
47
53
  import { overPictureRow, PICTURE_AT } from "./picture-row.js";
48
54
  import { padScreen, paddedColumns, paddedRows, SCREEN_PADDING } from "./screen-padding.js";
@@ -50,6 +56,8 @@ import { skillAboutLine, skillProgressLine } from "./skill-progress.js";
50
56
  import { createSidePanel } from "./regenerate/side-panel.js";
51
57
  import { createSpecMapSource, defaultMapFiles } from "./regenerate/spec-map.js";
52
58
  import { createSpecMapState } from "./regenerate/spec-map-view.js";
59
+ import { notificationView } from "./terminal-notifications.js";
60
+ import { BANNER_ENTRY } from "./chat-tab-header.js";
53
61
  import { createJobsTreeState, selectJob } from "./regenerate/jobs-tree.js";
54
62
  import { describeDiagnosis, diagnoseFailure } from "./regenerate/diagnose.js";
55
63
  import { HISTORY_DIR, historyLog } from "./regenerate/lineage.js";
@@ -295,12 +303,29 @@ export function createTurriCore(host = {}, options = {}) {
295
303
  // The AWS region the project's Bedrock models need, before any model is called - a host has no shell to export it in.
296
304
  applyBedrockRegion(cwd);
297
305
  let core;
306
+ // One activity light for every chat. Only plan changes need to read the plan; streaming job updates do not.
307
+ let planning = false;
308
+ const running = new Set();
309
+ const busy = () => planning || running.size > 0;
310
+ const updateActivity = (job) => {
311
+ if (!core?.terminal)
312
+ return;
313
+ const before = busy();
314
+ if (!job)
315
+ planning = workLoops.get(jobs)?.loop.planned().some((row) => row.planning !== undefined) ?? false;
316
+ else if (job.status === "running" && (job.kind === "regenerate" || job.kind === "conformance"))
317
+ running.add(job.id);
318
+ else
319
+ running.delete(job.id);
320
+ if (busy() !== before)
321
+ core.changed();
322
+ };
298
323
  // Finished work is announced twice, to two audiences, because pi treats them differently - see ChatInstance.announce:
299
324
  // in the chat that asked for it, or the one shown when that is closed.
300
325
  const jobs = createJobRegistry({
301
- // The loop's plan changed - a module being planned, or planned: the live panel shows it at once.
326
+ // The planner can be at work before the registry has its first pulse.
302
327
  onNotify: () => {
303
- core?.jobsChanged();
328
+ updateActivity();
304
329
  host.onPlanChange?.();
305
330
  },
306
331
  // A job that fails is run once more; failing again, it and every job behind it fail, and the
@@ -322,16 +347,16 @@ export function createTurriCore(host = {}, options = {}) {
322
347
  return diagnosis !== undefined ? describeDiagnosis(diagnosis) : undefined;
323
348
  },
324
349
  onChange: (job) => {
325
- core?.jobsChanged();
350
+ updateActivity(job);
326
351
  host.onJobChange?.(job);
327
352
  },
328
353
  onFinish: (job) => {
329
- core?.jobsChanged();
354
+ updateActivity(job);
330
355
  host.onJobChange?.(job);
331
356
  // Queued again as another job: that one says how it went.
332
357
  if (job.replacedBy !== undefined)
333
358
  return;
334
- // Gone wrong: the next ctrl+h opens on it - the live panel that showed it is gone with the last pulse.
359
+ // Gone wrong: the next ctrl+h opens on it.
335
360
  if (job.status === "failed" || job.status === "stopped" || didNotPass(job))
336
361
  needsLooking.set(jobs, job.id);
337
362
  core?.jobFinished(job);
@@ -344,7 +369,6 @@ export function createTurriCore(host = {}, options = {}) {
344
369
  jobs,
345
370
  model: (plainFile) => launchModel(workLoops.get(jobs)?.from.ctx, plainFile),
346
371
  onChange: (launch) => {
347
- core?.jobsChanged();
348
372
  try {
349
373
  host.onLaunch?.(launch);
350
374
  }
@@ -360,7 +384,7 @@ export function createTurriCore(host = {}, options = {}) {
360
384
  launches,
361
385
  host,
362
386
  jobs,
363
- extension: (pi, link) => turriExtension(pi, core, link),
387
+ extension: (pi, link) => turriExtension(pi, core, link, busy),
364
388
  // A finished pulse goes to the sentinel when the project wants one - read as each pulse finishes - the person asked
365
389
  // first under `sentinel: ask`, and what they choose for the project written.
366
390
  sentinel: () => sentinelSetting(cwd),
@@ -428,7 +452,7 @@ export function sessionLoop(session) {
428
452
  * turri's extension, built into one chat of the session: its tools, commands and handlers run in the chat's scope -
429
453
  * its id on the pulses it asks for - on the session's job registry and work loop.
430
454
  */
431
- function turriExtension(api, session, link) {
455
+ function turriExtension(api, session, link, busy) {
432
456
  const pi = scopedToChat(api, link.scope);
433
457
  const { cwd, host, jobs } = session;
434
458
  // The session's sentinel: its own prompt and tools - the project to read, notices, its guidance - and nothing that
@@ -443,8 +467,6 @@ function turriExtension(api, session, link) {
443
467
  const dialogs = link.dialogs ?? host.dialogs;
444
468
  // turri's own skills, and the project's - .turri/skills, .agents/skills (skills.ts).
445
469
  const discoveredSkills = discoverSkills(PACKAGE_ROOT, cwd);
446
- // What the background work is doing right now, drawn above the editor while it runs.
447
- const panel = createJobPanel(() => shownJobs(jobs));
448
470
  // The chat's context, as its tools and handlers were last given it: for its model and its providers.
449
471
  let lastContext;
450
472
  const contextNow = () => {
@@ -465,7 +487,8 @@ function turriExtension(api, session, link) {
465
487
  // does what the project's guidance says to do then (launch what was built, say), or says
466
488
  // what finished. In the chat that asked for the pulse, shown or not.
467
489
  const announce = (job) => {
468
- announceJob(pi, job);
490
+ if (!session.terminal)
491
+ announceJob(pi, job);
469
492
  // A pulse a call of this chat waits for is told in that call's reply: a turn of its own would say it again.
470
493
  if (toldByWaitingCall(jobs, job) && job.specConflict === undefined)
471
494
  return;
@@ -481,12 +504,13 @@ function turriExtension(api, session, link) {
481
504
  catch {
482
505
  /* a config that cannot be read launches nothing */
483
506
  }
507
+ const quiet = session.terminal && job.status === "succeeded" && !didNotPass(job);
484
508
  void pi.sendMessage({
485
509
  customType: "turri_job",
486
- content: pulseEndNote(job, { launching }),
510
+ content: pulseEndNote(job, { launching, quiet }),
487
511
  display: false,
488
512
  details: { jobId: job.id, status: job.status },
489
- }, { triggerTurn: true, deliverAs: "followUp" });
513
+ }, quiet ? { triggerTurn: false } : { triggerTurn: true, deliverAs: "followUp" });
490
514
  };
491
515
  // The sentinel's: what a pulse that ended is, told to its agent in a conversation of its own for the pulse. The hidden
492
516
  // message is the conversation's first entry - a host splits the sentinel's work by pulse on it - so the pulse's end is
@@ -531,13 +555,14 @@ function turriExtension(api, session, link) {
531
555
  // it landed and what the sentinel does with it - and nothing more: the pulse is the sentinel's. ***plain that
532
556
  // contradicts itself is put to the person at once, by turri itself, as the chat would have been started on it.
533
557
  const landed = (job, options = {}) => {
534
- announceJob(pi, job);
558
+ if (!session.terminal)
559
+ announceJob(pi, job);
535
560
  if (job.specConflict !== undefined)
536
561
  session.notice(specConflictNotice(job, specConflictTask(job.specConflict)));
537
562
  if (options.tell !== true || toldByWaitingCall(jobs, job))
538
563
  return;
539
564
  // A host that shows the person the pulse's end itself: the chat knows of it - in order, with no turn of its own.
540
- const shown = host.pulseEndsShown === true;
565
+ const shown = session.terminal || host.pulseEndsShown === true;
541
566
  let launching = false;
542
567
  try {
543
568
  launching = readProjectConfig(cwd, job.configModule).launchAfterPulse === true;
@@ -549,10 +574,17 @@ function turriExtension(api, session, link) {
549
574
  };
550
575
  const notices = noticeDialogs(pi, session, link, contextNow);
551
576
  link.live({
552
- openPlainPanel: () => {
553
- const ctx = contextNow();
554
- if (ctx?.hasUI)
555
- sidePanelOf(jobs, cwd).open(ctx, "map", "beside");
577
+ plainPanel: {
578
+ busy,
579
+ open: () => sidePanelOf(session).visible(),
580
+ toggle: () => {
581
+ const panel = sidePanelOf(session);
582
+ if (panel.visible())
583
+ return panel.close();
584
+ const ctx = contextNow();
585
+ if (ctx?.hasUI)
586
+ panel.open(ctx, "map", "beside");
587
+ },
556
588
  },
557
589
  announce,
558
590
  landed,
@@ -566,12 +598,13 @@ function turriExtension(api, session, link) {
566
598
  act: (task) => {
567
599
  void pi.sendMessage({ customType: "turri_notice_answer", content: task, display: false }, { triggerTurn: true, deliverAs: "followUp" });
568
600
  },
569
- jobsChanged: () => panel.refresh(),
570
601
  thinkingLevel: () => pi.getThinkingLevel(),
571
602
  context: contextNow,
572
603
  });
573
604
  pi.on("session_start", (_event, ctx) => {
574
605
  lastContext = ctx;
606
+ if (session.terminal && session.welcomeVisible(link.id) && ctx.sessionManager.getBranch().some((entry) => (entry.type === "message" && entry.message.role === "user") || (entry.type === "custom" && entry.customType === COMMAND_OUTCOME)))
607
+ session.dismissWelcome();
575
608
  });
576
609
  pi.on("before_agent_start", (_event, ctx) => {
577
610
  lastContext = ctx;
@@ -618,7 +651,8 @@ function turriExtension(api, session, link) {
618
651
  systemPrompt: conversationSystemPrompt(event.systemPrompt, host, [
619
652
  TOOLS_NOT_CLI,
620
653
  NEW_PROJECT,
621
- pulseEndsBlock(session.sentinelOn()),
654
+ CAPTURE_HINT,
655
+ pulseEndsBlock(session.sentinelOn(), session.terminal),
622
656
  // Conformance tests - what they are, whether they are on here, and how they are turned on: every turn, read afresh.
623
657
  conformanceBlock(conformanceTestsOnIn(cwd)),
624
658
  projectConfigBlock(cwd),
@@ -633,6 +667,8 @@ function turriExtension(api, session, link) {
633
667
  /** While a skill runs in this chat: what passes the person's message to its agent. */
634
668
  let skillMessage;
635
669
  pi.on("input", (event) => {
670
+ if (event.source === "interactive" && (event.text.trim() || event.images?.length))
671
+ session.dismissWelcome();
636
672
  if (event.source !== "extension")
637
673
  lastUserMessage = event.text;
638
674
  // A skill running in this chat holds its agent for the whole run: what the person types meanwhile is for the
@@ -710,31 +746,9 @@ function turriExtension(api, session, link) {
710
746
  };
711
747
  pi.on("agent_end", endTurnCapture);
712
748
  pi.on("agent_settled", endTurnCapture);
713
- pi.on("session_start", (_event, ctx) => {
714
- if (!ctx.hasUI)
715
- return;
716
- panel.attach({
717
- setWidget: (key, content, options) => {
718
- try {
719
- ctx.ui.setWidget(key, content, options);
720
- }
721
- catch {
722
- /* rebuilt by pi since: its new extension draws the panel */
723
- }
724
- },
725
- getToolsExpanded: () => {
726
- try {
727
- return ctx.ui.getToolsExpanded();
728
- }
729
- catch {
730
- return false;
731
- }
732
- },
733
- });
734
- });
735
- registerBranding(pi, discoveredSkills);
749
+ registerBranding(pi, discoveredSkills, () => session.welcomeVisible(link.id));
736
750
  registerInterviewLog(pi);
737
- registerJobTools(pi, jobs, cwd);
751
+ registerJobTools(pi, session);
738
752
  // The skills the person starts themselves - a project's, marked command-only: each has its command, and cultivate starts it only
739
753
  // once its command is typed, or picked among the options the conversation offers with ask_user.
740
754
  const gate = createCommandGate();
@@ -781,6 +795,8 @@ function turriExtension(api, session, link) {
781
795
  for (const controller of backgroundSkillRuns.values())
782
796
  controller.abort();
783
797
  });
798
+ // An existing codebase captured into ***plain, in the background: the person starts it, never the chat's agent.
799
+ registerCapture(pi, cwd, skillRunEnds);
784
800
  const startInBackground = (skill, params, plainFile, ctx) => {
785
801
  const key = `${cwd}\0${skill.name}`;
786
802
  const kind = scriptKindOfSkill(skill.name);
@@ -1314,6 +1330,16 @@ export function funcIdsNamedFirst(words) {
1314
1330
  export function asksOneByOne(words) {
1315
1331
  return /\b(one[\s-]+(by|at)[\s-]+(one|a[\s-]+time)|separately|each[\s-]+(on[\s-]+its[\s-]+own|alone))\b/i.test(words);
1316
1332
  }
1333
+ /** Keep a command's output in the transcript without adding a message to the model's context. */
1334
+ function showCommandEntry(pi, ctx, entry) {
1335
+ try {
1336
+ pi.appendEntry(COMMAND_OUTCOME, entry);
1337
+ }
1338
+ catch {
1339
+ if (ctx.hasUI)
1340
+ ctx.ui.notify(entry.text, entry.level);
1341
+ }
1342
+ }
1317
1343
  /**
1318
1344
  * What a slash command showed the person: kept in the chat, where they read it, and put in the conversation as well -
1319
1345
  * unseen there - so that when they speak of it next ("fix it"), the agent knows what they saw. A command runs outside
@@ -1323,14 +1349,7 @@ export function asksOneByOne(words) {
1323
1349
  export function shownAfterCommand(pi, ctx, command, text, level,
1324
1350
  /** The command is in the chat already, above it (echoCommand): the text alone. */
1325
1351
  echoed = false, react) {
1326
- try {
1327
- pi.appendEntry(COMMAND_OUTCOME, { command, text, level, ...(echoed ? { echoed } : {}) });
1328
- }
1329
- catch {
1330
- // Shown for a moment all the same.
1331
- if (ctx.hasUI)
1332
- ctx.ui.notify(text, level);
1333
- }
1352
+ showCommandEntry(pi, ctx, { command, text, level, ...(echoed ? { echoed } : {}) });
1334
1353
  const content = `The person ran ${command}, and was shown:\n${text}${react !== undefined ? `\n\n${react}` : ""}`;
1335
1354
  if (react === undefined)
1336
1355
  void pi.sendMessage({ customType: COMMAND_OUTCOME, content, display: false });
@@ -1992,7 +2011,8 @@ const needsLooking = new WeakMap();
1992
2011
  /** What heads a pulse told from the ledger: it is not this session's, and the facts are all there is of it. */
1993
2012
  const pastPulseNote = "A pulse of an earlier session, as the ledger recorded it - facts, not its transcript. Its whole log is the file it names, " +
1994
2013
  "for the read tool.";
1995
- function registerJobTools(pi, jobs, cwd) {
2014
+ function registerJobTools(pi, session) {
2015
+ const { jobs, cwd } = session;
1996
2016
  pi.registerTool(doctorTool({ cwd }));
1997
2017
  pi.registerTool({
1998
2018
  name: "pulses",
@@ -2073,8 +2093,6 @@ function registerJobTools(pi, jobs, cwd) {
2073
2093
  return { content: [{ type: "text", text }], details: { status: job.status } };
2074
2094
  },
2075
2095
  });
2076
- // The panel is compact and ctrl+o only lasts as long as the work does. This is the whole
2077
- // list, finished jobs included, put in the transcript where it stays.
2078
2096
  pi.registerCommand("halt", {
2079
2097
  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>]",
2080
2098
  handler: async (args, ctx) => {
@@ -2152,8 +2170,14 @@ function registerJobTools(pi, jobs, cwd) {
2152
2170
  // While the panel has the keys, every key is its own.
2153
2171
  // The side panel is the session's, one for every chat: it stays on the screen - beside the chat or over it - as
2154
2172
  // another chat is shown, and what it says to a chat it says to the one shown.
2155
- const sidePanel = sidePanelOf(jobs, cwd);
2173
+ const sidePanel = sidePanelOf(session);
2156
2174
  const openPanel = sidePanel.open;
2175
+ if (session.terminal)
2176
+ pi.registerCommand("notifications", {
2177
+ description: "Open the side panel on finished pulses and sentinel notices",
2178
+ handler: async (_args, ctx) => { if (ctx.hasUI)
2179
+ openPanel(ctx, "notifications", "beside"); },
2180
+ });
2157
2181
  pi.on("session_start", () => {
2158
2182
  sidePanel.say = (text) => pi.sendUserMessage(text, { deliverAs: "followUp" });
2159
2183
  });
@@ -2240,6 +2264,8 @@ export function pulseEndNote(job, options = {}) {
2240
2264
  : job.status === "stopped"
2241
2265
  ? `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." : ""}`
2242
2266
  : `Pulse ${job.id} (${job.kind}) failed after ${formatDuration(job)}.\n\n${job.error ?? ""}`;
2267
+ if (options.quiet)
2268
+ return `${head}\n\nThis result is in notifications. It needs no announcement in the chat.`;
2243
2269
  const landed = job.status === "succeeded" && job.details?.landed === true;
2244
2270
  if (!landed || options.launching !== true)
2245
2271
  return `${head}\n\n${JOB_FINISHED_REACTION}`;
@@ -2287,12 +2313,15 @@ export const JOB_FINISHED_REACTION = [
2287
2313
  ].join("\n");
2288
2314
  const sidePanels = new WeakMap();
2289
2315
  /** The side panel of the session these jobs are, made as a chat first asks for it. */
2290
- function sidePanelOf(jobs, cwd) {
2316
+ function sidePanelOf(session) {
2317
+ const { jobs, cwd } = session;
2291
2318
  const known = sidePanels.get(jobs);
2292
2319
  if (known !== undefined)
2293
2320
  return known;
2294
2321
  const self = {
2295
2322
  open: (ctx, view, placement) => openPanel(ctx, view, placement),
2323
+ visible: () => panel !== undefined && panel.handle?.isHidden() !== true,
2324
+ close: () => panel?.close(),
2296
2325
  shown: () => panel !== undefined && panel.keys,
2297
2326
  };
2298
2327
  sidePanels.set(jobs, self);
@@ -2331,8 +2360,6 @@ function sidePanelOf(jobs, cwd) {
2331
2360
  });
2332
2361
  /** Open the side panel - on the view named, or as it was left. */
2333
2362
  const openPanel = (ctx, view, placement) => {
2334
- // Found: ctrl+h under the job panel stops breathing.
2335
- keyPressed("peek");
2336
2363
  if (view !== undefined)
2337
2364
  mapState.view = view;
2338
2365
  // A pulse that failed or stopped since the panel was last opened: opened as it is, it is on that pulse - what went
@@ -2415,6 +2442,10 @@ function sidePanelOf(jobs, cwd) {
2415
2442
  // Opened, it reads the files again at once: they may have changed while it was closed.
2416
2443
  specMap.refresh();
2417
2444
  const view = createSidePanel({
2445
+ ...(session.terminal ? { notifications: notificationView(session, {
2446
+ accent: (text) => theme.fg("accent", text), muted: (text) => theme.fg("muted", text), bold: (text) => theme.bold(text),
2447
+ warning: (text) => theme.fg("warning", text), button: (text, selected) => buttonLabel(theme, text, selected, false, "panel"),
2448
+ }, back) } : {}),
2418
2449
  pointer: terminalPointer(tui.terminal),
2419
2450
  tabLabel: (text, active, hovered, role) => buttonLabel(theme, text, active, hovered, role),
2420
2451
  jobs: () => shownJobs(jobs),
@@ -2669,6 +2700,126 @@ function registerCheckPlain(pi, cwd, dialogs, afterAnswer) {
2669
2700
  const SIDE_ENTRY = "turri_btw";
2670
2701
  /** A message the person sent while a skill ran in the chat, read by the skill's agent: drawn as the message it is. */
2671
2702
  const SKILL_MESSAGE_ENTRY = "turri_skill_message";
2703
+ /** The capture's lines above the input while it runs. */
2704
+ const CAPTURE_WIDGET = "turri-capture";
2705
+ /**
2706
+ * /capture [path]: the codebase at path - the chat's folder by default - captured into ***plain in <path>/plain, in the
2707
+ * background and offline (docs/capture.md). A command alone: capture turns conformance tests on in the project it writes,
2708
+ * which the person alone does. One at a time; its end comes back to this chat as a background skill's does, its report
2709
+ * for the chat's agent to pass on.
2710
+ */
2711
+ function registerCapture(pi, cwd, ends) {
2712
+ let running;
2713
+ pi.on("session_shutdown", (event) => {
2714
+ if (event.reason === "quit")
2715
+ running?.controller.abort();
2716
+ });
2717
+ // turri opened again here, in the project a capture wrote: its report told in the first chat, once.
2718
+ pi.on("session_start", () => {
2719
+ const told = readReopenedAfterCapture(process.env[REOPENED_AFTER_CAPTURE]);
2720
+ delete process.env[REOPENED_AFTER_CAPTURE];
2721
+ if (told !== undefined)
2722
+ ends.put(captureEnded(cwd, { plainDir: cwd, reportFile: captureReportFile(cwd), summary: told.summary }));
2723
+ });
2724
+ pi.registerCommand("capture", {
2725
+ description: "Capture an existing codebase into ***plain, in the background - nothing is asked, and its report comes back here; a stopped one goes on: /capture [path] (this folder by default - the ***plain goes into <path>/plain)",
2726
+ handler: async (args, ctx) => {
2727
+ const command = `/capture ${args.trim()}`.trim();
2728
+ await echoCommand(pi, command);
2729
+ const refuse = (text) => shownAfterCommand(pi, ctx, command, text, "error", true);
2730
+ if (running !== undefined)
2731
+ return refuse(`A capture of ${running.root} is running already: its report comes back here when it ends. Nothing new was started.`);
2732
+ const root = resolve(cwd, args.trim() || ".");
2733
+ const refusal = captureRefusal(root);
2734
+ if (refusal !== undefined)
2735
+ return refuse(refusal);
2736
+ const controller = new AbortController();
2737
+ running = { root, controller };
2738
+ const model = conversationModel(ctx);
2739
+ shownAfterCommand(pi, ctx, command, captureStartedText(root, captureGoesOn(root)), "info", true);
2740
+ // Above the input while it runs: where it is, each agent at work and what it did last - a capture at work
2741
+ // is told from one that hangs.
2742
+ let status;
2743
+ let redrawNow;
2744
+ if (ctx.hasUI) {
2745
+ ctx.ui.setWidget(CAPTURE_WIDGET, (tui, theme) => {
2746
+ // The spinner and the clocks move.
2747
+ const redraw = setInterval(() => tui.requestRender(), 1000);
2748
+ redraw.unref?.();
2749
+ redrawNow = () => tui.requestRender();
2750
+ const style = {
2751
+ heading: (text) => theme.bold(theme.fg("accent", text)),
2752
+ done: (text) => theme.fg("success", text),
2753
+ now: (text) => theme.bold(theme.fg("accent", text)),
2754
+ muted: (text) => theme.fg("muted", text),
2755
+ };
2756
+ return {
2757
+ render: (width) => (status === undefined ? [] : captureStatusLines(status, { frame: spinner(Date.now()), now: Date.now(), width }, style)),
2758
+ invalidate: () => { },
2759
+ dispose: () => {
2760
+ clearInterval(redraw);
2761
+ redrawNow = undefined;
2762
+ },
2763
+ };
2764
+ });
2765
+ }
2766
+ const watch = (next) => {
2767
+ status = next;
2768
+ redrawNow?.();
2769
+ };
2770
+ // The same milestones as the CLI, kept in the chat that started the capture. Tool activity stays in the widget.
2771
+ const started = Date.now();
2772
+ const progress = (line) => {
2773
+ if (controller.signal.aborted)
2774
+ return;
2775
+ const elapsed = duration(Date.now() - started);
2776
+ const spent = status && status.cost > 0 ? ` · $${status.cost.toFixed(2)}` : "";
2777
+ showCommandEntry(pi, ctx, { command, text: `capture · ${elapsed}${spent} · ${line}`, level: "info", echoed: true });
2778
+ };
2779
+ // The captured project starts as the config in use here, with the chat's model and thinking of the moment, and the
2780
+ // coding model turri was started with, where it says otherwise.
2781
+ const codingModel = process.env[CODING_MODEL_ENV];
2782
+ const configured = {
2783
+ configFrom: cwd,
2784
+ ...(model !== undefined ? { model, harnessModel: `${model}:${pi.getThinkingLevel()}` } : {}),
2785
+ ...(codingModel !== undefined && codingModel !== "" ? { codingModel } : {}),
2786
+ };
2787
+ void captureConsole(() => runCapture({ root, signal: controller.signal, progress, watch, ...configured }))
2788
+ .then(async ({ result }) => {
2789
+ if (ctx.hasUI)
2790
+ ctx.ui.setWidget(CAPTURE_WIDGET, undefined);
2791
+ // A chat works on the project of its own folder, and the capture wrote one of its own: turri in a terminal
2792
+ // can open again there, on the chat's model, the report told there.
2793
+ if (ctx.hasUI && canReopen()) {
2794
+ const question = captureOpenQuestion(cwd, result);
2795
+ const chatModel = conversationModel(ctx);
2796
+ const codingModel = process.env[CODING_MODEL_ENV];
2797
+ const args = [
2798
+ ...(chatModel !== undefined ? ["--model", chatModel] : []),
2799
+ "--thinking",
2800
+ pi.getThinkingLevel(),
2801
+ ...(codingModel !== undefined && codingModel !== "" ? ["--coding-model", codingModel] : []),
2802
+ ];
2803
+ if ((await ctx.ui.confirm(question.title, question.message)) && reopenIn(result.plainDir, { args, env: { [REOPENED_AFTER_CAPTURE]: reopenedAfterCapture(result.summary) } })) {
2804
+ ctx.shutdown();
2805
+ return;
2806
+ }
2807
+ }
2808
+ ends.put(captureEnded(cwd, result));
2809
+ })
2810
+ .catch((error) => {
2811
+ // Stopped as turri quits: nobody is left to tell.
2812
+ if (!controller.signal.aborted)
2813
+ ends.put(captureFailed(error));
2814
+ })
2815
+ .finally(() => {
2816
+ running = undefined;
2817
+ if (ctx.hasUI)
2818
+ ctx.ui.setWidget(CAPTURE_WIDGET, undefined);
2819
+ });
2820
+ },
2821
+ });
2822
+ }
2672
2823
  /**
2673
2824
  * /btw, a question on the side (btw.ts): answered at once, even while a skill runs - pi runs a command mid-turn - and
2674
2825
  * shown in the transcript, never in a model's context.
@@ -2957,7 +3108,6 @@ function recentUserMessages(ctx, limit) {
2957
3108
  }
2958
3109
  return said.slice(-limit);
2959
3110
  }
2960
- const BANNER_ENTRY = "turri_banner";
2961
3111
  /**
2962
3112
  * The name on the door.
2963
3113
  *
@@ -2972,7 +3122,7 @@ const BANNER_ENTRY = "turri_banner";
2972
3122
  export function chatRulesBlock(rules = loadRules(join(PACKAGE_ROOT, "genome", "rules"))) {
2973
3123
  return renderRulesBlock(rules);
2974
3124
  }
2975
- function registerBranding(pi, skills) {
3125
+ function registerBranding(pi, skills, welcomeVisible) {
2976
3126
  pi.registerCommand("stdlib", {
2977
3127
  description: "List the ***plain standard library: the stacks a spec can import instead of writing its implementation reqs.",
2978
3128
  handler: async (_args, ctx) => {
@@ -2989,8 +3139,8 @@ function registerBranding(pi, skills) {
2989
3139
  (data.commit !== undefined ? theme.fg("dim", ` from a clone, ${data.commit}${data.changed ? " with changes" : ""}`) : ""),
2990
3140
  // A newer turri out, or one installed and hidden behind this one: said first, under the version it is about.
2991
3141
  ...(data.versions ?? []).map((line) => theme.fg("warning", line)),
2992
- // A key renamed is information; the rest are the person's to take out.
2993
- ...(data.config ?? []).map((line) => theme.fg(line.kind === "renamed" ? "muted" : "warning", line.text)),
3142
+ // A key renamed is information; one that does not parse stops everything that reads it; the rest are the person's to take out.
3143
+ ...(data.config ?? []).map((line) => theme.fg(line.kind === "renamed" ? "muted" : line.kind === "broken" ? "error" : "warning", line.text)),
2994
3144
  `${theme.fg("text", "the first coding agent with the power of ")}${brandPink(theme)("regenerative software")}`,
2995
3145
  // Where the settings are changed, without leaving the chat.
2996
3146
  theme.fg("muted", "configure with /settings"),
@@ -3015,7 +3165,10 @@ function registerBranding(pi, skills) {
3015
3165
  pi.on("session_start", (_event, ctx) => {
3016
3166
  if (ctx.hasUI) {
3017
3167
  padTheScreen(ctx);
3018
- animateJellyfish(ctx);
3168
+ if (welcomeVisible())
3169
+ animateJellyfish(ctx, welcomeVisible);
3170
+ // ***plain an agent shows in the chat, highlighted in the theme of the moment.
3171
+ highlightPlainCodeBlocks(() => ctx.ui.theme);
3019
3172
  }
3020
3173
  // Once a chat: it starts again each time it is shown.
3021
3174
  if (bannered)
@@ -3068,13 +3221,17 @@ let jellyfishTimer;
3068
3221
  * jellyfish stops for the rest of the session - swimming, whole, drawn once more if it was not, rather than on whatever
3069
3222
  * frame it was at, a polyp half grown.
3070
3223
  */
3071
- export function animateJellyfish(ctx) {
3224
+ export function animateJellyfish(ctx, visible = () => true) {
3072
3225
  if (jellyfishTimer !== undefined)
3073
3226
  clearInterval(jellyfishTimer);
3074
3227
  jellyfishTimer = undefined;
3075
3228
  ctx.ui.setWidget(JELLYFISH_CLOCK_KEY, (tui) => {
3076
3229
  drawOverlaysBesidePicture(tui);
3077
3230
  const timer = setInterval(() => {
3231
+ if (!visible()) {
3232
+ clearInterval(timer);
3233
+ return;
3234
+ }
3078
3235
  if (tui.render(tui.terminal.columns).length > tui.terminal.rows) {
3079
3236
  clearInterval(timer);
3080
3237
  if (shownFrame() !== JELLYFISH_SEQUENCE[JELLYFISH_REST]) {
package/dist/identity.js CHANGED
@@ -42,7 +42,8 @@ const IDENTITY_BEFORE = [
42
42
  "regenerative software - you write ***plain with them and regenerate the code from it. Never say they write the",
43
43
  "***plain and you help: you write it, together. Not an assistant, and not a helper with specifications: ***plain is",
44
44
  "the language the software is written in, and naming it is the point. Your replies are Markdown, where",
45
- "three asterisks start bold italics: write the name escaped, \\*\\*\\*plain, so it shows as ***plain.",
45
+ "three asterisks start bold italics: write the name escaped, \\*\\*\\*plain, so it shows as ***plain. ***plain you",
46
+ "show is fenced as ```plain, which highlights it.",
46
47
  "",
47
48
  "Speak as turri, in the first person - I, my pulses, my agents - to the person, in whole sentences. Never speak of",
48
49
  "turri in the third person, as if it were someone else, and never tell the person to tell or ask turri something:",
@@ -4,7 +4,7 @@ import { type CatalogueModel, type ModelCatalogue } from "./model-check.ts";
4
4
  * write the code - so a new project starts with a choice that works rather than an empty file. It asks which vendor's
5
5
  * models you use and fills in theirs. Every other setting is written out with the value turri uses for it (DEFAULTS),
6
6
  * so the file says how the project is built; the optional ones, which have no value of their own - the testing
7
- * scripts, `module`, `judge-model`, `models` - are there commented out, with an example. docs/config.md has them all.
7
+ * scripts, `module`, `judge-model` - are there commented out, with an example. The three capture models are active.
8
8
  *
9
9
  * Then it says what to do next: where the file is - turri reads it from that folder and the folders below it, nowhere
10
10
  * else - and how to sign in to the vendor so pi, which turri runs on, can reach the models.
@@ -128,6 +128,9 @@ export declare function defaultParallel(cores?: number): number;
128
128
  export declare function quickStartConfig(vendor?: Vendor, bedrock?: BedrockChoice, models?: ModelSet): string;
129
129
  /** The quick start config for the mix of vendors: what turri wrote before it asked. */
130
130
  export declare const QUICK_START_CONFIG: string;
131
+ /** A capture without a config starts with init-config's settings. Resolve an omitted model from the vendor's pair,
132
+ * including the maker and geography on Bedrock, just as the wizard does. */
133
+ export declare function quickStartForCapture(harness?: string, coding?: string): Promise<string>;
131
134
  /** A vendor from what was typed: its number in the list, or its name. */
132
135
  export declare function vendorOf(answer: string): Vendor | undefined;
133
136
  /** Bedrock's maker from what was typed: its number in the list - with no catalogue, 1 Anthropic, 2 OpenAI - or its name. */