@turri-dev/cli 0.2.3 → 0.2.4-next.009bd0c

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 (175) hide show
  1. package/README.md +7 -8
  2. package/dist/bedrock-region.js +3 -3
  3. package/dist/chat-idle.d.ts +2 -2
  4. package/dist/chat-idle.js +2 -2
  5. package/dist/chat-models.d.ts +1 -1
  6. package/dist/chat-models.js +1 -1
  7. package/dist/chat-scope.d.ts +1 -3
  8. package/dist/chat-skills.d.ts +1 -1
  9. package/dist/chat-skills.js +1 -1
  10. package/dist/chats.d.ts +44 -20
  11. package/dist/chats.js +125 -64
  12. package/dist/cli.js +12 -31
  13. package/dist/config-edit.d.ts +20 -8
  14. package/dist/config-edit.js +32 -26
  15. package/dist/config.d.ts +106 -78
  16. package/dist/config.js +267 -133
  17. package/dist/conform-cli.js +14 -3
  18. package/dist/conformance-switch.d.ts +13 -22
  19. package/dist/conformance-switch.js +37 -59
  20. package/dist/drift-cli.js +1 -1
  21. package/dist/extension.d.ts +17 -10
  22. package/dist/extension.js +425 -531
  23. package/dist/genome.js +10 -49
  24. package/dist/graph.js +3 -5
  25. package/dist/host-session.d.ts +11 -21
  26. package/dist/host-session.js +6 -8
  27. package/dist/host.d.ts +4 -4
  28. package/dist/host.js +4 -7
  29. package/dist/identity.js +2 -3
  30. package/dist/init-config.d.ts +1 -2
  31. package/dist/init-config.js +10 -17
  32. package/dist/installed-providers.d.ts +1 -1
  33. package/dist/installed-providers.js +1 -1
  34. package/dist/launch-agent.d.ts +41 -0
  35. package/dist/launch-agent.js +219 -0
  36. package/dist/{release-cli.js → launch-cli.js} +41 -24
  37. package/dist/launch-session.d.ts +58 -0
  38. package/dist/launch-session.js +195 -0
  39. package/dist/launch-tools.d.ts +28 -0
  40. package/dist/launch-tools.js +69 -0
  41. package/dist/launch-track.d.ts +120 -0
  42. package/dist/launch-track.js +298 -0
  43. package/dist/loop-cli.d.ts +4 -3
  44. package/dist/loop-cli.js +17 -15
  45. package/dist/loop-tools.d.ts +45 -21
  46. package/dist/loop-tools.js +155 -90
  47. package/dist/new-project.js +2 -2
  48. package/dist/notice.d.ts +7 -6
  49. package/dist/parse-cli.js +2 -2
  50. package/dist/pi-launch.js +4 -1
  51. package/dist/pi-settings.d.ts +4 -0
  52. package/dist/pi-settings.js +39 -0
  53. package/dist/pi.js +12 -9
  54. package/dist/plain/check.d.ts +2 -9
  55. package/dist/plain/check.js +6 -39
  56. package/dist/plain-files.d.ts +2 -2
  57. package/dist/plain-files.js +7 -7
  58. package/dist/regenerate/activity.d.ts +0 -7
  59. package/dist/regenerate/activity.js +2 -20
  60. package/dist/regenerate/agent-env.d.ts +1 -1
  61. package/dist/regenerate/agent-env.js +3 -3
  62. package/dist/regenerate/agent-shell.js +5 -3
  63. package/dist/regenerate/audit.js +9 -0
  64. package/dist/regenerate/base-folder.d.ts +2 -2
  65. package/dist/regenerate/base-folder.js +1 -1
  66. package/dist/regenerate/cases.js +7 -0
  67. package/dist/regenerate/chunk-plan.d.ts +5 -0
  68. package/dist/regenerate/chunk-plan.js +16 -1
  69. package/dist/regenerate/command-check.d.ts +1 -1
  70. package/dist/regenerate/command-check.js +1 -1
  71. package/dist/regenerate/delivery.d.ts +1 -1
  72. package/dist/regenerate/delivery.js +3 -3
  73. package/dist/regenerate/drift.d.ts +4 -0
  74. package/dist/regenerate/drift.js +26 -6
  75. package/dist/regenerate/failure-reports.d.ts +28 -0
  76. package/dist/regenerate/failure-reports.js +79 -0
  77. package/dist/regenerate/job-panel.js +3 -1
  78. package/dist/regenerate/jobs-tree.js +1 -1
  79. package/dist/regenerate/jobs.d.ts +4 -2
  80. package/dist/regenerate/jobs.js +14 -10
  81. package/dist/regenerate/launch.d.ts +126 -0
  82. package/dist/regenerate/{release.js → launch.js} +60 -48
  83. package/dist/regenerate/ledger-view.d.ts +11 -24
  84. package/dist/regenerate/ledger-view.js +14 -60
  85. package/dist/regenerate/ledger.d.ts +26 -16
  86. package/dist/regenerate/ledger.js +1 -1
  87. package/dist/regenerate/lineage.d.ts +2 -0
  88. package/dist/regenerate/lineage.js +8 -0
  89. package/dist/regenerate/loop.d.ts +54 -67
  90. package/dist/regenerate/loop.js +312 -148
  91. package/dist/regenerate/model-names.d.ts +33 -0
  92. package/dist/regenerate/{engine.js → model-names.js} +2 -28
  93. package/dist/regenerate/paths.d.ts +3 -3
  94. package/dist/regenerate/paths.js +4 -4
  95. package/dist/regenerate/records.d.ts +11 -0
  96. package/dist/regenerate/records.js +15 -0
  97. package/dist/regenerate/regenerate.d.ts +0 -2
  98. package/dist/regenerate/regenerate.js +4 -15
  99. package/dist/regenerate/renames.js +4 -4
  100. package/dist/regenerate/requires.d.ts +7 -0
  101. package/dist/regenerate/requires.js +24 -18
  102. package/dist/regenerate/scripts-being-written.d.ts +4 -4
  103. package/dist/regenerate/scripts-being-written.js +3 -3
  104. package/dist/regenerate/spec-map.js +3 -3
  105. package/dist/regenerate/standing.js +1 -1
  106. package/dist/regenerate/submit-work.d.ts +2 -0
  107. package/dist/regenerate/submit-work.js +8 -3
  108. package/dist/regenerate/test-scripts.d.ts +2 -1
  109. package/dist/regenerate/test-scripts.js +33 -23
  110. package/dist/regenerate/testing-steps.d.ts +16 -5
  111. package/dist/regenerate/testing-steps.js +28 -9
  112. package/dist/regenerate-cli.js +18 -9
  113. package/dist/self-invocation.d.ts +11 -0
  114. package/dist/self-invocation.js +36 -10
  115. package/dist/sentinel-check.d.ts +3 -3
  116. package/dist/sentinel-check.js +3 -3
  117. package/dist/sentinel.d.ts +17 -12
  118. package/dist/sentinel.js +75 -46
  119. package/dist/{config-command.d.ts → settings.d.ts} +13 -8
  120. package/dist/{config-command.js → settings.js} +155 -24
  121. package/dist/setup.d.ts +2 -2
  122. package/dist/setup.js +7 -7
  123. package/dist/skill.d.ts +0 -11
  124. package/dist/skill.js +0 -9
  125. package/dist/tools.js +2 -3
  126. package/dist/turri-versions.js +2 -1
  127. package/docs/README.md +4 -6
  128. package/docs/authoring-plain.md +3 -3
  129. package/docs/chats.md +6 -9
  130. package/docs/claude-subscription.md +2 -2
  131. package/docs/config.md +61 -51
  132. package/docs/development.md +4 -5
  133. package/docs/headless.md +7 -6
  134. package/docs/hosting.md +24 -23
  135. package/docs/launch.md +63 -0
  136. package/docs/parser.md +3 -3
  137. package/docs/regenerating.md +30 -22
  138. package/docs/sandbox.md +3 -3
  139. package/docs/sentinel.md +27 -16
  140. package/docs/skills-and-gates.md +6 -11
  141. package/docs/using.md +25 -42
  142. package/genome/rules/project-model.md +2 -1
  143. package/genome/rules/test-plain-files.md +15 -7
  144. package/genome/rules/turri-regeneration.md +7 -10
  145. package/genome/skills/convert-old-syntax/SKILL.md +5 -5
  146. package/genome/skills/implement-conformance-testing-script/SKILL.md +2 -2
  147. package/genome/skills/implement-unit-testing-script/SKILL.md +3 -3
  148. package/package.json +1 -1
  149. package/dist/advisor-chat.d.ts +0 -63
  150. package/dist/advisor-chat.js +0 -290
  151. package/dist/change-plain-cli.js +0 -55
  152. package/dist/ledger-cli.d.ts +0 -1
  153. package/dist/ledger-cli.js +0 -50
  154. package/dist/ledger-tools.d.ts +0 -10
  155. package/dist/ledger-tools.js +0 -64
  156. package/dist/regenerate/advisor-records.d.ts +0 -93
  157. package/dist/regenerate/advisor-records.js +0 -110
  158. package/dist/regenerate/advisor-runs.d.ts +0 -87
  159. package/dist/regenerate/advisor-runs.js +0 -327
  160. package/dist/regenerate/engine.d.ts +0 -52
  161. package/dist/regenerate/release.d.ts +0 -121
  162. package/dist/regenerate/test-advisor.d.ts +0 -101
  163. package/dist/regenerate/test-advisor.js +0 -379
  164. package/dist/release-agent.d.ts +0 -43
  165. package/dist/release-agent.js +0 -130
  166. package/dist/release-cli.d.ts +0 -1
  167. package/dist/release-tools.d.ts +0 -44
  168. package/dist/release-tools.js +0 -170
  169. package/dist/spec-tools.d.ts +0 -36
  170. package/dist/spec-tools.js +0 -128
  171. package/dist/stacks.d.ts +0 -13
  172. package/dist/stacks.js +0 -96
  173. package/docs/deploy.md +0 -48
  174. package/docs/test-advisor.md +0 -110
  175. /package/dist/{change-plain-cli.d.ts → launch-cli.d.ts} +0 -0
@@ -31,20 +31,16 @@ The other rules say what a spec means. This one says what turri does with a chan
31
31
  - Test reqs and scenarios - a functional spec's conformance and acceptance scenarios, in its test plain file - reach the conformance tests only, never the code. A scenario changed alone regenerates no code
32
32
  - A functional spec regenerated again by name has its code taken out and built anew - never left as it was, even where it already does what the spec says; a pulse that changes nothing does not land. Its conformance tests, when it has them, are run on its new code once it lands: those that pass are kept as they are; one that fails is judged against the spec - what it checks that the spec leaves open, a path, a field, a message the old code chose, goes by the new code
33
33
  - What is conformance tested is the scenarios: each conformance and acceptance scenario of a functional spec gets at least one test, and nothing else is tested - a functional spec with no test plain file, or an empty one, has no conformance tests. Its tests are written or changed once its code lands, whenever a scenario is added, changed or taken out, its text changes, it is regenerated again or taken out; one whose scenarios are all taken out loses its tests. It goes scenario by scenario, by scenario-id: a scenario added gets its tests, one changed has them rewritten, one taken out loses them, and an unchanged one keeps them - run on the new code when the functional spec's code changed. A scenario-id renamed with its text as it was has its tests relabelled, nothing rewritten; renamed with any other change, or moved between conformance and acceptance, it is one taken out and one added. To have something checked end to end, write it as a scenario
34
- - Scenarios are tested only once the module has test reqs - its own, or the stack's conformance template imported - and the project has a conformance testing script for its stack. For a module another requires, that is the tip of the chain: its conformance tests are written there, from the tip's test reqs, so the template goes into the tip. Without either, turri starts no conformance pulse there, by itself or from `conform`: it refuses, naming the step missing, the module waits on it until the `.plain` files or the scripts change, and `turri parse` warns. Take the steps in order - test reqs, the script, then the scenarios - and a module with no scenarios needs neither
34
+ - Scenarios are tested only once the module has test reqs - its own, or the stack's conformance template imported - and the project has a conformance testing script for it. For a module another requires, that is the tip of the chain: its conformance tests are written there, from the tip's test reqs, so the template goes into the tip. Without either, turri starts no conformance pulse there, by itself or from `conform`: it refuses, naming the step missing, the module waits on it until the `.plain` files or the scripts change, and `turri parse` warns. Take the steps in order - test reqs, the script, then the scenarios - and a module with no scenarios needs neither
35
+ - A module is built with `config.turri.yaml` and, laid over it, its own `config.turri.<module>.yaml` - else the one of a module it requires, all the way down: a module is built on their code, with their testing scripts. Nobody chooses it. Two modules it requires with a file of their own, and none of its own, is an error `turri parse` reports and `regenerate` refuses: give the module its own file, or keep one of theirs. Only `requires` counts, not `import`
35
36
  - Definitions moved to a common module and reqs reordered are recorded, not regenerated
36
37
  - A functional spec written on its happy path and hardened later - its validation, edge cases and errors added to it - is patched in place each time: growing a spec a step at a time costs no more than writing it whole up front
37
38
  - A module's first pulse, when it builds one functional spec - the project set up and the smallest thing that runs - lands on its unit tests with no review
38
39
 
39
- ## The test advisor
40
+ ## Conformance tests
40
41
 
41
- - Conformance tests are the project's choice: `conformance-tests:` in config.turri.yaml, off when unset. Off, no scenarios are tested and the test advisor is off - write no test plain file, test reqs or conformance testing script unless the person asks for tests; their asking, or their yes when the chat offers them, turns them on first
42
- - In the chat and a host, turri's test advisor looks at each functional spec that is new, or whose text changed since its code was built, and that has no scenarios - in the background, beside the pulses, taking no slot of theirs and never stopping one. It asks whether a wrong implementation could give output that looks right, whether two reasonable readings give different outputs for some input, whether it is likely to be built on later, and whether a bug in it would be costly. A yes to the first, the second or the last, with evidence, means the functional spec needs testing; built on later alone does not
43
- - It writes nothing in the ***plain: you are its only writer. A functional spec with scenarios of any kind is not looked at by it; its scenarios go through the usual review when its text changes
44
- - A change's result names the functional specs the advisor is checking: tell the person in a line that testing scenarios are being evaluated for them, and go on
45
- - Its yes comes to you as a message, once the chat is idle, with its report: tell the person in a line, then write with `change_plain` what testing the functional spec needs - its test reqs, the conformance testing script, its scenarios, in that order and only what is missing - the script written in the background, so you go straight on to the scenarios - as the rules on test plain files say, asking the person nothing. Its no is a line turri draws: nothing for you to do
46
- - `evaluate_tests` asks the advisor yourself, for functional specs you name with why, even a text it judged already: it returns at once, and the verdict comes back the same way. Call it when the person asks whether a functional spec needs tests, and on your own as another way of expressing intent - when pulses keep failing on a complicated functional spec, scenarios may pin down what it should do. A functional spec with scenarios is not evaluated
47
- - When the person asks for scenarios, write them yourself, as the rules on test plain files say. `test-advisor: false` turns off only what a change starts, never `evaluate_tests`; the advisor never runs in a headless run
42
+ - Conformance tests are the person's choice: `conformance-tests:` in config.turri.yaml, off when unset, as they make each change take about twice as long. Off, no scenarios are tested and `conform` is refused - write no test plain file, test reqs or conformance testing script. When you think a module needs conformance tests, or the person asks for them, tell them in a line or two why; they decide, and turn them on with `/conform`
43
+ - On, you decide which functional specs need scenarios: as you write or change one, judge it by the criteria in the rules on test plain files, and when it needs them, write them - with the test reqs and the conformance testing script first, when missing, without asking: conformance tests on is the person's yes to all three - as a visible ***plain change the person reviews like any other, then call `regenerate`. The work loop writes and runs their conformance tests once the code is built
48
44
 
49
45
  ## What a coding agent sees
50
46
 
@@ -57,9 +53,10 @@ The other rules say what a spec means. This one says what turri does with a chan
57
53
 
58
54
  - Never edit the code under `plain_modules/`: the next regeneration does not keep it, and the code record no longer says what the code is
59
55
  - In order of cost: change the spec where it is wrong or silent; regenerate the functional specs whose code went bad again, by name; regenerate the module from scratch, or its whole chain - only when the person asks for it or agrees to it
56
+ - Bad conformance tests are fixed the same way, their code untouched: `conform` naming a functional spec whose tests are written writes them again, anew from its scenarios; `conform` from scratch takes out the tests folder at the tip of the module's chain and writes them again - from the tests of the module the tip requires, or, its whole chain, from nothing - only when the person asks for it
60
57
  - Pulses regenerate in the background: the spec can be changed while they run, and need not wait for them. A change inside what a running pulse regenerates steers it; the rest is planned again around it
61
58
  - A pulse that does not land is rolled back whole - code, tests and record together - and its module waits until the spec changes or the module is asked for again. Running it again unchanged usually ends the same way: look at why it did not land first
62
- - A finished pulse goes to the sentinel, a chat of turri's own - unless `sentinel: false`; under `sentinel: ask`, the default, only once the person said to start it, asked by turri before it first opens in a session (declined, a pulse goes to the chat that asked for it, as with `false`): it checks the pulse, tests what was released, fixes a testing script - or where the config says the scripts are - itself and regenerates the module again, and puts anything else that is wrong to the person as a notice with what can be done. It never changes ***plain. turri installs nothing on the machine and changes none of its settings - not the sentinel, the chat, a release or any agent: a toolchain the machine lacks is the person's to install, told the exact command. A pulse that landed is told to the chat the person is in too, only to say it landed and what the sentinel does with it, and when the sentinel is done with a pulse, what it found - the chat does nothing else about either; a pulse that went wrong is not told to it - the chat's agent is given a notice's task once the person accepts it, and does that
59
+ - A finished pulse goes to the sentinel, a chat of turri's own - unless `sentinel: false`; under `sentinel: ask`, the default, only once the person said to start it, asked by turri before it first opens in a session (declined, a pulse goes to the chat that asked for it, as with `false`): it checks every pulse, in order, tests it in what was launched - a launch whose commit holds the pulse's - fixes a testing script - or where the config says the scripts are - itself and regenerates the module again, and puts anything else that is wrong to the person as a notice with what can be done. It never changes ***plain. turri installs nothing on the machine and changes none of its settings - not the sentinel, the chat, a launch or any agent: a toolchain the machine lacks is the person's to install, told the exact command. A pulse that landed is told to the chat the person is in too, only to say it landed and what the sentinel does with it, and when the sentinel is done with a pulse, what it found - the chat does nothing else about either; a pulse that went wrong is not told to it - the chat's agent is given a notice's task once the person accepts it, and does that
63
60
 
64
61
  ## Where the cost is
65
62
 
@@ -7,11 +7,11 @@ description: >-
7
7
  when turri says a module is in the old ***plain syntax, or the person asks to
8
8
  convert one. One run converts one module, the lowest of the chain first;
9
9
  it never regenerates.
10
- allowed-tools: [read, ls, grep, find, change_plain, parse]
10
+ allowed-tools: [read, write, edit, ls, grep, find, parse]
11
11
  metadata:
12
12
  phases:
13
13
  ids: "a func-id for each functional spec and a scenario-id for each acceptance test, proposed and confirmed"
14
- rewrite: "the module and its test plain files, in one ***plain diff, word for word"
14
+ rewrite: "the module and its test plain files, word for word"
15
15
  check: "parse, and which module is next"
16
16
  gates:
17
17
  - after: rewrite
@@ -44,7 +44,7 @@ Ask the person once, with `ask_user`: the whole list in its `context` - each fun
44
44
 
45
45
  ### rewrite
46
46
 
47
- Write the whole conversion as one `change_plain` diff, with the confirmed ids:
47
+ Write the whole conversion with `write` and `edit`, with the confirmed ids:
48
48
 
49
49
  - **The module.** Under `***functional specs***`, each bullet becomes its `# <func-id>` heading followed by its body: the bullet's text without its leading `- `, word for word. Its sub-bullets become `- ` bullets under that text, one level less indented, word for word and in the same order. Its nested `***acceptance tests***` are taken out of the module. The functional specs keep their order, one blank line between them. The frontmatter, every other section, the comments and any Liquid stay exactly as they are.
50
50
  - **Its test plain files,** one for each functional spec that has acceptance tests, at `tests/<module>/<func-id>.plain`: frontmatter `module:` (the module's file name without `.plain`) and `func_id:`, then `***conformance tests***`, then `***acceptance tests***` (`test-plain-files.md`). Each acceptance test of the functional spec becomes a scenario under `***acceptance tests***`: its `# <scenario-id>` heading followed by its text without its `- `, word for word, and its sub-bullets as `- ` bullets under it. `***conformance tests***` stays empty. A functional spec with no acceptance tests gets no test plain file: it has no scenarios.
@@ -53,13 +53,13 @@ Nothing else: no word added, reworded or dropped, no conformance scenario, no fi
53
53
 
54
54
  The change regenerates nothing: a module built before func-ids is not built on until its chain is regenerated from scratch, which the chat asks the person for.
55
55
 
56
- The record for the review: the module as it was before the change, word for word as you read it; the confirmed ids; and every file the change wrote. When the review sends the step back, show the person what it found and your fix with `ask_user`, then write the fix with one `change_plain`.
56
+ The record for the review: the module as it was before the change, word for word as you read it; the confirmed ids; and every file the change wrote. When the review sends the step back, show the person what it found and your fix with `ask_user`, then write the fix.
57
57
 
58
58
  ### check
59
59
 
60
60
  Run `parse` on the module and show what it says in your reply.
61
61
 
62
- When it reports an error the conversion made, show it to the person with `ask_user`, with the fix, and write the fix with one `change_plain`; then run `parse` again. An error the module had before the conversion stays for the person.
62
+ When it reports an error the conversion made, show it to the person with `ask_user`, with the fix, and write the fix; then run `parse` again. An error the module had before the conversion stays for the person.
63
63
 
64
64
  End with the result:
65
65
  - the module converted, its functional specs and scenarios counted, and the files written
@@ -212,7 +212,7 @@ The harness never runs `.ps1` scripts. These notes apply only to an optional cop
212
212
  4. Pick the right row from the [Dependency isolation](#dependency-isolation) table — use the same flag/env var in steps 7, 7b and 8 — and the checks from [Static checks of the tests](#static-checks-of-the-tests).
213
213
  5. Add the language-appropriate "no tests discovered" guard from [No tests discovered detection](#no-tests-discovered-detection), and the guard against conformance tests in the build folder from [Tests in the build folder](#tests-in-the-build-folder).
214
214
  6. Save the new script as `test_scripts/run_conformance_tests_<lang>.sh` and `chmod +x` it. Write a `.ps1` copy only if the user wants to run it by hand on Windows.
215
- 7. **Make sure turri finds the script.** Do not link it from the ***plain - turri finds the conformance testing script in the project root (the folder that holds `plain_modules/`) and puts it, whole, into the prompts of the agents that write and review the conformance tests itself, whenever conformance tests are written for a build; a link to it from the ***plain is ignored. It looks, in order, at `config.turri.yaml` in the root (`conformance-tests-script: <path relative to the root>`) - with the chosen stack's `config.turri.<stack>.yaml` over it, then for the one `run_conformance_tests*.sh` in the root, then for the one in `test_scripts/`. Saving the script in `test_scripts/` (or the root) is enough when it is the only one there. If the project keeps it elsewhere, name it in `config.turri.yaml` as `conformance-tests-script:` - and when the project has only a `config.yaml`, copy it to `config.turri.yaml` first (and each `config.<name>.yaml` to `config.turri.<name>.yaml`) and edit the copy; `config.yaml` may be another tool's, and is never written. If the project has modules on different stacks - e.g. a Python backend and a React frontend side by side, sharing only an imported module - each part is on a stack of its own, and each stack names its own script in its own file beside `config.turri.yaml`: `conformance-tests-script:` in `config.turri.backend.yaml` for the stack `backend`, in `config.turri.frontend.yaml` for the stack `frontend`. Name each stack after the module it builds - `config.turri.backend.yaml` for `backend.plain` - and that module is built with it by itself, with nothing to choose; a stack named otherwise is passed as `stack` to `regenerate` in the chat, or `--stack <stack>` on the command line. turri never guesses between two. The script is required: without one, no conformance or acceptance test is written or run. The `***test reqs***` still describe the conformance framework and command in words; do not paraphrase the script into them.
215
+ 7. **Make sure turri finds the script.** Do not link it from the ***plain - turri finds the conformance testing script in the project root (the folder that holds `plain_modules/`) and puts it, whole, into the prompts of the agents that write and review the conformance tests itself, whenever conformance tests are written for a build; a link to it from the ***plain is ignored. It looks, in order, at `config.turri.yaml` in the root (`conformance-tests-script: <path relative to the root>`) - with the module's own `config.turri.<module>.yaml` over it - or the one of a module it requires - then for the one `run_conformance_tests*.sh` in the root, then for the one in `test_scripts/`. Saving the script in `test_scripts/` (or the root) is enough when it is the only one there. If the project keeps it elsewhere, name it in `config.turri.yaml` as `conformance-tests-script:` - and when the project has only a `config.yaml`, copy it to `config.turri.yaml` first (and each `config.<name>.yaml` to `config.turri.<name>.yaml`) and edit the copy; `config.yaml` may be another tool's, and is never written. If the project has modules on different stacks - e.g. a Python backend and a React frontend side by side, sharing only an imported module - each part names its own script in a file of its own beside `config.turri.yaml`: `conformance-tests-script:` in `config.turri.backend.yaml` for `backend.plain`, in `config.turri.frontend.yaml` for `frontend.plain`. A module's file builds it and every module built on it that has no file of its own, so name it after the module at the bottom of the chain - `config.turri.backend.yaml` builds `backend_auth.plain`, which requires `backend.plain`, too - and turri works it out with nothing to choose; two files among the modules one requires is an error. turri never guesses between two. The script is required: without one, no conformance or acceptance test is written or run. The `***test reqs***` still describe the conformance framework and command in words; do not paraphrase the script into them.
216
216
 
217
217
  ## Anti-Patterns
218
218
 
@@ -235,5 +235,5 @@ The harness never runs `.ps1` scripts. These notes apply only to an optional cop
235
235
  - **Don't ship only a `.ps1`.** The harness runs `.sh` scripts only; a project with just a PowerShell runner has no conformance testing script as far as turri is concerned.
236
236
  - **Don't install dependencies into the user's global location** (`~/.m2`, system-wide `pip`, `~/.cargo`, etc.). Always isolate inside `$WORKING_FOLDER` so concurrent runs and other projects can't interfere.
237
237
  - **Don't run the test command without first verifying the install succeeded.** A failed install followed by a "test" run produces misleading errors that look like test failures.
238
- - **Don't link the script from the ***plain, and don't leave turri guessing.** turri finds the script in `config.turri.yaml`, the project root, or `test_scripts/`, shows it to the agents that write the conformance tests itself, and writes or runs no conformance test without it; a link to it from the ***plain is ignored. Put it where it is found, and when there are two conformance testing scripts in one folder, name the one to use as `conformance-tests-script:` - in each stack's `config.turri.<stack>.yaml` when they are for parts on different stacks (see Workflow step 7).
238
+ - **Don't link the script from the ***plain, and don't leave turri guessing.** turri finds the script in `config.turri.yaml`, the project root, or `test_scripts/`, shows it to the agents that write the conformance tests itself, and writes or runs no conformance test without it; a link to it from the ***plain is ignored. Put it where it is found, and when there are two conformance testing scripts in one folder, name the one to use as `conformance-tests-script:` - in each module's own `config.turri.<module>.yaml` when they are for parts on different stacks (see Workflow step 7).
239
239
  - **Don't write a terse script.** Silent steps, `>/dev/null` redirects on the install output, missing `--version` prints, absent step banners, an un-logged resolved `$2`, and a missing final summary all make the script harder to debug than the tests it is running. Follow the *Logging — be as verbose as possible* rule under [Conventions](#conventions) literally: every step announces itself, every command is echoed, the resolved `$CONFORMANCE_TESTS_FOLDER` is printed, every failure prints what was about to run and where, and the final summary names the test command, exit code, and working folder.
@@ -138,12 +138,12 @@ Notes:
138
138
 
139
139
  ## Workflow
140
140
 
141
- 1. Take the target **language**, **test framework** and **dependency manifest** (`pom.xml`, `requirements.txt` / `pyproject.toml`, `package.json`, `go.mod`, `Cargo.toml`, ...) from the module the script is for: its stack - the `stdlib/...` template it imports - its implementation reqs, and the project. You run in the background, with nobody to ask: decide what they leave open, the choice most consistent with them, and say what you decided in your result. The script is Bash; a PowerShell copy only when the context asks for one. When `config.turri.yaml` - or the stack's `config.turri.<stack>.yaml` - names a `base-folder:`, the module's code starts as a copy of that folder: an existing codebase to build on, or only files to use. Read it. When it holds code with its own test setup - a `pytest.ini` or `pyproject.toml` test section, `package.json` test scripts, a `pom.xml`, a `go.mod` - the script runs that setup's tests as they run there, beside the tests the coding agents write, so they keep passing; its existing dependency manifest is the one to install from. A folder of assets alone changes nothing.
141
+ 1. Take the target **language**, **test framework** and **dependency manifest** (`pom.xml`, `requirements.txt` / `pyproject.toml`, `package.json`, `go.mod`, `Cargo.toml`, ...) from the module the script is for: its stack - the `stdlib/...` template it imports - its implementation reqs, and the project. You run in the background, with nobody to ask: decide what they leave open, the choice most consistent with them, and say what you decided in your result. The script is Bash; a PowerShell copy only when the context asks for one. When `config.turri.yaml` - or the module's own `config.turri.<module>.yaml` - names a `base-folder:`, the module's code starts as a copy of that folder: an existing codebase to build on, or only files to use. Read it. When it holds code with its own test setup - a `pytest.ini` or `pyproject.toml` test section, `package.json` test scripts, a `pom.xml`, a `go.mod` - the script runs that setup's tests as they run there, beside the tests the coding agents write, so they keep passing; its existing dependency manifest is the one to install from. A folder of assets alone changes nothing.
142
142
  2. Read [assets/run_unittests_java.sh](assets/run_unittests_java.sh) to refresh the exact structure.
143
143
  3. Translate each of the eight steps above into the equivalent commands for the target language **and** shell. The toolchain check, dependency install, static checks and test invocation are the language-specific parts; the rest is mechanical translation between Bash and PowerShell syntax.
144
144
  4. Pick the dependency-isolation mechanism from the [Dependency isolation](#dependency-isolation) table and use it consistently in steps 6, 7 and 8, and the checks from the [Static checks](#static-checks) table.
145
145
  5. Save the new script as `test_scripts/run_unittests_<lang>.sh` (a `.ps1` copy next to it only if the user wants to run it by hand on Windows). For Bash, `chmod +x` it.
146
- 6. **Make sure turri finds the script.** Do not link it from the ***plain - turri finds the unit testing script in the project root (the folder that holds `plain_modules/`) and puts it, whole, into the prompt of the coding agent itself; a link to it from the ***plain is ignored. It looks, in order, at `config.turri.yaml` in the root (`unittests-script: <path relative to the root>`) - with the chosen stack's `config.turri.<stack>.yaml` over it, then for the one `run_unittests*.sh` in the root, then for the one in `test_scripts/`. Saving the script in `test_scripts/` (or the root) is enough when it is the only one there. If the project keeps it elsewhere, name it in `config.turri.yaml` as `unittests-script:` - and when the project has only a `config.yaml`, copy it to `config.turri.yaml` first (and each `config.<name>.yaml` to `config.turri.<name>.yaml`) and edit the copy; `config.yaml` may be another tool's, and is never written. If the project has modules on different stacks - e.g. a Python backend and a React frontend side by side, sharing only an imported module - each part is on a stack of its own, and each stack names its own script in its own file beside `config.turri.yaml`: `unittests-script:` in `config.turri.backend.yaml` for the stack `backend`, in `config.turri.frontend.yaml` for the stack `frontend`. Name each stack after the module it builds - `config.turri.backend.yaml` for `backend.plain` - and that module is built with it by itself, with nothing to choose; a stack named otherwise is passed as `stack` to `regenerate` in the chat, or `--stack <stack>` on the command line. turri never guesses between two. The script is required: a build without one stops before it starts.
146
+ 6. **Make sure turri finds the script.** Do not link it from the ***plain - turri finds the unit testing script in the project root (the folder that holds `plain_modules/`) and puts it, whole, into the prompt of the coding agent itself; a link to it from the ***plain is ignored. It looks, in order, at `config.turri.yaml` in the root (`unittests-script: <path relative to the root>`) - with the module's own `config.turri.<module>.yaml` over it - or the one of a module it requires - then for the one `run_unittests*.sh` in the root, then for the one in `test_scripts/`. Saving the script in `test_scripts/` (or the root) is enough when it is the only one there. If the project keeps it elsewhere, name it in `config.turri.yaml` as `unittests-script:` - and when the project has only a `config.yaml`, copy it to `config.turri.yaml` first (and each `config.<name>.yaml` to `config.turri.<name>.yaml`) and edit the copy; `config.yaml` may be another tool's, and is never written. If the project has modules on different stacks - e.g. a Python backend and a React frontend side by side, sharing only an imported module - each part names its own script in a file of its own beside `config.turri.yaml`: `unittests-script:` in `config.turri.backend.yaml` for `backend.plain`, in `config.turri.frontend.yaml` for `frontend.plain`. A module's file builds it and every module built on it that has no file of its own, so name it after the module at the bottom of the chain - `config.turri.backend.yaml` builds `backend_auth.plain`, which requires `backend.plain`, too - and turri works it out with nothing to choose; two files among the modules one requires is an error. turri never guesses between two. The script is required: a build without one stops before it starts.
147
147
 
148
148
  ## Anti-Patterns
149
149
 
@@ -159,5 +159,5 @@ Notes:
159
159
  - Don't write a cross-shell hybrid (e.g. a `.sh` that detects PowerShell, or vice versa). Ship one script per shell, named with the appropriate extension.
160
160
  - Don't install dependencies into the user's global location (`~/.m2`, system-wide `pip`, `~/.cargo`, etc.). Always isolate inside `$WORKING_FOLDER` so concurrent runs and other projects can't interfere.
161
161
  - Don't run the test command without first verifying the install step succeeded. A failed install followed by a "test" run produces misleading errors that look like test failures.
162
- - **Don't link the script from the ***plain, and don't leave turri guessing.** turri finds the script in `config.turri.yaml`, the project root, or `test_scripts/`, and shows it to the coding agent itself; a link to it from the ***plain is ignored. Put it where it is found, and when there are two unit testing scripts in one folder, name the one to use as `unittests-script:` - in each stack's `config.turri.<stack>.yaml` when they are for parts on different stacks (see Workflow step 6).
162
+ - **Don't link the script from the ***plain, and don't leave turri guessing.** turri finds the script in `config.turri.yaml`, the project root, or `test_scripts/`, and shows it to the coding agent itself; a link to it from the ***plain is ignored. Put it where it is found, and when there are two unit testing scripts in one folder, name the one to use as `unittests-script:` - in each module's own `config.turri.<module>.yaml` when they are for parts on different stacks (see Workflow step 6).
163
163
  - **Don't write a terse script.** Silent steps, `>/dev/null` redirects on the install output, missing `--version` prints, and absent failure banners all make the script harder to debug than the code it is testing. Follow the *Logging — be as verbose as possible* rule under [Conventions](#conventions) literally: every step announces itself, every command is echoed, every failure prints what was about to run and where.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@turri-dev/cli",
3
- "version": "0.2.3",
3
+ "version": "0.2.4-next.009bd0c",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "repository": {
@@ -1,63 +0,0 @@
1
- import { type ExtensionAPI, type ExtensionContext, type ToolDefinition } from "@earendil-works/pi-coding-agent";
2
- import type { ChatLink } from "./chats.ts";
3
- import type { AdvisorVerdict, TestAdvisor } from "./regenerate/advisor-runs.ts";
4
- import type { WorkLoop } from "./regenerate/loop.ts";
5
- /** The line a no is drawn as: the functional spec, and the classifier's reading in a few words - a no has no evidence. */
6
- export declare function noLine(verdict: AdvisorVerdict): string;
7
- /** The line the chat is to tell the person a yes in. */
8
- export declare function yesLine(verdict: AdvisorVerdict): string;
9
- /** A yes's report, as the chat's agent is given it: the questions that were a yes with their evidence, and the inputs. */
10
- export declare function describeReport(verdict: AdvisorVerdict): string[];
11
- /** The turn a batch of yeses starts: each one's report, and what the chat is to do with them - asking the person nothing. */
12
- export declare function yesTask(verdicts: AdvisorVerdict[]): string;
13
- /** How long a verdict waits before the chat is looked at again, while the person types or it cannot be told yet. */
14
- export declare const ADVISOR_RECHECK_MS = 2000;
15
- /**
16
- * A chat's verdicts: held until the chat is idle - its agent done, and nothing typed in its editor - then delivered
17
- * together: one turn for every yes, one line for each no. A verdict no longer about its functional spec as it is - its
18
- * text changed, or it was given scenarios meanwhile - is let go.
19
- */
20
- export declare function verdictDelivery(pi: ExtensionAPI, link: ChatLink, context: () => ExtensionContext | undefined): {
21
- put(verdict: AdvisorVerdict): void;
22
- };
23
- /**
24
- * The test advisor and the chat, in its system prompt while the session has the advisor and the project wants it: the
25
- * two ways an evaluation starts, what to say while it runs, what to do with its verdict, and when to ask for one.
26
- */
27
- export declare const TEST_ADVISOR_BLOCK: string;
28
- /** The test advisor of the session a work loop is in. */
29
- export declare function bindAdvisor(loop: WorkLoop, advisor: () => TestAdvisor | undefined): void;
30
- /**
31
- * What a change's tool result tells the chat's agent of the test advisor: the functional specs it has taken up, so the
32
- * agent tells the person they are being evaluated - nothing when it has taken up none.
33
- */
34
- export declare function advisingNote(loop: WorkLoop, plainFile: string): string;
35
- /** What an evaluation asked for came to, by functional spec - each named `module:func-id`, a missing one with why. */
36
- export interface EvaluateOutcome {
37
- /** Being evaluated now: the verdict comes to the chat the person looks at. */
38
- started: string[];
39
- /** Being evaluated already. */
40
- already: string[];
41
- /** With scenarios already: not evaluated. */
42
- scenarios: string[];
43
- /** Not found, with why. */
44
- missing: string[];
45
- }
46
- /**
47
- * The test advisor asked to evaluate functional specs - `module:func-id`s, or func-ids of `plainFile`'s module (else the
48
- * one the project's config names) - even a text it judged already, and whatever `test-advisor` says: `evaluate_tests`'s
49
- * and a host's `evaluateTests`. It returns at once.
50
- */
51
- export declare function evaluateTests(cwd: string, advisor: TestAdvisor | undefined, funcIds: string[], options?: {
52
- plainFile?: string;
53
- reason?: string;
54
- }): EvaluateOutcome;
55
- /**
56
- * evaluate_tests: the chat's own way to the test advisor - a functional spec evaluated in the background, whatever
57
- * `test-advisor` says, and even when its text was judged already. It returns at once; the verdict comes back to the chat
58
- * as the advisor's verdicts do. In the chat and a host only: the session has an advisor.
59
- */
60
- export declare function evaluateTestsTool(options: {
61
- cwd: string;
62
- advisor: () => TestAdvisor | undefined;
63
- }): ToolDefinition;
@@ -1,290 +0,0 @@
1
- import { existsSync } from "node:fs";
2
- import { basename, join, relative, resolve } from "node:path";
3
- import { defineTool } from "@earendil-works/pi-coding-agent";
4
- import { Box, Text } from "@earendil-works/pi-tui";
5
- import { Type } from "typebox";
6
- import { chatBusy } from "./chat-idle.js";
7
- import { conformanceTestsOnIn } from "./conformance-switch.js";
8
- import { readProjectConfig } from "./config.js";
9
- import { modulePlainFile } from "./plain/parser.js";
10
- import { projectDirOf, resolveTemplateDirs } from "./regenerate/paths.js";
11
- import { resolveRequiresChain } from "./regenerate/requires.js";
12
- import { refuseTestPlainFile } from "./test-plain-files.js";
13
- /**
14
- * The test advisor in the chat (docs/test-advisor.md). The advisor decides; the chat is the only writer of the ***plain.
15
- * A finished verdict reaches the chat the person looks at once it is idle - never interrupting it: a yes is a message
16
- * that starts a turn, in which the chat tells the person and writes the scenarios with change_plain, asking nothing; a
17
- * no is one line drawn by turri, starting no turn. What else the chat is told of the advisor - in its system prompt, in a
18
- * change's result - is here too, and its own way to it, evaluate_tests.
19
- */
20
- /** Why, in a few words, by the first question of a yes. */
21
- const WHY = {
22
- "silent-failure": "a wrong implementation could look right",
23
- divergence: "it can be read two ways",
24
- cost: "a bug in it would be costly",
25
- };
26
- const specOf = (verdict) => `${verdict.module}:${verdict.funcId}`;
27
- /** The line a no is drawn as: the functional spec, and the classifier's reading in a few words - a no has no evidence. */
28
- export function noLine(verdict) {
29
- const only = verdict.report.questions.map((answered) => answered.question);
30
- const reading = only.length > 0 && only.every((question) => question === "revisited") ? "its unit tests cover it as it is built on" : "nothing silent to get wrong";
31
- return `${specOf(verdict)} doesn't need testing scenarios - ${reading}.`;
32
- }
33
- /** The line the chat is to tell the person a yes in. */
34
- export function yesLine(verdict) {
35
- const why = verdict.report.questions.map((answered) => WHY[answered.question]).find((reason) => reason !== undefined);
36
- return `${specOf(verdict)} needs testing scenarios${why !== undefined ? ` - ${why}` : ""}. Writing them now.`;
37
- }
38
- /** A yes's report, as the chat's agent is given it: the questions that were a yes with their evidence, and the inputs. */
39
- export function describeReport(verdict) {
40
- return [
41
- "Why it needs testing:",
42
- ...verdict.report.questions.map((answered) => `- ${answered.question}: ${answered.evidence}`),
43
- "Inputs to cover:",
44
- ...(verdict.report.inputs.length === 0
45
- ? ["- none picked: cover its expected use, as the rules on test plain files say"]
46
- : verdict.report.inputs.map((input, index) => "agreed" in input
47
- ? `${index + 1}. input: ${input.input} - agreed output: ${input.agreed}`
48
- : `${index + 1}. input: ${input.input} - split: ${input.readings.map((reading, at) => `(${at + 1}) ${reading}`).join("; ")}`)),
49
- ];
50
- }
51
- /** The turn a batch of yeses starts: each one's report, and what the chat is to do with them - asking the person nothing. */
52
- export function yesTask(verdicts) {
53
- const where = (path, project) => relative(project, path) || path;
54
- return [
55
- `My test advisor judged that ${verdicts.length === 1 ? "this functional spec needs" : "these functional specs need"} explicit testing scenarios. You write them now.`,
56
- "",
57
- ...verdicts.flatMap((verdict) => [
58
- `<functional_spec name="${specOf(verdict)}" plain_file="${where(verdict.plainFile, verdict.project)}" tested_in="${where(verdict.tip, verdict.project)}" test_plain_file="${verdict.testFile}">`,
59
- ...describeReport(verdict),
60
- "</functional_spec>",
61
- "",
62
- ]),
63
- "What to do, in this turn, asking the person nothing:",
64
- `1. Tell the person in a line for each, e.g. "${yesLine(verdicts[0])}"`,
65
- "2. With change_plain, write whatever the step-7 guard would refuse, in this order, only what is missing: the ***test reqs*** of the module",
66
- " it is tested in - the stack's conformance template, stdlib/<kind>/conformance/<stack>, imported, or the module's own - then the",
67
- " conformance testing script for its stack, with implement-conformance-testing-script - cultivate, plainFile the module it is tested in,",
68
- " which returns at once: go straight on - then the scenarios in its test plain file.",
69
- "3. Cover each input of the report that is this functional spec's: an agreed one with the readers' output, never a placeholder such as",
70
- " <name> where a value belongs; a split one settled by the reading most consistent with the functional spec and its module - say which",
71
- " reading you took. Leave out an input that exercises another functional spec, or nothing this one says.",
72
- "4. Ask the person nothing: the change is visible, and turri tests the scenarios once the code is built.",
73
- ].join("\n");
74
- }
75
- /** The line a no is drawn as, in the transcript and in no model's context. */
76
- const ADVISOR_ENTRY = "turri_advisor";
77
- /** How long a verdict waits before the chat is looked at again, while the person types or it cannot be told yet. */
78
- export const ADVISOR_RECHECK_MS = 2000;
79
- /**
80
- * A chat's verdicts: held until the chat is idle - its agent done, and nothing typed in its editor - then delivered
81
- * together: one turn for every yes, one line for each no. A verdict no longer about its functional spec as it is - its
82
- * text changed, or it was given scenarios meanwhile - is let go.
83
- */
84
- export function verdictDelivery(pi, link, context) {
85
- const waiting = [];
86
- let timer;
87
- pi.registerEntryRenderer(ADVISOR_ENTRY, (entry, _options, theme) => {
88
- const data = entry.data;
89
- if (data === undefined)
90
- return undefined;
91
- const box = new Box(1, 0);
92
- box.addChild(new Text(theme.fg("muted", data.text), 0, 0));
93
- return box;
94
- });
95
- const busy = () => chatBusy(link, context);
96
- const later = (ms) => {
97
- if (timer !== undefined)
98
- return;
99
- timer = setTimeout(() => {
100
- timer = undefined;
101
- deliver();
102
- }, ms);
103
- timer.unref?.();
104
- };
105
- const deliver = () => {
106
- if (waiting.length === 0)
107
- return;
108
- if (busy()) {
109
- // Its agent ending says so (agent_settled); the person's typing does not, so it is looked at again.
110
- later(ADVISOR_RECHECK_MS);
111
- return;
112
- }
113
- const now = waiting.splice(0).filter((verdict) => {
114
- try {
115
- return verdict.current();
116
- }
117
- catch {
118
- return false;
119
- }
120
- });
121
- const yes = now.filter((verdict) => verdict.report.verdict === "yes");
122
- try {
123
- for (const verdict of now.filter((verdict) => verdict.report.verdict === "no"))
124
- pi.appendEntry(ADVISOR_ENTRY, { text: noLine(verdict) });
125
- if (yes.length > 0) {
126
- // A follow-up, never a steer: should a turn start in between, this waits for it to end.
127
- void pi.sendMessage({ customType: "turri_advisor_verdict", content: yesTask(yes), display: false, details: { specs: yes.map(specOf) } }, { triggerTurn: true, deliverAs: "followUp" });
128
- }
129
- }
130
- catch {
131
- // Not bound to its session yet: kept, and tried again.
132
- waiting.unshift(...now);
133
- later(ADVISOR_RECHECK_MS);
134
- return;
135
- }
136
- for (const verdict of now)
137
- verdict.delivered();
138
- };
139
- pi.on("agent_settled", () => deliver());
140
- pi.on("session_start", () => later(0));
141
- return {
142
- put(verdict) {
143
- // A newer verdict on the same functional spec replaces the one waiting.
144
- const at = waiting.findIndex((known) => known.project === verdict.project && specOf(known) === specOf(verdict));
145
- if (at !== -1)
146
- waiting.splice(at, 1);
147
- waiting.push(verdict);
148
- // The rest of what arrives at once comes with it.
149
- later(0);
150
- },
151
- };
152
- }
153
- /**
154
- * The test advisor and the chat, in its system prompt while the session has the advisor and the project wants it: the
155
- * two ways an evaluation starts, what to say while it runs, what to do with its verdict, and when to ask for one.
156
- */
157
- export const TEST_ADVISOR_BLOCK = [
158
- "<test advisor>",
159
- "My test advisor decides whether a functional spec needs explicit testing scenarios - whether it could fail silently, be read two ways, or",
160
- "cost a lot when wrong - in the background. You are the only writer of the ***plain: it writes nothing, and you write what its yes calls for.",
161
- "An evaluation starts two ways:",
162
- "- By itself, for each new or changed functional spec that has no scenarios. A change's result names the ones it took up.",
163
- "- When you call evaluate_tests - even for a text it judged already. Call it when the person asks whether a functional spec needs tests,",
164
- " and on your own, as another way of saying what one means: when pulses keep failing on a complicated functional spec, scenarios may pin",
165
- " down what it should do - say why in its reason. A functional spec with scenarios is not evaluated.",
166
- "When a change's result or evaluate_tests says a functional spec is being evaluated, tell the person so in a line, and go on: nothing waits",
167
- "for it. Its verdict comes back to this chat once you are idle:",
168
- "- A yes is a message with its report: tell the person in a line, then write with change_plain what testing it needs - the test reqs, the",
169
- " conformance testing script and its scenarios, in that order and only what is missing - as the message says, asking the person nothing.",
170
- "- A no is a line turri draws itself: there is nothing for you to do.",
171
- "When the person asks you for scenarios (\"write conformance scenarios for core:add-task\"), decide and write them yourself, with change_plain,",
172
- "as a ***plain change they see, as the rules say - whatever test-advisor says.",
173
- "</test advisor>",
174
- ].join("\n");
175
- /** Each work loop's session's test advisor - the chat's and a host's loops have one. */
176
- const advisorsOfLoops = new WeakMap();
177
- /** The test advisor of the session a work loop is in. */
178
- export function bindAdvisor(loop, advisor) {
179
- advisorsOfLoops.set(loop, advisor);
180
- }
181
- /**
182
- * What a change's tool result tells the chat's agent of the test advisor: the functional specs it has taken up, so the
183
- * agent tells the person they are being evaluated - nothing when it has taken up none.
184
- */
185
- export function advisingNote(loop, plainFile) {
186
- const taking = advisorsOfLoops.get(loop)?.()?.taking(projectDirOf(resolve(plainFile))) ?? [];
187
- if (taking.length === 0)
188
- return "";
189
- return [
190
- `My test advisor is evaluating ${taking.join(", ")} in the background, to see whether ${taking.length === 1 ? "it needs" : "they need"} explicit testing scenarios.`,
191
- "Tell the person, in a line, that testing scenarios are being evaluated for them, and go on - there is nothing to wait for: the verdict",
192
- "comes back to this chat.",
193
- ].join("\n");
194
- }
195
- /** The functional specs evaluate_tests is given, each as the advisor is asked for it - or, not found, why. */
196
- function namedSpecs(cwd, names, plainFile) {
197
- const named = plainFile ?? readProjectConfig(cwd).module;
198
- const base = named !== undefined ? resolve(cwd, named) : undefined;
199
- if (base !== undefined)
200
- refuseTestPlainFile(base);
201
- if (base !== undefined && !existsSync(base))
202
- throw new Error(`There is no .plain file at ${base}.`);
203
- const chain = (() => {
204
- try {
205
- return base !== undefined ? resolveRequiresChain(base, [], undefined, { allowNoFunctionalities: true }) : [];
206
- }
207
- catch {
208
- return [];
209
- }
210
- })();
211
- return names.map((given) => {
212
- const name = given.trim();
213
- const at = name.lastIndexOf(":");
214
- if (at === -1 && base === undefined)
215
- return { name, missing: `name it as module:func-id - there is no plain_file, and no module: in the project's config` };
216
- const module = at === -1 ? basename(base, ".plain") : name.slice(0, at);
217
- const funcId = at === -1 ? name : name.slice(at + 1);
218
- const own = chain.find((link) => link.moduleName === module)?.plainFile ?? modulePlainFile(module, resolveTemplateDirs(base ?? join(cwd, `${module}.plain`)));
219
- if (own === null || own === undefined || !existsSync(own))
220
- return { name: `${module}:${funcId}`, missing: `there is no module ${module} here` };
221
- // A module below the one named: its scenarios are tested in the one named, at the top of the chain.
222
- const tip = base !== undefined && chain.some((link) => link.moduleName === module) && resolve(own) !== resolve(base) ? { tip: base } : {};
223
- return { name: `${module}:${funcId}`, asked: { module, funcId, plainFile: resolve(own), ...tip } };
224
- });
225
- }
226
- /**
227
- * The test advisor asked to evaluate functional specs - `module:func-id`s, or func-ids of `plainFile`'s module (else the
228
- * one the project's config names) - even a text it judged already, and whatever `test-advisor` says: `evaluate_tests`'s
229
- * and a host's `evaluateTests`. It returns at once.
230
- */
231
- export function evaluateTests(cwd, advisor, funcIds, options = {}) {
232
- if (advisor === undefined)
233
- throw new Error("This session has no test advisor: it runs in the chat and a host only.");
234
- if (!conformanceTestsOnIn(cwd)) {
235
- throw new Error("Conformance tests are off for this project (conformance-tests: false, or unset), and the test advisor with them. They are turned on in the chat - by asking for them - or with conformance-tests: true in config.turri.yaml.");
236
- }
237
- if (funcIds.length === 0)
238
- throw new Error("Name the functional specs to evaluate, each as module:func-id.");
239
- const said = { started: [], already: [], scenarios: [], missing: [] };
240
- for (const spec of namedSpecs(cwd, funcIds, options.plainFile)) {
241
- if (spec.asked === undefined) {
242
- said.missing.push(`${spec.name}: ${spec.missing}`);
243
- continue;
244
- }
245
- const outcome = advisor.evaluate({ ...spec.asked, ...(options.reason !== undefined ? { reason: options.reason } : {}) });
246
- if (outcome === "missing")
247
- said.missing.push(`${spec.name}: its module has no such functional spec`);
248
- else
249
- said[outcome].push(spec.name);
250
- }
251
- return said;
252
- }
253
- /**
254
- * evaluate_tests: the chat's own way to the test advisor - a functional spec evaluated in the background, whatever
255
- * `test-advisor` says, and even when its text was judged already. It returns at once; the verdict comes back to the chat
256
- * as the advisor's verdicts do. In the chat and a host only: the session has an advisor.
257
- */
258
- export function evaluateTestsTool(options) {
259
- return defineTool({
260
- name: "evaluate_tests",
261
- label: "Evaluate tests",
262
- description: "Have turri's test advisor evaluate, in the background, whether functional specs need explicit testing scenarios - even one it judged " +
263
- "already, and whatever test-advisor says. It returns at once; the verdict comes back to this chat: a yes as a message to write the " +
264
- "scenarios on, a no as a line. A functional spec that has scenarios is not evaluated.",
265
- promptSnippet: "evaluate_tests: have the test advisor judge whether functional specs need testing scenarios, in the background",
266
- promptGuidelines: [
267
- "Call evaluate_tests when the person asks whether a functional spec needs tests (\"does add-task need tests?\"), rather than judging it yourself.",
268
- "Call it on your own too, as another way of saying what a functional spec means: when pulses keep failing on a complicated functional spec, scenarios may pin down what it should do - say so in reason.",
269
- "It returns at once: tell the person testing scenarios are being evaluated, and go on. On a yes, write the scenarios as the verdict's message says.",
270
- ],
271
- parameters: Type.Object({
272
- funcIds: Type.Array(Type.String(), { description: "The functional specs, each as module:func-id (core:add-task) - or a func-id alone, of plain_file's module" }),
273
- plain_file: Type.Optional(Type.String({ description: "The .plain file a func-id alone is of, and whose chain the scenarios are tested in. Omitted: the module the project's config.turri.yaml names" })),
274
- reason: Type.Optional(Type.String({ description: "Why you ask, for the advisor to weigh: \"the coding agent failed three times to implement it\"" })),
275
- }),
276
- async execute(_id, params) {
277
- const said = evaluateTests(options.cwd, options.advisor(), params.funcIds, { ...(params.plain_file !== undefined ? { plainFile: params.plain_file } : {}), ...(params.reason !== undefined ? { reason: params.reason } : {}) });
278
- const list = (names) => names.join(", ");
279
- const one = (names, single, many) => (names.length === 1 ? single : many);
280
- const text = [
281
- ...(said.started.length > 0 ? [`Testing scenarios for ${list(said.started)} are being evaluated in the background; the verdict comes back to this chat.`] : []),
282
- ...(said.already.length > 0 ? [`${list(said.already)} ${one(said.already, "is", "are")} being evaluated already; the verdict comes back to this chat.`] : []),
283
- ...(said.scenarios.length > 0 ? [`${list(said.scenarios)} ${one(said.scenarios, "has", "have")} scenarios already, so ${one(said.scenarios, "it is", "they are")} not evaluated: tested as the scenarios say.`] : []),
284
- ...(said.missing.length > 0 ? [`Not evaluated - ${said.missing.join("; ")}.`] : []),
285
- ...(said.started.length + said.already.length > 0 ? ["Tell the person so in a line, and go on: there is nothing to wait for."] : []),
286
- ].join("\n");
287
- return { content: [{ type: "text", text }], details: said };
288
- },
289
- });
290
- }
@@ -1,55 +0,0 @@
1
- import { readFileSync } from "node:fs";
2
- import { resolve } from "node:path";
3
- import { checkTouchedPlain, formatCheckResults } from "./plain/check.js";
4
- import { applySpecDiff, plainFilesOf, revertSpecDiff } from "./regenerate/regenerate.js";
5
- import { testPlainFileRefusal } from "./test-plain-files.js";
6
- import { parseArgs } from "./cli-options.js";
7
- import { headlessOptions, runLoop } from "./loop-cli.js";
8
- const USAGE = `usage: turri change-plain <file.plain> <diff-file> [options]
9
-
10
- Applies a change to ***plain, given as a git diff of the .plain files - modules and test plain files - and
11
- builds it: the headless
12
- counterpart of regenerate, given a diff. The diff is applied first, unless it is already in; then, as
13
- turri regenerate does, what is left to build is planned into jobs and built.
14
-
15
- --harness-model <p/id> config.turri.yaml's harness-model for this run: the planner, a diagnosis
16
- --coding-model <p/id> its coding-model, --model too: the agents that build
17
- --start-over start over, without asking, a codebase regenerated without a module it now requires
18
- --judge-model <p/id> its judge-model: the judge and the test review
19
- --review <true|false> its review: whether the code and its tests are reviewed once they pass
20
- --build-dir <dir> as the run ends, export the code there (see turri regenerate --help)
21
- --report <file.json> write a report of the run there (see turri regenerate --help)`;
22
- const { positional, options } = parseArgs(process.argv.slice(2), ["--start-over"], USAGE, ["--build-dir", "--report", "--harness-model", "--judge-model", "--review"]);
23
- const { report, buildDir } = headlessOptions(options);
24
- const [plainFile, diffFile] = positional;
25
- if (plainFile === undefined || diffFile === undefined) {
26
- console.error(USAGE);
27
- process.exit(1);
28
- }
29
- const refusal = testPlainFileRefusal(plainFile);
30
- if (refusal !== undefined) {
31
- console.error(refusal);
32
- process.exit(1);
33
- }
34
- const diff = readFileSync(diffFile, "utf8");
35
- const cwd = process.cwd();
36
- const applied = applySpecDiff(diff, cwd);
37
- // Every file the diff touched is checked - a test plain file as its module - not only the one named.
38
- const failed = checkTouchedPlain([plainFile, ...plainFilesOf(diff)].map((file) => resolve(cwd, file))).filter((check) => !check.ok);
39
- if (failed.length > 0) {
40
- if (applied === "applied")
41
- revertSpecDiff(diff, cwd);
42
- console.error(`Nothing was changed: with this diff the ***plain no longer checks.\n${formatCheckResults(failed)}`);
43
- process.exit(1);
44
- }
45
- runLoop({
46
- plainFile,
47
- startOver: options["start-over"] !== undefined,
48
- ...(buildDir !== undefined ? { buildDir } : {}),
49
- ...(report !== undefined ? { report } : {}),
50
- command: ["change-plain", ...process.argv.slice(2)],
51
- ask: (loop) => loop.bringUp(plainFile),
52
- }).catch((error) => {
53
- console.error(error instanceof Error ? error.message : error);
54
- process.exit(1);
55
- });
@@ -1 +0,0 @@
1
- export {};