@turri-dev/cli 0.1.3-next.f74e98a → 0.1.4-next.172be6f

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 (46) hide show
  1. package/README.md +22 -1
  2. package/dist/ask.js +34 -15
  3. package/dist/cli-options.js +12 -6
  4. package/dist/config-edit.js +1 -0
  5. package/dist/config.js +5 -2
  6. package/dist/extension.js +86 -25
  7. package/dist/genome.js +1 -1
  8. package/dist/init-config.js +5 -0
  9. package/dist/loop-cli.js +13 -1
  10. package/dist/loop-tools.js +31 -12
  11. package/dist/pi-launch.js +5 -0
  12. package/dist/pi.js +48 -19
  13. package/dist/question-dialog.js +9 -3
  14. package/dist/questioning.js +1 -1
  15. package/dist/regenerate/activity.js +14 -0
  16. package/dist/regenerate/conform.js +5 -5
  17. package/dist/regenerate/conformance-agents.js +28 -8
  18. package/dist/regenerate/conformance.js +24 -10
  19. package/dist/regenerate/list-arguments.js +121 -0
  20. package/dist/regenerate/loop.js +137 -18
  21. package/dist/regenerate/notes.js +66 -17
  22. package/dist/regenerate/prompt.js +3 -1
  23. package/dist/regenerate/regenerate.js +16 -10
  24. package/dist/regenerate/regression.js +2 -1
  25. package/dist/regenerate/requires.js +55 -2
  26. package/dist/regenerate/self-check.js +13 -6
  27. package/dist/regenerate/test-scripts.js +54 -10
  28. package/dist/regenerate/unit-review.js +12 -1
  29. package/dist/regenerate-cli.js +11 -5
  30. package/dist/release-tools.js +1 -1
  31. package/dist/resume-line.js +4 -0
  32. package/dist/review/live.js +2 -1
  33. package/dist/run-report.js +34 -1
  34. package/dist/spec-tools.js +10 -45
  35. package/docs/authoring-plain.md +9 -6
  36. package/docs/config.md +3 -2
  37. package/docs/headless.md +30 -3
  38. package/docs/installation.md +3 -0
  39. package/docs/regenerating.md +69 -20
  40. package/docs/skills-and-gates.md +5 -3
  41. package/docs/using.md +20 -9
  42. package/genome/skills/bud/SKILL.md +67 -36
  43. package/genome/skills/bud/references/intent.md +4 -0
  44. package/genome/skills/refactor-module/SKILL.md +24 -2
  45. package/package.json +3 -3
  46. package/genome/skills/bud/references/checklist.md +0 -44
@@ -40,6 +40,9 @@ on npm runs JavaScript compiled from them instead (`npm run build`, into `dist/`
40
40
  before they pack), as Node runs no `.ts` file inside a `node_modules`. `bin/turri.mjs` runs `src/` where there is one,
41
41
  and `dist/` otherwise.
42
42
 
43
+ To update, `git pull` and `npm install` - the second picks up a dependency that changed, pi's say. `npm link` needs
44
+ running only once. A **turri** already running keeps the code it started with: start it again to run what you pulled.
45
+
43
46
  ## In Docker
44
47
 
45
48
  `docker/Dockerfile` builds an image with Node, git, bash, bubblewrap and **turri** linked; the agents' commands and the
@@ -112,6 +112,10 @@ the planner's, the spec-steps agent's, the conformance agents' - is laid out in
112
112
  A module that `requires` another inherits its functional specs; one that `import`s another
113
113
  inherits its definitions, implementation reqs and test reqs.
114
114
 
115
+ An import module - one a `.plain` file imports, or one kept in a `template/` folder - is no codebase of its own. A
116
+ change to it is built in the modules that import it, through any import modules between, whose code is started; when
117
+ none is, nothing is built, and the change goes in with the first of them built.
118
+
115
119
  Template search order: the plain file's own directory, then a sibling `template/`, then
116
120
  `--template-dir`, then `PLAIN_TEMPLATE_DIRS`.
117
121
 
@@ -119,7 +123,21 @@ An agent that goes round in a circle - the same tool called with the same argume
119
123
  nothing in between, or a look (read, grep, find, ls) made again with nothing changed since, however
120
124
  many other looks came between, so the same answer comes back - is let through three times; the next
121
125
  such call is refused with what is happening, and past six its turn is stopped, and the harness goes on
122
- from there as after any turn. The arguments are compared whatever order they come in.
126
+ from there as after any turn. The arguments are compared whatever order they come in. So too an agent whose
127
+ calls to one tool fail ten times in a row, nothing going through - a call its arguments do not fit never reaches
128
+ any guard on the tools.
129
+
130
+ A turn turri stops itself - for any of these, or for its time, below - ends as any turn ends: what the agent said
131
+ stands, `[the turn was stopped: ...]` after it, and the caller does what it does when the agent handed nothing over
132
+ (the explorer's fallback, a nudge, a failed round). The abort that ended it is never taken for the provider
133
+ failing; an abort turri did not make still is. Each stop is said as it happens - a notification in the chat, a
134
+ line in a headless run - and listed in the run report's `turn_incidents`.
135
+
136
+ A tool argument that is a list of objects - the explorer's `interfaces` and `plan`, a reviewer's `problems` - is
137
+ what small models get wrong most. Before a call's arguments are checked, a list sent as JSON text, entries sent as
138
+ JSON text, one object for the list, or a list written inside another argument's text
139
+ (`...</tests_reach_it><plan>[...]</plan>`) are taken as the list; what still is not one is refused saying which
140
+ argument, what was sent, each entry's fields and an example (`list-arguments.ts`).
123
141
 
124
142
  The agents with one thing to decide have a budget of tool calls: the judge 30, the test review and the
125
143
  explorer 40. Past it every tool but the one that hands the decision over refuses, telling it to decide
@@ -241,12 +259,18 @@ use each:
241
259
  - **`my_diff`**: the diff of the code folder from the commit the job started from, new files whole - exactly
242
260
  what the reviewer is shown. Read before handing the work in: every part of the change in it, and nothing else.
243
261
  - **`can_it_fail`**: whether the unit tests catch a bug. The agent gives one change to a code file - a
244
- condition turned round, a value changed - and the unit testing script runs on a fresh copy of the code with
245
- it; the code itself is never touched. If every test still passes, no test catches that bug. Six
262
+ condition turned round, a value changed - and the unit testing script runs with it. Where the testing scripts
263
+ run on a copy (`testing-scripts-run-on: copy`), the change is made to a fresh copy and the code itself is never
264
+ touched. In place, the default, it is made to the code itself, so a script that finds the code from its own path
265
+ sees it; the file is put back as it was once the run ends - passed, failed, hung, the script failing to start, the
266
+ script rewriting the file, turri exiting. Killed outright, the next unit of work starts from the last commit anyway.
267
+ It never runs beside another call of the agent's, so no edit lands while the bug is in. What the script does
268
+ beyond the code - a package copied into a host codebase - it does with the bug in, until the next test run puts the
269
+ real code there. If every test still passes, no test catches that bug. Six
246
270
  runs a job. A bug often makes the code hang instead - a loop that never ends - so a run may take three times
247
271
  as long as the last passing run of the unit tests, within 15 and 60 seconds, and one that does not finish is
248
- reported as a hang, not as a test that caught it. Only where the testing scripts run on a copy
249
- (`testing-scripts-run-on: copy`): in place, the default, there is no copy to change.
272
+ reported as a hang, not as a test that caught it. `mutation-testing: false` in the [config](config.md) - or
273
+ `turri regenerate --mutation-testing false` - takes it away, from the reviewer too.
250
274
  - **`start_service`**, **`service_logs`**, **`stop_service`**: a server or a worker it built, started in the
251
275
  background on this machine, behind the same walls as its shell - the command check, the module's environment, the
252
276
  OS sandbox, the audit while it comes up - to try from outside with `curl` as a client would. Whatever the stack: the
@@ -266,7 +290,8 @@ Passing unit tests prove only what they check, and a coding agent is quick to wr
266
290
  next to nothing - that a function exists, that a result is not empty, that a status is 200 - or code
267
291
  that no test reaches. So, with `review: true` in the [config](config.md), once the unit testing script
268
292
  passes a reviewer on the judge model reads what the work wrote, beside the spec, and changes nothing. It
269
- reviews both halves. The review is off by default - `review: false`, or the key left out - and so is the
293
+ reviews both halves, with the unit testing script word for word in its prompt: a test the script never reaches is
294
+ not run, and checks nothing. The review is off by default - `review: false`, or the key left out - and so is the
270
295
  conformance tests' review: the work goes on once its tests pass.
271
296
 
272
297
  - **The code.** Every behaviour, edge case, validation rule and error the spec states for this work
@@ -375,6 +400,18 @@ halts its codebase: nothing more runs there until the spec changes or the module
375
400
  the command line, `turri regenerate` runs until nothing more can start, one line as each job starts and
376
401
  ends, and exits 1 when any failed.
377
402
 
403
+ The person halts a module's planned work too: `halt` (and `/halt`) given a planned row - `planned-<module>-2`,
404
+ `planned-<module>-waiting` - or the module's name. A module's pulses are planned again from its spec at every look, so
405
+ one planned pulse cannot be taken out alone: the module is halted - its running pulse stopped and rolled back, none of
406
+ its planned pulses started, the modules built on it waiting for it - and what landed stays. A halt the person asked for
407
+ holds through spec changes - `write_spec_diff` brings the spec in without starting the module - until the module is
408
+ asked for again (`regenerate`, `conform`). To build some of it later, or cut it differently, there is `steer`; to drop
409
+ work, the spec.
410
+
411
+ A module the loop looked after whose `.plain` file is gone is forgotten - no rows, nothing waited for - and a codebase
412
+ left behind, or whose spec no longer parses, shows nothing planned: its plan, and what it waited for, were the spec's
413
+ before.
414
+
378
415
  ### How the work is cut into jobs
379
416
 
380
417
  A job that renders the whole of a new spec is too big to build well, and a render per functional spec,
@@ -503,8 +540,9 @@ testing script, stops before it starts and says which skill adds it.
503
540
  `prepare-environment-script:` in the config, else the one `prepare_environment*.sh` at the root, else in
504
541
  `test_scripts/` - on the build, before every run of the conformance testing script: the harness's own, and the agents'
505
542
  `run_conformance_tests`. Both get the same build folder - the code in place, or the same fresh copy - so what it sets up
506
- for that build, the conformance testing script finds. With conformance off it is not run. The conformance agents are
507
- shown it, before the conformance testing script.
543
+ for that build, the conformance testing script finds. With conformance off it is not run. Every agent shown the
544
+ conformance testing script - the explorer, the conformance agent, the judge, the code fixer and the repair agent - is
545
+ shown it too, before the conformance testing script.
508
546
 
509
547
  **Where they run.** On this machine, as you would run them: unfenced - no sandbox, no command check, no audit - in
510
548
  your own environment with this machine's toolchains, turri's model providers' API keys alone left out. They are yours,
@@ -543,7 +581,8 @@ does not find them:
543
581
  testing-scripts-run-on: copy
544
582
  ```
545
583
 
546
- `can_it_fail` needs a copy to change, so an agent has it only where the scripts run on one.
584
+ `can_it_fail` works either way: on a copy it changes the copy; in place it changes the code for the one run and puts
585
+ it back.
547
586
 
548
587
  ### When the environment lacks something
549
588
 
@@ -700,7 +739,7 @@ with no agent and no testing script. Moving specs into a module the code was not
700
739
  change to the code brings that module's code in, so the codebase stops: it has to be started over - its code
701
740
  and conformance tests taken out, committed so its history keeps them, and the chain built again from the
702
741
  bottom. That is never done unasked. In the chat the model asks the person, saying why, and calls
703
- `regenerate` with `from_scratch` once they agree; `turri regenerate` and `spec-diff` ask at the terminal, and
742
+ `regenerate` with `from_scratch: "module"` once they agree; `turri regenerate` and `spec-diff` ask at the terminal, and
704
743
  `--start-over` agrees in advance - with no terminal and no flag, the run stops there, exit 1, saying so.
705
744
 
706
745
  ## Conformance tests
@@ -836,7 +875,8 @@ coding agent that fixes the code is told the same of the tests: it can read them
836
875
  Before the test author starts, an explorer - an agent in
837
876
  the code's folder with the file tools alone: it reads the code, runs nothing and changes nothing - hands over everything
838
877
  the author needs, in parts: how to build and run it; how the conformance tests reach it as the project's
839
- conformance testing script runs them - the explorer is given the script, and says what it builds or
878
+ conformance testing script runs them - the explorer is given the script, and the prepare script before it where there
879
+ is one, and says what they build or
840
880
  installs and what the tests depend on or start (a package, a module, an entry point, by its exact name);
841
881
  how each functionality is reached from outside
842
882
  (the command, or the route, method and the request and response fields); what it needs around it; and
@@ -919,7 +959,8 @@ culprit: what it does with the tests, the tests fit; what it needs of the build,
919
959
  - **the code:** the coding agent - in the code's folder, reading the tests but never changing them - fixes it,
920
960
  and keeps its unit tests passing. The judge quotes the spec's own words the code does not meet, or the testing
921
961
  script's for what it needs of the build (`script_needs`: a build output, an entry point, a module) - each checked
922
- by the harness against the text it quotes;
962
+ by the harness against the text it quotes. The acceptance tests are in that text, labelled as their tests are:
963
+ for a spec change, those of every functional spec it touches, not only the last one's;
923
964
  - **the tests:** the conformance agent corrects them to what the spec says;
924
965
  - **the spec:** two functional specs cannot both hold, whatever the code does;
925
966
  - **the environment:** neither the code nor the tests can fix it - only the person can, in what the run is given:
@@ -961,7 +1002,9 @@ spending the rest of its 20 attempts on it. Two failures are the same once what
961
1002
  taken out of their lines - numbers, times, paths, colour codes, and the ids a service makes up for each
962
1003
  response, a UUID or a correlation id. Nothing changes either when the agent sent to fix the code or the tests
963
1004
  changes no file: two such fixes in a row, and the run stops. The conformance agent has the testing script in its prompt,
964
- and is told to fit the tests' own build to it.
1005
+ and is told to fit the tests' own build to it. The code fixer has the testing scripts its fixes are run by - the
1006
+ conformance testing script, the prepare script before it, and the unit testing script - word for word in its task:
1007
+ what the conformance testing script needs of the build, it reads there, not only in the judge's quote of it.
965
1008
 
966
1009
  **Escalation.** A failure judged the tests' goes to the conformance agent first: it owns the tests. When the run then
967
1010
  fails the same way - the fix changed nothing, or nothing that mattered - the judge is asked again, now whether the
@@ -1067,8 +1110,7 @@ both. Each set goes where its folder goes - copied up the chain, committed, roll
1067
1110
  | --- | --- |
1068
1111
  | Where things are | entry points, layout, where each functionality lives |
1069
1112
  | How to build, run and test | the commands that work, what had to be installed |
1070
- | Assumptions | what an agent assumed where the spec is silent - a format, a default, a choice it leaves open |
1071
- | Spec gaps | what the spec should say and does not - a behaviour the person would want to decide, as the question it leaves |
1113
+ | Assumptions | what an agent assumed where the spec is silent - a format, a default, a choice it leaves open - and the tests that assert it, when any do; one no test asserts is written down all the same |
1072
1114
  | Pitfalls | what went wrong and what fixed it - and what the debugger found, filed by turri itself |
1073
1115
  | Pulses | written by turri alone, as each pulse ends: the last ten, a line each |
1074
1116
 
@@ -1085,9 +1127,16 @@ it landed, a commit of its own (`pulse 3 rolled back: …`) when it did not - so
1085
1127
  commit, keeps it. `update_notes` refuses the section. What the debugger finds is filed in the pitfalls the moment it
1086
1128
  finds it, not left to the coding agent to write down.
1087
1129
 
1088
- The spec gaps a pulse's agents add are said in its report - "Spec gaps its agents met ... Put each to the user" - so
1089
- the conversation asks you, and writes the ones you decide into the spec; the gaps stay in the notes, for the agents
1090
- after, until then.
1130
+ A spec gap - what the spec should say and does not, a behaviour you would want to decide - is not a note: the notes
1131
+ are the next agent's, and a gap is yours. An agent reports one with `report_spec_gap`, giving the question it leaves
1132
+ and the assumption it made meanwhile; turri writes that assumption into the notes' assumptions, so the code built on
1133
+ it is known for what it is. The gaps a pulse's agents report are said in its report - "Spec gaps its agents met ... Put
1134
+ each to the user", each with its assumption - so the conversation asks you, and writes the ones you decide into the
1135
+ spec; the pulse that builds the answer finds the assumption it replaces in the notes, and the tests it names.
1136
+ A headless run has no one to ask: it prints each gap under its pulse, and lists them in its run report's
1137
+ `spec_gaps` ([running unattended](headless.md#the-run-report)). However many gaps a pulse's agents report, they
1138
+ are put to you - never a reason to stop the pulse; the tool is guarded like any other. A notes
1139
+ file from before keeps no spec gaps section: its lines are dropped as it is read.
1091
1140
 
1092
1141
  Stubborn on the specs, flexible on the assumptions: the spec is never an assumption and never
1093
1142
  copied into the notes, and where the two disagree the spec wins. An agent builds on the assumptions
@@ -1110,8 +1159,8 @@ Leaving notes is required, and only through the `update_notes` tool. The file to
1110
1159
  notes file, and a change made to it any other way - from the shell, by a script - is undone. An agent
1111
1160
  that finishes without calling `update_notes` is asked again, up to three times; if it still has not,
1112
1161
  the activity log says so. The turn that asks is for the notes alone: the work is done - its testing script's run
1113
- passed, and the agent is told so first, so its notes speak of work that succeeded - so every tool but `update_notes` is
1114
- refused, and an agent that keeps calling them has its turn stopped. What
1162
+ passed, and the agent is told so first, so its notes speak of work that succeeded - so every tool but `update_notes` and
1163
+ `report_spec_gap` is refused, and an agent that keeps calling the refused ones has its turn stopped. What
1115
1164
  landed is what the harness checked; nothing changes after it. Only work that lands is asked: a job whose code or tests do not pass - or whose
1116
1165
  testing script cannot run - is rolled back, notes and all, so its agent is not asked to leave any.
1117
1166
 
@@ -52,7 +52,7 @@ last one - one answer, one change, as an interview writes them. `spawn` is unpac
52
52
  each change to write the next at once, not to carry on with an interview it does not have.
53
53
 
54
54
  `questioning:` under `metadata:` names the steps the questioning level caps (`src/questioning.ts`) - `brood`'s
55
- `[stack, product]`. When there are any and someone to ask, the harness itself asks the first question of the first
55
+ `[stack, product]`, `bud`'s `[product]`. When there are any and someone to ask, the harness itself asks the first question of the first
56
56
  step: how many questions those steps may ask - light (3), medium (5), thorough (10) or best judgement - and tells the
57
57
  agent the answer beside each step's instructions, with how broad each question is to be: broad at light, a whole area
58
58
  at once, narrow at thorough, an edge case at a time. Every level covers the same ground, in less or more depth. In a
@@ -63,7 +63,7 @@ questions each step has asked, are kept in the run's `run.json`, so a resumed ru
63
63
  or a run with nobody to ask, is not capped.
64
64
 
65
65
  `spec-diff-per-answer:` under `metadata:` names the steps where every answer is a spec change - `brood`'s
66
- `[product]`, at every questioning level. There `ask_user` refuses the next question until the last answer is written
66
+ and `bud`'s `[product]`, at every questioning level. There `ask_user` refuses the next question until the last answer is written
67
67
  with `write_spec_diff` (a confirmation, or a question dismissed, owes nothing), and `write_spec_diff` no longer waits
68
68
  for an answer before a change: the agent writes as many as the step needs, those it decides itself included. The
69
69
  level limits the questions, never the spec changes.
@@ -133,7 +133,9 @@ change the step makes and puts its findings on the executor's next tool result.
133
133
  - **Interview the user.** `ask_user` puts one question to the person. In the TUI it is a dialog;
134
134
  from the CLI the options are numbered. Offering choices is required, not optional - a call with
135
135
  neither `options` nor `free_form: true` is refused - and every list carries "Something else…".
136
- `multi_select: true` keeps offering what is left until they are done. The skill's agent talks in a
136
+ `multi_select: true` gives every option a box, ticked and unticked as it is chosen - a pick made by mistake is
137
+ undone by choosing it again - until they choose Done; what they type is one more box, ticked. "Something
138
+ else…", "Chat about this" and Done are no boxes. The skill's agent talks in a
137
139
  session of its own that the person never sees, so what the person must read to answer - the brief
138
140
  to confirm, the plan to approve - it passes as `ask_user`'s `context`, shown above the question in
139
141
  the dialog; `brood`, `spawn` and `bud` pass their briefs so. The agents are told to keep it to what can be taken in at
package/docs/using.md CHANGED
@@ -50,7 +50,7 @@ where it stopped. A project can have skills of its own, in `.turri/skills/` or `
50
50
 
51
51
  | tool | |
52
52
  | --- | --- |
53
- | `regenerate` | regenerate a module and its chain from the spec as it is now - after any change to it, by any means: what is left to regenerate is planned into pulses of one to three functional specs, each with the definitions and reqs it uses, and a pulse regenerating what the spec no longer wants is stopped. With functionalities named, those are regenerated though their spec did not change - rewritten or started over, planned into pulses as any change is; with `from_scratch`, the whole module, its code deleted first - only when you ask, or agree |
53
+ | `regenerate` | regenerate a module and its chain from the spec as it is now - after any change to it, by any means: what is left to regenerate is planned into pulses of one to three functional specs, each with the definitions and reqs it uses, and a pulse regenerating what the spec no longer wants is stopped. With functionalities named, those are regenerated though their spec did not change - rewritten or started over, planned into pulses as any change is; with `from_scratch`, the whole module, its code deleted first - `"chain"` for every module of its requires chain too, built again from the bottom - only when you ask, or agree |
54
54
  | `drift` | what is left to regenerate: how far the code and its conformance tests have drifted from the spec, starting nothing |
55
55
  | `glimpse` | the pulse a module's codebases would start next, and the whole prompt its coding agent would get - starting nothing |
56
56
  | `steer` | say how the work is planned - which functional specs go together, what first - for the project or one module, for the session; the next plan follows it, beside what AGENTS.md says under a heading naming the queue |
@@ -58,12 +58,12 @@ where it stopped. A project can have skills of its own, in `.turri/skills/` or `
58
58
  | `validate` | validate a spec, regenerating nothing |
59
59
  | `engine` | show or choose the model the code is regenerated on - see [below](#choosing-a-model) |
60
60
  | `pulses` | the pulses - running, planned and finished - or one of them |
61
- | `halt` | halt a pulse, or what `activate` started |
61
+ | `halt` | halt a pulse, a module's planned pulses, or what `activate` started |
62
62
  | `diagnose` | why a pulse did not land, from its transcript: how it ended, the stages that went wrong, the last failing test run, the last review, the tool calls that failed |
63
63
  | `lineage` | a module's lineage: what each regeneration and conformance run changed in it, and what it was regenerated from |
64
64
  | `cultivate` | run a gated skill, its steps and review gates enforced |
65
65
  | `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) |
66
- | `ask_user` | put a question to you as a dialog to pick from - several at once, "Something else…" to type, or "Chat about this" to talk it over first; Esc in either goes back to the options |
66
+ | `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 |
67
67
  | `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` |
68
68
 
69
69
  What each render does, in order, is in [regenerating the code](regenerating.md).
@@ -238,7 +238,7 @@ come waits for a free slot, and says so.
238
238
  is laid over `config.turri.yaml` - its testing scripts, toolchains, models - for the session; a pulse already
239
239
  running keeps the stack it started with. The chat model switches it too when you ask. See
240
240
  [stacks](config.md#stacks).
241
- - **`/regenerate [module | file.plain] [functionality ...] [from scratch] [how to cut the work]`** regenerates a module from its spec as it is now, as
241
+ - **`/regenerate [module | file.plain] [functionality ...] [from scratch [whole chain]] [how to cut the work]`** regenerates a module from its spec as it is now, as
242
242
  the `regenerate` tool does: what is left to regenerate is planned into pulses - one functional spec at a time, a few
243
243
  together or the whole module in one, as the planner judges - and the first starts. Words after the module are
244
244
  guidance for that plan (`/regenerate app models first`). A module's name typed with spaces for its underscores is
@@ -246,13 +246,19 @@ come waits for a free slot, and says so.
246
246
  `config.turri.yaml` names, else the folder's top modules, to pick from. Asked for from scratch - `from scratch`,
247
247
  `start over`, `delete the module` - it asks first, then deletes the module's code and conformance tests in every
248
248
  codebase where they live, committed so `/lineage` keeps them, and regenerates the whole module from its spec,
249
- built though nothing in it changed: `/regenerate shorty from scratch`. The chat's `regenerate` does the same with
250
- `from_scratch`, when you ask for it; `turri regenerate --from-scratch` on the command line, not with `--dry-run`.
249
+ built though nothing in it changed: `/regenerate shorty from scratch`. The modules below it keep their code, and
250
+ the module starts again from a copy of the code below it. Asked for its chain too - `/regenerate shorty from scratch,
251
+ the whole chain` - the code of every module of its requires chain is deleted, the base's included, and the whole
252
+ chain is regenerated from the bottom: what to do after modules were split, merged or moved, when the code below was
253
+ laid out for modules that are no more. The chat's `regenerate` does the same with `from_scratch: "module"` or
254
+ `"chain"`, when you ask for it; `turri regenerate --from-scratch` or `--from-scratch-chain` on the command line, not
255
+ with `--dry-run`.
251
256
  Functionalities named after the module - `/regenerate shorty 3 5` - are regenerated though their spec did not
252
257
  change, on the model chosen for functionalities: as `turri regenerate shorty.plain 3 5` does, and the chat's
253
258
  `regenerate` with `functionalities`.
254
- - **`/halt <id>`** halts a pulse - a queued one never starts - and **`/halt activated <name>`** halts a
255
- server `activate` started; it lists both when no id is given.
259
+ - **`/halt <id>`** halts a pulse - a queued one never starts - **`/halt <module>`** (or a planned row's id) halts a
260
+ module's planned pulses until you ask for it again, a spec change not starting it, and **`/halt activated <name>`**
261
+ halts a server `activate` started; it lists all three when no id is given.
256
262
  - **What these commands show you, the chat knows.** What `/regenerate` and `/halt activated` tell you - a spec that
257
263
  does not parse, the pulses planned, a server halted - stays in the chat under the command, and since a slash command
258
264
  runs outside the conversation, it is put in the conversation as well: say "fix it" next and turri knows what you are
@@ -389,7 +395,11 @@ To change pi's own default, in `~/.pi/agent/settings.json`:
389
395
  ```
390
396
 
391
397
  A provider failure - no credits, bad key, rate limit - is raised with the provider's own message,
392
- rather than surfacing as an agent that said nothing.
398
+ rather than surfacing as an agent that said nothing. One that passes - overloaded, rate limited, unreachable,
399
+ timed out - is waited out first, after pi's own retries: six more tries, the wait doubled each time from 15
400
+ seconds up to five minutes (15s, 30s, 1m, 2m, 4m, 5m, a tenth either way so parallel jobs do not all come back
401
+ at once), the agent carrying on where it was. Each wait is shown as it happens - a notification in the chat and
402
+ the job panel's status, a yellow line in a headless run - and listed in the run report's `turn_incidents`.
393
403
 
394
404
  ## Module history
395
405
 
@@ -452,6 +462,7 @@ turri regenerate <file.plain> # regenerate what the code is not bui
452
462
  turri glimpse <file.plain> # plan it, and print the first job's prompt - starts nothing
453
463
  turri regenerate <file.plain> 2 # regenerate functionality 2 again, changed or not
454
464
  turri regenerate <file.plain> --from-scratch # delete the module's code and tests (its lineage keeps them), regenerate all of it
465
+ turri regenerate <file.plain> --from-scratch-chain # the same for every module of its requires chain, from the bottom
455
466
  turri spec-diff <file.plain> <diff> # apply a spec diff, and regenerate it
456
467
  turri conform <file.plain> 1 # black-box tests for functionality 1
457
468
  turri lineage <module> # what each regeneration changed in a module, and when
@@ -1,11 +1,13 @@
1
1
  ---
2
2
  name: bud
3
3
  description: >-
4
- Add a feature to an existing ***plain project the way `brood` builds one: a short
5
- feature-intent interview, then product questions one at a time - a trigger and its outcome, an
6
- edge case, a rule - where every answer becomes one spec change, written as a git diff of the
4
+ Add a feature to an existing ***plain project the way `brood` builds one: it first asks how many
5
+ questions the product phase may ask - light, medium, thorough or best judgement, broader with
6
+ fewer - then a short feature-intent interview, then product questions - a trigger and its outcome,
7
+ an edge case, a rule - where every answer becomes a spec change, written as a git diff of the
7
8
  .plain files and built the moment it is written, so the feature appears while the interview is
8
- still going. A change that touches what is already specified or being built is a spec diff too: what
9
+ still going. What the questions leave open it decides itself, each decision a spec change of its
10
+ own. A change that touches what is already specified or being built is a spec diff too: what
9
11
  is left to build is worked out again from the spec. Use when the user wants to add a
10
12
  feature to an existing project. Not for starting a new project (use `brood`, or `spawn`
11
13
  to start fast) or for editing generated code (the .plain specs are the source of truth).
@@ -16,7 +18,12 @@ metadata:
16
18
  intent: "what the feature is for, who it serves, and what it leaves out"
17
19
  scope: "finds where the feature goes in the spec, and what is built already"
18
20
  product: "the feature, question by question - each answer starts a regenerate pulse"
19
- review: "checks the changed spec holds together, then hands over"
21
+ # The phase the questioning level caps, asked by the harness as the first question: light 3,
22
+ # medium 5, thorough 10, best judgement as many as turri judges the phase needs.
23
+ questioning: [product]
24
+ # Every answer in the product phase is a spec change: the next question waits until it is
25
+ # written with write_spec_diff. Changes turri decides itself need no answer before them.
26
+ spec-diff-per-answer: [product]
20
27
  ---
21
28
 
22
29
  # Bud
@@ -37,10 +44,36 @@ the spec."
37
44
  This is `brood`'s product phase, scoped to one feature, on top of what is there: the stack,
38
45
  the testing setup and every earlier feature are settled - read them, build on them, restart none.
39
46
 
47
+ ## How many questions
48
+
49
+ The first question of the intent phase is the harness's own, not yours: how many questions the
50
+ **product** phase may ask. The level sets how many questions there are and so how broad each is -
51
+ never what they cover:
52
+
53
+ | level | product questions | each question |
54
+ | --- | --- | --- |
55
+ | light | at most 3 | broad: the whole feature at once - what it does end to end, its main rules - with what fits the brief proposed, for the person to confirm or correct |
56
+ | medium | at most 5 | one part of the feature, with its main rules |
57
+ | thorough | at most 10 | narrow: one trigger, rule or edge case, with follow-ups on the ones that matter |
58
+ | best judgement | as many as you judge the feature needs | as broad or as narrow as each part needs |
59
+
60
+ The intent phase is not capped. Follow-ups count; the closing confirmation - asked with
61
+ `confirms_phase: true` - does not. Past the cap `ask_user` refuses the question. To stop sooner, or
62
+ under best judgement once the feature is settled enough to build, call `end_questions`.
63
+
64
+ The level limits the questions, never the spec changes. **Every answer is a spec change**, whatever
65
+ the level: written with `write_spec_diff` and built at once, before the next question - `ask_user`
66
+ refuses the next one until it is. A broad answer that covers several behaviours is several changes,
67
+ and you write them all. What the questions leave open - the details of a light answer, what is left
68
+ once they are over - is yours to decide, as a careful engineer would, in the light of the brief: each
69
+ decision a spec change of its own, written with `write_spec_diff` with no answer needed before it,
70
+ and said in one line. The closing summary names every decision you made yourself, so the
71
+ confirmation is where the person can change it.
72
+
40
73
  ## Question style
41
74
 
42
- - Ask with `ask_user`, one question per call, and pass `options` so the user picks rather than
43
- types - concrete choices, plus the free-form catch-all the tool adds. Reserve `free_form: true`
75
+ - Ask with `ask_user`, one question per call, as broad as the level says, and pass `options` so
76
+ the user picks rather than types - concrete choices, plus the free-form catch-all the tool adds. Reserve `free_form: true`
44
77
  for a genuinely open question.
45
78
  - Ask about the product - a trigger and its outcome, an edge case, a rule, a permission, a step of
46
79
  a flow - never about a spec section ("which concepts?", "what reqs?"). Let the answer decide which
@@ -55,6 +88,9 @@ the testing setup and every earlier feature are settled - read them, build on th
55
88
 
56
89
  ### intent
57
90
 
91
+ The harness has asked how many questions the product phase may ask before this phase starts; its
92
+ note beside these instructions gives the answer. Do not ask it again.
93
+
58
94
  Read `references/intent.md` and ask its five core questions one at a time with `ask_user`. Ask at
59
95
  most one focused follow-up when an answer is too vague to summarize. If what the user has already
60
96
  said answers a question, confirm it in one line instead of asking.
@@ -81,8 +117,8 @@ Say in one line where the feature goes, and move on. Write nothing to disk.
81
117
 
82
118
  ### product
83
119
 
84
- The feature, walked question by question. Run this loop until the user says the feature is fully
85
- covered:
120
+ The feature, walked question by question. Run this loop while the questioning level allows (see
121
+ "How many questions"):
86
122
 
87
123
  1. **Ask** one product question with `ask_user`.
88
124
  2. The user **answers**.
@@ -106,14 +142,17 @@ covered:
106
142
  Write it as a git diff: `diff --git a/<file> b/<file>`, `--- a/<file>`, `+++ b/<file>`, then the
107
143
  hunks with a few lines of unchanged context, paths from the project root. A new functional spec
108
144
  goes where it belongs in build order - after what it builds on, usually at the end.
109
- 4. **Write it with `write_spec_diff`.** It applies the diff and queues a render spec diff job for
110
- it; with conformance on, its conformance tests follow it. Say in one line what went into the
111
- spec - "added `:Note:` and functional spec 7" - and what became of the build, as the tool says,
112
- then ask the next question. Never wait for a build, and never ask the user to approve a change.
113
-
114
- **One answer, one change.** A follow-up about the same behavior - an edge case, a validation rule -
115
- is its own answer and its own change. An answer that describes two behaviors is two: write the
116
- first, then ask about the second. A change never carries anything the user was not asked about.
145
+ 4. **Write it with `write_spec_diff` at once**, before anything else. It applies the diff and starts
146
+ a render spec diff job for it; with conformance on, its conformance tests follow it. An answer
147
+ that covers several behaviours is a change for each: write them all. Then the changes for what
148
+ you decide yourself around it, if any. Say in one line what went into the spec - "added `:Note:`
149
+ and functional spec 7" - and what became of the build, as the tool says, then ask the next
150
+ question. Never wait for a build, and never ask the user to approve a change.
151
+
152
+ **One answer, at least one change.** A follow-up about the same behaviour - an edge case, a
153
+ validation rule - is its own answer and its own change. An answer that describes two behaviours is
154
+ two changes, both written before the next question. A change never carries both an answer and
155
+ something you decided: what you decide is a change of its own.
117
156
 
118
157
  **What already exists.** When an answer - or the conflict check - means changing something already
119
158
  specified: a definition, a req, a functional spec, built or still queued, the next question is
@@ -127,22 +166,14 @@ is taken out, one it touches renders the spec as it now is.
127
166
  **Fix your own mistakes in place.** When a later answer refines or contradicts a change you wrote in
128
167
  this feature, write the correction as its own diff with `fixes_earlier`, before the next question.
129
168
 
130
- When the loop reaches the end of what the brief covers, ask whether the feature is fully covered.
131
- Yes: go to the review. No: the next question.
132
-
133
- ### review
134
-
135
- A short consistency pass over what the feature changed, then the handover.
136
-
137
- 1. Read the modified `.plain` file(s) whole, and check: every new concept defined before use, with
138
- no cycles; build order right end to end - no spec depends on one after it; functional specs
139
- language-agnostic; every external interface explicit (paths, methods, arguments, formats);
140
- acceptance tests consistent with their functional specs.
141
- 2. Run `validate` on every module the feature touched.
142
- 3. Fix what either finds with a spec diff and `fixes_earlier` - never by editing the file. Ask the
143
- user only when a fix is a decision the brief and the answers do not settle.
144
-
145
- Walk `references/checklist.md` once, as a self-audit. Then hand over in a few lines: the feature's
146
- spec changes in order, the builds they queued and how they stand (`drift`), and that any
147
- further change is asked for in the conversation - each one a spec diff, and what is left to build is
148
- worked out again from the spec. The next feature starts again from the intent.
169
+ Once the questions are over - the cap reached, or `end_questions` called - write what is left of
170
+ the feature the same way: one decision of yours, one spec change, with no answer between. Then run
171
+ `validate` on every module the feature touched, and fix what it finds with a spec diff and
172
+ `fixes_earlier`.
173
+
174
+ Finish by summarizing the feature's spec changes in build order, marking what you decided without
175
+ asking, saying what is built and what is still queued (`drift`), and getting explicit confirmation
176
+ with `confirms_phase: true`. The summary is for the person to take in at a glance - a line a change,
177
+ each decision you made yourself in a few words, about fifteen lines at most, never the specs'
178
+ wording. Any further change is asked for in the conversation, each one a spec diff; the next
179
+ feature starts again from the intent.
@@ -3,6 +3,10 @@
3
3
  Extract the intent of this feature before choosing files or authoring specifications. Ask exactly
4
4
  five core questions, one at a time, and do not write to disk.
5
5
 
6
+ The harness has already asked the first question of this phase: how many questions the product
7
+ phase may ask - light (3), medium (5), thorough (10) or best judgement. Do not ask it again; this
8
+ phase's own questions are not capped by it.
9
+
6
10
  ## Questions
7
11
 
8
12
  1. **Motivation** — What problem or limitation should this feature address?
@@ -21,6 +21,8 @@ allowed-tools: [read, write, edit, bash, ls, grep, find]
21
21
 
22
22
  The refactoring is purely structural. The **combined behavior** of the resulting modules must be **identical** to the original module. No functional spec is added, removed, or weakened. The split is semantic — grouping related specs together — not behavioral.
23
23
 
24
+ The spec is structural; the code is not. Once modules are split and specs move between them, the code already built no longer matches the module layout: specs move into modules the code was never built on, and no change to that code brings them in. **After a refactor, the whole requires chain is regenerated from scratch** — the existing code and conformance tests are taken out (their lineage keeps them) and every module is built again from the base of the chain upward. Say so up front: it is part of what the user agrees to (Phase 2e), and it is the last step of the skill (Phase 5).
25
+
24
26
  ## Input
25
27
 
26
28
  The `.plain` file to refactor, plus guidance from the user on the desired grouping (or ask the user to confirm your proposed grouping).
@@ -90,8 +92,9 @@ Summarize for the user:
90
92
  - Any new import module being created
91
93
  - Which concepts are exported from each module
92
94
  - Confirmation that all original specs are accounted for (none lost)
95
+ - That the whole chain will be **regenerated from scratch** once the split is done: the code and conformance tests built so far are taken out (kept in the lineage) and everything is built again from the base module up — this takes as long and costs as much as building the original module did
93
96
 
94
- Get explicit user confirmation before proceeding.
97
+ Get explicit user confirmation before proceeding — of the split and of regenerating from scratch.
95
98
 
96
99
  ## Phase 3 — Execute the Split
97
100
 
@@ -162,6 +165,19 @@ For each new module:
162
165
 
163
166
  Read each new `.plain` file in full and present the final structure to the user for approval. If the user requests changes, apply them and re-verify.
164
167
 
168
+ Validate each new module with `turri validate <module>.plain` (or the `validate` tool) before going on: a module that does not parse cannot be regenerated.
169
+
170
+ ## Phase 5 — Regenerate the Chain from Scratch
171
+
172
+ The split moves specs between modules, so the code built from the original module cannot be patched into the new layout: the chain is regenerated from scratch. Do not try to keep or reuse the existing code, and do not regenerate only what looks changed — modules have moved, and a codebase built without a module it now requires has to be started over anyway.
173
+
174
+ 1. **Remind the user** what regenerating from scratch does — the code and conformance tests built so far are taken out, committed so the lineage keeps them, and the whole chain is built again from the base up — and that they already agreed to it in Phase 2e. Proceed only on that agreement.
175
+ 2. **Regenerate the tip of the chain from scratch, with its whole chain** — the last module, the one everything else is required by. From scratch for the tip alone is not enough: the modules below keep their code, and the tip starts from a copy of it, laid out for the old modules. With the whole chain, every module's code is taken out, the base's included, and the chain is built again from the bottom:
176
+ - in the chat: the `regenerate` tool on the tip's `.plain` file with `from_scratch: "chain"`, or `/regenerate <tip> from scratch, the whole chain`;
177
+ - on the command line: `turri regenerate <tip>.plain --from-scratch-chain`.
178
+ 3. **Modules that require the chain** (updated in 3d) are regenerated after it, from scratch too (`from_scratch: "module"`): the modules they require are not the ones their code was built on. When the tip's whole chain is regenerated, a module built on top of it is a chain of its own — regenerating it from scratch with its whole chain instead covers the tip's chain too, in one go.
179
+ 4. **The original module's codebase** (`plain_modules/<original-module>/`), when the original module was deleted or renamed, is no longer built from anything. Tell the user it is there; it is theirs to delete. Do not delete it unasked.
180
+
165
181
  ## Common Pitfalls
166
182
 
167
183
  ### Splitting too aggressively
@@ -179,9 +195,12 @@ This is a refactoring, not a rewrite. Spec text must be copied verbatim. If a sp
179
195
  ### Losing acceptance tests
180
196
  Acceptance tests are nested under their parent functional spec. When moving a spec to a new module, its acceptance tests must move with it.
181
197
 
198
+ ### Regenerating only what changed
199
+ After a split the existing code was built for a module layout that no longer exists. Regenerating incrementally either stops at a codebase that has to be started over or builds on code laid out for the old modules. Regenerate the whole chain from scratch.
200
+
182
201
  ## Validation Checklist
183
202
 
184
- - [ ] User confirmed the split plan before execution
203
+ - [ ] User confirmed the split plan before execution, including regenerating the whole chain from scratch
185
204
  - [ ] All original functional specs are present in exactly one new module — none lost
186
205
  - [ ] Spec text is identical to the original — no rewording
187
206
  - [ ] Acceptance tests moved with their parent specs
@@ -194,3 +213,6 @@ Acceptance tests are nested under their parent functional spec. When moving a sp
194
213
  - [ ] Original module removed or updated
195
214
  - [ ] Downstream modules (if any) updated to require the chain tip, plus any earlier chain modules whose exported concepts they reference
196
215
  - [ ] User approved the final result
216
+ - [ ] Every new module validates
217
+ - [ ] The tip of the chain regenerated from scratch with its whole chain, then any module that requires it
218
+ - [ ] User told about the original module's leftover codebase, if there is one
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@turri-dev/cli",
3
- "version": "0.1.3-next.f74e98a",
3
+ "version": "0.1.4-next.172be6f",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "repository": {
@@ -33,8 +33,8 @@
33
33
  "grammar:sync": "node scripts/sync-plyn-grammar.mjs"
34
34
  },
35
35
  "dependencies": {
36
- "@earendil-works/pi-coding-agent": "^1.1.0",
37
- "@earendil-works/pi-tui": "^1.1.0",
36
+ "@earendil-works/pi-coding-agent": "^1.2.0",
37
+ "@earendil-works/pi-tui": "^1.2.0",
38
38
  "@langchain/langgraph": "1.4.15",
39
39
  "gray-matter": "^4.0.3",
40
40
  "js-yaml": "^5.4.2",
@@ -1,44 +0,0 @@
1
- # Bud Checklist
2
-
3
- Use this to verify the workflow was followed - never as a substitute for it. Walk it once in the
4
- review step, before the handover. A box counts only when the change is in the `.plain` files, not
5
- merely discussed; an unmet box is completed with a spec diff before finishing.
6
-
7
- ## Intent
8
-
9
- - [ ] Asked the five core questions of `references/intent.md` one at a time - or confirmed in one
10
- line what the user had already said - with at most one clarification for a vague answer.
11
- - [ ] Wrote nothing to disk before the brief was confirmed.
12
- - [ ] Summarized motivation, affected user, desired outcome, observable success criterion, and
13
- boundary with explicit exclusions; got explicit confirmation.
14
-
15
- ## Scope
16
-
17
- - [ ] Read the target `.plain` file(s) whole, with their `import` and `requires` chains, and the
18
- config that says whether conformance tests are on.
19
- - [ ] Asked which module only when it was genuinely ambiguous.
20
-
21
- ## Every product question
22
-
23
- - [ ] Asked exactly one question via `ask_user`, about the product - a trigger and outcome, an edge
24
- case, a rule, a permission, a step of a flow - never about a spec section.
25
- - [ ] Turned the answer into exactly one spec change, across every section it needed, and wrote it
26
- with `write_spec_diff` - never with `write` or `edit`.
27
- - [ ] Concepts defined in the same change as, or before, what first uses them; no cycles.
28
- - [ ] Every functional spec follows `add-functional-spec`'s rules, passed its complexity and
29
- conflict checks, and sits in build order; one too big was split with the user.
30
- - [ ] Every change to something already specified - built or still queued - was put to the user
31
- first (keep / augment / replace) and written as a diff with `fixes_earlier`.
32
- - [ ] Every correction of this feature's own changes was a diff with `fixes_earlier`, before the
33
- next question.
34
- - [ ] `***test reqs***` and `***acceptance tests***` only with conformance tests on.
35
- - [ ] Asked whether the feature is fully covered before leaving the loop.
36
-
37
- ## Review
38
-
39
- - [ ] Read the modified `.plain` file(s) whole and checked: concepts defined before use, no cycles,
40
- build order right end to end, functional specs language-agnostic, every external interface
41
- explicit, acceptance tests consistent with their functional specs.
42
- - [ ] Ran `validate` on every module touched, and fixed what it reported with spec diffs.
43
- - [ ] Handed over: the spec changes in order, the builds they queued and how they stand, and that
44
- further changes are asked for in the conversation as spec diffs.