@turri-dev/cli 0.4.2-next.a6867e8 → 0.4.3-next.3fc888b

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 (128) 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 +391 -0
  5. package/dist/capture/agents.js +338 -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 +1281 -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 +58 -0
  21. package/dist/capture/map.js +530 -0
  22. package/dist/capture/plan.d.ts +8 -0
  23. package/dist/capture/plan.js +13 -0
  24. package/dist/capture/progress.d.ts +109 -0
  25. package/dist/capture/progress.js +240 -0
  26. package/dist/capture/report.d.ts +75 -0
  27. package/dist/capture/report.js +268 -0
  28. package/dist/capture/scripts.d.ts +26 -0
  29. package/dist/capture/scripts.js +33 -0
  30. package/dist/capture/state.d.ts +299 -0
  31. package/dist/capture/state.js +43 -0
  32. package/dist/capture/trial.d.ts +34 -0
  33. package/dist/capture/trial.js +89 -0
  34. package/dist/capture-cli.d.ts +1 -0
  35. package/dist/capture-cli.js +77 -0
  36. package/dist/chat-commands.d.ts +2 -10
  37. package/dist/chat-commands.js +3 -57
  38. package/dist/chat-tab-header.d.ts +15 -0
  39. package/dist/chat-tab-header.js +78 -0
  40. package/dist/chat-tabs.d.ts +26 -0
  41. package/dist/chat-tabs.js +100 -0
  42. package/dist/chat-terminal.js +57 -8
  43. package/dist/chat-waiting.d.ts +4 -1
  44. package/dist/chat-waiting.js +7 -4
  45. package/dist/chats.d.ts +12 -7
  46. package/dist/chats.js +35 -21
  47. package/dist/cli.js +32 -14
  48. package/dist/config-edit.js +4 -2
  49. package/dist/config.d.ts +15 -2
  50. package/dist/config.js +62 -4
  51. package/dist/extension.d.ts +1 -0
  52. package/dist/extension.js +262 -136
  53. package/dist/identity.js +3 -2
  54. package/dist/init-config.js +2 -0
  55. package/dist/loop-cli.js +5 -1
  56. package/dist/loop-tools.d.ts +2 -3
  57. package/dist/loop-tools.js +12 -13
  58. package/dist/new-project.d.ts +5 -0
  59. package/dist/new-project.js +11 -0
  60. package/dist/pi-launch.js +2 -0
  61. package/dist/pi-themes.d.ts +3 -0
  62. package/dist/pi-themes.js +21 -0
  63. package/dist/pi.js +2 -2
  64. package/dist/plain-code-blocks.d.ts +14 -0
  65. package/dist/plain-code-blocks.js +56 -0
  66. package/dist/pointer-hover.d.ts +12 -0
  67. package/dist/pointer-hover.js +48 -0
  68. package/dist/question-dialog.d.ts +5 -0
  69. package/dist/question-dialog.js +20 -1
  70. package/dist/regenerate/chunk-plan.d.ts +2 -11
  71. package/dist/regenerate/chunk-plan.js +9 -20
  72. package/dist/regenerate/command-check.d.ts +9 -0
  73. package/dist/regenerate/command-check.js +163 -14
  74. package/dist/regenerate/job-panel.d.ts +5 -107
  75. package/dist/regenerate/job-panel.js +4 -289
  76. package/dist/regenerate/jobs-tree.d.ts +1 -0
  77. package/dist/regenerate/jobs-tree.js +5 -1
  78. package/dist/regenerate/loop.d.ts +6 -14
  79. package/dist/regenerate/loop.js +51 -35
  80. package/dist/regenerate/side-panel.d.ts +6 -1
  81. package/dist/regenerate/side-panel.js +158 -22
  82. package/dist/regenerate/spec-map-view.d.ts +11 -3
  83. package/dist/regenerate/spec-map-view.js +22 -2
  84. package/dist/regenerate/test-scripts.d.ts +8 -0
  85. package/dist/regenerate/test-scripts.js +20 -5
  86. package/dist/reopen.d.ts +29 -0
  87. package/dist/reopen.js +47 -0
  88. package/dist/resume-line.d.ts +4 -1
  89. package/dist/resume-line.js +5 -2
  90. package/dist/sentinel-chat.js +7 -2
  91. package/dist/sentinel.d.ts +1 -1
  92. package/dist/sentinel.js +4 -2
  93. package/dist/setup.js +9 -1
  94. package/dist/terminal-notifications.d.ts +31 -0
  95. package/dist/terminal-notifications.js +134 -0
  96. package/docs/README.md +2 -0
  97. package/docs/capture.md +207 -0
  98. package/docs/chats.md +8 -7
  99. package/docs/config.md +18 -3
  100. package/docs/development.md +4 -1
  101. package/docs/hosting.md +2 -2
  102. package/docs/launch.md +2 -2
  103. package/docs/regenerating.md +9 -8
  104. package/docs/sandbox.md +3 -1
  105. package/docs/sentinel.md +11 -11
  106. package/docs/skills-and-gates.md +1 -1
  107. package/docs/theming.md +3 -3
  108. package/docs/using.md +12 -5
  109. package/genome/capture/capture.md +26 -0
  110. package/genome/capture/check-conventions.md +5 -0
  111. package/genome/capture/check-reference.md +11 -0
  112. package/genome/capture/compact.md +7 -0
  113. package/genome/capture/concepts.md +3 -0
  114. package/genome/capture/divide.md +9 -0
  115. package/genome/capture/feature.md +45 -0
  116. package/genome/capture/interface.md +9 -0
  117. package/genome/capture/modules.md +23 -0
  118. package/genome/capture/outline.md +11 -0
  119. package/genome/capture/readability.md +12 -0
  120. package/genome/capture/reference.md +10 -0
  121. package/genome/capture/split.md +9 -0
  122. package/genome/capture/survey.md +37 -0
  123. package/genome/capture/trial.md +18 -0
  124. package/genome/capture/verify.md +7 -0
  125. package/genome/rules/turri-regeneration.md +2 -2
  126. package/package.json +3 -3
  127. package/dist/regenerate/steer.d.ts +0 -34
  128. package/dist/regenerate/steer.js +0 -91
@@ -53,5 +53,14 @@ export declare function writesPlain(command: string): string | undefined;
53
53
  export declare function runsBuiltCode(command: string): string | undefined;
54
54
  /** What turri says when a command would change the machine: what it does instead. */
55
55
  export declare function machineChangeReason(why: string): string;
56
+ /**
57
+ * The command as the shell reads its operators, the same length: what quotes hold has its `<`, `>`, `|`, `&`, `;` and
58
+ * newlines put out of the way - a `>` in `grep "</content>"` redirects nothing, a `;` in a string ends no command - and
59
+ * the body of a here-document fed to cat or tee with a quoted delimiter, so not expanded, is blanked: it is the text of
60
+ * a file being written, and a `../lib/logger` or a `>` in it is code, not a path or a redirection. A `$(...)` in double
61
+ * quotes, an unquoted delimiter's body and a here-document fed to anything else - a shell, an interpreter - run, and are
62
+ * read as they are.
63
+ */
64
+ export declare function shellCode(command: string): string;
56
65
  /** Check one command line against a role's fence: `{ ok: true }`, or which rule it breaks and what to do instead. */
57
66
  export declare function checkCommand(command: string, fence: CommandFence): CheckResult;
@@ -54,12 +54,50 @@ const INSTALLER_FILE = /\.(run|pkg|msi|dmg)$/i;
54
54
  function words(segment) {
55
55
  return (segment.match(/"[^"]*"|'[^']*'|[^\s"']+(?:(?:"[^"]*"|'[^']*')[^\s"']*)*/g) ?? []).map((word) => word.replace(/"([^"]*)"|'([^']*)'/g, "$1$2"));
56
56
  }
57
- /** The simple commands a command line is made of, in order: split on `;`, `&&`, `||`, `|`, `&`, newlines and subshells. */
57
+ /**
58
+ * The simple commands a command line is made of, in order: split on `;`, `&&`, `||`, `|`, `&`, newlines and subshells
59
+ * where the shell reads them - not in a string, so `grep "a\|b.run"` is one command - each cut from the command itself.
60
+ * A here-document's body that is a file's text is none.
61
+ */
58
62
  function segments(command) {
59
- return command
60
- .split(/&&|\|\||[;|&\n()`]|\$\(/)
61
- .map((part) => part.trim())
62
- .filter((part) => part !== "");
63
+ const code = shellCode(command);
64
+ const found = [];
65
+ let start = 0;
66
+ const cut = (end) => {
67
+ if (code.slice(start, end).trim() !== "")
68
+ found.push(command.slice(start, end).trim());
69
+ };
70
+ for (const match of code.matchAll(/&&|\|\||[;|&\n()`]|\$\(/g)) {
71
+ cut(match.index);
72
+ start = match.index + match[0].length;
73
+ }
74
+ cut(code.length);
75
+ return found;
76
+ }
77
+ /**
78
+ * The simple commands a command line runs: its own, and those of each script it hands a shell as a word - `bash -c
79
+ * "cd app; pip install --user x"`, `eval "..."` - which a string hides from the shell reading the line.
80
+ */
81
+ function simpleCommands(command, depth = 0) {
82
+ const own = segments(command);
83
+ if (depth >= 3)
84
+ return own;
85
+ return own.flatMap((segment) => {
86
+ const script = scriptOf(segment);
87
+ return script === undefined ? [segment] : [segment, ...simpleCommands(script, depth + 1)];
88
+ });
89
+ }
90
+ /** The script a simple command hands a shell to run: `sh -c '<script>'`, `bash -lc "<script>"`, `eval <script>`. */
91
+ function scriptOf(segment) {
92
+ const found = programOf(segment);
93
+ if (found === undefined)
94
+ return undefined;
95
+ if (found.program === "eval")
96
+ return found.args.length > 0 ? found.args.join(" ") : undefined;
97
+ if (!/^(ba|z|da|k)?sh$/.test(found.program))
98
+ return undefined;
99
+ const at = found.args.findIndex((arg) => /^-[a-zA-Z]*c[a-zA-Z]*$/.test(arg));
100
+ return at === -1 ? undefined : found.args[at + 1];
63
101
  }
64
102
  /** A simple command's program and arguments, past assignments, wrappers and their own options. */
65
103
  function programOf(segment) {
@@ -169,9 +207,9 @@ function systemSettingIn(segment) {
169
207
  * an agent, not the chat, not a launch - what the machine lacks is the person's to install, in their own words.
170
208
  */
171
209
  export function machineChange(command) {
172
- if (PIPED_DOWNLOAD.test(command) || RUN_DOWNLOAD.test(command))
210
+ if (runsDownload(command))
173
211
  return "it runs a script downloaded from the web";
174
- for (const segment of segments(command)) {
212
+ for (const segment of simpleCommands(command)) {
175
213
  const why = installIn(segment) ?? systemSettingIn(segment);
176
214
  if (why !== undefined)
177
215
  return why;
@@ -241,12 +279,122 @@ export function machineChangeReason(why) {
241
279
  "the same tool (python for python3), a version manager's folder - and use it, or give the person the exact command to " +
242
280
  "run themselves, and go on once they say it is done.");
243
281
  }
244
- /** Downloads run as programs: a script piped to a shell, or run from a download. */
245
- const PIPED_DOWNLOAD = /\b(curl|wget)\b[^|;&\n]*\|\s*(sudo\s+(-\S+\s+)*)?((ba|z|da|k)?sh|python\d*|perl|ruby|node)\b/;
282
+ /** Downloads run as programs: a script piped to a shell or an interpreter, or run from a download. */
283
+ const PIPED_DOWNLOAD = /\b(?:curl|wget)\b[^|;&\n]*\|\s*(?:sudo\s+(?:-\S+\s+)*)?((?:ba|z|da|k)?sh|python[\d.]*|perl|ruby|node)\b([^|;&\n]*)/g;
246
284
  const RUN_DOWNLOAD = /\b(ba|z|da|k)?sh\s+(-\w+\s+)*["']?\$\(\s*(curl|wget)\b|<\(\s*(curl|wget)\b/;
285
+ /**
286
+ * The option that gives an interpreter its code on the command line, so what is piped to it is data it reads - `curl
287
+ * localhost:8000/links | python3 -c 'import json, sys; ...'`, `| python3 -m json.tool`, `| node -e`, `| perl -ne`.
288
+ */
289
+ const CODE_OPTIONS = [
290
+ [/^(ba|z|da|k)?sh$/, /^-[a-zA-Z]*c[a-zA-Z]*$/],
291
+ [/^python/, /^-[a-zA-Z]*[cm]$/],
292
+ [/^node$/, /^(-[a-zA-Z]*[ep][a-zA-Z]*|--eval|--print)$/],
293
+ [/^(perl|ruby)$/, /^-[a-zA-Z]*[eE][a-zA-Z]*$/],
294
+ ];
295
+ /** Whether a command line runs what it downloads: piped to a shell or an interpreter that runs it, or run from it. */
296
+ function runsDownload(command) {
297
+ if (RUN_DOWNLOAD.test(command))
298
+ return true;
299
+ for (const match of shellCode(command).matchAll(PIPED_DOWNLOAD)) {
300
+ const interpreter = match[1];
301
+ const options = [];
302
+ for (const word of words(match[2])) {
303
+ if (!word.startsWith("-") || word === "-")
304
+ break;
305
+ options.push(word);
306
+ }
307
+ const code = CODE_OPTIONS.find(([program]) => program.test(interpreter))?.[1];
308
+ if (code === undefined || !options.some((option) => code.test(option)))
309
+ return true;
310
+ }
311
+ return simpleCommands(command).some((segment) => {
312
+ const script = scriptOf(segment);
313
+ return script !== undefined && script !== command && runsDownload(script);
314
+ });
315
+ }
247
316
  /** Killing by name, or by what holds a port. */
248
317
  const KILL_BY_LOOKUP = /\bkill\b[^;&|\n]*(\$\(|`)\s*(lsof|fuser|pgrep|pidof|ss|netstat)\b/;
249
318
  const LOOKUP_TO_KILL = /\b(lsof|pgrep|pidof|fuser|ss|netstat)\b[^;&\n]*\|\s*xargs\s+(-\S+\s+)*kill\b/;
319
+ /** A here-document's start: `<<'EOF'`, `<<-"END"`, `<<EOF` - not a here-string's `<<<`. */
320
+ const HEREDOC = /(?<!<)<<(-?)\s*(?:'([^'\n]+)'|"([^"\n]+)"|\\?([A-Za-z_][A-Za-z0-9_]*))/g;
321
+ /** The programs whose here-document is a file's text: they write it out, and run nothing in it. */
322
+ const DATA_SINKS = new Set(["cat", "tee"]);
323
+ /**
324
+ * The command as the shell reads its operators, the same length: what quotes hold has its `<`, `>`, `|`, `&`, `;` and
325
+ * newlines put out of the way - a `>` in `grep "</content>"` redirects nothing, a `;` in a string ends no command - and
326
+ * the body of a here-document fed to cat or tee with a quoted delimiter, so not expanded, is blanked: it is the text of
327
+ * a file being written, and a `../lib/logger` or a `>` in it is code, not a path or a redirection. A `$(...)` in double
328
+ * quotes, an unquoted delimiter's body and a here-document fed to anything else - a shell, an interpreter - run, and are
329
+ * read as they are.
330
+ */
331
+ export function shellCode(command) {
332
+ const lines = command.split("\n");
333
+ const out = [];
334
+ for (let index = 0; index < lines.length; index += 1) {
335
+ const line = lines[index];
336
+ out.push(line);
337
+ // The here-documents this line opens, in order: each body runs to its delimiter alone on a line.
338
+ const opened = [];
339
+ for (const match of maskQuotes(line).matchAll(HEREDOC)) {
340
+ const quoted = match[2] ?? match[3];
341
+ const before = line.slice(0, match.index).split(/&&|\|\||[;|]/).pop() ?? "";
342
+ const program = programOf(before)?.program;
343
+ opened.push({ delimiter: quoted ?? match[4], strip: match[1] === "-", data: quoted !== undefined && program !== undefined && DATA_SINKS.has(program) });
344
+ }
345
+ for (const heredoc of opened) {
346
+ while (index + 1 < lines.length) {
347
+ index += 1;
348
+ const body = lines[index];
349
+ if ((heredoc.strip ? body.replace(/^\t+/, "") : body) === heredoc.delimiter) {
350
+ out.push(body);
351
+ break;
352
+ }
353
+ out.push(heredoc.data ? " ".repeat(body.length) : body);
354
+ }
355
+ }
356
+ }
357
+ return maskQuotes(out.join("\n"));
358
+ }
359
+ /** `text` with what its quotes hold out of the shell's way: operators and newlines in a string are a space each. */
360
+ function maskQuotes(text) {
361
+ let out = "";
362
+ let quote;
363
+ /** Inside double quotes, a command substitution runs: read as it is to the end of the string. */
364
+ let substituting = false;
365
+ for (let at = 0; at < text.length; at += 1) {
366
+ const char = text[at];
367
+ if (quote === undefined) {
368
+ if (char === "\\" && at + 1 < text.length) {
369
+ out += char + text[at + 1];
370
+ at += 1;
371
+ continue;
372
+ }
373
+ if (char === "'" || char === '"')
374
+ quote = char;
375
+ out += char;
376
+ continue;
377
+ }
378
+ if (quote === '"' && char === "\\" && at + 1 < text.length) {
379
+ out += char + (substituting ? text[at + 1] : maskedChar(text[at + 1]));
380
+ at += 1;
381
+ continue;
382
+ }
383
+ if (char === quote) {
384
+ quote = undefined;
385
+ substituting = false;
386
+ out += char;
387
+ continue;
388
+ }
389
+ if (quote === '"' && (char === "`" || (char === "$" && text[at + 1] === "(")))
390
+ substituting = true;
391
+ out += substituting ? char : maskedChar(char);
392
+ }
393
+ return out;
394
+ }
395
+ function maskedChar(char) {
396
+ return /[<>|&;\n]/.test(char) ? " " : char;
397
+ }
250
398
  /** One check, the paths of one platform. */
251
399
  class Paths {
252
400
  path;
@@ -342,7 +490,8 @@ function writeTargets(segment) {
342
490
  if (found === undefined)
343
491
  continue;
344
492
  const { program, args } = found;
345
- const operands = args.filter((arg) => !arg.startsWith("-"));
493
+ // A redirection among its words - `2>/dev/null`, `>out.txt` - is the shell's, read above: never an operand.
494
+ const operands = args.filter((arg) => !arg.startsWith("-") && !/^(\d|&)?[<>]/.test(arg));
346
495
  if (program === "tee")
347
496
  targets.push(...operands);
348
497
  else if ((program === "cp" || program === "mv" || program === "install" || program === "ln") && operands.length >= 2)
@@ -372,11 +521,11 @@ export function checkCommand(command, fence) {
372
521
  return refusal("record", `${RECORD_FILE} is the harness's record of what the code is built from: no agent reads or writes it, and nothing in it is yours to go by.`);
373
522
  }
374
523
  // Installs and kills, a simple command at a time; downloads run as programs, on the whole line.
375
- if (PIPED_DOWNLOAD.test(command) || RUN_DOWNLOAD.test(command))
524
+ if (runsDownload(command))
376
525
  return refusal("install", installReason("it runs a script downloaded from the web"));
377
526
  if (KILL_BY_LOOKUP.test(command) || LOOKUP_TO_KILL.test(command))
378
527
  return refusal("kill", killReason());
379
- for (const segment of segments(command)) {
528
+ for (const segment of simpleCommands(command)) {
380
529
  const why = installIn(segment);
381
530
  if (why !== undefined)
382
531
  return refusal("install", installReason(why));
@@ -388,9 +537,9 @@ export function checkCommand(command, fence) {
388
537
  return refusal("kill", killReason());
389
538
  }
390
539
  }
391
- // Paths, a simple command at a time from where the cds before it left it.
540
+ // Paths, a simple command at a time from where the cds before it left it - read as the shell reads its operators.
392
541
  let cwd = fence.cwd;
393
- for (const segment of command.split(/&&|\|\||[;\n]/)) {
542
+ for (const segment of shellCode(command).split(/&&|\|\||[;\n]/)) {
394
543
  for (const word of pathWords(segment, paths, fence)) {
395
544
  const target = resolveWord(word, cwd, fence, paths);
396
545
  if (target !== undefined && !paths.inside(target, readable)) {
@@ -1,122 +1,20 @@
1
- import { type Color } from "@earendil-works/pi-tui";
2
- import { type Job } from "./jobs.ts";
3
- /**
4
- * The live panel above the editor while background work runs.
5
- *
6
- * One block per running job: what it is and how long it has been going, the stage it is
7
- * at, what is happening this second, and the last things its agents did. What waits is not
8
- * in it - the side panel lists the queue. It disappears when nothing is running - the finished
9
- * job announces itself in the transcript instead.
10
- *
11
- * It is drawn as a component rather than handed over as lines, because pi cuts a list of
12
- * lines off at ten. Instead it sizes itself: compact by default, and the agents' trace in full
13
- * while tool output is expanded - pi's own ctrl+o, which the person already uses to see more of
14
- * what the agent did. What finished stays counted either way: the side panel lists it.
15
- */
16
- export declare const JOB_PANEL_KEY = "turri-jobs";
17
- /**
18
- * The key that opens the side panel on its jobs, and goes back to it. Not ctrl+j: a terminal without the Kitty keyboard
19
- * protocol sends ctrl+j as a line feed - what it sends for shift+enter too, and what a dialog reads as enter - so it
20
- * would answer a question, and take a new line from the editor. ctrl+h is the byte old terminals sent for backspace;
21
- * every terminal now sends backspace as DEL, which pi never takes for ctrl+h, so it is free - in pi, and in a dialog.
22
- */
1
+ import type { Job } from "./jobs.ts";
2
+ /** Opens the side panel; ctrl+j would conflict with the editor's newline. */
23
3
  export declare const PANEL_KEY = "ctrl+h";
24
- /**
25
- * Each key in the line under the panel - ctrl+o, ctrl+h - breathes until it is first pressed: fully there, a little
26
- * faint, and back, so it reads as something to press, not as text. Once every BREATH_MS, redrawn every BREATH_TICK_MS
27
- * while the panel shows and a key still breathes, at most BREATH_FADE of the way from the text's colour to the dim one.
28
- * Pressed once, it stays still for the rest of the process; the other breathes on.
29
- */
30
- export declare const BREATH_MS = 2400;
31
- /** The keys of the line, by what they do: pressed once, each stops breathing. */
32
- export type PanelKey = "trace" | "peek";
33
- /** A key of the line was pressed - ctrl+o, or the side panel opened: it stops breathing. */
34
- export declare function keyPressed(key: PanelKey): void;
35
- export declare function breathes(key: PanelKey): boolean;
36
- /** For tests: every key breathing again. */
37
- export declare function resetKeysForTests(): void;
38
- /** How faint a breathing key is at `now`: 0, fully there, at the start of each breath, BREATH_FADE halfway through. */
39
- export declare function breath(now: number): number;
40
4
  export declare function spinner(now: number): string;
41
- /**
42
- * What finished, a line a module - the module that finished last on top, its name, then its pulses newest first -
43
- * fitted to `width`: the newest that fit, the rest counted as earlier. The side panel lists every one.
44
- */
45
- export declare function finishedLines(finished: Job[], width: number | undefined, marks?: MarkPaint): string[];
46
- /** A pulse that ran to its end and whose build did not pass - stopped at a gate - is not a success. */
5
+ /** A pulse that ran to its end and whose build did not pass is not a success. */
47
6
  export declare function didNotPass(job: Job): boolean;
48
- /** How a finished pulse's mark is coloured: green it passed, red it failed or did not pass, amber it was stopped. */
49
- export interface MarkPaint {
7
+ interface MarkPaint {
50
8
  success(text: string): string;
51
9
  error(text: string): string;
52
10
  warning(text: string): string;
53
11
  }
54
- /** A finished pulse's mark, in the colour of how it ended. */
55
12
  export declare function finishedMark(job: Job, paint?: MarkPaint): string;
56
- /** What a pulse cost, as its line says it: " · $0.12", or nothing when the price is not known. */
57
13
  export declare function pulseCost(job: Job): string;
58
- /**
59
- * One line saying what a spec change does: the files, the lines added and removed, and the
60
- * first line it adds - usually the concept or the functional spec it is about.
61
- */
62
- /** How a diff is coloured: added lines green, removed lines red. Plain when there is no theme. */
63
14
  export interface DiffStyle {
64
15
  added(text: string): string;
65
16
  removed(text: string): string;
66
17
  }
18
+ /** One line saying what a spec change does: the files, the lines added and removed, and the first line it adds. */
67
19
  export declare function summarizeDiff(diff: string, style?: DiffStyle): string;
68
- /** The lines of a diff worth reading in a panel: the hunks, not the headers. */
69
- /**
70
- * A line of the panel wrapped to its width, its continuations under its text: indented as far as it is,
71
- * and past the rule of a diff box when it is in one.
72
- */
73
- export declare function wrapKeepingIndent(line: string, width: number): string[];
74
- /** A diff's colours for the +/- alone, when there is nothing to highlight with. */
75
- export interface PanelOptions {
76
- /** Everything, rather than the compact view. */
77
- expanded?: boolean;
78
- now?: number;
79
- width?: number;
80
- /** The lines of help about ctrl+o and the side panel - left out where they do not apply, as in the side panel itself. */
81
- hints?: boolean;
82
- /** How the finished pulses' marks are coloured. */
83
- marks?: MarkPaint;
84
- /** How each key of the line is painted - breathing until it is pressed, in the TUI. */
85
- keys?: (key: PanelKey, text: string) => string;
86
- }
87
- export declare function jobPanelLines(jobs: Job[], options?: PanelOptions): string[];
88
- interface Redrawable {
89
- requestRender(): void;
90
- }
91
- /** What of pi's theme the panel paints with: the diff's colours and bands, and ***plain's colours in it. */
92
- interface PanelTheme {
93
- fg(color: "toolDiffAdded" | "toolDiffRemoved" | "success" | "error" | "warning", text: string): string;
94
- /** Whether it is made for a dark or a light surface, and how many colours the terminal has: the diff's palette. */
95
- appearance?: "dark" | "light";
96
- getColorMode?(): string;
97
- /** Each token's concrete colour - what the line of keys breathes between. */
98
- colors?: Readonly<Record<string, Color>>;
99
- }
100
- /**
101
- * The keys of the line, painted at `now`'s breath: one not pressed yet in the text's colour mixed toward the dim one, one
102
- * pressed as it is. Plain where the theme has no colours to mix.
103
- */
104
- export declare function breathing(theme: PanelTheme, now: number): (key: PanelKey, text: string) => string;
105
- /** The parts of pi's TUI the panel needs: enough to draw, redraw, and ask about ctrl+o. */
106
- export interface PanelUI {
107
- setWidget(key: string, content: ((tui: Redrawable, theme: PanelTheme) => {
108
- render(width: number): string[];
109
- invalidate(): void;
110
- }) | undefined, options?: {
111
- placement?: "aboveEditor" | "belowEditor";
112
- }): void;
113
- getToolsExpanded(): boolean;
114
- }
115
- export interface JobPanel {
116
- /** Where to draw. Until this is set there is no UI, and the panel does nothing. */
117
- attach(ui: PanelUI): void;
118
- /** Redraw soon, e.g. because a job changed. */
119
- refresh(): void;
120
- }
121
- export declare function createJobPanel(list: () => Job[]): JobPanel;
122
20
  export {};