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

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 (106) 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 +361 -0
  5. package/dist/capture/agents.js +332 -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 +122 -0
  9. package/dist/capture/assemble.js +452 -0
  10. package/dist/capture/capture.d.ts +116 -0
  11. package/dist/capture/capture.js +1228 -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 +643 -0
  16. package/dist/capture/config.d.ts +13 -0
  17. package/dist/capture/config.js +60 -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/progress.d.ts +108 -0
  23. package/dist/capture/progress.js +234 -0
  24. package/dist/capture/report.d.ts +75 -0
  25. package/dist/capture/report.js +267 -0
  26. package/dist/capture/scripts.d.ts +26 -0
  27. package/dist/capture/scripts.js +33 -0
  28. package/dist/capture/state.d.ts +296 -0
  29. package/dist/capture/state.js +43 -0
  30. package/dist/capture/trial.d.ts +34 -0
  31. package/dist/capture/trial.js +89 -0
  32. package/dist/capture-cli.d.ts +1 -0
  33. package/dist/capture-cli.js +77 -0
  34. package/dist/chat-tabs.d.ts +7 -1
  35. package/dist/chat-tabs.js +10 -6
  36. package/dist/chat-terminal.js +5 -2
  37. package/dist/chats.d.ts +11 -8
  38. package/dist/chats.js +34 -20
  39. package/dist/cli.js +32 -14
  40. package/dist/config-edit.js +1 -0
  41. package/dist/config.d.ts +15 -2
  42. package/dist/config.js +57 -3
  43. package/dist/extension.d.ts +1 -0
  44. package/dist/extension.js +188 -55
  45. package/dist/identity.js +2 -1
  46. package/dist/init-config.js +1 -0
  47. package/dist/loop-cli.js +5 -1
  48. package/dist/loop-tools.js +5 -1
  49. package/dist/new-project.d.ts +5 -0
  50. package/dist/new-project.js +11 -0
  51. package/dist/pi-launch.js +2 -0
  52. package/dist/pi-themes.d.ts +3 -0
  53. package/dist/pi-themes.js +21 -0
  54. package/dist/pi.js +2 -2
  55. package/dist/plain-code-blocks.d.ts +14 -0
  56. package/dist/plain-code-blocks.js +56 -0
  57. package/dist/pointer-hover.d.ts +1 -1
  58. package/dist/pointer-hover.js +4 -0
  59. package/dist/question-dialog.d.ts +5 -0
  60. package/dist/question-dialog.js +20 -1
  61. package/dist/regenerate/command-check.js +80 -11
  62. package/dist/regenerate/job-panel.d.ts +5 -107
  63. package/dist/regenerate/job-panel.js +4 -289
  64. package/dist/regenerate/loop.js +9 -1
  65. package/dist/regenerate/side-panel.d.ts +2 -0
  66. package/dist/regenerate/side-panel.js +32 -5
  67. package/dist/regenerate/spec-map-view.d.ts +2 -2
  68. package/dist/regenerate/test-scripts.d.ts +5 -0
  69. package/dist/regenerate/test-scripts.js +4 -0
  70. package/dist/reopen.d.ts +29 -0
  71. package/dist/reopen.js +47 -0
  72. package/dist/sentinel-chat.js +7 -2
  73. package/dist/sentinel.d.ts +1 -1
  74. package/dist/sentinel.js +3 -1
  75. package/dist/setup.js +9 -1
  76. package/dist/terminal-notifications.d.ts +31 -0
  77. package/dist/terminal-notifications.js +134 -0
  78. package/docs/README.md +2 -0
  79. package/docs/capture.md +191 -0
  80. package/docs/chats.md +3 -2
  81. package/docs/config.md +15 -3
  82. package/docs/development.md +4 -1
  83. package/docs/hosting.md +2 -2
  84. package/docs/launch.md +2 -2
  85. package/docs/regenerating.md +1 -1
  86. package/docs/sandbox.md +2 -2
  87. package/docs/sentinel.md +11 -11
  88. package/docs/theming.md +3 -3
  89. package/docs/using.md +7 -3
  90. package/genome/capture/capture.md +26 -0
  91. package/genome/capture/check-conventions.md +5 -0
  92. package/genome/capture/check-reference.md +11 -0
  93. package/genome/capture/concepts.md +3 -0
  94. package/genome/capture/divide.md +9 -0
  95. package/genome/capture/feature.md +45 -0
  96. package/genome/capture/interface.md +9 -0
  97. package/genome/capture/modules.md +23 -0
  98. package/genome/capture/outline.md +11 -0
  99. package/genome/capture/readability.md +12 -0
  100. package/genome/capture/reference.md +10 -0
  101. package/genome/capture/split.md +9 -0
  102. package/genome/capture/survey.md +37 -0
  103. package/genome/capture/trial.md +18 -0
  104. package/genome/capture/verify.md +7 -0
  105. package/genome/rules/turri-regeneration.md +1 -1
  106. package/package.json +1 -1
package/dist/chats.d.ts CHANGED
@@ -2,9 +2,10 @@ import type { AgentSession, ExtensionAPI, ExtensionContext, ExtensionFactory, Ex
2
2
  import { type ChatScope } from "./chat-scope.ts";
3
3
  import { type RunRecord } from "./chat-records.ts";
4
4
  import { type ChatUi } from "./chat-ui.ts";
5
+ import { TerminalNotifications } from "./terminal-notifications.ts";
5
6
  import { type SentinelSetting } from "./config.ts";
6
7
  import type { AskUserIO } from "./ask.ts";
7
- import type { Job, JobRegistry } from "./regenerate/jobs.ts";
8
+ import { type Job, type JobRegistry } from "./regenerate/jobs.ts";
8
9
  import type { Launch } from "./launch-track.ts";
9
10
  import type { ToolDefinition } from "@earendil-works/pi-coding-agent";
10
11
  import { type ChatRole, type Conclusion, type Notice, type NoticeAnswer, type NoticeInput, type SentinelCheck } from "./notice.ts";
@@ -77,7 +78,7 @@ export interface TurriHost {
77
78
  * The host shows the person each pulse that lands and each of the sentinel's conclusions itself - its own
78
79
  * notifications, from onJobChange and onConcluded. With the sentinel on, the chat the person is in is then told of both
79
80
  * without a turn of its own: its agent knows what landed and what the sentinel found when the person asks, and does
80
- * not say it again in the conversation. Unset, it says both, as in the terminal.
81
+ * not say it again in the conversation. Unset in a host, it says both.
81
82
  */
82
83
  pulseEndsShown?: boolean;
83
84
  /**
@@ -102,8 +103,12 @@ export interface TurriHost {
102
103
  }
103
104
  /** What a chat's extension does for its chat when the session asks. */
104
105
  export interface ChatInstance {
105
- /** The terminal header's button: open the project's spec map beside this chat. */
106
- openPlainPanel?(): void;
106
+ /** The terminal header's toggle. Visibility is independent of which side has the keys. */
107
+ plainPanel?: {
108
+ open(): boolean;
109
+ busy(): boolean;
110
+ toggle(): void;
111
+ };
107
112
  /** A pulse it asked for ended: said in the chat, and its agent told, to react to it. */
108
113
  announce(job: Job): void;
109
114
  /**
@@ -141,8 +146,6 @@ export interface ChatInstance {
141
146
  concluded(conclusion: Conclusion): void;
142
147
  /** The person answered a notice with something to do: the chat's agent started on it. */
143
148
  act(task: string): void;
144
- /** The jobs changed: what it draws of them is drawn again. */
145
- jobsChanged(): void;
146
149
  /** How hard the chat's model thinks now: sub-agents started from it think as hard. */
147
150
  thinkingLevel(): string | undefined;
148
151
  /** The chat's context, as its tools get it - for its model and its providers. */
@@ -191,6 +194,8 @@ export interface ChatState {
191
194
  unsubscribe?: () => void;
192
195
  }
193
196
  export interface TurriCore {
197
+ /** Shared by all the terminal's chats. */
198
+ readonly notifications: TerminalNotifications;
194
199
  readonly cwd: string;
195
200
  readonly host: TurriHost;
196
201
  readonly jobs: JobRegistry;
@@ -269,8 +274,6 @@ export interface TurriCore {
269
274
  * `refused`: `ignore` on one that is not ignorable.
270
275
  */
271
276
  answer(id: string, answer: NoticeAnswer): "done" | "dismissed" | "ignored" | "refused" | "missing" | "over";
272
- /** For the extension: the jobs changed - every chat draws them again. */
273
- jobsChanged(): void;
274
277
  /** The chat whose work this is, else the one shown: its instance. */
275
278
  instanceInScope(): ChatInstance | undefined;
276
279
  setDriver(driver: ChatDriver): void;
package/dist/chats.js CHANGED
@@ -3,8 +3,10 @@ import { existsSync } from "node:fs";
3
3
  import { currentChat, inChat } from "./chat-scope.js";
4
4
  import { adoptRun, forgetChat, forgetSessionFile, recordRun } from "./chat-records.js";
5
5
  import { createChatUi } from "./chat-ui.js";
6
+ import { TerminalNotifications } from "./terminal-notifications.js";
6
7
  import { debugMode } from "./config.js";
7
8
  import { firstLine, record } from "./regenerate/ledger.js";
9
+ import { pulseName, formatDuration } from "./regenerate/jobs.js";
8
10
  import { newNotice, noticeTask, SENTINEL, sentinelStartChoice, wentWrong } from "./notice.js";
9
11
  /**
10
12
  * The chats of a turri session.
@@ -204,6 +206,7 @@ export function createChats(options) {
204
206
  });
205
207
  };
206
208
  const core = {
209
+ notifications: new TerminalNotifications(),
207
210
  cwd,
208
211
  host,
209
212
  jobs,
@@ -385,6 +388,11 @@ export function createChats(options) {
385
388
  },
386
389
  sentinelOn: () => driver !== undefined && wantsSentinel(),
387
390
  jobFinished(job) {
391
+ if (core.terminal) {
392
+ const result = job.status === "succeeded" ? wentWrong(job) ? "did not pass" : "finished" : job.status;
393
+ core.notifications.add(`${pulseName(job)} · ${result} after ${formatDuration(job)}`, job.error ?? job.report ?? job.note ?? "");
394
+ changed();
395
+ }
388
396
  // The question was settled in config.turri.yaml while it was open: what it held goes as the file now says.
389
397
  if (consent === "asking" && setting() !== "ask")
390
398
  settleStart(setting() === true ? "given" : "declined", "superseded");
@@ -451,16 +459,6 @@ export function createChats(options) {
451
459
  sentinelChecks(check);
452
460
  return { check: check.id };
453
461
  },
454
- jobsChanged() {
455
- for (const chat of chats) {
456
- try {
457
- chat.instance?.jobsChanged();
458
- }
459
- catch {
460
- /* a chat let go draws nothing */
461
- }
462
- }
463
- },
464
462
  notice(input) {
465
463
  // A check's notice is about its module.
466
464
  const about = input.check !== undefined ? checks.get(input.check) : undefined;
@@ -479,7 +477,13 @@ export function createChats(options) {
479
477
  const { ignorable, ...rest } = input;
480
478
  const notice = newNotice(ignorable === true && input.kind === undefined ? input : rest, target.id);
481
479
  open.push(notice);
482
- if (target.id !== shownId)
480
+ if (core.terminal) {
481
+ // notify_person may omit the id; the sentinel still has exactly one review in progress.
482
+ const work = checking?.work;
483
+ const about = work && currentChat()?.id === sentinelChat()?.id ? ("pulse" in work ? { job: work.pulse.id } : { check: work.check.id }) : undefined;
484
+ core.notifications.put(notice, about);
485
+ }
486
+ else if (target.id !== shownId)
483
487
  target.unread = true;
484
488
  inChat(target.scope, () => record({ kind: "notice.put", notice: notice.id, severity: notice.severity, ...(notice.module !== undefined ? { module: notice.module } : {}) }, { project: cwd }));
485
489
  try {
@@ -511,7 +515,9 @@ export function createChats(options) {
511
515
  const module = conclusion.module ?? job?.module ?? check?.module;
512
516
  const pulse = conclusion.pulse ?? job?.pulse;
513
517
  const told = { ...conclusion, ...(module !== undefined ? { module } : {}), ...(pulse !== undefined ? { pulse } : {}) };
514
- if (target.id !== shownId)
518
+ if (core.terminal)
519
+ core.notifications.concluded(told);
520
+ else if (target.id !== shownId)
515
521
  target.unread = true;
516
522
  inChat(target.scope, () => record({ kind: "sentinel.concluded", verdict: told.verdict, ...(module !== undefined ? { module } : {}), ...(told.check !== undefined ? { check: told.check } : {}) }, { project: cwd, ...(told.job !== undefined ? { job: told.job } : {}) }));
517
523
  try {
@@ -543,7 +549,7 @@ export function createChats(options) {
543
549
  options.ignored?.(notice);
544
550
  }
545
551
  catch (error) {
546
- core.notify(`The sentinel's guidance could not be written: ${error instanceof Error ? error.message : String(error)}`, "warning");
552
+ sentinelMessage(`The sentinel's guidance could not be written: ${error instanceof Error ? error.message : String(error)}`, "warning");
547
553
  }
548
554
  over(notice, "ignored");
549
555
  return "ignored";
@@ -603,6 +609,8 @@ export function createChats(options) {
603
609
  }
604
610
  if (chat !== undefined)
605
611
  inChat(chat.scope, () => record({ kind: "notice.over", notice: notice.id, state }, { project: cwd }));
612
+ if (core.terminal)
613
+ changed();
606
614
  }
607
615
  /** A pulse ended, told to the chat that asked for it - as without a sentinel - or the chat shown, when that one is closed. */
608
616
  function toAsker(job) {
@@ -704,7 +712,7 @@ export function createChats(options) {
704
712
  const asked = chats.find((chat) => chat.id === job.chat && chat.role !== SENTINEL);
705
713
  const where = personFacing(asked);
706
714
  if (where !== undefined) {
707
- if (where.id !== shownId)
715
+ if (where.id !== shownId && !core.terminal)
708
716
  where.unread = true;
709
717
  try {
710
718
  where.instance?.landed(job, { tell: !wentWrong(job) });
@@ -739,7 +747,7 @@ export function createChats(options) {
739
747
  }
740
748
  catch (error) {
741
749
  const why = error instanceof Error ? error.message : String(error);
742
- core.notify(`The sentinel could not be opened: ${why}`, "warning");
750
+ sentinelMessage(`The sentinel could not be opened: ${why}`, "warning");
743
751
  failed(why);
744
752
  return undefined;
745
753
  }
@@ -750,10 +758,16 @@ export function createChats(options) {
750
758
  function unchecked(check, why) {
751
759
  core.concluded({ check: check.id, module: check.module, verdict: "unchecked", summary: `Not checked: ${why}.` });
752
760
  }
761
+ function sentinelMessage(message, level) {
762
+ if (!core.terminal)
763
+ return core.notify(message, level);
764
+ core.notifications.add(message, "");
765
+ changed();
766
+ }
753
767
  /** The sentinel's work, after what it was given before. */
754
768
  function toSentinel(work) {
755
769
  sentinelWork = sentinelWork.then(work).catch((error) => {
756
- core.notify(`The sentinel: ${error instanceof Error ? error.message : String(error)}`, "warning");
770
+ sentinelMessage(`The sentinel: ${error instanceof Error ? error.message : String(error)}`, "warning");
757
771
  });
758
772
  }
759
773
  /**
@@ -788,7 +802,7 @@ export function createChats(options) {
788
802
  async function refuse(sentinel, work, why) {
789
803
  const module = codebaseOf(work);
790
804
  inChat(sentinel.scope, () => record({ kind: "sentinel.refused", ...(module !== undefined ? { module } : {}), ...("check" in work ? { check: work.check.id } : {}), why: firstLine(why, 300) }, { project: cwd, ...("pulse" in work ? { job: work.pulse.id } : {}) }));
791
- if ("pulse" in work)
805
+ if ("pulse" in work && !core.terminal)
792
806
  core.notify(`The sentinel cannot check pulse ${work.pulse.id}: ${why}`, "error");
793
807
  core.concluded({
794
808
  ...("pulse" in work ? { job: work.pulse.id } : { check: work.check.id }),
@@ -823,7 +837,7 @@ export function createChats(options) {
823
837
  await sentinel.instance.briefCheck(check, where !== undefined ? { focused: titleFor(where) } : {});
824
838
  }
825
839
  catch (error) {
826
- core.notify(`The sentinel could not be told of check ${check.id}: ${error instanceof Error ? error.message : String(error)}`, "warning");
840
+ sentinelMessage(`The sentinel could not be told of check ${check.id}: ${error instanceof Error ? error.message : String(error)}`, "warning");
827
841
  checking = undefined;
828
842
  }
829
843
  changed();
@@ -856,7 +870,7 @@ export function createChats(options) {
856
870
  });
857
871
  }
858
872
  catch (error) {
859
- core.notify(`The sentinel could not be told of ${job.id}: ${error instanceof Error ? error.message : String(error)}`, "warning");
873
+ sentinelMessage(`The sentinel could not be told of ${job.id}: ${error instanceof Error ? error.message : String(error)}`, "warning");
860
874
  checking = undefined;
861
875
  }
862
876
  changed();
@@ -933,7 +947,7 @@ export function createChats(options) {
933
947
  catch (error) {
934
948
  Object.assign(chat, old);
935
949
  follow(chat);
936
- core.notify(`The sentinel goes on in the conversation it had - a new one could not be started: ${error instanceof Error ? error.message : String(error)}`, "warning");
950
+ sentinelMessage(`The sentinel goes on in the conversation it had - a new one could not be started: ${error instanceof Error ? error.message : String(error)}`, "warning");
937
951
  return;
938
952
  }
939
953
  const fresh = chat.session;
package/dist/cli.js CHANGED
@@ -15,12 +15,14 @@ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExte
15
15
  return path;
16
16
  };
17
17
  import { spawnSync } from "node:child_process";
18
+ import { tmpdir } from "node:os";
18
19
  import { dirname, join } from "node:path";
19
20
  import { fileURLToPath } from "node:url";
20
21
  import { CODING_MODEL_ENV, chatModels } from "./chat-models.js";
21
22
  import { readProjectConfig } from "./config.js";
22
23
  import { extensionInstalledGlobally, PACKAGE_ROOT, themesInstalledGlobally, versionLine } from "./environment.js";
23
24
  import { dropNoise } from "./quiet.js";
25
+ import { REOPEN_FILE_ENV, takeReopening } from "./reopen.js";
24
26
  /**
25
27
  * Start pi with this project's extension and themes already wired in.
26
28
  *
@@ -56,20 +58,35 @@ function chat(args) {
56
58
  // in as well: pi-launch.ts is told, and leaves it to that. turri doctor offers to remove the file.
57
59
  const inPi = extensionInstalledGlobally();
58
60
  const themes = themesInstalledGlobally() ? [] : ["--theme", join(PACKAGE_ROOT, ".pi", "themes")];
59
- // turri's own theme, unless this run names another. For this run only: pi's settings
60
- // are left as they are, so a plain `pi` keeps its theme.
61
- const useTheme = args.some((arg) => arg === "--use-theme" || arg.startsWith("--use-theme=")) ? [] : ["--use-theme", DEFAULT_THEME];
62
- // The model the person talks to, and the one every render runs on - see chat-models.ts.
63
- const { piArgs, codingModel } = chatModels(args, readProjectConfig(process.cwd()));
64
- // Fullscreen: pi owns the viewport, so the conversation stays where it is scrolled to while the
65
- // jobs redraw - in the terminal's own scrollback, every redraw pulls it back to the bottom.
66
- const tuiMode = args.some((arg) => arg === "--tui-mode" || arg.startsWith("--tui-mode=")) ? [] : ["--tui-mode", "fullscreen"];
67
- const result = spawnSync(process.execPath, [launcher, ...themes, ...useTheme, ...tuiMode, ...piArgs], {
68
- stdio: "inherit",
69
- cwd: process.cwd(),
70
- env: { ...process.env, ...(codingModel ? { [CODING_MODEL_ENV]: codingModel } : {}), ...(inPi ? { TURRI_EXTENSION_IN_PI: "1" } : {}) },
71
- });
72
- process.exit(result.status ?? 1);
61
+ // A chat that quits asking to open again elsewhere - after a capture, in the project it wrote - writes where in this
62
+ // file, and is started again there, as the first was (reopen.ts).
63
+ const reopenFile = join(tmpdir(), `turri-reopen-${process.pid}.json`);
64
+ let run = { cwd: process.cwd(), args, env: {} };
65
+ for (;;) {
66
+ // turri's own theme, unless this run names another. For this run only: pi's settings
67
+ // are left as they are, so a plain `pi` keeps its theme.
68
+ const useTheme = run.args.some((arg) => arg === "--use-theme" || arg.startsWith("--use-theme=")) ? [] : ["--use-theme", DEFAULT_THEME];
69
+ // The model the person talks to, and the one every render runs on - see chat-models.ts.
70
+ const { piArgs, codingModel } = chatModels(run.args, readProjectConfig(run.cwd));
71
+ // Fullscreen: pi owns the viewport, so the conversation stays where it is scrolled to while the
72
+ // jobs redraw - in the terminal's own scrollback, every redraw pulls it back to the bottom.
73
+ const tuiMode = run.args.some((arg) => arg === "--tui-mode" || arg.startsWith("--tui-mode=")) ? [] : ["--tui-mode", "fullscreen"];
74
+ const result = spawnSync(process.execPath, [launcher, ...themes, ...useTheme, ...tuiMode, ...piArgs], {
75
+ stdio: "inherit",
76
+ cwd: run.cwd,
77
+ env: {
78
+ ...process.env,
79
+ ...run.env,
80
+ [REOPEN_FILE_ENV]: reopenFile,
81
+ ...(codingModel ? { [CODING_MODEL_ENV]: codingModel } : {}),
82
+ ...(inPi ? { TURRI_EXTENSION_IN_PI: "1" } : {}),
83
+ },
84
+ });
85
+ const next = takeReopening(reopenFile);
86
+ if (next === undefined)
87
+ process.exit(result.status ?? 1);
88
+ run = { cwd: next.dir, args: next.args, env: next.env };
89
+ }
73
90
  }
74
91
  const COMMANDS = {
75
92
  regenerate: { module: "./regenerate-cli.ts", blurb: "regenerate a module and its chain from the spec as it is (with module:func-ids: regenerate those again)" },
@@ -79,6 +96,7 @@ const COMMANDS = {
79
96
  lineage: { module: "./lineage-cli.ts", blurb: "a module's lineage: what was regenerated into it, and when" },
80
97
  launch: { module: "./launch-cli.ts", blurb: "launch what is regenerated from dist/<module> on this machine" },
81
98
  cultivate: { module: "./cultivate-cli.ts", blurb: "run a gated skill" },
99
+ capture: { module: "./capture-cli.ts", blurb: "capture an existing codebase into ***plain, in <path>/plain - offline, with a report of what it decided" },
82
100
  };
83
101
  /** Getting the machine ready, and checking it is. */
84
102
  const SETUP_COMMANDS = {
@@ -22,6 +22,7 @@ const ROLE_ABOUT = {
22
22
  chat: "the conversation - as harness-model, which it wins over",
23
23
  sentinel: "the sentinel: checks every finished pulse and tests what is launched",
24
24
  planner: "cuts the work into pulses",
25
+ capture: "captures an existing codebase into ***plain",
25
26
  diagnosis: "looks into a pulse that failed for good",
26
27
  launch: "the launch agent",
27
28
  coding: "writes the code - as coding-model, which it wins over",
package/dist/config.d.ts CHANGED
@@ -143,7 +143,7 @@ export interface ModelChoice {
143
143
  * The code fixer of a conformance run and the repair agent are coding agents; the unit-test and conformance arbiters
144
144
  * are both `arbiter`.
145
145
  */
146
- export declare const AGENT_ROLES: readonly ["chat", "sentinel", "planner", "diagnosis", "launch", "coding", "conformance", "explorer", "reviewer", "test-reviewer", "judge", "arbiter", "debugger"];
146
+ export declare const AGENT_ROLES: readonly ["chat", "sentinel", "planner", "capture", "diagnosis", "launch", "coding", "conformance", "explorer", "reviewer", "test-reviewer", "judge", "arbiter", "debugger"];
147
147
  export type AgentRole = (typeof AGENT_ROLES)[number];
148
148
  /**
149
149
  * How hard each role thinks when nothing names a level - not the config's `models:`, nor a `:level` on the model it is
@@ -399,7 +399,7 @@ export declare function unknownConfigKeys(root: string): Array<{
399
399
  * a key turri renamed in the file - information, nothing to do; `old-beside-new`, an old name left beside its new one,
400
400
  * doing nothing - take it out; `unknown`, keys turri does not read - take them out, or fix their spelling.
401
401
  */
402
- export type ConfigLineKind = "renamed" | "old-beside-new" | "unknown";
402
+ export type ConfigLineKind = "broken" | "renamed" | "old-beside-new" | "unknown";
403
403
  export interface ConfigLine {
404
404
  kind: ConfigLineKind;
405
405
  /** The file, from the project: `config.turri.yaml`, `config.turri.<module>.yaml`. */
@@ -412,4 +412,17 @@ export interface ConfigLine {
412
412
  * beside its new one - doing nothing - and each file with keys turri does not read.
413
413
  */
414
414
  export declare function configLines(root: string): ConfigLine[];
415
+ /**
416
+ * Why a config file does not parse - its line and what YAML says, a key set twice among them - or undefined when it
417
+ * parses or is not there. turri reads a config that does not parse as empty, every setting at its default, the models
418
+ * pi's own: said, never silently.
419
+ */
420
+ export declare function configFileProblem(path: string): string | undefined;
421
+ /** The config files of a project folder that do not parse - config.turri.yaml and each module's own - each with why. */
422
+ export declare function configProblems(root: string): Array<{
423
+ file: string;
424
+ text: string;
425
+ }>;
426
+ /** Why a project's config does not parse, in a sentence for a refusal - undefined when every file of it parses. */
427
+ export declare function brokenConfig(root: string): string | undefined;
415
428
  export {};
package/dist/config.js CHANGED
@@ -303,7 +303,7 @@ export const THINKING_LEVELS = ["off", "minimal", "low", "medium", "high", "xhig
303
303
  * The code fixer of a conformance run and the repair agent are coding agents; the unit-test and conformance arbiters
304
304
  * are both `arbiter`.
305
305
  */
306
- export const AGENT_ROLES = ["chat", "sentinel", "planner", "diagnosis", "launch", "coding", "conformance", "explorer", "reviewer", "test-reviewer", "judge", "arbiter", "debugger"];
306
+ export const AGENT_ROLES = ["chat", "sentinel", "planner", "capture", "diagnosis", "launch", "coding", "conformance", "explorer", "reviewer", "test-reviewer", "judge", "arbiter", "debugger"];
307
307
  /**
308
308
  * How hard each role thinks when nothing names a level - not the config's `models:`, nor a `:level` on the model it is
309
309
  * given. The agents that do the work - write the code and the tests, explore, launch - think little: they work from a
@@ -321,12 +321,14 @@ export const ROLE_THINKING = {
321
321
  arbiter: "medium",
322
322
  debugger: "medium",
323
323
  planner: "medium",
324
+ capture: "medium",
324
325
  diagnosis: "medium",
325
326
  };
326
327
  /** The roles on the conversation's side: without their own entry they take the chat's model, not `default`. */
327
328
  // The launch is not: it follows steps - a script, a start command - and runs on the coding model, thinking low. Nor
328
329
  // is the diagnosis: a post-mortem of a job that failed, read by the person - it runs on the coding model, thinking medium.
329
- const CHAT_SIDE = ["chat", "sentinel", "planner"];
330
+ // Capture is too: it writes ***plain, as the chat does.
331
+ const CHAT_SIDE = ["chat", "sentinel", "planner", "capture"];
330
332
  function isThinkingLevel(value) {
331
333
  return typeof value === "string" && THINKING_LEVELS.includes(value);
332
334
  }
@@ -731,6 +733,7 @@ export function unknownConfigKeys(root) {
731
733
  * beside its new one - doing nothing - and each file with keys turri does not read.
732
734
  */
733
735
  export function configLines(root) {
736
+ const broken = configProblems(root).map((problem) => ({ kind: "broken", file: problem.file, text: `${problem.text} - so none of ${problem.file} applies: turri runs on its defaults and pi's, the models among them. Set each key once.` }));
734
737
  const renamed = renameOldKeys(root).map(({ file, from, to }) => ({ kind: "renamed", file, text: `${file}: ${from} is called ${to} now - turri renamed it there, its value kept.` }));
735
738
  const left = [];
736
739
  for (const file of namesIn(root).filter((name) => /^config\.turri(\.[^.]+)?\.yaml$/.test(name)).sort()) {
@@ -753,5 +756,56 @@ export function configLines(root) {
753
756
  file,
754
757
  text: `${file} has ${keys.length === 1 ? "a key" : "keys"} turri does not read - ${keys.join(", ")}: no setting turri has, so ${keys.length === 1 ? "it does" : "they do"} nothing. Take ${keys.length === 1 ? "it" : "them"} out, or see docs/config.md for the spelling.`,
755
758
  }));
756
- return [...renamed, ...left, ...unknown];
759
+ return [...broken, ...renamed, ...left, ...unknown];
760
+ }
761
+ /**
762
+ * Why a config file does not parse - its line and what YAML says, a key set twice among them - or undefined when it
763
+ * parses or is not there. turri reads a config that does not parse as empty, every setting at its default, the models
764
+ * pi's own: said, never silently.
765
+ */
766
+ export function configFileProblem(path) {
767
+ let text;
768
+ try {
769
+ if (!statSync(path).isFile())
770
+ return undefined;
771
+ text = readFileSync(path, "utf8");
772
+ }
773
+ catch {
774
+ return undefined;
775
+ }
776
+ const file = basename(path);
777
+ try {
778
+ const parsed = loadYaml(text);
779
+ if (parsed !== null && parsed !== undefined && (typeof parsed !== "object" || Array.isArray(parsed)))
780
+ return `${file} is not a list of settings, a key and its value a line`;
781
+ return undefined;
782
+ }
783
+ catch (error) {
784
+ const reason = error.reason;
785
+ const line = error.mark?.line;
786
+ const at = typeof line === "number" ? `, line ${line + 1}` : "";
787
+ const key = typeof line === "number" ? /^\s*([\w.-]+)\s*:/.exec(text.split("\n")[line] ?? "")?.[1] : undefined;
788
+ if (reason === "duplicated mapping key")
789
+ return `${file}${at}: ${key !== undefined ? `${key} is` : "a key is"} set twice`;
790
+ return `${file}${at} does not parse: ${typeof reason === "string" ? reason : error instanceof Error ? error.message.split("\n")[0] : String(error)}`;
791
+ }
792
+ }
793
+ /** The config files of a project folder that do not parse - config.turri.yaml and each module's own - each with why. */
794
+ export function configProblems(root) {
795
+ return namesIn(root)
796
+ // config.yaml only while turri reads it: until it writes config.turri.yaml, it may be another tool's.
797
+ .filter((name) => /^config\.turri(\.[^.]+)?\.yaml$/.test(name) || (name === LEGACY_CONFIG_FILE && usesLegacyConfig(root)))
798
+ .sort()
799
+ .flatMap((file) => {
800
+ const text = configFileProblem(join(root, file));
801
+ return text === undefined ? [] : [{ file, text }];
802
+ });
803
+ }
804
+ /** Why a project's config does not parse, in a sentence for a refusal - undefined when every file of it parses. */
805
+ export function brokenConfig(root) {
806
+ const problems = configProblems(root);
807
+ if (problems.length === 0)
808
+ return undefined;
809
+ return (`${problems.map((problem) => problem.text).join("; ")}. A config that does not parse is read as empty: none of it would apply - ` +
810
+ `not the models, not conformance tests, no other setting - and turri would run on its defaults and pi's. Fix it - each key set once - then ask again.`);
757
811
  }
@@ -162,6 +162,7 @@ export { fromWorkingDir };
162
162
  */
163
163
  export declare function pulseEndNote(job: Job, options?: {
164
164
  launching?: boolean;
165
+ quiet?: boolean;
165
166
  }): string;
166
167
  /**
167
168
  * 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