@turri-dev/cli 0.1.3-next.04c4f71 → 0.1.3-next.162a2c3

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.
@@ -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
- }
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 |
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
@@ -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,8 +508,9 @@ 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,
@@ -832,7 +842,8 @@ coding agent that fixes the code is told the same of the tests: it can read them
832
842
  Before the test author starts, an explorer - an agent in
833
843
  the code's folder with the file tools alone: it reads the code, runs nothing and changes nothing - hands over everything
834
844
  the author needs, in parts: how to build and run it; how the conformance tests reach it as the project's
835
- 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
836
847
  installs and what the tests depend on or start (a package, a module, an entry point, by its exact name);
837
848
  how each functionality is reached from outside
838
849
  (the command, or the route, method and the request and response fields); what it needs around it; and
@@ -906,10 +917,17 @@ agent is told that a failure of the software itself - it does not build or start
906
917
  spec says it must not - is not the tests' to work around. When it fails, a judge - an agent that reads
907
918
  the code and the tests, changes neither, and holds both to the spec - decides which is wrong. It has the
908
919
  file tools and the web (`web_search`, `web_fetch`), to look up what a service the code calls answers - no shell: it
909
- 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.
910
925
 
911
926
  - **the code:** the coding agent - in the code's folder, reading the tests but never changing them - fixes it,
912
- 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;
913
931
  - **the tests:** the conformance agent corrects them to what the spec says;
914
932
  - **the spec:** two functional specs cannot both hold, whatever the code does;
915
933
  - **the environment:** neither the code nor the tests can fix it - only the person can, in what the run is given:
@@ -951,16 +969,41 @@ spending the rest of its 20 attempts on it. Two failures are the same once what
951
969
  taken out of their lines - numbers, times, paths, colour codes, and the ids a service makes up for each
952
970
  response, a UUID or a correlation id. Nothing changes either when the agent sent to fix the code or the tests
953
971
  changes no file: two such fixes in a row, and the run stops. The conformance agent has the testing script in its prompt,
954
- 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.
955
989
 
956
990
  Every attempt is written into the working notes' pitfalls by the harness as cause and effect - what
957
991
  the run failed with, how it was judged, and which files the agent sent to fix it changed; the next
958
992
  attempt's line says what came of it - and each judge reads them first, so it does not send a
959
993
  failure the way that already failed. A run that does not pass is undone whole, its notes with it.
960
994
 
961
- Then the suite runs again. A run stopped by its time limit goes back to the conformance agent without a judge: the
962
- tests' environment is its. So does a run that exits 80 - the tests pass and only their static checks do not (see
963
- [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
964
1007
  toolchain stops the pulse instead - see [when the environment lacks something](#when-the-environment-lacks-something).
965
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.
966
1009
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@turri-dev/cli",
3
- "version": "0.1.3-next.04c4f71",
3
+ "version": "0.1.3-next.162a2c3",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "repository": {
@@ -33,8 +33,8 @@
33
33
  "grammar:sync": "node scripts/sync-plyn-grammar.mjs"
34
34
  },
35
35
  "dependencies": {
36
- "@earendil-works/pi-coding-agent": "^1.1.0",
37
- "@earendil-works/pi-tui": "^1.1.0",
36
+ "@earendil-works/pi-coding-agent": "^1.2.0",
37
+ "@earendil-works/pi-tui": "^1.2.0",
38
38
  "@langchain/langgraph": "1.4.15",
39
39
  "gray-matter": "^4.0.3",
40
40
  "js-yaml": "^5.4.2",