@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
@@ -0,0 +1,56 @@
1
+ import { Markdown } from "@earendil-works/pi-tui";
2
+ import { highlightLines, roleOf } from "./plain/highlight.js";
3
+ import { plainPaint } from "./regenerate/plain-palette.js";
4
+ /**
5
+ * A fenced block of ***plain in the chat - ```plain, as an agent shows a module, or a fence with no language around
6
+ * a section's header - highlighted as turri highlights ***plain everywhere else: by its own grammar
7
+ * (plain/highlight.ts), in the colours of a ***plain diff (plain-palette.ts). pi highlights a code block through highlight.js, which knows no ***plain, and has no hook for
8
+ * a language of an extension's: so pi-tui's Markdown is patched, as chat-terminal.ts patches pi's screen - a ***plain
9
+ * block drawn with a highlighter of turri's in place of the theme's, every other block as pi draws it.
10
+ */
11
+ /** The fence's languages that are ***plain. */
12
+ const PLAIN_LANGUAGES = new Set(["plain", "***plain"]);
13
+ export function isPlainLanguage(lang) {
14
+ return lang !== undefined && PLAIN_LANGUAGES.has(lang.trim().toLowerCase());
15
+ }
16
+ /** A section's header on a line of its own - `***functional specs***` - which nothing but ***plain writes. */
17
+ const SECTION_HEADER = /^\*\*\*[a-z][a-z ]*\*\*\*[ \t]*$/m;
18
+ /** Whether a fenced block is ***plain: fenced as plain, or fenced with no language around a section's header. */
19
+ export function isPlainBlock(lang, text) {
20
+ return isPlainLanguage(lang) || ((lang ?? "").trim() === "" && SECTION_HEADER.test(text));
21
+ }
22
+ /** Lines of ***plain, each piece painted by its role; the text around them in `rest`. */
23
+ export function highlightPlain(code, paint, rest = (text) => text) {
24
+ return highlightLines(code.split("\n")).map((tokens) => tokens
25
+ .map((token) => {
26
+ const role = roleOf(token.scopes);
27
+ return role !== undefined ? paint(role, token.text) : rest(token.text);
28
+ })
29
+ .join(""));
30
+ }
31
+ let themeNow = () => undefined;
32
+ let patched = false;
33
+ /** From now on, a ***plain block in the chat is highlighted - in the colours of the theme `theme` gives at the time. */
34
+ export function highlightPlainCodeBlocks(theme) {
35
+ themeNow = theme;
36
+ if (patched)
37
+ return;
38
+ patched = true;
39
+ const prototype = Markdown.prototype;
40
+ const renderToken = prototype.renderToken;
41
+ prototype.renderToken = function (token, ...rest) {
42
+ const theme = this.theme;
43
+ const current = themeNow();
44
+ if (token.type !== "code" || !isPlainBlock(token.lang, token.text ?? "") || current === undefined)
45
+ return renderToken.call(this, token, ...rest);
46
+ const paint = plainPaint(current);
47
+ // Drawn by pi, with turri's highlighter in the theme's place for this block alone.
48
+ this.theme = { ...theme, highlightCode: (code) => highlightPlain(code, paint.syntax, theme.codeBlock) };
49
+ try {
50
+ return renderToken.call(this, token, ...rest);
51
+ }
52
+ finally {
53
+ this.theme = theme;
54
+ }
55
+ };
56
+ }
@@ -1,5 +1,5 @@
1
1
  import type { Theme } from "@earendil-works/pi-coding-agent";
2
- export type ButtonRole = "tab" | "new" | "close" | "panel";
2
+ export type ButtonRole = "tab" | "new" | "close" | "panel" | "regenerating";
3
3
  export type ButtonPaint = (text: string, active: boolean, hovered: boolean, role: ButtonRole) => string;
4
4
  /** The layout owns the padding, so the entire coloured surface is also the click target. */
5
5
  export declare function buttonLabel(theme: Theme, text: string, active: boolean, hovered: boolean, role: ButtonRole): string;
@@ -1,5 +1,7 @@
1
1
  import { colorToRgb, parseColor } from "@earendil-works/pi-tui";
2
+ import { BRAND_PINK } from "./regenerate/plain-palette.js";
2
3
  const abyss = parseColor("#0a0f1a");
4
+ const pink = parseColor(BRAND_PINK.dark);
3
5
  const white = parseColor("#f4f7f9");
4
6
  const linear = (byte) => byte <= 10 ? byte / 3294.6 : ((byte / 255 + 0.055) / 1.055) ** 2.4;
5
7
  function luminance(color) {
@@ -11,6 +13,8 @@ function luminance(color) {
11
13
  const inkSwitch = Math.sqrt((luminance(abyss) + 0.05) * (luminance(white) + 0.05)) - 0.05;
12
14
  /** The layout owns the padding, so the entire coloured surface is also the click target. */
13
15
  export function buttonLabel(theme, text, active, hovered, role) {
16
+ if (role === "regenerating")
17
+ return theme.style(text, { bg: pink, fg: abyss, bold: true, underline: hovered });
14
18
  if (role === "new" || active || hovered) {
15
19
  const fill = theme.colors[role === "new" ? "success" : role === "close" && hovered ? "error" : "accent"];
16
20
  return theme.style(text, { bg: fill, fg: luminance(fill) > inkSwitch ? abyss : white, bold: true, underline: hovered });
@@ -18,6 +18,8 @@ export interface QuestionDialogOptions {
18
18
  question: string;
19
19
  /** The choices. Without them, a line to type the answer on. */
20
20
  options?: string[];
21
+ /** Clickable choices when this dialog is embedded in the side panel. */
22
+ clickable?: boolean;
21
23
  /** The choice the cursor starts on. */
22
24
  selected?: number;
23
25
  /** The terminal's height, for the window the brief scrolls in. */
@@ -40,6 +42,9 @@ export declare class QuestionDialog implements Component, Focusable {
40
42
  private maxScroll;
41
43
  private window;
42
44
  private answered;
45
+ private choiceLines;
46
+ private choiceTop;
47
+ private pressed;
43
48
  private focusedNow;
44
49
  constructor(options: QuestionDialogOptions);
45
50
  get focused(): boolean;
@@ -15,6 +15,9 @@ export class QuestionDialog {
15
15
  maxScroll = 0;
16
16
  window = 0;
17
17
  answered = false;
18
+ choiceLines = [];
19
+ choiceTop = 0;
20
+ pressed;
18
21
  focusedNow = false;
19
22
  constructor(options) {
20
23
  this.options = options;
@@ -61,10 +64,13 @@ export class QuestionDialog {
61
64
  const brief = context === "" ? [] : context.split("\n").flatMap((line) => (line.trim() === "" ? [""] : wrapTextWithAnsi(styled(line, style), inner)));
62
65
  const question = wrapTextWithAnsi(style.bold(style.accent(this.options.question)), inner);
63
66
  const choices = this.options.options ?? [];
67
+ this.choiceLines = [];
64
68
  const body = this.input !== undefined
65
69
  ? this.input.render(inner)
66
70
  : // A long option wraps, its lines under its first, rather than cut off where the person cannot read it.
67
71
  choices.flatMap((choice, index) => wrapTextWithAnsi(choice, Math.max(1, inner - 2)).map((line, at) => {
72
+ if (this.options.clickable)
73
+ this.choiceLines.push(index);
68
74
  const shown = `${at === 0 && index === this.selected ? "›" : " "} ${line}`;
69
75
  return index === this.selected ? style.accent(shown) : shown;
70
76
  }));
@@ -89,7 +95,9 @@ export class QuestionDialog {
89
95
  }
90
96
  lines.push("");
91
97
  }
92
- lines.push(...question.map(pad), ...body.map(pad), "", pad(style.muted(hint)));
98
+ lines.push(...question.map(pad));
99
+ this.choiceTop = lines.length;
100
+ lines.push(...body.map(pad), "", pad(style.muted(hint)));
93
101
  return lines;
94
102
  }
95
103
  handleInput(data) {
@@ -131,6 +139,17 @@ export class QuestionDialog {
131
139
  }
132
140
  }
133
141
  handleMouse(event) {
142
+ if (this.options.clickable && event.button === "left" && (event.type === "press" || event.type === "click")) {
143
+ const index = this.choiceLines[event.y - this.choiceTop];
144
+ const down = this.pressed;
145
+ this.pressed = event.type === "press" ? index : undefined;
146
+ if (index === undefined)
147
+ return;
148
+ this.selected = index;
149
+ if (event.type === "click" && down === index)
150
+ this.finish(this.options.options?.[index]);
151
+ return { handled: true };
152
+ }
134
153
  if (event.type !== "wheel" || event.wheelDelta === undefined || this.maxScroll === 0)
135
154
  return undefined;
136
155
  this.scrollBy(event.wheelDelta);
@@ -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,9 +279,40 @@ 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/;
@@ -452,11 +521,11 @@ export function checkCommand(command, fence) {
452
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.`);
453
522
  }
454
523
  // Installs and kills, a simple command at a time; downloads run as programs, on the whole line.
455
- if (PIPED_DOWNLOAD.test(command) || RUN_DOWNLOAD.test(command))
524
+ if (runsDownload(command))
456
525
  return refusal("install", installReason("it runs a script downloaded from the web"));
457
526
  if (KILL_BY_LOOKUP.test(command) || LOOKUP_TO_KILL.test(command))
458
527
  return refusal("kill", killReason());
459
- for (const segment of segments(command)) {
528
+ for (const segment of simpleCommands(command)) {
460
529
  const why = installIn(segment);
461
530
  if (why !== undefined)
462
531
  return refusal("install", installReason(why));
@@ -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 {};