@turri-dev/cli 0.1.3-next.26f08c5 → 0.1.3-next.420ce7e

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 (42) hide show
  1. package/README.md +1 -1
  2. package/dist/config.js +3 -2
  3. package/dist/extension.js +167 -51
  4. package/dist/identity.js +1 -1
  5. package/dist/loop-cli.js +1 -1
  6. package/dist/loop-tools.js +1 -1
  7. package/dist/pi-launch.js +5 -0
  8. package/dist/picture-row.js +21 -0
  9. package/dist/question-dialog.js +8 -3
  10. package/dist/questioning.js +1 -1
  11. package/dist/regenerate/activity.js +2 -0
  12. package/dist/regenerate/confine.js +1 -0
  13. package/dist/regenerate/conform.js +5 -5
  14. package/dist/regenerate/conformance-agents.js +220 -11
  15. package/dist/regenerate/conformance.js +91 -35
  16. package/dist/regenerate/debugger.js +27 -3
  17. package/dist/regenerate/environment-error.js +63 -9
  18. package/dist/regenerate/loop.js +22 -4
  19. package/dist/regenerate/notes.js +66 -17
  20. package/dist/regenerate/panel-dock.js +86 -0
  21. package/dist/regenerate/prompt.js +3 -1
  22. package/dist/regenerate/regenerate.js +35 -14
  23. package/dist/regenerate/regression.js +2 -1
  24. package/dist/regenerate/requires.js +55 -2
  25. package/dist/regenerate/side-panel.js +14 -4
  26. package/dist/regenerate/stop-report.js +13 -0
  27. package/dist/regenerate/test-scripts.js +45 -9
  28. package/dist/regenerate/unit-review.js +11 -0
  29. package/dist/regenerate-cli.js +1 -1
  30. package/dist/resume-line.js +4 -0
  31. package/dist/spec-tools.js +8 -44
  32. package/docs/authoring-plain.md +9 -6
  33. package/docs/config.md +3 -2
  34. package/docs/development.md +1 -0
  35. package/docs/headless.md +2 -2
  36. package/docs/regenerating.md +81 -22
  37. package/docs/skills-and-gates.md +2 -2
  38. package/docs/using.md +12 -3
  39. package/genome/skills/bud/SKILL.md +67 -36
  40. package/genome/skills/bud/references/intent.md +4 -0
  41. package/package.json +3 -3
  42. package/genome/skills/bud/references/checklist.md +0 -44
@@ -335,7 +335,15 @@ async function runScript(cwd, script, args, logDir, options = {}) {
335
335
  const noted = withScriptLineNote(text, script);
336
336
  // Its failures, counts and end are what the agent is shown; the whole is kept, a read_output away.
337
337
  const log = keepTestOutput(logDir, basename(script), noted);
338
- return { command: shown(script), exitCode: timedOut === true ? 124 : exitCode, output: shownTestOutput(noted, log), timedOut: timedOut === true, timeoutMs, ...(log !== undefined ? { log } : {}) };
338
+ return {
339
+ command: shown(script),
340
+ exitCode: timedOut === true ? 124 : exitCode,
341
+ output: shownTestOutput(noted, log),
342
+ timedOut: timedOut === true,
343
+ timeoutMs,
344
+ elapsedMs: Date.now() - started,
345
+ ...(log !== undefined ? { log } : {}),
346
+ };
339
347
  }
340
348
  /** What bash says when a line of the script itself cannot run: a command or file that is not there, or not runnable. */
341
349
  const OWN_LINE_FAILURE = /: (No such file or directory|command not found|Permission denied)$/;
@@ -589,6 +597,19 @@ function loopNotice(loop) {
589
597
  "the failure with fresh eyes, and you will be given what it finds.",
590
598
  ].join("\n");
591
599
  }
600
+ /**
601
+ * How long a run took against its time limit, in a line: for whoever judges it or works out its cause - so a run that
602
+ * ended on its own is never taken for one the limit stopped, nor the other way.
603
+ */
604
+ export function runTiming(run) {
605
+ const seconds = (ms) => `${(ms / 1000).toFixed(1)}s`;
606
+ const limit = seconds(run.timeoutMs);
607
+ if (run.timedOut === true) {
608
+ return `The time limit stopped this run: it had run ${seconds(run.elapsedMs ?? run.timeoutMs)} of the ${limit} a test run may take, and had not finished.`;
609
+ }
610
+ const took = run.elapsedMs !== undefined ? `after ${seconds(run.elapsedMs)} of the ${limit} a test run may take` : `well within the ${limit} a test run may take`;
611
+ return `This run ended on its own - exit ${run.exitCode}, ${took}. The time limit did not stop it and played no part in how it ended.`;
612
+ }
592
613
  /** A run the time limit stopped: failed, and what most often keeps a test run from ending. */
593
614
  function timedOutFailure(run, what) {
594
615
  const limit = Math.round(run.timeoutMs / 1000);
@@ -609,19 +630,34 @@ function timedOutFailure(run, what) {
609
630
  `the same ${limit} seconds, and a skipped or deleted test does not count as a fix.`,
610
631
  ].join("\n");
611
632
  }
633
+ /** A command `timeout` could not start, or a shell could not find - on a line of its own. */
634
+ const COULD_NOT_RUN = /^(?:[^:]*: )?failed to run command [‘'`"]?([\w.+-]+)[’'`"]?: No such file or directory$/;
635
+ const NOT_FOUND = /^(?:[^:]*: )?(?:line \d+: )?([\w.+-]+): command not found$/;
612
636
  /**
613
637
  * What a failed run says is not installed where it ran - the command, when its output names it - or undefined when
614
- * the run failed for another reason. Exit 69 is the testing scripts' own way to say a toolchain is missing; exit 127,
615
- * or a shell or `timeout` that could not find the command, says it as well.
638
+ * the run failed for another reason. A missing command is the cause only on evidence that it ended the run: exit 69,
639
+ * the testing scripts' own way to say a toolchain is missing, or 127, what a shell or `timeout` gives for a command it
640
+ * could not find - else a command not found on the last line the run printed, nothing having run after it. Earlier in
641
+ * the output it is a warning, not the failure: a shell profile's, an optional tool probed for, a fallback taken - and a
642
+ * run that failed for its own reasons is the agent's to fix, not a stop for the person.
616
643
  */
617
644
  export function missingToolchain(run) {
618
- const named = /failed to run command [‘'`"]?([\w.+-]+)[’'`"]?: No such file or directory/.exec(run.output) ??
619
- /(?:^|\n)(?:[^\n:]*: )?(?:line \d+: )?([\w.+-]+): command not found/.exec(run.output);
620
- if (named !== null)
621
- return { command: named[1] };
622
- if (run.exitCode === 69 || run.exitCode === 127)
645
+ if (run.exitCode === 0)
646
+ return undefined;
647
+ const lines = run.output.split("\n").map((line) => line.trim()).filter((line) => line !== "");
648
+ const named = (line) => COULD_NOT_RUN.exec(line)?.[1] ?? NOT_FOUND.exec(line)?.[1];
649
+ if (run.exitCode === 69 || run.exitCode === 127) {
650
+ // The command is the last one named: the one the run stopped on.
651
+ for (let at = lines.length - 1; at >= 0; at -= 1) {
652
+ const command = named(lines[at]);
653
+ if (command !== undefined)
654
+ return { command };
655
+ }
623
656
  return {};
624
- return undefined;
657
+ }
658
+ const last = lines.at(-1);
659
+ const command = last !== undefined ? named(last) : undefined;
660
+ return command !== undefined ? { command } : undefined;
625
661
  }
626
662
  /** Where `command` is on this machine's PATH, or undefined when it is not there. */
627
663
  export function onThisMachine(command) {
@@ -63,6 +63,17 @@ export function unitReviewTask(options) {
63
63
  options.spec.trim(),
64
64
  "</specification>",
65
65
  "",
66
+ ...(options.testingScript !== undefined
67
+ ? [
68
+ "The harness runs the unit tests with this script, and it decides whether they pass. Read it for which tests it",
69
+ "runs and how: a test it never reaches - a file it does not pick up, a folder it does not look in - is not run, and",
70
+ "checks nothing.",
71
+ `<unit testing script path="${options.testingScript.path}">`,
72
+ options.testingScript.content.trimEnd(),
73
+ "</unit testing script>",
74
+ "",
75
+ ]
76
+ : []),
66
77
  ...(options.cases !== undefined ? [...codeReviewCasesBlock(options.cases), ""] : []),
67
78
  // A job that touches no functional spec is held only to that: the checks of behaviour are not its.
68
79
  ...(mechanical ? [] : ["Check that the code does what the specification states for this work:"]),
@@ -19,7 +19,7 @@ its conformance tests too when they are on.
19
19
  --start-over start over, without asking, a codebase regenerated without a module it now requires -
20
20
  with no terminal to ask and without it, the run stops there
21
21
  --from-scratch delete the module's code and conformance tests (its lineage keeps them) and regenerate all of it
22
- --harness-model <p/id> config.turri.yaml's harness-model for this run: the planner, the conformance chooser, a diagnosis
22
+ --harness-model <p/id> config.turri.yaml's harness-model for this run: the planner and the conformance chooser
23
23
  --coding-model <p/id> its coding-model, --model too: the agents that build; p/id:level for how hard a model thinks
24
24
  --judge-model <p/id> its judge-model: the judge and the test review
25
25
  --review <true|false> its review: whether the code and its tests are reviewed once they pass
@@ -0,0 +1,4 @@
1
+ /** pi's line on the way out that says how to resume the session, with turri in place of pi as the command to run. */
2
+ export function resumeLine(text) {
3
+ return text.replace(/^((?:\x1b\[[0-9;]*m)*To resume this session:(?:\x1b\[[0-9;]*m)*\s+)pi(?= )/m, "$1turri");
4
+ }
@@ -1,8 +1,8 @@
1
- import { readdirSync, readFileSync } from "node:fs";
2
- import { basename, dirname, join, relative, resolve } from "node:path";
1
+ import { basename, relative, resolve } from "node:path";
3
2
  import { defineTool } from "@earendil-works/pi-coding-agent";
4
3
  import { Type } from "typebox";
5
- import { IMPORT_DIRECTIVE, PLAIN_SOURCE_FILE_EXTENSION, plainFileParser, readPlainSourceMetadata } from "./plain/parser.js";
4
+ import { plainFileParser } from "./plain/parser.js";
5
+ import { importingModules, isImportModule } from "./regenerate/requires.js";
6
6
  import { resolveTemplateDirs } from "./regenerate/paths.js";
7
7
  import { applySpecDiff, plainFilesOf, revertSpecDiff } from "./regenerate/regenerate.js";
8
8
  import { MissingFunctionalitiesError } from "./plain/errors.js";
@@ -62,24 +62,12 @@ export function createSpecDiffTools(options) {
62
62
  // file that cannot be parsed. A module with no functional specs yet is not broken. An import
63
63
  // module - definitions only, say - is not a module of its own: it is parsed as the modules
64
64
  // that import it read it, the one the change is built for among them.
65
- const importers = (file) => {
66
- const name = basename(file, ".plain");
67
- const dir = dirname(resolve(cwd, file));
68
- return readdirSync(dir)
69
- .filter((entry) => entry.endsWith(".plain"))
70
- .map((entry) => join(dir, entry))
71
- .filter((path) => {
72
- try {
73
- return (readPlainSourceMetadata(readFileSync(path, "utf8")).metadata[IMPORT_DIRECTIVE] ?? []).includes(name);
74
- }
75
- catch {
76
- return false;
77
- }
78
- });
79
- };
80
- const imported = importedNames(resolveTemplateDirs(resolve(cwd, params.plain_file)));
81
65
  const toParse = [
82
- ...new Set([params.plain_file, ...touched].flatMap((file) => imported.has(basename(file, ".plain")) ? importers(file).filter((path) => !imported.has(basename(path, ".plain"))) : [resolve(cwd, file)])),
66
+ ...new Set([params.plain_file, ...touched].flatMap((file) => {
67
+ const path = resolve(cwd, file);
68
+ const importing = isImportModule(path) ? importingModules(path) : [];
69
+ return importing.length > 0 ? importing : [path];
70
+ })),
83
71
  ];
84
72
  for (const path of toParse) {
85
73
  const file = relative(cwd, path);
@@ -129,27 +117,3 @@ export function createSpecDiffTools(options) {
129
117
  },
130
118
  };
131
119
  }
132
- /** The module names some .plain file in these folders imports: import modules, not codebases. */
133
- export function importedNames(dirs) {
134
- const names = new Set();
135
- for (const dir of dirs) {
136
- let entries;
137
- try {
138
- entries = readdirSync(dir).filter((name) => name.endsWith(PLAIN_SOURCE_FILE_EXTENSION));
139
- }
140
- catch {
141
- continue;
142
- }
143
- for (const entry of entries) {
144
- try {
145
- const imports = readPlainSourceMetadata(readFileSync(join(dir, entry), "utf8")).metadata[IMPORT_DIRECTIVE];
146
- for (const name of imports ?? [])
147
- names.add(name);
148
- }
149
- catch {
150
- // A file that does not read imports nothing.
151
- }
152
- }
153
- }
154
- return names;
155
- }
@@ -196,18 +196,21 @@ the reading that fits the rest of the spec, and marks each such decision in its
196
196
  code, environment and turri problems to the builds, and stops when a functionality keeps
197
197
  struggling after the spec was clarified, when two cycles change nothing, or after twenty.
198
198
 
199
- For an existing project, `bud` works the same way, scoped to one feature: intent → scope →
200
- product → review. After a short feature-intent interview it asks product questions one at a time -
201
- a trigger and its outcome, an edge case, a rule - and every answer is one spec change, a git diff
202
- written with `write_spec_diff` and built the moment it is written. A change to something already
199
+ For an existing project, `bud` works the same way, scoped to one feature: intent → scope → product.
200
+ It first asks how many questions the product phase may ask - light, medium, thorough or best
201
+ judgement, as `brood` does - then a short feature-intent interview, then product questions - a
202
+ trigger and its outcome, an edge case, a rule - and every answer is a spec change, a git diff
203
+ written with `write_spec_diff` and built the moment it is written, before the next question. What
204
+ the questions leave open it decides itself, a spec change each. A change to something already
203
205
  specified, built or still to build, is put to the user first and is a spec diff too: what is left to
204
- build is worked out again from the spec.
206
+ build is worked out again from the spec. It ends on the person's confirmation of a short summary of
207
+ the feature's changes.
205
208
 
206
209
  What keeps the interview honest is the harness, not the interviewer:
207
210
 
208
211
  - **Every question offers choices** (`ask_user` refuses a question without them), and each
209
212
  answer maps to one spec change.
210
- - **Every answer is written before the next question.** In `brood`'s product phase `ask_user` refuses
213
+ - **Every answer is written before the next question.** In the product phase of `brood` and `bud`, `ask_user` refuses
211
214
  a new question until the last answer is a spec change - see [skills and gates](skills-and-gates.md).
212
215
  - **Each phase ends on the person's confirmation** of a short summary, not on the interviewer's word.
213
216
 
package/docs/config.md CHANGED
@@ -122,7 +122,7 @@ models: # each agent role's model, thinking and tur
122
122
  | key | what it sets | left out |
123
123
  | --- | --- | --- |
124
124
  | `module` | the `.plain` file `turri regenerate` and the chat's `regenerate` build when none is named, from the project root | a file has to be named |
125
- | `harness-model` | the model `turri` starts on - the one you talk to - the one that diagnoses a job that failed for good, and, in the conversation, the planner that cuts the work into jobs (on whatever model the chat is on when it plans); under `turri regenerate`, the planner too | pi's configured model |
125
+ | `harness-model` | the model `turri` starts on - the one you talk to - and, in the conversation, the planner that cuts the work into jobs (on whatever model the chat is on when it plans); under `turri regenerate`, the planner too | pi's configured model |
126
126
  | `coding-model` | every render: functionalities, spec diffs, conformance tests, repairs, planning spec diffs, the explorer | `harness-model` |
127
127
  | `judge-model` | the judge and the test review of a conformance run | `coding-model` |
128
128
  | `conformance-tests` | `all` (or `true`): conformance tests for every functional spec of every module with test reqs, written once each module's code is built, before anything is built on it. `chosen`: for the functional specs chosen - every one with acceptance tests, and those the chooser picks as each code pulse ends, from what that pulse regenerated. `module`: the same, but the chooser is asked once, when the whole module is regenerated, and plans the conformance pulses too. Under both, the choice is made inside the pulse, before anything is built on the module, and the pulse's report says what was chosen and why; those the person asks for with `conform` are written too; once chosen, a functional spec keeps them, and they are rewritten when it changes - see [who chooses, and when](regenerating.md#conformance-tests-in-the-work-loop). `false`: none written, and none of the existing ones run - until the conversation asks with `conform` | `false` |
@@ -158,7 +158,8 @@ wrong type, as if it were not there. `model:`, from before there were separate m
158
158
  | --- | --- |
159
159
  | `default` | every role not named below - but the conversation's side |
160
160
  | `chat` | `turri`'s model - the same as `harness-model`, which it wins over |
161
- | `chooser`, `planner`, `diagnosis` | the conversation's side: the conformance chooser of `turri regenerate`, the planner's agents, the diagnosis of a failed job. Unnamed, the chat's model |
161
+ | `chooser`, `planner` | the conversation's side: the conformance chooser of `turri regenerate`, the planner's agents. Unnamed, the chat's model |
162
+ | `diagnosis` | the diagnosis of a job that failed for good: why it did not land, and what to do. Unnamed, the coding model the job ran on, thinking medium |
162
163
  | `release` | `turri release`'s agent and release-after-pulse's: it follows steps - a script, a start command - so it runs on the coding model, thinking low |
163
164
  | `coding` | the coding agent, the code fixer of a conformance run and the repair agent - the same as `coding-model`, which it wins over. `--model` on the command line, or a model chosen in the conversation (`engine`), wins over both |
164
165
  | `conformance` | the conformance agent |
@@ -75,6 +75,7 @@ trust `turri-oss/turri`, the workflow `publish.yml` and the environment `npm`. R
75
75
  | `src/regenerate/confine.ts`, `src/regenerate/agent-shell.ts`, `src/regenerate/command-check.ts`, `src/regenerate/os-sandbox.ts`, `src/regenerate/audit.ts`, `src/regenerate/agent-env.ts`, `src/regenerate/shell.ts` | the file-tool fence and the walls around every agent command: the check, the OS sandbox, the audit, the module's environment, the host runner - see [sandbox](sandbox.md) |
76
76
  | `src/regenerate/engine.ts` | choosing and resolving render models |
77
77
  | `src/regenerate/job-panel.ts`, `src/regenerate/transcript-view.ts`, `src/regenerate/diff-view.ts` | the job panel, the side panel's colours, and a spec diff as they show it - highlighted and banded |
78
+ | `src/regenerate/side-panel.ts`, `src/regenerate/panel-dock.ts` | the side panel, and the chat narrowed beside it when it is docked |
78
79
  | `src/regenerate/spec-map.ts`, `src/regenerate/spec-map-view.ts` | regen: each item's mark, from the records, the `.plain` files and the work loop's plan (`mapPlan`), and the map drawn |
79
80
  | `src/regenerate/debug-log.ts` | each render agent's whole conversation, always streamed to `.turri/debug/` |
80
81
  | `genome/` | what turri knows and can do: `genome/skills/`, the skill library, and `genome/rules/`, the \*\*\*plain authoring rules |
package/docs/headless.md CHANGED
@@ -81,7 +81,7 @@ Useful options - `turri regenerate --help` lists all of them:
81
81
 
82
82
  | | |
83
83
  | --- | --- |
84
- | `--harness-model <provider/id>` | `harness-model`: the planner, the conformance chooser, the diagnosis of a failed pulse |
84
+ | `--harness-model <provider/id>` | `harness-model`: the planner and the conformance chooser |
85
85
  | `--coding-model <provider/id>` | `coding-model` (`--model` too): the agents that build - with `:level` for how hard it thinks (`provider/id:high`); not given, the harness model's |
86
86
  | `--judge-model <provider/id>` | `judge-model`: the judge and the test review; not given, the coding model |
87
87
  | `--conformance-tests <all\|chosen\|module\|false>` | `conformance-tests`, with its values (`true` is `all`) |
@@ -151,7 +151,7 @@ changes meaning or goes; new fields may appear in the same version. Paths in `pu
151
151
  "conformance_tests": "all", // all | chosen | module | false
152
152
  "review": false,
153
153
  "models": {
154
- "harness": { "model": "…", "thinking": "medium" }, // the planner, the chooser, the diagnosis
154
+ "harness": { "model": "…", "thinking": "medium" }, // the planner, the chooser
155
155
  "coding": { "model": "…", "thinking": "low" },
156
156
  "judge": { "model": "…", "thinking": "medium" },
157
157
  "observed": { "coding": ["provider/id:low"], "planner": ["provider/id:medium"] } // what each role really ran on
@@ -112,6 +112,10 @@ the planner's, the spec-steps agent's, the conformance agents' - is laid out in
112
112
  A module that `requires` another inherits its functional specs; one that `import`s another
113
113
  inherits its definitions, implementation reqs and test reqs.
114
114
 
115
+ An import module - one a `.plain` file imports, or one kept in a `template/` folder - is no codebase of its own. A
116
+ change to it is built in the modules that import it, through any import modules between, whose code is started; when
117
+ none is, nothing is built, and the change goes in with the first of them built.
118
+
115
119
  Template search order: the plain file's own directory, then a sibling `template/`, then
116
120
  `--template-dir`, then `PLAIN_TEMPLATE_DIRS`.
117
121
 
@@ -160,6 +164,10 @@ runs the unit testing script itself**, and only that run counts (see
160
164
  tried. An agent circles a cause it has not thought of - an in-memory database every connection opens
161
165
  empty, a test runner that leaves the code off its path - and this is the way out. The rounds go on as
162
166
  before, up to 20; should the same failure come round three times again, the debugger looks again.
167
+ **A run the time limit stopped** is looked at by the debugger at once, told how long the run had and that the limit
168
+ stopped it: it finds what hangs - the root cause and the fix, as above - or that nothing does, the run getting on up
169
+ to the limit and needing more time than a test run may take. Then the pulse stops, rolled back and not retried, and
170
+ the person is told to raise `TURRI_COMMAND_TIMEOUT` or make the suite faster.
163
171
  - **It goes round in circles in its own runs.** An agent stuck on a failure can try the same few changes in
164
172
  turn - three signatures of a stand-in function, say - and run the tests after each, dozens of times in one
165
173
  turn. Its own `run_unit_tests` runs are watched (`createLoopWatch` in `test-scripts.ts`): the code folder back
@@ -218,7 +226,7 @@ and the `implement-unit-testing-script` and `implement-conformance-testing-scrip
218
226
  - **The formatting is the agents'.** The harness formats nothing: the scripts check, and leave their inputs as they
219
227
  found them. Every agent that writes code or tests is told to run, in its shell, the formatter its script checks with,
220
228
  on the files it changes, before the final run.
221
- - **A toolchain missing** where the checks run - exit 69, 127, `command not found` - stops the pulse as it does for the
229
+ - **A toolchain missing** where the checks run - exit 69, 127, a `command not found` the run ended on - stops the pulse as it does for the
222
230
  tests: the person installs it, the agents install nothing.
223
231
 
224
232
  ### Checking its own work
@@ -262,7 +270,8 @@ Passing unit tests prove only what they check, and a coding agent is quick to wr
262
270
  next to nothing - that a function exists, that a result is not empty, that a status is 200 - or code
263
271
  that no test reaches. So, with `review: true` in the [config](config.md), once the unit testing script
264
272
  passes a reviewer on the judge model reads what the work wrote, beside the spec, and changes nothing. It
265
- reviews both halves. The review is off by default - `review: false`, or the key left out - and so is the
273
+ reviews both halves, with the unit testing script word for word in its prompt: a test the script never reaches is
274
+ not run, and checks nothing. The review is off by default - `review: false`, or the key left out - and so is the
266
275
  conformance tests' review: the work goes on once its tests pass.
267
276
 
268
277
  - **The code.** Every behaviour, edge case, validation rule and error the spec states for this work
@@ -499,16 +508,19 @@ testing script, stops before it starts and says which skill adds it.
499
508
  `prepare-environment-script:` in the config, else the one `prepare_environment*.sh` at the root, else in
500
509
  `test_scripts/` - on the build, before every run of the conformance testing script: the harness's own, and the agents'
501
510
  `run_conformance_tests`. Both get the same build folder - the code in place, or the same fresh copy - so what it sets up
502
- for that build, the conformance testing script finds. With conformance off it is not run. The conformance agents are
503
- shown it, before the conformance testing script.
511
+ for that build, the conformance testing script finds. With conformance off it is not run. Every agent shown the
512
+ conformance testing script - the explorer, the conformance agent, the judge, the code fixer and the repair agent - is
513
+ shown it too, before the conformance testing script.
504
514
 
505
515
  **Where they run.** On this machine, as you would run them: unfenced - no sandbox, no command check, no audit - in
506
516
  your own environment with this machine's toolchains, turri's model providers' API keys alone left out. They are yours,
507
517
  and whatever they do is your doing. That is the only way the two scripts are ever run: the harness's own runs, and the
508
518
  agents' `run_unit_tests` and `run_conformance_tests`, which run them exactly as the harness does - through the host
509
519
  runner, in a process group of their own, so the time limit and a stopped job end the script and all it started. A
510
- toolchain the script needs and this machine lacks - exit 69, exit 127, or a `command not found` / `failed to run
511
- command` in its output (`missingToolchain`) - is yours to install, never the agent's: the agent is told to report it
520
+ toolchain the script needs and this machine lacks - exit 69, exit 127, or a run that ended on a `command not found` /
521
+ `failed to run command`, the last line it printed (`missingToolchain`) - is yours to install. Only on that evidence: a
522
+ `command not found` earlier in the output, the run going on after it and failing for its own reasons, is a warning -
523
+ a shell profile's, an optional tool probed for - and the failure is the agent's to fix. A missing toolchain is yours to install, never the agent's: the agent is told to report it
512
524
  with `report_environment_error` rather than work around it, and the pulse stops at the harness's first run of either
513
525
  script - unit or conformance - that cannot find it, rolled back, saying what to install (see
514
526
  [when the environment lacks something](#when-the-environment-lacks-something)). The code and the tests an agent wrote run unfenced inside the script too: what an agent runs with its own
@@ -562,7 +574,7 @@ It is raised two ways:
562
574
  is shown its output once, and a report made again after that stands. A report that stands ends its turn, the pulse
563
575
  stops, and what it said goes to you as it is;
564
576
  - **by the harness itself**: a testing script - the unit or the conformance one, in a code pulse, a conformance pulse or
565
- the whole-suite run - that cannot find its toolchain (exit 69 or 127, `command not found`), or
577
+ the whole-suite run - that cannot find its toolchain (exit 69 or 127, a `command not found` the run ended on), or
566
578
  a credential `agent-env:` names that is not there when the pulse starts - before any agent does. What the harness
567
579
  found it works out at once - the diagnosis, not after a second failure - to say how to fix it on this machine.
568
580
 
@@ -575,10 +587,20 @@ not an install:
575
587
  > **lunch stopped: turri's sandbox kept its agents from reading `…/mise/installs/node/24.16.0/lib/node_modules/npm/bin/npm-cli.js` - it is on this machine; nothing is missing.**
576
588
  > To fix: let the agents read that toolchain - add its folder to `toolchains:` in config.turri.yaml, keeping what is there: `toolchains: [/Users/…/mise/installs/node/24.16.0]`. Nothing needs installing.
577
589
 
590
+ A write the sandbox refused is told apart from a read - a report naming a lock file (`*.lock`, `*.lck`, `lockfile`, even
591
+ one never made), or saying a write, a create or a lock not taken. No setting lets the agents write outside their
592
+ module's folders, their own home and temporary folder and the package caches, and `toolchains:` only lets them read; so
593
+ the stop names the lock and what fixes it instead. In your home - a tool that found it without `$HOME`, as a JVM does for
594
+ `user.home` - it is having the tool use `$HOME` (`-Duser.home=$HOME` where the build starts its JVM); in a toolchain's own
595
+ install, it is a setting of the tool's that keeps the write elsewhere, or a copy of the toolchain that keeps its writes in
596
+ its cache. The agents are told such a refusal is the sandbox's, to report at once - not to work around it for half an
597
+ hour.
598
+
578
599
  **The conversation heals it.** Told of the stop, it never regenerates the module again before the cause is fixed - a pulse
579
600
  stopped on its environment stops the same way again - and fixes what it can:
580
601
 
581
- - **hidden by the sandbox**: it adds the folder to `toolchains:` itself, says so in a line, and resumes;
602
+ - **hidden by the sandbox**: it adds the folder to `toolchains:` itself, says so in a line, and resumes - a refused
603
+ write, which no setting fixes, it fixes in the project's own files when it can, and otherwise tells you what to do;
582
604
  - **a toolchain or a tool missing** - a JDK, Maven, Go, uv: it looks first for one installed off the PATH - Homebrew's opt
583
605
  folders, `/Library/Java/JavaVirtualMachines`, mise, asdf, sdkman, nvm - then asks you, with the exact command for this
584
606
  machine (`brew install openjdk@21`, `mise use -g java@21`), and on your yes runs it in its shell, checks the command is
@@ -820,7 +842,8 @@ coding agent that fixes the code is told the same of the tests: it can read them
820
842
  Before the test author starts, an explorer - an agent in
821
843
  the code's folder with the file tools alone: it reads the code, runs nothing and changes nothing - hands over everything
822
844
  the author needs, in parts: how to build and run it; how the conformance tests reach it as the project's
823
- conformance testing script runs them - the explorer is given the script, and says what it builds or
845
+ conformance testing script runs them - the explorer is given the script, and the prepare script before it where there
846
+ is one, and says what they build or
824
847
  installs and what the tests depend on or start (a package, a module, an entry point, by its exact name);
825
848
  how each functionality is reached from outside
826
849
  (the command, or the route, method and the request and response fields); what it needs around it; and
@@ -894,10 +917,17 @@ agent is told that a failure of the software itself - it does not build or start
894
917
  spec says it must not - is not the tests' to work around. When it fails, a judge - an agent that reads
895
918
  the code and the tests, changes neither, and holds both to the spec - decides which is wrong. It has the
896
919
  file tools and the web (`web_search`, `web_fetch`), to look up what a service the code calls answers - no shell: it
897
- judges from the code, the tests, the spec and the failing run's output, and its file tools write nothing:
920
+ judges from the code, the tests, the spec, the conformance testing script word for word and the failing run's output,
921
+ and its file tools write nothing. The explorer's account of how the code is invoked is in its prompt too, marked as
922
+ written before the run and possibly wrong: the judge checks what it uses of it against the script and the files, and
923
+ gives in `evidence` what it found itself. The script is fixed - neither agent can change it - so it is never the
924
+ culprit: what it does with the tests, the tests fit; what it needs of the build, the code provides.
898
925
 
899
926
  - **the code:** the coding agent - in the code's folder, reading the tests but never changing them - fixes it,
900
- and keeps its unit tests passing;
927
+ and keeps its unit tests passing. The judge quotes the spec's own words the code does not meet, or the testing
928
+ script's for what it needs of the build (`script_needs`: a build output, an entry point, a module) - each checked
929
+ by the harness against the text it quotes. The acceptance tests are in that text, labelled as their tests are:
930
+ for a spec change, those of every functional spec it touches, not only the last one's;
901
931
  - **the tests:** the conformance agent corrects them to what the spec says;
902
932
  - **the spec:** two functional specs cannot both hold, whatever the code does;
903
933
  - **the environment:** neither the code nor the tests can fix it - only the person can, in what the run is given:
@@ -939,16 +969,41 @@ spending the rest of its 20 attempts on it. Two failures are the same once what
939
969
  taken out of their lines - numbers, times, paths, colour codes, and the ids a service makes up for each
940
970
  response, a UUID or a correlation id. Nothing changes either when the agent sent to fix the code or the tests
941
971
  changes no file: two such fixes in a row, and the run stops. The conformance agent has the testing script in its prompt,
942
- and is told to fit the tests' own build to it.
972
+ and is told to fit the tests' own build to it. The code fixer has the testing scripts its fixes are run by - the
973
+ conformance testing script, the prepare script before it, and the unit testing script - word for word in its task:
974
+ what the conformance testing script needs of the build, it reads there, not only in the judge's quote of it.
975
+
976
+ **Escalation.** A failure judged the tests' goes to the conformance agent first: it owns the tests. When the run then
977
+ fails the same way - the fix changed nothing, or nothing that mattered - the judge is asked again, now whether the
978
+ failure belongs to the code rather than the tests: the run failing on something the code is meant to produce (a build
979
+ output, an entry point, a module the testing script needs), or the tests running and the behaviour itself being
980
+ wrong. Its verdict, either way, has to rest on evidence it gathered: each piece from a file it opened (the harness
981
+ keeps track of what it read, listed and searched), the testing script or the failing run - and not the run alone.
982
+ A verdict without it is sent back; a verdict of code still without it is taken as the tests'. Judged the tests'
983
+ again, the failure stays with the conformance agent, and a fix that changes nothing counts towards stopping as
984
+ before. Judged the code's, it is escalated to the coding agent, handed the script's error, the conformance tests as
985
+ they stand and the judge's reason and evidence (`the script runs dist/cli.js; the build emits dist/src/cli.js`). Its
986
+ fix has to build and pass the unit tests, then the suite runs again. Should the run still fail the same way - or the
987
+ fix change nothing - the run stops there, with the judge's reasoning and evidence in what the person is told. Each of
988
+ these runs is one of the run's 20 attempts, so a failure neither agent can fix stops in three of them.
943
989
 
944
990
  Every attempt is written into the working notes' pitfalls by the harness as cause and effect - what
945
991
  the run failed with, how it was judged, and which files the agent sent to fix it changed; the next
946
992
  attempt's line says what came of it - and each judge reads them first, so it does not send a
947
993
  failure the way that already failed. A run that does not pass is undone whole, its notes with it.
948
994
 
949
- Then the suite runs again. A run stopped by its time limit goes back to the conformance agent without a judge: the
950
- tests' environment is its. So does a run that exits 80 - the tests pass and only their static checks do not (see
951
- [the static checks](#the-static-checks)): the findings are the tests'. A run whose script cannot find its
995
+ Then the suite runs again. A run that exits 80 goes back to the conformance agent without a judge - the tests pass and
996
+ only their static checks do not (see [the static checks](#the-static-checks)): the findings are the tests'.
997
+
998
+ **Timing.** Every run is shown to the judge, the debugger and whoever fixes it with how long it ran against its time
999
+ limit (`runTiming` in `test-scripts.ts`): `This run ended on its own - exit 1, after 37.2s of the 120.0s a test run
1000
+ may take`, or `The time limit stopped this run: it had run 120.0s of the 120.0s ...` - so none takes a run that
1001
+ ended on its own for one the limit stopped, or the other way. A run the time limit stopped is judged like any other,
1002
+ and the judge is told what keeps a run from finishing: the code hangs (it waits on input, keeps a server in the
1003
+ foreground, never exits) - the code's; a test waits for what never comes - the tests'; or nothing hangs, the output
1004
+ showing the run getting on up to the limit, and it needs more time than a test run may take - the environment. That
1005
+ verdict stops the pulse at once, rolled back and not retried, and the person is told to raise `TURRI_COMMAND_TIMEOUT`
1006
+ or make the suite faster - no agent can give a run more time. A run whose script cannot find its
952
1007
  toolchain stops the pulse instead - see [when the environment lacks something](#when-the-environment-lacks-something).
953
1008
  Unit tests failing after the suite passes go to the coding agent. It goes round up to 20 times; still failing, the work is undone.
954
1009
 
@@ -1022,8 +1077,7 @@ both. Each set goes where its folder goes - copied up the chain, committed, roll
1022
1077
  | --- | --- |
1023
1078
  | Where things are | entry points, layout, where each functionality lives |
1024
1079
  | How to build, run and test | the commands that work, what had to be installed |
1025
- | Assumptions | what an agent assumed where the spec is silent - a format, a default, a choice it leaves open |
1026
- | Spec gaps | what the spec should say and does not - a behaviour the person would want to decide, as the question it leaves |
1080
+ | Assumptions | what an agent assumed where the spec is silent - a format, a default, a choice it leaves open - and the tests that assert it, when any do; one no test asserts is written down all the same |
1027
1081
  | Pitfalls | what went wrong and what fixed it - and what the debugger found, filed by turri itself |
1028
1082
  | Pulses | written by turri alone, as each pulse ends: the last ten, a line each |
1029
1083
 
@@ -1040,9 +1094,14 @@ it landed, a commit of its own (`pulse 3 rolled back: …`) when it did not - so
1040
1094
  commit, keeps it. `update_notes` refuses the section. What the debugger finds is filed in the pitfalls the moment it
1041
1095
  finds it, not left to the coding agent to write down.
1042
1096
 
1043
- The spec gaps a pulse's agents add are said in its report - "Spec gaps its agents met ... Put each to the user" - so
1044
- the conversation asks you, and writes the ones you decide into the spec; the gaps stay in the notes, for the agents
1045
- after, until then.
1097
+ A spec gap - what the spec should say and does not, a behaviour you would want to decide - is not a note: the notes
1098
+ are the next agent's, and a gap is yours. An agent reports one with `report_spec_gap`, giving the question it leaves
1099
+ and the assumption it made meanwhile; turri writes that assumption into the notes' assumptions, so the code built on
1100
+ it is known for what it is. The gaps a pulse's agents report are said in its report - "Spec gaps its agents met ... Put
1101
+ each to the user", each with its assumption - so the conversation asks you, and writes the ones you decide into the
1102
+ spec; the pulse that builds the answer finds the assumption it replaces in the notes, and the tests it names. However many gaps a pulse's agents report, they
1103
+ are put to you - never a reason to stop the pulse; the tool is guarded like any other. A notes
1104
+ file from before keeps no spec gaps section: its lines are dropped as it is read.
1046
1105
 
1047
1106
  Stubborn on the specs, flexible on the assumptions: the spec is never an assumption and never
1048
1107
  copied into the notes, and where the two disagree the spec wins. An agent builds on the assumptions
@@ -1065,8 +1124,8 @@ Leaving notes is required, and only through the `update_notes` tool. The file to
1065
1124
  notes file, and a change made to it any other way - from the shell, by a script - is undone. An agent
1066
1125
  that finishes without calling `update_notes` is asked again, up to three times; if it still has not,
1067
1126
  the activity log says so. The turn that asks is for the notes alone: the work is done - its testing script's run
1068
- passed, and the agent is told so first, so its notes speak of work that succeeded - so every tool but `update_notes` is
1069
- refused, and an agent that keeps calling them has its turn stopped. What
1127
+ passed, and the agent is told so first, so its notes speak of work that succeeded - so every tool but `update_notes` and
1128
+ `report_spec_gap` is refused, and an agent that keeps calling the refused ones has its turn stopped. What
1070
1129
  landed is what the harness checked; nothing changes after it. Only work that lands is asked: a job whose code or tests do not pass - or whose
1071
1130
  testing script cannot run - is rolled back, notes and all, so its agent is not asked to leave any.
1072
1131
 
@@ -52,7 +52,7 @@ last one - one answer, one change, as an interview writes them. `spawn` is unpac
52
52
  each change to write the next at once, not to carry on with an interview it does not have.
53
53
 
54
54
  `questioning:` under `metadata:` names the steps the questioning level caps (`src/questioning.ts`) - `brood`'s
55
- `[stack, product]`. When there are any and someone to ask, the harness itself asks the first question of the first
55
+ `[stack, product]`, `bud`'s `[product]`. When there are any and someone to ask, the harness itself asks the first question of the first
56
56
  step: how many questions those steps may ask - light (3), medium (5), thorough (10) or best judgement - and tells the
57
57
  agent the answer beside each step's instructions, with how broad each question is to be: broad at light, a whole area
58
58
  at once, narrow at thorough, an edge case at a time. Every level covers the same ground, in less or more depth. In a
@@ -63,7 +63,7 @@ questions each step has asked, are kept in the run's `run.json`, so a resumed ru
63
63
  or a run with nobody to ask, is not capped.
64
64
 
65
65
  `spec-diff-per-answer:` under `metadata:` names the steps where every answer is a spec change - `brood`'s
66
- `[product]`, at every questioning level. There `ask_user` refuses the next question until the last answer is written
66
+ and `bud`'s `[product]`, at every questioning level. There `ask_user` refuses the next question until the last answer is written
67
67
  with `write_spec_diff` (a confirmation, or a question dismissed, owes nothing), and `write_spec_diff` no longer waits
68
68
  for an answer before a change: the agent writes as many as the step needs, those it decides itself included. The
69
69
  level limits the questions, never the spec changes.
package/docs/using.md CHANGED
@@ -127,10 +127,13 @@ come waits for a free slot, and says so.
127
127
  as GitHub names a hunk's function: each section is named once.
128
128
  - **The side panel** (`ctrl+h`, as it was left - but on the pulse that last failed, stopped or did not pass, when one has
129
129
  since it was last opened: the live panel that showed it is gone with the last pulse, and its announcement in the chat
130
- says `ctrl+h shows this pulse`; **`/regen`** on regen, **`/pulses`** on the pulses; not `ctrl+j`, which a terminal without the Kitty
130
+ says `ctrl+h shows this pulse`; **`/pulses`** on the pulses; not `ctrl+j`, which a terminal without the Kitty
131
131
  keyboard protocol sends as a line feed, the same as `shift+enter`, and which a dialog takes for
132
132
  `enter`; both stay pi's new-line keys. `ctrl+h` is the byte old terminals sent for backspace; a
133
- terminal set to send `^H` for its Backspace key would open the panel on it) takes the whole screen - the panel or the chat, one at a time.
133
+ terminal set to send `^H` for its Backspace key would open the panel on it) takes the whole screen - the panel or the chat, one at a time -
134
+ or, `s`, sits beside the chat: the chat on the left, the panel in the right half of the screen, and `s` again
135
+ over the whole screen. It opens as it was last left, for the conversation; a terminal under 100 columns has
136
+ no room for both and shows the panel over the whole screen.
134
137
  It opens on **regen**: the spec itself, in full, with how much of it the code has been regenerated from drawn
135
138
  onto it.
136
139
 
@@ -214,7 +217,13 @@ come waits for a free slot, and says so.
214
217
  closes when it moves to another section. What is open is kept while the panel is closed. What the agents
215
218
  said and did is not shown - it is in each pulse's log (see [Agent logs](#agent-logs)).
216
219
 
217
- `ctrl+h` again, or `esc`, closes it and goes back to the chat. While it shows, every key is the panel's,
220
+ `ctrl+h` again, or `esc`, closes it and goes back to the chat. Beside the chat, a click decides which side has
221
+ the keys - the chat or the panel, the one clicked, or the one `⌥⌘←` / `⌥⌘→` points at (on a
222
+ terminal that passes ⌘ on, over the Kitty keyboard protocol - Ghostty, kitty, WezTerm, iTerm2; not Apple's Terminal);
223
+ the other is drawn faint - and `esc` gives the chat the keys too, the panel staying and
224
+ following the pulses; `ctrl+h` gives the panel the keys again, and from the panel closes it. (pi's regular screen,
225
+ `--tui-mode regular`, reads no mouse: there it is the keys alone.)
226
+ While the panel has the keys, every key is the panel's,
218
227
  whatever else happens: a question the chat model asks in the background (`ask_user`) waits in the chat,
219
228
  unanswered - an `enter` in the panel never answers it - and the panel's top line says "the chat is waiting
220
229
  for your answer". Back in the chat, the question is there, with the keys.