@turri-dev/cli 0.1.4-next.318a98a → 0.1.4-next.5a8c6e5

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 (103) hide show
  1. package/.pi/themes/turri-dark.json +67 -66
  2. package/.pi/themes/turri-light.json +71 -73
  3. package/README.md +40 -128
  4. package/assets/jellyfish/dark-00.png +0 -0
  5. package/assets/jellyfish/dark-01.png +0 -0
  6. package/assets/jellyfish/dark-02.png +0 -0
  7. package/assets/jellyfish/dark-03.png +0 -0
  8. package/assets/jellyfish/dark-04.png +0 -0
  9. package/assets/jellyfish/dark-05.png +0 -0
  10. package/assets/jellyfish/dark-06.png +0 -0
  11. package/assets/jellyfish/dark-07.png +0 -0
  12. package/assets/jellyfish/dark-08.png +0 -0
  13. package/assets/jellyfish/dark-09.png +0 -0
  14. package/assets/jellyfish/dark-10.png +0 -0
  15. package/assets/jellyfish/dark-11.png +0 -0
  16. package/assets/jellyfish/light-00.png +0 -0
  17. package/assets/jellyfish/light-01.png +0 -0
  18. package/assets/jellyfish/light-02.png +0 -0
  19. package/assets/jellyfish/light-03.png +0 -0
  20. package/assets/jellyfish/light-04.png +0 -0
  21. package/assets/jellyfish/light-05.png +0 -0
  22. package/assets/jellyfish/light-06.png +0 -0
  23. package/assets/jellyfish/light-07.png +0 -0
  24. package/assets/jellyfish/light-08.png +0 -0
  25. package/assets/jellyfish/light-09.png +0 -0
  26. package/assets/jellyfish/light-10.png +0 -0
  27. package/assets/jellyfish/light-11.png +0 -0
  28. package/dist/ask.js +34 -15
  29. package/dist/brand.js +7 -7
  30. package/dist/cli-options.js +12 -6
  31. package/dist/config-edit.js +1 -0
  32. package/dist/config.js +5 -2
  33. package/dist/cultivate-cli.js +16 -23
  34. package/dist/extension.js +59 -67
  35. package/dist/init-config.js +5 -0
  36. package/dist/jellyfish.js +130 -0
  37. package/dist/loop-cli.js +19 -7
  38. package/dist/loop-tools.js +11 -5
  39. package/dist/module-report.js +5 -4
  40. package/dist/pi.js +76 -19
  41. package/dist/question-dialog.js +1 -0
  42. package/dist/regenerate/activity.js +21 -0
  43. package/dist/regenerate/list-arguments.js +121 -0
  44. package/dist/regenerate/loop.js +21 -8
  45. package/dist/regenerate/plain-palette.js +52 -37
  46. package/dist/regenerate/regenerate.js +4 -2
  47. package/dist/regenerate/self-check.js +13 -6
  48. package/dist/regenerate/side-panel.js +1 -1
  49. package/dist/regenerate/spec-map-view.js +9 -5
  50. package/dist/regenerate/test-scripts.js +54 -10
  51. package/dist/regenerate/unit-review.js +1 -1
  52. package/dist/regenerate-cli.js +11 -5
  53. package/dist/release-cli.js +3 -8
  54. package/dist/review/live.js +2 -1
  55. package/dist/run-report.js +39 -1
  56. package/dist/validate-cli.js +3 -8
  57. package/docs/README.md +5 -12
  58. package/docs/authoring-plain.md +37 -119
  59. package/docs/config.md +53 -178
  60. package/docs/deploy.md +21 -80
  61. package/docs/development.md +13 -41
  62. package/docs/headless.md +45 -121
  63. package/docs/images/how-turri-works.svg +29 -31
  64. package/docs/images/turri-banner.png +0 -0
  65. package/docs/installation.md +13 -40
  66. package/docs/parser.md +15 -43
  67. package/docs/regenerating.md +229 -938
  68. package/docs/sandbox.md +38 -152
  69. package/docs/skills-and-gates.md +50 -171
  70. package/docs/theming.md +45 -46
  71. package/docs/using.md +69 -345
  72. package/genome/rules/bullet-continuation.md +5 -13
  73. package/genome/rules/concise-specs-examples.md +2 -4
  74. package/genome/rules/concise-specs-integration-examples.md +2 -6
  75. package/genome/rules/concise-specs.md +1 -2
  76. package/genome/rules/func-specs.md +1 -0
  77. package/genome/rules/integration-embedded-testing.md +1 -4
  78. package/genome/rules/integrations.md +1 -2
  79. package/genome/rules/project-model.md +14 -35
  80. package/genome/rules/stdlib.md +14 -49
  81. package/genome/rules/turri-regeneration.md +48 -0
  82. package/genome/skills/add-implementation-requirement/SKILL.md +1 -2
  83. package/genome/skills/analyze-if-func-spec-too-complex/SKILL.md +3 -8
  84. package/genome/skills/brood/SKILL.md +37 -127
  85. package/genome/skills/brood/references/intent.md +4 -12
  86. package/genome/skills/brood/references/product.md +24 -76
  87. package/genome/skills/brood/references/stack.md +7 -29
  88. package/genome/skills/brood/references/testing.md +11 -42
  89. package/genome/skills/bud/SKILL.md +32 -109
  90. package/genome/skills/bud/references/intent.md +4 -11
  91. package/genome/skills/implement-conformance-testing-script/SKILL.md +3 -6
  92. package/genome/skills/implement-unit-testing-script/SKILL.md +1 -2
  93. package/genome/skills/mature/SKILL.md +21 -69
  94. package/genome/skills/refactor-module/SKILL.md +24 -2
  95. package/genome/skills/spawn/SKILL.md +28 -113
  96. package/package.json +1 -1
  97. package/assets/jellyfish/dark-12.png +0 -0
  98. package/assets/jellyfish/dark-13.png +0 -0
  99. package/assets/jellyfish/dark-14.png +0 -0
  100. package/assets/jellyfish/fallback.txt +0 -252
  101. package/assets/jellyfish/light-12.png +0 -0
  102. package/assets/jellyfish/light-13.png +0 -0
  103. package/assets/jellyfish/light-14.png +0 -0
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/dist/ask.js CHANGED
@@ -9,6 +9,9 @@ import { PANEL_KEY } from "./regenerate/job-panel.js";
9
9
  export const OTHER_OPTION = "Something else…";
10
10
  export const CHAT_OPTION = "Chat about this";
11
11
  export const DONE_OPTION = "Done — that's all of them";
12
+ /** An option's box in a question of several, ticked and not. */
13
+ export const TICKED = "☑";
14
+ export const UNTICKED = "☐";
12
15
  export const DISMISSED = "The user dismissed the question without answering.";
13
16
  /** How an answer that is no answer starts: the person chose to talk about the question first. */
14
17
  export const CHAT_PREFIX = "The user has not answered this question yet: they chose to talk about it first.";
@@ -107,32 +110,48 @@ export async function runAsk(asked, io) {
107
110
  return choice;
108
111
  }
109
112
  }
110
- // Pick several: keep offering what is left until they say they are done.
111
- const chosen = [];
112
- let remaining = [...options];
113
- while (remaining.length > 0) {
114
- const title = chosen.length === 0 ? request.question : `${request.question} [so far: ${chosen.join(", ")}]`;
115
- const choice = await io.select(title, [...remaining, ...extras, DONE_OPTION], context);
116
- if (choice === undefined)
117
- break;
118
- if (choice === DONE_OPTION)
113
+ // Pick several: every option a box, ticked and unticked as it is chosen, until they say they are done. What they type
114
+ // is one more box, ticked - and can be unticked too. Something else, Chat about this and Done are no boxes.
115
+ const listed = [...options];
116
+ const ticked = new Set();
117
+ const picked = () => listed.filter((option) => ticked.has(option));
118
+ let at = 0;
119
+ for (;;) {
120
+ const rows = listed.map((option) => `${ticked.has(option) ? TICKED : UNTICKED} ${option}`);
121
+ const choice = await io.select(request.question, [...rows, ...extras, DONE_OPTION], context, at);
122
+ if (choice === undefined || choice === DONE_OPTION)
119
123
  break;
120
124
  if (choice === OTHER_OPTION) {
125
+ at = listed.length;
121
126
  const typed = await typeInstead();
122
- if (!typedNothing(typed))
123
- chosen.push(typed.trim());
127
+ if (typedNothing(typed))
128
+ continue;
129
+ const option = typed.trim();
130
+ if (!listed.includes(option))
131
+ listed.push(option);
132
+ ticked.add(option);
133
+ at = listed.indexOf(option);
124
134
  continue;
125
135
  }
126
136
  if (choice === CHAT_OPTION) {
137
+ at = listed.length + extras.indexOf(CHAT_OPTION);
127
138
  const said = await chatAbout();
128
139
  if (typedNothing(said))
129
140
  continue;
130
- return chatAnswer(said, chosen);
141
+ return chatAnswer(said, picked());
131
142
  }
132
- chosen.push(choice);
133
- remaining = remaining.filter((option) => option !== choice);
143
+ // A row, or - where the answer is typed, on the command line - an option by its text, or one more of their own.
144
+ const row = rows.indexOf(choice);
145
+ const option = row !== -1 ? listed[row] : choice.trim();
146
+ if (!listed.includes(option))
147
+ listed.push(option);
148
+ if (ticked.has(option))
149
+ ticked.delete(option);
150
+ else
151
+ ticked.add(option);
152
+ at = listed.indexOf(option);
134
153
  }
135
- return chosen.length > 0 ? chosen.join(", ") : DISMISSED;
154
+ return ticked.size > 0 ? picked().join(", ") : DISMISSED;
136
155
  }
137
156
  /**
138
157
  * While a question is open, what catches ctrl+h on the terminal's input: pi gives an extension's shortcut only the keys
package/dist/brand.js CHANGED
@@ -2,8 +2,8 @@ import { existsSync, readFileSync } from "node:fs";
2
2
  import { homedir } from "node:os";
3
3
  import { join } from "node:path";
4
4
  /**
5
- * turri's colours for what its command line prints - the ones its themes use (.pi/themes): on a dark terminal its lime
6
- * accent and green, on a light one its blue. Nothing is coloured when the output is not a terminal, or NO_COLOR is set;
5
+ * turri's colours for what its command line prints - the design system's, as its themes use them (.pi/themes): on a
6
+ * dark terminal neon and pink, on a light one blue whale and eggplant. Nothing is coloured when the output is not a terminal, or NO_COLOR is set;
7
7
  * a terminal without 24-bit colour gets the nearest of its sixteen.
8
8
  */
9
9
  /** Whether the terminal is light: COLORFGBG says so (a light background, 7 or 15), or pi's theme is a light one. */
@@ -35,15 +35,15 @@ function paint(stream = process.stdout) {
35
35
  };
36
36
  return {
37
37
  /** turri's accent: what to look at - a heading, a choice's number, the command to run. */
38
- accent: light ? ink("#0a1fd4", 34) : ink("#e0ff6e", 93),
38
+ accent: light ? ink("#1e3442", 34) : ink("#5ce1e6", 96),
39
39
  /** Done, and what was written. */
40
- success: light ? ink("#223936", 32) : ink("#79fc96", 92),
40
+ success: light ? ink("#732553", 35) : ink("#ff5c8d", 95),
41
41
  /** What is wrong: what stops turri. */
42
- error: light ? ink("#d00505", 31) : ink("#dd5353", 91),
42
+ error: ink("#ff7a3d", 33),
43
43
  /** What works, with limits. */
44
- warning: ink("#dc6803", 33),
44
+ warning: ink("#ff7a3d", 33),
45
45
  /** What goes with it, and can be skimmed. */
46
- muted: ink("#808080", 90),
46
+ muted: light ? ink("#3e5a6b", 90) : ink("#85a3b2", 37),
47
47
  bold: (text) => (on ? `\x1b[1m${text}\x1b[22m` : text),
48
48
  };
49
49
  }
@@ -1,4 +1,4 @@
1
- import { conformanceOption, overrideConfig, reviewOption, splitModelSpec } from "./config.js";
1
+ import { booleanOption, conformanceOption, overrideConfig, splitModelSpec } from "./config.js";
2
2
  /**
3
3
  * The command line of turri's commands: their words, and the options that stand for the config's own keys - kept apart
4
4
  * from the commands that use them, so a light one (doctor) reads them as a regenerate does without loading it.
@@ -51,19 +51,24 @@ export function optionValue(options, name) {
51
51
  }
52
52
  /**
53
53
  * The options that stand for the config's own keys - `--harness-model`, `--coding-model` (`--model`), `--judge-model`
54
- * and, as asked, `--review` and `--conformance-tests` - read as if config.turri.yaml had them, in their place in the
54
+ * and, as asked, `--review`, `--mutation-testing` and `--conformance-tests` - read as if config.turri.yaml had them, in their place in the
55
55
  * order the config resolves them in (overrideConfig): a run, or doctor, with them is the same as one with them in the
56
56
  * file. Exits on a value it cannot read.
57
57
  */
58
58
  export function configKeyOptions(options, take = {}) {
59
+ const flag = (name) => {
60
+ const given = take.review === true ? optionValue(options, name) : undefined;
61
+ const value = given !== undefined ? booleanOption(given) : undefined;
62
+ if (given !== undefined && value === undefined)
63
+ failOption(`--${name} takes true or false, not ${given}`);
64
+ return value;
65
+ };
59
66
  const tests = take.conformance === true ? optionValue(options, "conformance-tests") : undefined;
60
67
  const setting = tests !== undefined ? conformanceOption(tests) : undefined;
61
68
  if (tests !== undefined && setting === undefined)
62
69
  failOption(`--conformance-tests takes all, chosen, module or false, not ${tests}`);
63
- const reviewed = take.review === true ? optionValue(options, "review") : undefined;
64
- const review = reviewed !== undefined ? reviewOption(reviewed) : undefined;
65
- if (reviewed !== undefined && review === undefined)
66
- failOption(`--review takes true or false, not ${reviewed}`);
70
+ const review = flag("review");
71
+ const mutationTesting = flag("mutation-testing");
67
72
  const model = (name, key) => {
68
73
  const spec = optionValue(options, name);
69
74
  return spec !== undefined ? { [key]: splitModelSpec(spec) } : {};
@@ -74,6 +79,7 @@ export function configKeyOptions(options, take = {}) {
74
79
  ...model("judge-model", "judgeModel"),
75
80
  ...(setting !== undefined ? { conformanceTests: setting } : {}),
76
81
  ...(review !== undefined ? { review } : {}),
82
+ ...(mutationTesting !== undefined ? { mutationTesting } : {}),
77
83
  });
78
84
  }
79
85
  function failOption(message) {
@@ -59,6 +59,7 @@ export function settings(rules = []) {
59
59
  { key: "conformance-tests", about: "which functional specs get conformance tests", kind: "choice", options: ["all", "chosen", "module", "false"], unset: "all, where a module has test reqs", effect: "next-plan" },
60
60
  { key: "conformance-budget", about: "under conformance-tests: chosen or module, how many may be chosen - a count or a share", kind: "budget", options: ["10%", "30%", "50%", "5", "10"], unset: "no limit", effect: "next-plan" },
61
61
  { key: "review", about: "whether the code and its tests are reviewed once they pass", kind: "boolean", unset: "true", effect: "next-pulse" },
62
+ { key: "mutation-testing", about: "whether the coding agent and the reviewer can put a bug in the code for one test run (can_it_fail)", kind: "boolean", unset: "true", effect: "next-pulse" },
62
63
  { key: "allow-to-stop-jobs", about: "whether turri stops a running pulse the spec has moved on from", kind: "boolean", unset: "true", effect: "now" },
63
64
  { key: "release-after-pulse", about: "whether every pulse that lands code releases it", kind: "boolean", unset: "false", effect: "next-landing" },
64
65
  { key: "unittests-script", about: "the unit testing script, by path from the project root", kind: "path", unset: "the one run_unittests*.sh found", effect: "next-test-run" },
package/dist/config.js CHANGED
@@ -21,6 +21,7 @@ import { projectDirOf } from "./regenerate/paths.js";
21
21
  * conformance-tests: chosen # all, chosen (those with acceptance tests, and those the chooser picks after each pulse), module (the chooser picks, and plans, once the module is regenerated) or false (default: false)
22
22
  * conformance-budget: 30% # under chosen or module: how many functional specs a module may have chosen, beside those with acceptance tests - a count or a share (default: no limit)
23
23
  * review: false # review the code and its tests once they pass (default: true)
24
+ * mutation-testing: false # give the coding agent and the reviewer can_it_fail (default: true)
24
25
  * allow-to-stop-jobs: false # stop a running job the spec moved on from (default: true)
25
26
  * release-after-pulse: true # release what each pulse lands, as its last stage, before the next pulse (default: false)
26
27
  * rules-off: [integrations] # ***plain rules to leave out of the prompts, by name (default: none)
@@ -331,6 +332,7 @@ export const CONFIG_KEYS = {
331
332
  conformanceTests: "conformance-tests",
332
333
  conformanceBudget: "conformance-budget",
333
334
  review: "review",
335
+ mutationTesting: "mutation-testing",
334
336
  allowToStopJobs: "allow-to-stop-jobs",
335
337
  releaseAfterPulse: "release-after-pulse",
336
338
  unittestsScript: "unittests-script",
@@ -416,8 +418,8 @@ export function overrideConfig(overrides) {
416
418
  export function conformanceOption(value) {
417
419
  return conformanceSetting(value);
418
420
  }
419
- /** `--review <value>`: the config's own, true or false. Undefined for anything else. */
420
- export function reviewOption(value) {
421
+ /** `--review <value>`, `--mutation-testing <value>`: the config's own, true or false. Undefined for anything else. */
422
+ export function booleanOption(value) {
421
423
  const word = value.trim().toLowerCase();
422
424
  return word === "true" ? true : word === "false" ? false : undefined;
423
425
  }
@@ -487,6 +489,7 @@ function readConfigFile(path) {
487
489
  conformanceTests: conformanceSetting(conformance),
488
490
  conformanceBudget: budgetSetting(raw[CONFIG_KEYS.conformanceBudget]),
489
491
  review: typeof raw[CONFIG_KEYS.review] === "boolean" ? raw[CONFIG_KEYS.review] : undefined,
492
+ mutationTesting: typeof raw[CONFIG_KEYS.mutationTesting] === "boolean" ? raw[CONFIG_KEYS.mutationTesting] : undefined,
490
493
  allowToStopJobs: typeof raw[CONFIG_KEYS.allowToStopJobs] === "boolean" ? raw[CONFIG_KEYS.allowToStopJobs] : undefined,
491
494
  releaseAfterPulse: typeof raw[CONFIG_KEYS.releaseAfterPulse] === "boolean" ? raw[CONFIG_KEYS.releaseAfterPulse] : undefined,
492
495
  unittestsScript: text(raw[CONFIG_KEYS.unittestsScript]),
@@ -7,40 +7,33 @@ import { skillRunDir } from "./regenerate/paths.js";
7
7
  import { loadSkill } from "./skill.js";
8
8
  import { discoverSkills } from "./skills.js";
9
9
  import { PACKAGE_ROOT } from "./environment.js";
10
- const c = {
11
- dim: (s) => `\x1b[2m${s}\x1b[0m`,
12
- bold: (s) => `\x1b[1m${s}\x1b[0m`,
13
- green: (s) => `\x1b[32m${s}\x1b[0m`,
14
- red: (s) => `\x1b[31m${s}\x1b[0m`,
15
- yellow: (s) => `\x1b[33m${s}\x1b[0m`,
16
- cyan: (s) => `\x1b[36m${s}\x1b[0m`,
17
- };
10
+ import { c } from "./module-report.js";
18
11
  const reporter = {
19
- step: (name, attempt) => console.log(`\n${c.bold(c.cyan(`> step ${name}`))} ${c.dim(`attempt ${attempt}`)}`),
12
+ step: (name, attempt) => console.log(`\n${c.bold(c.accent(`> step ${name}`))} ${c.dim(`attempt ${attempt}`)}`),
20
13
  artifact: (path, body) => {
21
14
  console.log(c.dim(` ${path}:`));
22
15
  for (const line of body.split("\n"))
23
16
  console.log(c.dim(` | ${line}`));
24
17
  },
25
18
  gate: (name, judges) => console.log(judges === 0
26
- ? `${c.bold(c.yellow(`> gate ${name}`))} ${c.dim("no artifact - failing without spending judges")}`
27
- : `${c.bold(c.yellow(`> gate ${name}`))} ${c.dim(`${judges} independent judges`)}`),
19
+ ? `${c.bold(c.warning(`> gate ${name}`))} ${c.dim("no artifact - failing without spending judges")}`
20
+ : `${c.bold(c.warning(`> gate ${name}`))} ${c.dim(`${judges} independent judges`)}`),
28
21
  livePass: (step, scope, findings) => console.log(findings === 0
29
22
  ? c.dim(` review ${step}: ${scope} - clean`)
30
- : ` ${c.yellow(`review ${step}`)}: ${scope} ${c.dim(`- ${findings} to fix`)}`),
23
+ : ` ${c.warning(`review ${step}`)}: ${scope} ${c.dim(`- ${findings} to fix`)}`),
31
24
  liveReview: (name, passes, findings) => console.log(findings === 0
32
- ? `${c.bold(c.yellow(`> gate ${name}`))} ${c.dim(`reviewer read along in ${passes} passes, nothing outstanding`)}`
33
- : `${c.bold(c.yellow(`> gate ${name}`))} ${c.dim(`${findings} unresolved from the reviewer - failing without spending judges`)}`),
25
+ ? `${c.bold(c.warning(`> gate ${name}`))} ${c.dim(`reviewer read along in ${passes} passes, nothing outstanding`)}`
26
+ : `${c.bold(c.warning(`> gate ${name}`))} ${c.dim(`${findings} unresolved from the reviewer - failing without spending judges`)}`),
34
27
  judge: (index, model, verdict, violations) => {
35
- const mark = verdict === "pass" ? c.green("pass") : c.red(verdict);
28
+ const mark = verdict === "pass" ? c.success("pass") : c.error(verdict);
36
29
  console.log(` judge ${index + 1} ${c.dim(`(${model})`)}: ${mark}${violations ? c.dim(` (${violations})`) : ""}`);
37
30
  },
38
31
  outcome: (name, decision, critique) => {
39
32
  const colour = {
40
- advance: c.green,
41
- retry: c.yellow,
42
- escalate: c.yellow,
43
- abort: c.red,
33
+ advance: c.success,
34
+ retry: c.warning,
35
+ escalate: c.warning,
36
+ abort: c.error,
44
37
  };
45
38
  console.log(` ${c.bold(colour[decision](decision))} ${c.dim(`<- gate ${name}`)}`);
46
39
  if (critique)
@@ -78,7 +71,7 @@ async function main() {
78
71
  select: async (title, options, context) => {
79
72
  const rl = createInterface({ input: process.stdin, output: process.stdout });
80
73
  const list = options.map((option, i) => ` ${c.bold(String(i + 1))}. ${option}`).join("\n");
81
- const reply = (await rl.question(`\n${context !== undefined ? `${context}\n\n` : ""}${c.bold(c.cyan("? "))}${title}\n${list}\n> `)).trim();
74
+ const reply = (await rl.question(`\n${context !== undefined ? `${context}\n\n` : ""}${c.bold(c.accent("? "))}${title}\n${list}\n> `)).trim();
82
75
  rl.close();
83
76
  const index = Number.parseInt(reply, 10);
84
77
  if (Number.isInteger(index) && index >= 1 && index <= options.length)
@@ -87,13 +80,13 @@ async function main() {
87
80
  },
88
81
  input: async (title, context) => {
89
82
  const rl = createInterface({ input: process.stdin, output: process.stdout });
90
- const reply = (await rl.question(`\n${context !== undefined ? `${context}\n\n` : ""}${c.bold(c.cyan("? "))}${title}\n> `)).trim();
83
+ const reply = (await rl.question(`\n${context !== undefined ? `${context}\n\n` : ""}${c.bold(c.accent("? "))}${title}\n> `)).trim();
91
84
  rl.close();
92
85
  return reply === "" ? undefined : reply;
93
86
  },
94
87
  }),
95
88
  escalate: async ({ question, critique }) => {
96
- console.log(`\n${c.bold(c.yellow("! human review required"))}`);
89
+ console.log(`\n${c.bold(c.warning("! human review required"))}`);
97
90
  console.log(c.dim(critique));
98
91
  const rl = createInterface({ input: process.stdin, output: process.stdout });
99
92
  const answer = (await rl.question(`${question} [y/N] `)).trim().toLowerCase();
@@ -101,7 +94,7 @@ async function main() {
101
94
  return answer === "y";
102
95
  },
103
96
  });
104
- console.log(`\n${result.ok ? c.green(c.bold("run complete")) : c.red(c.bold("run aborted at a gate"))} ${c.dim(`artifacts in ${relative(cwd, skillRunDir(cwd, skill.name))}`)}`);
97
+ console.log(`\n${result.ok ? c.success(c.bold("run complete")) : c.error(c.bold("run aborted at a gate"))} ${c.dim(`artifacts in ${relative(cwd, skillRunDir(cwd, skill.name))}`)}`);
105
98
  process.exit(result.ok ? 0 : 1);
106
99
  }
107
100
  main().catch((err) => {
package/dist/extension.js CHANGED
@@ -5,7 +5,7 @@ import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
5
5
  import { basename, dirname, join, relative, resolve } from "node:path";
6
6
  import { conversationCommand, conversationSettled, conversationWriting } from "./regenerate/conversation-writes.js";
7
7
  import { fileURLToPath } from "node:url";
8
- import { allocateImageId, Box, getCapabilities, getPngDimensions, isKeyRelease, isKeyRepeat, matchesKey, renderImage, Text, visibleWidth, wrapTextWithAnsi } from "@earendil-works/pi-tui";
8
+ import { allocateImageId, Box, getCapabilities, getPngDimensions, isKeyRelease, isKeyRepeat, matchesKey, renderImage, Text, wrapTextWithAnsi } from "@earendil-works/pi-tui";
9
9
  import { defineTool } from "@earendil-works/pi-coding-agent";
10
10
  import { Type } from "typebox";
11
11
  import { CODING_MODEL_ENV } from "./chat-models.js";
@@ -16,7 +16,7 @@ import { readScript, scriptAgainstMachine, stackOnMachine, toolchainsBlock } fro
16
16
  import { sandboxAvailable, sandboxSummary } from "./regenerate/os-sandbox.js";
17
17
  import { findTestScripts } from "./regenerate/test-scripts.js";
18
18
  import { createAskUserTool } from "./tools.js";
19
- import { asksFromScratch, driftTool, fromWorkingDir, haltTool, loopReply, MODEL_PARAM, regenerateTool, stopJob, WAIT_PARAM, WORKING_DIR_PARAM } from "./loop-tools.js";
19
+ import { asksFromScratch, asksWholeChain, driftTool, fromWorkingDir, haltTool, loopReply, MODEL_PARAM, regenerateTool, stopJob, WAIT_PARAM, WORKING_DIR_PARAM } from "./loop-tools.js";
20
20
  import { createWebTools } from "./regenerate/web.js";
21
21
  import { describeGates, interruptedRun, runSkill } from "./genome.js";
22
22
  import { skillStatus } from "./skill.js";
@@ -29,7 +29,8 @@ import { describeChoices, describeResolution, modelFor, resolveModel } from "./r
29
29
  import { checkPlainFile, checkPlainTargets, formatCheckResults } from "./plain/check.js";
30
30
  import { whyFailed } from "./regenerate/diagnose-job.js";
31
31
  import { createWorkLoop, describeModules, isUpToDate, previewJobs } from "./regenerate/loop.js";
32
- import { brandBlue, plainPaint } from "./regenerate/plain-palette.js";
32
+ import { brandNeon, brandPink, plainPaint } from "./regenerate/plain-palette.js";
33
+ import { halfBlocks, JELLYFISH_FRAME_MS, JELLYFISH_TEXT_FRAMES } from "./jellyfish.js";
33
34
  import { createJobPanel, didNotPass, keyPressed, PANEL_KEY, spinner } from "./regenerate/job-panel.js";
34
35
  import { clickToFocus, dockedWidth, narrowChat, shade, shadeChat } from "./regenerate/panel-dock.js";
35
36
  import { overPictureRow, PICTURE_AT } from "./picture-row.js";
@@ -41,13 +42,13 @@ import { createJobsTreeState, selectJob } from "./regenerate/jobs-tree.js";
41
42
  import { describeDiagnosis, diagnoseFailure } from "./regenerate/diagnose.js";
42
43
  import { HISTORY_DIR, historyLog, historyShow } from "./regenerate/lineage.js";
43
44
  import { defaultBuildDir } from "./regenerate/paths.js";
44
- import { describeUsage } from "./regenerate/activity.js";
45
+ import { describeTurnIncident, describeUsage, onModelEvent } from "./regenerate/activity.js";
45
46
  import { describeSpecConflict } from "./regenerate/stop-report.js";
46
47
  import { inheritProviders, inheritThinkingLevel } from "./pi.js";
47
48
  import { beginCapture, captureConsole, describeCaptured, dropNoise } from "./quiet.js";
48
49
  import { loadRules, renderRulesBlock } from "./rules.js";
49
50
  import { registerTurriConfig } from "./config-command.js";
50
- import { describeStdlib, stdlibStackCount } from "./stdlib.js";
51
+ import { describeStdlib } from "./stdlib.js";
51
52
  import { peekKeyListener, runAsk } from "./ask.js";
52
53
  import { QuestionDialog } from "./question-dialog.js";
53
54
  import { registerStacks } from "./stacks.js";
@@ -90,11 +91,12 @@ aside) {
90
91
  // The question, with what the asker gives to read for it - a brief to confirm - above it; what it said of its work
91
92
  // before asking is kept in its record, never put in the dialog.
92
93
  // A dialog of turri's own: a long brief scrolls above the question, and the options always show (question-dialog.ts).
93
- const dialog = (question, context, options) => ctx.ui.custom((tui, theme, _keybindings, done) => {
94
+ const dialog = (question, context, options, selected) => ctx.ui.custom((tui, theme, _keybindings, done) => {
94
95
  const shown = new QuestionDialog({
95
96
  question,
96
97
  ...(context !== undefined ? { context } : {}),
97
98
  ...(options !== undefined ? { options } : {}),
99
+ ...(selected !== undefined ? { selected } : {}),
98
100
  rows: () => tui.terminal.rows,
99
101
  style: { accent: (text) => theme.fg("accent", text), muted: (text) => theme.fg("muted", text), bold: (text) => theme.bold(text) },
100
102
  done: (answer) => {
@@ -108,7 +110,7 @@ aside) {
108
110
  return shown;
109
111
  });
110
112
  const asking = (asked) => runAsk(asked, {
111
- select: (title, options, context) => dialog(title, context, options),
113
+ select: (title, options, context, at) => dialog(title, context, options, at),
112
114
  input: (title, context) => dialog(title, context),
113
115
  });
114
116
  const bare = { ...request, said: undefined };
@@ -327,6 +329,19 @@ export default function (pi) {
327
329
  };
328
330
  pi.on("agent_end", endTurnCapture);
329
331
  pi.on("agent_settled", endTurnCapture);
332
+ // A pulse's provider failing and waited out, or a turn turri ended itself: said in the chat as it happens - the job
333
+ // panel's activity holds it too, but scrolls by.
334
+ let stopTurnIncidents;
335
+ pi.on("session_start", (_event, ctx) => {
336
+ stopTurnIncidents?.();
337
+ if (!ctx.hasUI)
338
+ return;
339
+ stopTurnIncidents = onModelEvent((event) => {
340
+ const line = describeTurnIncident(event);
341
+ if (line !== undefined)
342
+ ctx.ui.notify(event.job !== undefined ? `${event.job}: ${line}` : line, "warning");
343
+ });
344
+ });
330
345
  // What a turri that was killed left running - its commands' process groups - stopped as this one starts.
331
346
  const orphans = sweepOrphanedGroups();
332
347
  let orphansSaid = orphans === 0;
@@ -356,7 +371,7 @@ export default function (pi) {
356
371
  conversationModels = ctx.modelRegistry;
357
372
  });
358
373
  inheritProviders(() => conversationModels);
359
- registerBranding(pi, rules.length, discoveredSkills);
374
+ registerBranding(pi, discoveredSkills);
360
375
  registerInterviewLog(pi);
361
376
  registerJobTools(pi, jobs, cwd);
362
377
  registerCheckPlain(pi, cwd);
@@ -610,7 +625,7 @@ function registerRegenerate(pi, cwd, jobs) {
610
625
  // by the planner: one functional spec at a time, a few together or the whole module in one, as it judges. What
611
626
  // follows the module is guidance for that plan, in the person's words.
612
627
  pi.registerCommand("regenerate", {
613
- description: "Regenerate a module from its spec as it is now, in pulses the planner cuts - named functionalities though they did not change, or all of it from scratch: /regenerate [module | file.plain] [functionality ...] [from scratch] [how to cut the work]",
628
+ description: "Regenerate a module from its spec as it is now, in pulses the planner cuts - named functionalities though they did not change, or all of it from scratch, its whole chain too when asked: /regenerate [module | file.plain] [functionality ...] [from scratch [whole chain]] [how to cut the work]",
614
629
  handler: async (args, ctx) => {
615
630
  const command = `/regenerate ${args.trim()}`.trim();
616
631
  await echoCommand(pi, command);
@@ -652,13 +667,17 @@ function registerRegenerate(pi, cwd, jobs) {
652
667
  }
653
668
  // From scratch - started over, its code deleted - asked in the person's words: confirmed first, as it deletes.
654
669
  const scratch = asksFromScratch(guidance);
670
+ // The whole chain with it - "from scratch, the whole chain" - every module it requires built again from the bottom.
671
+ const chain = scratch && asksWholeChain(guidance);
655
672
  const module = basename(plainFile).replace(/\.plain$/, "");
656
673
  if (scratch && again.length > 0) {
657
674
  say("Name functionalities or ask for it from scratch, not both: from scratch regenerates every one of them.", "warning");
658
675
  return;
659
676
  }
660
677
  if (scratch && ctx.hasUI) {
661
- const agreed = await ctx.ui.confirm(`Regenerate ${module} from scratch?`, `Its code and conformance tests are deleted - committed first, so /lineage ${module} keeps them - and the whole module is regenerated from its spec.`);
678
+ const agreed = await ctx.ui.confirm(chain ? `Regenerate ${module} and its whole chain from scratch?` : `Regenerate ${module} from scratch?`, chain
679
+ ? `The code and conformance tests of ${module} and of every module it requires are deleted - committed first, so /lineage keeps them - and the whole chain is regenerated from its spec, from the bottom.`
680
+ : `Its code and conformance tests are deleted - committed first, so /lineage ${module} keeps them - and the whole module is regenerated from its spec.`);
662
681
  if (!agreed)
663
682
  return;
664
683
  }
@@ -668,14 +687,14 @@ function registerRegenerate(pi, cwd, jobs) {
668
687
  // Said at once, and kept in the chat: what follows takes a while - the planner is an agent - and the person sees it
669
688
  // began, not a chat that stays empty until the first pulse starts. The plan is said under it once it is made.
670
689
  say(scratch
671
- ? `Deleting ${module}'s code, then planning all of it again…`
690
+ ? `Deleting ${module}'s code${chain ? " and its whole chain's" : ""}, then planning all of it again…`
672
691
  : again.length > 0
673
692
  ? `Planning ${module}'s functionalit${again.length === 1 ? "y" : "ies"} ${again.join(", ")} again…`
674
693
  : `Planning ${module}'s pulses…`, "info");
675
694
  await nextFrame();
676
695
  try {
677
696
  const statuses = scratch
678
- ? await loop.fromScratch(plainFile, request)
697
+ ? await loop.fromScratch(plainFile, { ...request, chain })
679
698
  : again.length > 0
680
699
  ? await loop.regenerateAgain(plainFile, again, request)
681
700
  : await loop.bringUp(plainFile, request);
@@ -1499,7 +1518,8 @@ function registerJobTools(pi, jobs, cwd) {
1499
1518
  });
1500
1519
  // The side panel: the regeneration - and the pulses behind p - over the whole screen, or beside the chat (s, from one to
1501
1520
  // the other). Its key (PANEL_KEY) opens it; the key again closes it and goes back to the chat, as esc does over the
1502
- // screen - beside the chat, esc gives the chat its keys back and the panel stays, and the key gives them to the panel.
1521
+ // screen - beside the chat, the key switches sides, giving the keys to the chat or the panel, as esc gives them to the
1522
+ // chat, the panel staying; ctrl+c closes it.
1503
1523
  // While the panel has the keys, every key is its own.
1504
1524
  let panel;
1505
1525
  // Beside the chat or over it: as the person last left it, for the conversation.
@@ -1627,8 +1647,8 @@ function registerJobTools(pi, jobs, cwd) {
1627
1647
  removed: (text) => theme.fg("toolDiffRemoved", text),
1628
1648
  // A spec diff's ***plain highlighted as plyn highlights it, and its added and removed lines filled.
1629
1649
  diff: plainPaint(theme),
1630
- // What conformance tests show does what its spec says: brand blue.
1631
- conforms: brandBlue(theme),
1650
+ // What conformance tests show does what its spec says: neon.
1651
+ conforms: brandNeon(theme),
1632
1652
  },
1633
1653
  back,
1634
1654
  close,
@@ -1670,17 +1690,6 @@ function registerJobTools(pi, jobs, cwd) {
1670
1690
  }
1671
1691
  if (!state)
1672
1692
  return undefined;
1673
- // Beside the chat, ⌥⌘← and ⌥⌘→ go to the side they point at, whichever has the keys - on a terminal that tells
1674
- // turri of ⌘ (the Kitty keyboard protocol). Its release goes nowhere.
1675
- if (panelBeside() > 0 && (matchesKey(data, SIDE_KEYS.chat) || matchesKey(data, SIDE_KEYS.panel))) {
1676
- if (!isKeyRelease(data)) {
1677
- if (matchesKey(data, SIDE_KEYS.chat))
1678
- toChat();
1679
- else
1680
- toPanel();
1681
- }
1682
- return { consume: true };
1683
- }
1684
1693
  // Beside the chat, with the chat's keys: they are the chat's - PANEL_KEY among them, for the shortcut that gives
1685
1694
  // them to the panel. A click on the panel gives it the focus, and the keys with it.
1686
1695
  if (!entry.keys && entry.handle?.isFocused() !== true)
@@ -1691,9 +1700,13 @@ function registerJobTools(pi, jobs, cwd) {
1691
1700
  // presses count - and ctrl+h held down, repeating, does not open and close it over and over.
1692
1701
  if (isKeyRelease(data) || (isKeyRepeat(data) && matchesKey(data, PANEL_KEY)))
1693
1702
  return { consume: true };
1694
- // ctrl+c closes it too: whatever else goes wrong, a key always leads back to the chat.
1695
- if (matchesKey(data, PANEL_KEY) || matchesKey(data, "ctrl+c"))
1703
+ // PANEL_KEY goes back: beside the chat, to the chat, the panel staying - the switch between the sides, as it is
1704
+ // from the chat to the panel - and over the screen, closing it. ctrl+c closes it either way: whatever else goes
1705
+ // wrong, a key always leads back to the chat.
1706
+ if (matchesKey(data, "ctrl+c"))
1696
1707
  close();
1708
+ else if (matchesKey(data, PANEL_KEY))
1709
+ back();
1697
1710
  else {
1698
1711
  try {
1699
1712
  view.handleInput(data);
@@ -1723,8 +1736,10 @@ function registerJobTools(pi, jobs, cwd) {
1723
1736
  handleInput: (data) => {
1724
1737
  if (isKeyRepeat(data) && matchesKey(data, PANEL_KEY))
1725
1738
  return;
1726
- if (matchesKey(data, PANEL_KEY))
1739
+ if (matchesKey(data, "ctrl+c"))
1727
1740
  close();
1741
+ else if (matchesKey(data, PANEL_KEY))
1742
+ back();
1728
1743
  else
1729
1744
  view.handleInput(data);
1730
1745
  tui.requestRender();
@@ -1859,8 +1874,6 @@ export const JOB_FINISHED_REACTION = [
1859
1874
  " to do, and that \"resume\" picks it up once it is in.",
1860
1875
  "- a credential `agent-env:` names that is not there: never make one up - tell the person where it is read from.",
1861
1876
  ].join("\n");
1862
- /** The keys that go to the chat and to the panel, side by side: ⌥⌘← and ⌥⌘→. */
1863
- const SIDE_KEYS = { chat: "alt+super+left", panel: "alt+super+right" };
1864
1877
  /** Opens the side panel, and goes back to it from the conversation. */
1865
1878
  /** The modules in this project that have a history, by name. */
1866
1879
  function modulesWithHistory(cwd) {
@@ -2283,7 +2296,7 @@ const BANNER_ENTRY = "turri_banner";
2283
2296
  export function chatRulesBlock(rules = loadRules(join(PACKAGE_ROOT, "genome", "rules"))) {
2284
2297
  return renderRulesBlock(rules);
2285
2298
  }
2286
- function registerBranding(pi, ruleCount, skills) {
2299
+ function registerBranding(pi, skills) {
2287
2300
  pi.registerCommand("stdlib", {
2288
2301
  description: "List the ***plain standard library: the stacks a spec can import instead of writing its implementation reqs.",
2289
2302
  handler: async (_args, ctx) => {
@@ -2296,24 +2309,18 @@ function registerBranding(pi, ruleCount, skills) {
2296
2309
  if (data === undefined)
2297
2310
  return undefined;
2298
2311
  const lines = [
2299
- `${theme.fg("accent", "turri")} ${theme.fg("muted", `v${data.version}`)}` +
2312
+ `${brandPink(theme)("turri")} ${theme.fg("muted", `v${data.version}`)}` +
2300
2313
  (data.commit !== undefined ? theme.fg("dim", ` from a clone, ${data.commit}${data.changed ? " with changes" : ""}`) : ""),
2301
- theme.fg("text", "regenerative software - the code is regenerated from the spec"),
2302
- theme.fg("muted", `${data.rules} rules · ${data.skills} skill${data.skills === 1 ? "" : "s"}` +
2303
- (data.projectSkills !== undefined && data.projectSkills > 0 ? ` (${data.projectSkills} the project's)` : "") +
2304
- (data.stdlib !== undefined && data.stdlib > 0 ? ` · ${data.stdlib} stdlib stacks (/stdlib)` : "") +
2305
- (data.pending > 0 ? theme.fg("warning", ` (${data.pending} failed to load)`) : "")),
2314
+ theme.fg("text", "the first coding agent with the power of regenerative software"),
2306
2315
  // Where the settings are changed, without leaving the chat.
2307
2316
  theme.fg("muted", "configure with /turri-config"),
2308
- theme.fg("dim", data.cwd),
2309
- // Where every command an agent runs will run - or that none can.
2310
- ...(data.sandbox
2311
- ? [theme.fg(data.sandbox.level === "ok" ? "dim" : data.sandbox.level === "limited" ? "warning" : "error", data.sandbox.text)]
2312
- : []),
2317
+ // Only what is wrong: skills that did not load, and agents' commands less fenced than they should be.
2318
+ ...(data.pending > 0 ? [theme.fg("warning", `${data.pending} skill${data.pending === 1 ? "" : "s"} failed to load`)] : []),
2319
+ ...(data.sandbox !== undefined && data.sandbox.level !== "ok" ? [theme.fg(data.sandbox.level === "limited" ? "warning" : "error", data.sandbox.text)] : []),
2313
2320
  ];
2314
2321
  // The jellyfish turri is named after, in ink for the theme's background: a picture where the
2315
2322
  // terminal shows images, drawn in text where it does not.
2316
- return new Banner(lines, (rule) => theme.fg("borderMuted", rule), jellyfishArt(theme.appearance, (art) => theme.fg("text", art)));
2323
+ return new Banner(lines, (rule) => theme.fg("borderMuted", rule), jellyfishArt(theme.appearance, (theme.getColorMode?.() ?? "truecolor") === "truecolor"));
2317
2324
  });
2318
2325
  pi.on("session_start", (_event, ctx) => {
2319
2326
  if (ctx.hasUI)
@@ -2324,12 +2331,7 @@ function registerBranding(pi, ruleCount, skills) {
2324
2331
  version: identity.version ?? "0.0.0",
2325
2332
  commit: identity.git_commit?.slice(0, 7),
2326
2333
  changed: identity.git_dirty === true,
2327
- rules: ruleCount,
2328
- skills: skills.skills.length,
2329
- projectSkills: skills.skills.filter((skill) => skill.origin !== "turri").length,
2330
2334
  pending: skills.pending.length,
2331
- stdlib: stdlibStackCount(),
2332
- cwd: ctx.cwd,
2333
2335
  sandbox: sandboxSummary(),
2334
2336
  });
2335
2337
  }
@@ -2338,10 +2340,8 @@ function registerBranding(pi, ruleCount, skills) {
2338
2340
  }
2339
2341
  });
2340
2342
  }
2341
- /** How many rows the banner's jellyfish takes: taller than the lines beside it. */
2342
- const JELLYFISH_ROWS = 13;
2343
- /** How long each frame of the jellyfish shows. */
2344
- const JELLYFISH_FRAME_MS = 250;
2343
+ /** How many rows the banner's jellyfish takes at most: as tall as the one drawn in text. */
2344
+ const JELLYFISH_ROWS = 10;
2345
2345
  /** Which frame of the jellyfish every banner shows, moved on by `animateJellyfish`. */
2346
2346
  let jellyfishFrame = 0;
2347
2347
  let jellyfishTimer;
@@ -2461,24 +2461,16 @@ class Banner {
2461
2461
  }
2462
2462
  const jellyfishFrameCache = new Map();
2463
2463
  /**
2464
- * The banner's jellyfish for this terminal: where it shows images, the picture's frames spread evenly
2465
- * over the video, light ink for a dark background and dark ink for a light one; where it does not, the
2466
- * jellyfish drawn in text, in `ink`. None when they cannot be read.
2464
+ * The banner's jellyfish for this terminal: where it shows images, the picture's frames
2465
+ * (scripts/jellyfish-frames.mjs writes them), in the colours for the theme's background; where it does not, the
2466
+ * small one in half blocks. None when the pictures cannot be read.
2467
2467
  */
2468
- function jellyfishArt(appearance, ink) {
2468
+ function jellyfishArt(appearance, truecolor) {
2469
2469
  const dir = join(PACKAGE_ROOT, "assets", "jellyfish");
2470
2470
  try {
2471
2471
  if (getCapabilities().images === null) {
2472
- // Its frames one after another, each ended by a line of "---" (scripts/jellyfish-frames.mjs writes them).
2473
- const drawn = readFileSync(join(dir, "fallback.txt"), "utf8")
2474
- .split(/^---$/m)
2475
- .map((frame) => frame.replace(/^\n+|\n+$/g, "").split("\n"))
2476
- .filter((frame) => frame.some((line) => line.trim() !== ""));
2477
- if (drawn.length === 0)
2478
- return undefined;
2479
- const columns = Math.max(...drawn.flat().map((line) => visibleWidth(line)));
2480
- const rows = Math.max(...drawn.map((frame) => frame.length));
2481
- return { kind: "text", frames: drawn.map((frame) => frame.map((line) => ink(line.padEnd(columns)))), columns, rows };
2472
+ const frames = JELLYFISH_TEXT_FRAMES.map((pixels) => halfBlocks(pixels, appearance, truecolor));
2473
+ return { kind: "text", frames, columns: JELLYFISH_TEXT_FRAMES[0][0].length, rows: frames[0].length };
2482
2474
  }
2483
2475
  let frames = jellyfishFrameCache.get(appearance);
2484
2476
  if (frames === undefined) {