@turri-dev/cli 0.1.4-next.fa9223b → 0.1.4

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 (105) hide show
  1. package/.pi/themes/turri-dark.json +67 -66
  2. package/.pi/themes/turri-light.json +71 -73
  3. package/README.md +41 -127
  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/brand.js +7 -7
  29. package/dist/cli-options.js +12 -6
  30. package/dist/config-edit.js +1 -0
  31. package/dist/config.js +5 -2
  32. package/dist/cultivate-cli.js +16 -23
  33. package/dist/extension.js +86 -73
  34. package/dist/init-config.js +5 -0
  35. package/dist/jellyfish.js +130 -0
  36. package/dist/loop-cli.js +16 -8
  37. package/dist/loop-tools.js +11 -5
  38. package/dist/module-report.js +5 -4
  39. package/dist/pi.js +76 -19
  40. package/dist/picture-row.js +3 -2
  41. package/dist/regenerate/activity.js +21 -0
  42. package/dist/regenerate/list-arguments.js +121 -0
  43. package/dist/regenerate/loop.js +9 -5
  44. package/dist/regenerate/panel-dock.js +7 -5
  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 +26 -1
  56. package/dist/screen-padding.js +72 -0
  57. package/dist/validate-cli.js +3 -8
  58. package/docs/README.md +5 -12
  59. package/docs/authoring-plain.md +37 -119
  60. package/docs/config.md +53 -178
  61. package/docs/deploy.md +21 -80
  62. package/docs/development.md +14 -41
  63. package/docs/headless.md +40 -129
  64. package/docs/images/how-turri-works.svg +29 -31
  65. package/docs/images/turri-banner.png +0 -0
  66. package/docs/images/turri-screenshot.png +0 -0
  67. package/docs/installation.md +13 -40
  68. package/docs/parser.md +15 -43
  69. package/docs/regenerating.md +231 -942
  70. package/docs/sandbox.md +38 -152
  71. package/docs/skills-and-gates.md +50 -173
  72. package/docs/theming.md +45 -46
  73. package/docs/using.md +68 -344
  74. package/genome/rules/bullet-continuation.md +5 -13
  75. package/genome/rules/concise-specs-examples.md +2 -4
  76. package/genome/rules/concise-specs-integration-examples.md +2 -6
  77. package/genome/rules/concise-specs.md +1 -2
  78. package/genome/rules/func-specs.md +1 -0
  79. package/genome/rules/integration-embedded-testing.md +1 -4
  80. package/genome/rules/integrations.md +1 -2
  81. package/genome/rules/project-model.md +14 -35
  82. package/genome/rules/stdlib.md +14 -49
  83. package/genome/rules/turri-regeneration.md +48 -0
  84. package/genome/skills/add-implementation-requirement/SKILL.md +1 -2
  85. package/genome/skills/analyze-if-func-spec-too-complex/SKILL.md +3 -8
  86. package/genome/skills/brood/SKILL.md +37 -127
  87. package/genome/skills/brood/references/intent.md +4 -12
  88. package/genome/skills/brood/references/product.md +24 -76
  89. package/genome/skills/brood/references/stack.md +7 -29
  90. package/genome/skills/brood/references/testing.md +11 -42
  91. package/genome/skills/bud/SKILL.md +32 -109
  92. package/genome/skills/bud/references/intent.md +4 -11
  93. package/genome/skills/implement-conformance-testing-script/SKILL.md +3 -6
  94. package/genome/skills/implement-unit-testing-script/SKILL.md +1 -2
  95. package/genome/skills/mature/SKILL.md +21 -69
  96. package/genome/skills/refactor-module/SKILL.md +24 -2
  97. package/genome/skills/spawn/SKILL.md +28 -113
  98. package/package.json +1 -1
  99. package/assets/jellyfish/dark-12.png +0 -0
  100. package/assets/jellyfish/dark-13.png +0 -0
  101. package/assets/jellyfish/dark-14.png +0 -0
  102. package/assets/jellyfish/fallback.txt +0 -252
  103. package/assets/jellyfish/light-12.png +0 -0
  104. package/assets/jellyfish/light-13.png +0 -0
  105. 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
Binary file
Binary file
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,10 +29,12 @@ 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";
37
+ import { padScreen, paddedColumns, paddedRows, SCREEN_PADDING } from "./screen-padding.js";
36
38
  import { skillAboutLine, skillProgressLine } from "./skill-progress.js";
37
39
  import { createSidePanel } from "./regenerate/side-panel.js";
38
40
  import { createSpecMapSource, defaultMapFiles } from "./regenerate/spec-map.js";
@@ -41,13 +43,13 @@ import { createJobsTreeState, selectJob } from "./regenerate/jobs-tree.js";
41
43
  import { describeDiagnosis, diagnoseFailure } from "./regenerate/diagnose.js";
42
44
  import { HISTORY_DIR, historyLog, historyShow } from "./regenerate/lineage.js";
43
45
  import { defaultBuildDir } from "./regenerate/paths.js";
44
- import { describeUsage } from "./regenerate/activity.js";
46
+ import { describeTurnIncident, describeUsage, onModelEvent } from "./regenerate/activity.js";
45
47
  import { describeSpecConflict } from "./regenerate/stop-report.js";
46
48
  import { inheritProviders, inheritThinkingLevel } from "./pi.js";
47
49
  import { beginCapture, captureConsole, describeCaptured, dropNoise } from "./quiet.js";
48
50
  import { loadRules, renderRulesBlock } from "./rules.js";
49
51
  import { registerTurriConfig } from "./config-command.js";
50
- import { describeStdlib, stdlibStackCount } from "./stdlib.js";
52
+ import { describeStdlib } from "./stdlib.js";
51
53
  import { peekKeyListener, runAsk } from "./ask.js";
52
54
  import { QuestionDialog } from "./question-dialog.js";
53
55
  import { registerStacks } from "./stacks.js";
@@ -96,7 +98,7 @@ aside) {
96
98
  ...(context !== undefined ? { context } : {}),
97
99
  ...(options !== undefined ? { options } : {}),
98
100
  ...(selected !== undefined ? { selected } : {}),
99
- rows: () => tui.terminal.rows,
101
+ rows: () => paddedRows(tui.terminal.rows),
100
102
  style: { accent: (text) => theme.fg("accent", text), muted: (text) => theme.fg("muted", text), bold: (text) => theme.bold(text) },
101
103
  done: (answer) => {
102
104
  if (questionShown === shown)
@@ -328,6 +330,19 @@ export default function (pi) {
328
330
  };
329
331
  pi.on("agent_end", endTurnCapture);
330
332
  pi.on("agent_settled", endTurnCapture);
333
+ // A pulse's provider failing and waited out, or a turn turri ended itself: said in the chat as it happens - the job
334
+ // panel's activity holds it too, but scrolls by.
335
+ let stopTurnIncidents;
336
+ pi.on("session_start", (_event, ctx) => {
337
+ stopTurnIncidents?.();
338
+ if (!ctx.hasUI)
339
+ return;
340
+ stopTurnIncidents = onModelEvent((event) => {
341
+ const line = describeTurnIncident(event);
342
+ if (line !== undefined)
343
+ ctx.ui.notify(event.job !== undefined ? `${event.job}: ${line}` : line, "warning");
344
+ });
345
+ });
331
346
  // What a turri that was killed left running - its commands' process groups - stopped as this one starts.
332
347
  const orphans = sweepOrphanedGroups();
333
348
  let orphansSaid = orphans === 0;
@@ -357,7 +372,7 @@ export default function (pi) {
357
372
  conversationModels = ctx.modelRegistry;
358
373
  });
359
374
  inheritProviders(() => conversationModels);
360
- registerBranding(pi, rules.length, discoveredSkills);
375
+ registerBranding(pi, discoveredSkills);
361
376
  registerInterviewLog(pi);
362
377
  registerJobTools(pi, jobs, cwd);
363
378
  registerCheckPlain(pi, cwd);
@@ -611,7 +626,7 @@ function registerRegenerate(pi, cwd, jobs) {
611
626
  // by the planner: one functional spec at a time, a few together or the whole module in one, as it judges. What
612
627
  // follows the module is guidance for that plan, in the person's words.
613
628
  pi.registerCommand("regenerate", {
614
- 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]",
629
+ 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]",
615
630
  handler: async (args, ctx) => {
616
631
  const command = `/regenerate ${args.trim()}`.trim();
617
632
  await echoCommand(pi, command);
@@ -653,13 +668,17 @@ function registerRegenerate(pi, cwd, jobs) {
653
668
  }
654
669
  // From scratch - started over, its code deleted - asked in the person's words: confirmed first, as it deletes.
655
670
  const scratch = asksFromScratch(guidance);
671
+ // The whole chain with it - "from scratch, the whole chain" - every module it requires built again from the bottom.
672
+ const chain = scratch && asksWholeChain(guidance);
656
673
  const module = basename(plainFile).replace(/\.plain$/, "");
657
674
  if (scratch && again.length > 0) {
658
675
  say("Name functionalities or ask for it from scratch, not both: from scratch regenerates every one of them.", "warning");
659
676
  return;
660
677
  }
661
678
  if (scratch && ctx.hasUI) {
662
- 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.`);
679
+ const agreed = await ctx.ui.confirm(chain ? `Regenerate ${module} and its whole chain from scratch?` : `Regenerate ${module} from scratch?`, chain
680
+ ? `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.`
681
+ : `Its code and conformance tests are deleted - committed first, so /lineage ${module} keeps them - and the whole module is regenerated from its spec.`);
663
682
  if (!agreed)
664
683
  return;
665
684
  }
@@ -669,14 +688,14 @@ function registerRegenerate(pi, cwd, jobs) {
669
688
  // Said at once, and kept in the chat: what follows takes a while - the planner is an agent - and the person sees it
670
689
  // began, not a chat that stays empty until the first pulse starts. The plan is said under it once it is made.
671
690
  say(scratch
672
- ? `Deleting ${module}'s code, then planning all of it again…`
691
+ ? `Deleting ${module}'s code${chain ? " and its whole chain's" : ""}, then planning all of it again…`
673
692
  : again.length > 0
674
693
  ? `Planning ${module}'s functionalit${again.length === 1 ? "y" : "ies"} ${again.join(", ")} again…`
675
694
  : `Planning ${module}'s pulses…`, "info");
676
695
  await nextFrame();
677
696
  try {
678
697
  const statuses = scratch
679
- ? await loop.fromScratch(plainFile, request)
698
+ ? await loop.fromScratch(plainFile, { ...request, chain })
680
699
  : again.length > 0
681
700
  ? await loop.regenerateAgain(plainFile, again, request)
682
701
  : await loop.bringUp(plainFile, request);
@@ -1500,7 +1519,8 @@ function registerJobTools(pi, jobs, cwd) {
1500
1519
  });
1501
1520
  // The side panel: the regeneration - and the pulses behind p - over the whole screen, or beside the chat (s, from one to
1502
1521
  // the other). Its key (PANEL_KEY) opens it; the key again closes it and goes back to the chat, as esc does over the
1503
- // screen - beside the chat, esc gives the chat its keys back and the panel stays, and the key gives them to the panel.
1522
+ // screen - beside the chat, the key switches sides, giving the keys to the chat or the panel, as esc gives them to the
1523
+ // chat, the panel staying; ctrl+c closes it.
1504
1524
  // While the panel has the keys, every key is its own.
1505
1525
  let panel;
1506
1526
  // Beside the chat or over it: as the person last left it, for the conversation.
@@ -1508,7 +1528,7 @@ function registerJobTools(pi, jobs, cwd) {
1508
1528
  // The terminal the panel is drawn on, for its width: set as it opens.
1509
1529
  let panelTerminal;
1510
1530
  /** The columns the panel takes beside the chat - 0 over the whole screen, or when the terminal is too narrow to share. */
1511
- const panelBeside = () => (panelDocked && panelTerminal !== undefined ? dockedWidth(panelTerminal.columns) : 0);
1531
+ const panelBeside = () => (panelDocked && panelTerminal !== undefined ? dockedWidth(paddedColumns(panelTerminal.columns)) : 0);
1512
1532
  // What is open in the pulse list and the map, and where their cursors are: the conversation's, as left each time it opens.
1513
1533
  const jobsTree = createJobsTreeState();
1514
1534
  const mapState = createSpecMapState();
@@ -1566,7 +1586,7 @@ function registerJobTools(pi, jobs, cwd) {
1566
1586
  const layOut = () => {
1567
1587
  if (panelDocked && undock === undefined) {
1568
1588
  const widen = narrowChat(tui, panelBeside);
1569
- const unwatch = clickToFocus(tui, () => tui.terminal.columns - panelBeside(), (side) => {
1589
+ const unwatch = clickToFocus(tui, () => tui.terminal.columns - SCREEN_PADDING.right - panelBeside(), (side) => {
1570
1590
  if (panelBeside() === 0)
1571
1591
  return;
1572
1592
  if (side === "chat")
@@ -1607,7 +1627,7 @@ function registerJobTools(pi, jobs, cwd) {
1607
1627
  tree: jobsTree,
1608
1628
  map: () => specMap.read(),
1609
1629
  mapState,
1610
- rows: () => tui.terminal.rows,
1630
+ rows: () => paddedRows(tui.terminal.rows),
1611
1631
  key: PANEL_KEY,
1612
1632
  dock: {
1613
1633
  docked: () => panelBeside() > 0,
@@ -1628,8 +1648,8 @@ function registerJobTools(pi, jobs, cwd) {
1628
1648
  removed: (text) => theme.fg("toolDiffRemoved", text),
1629
1649
  // A spec diff's ***plain highlighted as plyn highlights it, and its added and removed lines filled.
1630
1650
  diff: plainPaint(theme),
1631
- // What conformance tests show does what its spec says: brand blue.
1632
- conforms: brandBlue(theme),
1651
+ // What conformance tests show does what its spec says: neon.
1652
+ conforms: brandNeon(theme),
1633
1653
  },
1634
1654
  back,
1635
1655
  close,
@@ -1671,17 +1691,6 @@ function registerJobTools(pi, jobs, cwd) {
1671
1691
  }
1672
1692
  if (!state)
1673
1693
  return undefined;
1674
- // Beside the chat, ⌥⌘← and ⌥⌘→ go to the side they point at, whichever has the keys - on a terminal that tells
1675
- // turri of ⌘ (the Kitty keyboard protocol). Its release goes nowhere.
1676
- if (panelBeside() > 0 && (matchesKey(data, SIDE_KEYS.chat) || matchesKey(data, SIDE_KEYS.panel))) {
1677
- if (!isKeyRelease(data)) {
1678
- if (matchesKey(data, SIDE_KEYS.chat))
1679
- toChat();
1680
- else
1681
- toPanel();
1682
- }
1683
- return { consume: true };
1684
- }
1685
1694
  // Beside the chat, with the chat's keys: they are the chat's - PANEL_KEY among them, for the shortcut that gives
1686
1695
  // them to the panel. A click on the panel gives it the focus, and the keys with it.
1687
1696
  if (!entry.keys && entry.handle?.isFocused() !== true)
@@ -1692,9 +1701,13 @@ function registerJobTools(pi, jobs, cwd) {
1692
1701
  // presses count - and ctrl+h held down, repeating, does not open and close it over and over.
1693
1702
  if (isKeyRelease(data) || (isKeyRepeat(data) && matchesKey(data, PANEL_KEY)))
1694
1703
  return { consume: true };
1695
- // ctrl+c closes it too: whatever else goes wrong, a key always leads back to the chat.
1696
- if (matchesKey(data, PANEL_KEY) || matchesKey(data, "ctrl+c"))
1704
+ // PANEL_KEY goes back: beside the chat, to the chat, the panel staying - the switch between the sides, as it is
1705
+ // from the chat to the panel - and over the screen, closing it. ctrl+c closes it either way: whatever else goes
1706
+ // wrong, a key always leads back to the chat.
1707
+ if (matchesKey(data, "ctrl+c"))
1697
1708
  close();
1709
+ else if (matchesKey(data, PANEL_KEY))
1710
+ back();
1698
1711
  else {
1699
1712
  try {
1700
1713
  view.handleInput(data);
@@ -1724,8 +1737,10 @@ function registerJobTools(pi, jobs, cwd) {
1724
1737
  handleInput: (data) => {
1725
1738
  if (isKeyRepeat(data) && matchesKey(data, PANEL_KEY))
1726
1739
  return;
1727
- if (matchesKey(data, PANEL_KEY))
1740
+ if (matchesKey(data, "ctrl+c"))
1728
1741
  close();
1742
+ else if (matchesKey(data, PANEL_KEY))
1743
+ back();
1729
1744
  else
1730
1745
  view.handleInput(data);
1731
1746
  tui.requestRender();
@@ -1743,14 +1758,15 @@ function registerJobTools(pi, jobs, cwd) {
1743
1758
  return component;
1744
1759
  }, {
1745
1760
  overlay: true,
1746
- // The whole screen, or the columns on the right beside the chat - read at each frame, so it follows the terminal.
1761
+ // The whole screen, or the columns on the right beside the chat - read at each frame, so it follows the terminal -
1762
+ // inside the screen's padding.
1747
1763
  overlayOptions: {
1748
1764
  get width() {
1749
1765
  return panelBeside() > 0 ? panelBeside() : "100%";
1750
1766
  },
1751
1767
  maxHeight: "100%",
1752
1768
  anchor: "top-right",
1753
- margin: 0,
1769
+ margin: { ...SCREEN_PADDING },
1754
1770
  },
1755
1771
  onHandle: (handle) => {
1756
1772
  if (panel !== undefined)
@@ -1860,8 +1876,6 @@ export const JOB_FINISHED_REACTION = [
1860
1876
  " to do, and that \"resume\" picks it up once it is in.",
1861
1877
  "- a credential `agent-env:` names that is not there: never make one up - tell the person where it is read from.",
1862
1878
  ].join("\n");
1863
- /** The keys that go to the chat and to the panel, side by side: ⌥⌘← and ⌥⌘→. */
1864
- const SIDE_KEYS = { chat: "alt+super+left", panel: "alt+super+right" };
1865
1879
  /** Opens the side panel, and goes back to it from the conversation. */
1866
1880
  /** The modules in this project that have a history, by name. */
1867
1881
  function modulesWithHistory(cwd) {
@@ -2284,7 +2298,7 @@ const BANNER_ENTRY = "turri_banner";
2284
2298
  export function chatRulesBlock(rules = loadRules(join(PACKAGE_ROOT, "genome", "rules"))) {
2285
2299
  return renderRulesBlock(rules);
2286
2300
  }
2287
- function registerBranding(pi, ruleCount, skills) {
2301
+ function registerBranding(pi, skills) {
2288
2302
  pi.registerCommand("stdlib", {
2289
2303
  description: "List the ***plain standard library: the stacks a spec can import instead of writing its implementation reqs.",
2290
2304
  handler: async (_args, ctx) => {
@@ -2297,40 +2311,31 @@ function registerBranding(pi, ruleCount, skills) {
2297
2311
  if (data === undefined)
2298
2312
  return undefined;
2299
2313
  const lines = [
2300
- `${theme.fg("accent", "turri")} ${theme.fg("muted", `v${data.version}`)}` +
2314
+ `${brandPink(theme)("turri")} ${theme.fg("muted", `v${data.version}`)}` +
2301
2315
  (data.commit !== undefined ? theme.fg("dim", ` from a clone, ${data.commit}${data.changed ? " with changes" : ""}`) : ""),
2302
- theme.fg("text", "regenerative software - the code is regenerated from the spec"),
2303
- theme.fg("muted", `${data.rules} rules · ${data.skills} skill${data.skills === 1 ? "" : "s"}` +
2304
- (data.projectSkills !== undefined && data.projectSkills > 0 ? ` (${data.projectSkills} the project's)` : "") +
2305
- (data.stdlib !== undefined && data.stdlib > 0 ? ` · ${data.stdlib} stdlib stacks (/stdlib)` : "") +
2306
- (data.pending > 0 ? theme.fg("warning", ` (${data.pending} failed to load)`) : "")),
2316
+ theme.fg("text", "the first coding agent with the power of regenerative software"),
2307
2317
  // Where the settings are changed, without leaving the chat.
2308
2318
  theme.fg("muted", "configure with /turri-config"),
2309
- theme.fg("dim", data.cwd),
2310
- // Where every command an agent runs will run - or that none can.
2311
- ...(data.sandbox
2312
- ? [theme.fg(data.sandbox.level === "ok" ? "dim" : data.sandbox.level === "limited" ? "warning" : "error", data.sandbox.text)]
2313
- : []),
2319
+ // Only what is wrong: skills that did not load, and agents' commands less fenced than they should be.
2320
+ ...(data.pending > 0 ? [theme.fg("warning", `${data.pending} skill${data.pending === 1 ? "" : "s"} failed to load`)] : []),
2321
+ ...(data.sandbox !== undefined && data.sandbox.level !== "ok" ? [theme.fg(data.sandbox.level === "limited" ? "warning" : "error", data.sandbox.text)] : []),
2314
2322
  ];
2315
2323
  // The jellyfish turri is named after, in ink for the theme's background: a picture where the
2316
2324
  // terminal shows images, drawn in text where it does not.
2317
- return new Banner(lines, (rule) => theme.fg("borderMuted", rule), jellyfishArt(theme.appearance, (art) => theme.fg("text", art)));
2325
+ return new Banner(lines, (rule) => theme.fg("borderMuted", rule), jellyfishArt(theme.appearance, (theme.getColorMode?.() ?? "truecolor") === "truecolor"));
2318
2326
  });
2319
2327
  pi.on("session_start", (_event, ctx) => {
2320
- if (ctx.hasUI)
2328
+ if (ctx.hasUI) {
2329
+ padTheScreen(ctx);
2321
2330
  animateJellyfish(ctx);
2331
+ }
2322
2332
  try {
2323
2333
  const identity = turriIdentity();
2324
2334
  pi.appendEntry(BANNER_ENTRY, {
2325
2335
  version: identity.version ?? "0.0.0",
2326
2336
  commit: identity.git_commit?.slice(0, 7),
2327
2337
  changed: identity.git_dirty === true,
2328
- rules: ruleCount,
2329
- skills: skills.skills.length,
2330
- projectSkills: skills.skills.filter((skill) => skill.origin !== "turri").length,
2331
2338
  pending: skills.pending.length,
2332
- stdlib: stdlibStackCount(),
2333
- cwd: ctx.cwd,
2334
2339
  sandbox: sandboxSummary(),
2335
2340
  });
2336
2341
  }
@@ -2339,10 +2344,8 @@ function registerBranding(pi, ruleCount, skills) {
2339
2344
  }
2340
2345
  });
2341
2346
  }
2342
- /** How many rows the banner's jellyfish takes: taller than the lines beside it. */
2343
- const JELLYFISH_ROWS = 13;
2344
- /** How long each frame of the jellyfish shows. */
2345
- const JELLYFISH_FRAME_MS = 250;
2347
+ /** How many rows the banner's jellyfish takes at most: as tall as the one drawn in text. */
2348
+ const JELLYFISH_ROWS = 10;
2346
2349
  /** Which frame of the jellyfish every banner shows, moved on by `animateJellyfish`. */
2347
2350
  let jellyfishFrame = 0;
2348
2351
  let jellyfishTimer;
@@ -2377,6 +2380,24 @@ function animateJellyfish(ctx) {
2377
2380
  }, { placement: "belowEditor" });
2378
2381
  }
2379
2382
  const JELLYFISH_CLOCK_KEY = "turri-jellyfish";
2383
+ /**
2384
+ * The whole screen inside its padding (`screen-padding.ts`). An extension is given pi's screen only through what it
2385
+ * draws, so an empty widget below the editor hands it over - at each frame, as pi starts a new screen when it changes
2386
+ * how it draws.
2387
+ */
2388
+ function padTheScreen(ctx) {
2389
+ ctx.ui.setWidget(SCREEN_PADDING_KEY, (tui) => {
2390
+ padScreen(tui);
2391
+ return {
2392
+ render: () => {
2393
+ padScreen(tui);
2394
+ return [];
2395
+ },
2396
+ invalidate: () => { },
2397
+ };
2398
+ }, { placement: "belowEditor" });
2399
+ }
2400
+ const SCREEN_PADDING_KEY = "turri-padding";
2380
2401
  /** The columns the banner's picture takes from the left edge, while it shows one; 0 when it does not. */
2381
2402
  let pictureRight = 0;
2382
2403
  /**
@@ -2435,7 +2456,7 @@ class Banner {
2435
2456
  return line !== undefined ? `${before}${line}` : placed?.kind === "text" ? ` ${jellyfish}` : "";
2436
2457
  });
2437
2458
  // The side panel is drawn beside the picture (drawOverlaysBesidePicture), which goes on showing.
2438
- pictureRight = placed?.kind === "image" ? 1 + placed.columns : 0;
2459
+ pictureRight = placed?.kind === "image" ? SCREEN_PADDING.left + 1 + placed.columns : 0;
2439
2460
  if (placed?.kind === "image") {
2440
2461
  const at = placed.onLastRow ? placed.rows - 1 : 0;
2441
2462
  rows[at] = `${rows[at]}${PICTURE_AT}${placed.sequence}`;
@@ -2462,24 +2483,16 @@ class Banner {
2462
2483
  }
2463
2484
  const jellyfishFrameCache = new Map();
2464
2485
  /**
2465
- * The banner's jellyfish for this terminal: where it shows images, the picture's frames spread evenly
2466
- * over the video, light ink for a dark background and dark ink for a light one; where it does not, the
2467
- * jellyfish drawn in text, in `ink`. None when they cannot be read.
2486
+ * The banner's jellyfish for this terminal: where it shows images, the picture's frames
2487
+ * (scripts/jellyfish-frames.mjs writes them), in the colours for the theme's background; where it does not, the
2488
+ * small one in half blocks. None when the pictures cannot be read.
2468
2489
  */
2469
- function jellyfishArt(appearance, ink) {
2490
+ function jellyfishArt(appearance, truecolor) {
2470
2491
  const dir = join(PACKAGE_ROOT, "assets", "jellyfish");
2471
2492
  try {
2472
2493
  if (getCapabilities().images === null) {
2473
- // Its frames one after another, each ended by a line of "---" (scripts/jellyfish-frames.mjs writes them).
2474
- const drawn = readFileSync(join(dir, "fallback.txt"), "utf8")
2475
- .split(/^---$/m)
2476
- .map((frame) => frame.replace(/^\n+|\n+$/g, "").split("\n"))
2477
- .filter((frame) => frame.some((line) => line.trim() !== ""));
2478
- if (drawn.length === 0)
2479
- return undefined;
2480
- const columns = Math.max(...drawn.flat().map((line) => visibleWidth(line)));
2481
- const rows = Math.max(...drawn.map((frame) => frame.length));
2482
- return { kind: "text", frames: drawn.map((frame) => frame.map((line) => ink(line.padEnd(columns)))), columns, rows };
2494
+ const frames = JELLYFISH_TEXT_FRAMES.map((pixels) => halfBlocks(pixels, appearance, truecolor));
2495
+ return { kind: "text", frames, columns: JELLYFISH_TEXT_FRAMES[0][0].length, rows: frames[0].length };
2483
2496
  }
2484
2497
  let frames = jellyfishFrameCache.get(appearance);
2485
2498
  if (frames === undefined) {