@turri-dev/cli 0.2.4-next.efe96fe → 0.3.0

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 (73) hide show
  1. package/README.md +2 -2
  2. package/dist/chat-skills.d.ts +1 -1
  3. package/dist/chat-skills.js +1 -1
  4. package/dist/chats.d.ts +42 -8
  5. package/dist/chats.js +122 -38
  6. package/dist/cli.js +1 -1
  7. package/dist/config-edit.js +4 -4
  8. package/dist/config.d.ts +48 -11
  9. package/dist/config.js +102 -13
  10. package/dist/extension.d.ts +22 -2
  11. package/dist/extension.js +225 -125
  12. package/dist/genome.js +1 -1
  13. package/dist/host-session.d.ts +6 -5
  14. package/dist/host-session.js +2 -2
  15. package/dist/host.d.ts +2 -0
  16. package/dist/identity.js +2 -2
  17. package/dist/init-config.d.ts +1 -1
  18. package/dist/init-config.js +7 -7
  19. package/dist/launch-agent.d.ts +51 -0
  20. package/dist/launch-agent.js +267 -0
  21. package/dist/{release-cli.js → launch-cli.js} +41 -24
  22. package/dist/launch-session.d.ts +68 -0
  23. package/dist/launch-session.js +217 -0
  24. package/dist/launch-tools.d.ts +28 -0
  25. package/dist/launch-tools.js +69 -0
  26. package/dist/launch-track.d.ts +125 -0
  27. package/dist/launch-track.js +320 -0
  28. package/dist/loop-cli.js +4 -4
  29. package/dist/loop-tools.d.ts +8 -3
  30. package/dist/loop-tools.js +37 -32
  31. package/dist/notice.d.ts +7 -6
  32. package/dist/plain-files.d.ts +2 -2
  33. package/dist/plain-files.js +3 -3
  34. package/dist/regenerate/command-check.d.ts +7 -1
  35. package/dist/regenerate/command-check.js +43 -1
  36. package/dist/regenerate/delivery.d.ts +1 -1
  37. package/dist/regenerate/delivery.js +3 -3
  38. package/dist/regenerate/launch.d.ts +154 -0
  39. package/dist/regenerate/{release.js → launch.js} +195 -51
  40. package/dist/regenerate/ledger.d.ts +32 -1
  41. package/dist/regenerate/lineage.d.ts +2 -0
  42. package/dist/regenerate/lineage.js +8 -0
  43. package/dist/regenerate/loop.d.ts +18 -7
  44. package/dist/regenerate/loop.js +28 -22
  45. package/dist/regenerate/paths.d.ts +2 -2
  46. package/dist/regenerate/paths.js +2 -2
  47. package/dist/self-invocation.js +7 -7
  48. package/dist/sentinel-check.d.ts +3 -3
  49. package/dist/sentinel-check.js +3 -3
  50. package/dist/sentinel.d.ts +18 -12
  51. package/dist/sentinel.js +68 -42
  52. package/docs/README.md +2 -2
  53. package/docs/chats.md +2 -2
  54. package/docs/config.md +9 -9
  55. package/docs/development.md +1 -1
  56. package/docs/headless.md +1 -1
  57. package/docs/hosting.md +14 -13
  58. package/docs/launch.md +67 -0
  59. package/docs/parser.md +1 -1
  60. package/docs/regenerating.md +3 -3
  61. package/docs/sandbox.md +3 -3
  62. package/docs/sentinel.md +24 -12
  63. package/docs/skills-and-gates.md +3 -3
  64. package/docs/using.md +8 -8
  65. package/genome/rules/turri-regeneration.md +1 -1
  66. package/package.json +1 -1
  67. package/dist/regenerate/release.d.ts +0 -121
  68. package/dist/release-agent.d.ts +0 -43
  69. package/dist/release-agent.js +0 -130
  70. package/dist/release-tools.d.ts +0 -44
  71. package/dist/release-tools.js +0 -170
  72. package/docs/deploy.md +0 -48
  73. /package/dist/{release-cli.d.ts → launch-cli.d.ts} +0 -0
package/docs/using.md CHANGED
@@ -28,10 +28,10 @@ While a skill runs, a line above the input shows its phases, every one by name -
28
28
  | `parse` | parse \*\*\*plain - its syntax and structure, never its code or tests - regenerating nothing - a module whose functional specs have scenarios but which has no test reqs, or no conformance testing script, passes with a warning naming the next step (see [the steps of adding tests](regenerating.md#the-steps-of-adding-tests)) |
29
29
  | `settings` | read the project's settings, or change one when you ask - "regenerate with gpt 5.5 from now on" sets `coding-model` - see [below](#choosing-a-model) and [changing it from the chat](config.md#changing-it-from-the-chat) |
30
30
  | `pulses` | pulses in every tense: this session's - finished, running and planned - and the last runs of earlier sessions (`runs` for more), or one of them - a finished one with what the [ledger](#the-ledger) recorded of it: its rounds, test runs, verdicts, healers and commits; one that did not land says why besides, from its transcript: its diagnosis, the stages that went wrong, the last failing test run, the last review, the tool calls that failed. With a module's `plain_file`, a look ahead: its work planned as `regenerate` plans it - the steering with it - and kept, nothing started, its pulses waiting for `regenerate`, `conform` or `/regenerate`, which runs that plan as it is unless the \*\*\*plain or the steering changed since. A planned row's id (`planned-<module>-1`) then gives its cases and - the next pulse of its codebase - the whole prompt its coding agent will get |
31
- | `halt` | halt a pulse, a module's planned pulses, or what `activate` started |
31
+ | `halt` | halt a pulse, a module's planned pulses, a launch, or what a launch started |
32
32
  | `doctor` | turri's self check, as `turri doctor` runs it: Node, bash, git, the OS sandbox, a model provider, and the project's toolchains and testing scripts - against the PATH turri's pulses run with, not the agent's shell's. The project's models are asked for a word only when you ask (a request a model); it changes nothing |
33
33
  | `cultivate` | run a gated skill, its steps and review gates enforced |
34
- | `release`, `activate` | try what is regenerated: release it to `dist/<module>` and activate it on this machine, installing what it needs - see [deploy](deploy.md) |
34
+ | `launch` | try what is regenerated: launched in the background from `dist/<module>` - or as the project's guidance says - on this machine, installing what it needs; told when it is up - see [launch](launch.md) |
35
35
  | `ask_user` | put a question to you as a dialog to pick from - several at once, each a box you tick and untick, "Something else…" to type, or "Chat about this" to talk it over first; Esc in either goes back to the options |
36
36
  | `web_search`, `web_fetch` | search the web and read a page as text - documentation, an API, an error; `curl` and the like run in its `bash` |
37
37
 
@@ -79,14 +79,14 @@ A regeneration takes minutes, so in the TUI every tool that regenerates starts t
79
79
  - **`/settings`** changes a setting of the project's `config.turri.yaml` - the models, review, conformance tests, any key - and says when it takes effect: now, at your next message, or at the next pulse; never only after a restart. It takes [pi](https://pi.dev)'s own `/settings` over, pi's menu the last entry of its list. See [changing it from the chat](config.md#changing-it-from-the-chat).
80
80
  - **`/sentinel`** says whether the [sentinel](sentinel.md) checks every pulse that finishes: `ask` - you are asked before it first opens in a session - `on`, or `off`; written to `config.turri.yaml`.
81
81
  - **`/regenerate [module | file.plain] [module:func-id ...] [from scratch [whole chain]] [how to cut the work]`** regenerates a module from its \*\*\*plain as it is now, as the `regenerate` tool does: what is left to regenerate is planned into pulses - one functional spec at a time, a few together or the whole module in one, as the planner judges - and the first starts. Words after the module are guidance for that plan (`/regenerate app models first`). A module's name typed with spaces for its underscores is that module - `/regenerate d365_function executor` is `d365_function_executor`. With no module named: the one `module:` in `config.turri.yaml` names, else the folder's top modules, to pick from. Asked for from scratch - `from scratch`, `start over`, `delete the module` - it starts at once, with nothing to confirm: it deletes the module's code and conformance tests in every codebase where they live, committed so `/lineage` keeps them, and regenerates the whole module from its \*\*\*plain, built though nothing in it changed: `/regenerate shorty from scratch`. The modules below it keep their code, and the module starts again from a copy of the code below it. Asked for its chain too - `/regenerate shorty from scratch, the whole chain` - the code of every module of its requires chain is deleted, the base's included, and the whole chain is regenerated from the bottom: what to do after modules were split, merged or moved, when the code below was laid out for modules that are no more. The chat's `regenerate` does the same with `from_scratch: "module"` or `"chain"`, when you ask for it; `turri regenerate --from-scratch` or `--from-scratch-chain` on the command line, not with `--dry-run`. Functional specs named after the module, each as `<module>:<func-id>` - `/regenerate shorty shorty:shorten shorty:expand` - are regenerated though their \*\*\*plain did not change, on the coding model: as `turri regenerate shorty.plain shorty:shorten shorty:expand` does, and the chat's `regenerate` with `funcIds`. A bare func-id is refused: the module is always named. Code built before functional specs had func-ids - its record numbers them - is never built on: the module's whole chain has to be regenerated from scratch, and the chat asks you first, as for a start over.
82
- - **`/conform [module | file.plain] [module:func-id ...] [from scratch [whole chain]] [one by one]`** writes and runs a module's conformance tests now, as the `conform` tool does: those of the functional specs named, each as `<module>:<func-id>` - `/conform shorty shorty:shorten shorty:expand` - or, with none named, of every functional spec with scenarios. A functional spec named whose tests are written has them written again, deleted and written anew from its scenarios; `from scratch` takes out the tests folder where the module's code lives - the tip of its chain, never a module in the middle - its lineage keeping it, and writes the tests again from a copy of the tests of the module the tip requires; `from scratch, whole chain`, from nothing. None of it touches the code ([written again](regenerating.md#conformance-tests-in-the-work-loop)). They go in one pulse, as far as a size guardrail lets; `one by one` (or `separately`, `one at a time`) has a pulse a functional spec. No other words are taken: there is no plan to guide. The module is found as `/regenerate` finds it. Asking for them is asking for them on: with conformance tests off, `/conform` turns them on first - `conformance-tests: true`, written where the module's value comes from - and says so: the one way the chat's work has them turned on, as the `conform` tool is refused while they are off. What would start nothing is found from the \*\*\*plain before anything is said - no scenarios, a functional spec named that is not there or has none, a step of adding tests skipped (no test reqs, no conformance testing script) - and turri answers it at once in the chat. What is missing that turri can write - the test reqs, the conformance testing script, the scenarios of the functional specs named, or of each one that needs them - it writes at once, without asking again: your `/conform` was the yes. Then it regenerates the module, and says what it wrote and why. What is yours to settle - a functional spec named that is not there - it tells you, starting nothing. Its tests come before anything is built on it: a codebase built on the module is stopped and deleted, and regenerated from it once they pass. Tests written already for the scenarios as built are said to be, and nothing starts.
83
- - **`/halt <id>`** halts a pulse - a queued one never starts - **`/halt <module>`** (or a planned row's id) halts a module's planned pulses until you ask for it again, a \*\*\*plain change not starting it, and **`/halt activated <name>`** halts a server `activate` started; it lists all three when no id is given.
84
- - **What these commands show you, the chat knows.** What `/regenerate`, `/conform` and `/halt activated` tell you - \*\*\*plain that does not parse, the pulses planned, a server halted - stays in the chat under the command, and since a slash command runs outside the conversation, it is put in the conversation as well: say "fix it" next and turri knows what you are looking at. When `/conform` starts nothing, turri answers it at once - writing what it can of what is missing, and saying why for the rest. Once `/regenerate` or `/conform` has started pulses, turri says so in the chat too - what runs and what is planned, and that you need not wait for it - without starting anything more for it; a module already up to date gets the plan's answer alone. A halted pulse reaches it as every pulse's end does.
82
+ - **`/conform [module | file.plain] [module:func-id ...] [from scratch [whole chain]] [one by one]`** writes and runs a module's conformance tests now, as the `conform` tool does: those of the functional specs named, each as `<module>:<func-id>` - `/conform shorty shorty:shorten shorty:expand` - or, with none named, of every functional spec with scenarios. A functional spec named whose tests are written has them written again, deleted and written anew from its scenarios; `from scratch` takes out the tests folder where the module's code lives - the tip of its chain, never a module in the middle - its lineage keeping it, and writes the tests again from a copy of the tests of the module the tip requires; `from scratch, whole chain`, from nothing. None of it touches the code ([written again](regenerating.md#conformance-tests-in-the-work-loop)). They go in one pulse, as far as a size guardrail lets; `one by one` (or `separately`, `one at a time`) has a pulse a functional spec. No other words are taken: there is no plan to guide. The module is found as `/regenerate` finds it. Asking for them is asking for them on: with conformance tests off, `/conform` turns them on first - `conformance-tests: true`, written where the module's value comes from - and says so: the one way the chat's work has them turned on, as the `conform` tool is refused while they are off. What would start nothing is found from the \*\*\*plain before anything is said. A step of adding tests still to take - no test reqs, no conformance testing script, no scenarios - is not an error: it is what `/conform` needs first, told to turri alone, not shown to you, and turri takes it at once - the test reqs, the conformance testing script, the scenarios of the functional specs named, or of each one that needs them - without asking again: your `/conform` was the yes. Then it regenerates the module, and says what it is writing and why. What is yours to settle - a functional spec named that is not there - is shown to you, and turri tells you what would let it start, starting nothing. Its tests come before anything is built on it: a codebase built on the module is stopped and deleted, and regenerated from it once they pass. Tests written already for the scenarios as built are said to be, and nothing starts.
83
+ - **`/halt <id>`** halts a pulse - a queued one never starts - **`/halt <module>`** (or a planned row's id) halts a module's planned pulses until you ask for it again, a \*\*\*plain change not starting it, and **`/halt launched <name>`** halts a server a launch started - **`/halt launched <module>`** the module's launch under way, the one waiting, and what it started; it lists them all when no id is given.
84
+ - **What these commands show you, the chat knows.** What `/regenerate`, `/conform` and `/halt launched` tell you - \*\*\*plain that does not parse, the pulses planned, a server halted - stays in the chat under the command, and since a slash command runs outside the conversation, it is put in the conversation as well: say "fix it" next and turri knows what you are looking at. When `/conform` starts nothing, turri answers it at once - taking the steps of adding tests still to take, which you are not shown, and saying why for the rest. Once `/regenerate` or `/conform` has started pulses, turri says so in the chat too - what runs and what is planned, and that you need not wait for it - without starting anything more for it; a module already up to date gets the plan's answer alone. A halted pulse reaches it as every pulse's end does.
85
85
  - **Nothing is queued.** What is left to build is worked out from what each codebase is built from and \*\*\*plain as it is now - again whenever a pulse ends or \*\*\*plain changes - and the first pulse of it runs; see [a whole module](regenerating.md#a-whole-module). Changes that overlap never pile up: the next pulse builds \*\*\*plain as it is. The pulses planned after the one running are listed behind it, as queued, and so is each module waiting for the one it is built on - "waits for base" - until it can be planned. A change inside what the running pulse regenerates - a functional spec it regenerates reworded or given a sub-bullet, a definition or req it is given, a file they link - steers it: its agent is told, and it lands \*\*\*plain as it is now there, twice a pulse at most. Otherwise a pulse building something \*\*\*plain no longer wants is stopped and rolled back - unless `allow-to-stop-jobs: false` in `config.turri.yaml`, which has it land first and the change regenerated on top. To drop something, take it out of \*\*\*plain - one \*\*\*plain diff. Stopping a pulse leaves its change in \*\*\*plain: the codebase waits until its \*\*\*plain changes or it is asked for again.
86
86
  - **A change to a module below** is made in the codebase at the tip of the chain, where its code lives; the codebase below is left as it was, and is brought up to its own \*\*\*plain only when a new module is to start from it. \*\*\*plain moved into a module the code was not built on stops the codebase: no change to its code brings that module in, so it has to be started over - its code and conformance tests taken out, kept in its history, and built again from the bottom of the chain. That is never done unasked: the chat asks you, saying why, and regenerates it from scratch once you agree; on the command line `turri regenerate` asks at the terminal, and `--start-over` agrees in advance.
87
87
  - **Conformance tests are a track of their own.** A code pulse lands once its unit tests pass and are reviewed. Then, before the next one builds on it, a conformance pulse writes and runs the tests of what it built - the scenarios of its functional specs, by the test reqs - with the whole suite the module inherits, and, where one fails, fixes the test or the code, whichever is wrong; what they are written for is recorded in `tests/.turri.json`. A functional spec with no test plain file, or an empty one, gets none: to have it tested, ask for conformance tests - or, with them on, the chat writes scenarios itself for a functional spec it judges needs them (when an incorrect implementation could give output that looks right but is wrong, when two reasonable readings of its text answer some input differently, or when a bug would be costly - money, security, data, users' trust) - either way the chat writes its scenarios with its file tools and calls `regenerate`, and the loop tests them once the code is built. `conform` runs them now, for a module or some of its functional specs. A conformance pulse that does not pass is undone whole and halts the conformance tests alone: the code goes on being built.
88
88
  - **A pulse that fails** - its work errors, or it does not pass - is run once more; one stopped on what only you can fix - the machine lacks something, a testing script no code could pass - is not. Failing again, it stops, and so does every pulse queued behind it on the same module, without running - the other modules' pulses go on. The harness then works out why: an agent that can read the project's \*\*\*plain, code, tests, testing scripts and logs, and turri's own source, skills and rules, says what happened, why, whether the fix belongs in \*\*\*plain, the environment, the code or turri itself, and exactly what to do.
89
- - **When a pulse finishes** the transcript shows its line - `✓`, `✗` or `■`, its module, kind and number, how long it took and what it cost, never what it regenerated - `✓ shorty · conformance pulse 4 finished after 3m 47s · 488.6k tok · $0.02` - and the chat, which gets its whole report, reacts then and there, whatever else is running or queued, without waiting for you to speak: at once when it is idle, else as soon as the reply it is in ends. It does what the project's guidance says to do when a pulse finishes - release what was built, say - or tells you what finished and what it means. Ask to try it ("let me try it") and the chat releases what is built to `dist/<module>` and starts it on your machine, even while other pulses run. See [deploy](deploy.md). The chat reacts to it then and there, whatever else is running or queued, without waiting for you to speak - at once when it is idle, else as soon as the reply it is in ends: it does what the project's guidance says to do when a pulse finishes (release what was built, say), or tells you in a line or two what finished.
89
+ - **When a pulse finishes** the transcript shows its line - `✓`, `✗` or `■`, its module, kind and number, how long it took and what it cost, never what it regenerated - `✓ shorty · conformance pulse 4 finished after 3m 47s · 488.6k tok · $0.02` - and the chat, which gets its whole report, reacts then and there, whatever else is running or queued, without waiting for you to speak: at once when it is idle, else as soon as the reply it is in ends. It does what the project's guidance says to do when a pulse finishes - launch what was built, say - or tells you what finished and what it means. Ask to try it ("let me try it") and the chat launches what is built: in the background, from `dist/<module>`, on your machine, even while other pulses run - you are told where it runs once it is up. See [launch](launch.md). The chat reacts to it then and there, whatever else is running or queued, without waiting for you to speak - at once when it is idle, else as soon as the reply it is in ends: it does what the project's guidance says to do when a pulse finishes (launch what was built, say), or tells you in a line or two what finished.
90
90
  - **When a pulse stops** - a gate still failing after 20 attempts - it says where it stopped, why in plain words, and what to change in \*\*\*plain - which section, and how. Running the same build again picks up from there.
91
91
 
92
92
  In `print`, `json` and `rpc` modes the process ends when the answer is written, so the tools wait for the work there instead. Pulses live in memory for the session; the work itself is on disk.
@@ -132,7 +132,7 @@ A provider failure - no credits, bad key, rate limit - is raised with the provid
132
132
 
133
133
  ### Models from a pi extension
134
134
 
135
- A provider a [pi](https://pi.dev) extension registers - a Claude subscription through Claude Code ([pi-claude-code](https://github.com/earendil-works/pi-claude-code), `claude-code/...`, see [a Claude subscription](claude-subscription.md)), your company's own LLM gateway - works everywhere turri needs a model. Install the extension with `turri install <source>` - pi's own `install`, run by the pi inside turri, so no `pi` of your own is needed; `turri list`, `turri update <source>` and `turri remove <source>` are pi's too - and name its models in `config.turri.yaml` as any. In the chat, pi loads it, and every agent the conversation starts is given the providers the conversation's extensions registered, as they are when it starts - the agents themselves load no extensions, which would load a second copy of turri. A run with no conversation - `turri regenerate`, `turri conform`, `turri release` and the rest - loads the installed extensions itself, once, as pi loads them, and keeps only the providers they register; so do `turri doctor` and `turri init-config`, which check a model against them. An older turri that installed itself into every pi is among them, and is loaded as nothing.
135
+ A provider a [pi](https://pi.dev) extension registers - a Claude subscription through Claude Code ([pi-claude-code](https://github.com/earendil-works/pi-claude-code), `claude-code/...`, see [a Claude subscription](claude-subscription.md)), your company's own LLM gateway - works everywhere turri needs a model. Install the extension with `turri install <source>` - pi's own `install`, run by the pi inside turri, so no `pi` of your own is needed; `turri list`, `turri update <source>` and `turri remove <source>` are pi's too - and name its models in `config.turri.yaml` as any. In the chat, pi loads it, and every agent the conversation starts is given the providers the conversation's extensions registered, as they are when it starts - the agents themselves load no extensions, which would load a second copy of turri. A run with no conversation - `turri regenerate`, `turri conform`, `turri launch` and the rest - loads the installed extensions itself, once, as pi loads them, and keeps only the providers they register; so do `turri doctor` and `turri init-config`, which check a model against them. An older turri that installed itself into every pi is among them, and is loaded as nothing.
136
136
 
137
137
  ## Module history
138
138
 
@@ -200,7 +200,7 @@ turri conform <file.plain> app:add-task # black-box tests for one functional s
200
200
  turri conform <file.plain> --from-scratch # its tests folder taken out and written again; --from-scratch-chain, from nothing
201
201
  turri lineage <module> # what each regeneration changed in a module, and when
202
202
  turri cultivate debug-specs # run a skill directly - by name, the project's too, or by its folder
203
- turri release <file.plain> # release what is regenerated to dist/<module>, and activate it here
203
+ turri launch <file.plain> # launch what is regenerated from dist/<module>, here
204
204
  ```
205
205
 
206
206
  `turri cultivate` runs a skill on the project's harness model, as the chat does, unless `--model` names another. The ones that build take `--model provider/model-id`; `regenerate` also takes `--build-dir` and `--dry-run`, which looks ahead as `pulses` does in the chat - plans the work as `regenerate` would, prints the prompt of each codebase's next pulse from that plan, and starts and writes nothing - so not with `--from-scratch` or functional specs named, which change the code or its record before anything is planned. Template directories come from `PLAIN_TEMPLATE_DIRS`. `--help` on any of them lists the rest.
@@ -56,7 +56,7 @@ The other rules say what a spec means. This one says what turri does with a chan
56
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
57
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
58
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
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 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
60
60
 
61
61
  ## Where the cost is
62
62
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@turri-dev/cli",
3
- "version": "0.2.4-next.efe96fe",
3
+ "version": "0.3.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "repository": {
@@ -1,121 +0,0 @@
1
- import { type ChainEntry } from "./requires.ts";
2
- /**
3
- * Deploy: a module's code, as its last commit has it, put out in `dist/<module>` for the person to try.
4
- *
5
- * A render works in `plain_modules/<module>/code` while the person asks to try what is there, so what
6
- * is there is half-written. Its last commit is not: every unit of work starts from one and ends with
7
- * one, and both are runnable. So the commit is exported - git's own list of what it tracks, and
8
- * nothing else - which is a copy of the working tree with every unstaged and untracked change put
9
- * back, without a list of what each stack leaves lying around (`node_modules`, `.venv`, `target`). The
10
- * working tree itself is never read or touched.
11
- *
12
- * What starts it runs here, on the person's machine, unfenced: a server the person opens in their
13
- * browser, with their toolchains. The agent that releases it installs and runs what it needs itself,
14
- * as any agent with a shell would - nothing is put to the person - and everything started is the
15
- * harness's to stop: on a redeploy, on /halt, and when turri exits.
16
- */
17
- /**
18
- * How a module is released - always from its last commit, exported to `dist/<module>` first. `dist`, the default: started
19
- * from there. `guided`: taken on from there as there is guidance to - the person's, the project's AGENTS.md, a skill -
20
- * into the host codebase, say.
21
- */
22
- export type ReleaseWay = "dist" | "guided";
23
- export interface Deployment {
24
- moduleName: string;
25
- plainFile: string;
26
- way: ReleaseWay;
27
- /** `dist/<module>`, in the project: the module's last commit, exported. */
28
- dir: string;
29
- /** Guided: the host codebase the guidance takes the code into, and what release runs and starts runs from. */
30
- hostDir?: string;
31
- /** Where the module's code is built: `plain_modules/<module>/code`. */
32
- buildDir: string;
33
- commit: string;
34
- /** The commit's subject: what the last unit of work that landed did. */
35
- subject: string;
36
- /** When, as git says it: "3 minutes ago". */
37
- when: string;
38
- /** Work under way in the module - changes nobody committed yet - left out. */
39
- unfinished: boolean;
40
- /** The module the spec's code lives in had nothing committed yet: the nearest one below it that had, instead. */
41
- instead?: string;
42
- /** When the release tool shipped it: what it started since is this release's. */
43
- at?: number;
44
- }
45
- /**
46
- * Which module to deploy for a spec: the tip of its codebase - code accumulates up a requires chain, so
47
- * the top module holds everything below it. Before the tip has anything committed, the nearest module
48
- * below it that has.
49
- */
50
- export declare function deployTarget(plainFile: string, inModule?: string): {
51
- entry: ChainEntry;
52
- commit: string;
53
- instead?: string;
54
- };
55
- /**
56
- * Export the module's code at its last commit into `dist/<module>` - or `into`, `turri regenerate --build-dir` -
57
- * replacing whatever was there, the harness's own files (what the code is built from, the agents' notes) left out.
58
- */
59
- export declare function exportModule(plainFile: string, inModule?: string, into?: string): Deployment;
60
- /**
61
- * The host codebase a guided release works in: the git repository the project is in - an embedded project's host -
62
- * or else `fallback`, where turri runs.
63
- */
64
- export declare function hostDirOf(plainFile: string, fallback: string): string;
65
- /** Where a path is, said from the current directory when it is below it. */
66
- export declare function shortPath(path: string): string;
67
- /** What was deployed, in a line or three. */
68
- export declare function describeDeployment(deployment: Deployment): string;
69
- export interface DeployedProcess {
70
- name: string;
71
- moduleName: string;
72
- command: string;
73
- /** Where it runs. */
74
- dir: string;
75
- url?: string;
76
- /** Its output, both streams. */
77
- log: string;
78
- pid: number;
79
- startedAt: number;
80
- /** Set once it has ended. */
81
- exited?: {
82
- code: number | null;
83
- signal: string | null;
84
- };
85
- }
86
- /** Everything deploy started, running or ended, oldest first. */
87
- export declare function listDeployed(): DeployedProcess[];
88
- /** The ones still running. */
89
- export declare function runningDeployed(moduleName?: string): DeployedProcess[];
90
- /** Where a project's deployed processes write their output: its scratch, not the code in dist. */
91
- export declare function deployLogDir(projectDir: string): string;
92
- /** The end of a log, for when something did not come up. */
93
- export declare function logTail(log: string, lines?: number, chars?: number): string;
94
- /** Stop one deployed process, or every one of a module, or every one: politely, then not. Returns the names stopped. */
95
- export declare function stopDeployed(which?: {
96
- name?: string;
97
- moduleName?: string;
98
- }): Promise<string[]>;
99
- /** Stop everything at once, without waiting: for when turri itself is going. */
100
- export declare function stopAllDeployedNow(): void;
101
- /** How long a server is given to answer at its URL, and to stay up when it has none. */
102
- export declare const READY_TIMEOUT_MS: number;
103
- export interface StartResult {
104
- ok: boolean;
105
- /** What happened, for the agent and the person. */
106
- text: string;
107
- process?: DeployedProcess;
108
- }
109
- /**
110
- * Start what keeps running, in `dir` - the deployed folder `root`, or one inside it. A folder that is not there starts
111
- * nothing: said, with what the deployed folder holds, so the agent can name the right one.
112
- */
113
- export declare function startDeployed(input: {
114
- name: string;
115
- command: string;
116
- dir: string;
117
- moduleName: string;
118
- logDir: string;
119
- url?: string;
120
- root?: string;
121
- }): Promise<StartResult>;
@@ -1,43 +0,0 @@
1
- import { type ToolDefinition } from "@earendil-works/pi-coding-agent";
2
- import { type DeployState } from "./release-tools.ts";
3
- /**
4
- * The agent that releases a module on its own - `turri release`'s, and a pulse's last stage under
5
- * `release-after-pulse: true`, which is the word to release: the guidance it finds as the chat does - what it was told,
6
- * the project's AGENTS.md, its skills - says only how. It passes it to `release`, and does what it says, asking no one.
7
- */
8
- type AnyTool = ToolDefinition<any, any, any>;
9
- /**
10
- * The person's own shell, in the deployed folder: it installs what the release needs into the project, and runs it. It
11
- * changes nothing of the machine's - no toolchain installed, no system setting changed: a command that would is refused.
12
- */
13
- export declare function releaseShell(dir: string): AnyTool;
14
- /**
15
- * What the project says of itself, for the agent to find release guidance in: its AGENTS.md and its skills
16
- * (`.agents/skills`, `.pi/skills`, `.claude/skills`), where turri runs and in the host codebase - once each, whole.
17
- */
18
- export declare function projectNotes(dirs: string[]): string[];
19
- export interface ReleaseAgentInput {
20
- plainFile: string;
21
- /** Where turri runs. */
22
- cwd: string;
23
- /** The agent's model: the harness model. */
24
- model?: string;
25
- /** What release has shipped and been told this conversation - shared with the chat's release. */
26
- state: DeployState;
27
- inModule?: string;
28
- /** What the person said of how to release it. */
29
- guidance?: string;
30
- /** Released as a pulse's last stage: what the pulse landed. The setting has said to release it; the guidance says how. */
31
- afterPulse?: {
32
- moduleName: string;
33
- subject: string;
34
- };
35
- /** Released for the sentinel to check functional specs of the module in: asked for, so released; the guidance says how. */
36
- forCheck?: {
37
- moduleName: string;
38
- };
39
- onDelta?: (delta: string) => void;
40
- }
41
- /** Run the release agent to its end; its last reply. */
42
- export declare function runReleaseAgent(input: ReleaseAgentInput): Promise<string>;
43
- export {};
@@ -1,130 +0,0 @@
1
- import { existsSync, readdirSync, readFileSync } from "node:fs";
2
- import { join, relative, resolve, sep } from "node:path";
3
- import { createBashToolDefinition, createEditToolDefinition, createFindToolDefinition, createGrepToolDefinition, createLsToolDefinition, createReadToolDefinition, createWriteToolDefinition, } from "@earendil-works/pi-coding-agent";
4
- import { createDeployTools, DEPLOY_TOOLS } from "./release-tools.js";
5
- import { hostDirOf, shortPath } from "./regenerate/release.js";
6
- import { machineChange, machineChangeReason } from "./regenerate/command-check.js";
7
- import { projectDirOf } from "./regenerate/paths.js";
8
- import { ask, BEGIN, createExecutor } from "./pi.js";
9
- /**
10
- * The person's own shell, in the deployed folder: it installs what the release needs into the project, and runs it. It
11
- * changes nothing of the machine's - no toolchain installed, no system setting changed: a command that would is refused.
12
- */
13
- export function releaseShell(dir) {
14
- const bash = createBashToolDefinition(dir);
15
- return {
16
- ...bash,
17
- description: `${bash.description}\n\nIt runs on the person's own machine, in ${shortPath(dir)}. Never start a server here: activate does. It installs nothing on the machine and changes none of its settings: what the machine lacks, the person installs.`,
18
- async execute(toolCallId, params, signal, onUpdate, ctx) {
19
- const changes = machineChange(String(params.command ?? ""));
20
- if (changes !== undefined)
21
- throw new Error(machineChangeReason(changes));
22
- return bash.execute(toolCallId, params, signal, onUpdate, ctx);
23
- },
24
- };
25
- }
26
- /** A file tool that writes, refused inside plain_modules: the built code is the spec's to change, never a release's. */
27
- function outsideBuiltCode(tool, dir) {
28
- return {
29
- ...tool,
30
- async execute(toolCallId, params, signal, onUpdate, ctx) {
31
- const path = resolve(dir, String(params.path ?? ""));
32
- if (relative(dir, path).split(sep).includes("plain_modules")) {
33
- throw new Error(`Not written: ${shortPath(path)} is built code. A release never changes it - a fix belongs in the spec.`);
34
- }
35
- // The ***plain - a module, a test plain file - is the person's: a release that finds it wrong says so, never rewrites it.
36
- if (path.endsWith(".plain")) {
37
- throw new Error(`Not written: ${shortPath(path)} is ***plain. A release never changes it - say what is wrong with it instead.`);
38
- }
39
- return tool.execute(toolCallId, params, signal, onUpdate, ctx);
40
- },
41
- };
42
- }
43
- function shown(file, max = 40_000) {
44
- const text = readFileSync(file, "utf8");
45
- const body = text.length > max ? `${text.slice(0, max)}\n… [the rest of ${shortPath(file)} is not shown]` : text;
46
- return `<file path="${shortPath(file)}">\n${body.trimEnd()}\n</file>`;
47
- }
48
- /**
49
- * What the project says of itself, for the agent to find release guidance in: its AGENTS.md and its skills
50
- * (`.agents/skills`, `.pi/skills`, `.claude/skills`), where turri runs and in the host codebase - once each, whole.
51
- */
52
- export function projectNotes(dirs) {
53
- const roots = [...new Set(dirs.map((dir) => resolve(dir)))];
54
- const files = new Set();
55
- for (const root of roots) {
56
- const agents = join(root, "AGENTS.md");
57
- if (existsSync(agents))
58
- files.add(agents);
59
- for (const skills of [".agents/skills", ".pi/skills", ".claude/skills"].map((folder) => join(root, folder))) {
60
- if (!existsSync(skills))
61
- continue;
62
- for (const name of readdirSync(skills)) {
63
- const skill = join(skills, name, "SKILL.md");
64
- if (existsSync(skill))
65
- files.add(skill);
66
- }
67
- }
68
- }
69
- return [...files].map((file) => shown(file));
70
- }
71
- /** Run the release agent to its end; its last reply. */
72
- export async function runReleaseAgent(input) {
73
- const { plainFile } = input;
74
- const tools = createDeployTools({ cwd: input.cwd, state: input.state, defaultPlainFile: () => plainFile });
75
- // It releases from the host codebase, which holds dist too.
76
- const dir = hostDirOf(plainFile, input.cwd);
77
- const notes = projectNotes([input.cwd, dir, projectDirOf(plainFile)]);
78
- const said = input.guidance ?? input.state.guidance.get(input.afterPulse?.moduleName ?? "");
79
- const fileTools = [
80
- createReadToolDefinition(dir),
81
- createLsToolDefinition(dir),
82
- createGrepToolDefinition(dir),
83
- createFindToolDefinition(dir),
84
- // A guided release may say to change the host - a registration, an import.
85
- outsideBuiltCode(createEditToolDefinition(dir), dir),
86
- outsideBuiltCode(createWriteToolDefinition(dir), dir),
87
- ];
88
- const executor = await createExecutor({
89
- // Its sessions are kept in the project, not in the folder it deploys.
90
- cwd: projectDirOf(plainFile),
91
- customTools: [...fileTools, releaseShell(dir), ...tools],
92
- tools: [...fileTools.map((tool) => tool.name), "bash", ...DEPLOY_TOOLS],
93
- ...(input.model !== undefined ? { model: input.model } : {}),
94
- role: "release",
95
- system: [
96
- "You get software that was just built running on the person's own machine, so they can try it. You ask no one: do it.",
97
- `Your file tools and your shell start in ${dir}. Your shell is the person's own - not a sandbox.`,
98
- ].join("\n"),
99
- task: [
100
- input.afterPulse !== undefined
101
- ? `A pulse of module ${input.afterPulse.moduleName} just landed: ${input.afterPulse.subject}. Release it now, before the module's next pulse starts: the project releases after every pulse.`
102
- : input.forCheck !== undefined
103
- ? `The person asked turri's sentinel to check functional specs of module ${input.forCheck.moduleName} in its release, and what runs of it is not its last commit. Release its last commit now, for the sentinel to test.`
104
- : `Release ${shortPath(plainFile)} for the person to try, with the release tool, then do what it says.`,
105
- "",
106
- "First ask yourself: is there guidance for how this project releases it - what the person said below, the project's",
107
- "notes and skills below, or anything else you find? If there is, call release with it as guidance, in full: the code is",
108
- "put in dist/<module>, and the guidance takes it on from there. If there is none, call release without guidance: the",
109
- "code is put in dist/<module> and started from there, as best it can be.",
110
- ...(input.afterPulse !== undefined || input.forCheck !== undefined
111
- ? [
112
- "",
113
- `Release it whether or not the guidance speaks of releasing ${input.afterPulse !== undefined ? "after a build - the project's setting has said to" : "for a check - the person asked for it"}. What`,
114
- "the guidance says is how. When release says it is already released, leave it at that.",
115
- ]
116
- : []),
117
- ...(input.inModule !== undefined ? ["", `Release the codebase of module ${input.inModule}: pass in_module.`] : []),
118
- ...(said !== undefined ? ["", "What the person said of how to release it:", said] : []),
119
- ...(notes.length > 0 ? ["", "The project's notes and skills:", ...notes] : []),
120
- "",
121
- "End with what you did, in a line or two: where it runs, or why nothing was released.",
122
- ].join("\n"),
123
- });
124
- try {
125
- return await ask(executor, BEGIN, input.onDelta);
126
- }
127
- finally {
128
- executor.dispose();
129
- }
130
- }
@@ -1,44 +0,0 @@
1
- import { type Deployment } from "./regenerate/release.ts";
2
- import type { JobRegistry } from "./regenerate/jobs.ts";
3
- import type { WorkLoop } from "./regenerate/loop.ts";
4
- /**
5
- * The tools that put a module out for the person to try, and start it: the conversation's, and the
6
- * one-off agent's of `turri release`. The harness does the parts that must hold - exporting the
7
- * last commit, owning what it starts - and the agent the rest: reading the code to see how it runs,
8
- * installing what it needs, starting it, and telling the person where to find it. Nothing is put to
9
- * the person: a release does everything itself.
10
- */
11
- export interface DeployState {
12
- /** The last deploy: where what is started runs from. */
13
- current?: Deployment;
14
- /** The last release of each module in this conversation, by module: the commit it shipped. */
15
- released: Map<string, Deployment>;
16
- /** The guidance each module was last released with, by module: what a release after a pulse is told the person said. */
17
- guidance: Map<string, string>;
18
- }
19
- export declare function createDeployState(): DeployState;
20
- /**
21
- * A module's release as it stands, when it is current: its own codebase's last commit is what the last release shipped,
22
- * and nothing that release started has ended. Undefined when it is behind, was never made, or what it started died -
23
- * then it is released again.
24
- */
25
- export declare function currentRelease(state: DeployState, plainFile: string, moduleName: string): Deployment | undefined;
26
- /** What the agent is to do once the code is in dist - in the deploy tool's answer, and the CLI agent's prompt. */
27
- export declare function deployGuide(dir: string): string;
28
- /**
29
- * What the agent is to do on a guided release: the code is in dist, as on any release, and the guidance takes it on from
30
- * there. The rules of a release to dist hold here too: what keeps running started with activate, and the built code never
31
- * edited - and nothing put to the person.
32
- */
33
- export declare function guidedGuide(deployment: Deployment, guidance: string): string;
34
- export declare function createDeployTools(options: {
35
- cwd: string;
36
- state: DeployState;
37
- /** The spec deploy takes when it is given none: the project's module. */
38
- defaultPlainFile: () => string | undefined;
39
- /** The pulses halt stops as well - the conversation's. */
40
- jobs?: JobRegistry;
41
- /** The work loop whose modules halt halts by a planned row or a name - the conversation's, once it has one. */
42
- workLoop?: () => WorkLoop | undefined;
43
- }): import("@earendil-works/pi-coding-agent").ToolDefinition<any, any, any>[];
44
- export declare const DEPLOY_TOOLS: string[];
@@ -1,170 +0,0 @@
1
- import { isAbsolute, relative, resolve } from "node:path";
2
- import { refuseTestPlainFile } from "./test-plain-files.js";
3
- import { defineTool } from "@earendil-works/pi-coding-agent";
4
- import { Type } from "typebox";
5
- import { deployLogDir, deployTarget, describeDeployment, exportModule, hostDirOf, listDeployed, shortPath, startDeployed, stopDeployed, } from "./regenerate/release.js";
6
- import { projectDirOf } from "./regenerate/paths.js";
7
- import { haltTool } from "./loop-tools.js";
8
- export function createDeployState() {
9
- return { released: new Map(), guidance: new Map() };
10
- }
11
- /**
12
- * A module's release as it stands, when it is current: its own codebase's last commit is what the last release shipped,
13
- * and nothing that release started has ended. Undefined when it is behind, was never made, or what it started died -
14
- * then it is released again.
15
- */
16
- export function currentRelease(state, plainFile, moduleName) {
17
- let target;
18
- try {
19
- target = deployTarget(plainFile, moduleName);
20
- }
21
- catch {
22
- return undefined;
23
- }
24
- const last = state.released.get(moduleName);
25
- if (target.entry.moduleName !== moduleName || last === undefined || !target.commit.startsWith(last.commit))
26
- return undefined;
27
- const started = listDeployed().filter((item) => item.moduleName === moduleName && (last.at === undefined || item.startedAt >= last.at));
28
- return started.some((item) => item.exited !== undefined) ? undefined : last;
29
- }
30
- /** What the agent is to do once the code is in dist - in the deploy tool's answer, and the CLI agent's prompt. */
31
- export function deployGuide(dir) {
32
- const where = shortPath(dir);
33
- return [
34
- `What to do now, to have the person try it - it runs on this machine, outside the sandbox, from ${where}:`,
35
- `1. Find out how it runs: its README, its manifests (package.json, pyproject.toml, requirements.txt, go.mod, Cargo.toml, pom.xml, build.gradle, docker-compose.yml) and entry points, in ${where}.`,
36
- "2. Check the toolchains it needs are on this machine (`command -v node`, `python3 --version`, `go version`, ...) - under another name too: python where python3 is not, of the version it needs. One missing: you install nothing on the machine and change none of its settings - stop, and tell the person exactly what to install, the command they run themselves (`brew install node`), and that releasing again picks it up.",
37
- "3. Install what it needs into the project yourself, in your shell - dependencies into a virtual environment or node_modules, a build that fetches packages, an image pull. Do not ask the person: do it, and fix what fails - within the project: never a global install, never a system setting.",
38
- "4. Start anything that keeps running - a backend, a frontend's dev server - with activate, with the URL it serves at: never in the shell with & or nohup. An app with a backend and a frontend: start both, the backend first.",
39
- "5. Then tell the person, briefly. Something that serves: only where to open it - the frontend's URL, and the API's in one line when there is one. A CLI or a library: a few commands to paste, run from the folder, with what they print. A port that is taken: say which and by what, and do not move the app to another.",
40
- `Do not change the code in ${where} - it is a copy of what was built, and a fix belongs in the spec. A config file it needs made from its example (a .env from .env.example) is fine.`,
41
- ].join("\n");
42
- }
43
- /**
44
- * What the agent is to do on a guided release: the code is in dist, as on any release, and the guidance takes it on from
45
- * there. The rules of a release to dist hold here too: what keeps running started with activate, and the built code never
46
- * edited - and nothing put to the person.
47
- */
48
- export function guidedGuide(deployment, guidance) {
49
- const host = shortPath(deployment.hostDir ?? deployment.dir);
50
- const dist = shortPath(deployment.dir);
51
- const built = shortPath(deployment.buildDir);
52
- return [
53
- "The guidance for releasing it - follow it:",
54
- guidance.trim(),
55
- "",
56
- `What to do now - on this machine, outside the sandbox, from ${host}:`,
57
- `1. The code to release is in ${dist}: the last commit that landed whole. Take it from there, never from ${built}, where a pulse may be writing. Where the guidance's own tooling reads ${built}, point it at ${dist} if it can take another source; if it cannot, do by hand, from ${dist}, what it does.`,
58
- `2. Read what the guidance leaves open - the scripts, files and commands it names, in ${host} - then do what it says, in its order. Where it says to change the host - a registration, an import, a config entry - change it. Never change ${built} or ${dist}: a fix to the code belongs in the spec.`,
59
- "3. Run the project's scripts and install what it needs into the project yourself, in your shell. Do not ask the person: do it, and fix what fails. A toolchain or system tool the machine lacks you never install, nor change a setting of the machine's: tell the person the command they run themselves.",
60
- "4. Start what keeps running - a start script, a dev server - with activate, with the URL it serves at - never in the shell with & or nohup.",
61
- `5. Then tell the person briefly: what was done, what you changed in ${host} if anything, and where to open it or how to try it. Where the guidance does not fit what you find, say so, and do not guess past it.`,
62
- ].join("\n");
63
- }
64
- function text(value, details = {}) {
65
- return { content: [{ type: "text", text: value }], details };
66
- }
67
- /** The folder a command runs in: dist's, or - guided - the host codebase's, or one inside either. */
68
- function inside(current, dir) {
69
- const base = current.hostDir ?? current.dir;
70
- const target = resolve(base, dir ?? ".");
71
- const within = (root) => {
72
- const rel = relative(root, target);
73
- return !rel.startsWith("..") && !isAbsolute(rel);
74
- };
75
- if (!within(base) && !within(current.dir))
76
- throw new Error(`${dir} is outside ${shortPath(base)}: what release starts runs from there.`);
77
- return target;
78
- }
79
- export function createDeployTools(options) {
80
- const { state } = options;
81
- const needsDeploy = () => {
82
- if (state.current === undefined)
83
- throw new Error("Nothing is released yet: call release first.");
84
- return state.current;
85
- };
86
- const deploy = defineTool({
87
- name: "release",
88
- label: "Release",
89
- description: "Release a module's code for the person to try - the module on top of the spec's requires chain, which holds the " +
90
- "code of the ones below - stopping whatever an earlier release of it started. Before you call it, ask yourself: is " +
91
- "there guidance for releasing this project - in what the person said, the project's AGENTS.md, a skill, or anything " +
92
- "else you were given? An integration a host application loads, say, released with the host's own scripts. If there " +
93
- "is, pass it as guidance, in full. Either way its last commit - what last landed whole - is exported to dist/<module> " +
94
- "first; with guidance it is taken on from there as the guidance says, in the host codebase; without, it is started " +
95
- "from there, as best it can be. Call it when the " +
96
- "person wants to try, run, see or use what was built, and whenever guidance says to release after a pulse: when " +
97
- "the module's last commit is already released it does nothing and says so, so never decide that yourself. It says " +
98
- "what to do next.",
99
- promptSnippet: "release the regenerated code for the person to try - as the project's release guidance says, or to dist/<module> - then activate it",
100
- parameters: Type.Object({
101
- plain_file: Type.Optional(Type.String({ description: "A .plain file of the module. Default: the project's module from config.turri.yaml." })),
102
- in_module: Type.Optional(Type.String({ description: "The codebase to take, when modules built on this one branch" })),
103
- again: Type.Optional(Type.Boolean({ description: "Release even when the module's last commit is already released - only when what the last release said to do was not done." })),
104
- guidance: Type.Optional(Type.String({ description: "The guidance for releasing this project, whole, from wherever it is - the person, AGENTS.md, a skill: the scripts to run and in which order, where the code goes. Omit when there is none." })),
105
- }),
106
- async execute(_id, params) {
107
- const named = params.plain_file ?? options.defaultPlainFile();
108
- if (named === undefined)
109
- throw new Error("Which spec? config.turri.yaml names no module: pass plain_file.");
110
- const plainFile = resolve(options.cwd, named);
111
- refuseTestPlainFile(plainFile);
112
- const target = deployTarget(plainFile, params.in_module);
113
- const guidance = params.guidance?.trim() || undefined;
114
- // Released already: the module's last commit is what the last release shipped. Nothing is exported or stopped -
115
- // releasing it again would only restart what runs - so it is safe to call after every pulse.
116
- const last = state.released.get(target.entry.moduleName);
117
- if (last !== undefined && !params.again && target.commit.startsWith(last.commit) && last.way === (guidance === undefined ? "dist" : "guided")) {
118
- state.current = last;
119
- return text(`Already released: ${target.entry.moduleName}'s last commit, ${last.commit} (${last.subject}), is what the last release shipped, and what that release said to do was done then. Nothing to do - what runs is left running. Say so in a line.`, { module: last.moduleName, commit: last.commit, already: true });
120
- }
121
- // What the last release started runs from what is about to be replaced.
122
- const stopped = await stopDeployed({ moduleName: target.entry.moduleName });
123
- // Always the last commit, clean, in dist first; guidance takes it on from there.
124
- const exported = exportModule(plainFile, params.in_module);
125
- const deployment = guidance === undefined ? exported : { ...exported, way: "guided", hostDir: hostDirOf(plainFile, options.cwd) };
126
- state.current = deployment;
127
- state.released.set(deployment.moduleName, { ...deployment, at: Date.now() });
128
- if (guidance !== undefined)
129
- state.guidance.set(deployment.moduleName, guidance);
130
- return text([
131
- describeDeployment(deployment),
132
- ...(stopped.length > 0 ? [`Stopped what the last release started: ${stopped.join(", ")}.`] : []),
133
- "",
134
- guidance === undefined ? deployGuide(deployment.dir) : guidedGuide(deployment, guidance),
135
- ].join("\n"), { module: deployment.moduleName, way: deployment.way, dir: deployment.dir, ...(deployment.hostDir !== undefined ? { host: deployment.hostDir } : {}), commit: deployment.commit });
136
- },
137
- });
138
- const startTool = defineTool({
139
- name: "activate",
140
- label: "Activate",
141
- description: "Start something that keeps running - a backend, a frontend's dev server - from the deployed folder, on this " +
142
- "machine: in the background, its output kept, stopped on the next release, on /halt and when turri exits. " +
143
- "With `url`, waits until something answers there and says so, or shows the end of its output. A port something " +
144
- "else holds is said, and nothing is started.",
145
- promptSnippet: "start a server of the deployed code, and wait for it to answer",
146
- parameters: Type.Object({
147
- name: Type.String({ description: "A short name for it: backend, frontend, app" }),
148
- command: Type.String({ description: "The command that starts it, as run from its folder" }),
149
- url: Type.Optional(Type.String({ description: "Where it serves, e.g. http://localhost:5173 - it is ready once this answers" })),
150
- dir: Type.Optional(Type.String({ description: "The folder to run it in, relative to the deployed folder - e.g. frontend - never the project's path to the deployed folder (dist/<module>). Default: the deployed folder itself." })),
151
- }),
152
- async execute(_id, params) {
153
- const current = needsDeploy();
154
- const started = await startDeployed({
155
- name: params.name,
156
- command: params.command,
157
- dir: inside(current, params.dir),
158
- root: current.hostDir ?? current.dir,
159
- moduleName: current.moduleName,
160
- logDir: deployLogDir(projectDirOf(current.plainFile)),
161
- ...(params.url !== undefined ? { url: params.url } : {}),
162
- });
163
- return text(started.text, { ok: started.ok, ...(started.process !== undefined ? { pid: started.process.pid, log: started.process.log } : {}) });
164
- },
165
- });
166
- // The one halt: with the pulses in the conversation, and without them for the release agent.
167
- const stopTool = haltTool(options.jobs !== undefined ? { jobs: options.jobs, ...(options.workLoop !== undefined ? { workLoop: options.workLoop } : {}) } : {});
168
- return [deploy, startTool, stopTool];
169
- }
170
- export const DEPLOY_TOOLS = ["release", "activate", "halt"];