@turri-dev/cli 0.4.3-next.620bae9 → 0.4.3-next.8482fed

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 (78) hide show
  1. package/README.md +1 -0
  2. package/dist/background-skills.d.ts +4 -1
  3. package/dist/background-skills.js +9 -1
  4. package/dist/capture/agents.d.ts +361 -0
  5. package/dist/capture/agents.js +332 -0
  6. package/dist/capture/area.d.ts +58 -0
  7. package/dist/capture/area.js +197 -0
  8. package/dist/capture/assemble.d.ts +122 -0
  9. package/dist/capture/assemble.js +452 -0
  10. package/dist/capture/capture.d.ts +116 -0
  11. package/dist/capture/capture.js +1228 -0
  12. package/dist/capture/chat.d.ts +29 -0
  13. package/dist/capture/chat.js +94 -0
  14. package/dist/capture/checks.d.ts +142 -0
  15. package/dist/capture/checks.js +643 -0
  16. package/dist/capture/config.d.ts +13 -0
  17. package/dist/capture/config.js +60 -0
  18. package/dist/capture/interface.d.ts +71 -0
  19. package/dist/capture/interface.js +199 -0
  20. package/dist/capture/map.d.ts +56 -0
  21. package/dist/capture/map.js +530 -0
  22. package/dist/capture/progress.d.ts +108 -0
  23. package/dist/capture/progress.js +234 -0
  24. package/dist/capture/report.d.ts +75 -0
  25. package/dist/capture/report.js +267 -0
  26. package/dist/capture/scripts.d.ts +26 -0
  27. package/dist/capture/scripts.js +33 -0
  28. package/dist/capture/state.d.ts +296 -0
  29. package/dist/capture/state.js +43 -0
  30. package/dist/capture/trial.d.ts +34 -0
  31. package/dist/capture/trial.js +89 -0
  32. package/dist/capture-cli.d.ts +1 -0
  33. package/dist/capture-cli.js +77 -0
  34. package/dist/cli.js +32 -14
  35. package/dist/config-edit.js +1 -0
  36. package/dist/config.d.ts +15 -2
  37. package/dist/config.js +57 -3
  38. package/dist/extension.js +125 -3
  39. package/dist/identity.js +2 -1
  40. package/dist/init-config.js +1 -0
  41. package/dist/loop-cli.js +5 -1
  42. package/dist/loop-tools.js +5 -1
  43. package/dist/new-project.d.ts +5 -0
  44. package/dist/new-project.js +11 -0
  45. package/dist/pi.js +2 -2
  46. package/dist/plain-code-blocks.d.ts +14 -0
  47. package/dist/plain-code-blocks.js +56 -0
  48. package/dist/regenerate/command-check.js +80 -11
  49. package/dist/regenerate/loop.js +9 -1
  50. package/dist/regenerate/test-scripts.d.ts +5 -0
  51. package/dist/regenerate/test-scripts.js +4 -0
  52. package/dist/reopen.d.ts +29 -0
  53. package/dist/reopen.js +47 -0
  54. package/dist/setup.js +9 -1
  55. package/docs/README.md +2 -0
  56. package/docs/capture.md +191 -0
  57. package/docs/config.md +14 -2
  58. package/docs/development.md +4 -1
  59. package/docs/regenerating.md +1 -1
  60. package/docs/sandbox.md +2 -2
  61. package/docs/theming.md +1 -1
  62. package/docs/using.md +5 -1
  63. package/genome/capture/capture.md +26 -0
  64. package/genome/capture/check-conventions.md +5 -0
  65. package/genome/capture/check-reference.md +11 -0
  66. package/genome/capture/concepts.md +3 -0
  67. package/genome/capture/divide.md +9 -0
  68. package/genome/capture/feature.md +45 -0
  69. package/genome/capture/interface.md +9 -0
  70. package/genome/capture/modules.md +23 -0
  71. package/genome/capture/outline.md +11 -0
  72. package/genome/capture/readability.md +12 -0
  73. package/genome/capture/reference.md +10 -0
  74. package/genome/capture/split.md +9 -0
  75. package/genome/capture/survey.md +37 -0
  76. package/genome/capture/trial.md +18 -0
  77. package/genome/capture/verify.md +7 -0
  78. package/package.json +1 -1
@@ -193,6 +193,10 @@ const SKILL = {
193
193
  unit: { skill: "implement-unit-testing-script", file: "run_unittests", what: "unit testing script" },
194
194
  conformance: { skill: "implement-conformance-testing-script", file: "run_conformance_tests", what: "conformance testing script" },
195
195
  };
196
+ /** The skill that writes a testing script of a kind, and what the script is called in words. */
197
+ export function testingScriptSkill(kind) {
198
+ return { skill: SKILL[kind].skill, what: SKILL[kind].what };
199
+ }
196
200
  /** The kind of testing script a skill writes, by its name - one that writes none, undefined. */
197
201
  export function scriptKindOfSkill(skill) {
198
202
  return Object.keys(SKILL).find((kind) => SKILL[kind].skill === skill);
@@ -0,0 +1,29 @@
1
+ /**
2
+ * turri opened again in another folder, in the same terminal, once its chat has quit: a chat works on the project of
3
+ * the folder it was opened in, and after a capture the work is in another - `plain/`, a project of its own. `turri`
4
+ * (cli.ts) starts the chat as a process of its own, with turri's theme, its screen and the folder's models, and names
5
+ * it a file to write in: a chat that is to open again elsewhere writes where, with what, and quits; `turri` reads it and
6
+ * starts the chat there as it started the first - the theme, the screen and that folder's models worked out the same.
7
+ * A chat `turri` did not start - a host's, a desktop app's - has no file, and is never offered it.
8
+ */
9
+ /** The file the chat `turri` started writes where it is to open again. */
10
+ export declare const REOPEN_FILE_ENV = "TURRI_REOPEN_FILE";
11
+ /** Said to the chat opened again, at its start: the capture whose report it tells - what the capture said of itself. */
12
+ export declare const REOPENED_AFTER_CAPTURE = "TURRI_REOPENED_AFTER_CAPTURE";
13
+ export interface Reopening {
14
+ /** The folder the chat opens in. */
15
+ dir: string;
16
+ /** Its arguments, as `turri` takes them. */
17
+ args: string[];
18
+ /** What it is told at its start, in its environment. */
19
+ env: Record<string, string>;
20
+ }
21
+ /** Whether this chat can open again in another folder: `turri` started it. */
22
+ export declare function canReopen(): boolean;
23
+ /** Ask `turri` to open the chat again in `dir` once it has quit - the caller quits it. False when it cannot (`canReopen`). */
24
+ export declare function reopenIn(dir: string, options?: {
25
+ args?: string[];
26
+ env?: Record<string, string>;
27
+ }): boolean;
28
+ /** What the chat that quit asked for, taken - its file removed - or undefined when it asked for nothing. */
29
+ export declare function takeReopening(file: string): Reopening | undefined;
package/dist/reopen.js ADDED
@@ -0,0 +1,47 @@
1
+ import { readFileSync, rmSync, writeFileSync } from "node:fs";
2
+ /**
3
+ * turri opened again in another folder, in the same terminal, once its chat has quit: a chat works on the project of
4
+ * the folder it was opened in, and after a capture the work is in another - `plain/`, a project of its own. `turri`
5
+ * (cli.ts) starts the chat as a process of its own, with turri's theme, its screen and the folder's models, and names
6
+ * it a file to write in: a chat that is to open again elsewhere writes where, with what, and quits; `turri` reads it and
7
+ * starts the chat there as it started the first - the theme, the screen and that folder's models worked out the same.
8
+ * A chat `turri` did not start - a host's, a desktop app's - has no file, and is never offered it.
9
+ */
10
+ /** The file the chat `turri` started writes where it is to open again. */
11
+ export const REOPEN_FILE_ENV = "TURRI_REOPEN_FILE";
12
+ /** Said to the chat opened again, at its start: the capture whose report it tells - what the capture said of itself. */
13
+ export const REOPENED_AFTER_CAPTURE = "TURRI_REOPENED_AFTER_CAPTURE";
14
+ /** Whether this chat can open again in another folder: `turri` started it. */
15
+ export function canReopen() {
16
+ return (process.env[REOPEN_FILE_ENV] ?? "") !== "";
17
+ }
18
+ /** Ask `turri` to open the chat again in `dir` once it has quit - the caller quits it. False when it cannot (`canReopen`). */
19
+ export function reopenIn(dir, options = {}) {
20
+ const file = process.env[REOPEN_FILE_ENV];
21
+ if (file === undefined || file === "")
22
+ return false;
23
+ const reopening = { dir, args: options.args ?? [], env: options.env ?? {} };
24
+ writeFileSync(file, JSON.stringify(reopening));
25
+ return true;
26
+ }
27
+ /** What the chat that quit asked for, taken - its file removed - or undefined when it asked for nothing. */
28
+ export function takeReopening(file) {
29
+ let text;
30
+ try {
31
+ text = readFileSync(file, "utf8");
32
+ }
33
+ catch {
34
+ return undefined;
35
+ }
36
+ rmSync(file, { force: true });
37
+ try {
38
+ const parsed = JSON.parse(text);
39
+ if (typeof parsed.dir !== "string" || !Array.isArray(parsed.args) || parsed.args.some((arg) => typeof arg !== "string"))
40
+ return undefined;
41
+ const env = Object.fromEntries(Object.entries(parsed.env ?? {}).filter((entry) => typeof entry[1] === "string"));
42
+ return { dir: parsed.dir, args: parsed.args, env };
43
+ }
44
+ catch {
45
+ return undefined;
46
+ }
47
+ }
package/dist/setup.js CHANGED
@@ -10,7 +10,7 @@ import { fetchLatest, newerThan, turrisOnPath, versionFindings } from "./turri-v
10
10
  import { sandboxAvailable, sandboxWithAsync } from "./regenerate/os-sandbox.js";
11
11
  import { findTestScripts, onThisMachine } from "./regenerate/test-scripts.js";
12
12
  import { configKeyOptions, parseArgs } from "./cli-options.js";
13
- import { CONFIG_FILE, hasProjectConfig, readProjectConfig, moduleConfigFile, configModuleOf, moduleConfigsOf } from "./config.js";
13
+ import { CONFIG_FILE, hasProjectConfig, readProjectConfig, moduleConfigFile, configModuleOf, moduleConfigsOf, configProblems } from "./config.js";
14
14
  import { checkModels, modelsInUse, piModelAccess } from "./model-check.js";
15
15
  import { bedrockRegionFor, describeBedrockRegion, regionInGeography } from "./bedrock-region.js";
16
16
  import { baseFilesAsync } from "./regenerate/base-folder.js";
@@ -230,6 +230,14 @@ async function allChecks(options) {
230
230
  const project = options.dir;
231
231
  if (project === undefined)
232
232
  return checks;
233
+ // A config that does not parse is read as empty - every setting at its default, the models pi's own: said first.
234
+ checks.push(...configProblems(project).map((problem) => ({
235
+ level: "missing",
236
+ name: "Config",
237
+ detail: problem.text,
238
+ more: [`turri reads a config that does not parse as empty: none of ${problem.file} applies - not its models, not conformance tests, no other setting.`],
239
+ fix: `Set each key once in ${problem.file}, then run turri doctor again`,
240
+ })));
233
241
  if (hasProjectConfig(project) || existsSync(join(project, "plain_modules")))
234
242
  checks.push(...(await checkProject(project, { has: (command) => onThisMachine(command, env) !== undefined })));
235
243
  if (hasProjectConfig(project))
package/docs/README.md CHANGED
@@ -16,6 +16,7 @@ turri is the first coding agent with the power of regenerative software: [\*\*\*
16
16
  | what my machine needs, and why a check failed | [installation](installation.md) |
17
17
  | what turri needs of this machine, and what `turri doctor` checks | [installation](installation.md#what-turri-doctor-checks) |
18
18
  | how to start a project, or add a feature, in a conversation | [using](using.md#in-a-conversation) |
19
+ | how to bring an existing codebase under \*\*\*plain | [capture](capture.md) |
19
20
  | how to have several chats open at once, and reopen them | [chats](chats.md) |
20
21
  | what checks each pulse as it finishes, and tells me what needs me | [the sentinel](sentinel.md) |
21
22
  | which model codes, and how to change it | [using](using.md#choosing-a-model), [the project config](config.md#models) |
@@ -48,6 +49,7 @@ turri is the first coding agent with the power of regenerative software: [\*\*\*
48
49
  | [A Claude subscription](claude-subscription.md) | running every agent on a Claude Pro, Max or Team subscription through Claude Code: setting it up, its models, checking it yourself, in turri-desktop, its limits, when it does not work |
49
50
  | [The project config](config.md) | `config.turri.yaml` and a module's own `config.turri.<module>.yaml`: where they are read from, every key, models and their inheritance, conformance, the testing scripts, which file builds a module, the old `config.yaml` |
50
51
  | [Launch](launch.md) | trying what is built: the launch track, a commit in dist/<module>, starting it on your machine, after every pulse, `turri launch` |
52
+ | [Capture](capture.md) | an existing codebase captured into \*\*\*plain, offline: what it aims for, how it scales, what it writes, the report, resuming |
51
53
  | [Running unattended](headless.md) | regenerating overnight or in CI: before you leave it, the command, the results, resuming, rebuilding one functionality |
52
54
  | [Authoring \*\*\*plain](authoring-plain.md) | a \*\*\*plain project, what \*\*\*plain is made of, the rules, writing \*\*\*plain with the agent, the skills, checking \*\*\*plain |
53
55
  | [Regenerating](regenerating.md) | where things go, one job, a whole module and how its work is cut into jobs, each job's cases, \*\*\*plain changes, conformance tests, the two records of what is built |
@@ -0,0 +1,191 @@
1
+ # Capture
2
+
3
+ Capture takes an existing codebase and captures what it does into \*\*\*plain. From then on you work on the \*\*\*plain: the code is regenerated from it, and the original codebase is abandoned.
4
+
5
+ ```bash
6
+ cd ~/my-app
7
+ turri capture # this folder, into ./plain
8
+ turri capture ../other-app --harness-model anthropic/claude-opus-4-5 --coding-model anthropic/claude-sonnet-4-5
9
+ ```
10
+
11
+ In the chat, `/capture [path]` does the same in the background. Only you start it: the chat can tell you about it, but cannot run it, since a capture turns conformance tests on in the project it writes (`src/capture/`).
12
+
13
+ While it runs, the lines above the input show how far it is and what is left (`src/capture/progress.ts`):
14
+
15
+ ```
16
+ capture shorty ✓ survey ━ ✓ outline ━ ⠋ features ─ ○ concepts ─ ○ readability ─ ○ interface ─ ○ trial ─ ○ scripts phase 3 of 8
17
+ ██████████▓▓▓▓▓▓▓▓▓▓▓▓▓▓ 1 of 3 features captured, 2 at work · 2m 10s · $0.84
18
+ feature shorty#shorten-link 40s ○ read app/api/links.py · thinking
19
+ feature shorty#follow-link 15s ○ read app/repositories/sqlite.py · waiting for the model
20
+ captured shorty#service-info: 1 functional spec
21
+ ```
22
+
23
+ - **The phases,** drawn as a skill's are: those done ticked, the one it is in spinning, those to come, and which of the eight it is in.
24
+ - **Under them, the phase's own work,** where it is counted, as the regen panel draws functional specs: done in green, at work in the accent colour, waiting `▓`. Then that work in words - while outlining, the features outlined so far and the areas still to outline; then the features captured of those to capture - how long the capture has taken, and what its models have cost.
25
+ - **A line for each agent at work:** what it captures, for how long, the last file it read or searched, and what it is doing now.
26
+ - **The last line:** what the capture said last.
27
+
28
+ `turri capture` prints a line as each step ends.
29
+
30
+ When it ends, turri asks whether to open the captured project. A chat works on the project of the folder it was opened in, and `plain/` is a project of its own. So on yes, the chat closes and `turri` starts it again in `plain/`, as it started the first - turri's theme, its screen, that folder's config - on the chat's model and thinking (`src/reopen.ts`). There, `ctrl+h` shows its \*\*\*plain, `/regenerate` builds it, and the chat tells you its report. On no, the chat tells you the report where you are, and `cd plain && turri` opens it later. A host - a desktop app - opens projects itself, so it is not asked.
31
+
32
+ ## What it aims for
33
+
34
+ **The interface, whole and exact.** What a user, a client or a script calls is the contract the regenerated software must keep, call for call: every command and subcommand; every option with each name it has, its value, choices and default; every route with its method, path, parameters, fields and status codes; every environment variable and configuration key; every message, output format and exit code a script sees. It is never guessed, never left out as obvious or as the stack's - a stack says how errors are shaped, never which options exist - and never cut for readability. So it is not left to prose at all. It is taken from the code as data - each entry checked against the code it cites - into each part's **interface reference**, a linked resource beside the \*\*\*plain (`resources/interface/<part>.md`) that every functional spec about it carries, through the part's interface concept (`:HttpieInterface:`), to every agent that regenerates or tests the code: the details exact there, the prose free to name them and say what each does. Then capture holds the \*\*\*plain to it: the conventions every feature follows are checked against the code before any feature is written; each writer works from the reference's entries in its feature's files; what no functional spec names goes to a writer of its own; and each module's \*\*\*plain is checked against the reference and the code at the end (steps 3, 4, 8, 9 and 13 below).
35
+
36
+ **Scenarios that hold on the original.** The scenarios are what the regenerated code's conformance tests check, so one the original itself fails is wrong twice: a coding agent builds to it, or its module's tests fail for good. They are written by agents that read the original and never run it, so before the \*\*\*plain is written each is run against a copy of the original, as its conformance test will run it, and corrected to what the original does (step 14). And each module is a concern of its own, never one that holds everything, put in the order its behaviour is built in, so its scenarios need only the modules before it (step 10).
37
+
38
+ **Readable \*\*\*plain, not a transcript of the code** - about everything else. An agent that reads code tends to write every detail down, and \*\*\*plain nobody can read is \*\*\*plain nobody reviews. Every capture agent is told (`genome/capture/capture.md`):
39
+
40
+ - **What someone sees, not what the code does.** A line stays when a user or client would notice the difference and care. Function names, file layout, helpers and internal data shapes are left out.
41
+ - **Only where the code departs from the default.** The default is the stack's conventions, the domain's conventions, and the functional specs before this one. An odd rule is written exactly; cookie-cutter behaviour takes a line or none.
42
+ - **Exact where exactness is the contract.** Endpoints, fields, status codes, flags and formats are captured exactly.
43
+ - **Edge cases go in scenarios.** A functional spec states the rule - `the url is an absolute http or https URL` - and its scenarios pin the edges with concrete values. An example, or what one wrong input answers (`nope` answers 422 `validation_error`), is a scenario's, never said again in the functional spec. How a wrong input is answered is the stack's, unless the original answers otherwise.
44
+
45
+ **About 80% right.** Capture tries its scenarios on the original, but does not regenerate and compare. You close the gap afterwards: regenerate, run the original's tests (or the conformance tests written from the scenarios) against the result, and capture what is missing as ordinary \*\*\*plain changes.
46
+
47
+ **Offline.** No capture agent can ask anything. Whatever the code leaves open, each agent decides itself, and says so. The [report](#the-report) collects every such decision.
48
+
49
+ ## How it works
50
+
51
+ The cost of a capture follows the number of features, not lines of code. However large the codebase, no agent sees more than a fixed budget. Size only changes how many agents run and how deep the split goes.
52
+
53
+ 1. **The map** (`src/capture/map.ts`), with no model. Every file the codebase holds, read through git when it is a repo, so what git ignores is left out. Also left out: dependencies, caches, capture's own output folder, and any turri project inside the codebase (a folder with a `config.turri.yaml`, an earlier capture's among them), since its \*\*\*plain is not the code. Each file gets:
54
+ - its kind: source, test, doc, asset, contract, manifest
55
+ - its lines
56
+ - the surfaces patterns find in it: routes, commands, options with every name each has (`-v, --verbose`), screens, the environment variables it reads, tables and models, test names, exports. A file keeps its whole interface - seventy options are seventy - and a sample of the rest.
57
+ - the codebase's own files it imports
58
+
59
+ The patterns cover common frameworks:
60
+ - **Python:** Flask, FastAPI, Django, click, typer, argparse
61
+ - **JavaScript and TypeScript:** Express, Fastify, NestJS, React Router, Vue Router, file-routed Next.js and SvelteKit, commander
62
+ - **Go:** net/http, gin, echo, chi, cobra
63
+ - **Java:** Spring, picocli
64
+ - **Rust:** axum, actix, clap
65
+ - **Ruby:** Rails
66
+ - **SQL:** tables in schema and migration files
67
+
68
+ A file no pattern fits is still on the map, by its size.
69
+ 2. **The survey.** One agent is shown the map of the whole codebase, folded to its budget, with the manifests, the README and the standard library's catalogue. It names the parts: software on one stack each, like a backend and a frontend. For each part it gives:
70
+ - the stack - a `stdlib/` template only when the original agrees with it, otherwise written out as implementation reqs
71
+ - its conventions: what every feature does the same way and a user or a script relies on - how an error is written, the exit code or status of each kind of failure, what changes without a terminal. For software that talks to other software, also what reaches the other side on every call, whichever feature makes it: the headers it adds of its own, how bodies and header values are encoded - JSON's separators, non-ASCII escaped or not, the charset - and when a body is sent or read whole, streamed, or not read at all. No feature's writer looks at the wire. Each is settled from the code that does it, never from a declaration or a framework's default, and names the files that decide it. They go into the part's import module as implementation reqs, and every feature's agent is handed them as settled, so no two features decide an exit code differently.
72
+ - how its black-box tests run, from the original's own tests and the harness they run under: what standard input is, the environment, the servers they start - a conformance test run otherwise tests another program. Then what every test sets up so the software acts the same on every run and machine: what it fetches or checks on its own (an update check, telemetry) off or pointed at a local stand-in; a home and a configuration folder of the test's own; the terminal width fixed (`COLUMNS`) where its output wraps; a pseudo-terminal where it prompts on one; local servers, never the internet
73
+ - its core concepts
74
+
75
+ It also names what is not the software (vendored, generated, tooling). It may never leave out the original's tests, which are the evidence of what the software does.
76
+ 3. **The conventions checked.** Before any writer is given them, an agent per part checks each convention against the code it names - the entry point, where errors are caught, written and exited, where a request is built and sent or a response written - and corrects what does not hold, saying why. Every feature follows them, so one that is wrong is wrong everywhere. A check that never holds leaves them as surveyed, and the report says so.
77
+ 4. **The interface reference.** The interface is taken from the code as data, before any feature is outlined (`src/capture/interface.ts`, `genome/capture/reference.md`). The files where the map found it are given to agents, up to 4000 lines and 12 files each, and each agent lists every command, argument, option, route and environment variable they define - and any the map missed - as entries: the name exactly as the code has it, every other name, the command it belongs to, what it takes, its choices, its default, whether it repeats, is required or is hidden, its help word for word, a route's parameters, fields and statuses, and where it is defined. The harness checks each entry against the code with no model (`referenceProblems`): its `where` is a line of a file of the map, and every literal it gives - each name, alias, choice, default and the start of its help - is in that file or in the files it names as where one is worked out. A literal the code does not have sends the entry back, and so does any surface the map found in the files that is neither listed nor excluded with why. Then a fresh agent checks it against the code, as the conventions are - what checking literals cannot see: a help text cut to its first line, choices left out or worked out when the program runs, an environment variable read through a constant - and corrects or adds each, citing the line that shows it, its answer checked again as the first was; what it changed is in the report, to read first: a checker can be wrong too. The entries become the part's interface reference, `resources/interface/<part>.md`, linked from the part's interface concept, defined in what every module of the part imports: every functional spec that uses it carries the reference, whole, to its coding and conformance agents. A part none of whose entries held has no reference, and its writers work from the map, as do those of files whose agent never held.
78
+ 5. **The split.** An area of more than 6000 lines (`TURRI_CAPTURE_LEAF_LINES`) goes to an agent that splits it into smaller areas by what they do. Each smaller area that is still too large is split again, so depth grows only slowly with size. The harness puts the areas in the order of their code: an area whose files import another's comes after it. The modules are gathered by concern and put in the order their behaviour is built in once the features are written (step 10).
79
+ 6. **The outline.** An area that fits is outlined by one agent into features, in build order. Each feature is something a user can do, with the files where it is built. The agent sees the stack's templates too: infrastructure they settle - settings, logging, error bodies, middleware - is no feature, and is left out as settled by the stack, unless a user would notice the original does it differently.
80
+ 7. **The features divided.** Once every area of a part is outlined, one agent sees all its features, area by area, with what each is about and where it is built, and gives each behaviour to one feature. The outlines are made area by area from each area's own files, so the same behaviour can be outlined twice - an option parsed in one area and acted on in another, a message printed in a third - and written twice it reads twice, in different words, and contradicts itself. Each feature that stays gets a line of what it alone owns; a feature that is a slice of another's behaviour is merged into it, its files the other's, and not written. A part outlined as one area is not divided: one agent saw all of it. A division that never holds leaves each feature owning what it was outlined for.
81
+ 8. **The features, side by side.** One agent per feature, up to `--parallel` (4) at once. Each is given the full text of the `stdlib/` templates its part is built on - the stack, its kind's `common`, its language's - as the default it never restates, the part's conventions, every feature of the part with what it owns, and the reference's entries in its feature's files, with what the map found there that the reference does not list: it captures what each piece its feature owns does, by its exact name, using the part's interface concept - what one takes, its choices, its default and its help left to the reference, said only where a behaviour turns on them and never otherwise - and never another feature's behaviour, even where its code or tests touch it. Each follows the feature's surfaces through the code, reads the original's tests of it, then writes:
82
+ - at most 8 functional specs
83
+ - the concepts they need beyond the part's
84
+ - its scenarios, mimicking the original's black-box tests - a test that runs the software through its interface, in its own process or the test's - and spent where those are densest: a functional spec the original tests twenty ways gets several, error cases no larger share than the original gives them. Where the original has no test of a spec, it gets scenarios only when it can fail silently, can be read two ways, or is costly when wrong. A feature may have 8 scenarios, and one more for every 50 lines of the original's tests in its files, up to 30; its agent is shown those test files, their lines and their tests' names. Each scenario expects what the original does under the test reqs: output that is not a terminal unless they give one, a local server rather than the internet - never a unit test that mocks a library, recast.
85
+ 9. **The interface no feature captured.** Once every feature is written, the harness matches the interface - the reference's entries, and what the map found in the parts' files that the reference neither lists nor excludes - against the \*\*\*plain: an option, command or variable as a word of its own, a route by its path under any prefix, its parameters written any way. What no feature names goes to a writer of its own, as a feature added to the area whose files define it, up to 30 surfaces a writer. It captures each exactly - or, for one that is not the software's interface, such as a development script's option, names it in `dropped` with why - and is sent back until every one is settled. A capture leaves no interface out by accident.
86
+ 10. **The modules, by concern and in build order** (`genome/capture/modules.md`). A module is a concern of its own - what a person looks for in one file: request sending, output formatting, sessions, downloads. One module that holds everything is as hard to read as the code, and every change to it regenerates all of it. The code's areas are gathered into modules by size alone (see [modules](#what-it-writes)), so a small codebase's every concern can land in one. And a module is built on the code of the modules before it, its scenarios run as soon as it is built, with nothing after it there - yet the areas are in the order of their code's imports, which is not the order behaviour is built in: the code that runs everything imports everything - httpie's request sending imports its output formatting and its sessions - so output formatting's scenarios, which send a request and print the answer, could not pass before it. So for each part of more than one feature, an agent is shown every feature, area by area, with what it owns, its functional specs and scenarios, and the modules as the areas make them, and gathers the features into modules by concern - a feature with another only when it is part of that concern, a concern past about 40 functional specs two modules - and puts them in the order they are built, naming for each the modules before it that its functional specs build on and its scenarios run. A scenario that needs a module after its own whatever the order - two modules each needing the other - is rewritten to check the same with only those before it, never merged away. The harness checks that every feature is in one module, that one module never holds a part larger than a module, that none holds more than twice that, and that each module needs only those before it. It runs once, before anything is done module by module; an answer that never holds leaves the modules as the areas make them, in the order of their code, and the report says so.
87
+ 11. **Concepts reconciled.** A concept two features defined in different words is given one definition by an agent that sees the definitions and the specs that use it.
88
+ 12. **The readability pass.** For each module, an agent reads its \*\*\*plain - each functional spec with its scenarios - and the stack's templates, never the code. It rewrites the functional specs that read as code, or restate the stack, an earlier spec, or a case one of their scenarios pins. It must keep every fact the stack and the scenarios do not keep - every interface fact, however obvious - and may never make a spec longer. Like the unit review, it improves; it is not a gate.
89
+ 13. **The interface checked against the code.** For each module, an agent is given its \*\*\*plain - functional specs with their scenarios - the reference's entries in its features' files, and the options the \*\*\*plain names that the reference does not have, found mechanically, and checks every interface fact against the reference and the code that decides it: each option's names, value, choices and default; each route's method, path, fields and status codes; each message, format and exit code. It corrects what is wrong or left out, a functional spec's text or a scenario's, citing the code - over the readability pass, which never sees the code. A correction that never holds is not made.
90
+ 14. **The scenarios tried on the original** (`src/capture/trial.ts`, `genome/capture/trial.md`). Every agent before this one read the original and never ran it, so a scenario can expect a terminal its test will not give, a site on the internet, output wrapped at a width nobody set, or a message the original never prints. For each module, a copy of the original - the files the map has, so none of its installed dependencies, nor turri's own config files, and the lock files beside its manifests, so it installs what the original pins - is made under `.turri/capture/trial/<module>/`, and agents with a shell on it, 20 scenarios each, one after another, install the original there and run each scenario as its conformance test will: from outside, through its interface, under the part's test reqs and its stack's conformance template. Their shell is a coding agent's - the command check, a home, temporary folder and package caches of its own, the OS sandbox and the audit - fenced to the copy. Each scenario comes back `held`, with what was run and what the original answered; `corrected` to what the original does, keeping what it checks - a local server for a site on the internet, the option that forces colour where the test's output is no terminal; `removed`, when nothing outside can check it; or `untried`, with why, when the original would not run here - kept as written. A functional spec the original contradicts is corrected with its scenario, and what every test must set up for the original to act as the scenarios say - `COLUMNS`, a configuration folder of its own, an update check off - joins the part's test reqs. What only some scenarios need - a file one sends, a server answering one exact body, a pseudo-terminal for one prompt - is never a test req, which every conformance test of every module is written under: those scenarios are corrected to say it themselves, and a test req that names a scenario or a functional spec is sent back. The harness checks that every scenario has one result and that each held or corrected one says what was run. The copy is removed once the module's agents are done. An agent that never holds leaves its scenarios as written, and the report says so.
91
+ 15. **The files.** The modules, their scenarios, the interface references and the config are written, once.
92
+ 16. **The testing scripts.** turri's own skills write each part's unit and conformance testing scripts for the \*\*\*plain just written - `implement-unit-testing-script` and `implement-conformance-testing-script` (`src/capture/scripts.ts`), side by side, on `--coding-model` when given, else the capture's model. They run as the chat runs them in the background: nobody is asked, and a review gate that cannot be satisfied stands. So the captured project can be regenerated at once. A script that is not written does not stop the capture: the report says why, and which skill to ask for.
93
+ 17. **The check and the report.** The parser checks every module.
94
+
95
+ The harness checks every answer before keeping it, and sends it back with what is wrong, twice at most (`src/capture/checks.ts`). It checks:
96
+ - paths that are not in the codebase
97
+ - a convention that names no file deciding it
98
+ - ids that are not kebab-case
99
+ - concepts used and never defined
100
+ - a feature over its budget: functional specs, and scenarios past what the original's tests give it
101
+ - a line the parser would read as a heading
102
+ - a link, such as `<https://...>`: the parser refuses any link but one to a file of the project, so a URL is written as code
103
+ - a split that leaves files nowhere
104
+ - a division that leaves a feature with no owner, or merges one into itself, into nothing or into one merged too
105
+ - an entry of the interface reference with a literal the code it cites does not have, or a surface of the map neither listed nor excluded
106
+ - a writer of the interface no feature captured that leaves a surface neither captured nor dropped with why
107
+ - modules that leave a feature out or hold it twice, one module holding a part too large for one, or a module before one it needs
108
+ - a correction to a functional spec or scenario that is not there, or with no why
109
+ - a trial that leaves a scenario it was given with no result, says a scenario held or is corrected without saying what it ran against the original, or adds a test req that names a scenario or a functional spec - one scenario's setup, which its own text says
110
+
111
+ An answer that never holds does not stop the capture:
112
+ - **A split** falls back to an outline of the whole area.
113
+ - **A division** leaves each feature owning what it was outlined for.
114
+ - **An outline or a feature** is left uncaptured, and the report says so - a writer of the interface too, its surfaces then counted in the summary.
115
+ - **The modules by concern** stay as the code's areas make them, in the order of their code.
116
+ - **The conventions check, an interface correction or a trial** leaves what was there.
117
+
118
+ Only a survey that never holds stops the capture, before anything is written.
119
+
120
+ ## What it writes
121
+
122
+ ```
123
+ my-app/
124
+ ... the original - read only, never written
125
+ plain/
126
+ config.turri.yaml the config in use where the capture was started, conformance-tests: true, base-folder: assets
127
+ config.turri.<m>.yaml one per part, when there are several - where its testing scripts go
128
+ template/<part>-shared.plain what a part's modules share: the stack, test reqs, concepts used across modules
129
+ <module>.plain ... the modules, a concern each, in the order they are built, each requiring the one before it
130
+ tests/<module>/<func-id>.plain the scenarios of each functional spec that has them
131
+ test_scripts/ the unit and conformance testing scripts, written by turri's skills
132
+ resources/interface/<part>.md each part's interface reference, linked by its interface concept
133
+ assets/ the original's images, fonts and media, copied - the base folder
134
+ .gitignore keeps the regenerated code's histories out of the repo
135
+ .turri/capture/ state.json - what each agent answered - and report.md
136
+ ```
137
+
138
+ - **Modules.** Splitting decides what each agent sees; a module is a concern, what a person reads in one file. The code's areas make the modules an agent starts from: an area whose leaves hold 40 functional specs or fewer (`MODULE_SPECS`) is one module, named after the area, with its leaves' features in build order, and a larger area is its areas' modules, each worked out the same way. That is by size alone, so an agent then gathers the features into modules by concern and puts them in the order they are built (step 10): each module a concern, named for it, never one holding everything. Where its answer never holds, the modules stay as the areas make them.
139
+ - **Feature groups.** Each module's functional specs are grouped by feature, one feature's after another's, with no comment line between them.
140
+ - **Concepts.** A concept stays in the module that defines it when only that module uses it. A concept used across modules goes to the part's import module, along with every concept its definition uses.
141
+ - **The codebase is never written to.** Capture's agents only read it - read, grep, find, ls, and no shell - but for those that try the scenarios, which run the original in a copy of it, removed once they are done.
142
+ - **Assets.** The assets are copied rather than linked, so the original can be deleted without breaking anything. `base-folder: assets` puts them in the first module's code before its first pulse, at the paths they had.
143
+ - **The config.** The captured project's `config.turri.yaml` starts as the config in use where the capture was started - the chat's folder's, or the folder `turri capture` runs in (the nearest upwards that is a project's) - so the person's models, thinking, reviews, limits and every other setting they chose carry over (`src/capture/config.ts`). It is written as the capture starts, so its own agents run on those models too: its agents on the model you talk to, its testing scripts on the coding model. What belonged to the original project alone is left out - `module`, the testing scripts, `base-folder`, `test-dir` - since the capture writes its own; then `conformance-tests: true`, and the models given for it where they differ: in the chat, its model and thinking of the moment, and the coding model turri was started with; on the command line, `--harness-model` and `--coding-model`. With no config in use, it holds those alone. A config in use that does not parse refuses the capture, and nothing is written ([a config that does not parse](config.md#a-config-that-does-not-parse)).
144
+
145
+ ## The report
146
+
147
+ `plain/.turri/capture/report.md` replaces the questions a capture never asks. It lists:
148
+
149
+ - what was written
150
+ - the conventions every feature follows, with the files that decide each: wrong there, wrong everywhere - and what the check against the code changed
151
+ - what the check of each module's interface against the code corrected, and why
152
+ - the scenarios tried on the original: each one corrected to what the original does, removed or not tried, with why; the functional specs corrected with them; what was added to the test reqs. The summary says how many held as written.
153
+ - each part's modules by concern, in the order they are built, what each needs of those before it, and the scenarios rewritten to need only those before their own
154
+ - the features merged into others, and why
155
+ - the testing scripts: where each is, or why it was not written and which skill to ask for
156
+ - the parser's check
157
+ - what could not be captured
158
+ - features the original's tests cover that were captured with no scenario
159
+ - each part's interface reference: where it is, what it holds, what was left out of it and why, and what could not be taken
160
+ - the interface its \*\*\*plain still names nowhere - options, commands, routes, screens, environment variables - each with why its writer dropped it, or with none when no writer settled it. Those with no why are counted in the summary: a user could call them in the original and will not find them in what is regenerated.
161
+ - what was left out and why
162
+ - every assumption
163
+ - what the agents were unsure of
164
+ - what they dropped as incidental
165
+ - what to do next
166
+
167
+ Its first lines are the summary the command line and the chat show. In the chat, the report comes back once the capture ends, and the chat's agent passes it on.
168
+
169
+ ## Stopped, finished, run again
170
+
171
+ - **Stopped part-way.** Every answer is saved in `state.json` as it comes. Running the capture again goes on from where it was and asks no agent twice. This covers a quit, a crash, or a provider down for good.
172
+ - **Finished.** A finished capture is never run over. To capture again, move `plain/` out of the way.
173
+ - **A folder that is not a capture.** Capture refuses a `plain/` that holds anything but its own state, and `--into <folder>` names another folder.
174
+
175
+ ## Models
176
+
177
+ Capture's agents are the `capture` role (`models: capture:` in [the config](config.md#models-per-role)). Their model is:
178
+ - in the chat, the chat's model
179
+ - under `turri capture`, `--harness-model`
180
+ - otherwise, pi's default
181
+
182
+ They think at medium. A turn may take ten minutes, unless the role's entry, `default`'s or `turn-limit:` says otherwise - and an agent trying the scenarios on the original at least thirty, since it installs the original and runs twenty scenarios in its turn, unless the limit is turned off.
183
+
184
+ `--harness-model` and `--coding-model` are also written into the new project's config, for the chat and the regeneration that follow.
185
+
186
+ ## After a capture
187
+
188
+ 1. **Read the \*\*\*plain and the report,** in turri opened in `plain/`. From now on the \*\*\*plain is the source of truth.
189
+ 2. **Regenerate,** first module first: `/regenerate`. Its testing scripts are written already. Any the report says were not, ask turri for first (`implement-unit-testing-script`, `implement-conformance-testing-script`).
190
+ 3. **Compare with the original** by hand: its own tests, the scenarios' conformance tests, a look at what is launched. Each difference becomes a \*\*\*plain change.
191
+ 4. **Abandon the original** once you are satisfied.
package/docs/config.md CHANGED
@@ -139,6 +139,7 @@ Keys are written with dashes; underscores are read the same (`mutation_testing`)
139
139
  | `chat` | `turri`'s model - the same as `harness-model`, which it wins over |
140
140
  | `sentinel` | [the sentinel](sentinel.md): checks every finished pulse, and tests what was launched. Unnamed, the chat's model |
141
141
  | `planner` | the conversation's side: the planner's agents. Unnamed, the chat's model |
142
+ | `capture` | the agents of [a capture](capture.md): they write \*\*\*plain from an existing codebase. Unnamed, the chat's model - `--harness-model` under `turri capture`. A turn may take ten minutes unless its entry, `default`'s or `turn-limit:` says otherwise - one trying the scenarios on the original at least thirty, unless the limit is off |
142
143
  | `diagnosis` | the diagnosis of a job that failed for good: why it did not land, and what to do. Unnamed, the coding model the job ran on, thinking medium |
143
144
  | `launch` | the launch agent - the chat's `launch`, `turri launch` and launch-after-pulse's: it follows steps - a script, a start command - so it runs on the coding model, thinking low |
144
145
  | `coding` | the coding agent, the code fixer of a conformance run and the repair agent - the same as `coding-model`, which it wins over. `--model` on the command line, or a model a call to `regenerate` or `conform` names, wins over both |
@@ -152,7 +153,7 @@ Keys are written with dashes; underscores are read the same (`mutation_testing`)
152
153
 
153
154
  What an entry leaves out it takes from `default`: `reviewer: { thinking: low }` runs the default model, thinking little. A turn limit is the role's own, else `default`'s, else `turn-limit:`, else two minutes. A module's `config.turri.<module>.yaml` lays its own `models:` over the project's, role by role - all but `chat`, the project's alone.
154
155
 
155
- A role whose thinking nothing names - neither its entry, `default`'s, nor a `:level` on the model it runs on - thinks as its kind of work needs: **low** for the agents that do the work (`coding`, `conformance`, `explorer`, `launch`), which work from \*\*\*plain that leaves little to guess and take many turns, and **medium** for the ones that judge (`reviewer`, `test-reviewer`, `judge`, `arbiter`, `debugger`, `planner`, `diagnosis`), where a wrong call costs pulses. A judging role that falls back on the coding model takes its model alone, not its thinking. The conversation keeps its own level, as [pi](https://pi.dev) sets it.
156
+ A role whose thinking nothing names - neither its entry, `default`'s, nor a `:level` on the model it runs on - thinks as its kind of work needs: **low** for the agents that do the work (`coding`, `conformance`, `explorer`, `launch`), which work from \*\*\*plain that leaves little to guess and take many turns, and **medium** for the ones that judge (`reviewer`, `test-reviewer`, `judge`, `arbiter`, `debugger`, `planner`, `capture`, `diagnosis`), where a wrong call costs pulses. A judging role that falls back on the coding model takes its model alone, not its thinking. The conversation keeps its own level, as [pi](https://pi.dev) sets it.
156
157
 
157
158
  The thinking level reaches the model as each provider takes it. OpenAI's models on Bedrock are sent it as their reasoning effort (`none`, `low`, `medium`, `high`, `xhigh`) by turri itself, as [pi](https://pi.dev) sends them none.
158
159
 
@@ -286,4 +287,15 @@ turri's settings were once in `config.yaml`, and a module's own in `config.<modu
286
287
 
287
288
  The first time turri itself writes a setting there with `/settings`, it copies `config.yaml` to `config.turri.yaml` and each `config.<name>.yaml` to `config.turri.<name>.yaml` first, leaves the old files as they are, and from then on reads only the new ones. `turri init-config` copies the modules' files the same way, but writes `config.turri.yaml` as its quick start, taking from `config.yaml` only the keys turri reads too - `unittests-script`, `conformance-tests-script` and `prepare-environment-script`, say - each in its place in the file, and saying which keys it left: `template_dir`, `verbose`, `api`, the other tool's alone. The two models are the vendor's, never taken. To change a setting by hand in such a project, do the same: copy the files to their new names, and edit the copies - never `config.yaml`. Writing a `config.turri.yaml` of your own beside it is the same move: from then on `config.yaml` is not read, its testing scripts with it. For a headless run that only needs conformance tests or another judge, or review, those options leave the files alone: `--conformance-tests`, `--judge-model`, `--review true|false`, and the models' too.
288
289
 
289
- Keys turri does not read - another tool's `verbose`, `api-key`, `build-folder`, ... - are ignored without a word, and so is a value of the wrong type. A file that does not parse as YAML is read as empty, so its testing scripts are then looked for by name.
290
+ Keys turri does not read - another tool's `verbose`, `api-key`, `build-folder`, ... - are ignored without a word, and so is a value of the wrong type.
291
+
292
+ ## A config that does not parse
293
+
294
+ A `config.turri.yaml` - or a module's own file, or a `config.yaml` turri still reads - that is not valid YAML is read as empty: none of it applies, and turri would run on its defaults and [pi](https://pi.dev)'s, the models among them - pi's own default model, which may not be one your credentials reach. A key set twice is the usual way in: a second config pasted under the first. So turri says it, never silently (`configProblems` in `src/config.ts`), naming the file, the line and what is wrong - `config.turri.yaml, line 13: conformance-tests is set twice`:
295
+
296
+ - **The chat** says it under the banner, in the error colour, as it starts.
297
+ - **Nothing is regenerated with it.** `regenerate`, `conform`, `/regenerate`, `/conform` and `turri regenerate` refuse to start a pulse until it parses, saying why - as they refuse a module that cannot be built with its config.
298
+ - **A capture** started where it is in use refuses to start, since the captured project starts as that config ([capture](capture.md)).
299
+ - **`turri doctor`** lists it first among the project's checks.
300
+
301
+ Fix it - each key set once - and ask again.
@@ -64,7 +64,10 @@ The workflow signs in to npm with npm's trusted publishing (OIDC), not a token:
64
64
  | `src/regenerate/pulse-files.ts` | what a pulse writes only for a person - its logs, outputs, temporary files, its chain's installed dependencies - removed as it ends outside debug mode |
65
65
  | `src/regenerate/failure-reports.ts` | why a pulse that failed or finished without landing did - what `pulses` says of it - kept in `.turri/pulses/<id>.md` whatever the debug setting, for a later session |
66
66
  | `src/regenerate/ledger.ts`, `src/regenerate/ledger-view.ts` | the ledger: what turri did, as typed facts, in `.turri/ledger/` - `record()`, read back for `pulses` - see [the ledger](using.md#the-ledger) |
67
- | `genome/` | what turri knows and can do: `genome/skills/`, the skill library, and `genome/rules/`, the \*\*\*plain authoring rules |
67
+ | `src/capture/`, `src/capture-cli.ts` | [capture](capture.md): the map, areas folded to a budget, the agents and the checks of what they hand over, assembling the modules, the testing scripts, the report, resuming, its status while it runs - and `turri capture` |
68
+ | `src/reopen.ts` | a chat opened again in another folder by `turri` once it quits - into the project a capture wrote |
69
+ | `src/plain-code-blocks.ts` | \*\*\*plain fenced as ` ```plain ` in the chat, highlighted by turri's grammar - pi-tui's Markdown patched |
70
+ | `genome/` | what turri knows and can do: `genome/skills/`, the skill library, `genome/rules/`, the \*\*\*plain authoring rules, and `genome/capture/`, capture's prompts |
68
71
 
69
72
  ## Known edges
70
73
 
@@ -365,7 +365,7 @@ A conformance job is a \*\*\*plain diff's conformance run: the tests of its chan
365
365
 
366
366
  A functional spec with no scenarios is not listed: `parse` shows it as "no scenarios - not tested".
367
367
 
368
- While a codebase's work is being planned into jobs, with nothing running there, what is planned says so - the conformance tests being planned, or the work - rather than showing nothing until the plan is made. A module asked for - `regenerate`, from scratch, functionalities again - shows its work as being planned from that moment, before its code is deleted and what is left is worked out, not only once the planner runs: in the loop's status, which a host draws its plan from, and in the job panel - a module the loop holds nothing of yet, as when turri was just opened, too. A \*\*\*plain change is looked at quietly.
368
+ While a codebase's work is being planned into jobs, with nothing running there, what is planned says so - the conformance tests being planned, or the work - rather than showing nothing until the plan is made. A module asked for - `regenerate`, from scratch, functionalities again - shows its work as being planned from that moment, before its code is deleted and what is left is worked out, not only once the planner runs: in the loop's status, which a host draws its plan from, and in the job panel - a module the loop holds nothing of yet, as when turri was just opened, too. One whose chain has a module below it not built at all is shown waiting for that module instead, from the moment its codebase is tracked - `top.plain - waits for base` - never as being planned while the codebases below it are looked at first, each taking the planner's time: nothing plans it until the one below is built. A \*\*\*plain change is looked at quietly.
369
369
 
370
370
  **What a conformance job tests is built.** As a conformance job starts, the harness reads the code record, `code/.turri.json`, and checks that it has every functional spec the job adds or changes tests for, as the job has it. One it does not have stops the job before any agent runs: its report says which are not built, the conformance tests halt, and the chat model tells the person. They are tried again once the code or \*\*\*plain changes. Code jobs and conformance jobs are planned apart, each track on its own: a job is one or the other. A module built on another starts with the tests record below it, as what it inherits: none of its own tests is written yet.
371
371
 
package/docs/sandbox.md CHANGED
@@ -64,10 +64,10 @@ Before an agent's command runs, its text is checked (`src/regenerate/command-che
64
64
  - names the code record, `.turri.json`;
65
65
  - writes a credential file (`.env` and its variants; a template is fine) - by redirect, `tee`, `cp`, `mv` or an edit in place;
66
66
  - changes a setting of the machine's or the person's environment: `defaults write`, `launchctl`, `systemctl enable`, `sysctl -w`, `git config --global`, `npm config set`, a line written to a shell profile (`~/.zshrc`) or `/etc`. The same rule (`machineChange`) holds in every shell turri runs, not only the agents': the chat's and the launch agent's refuse an install or a system setting too, asked or not - turri changes nothing of the machine's;
67
- - installs software outside the project: `sudo`, the system's package managers installing (`brew`, `apt`, `dnf`, `apk`, `pacman`, `choco`, `winget`, ...), toolchain managers installing (`nvm`, `sdk`, `rustup`, `pyenv`, `asdf`, ...), global installs (`npm -g`, `yarn global`, `pip --user`, `pipx`, `gem install`), a script downloaded and run (`curl ... | sh`), an installer (`.pkg`, `.msi`, `.dmg`, `.run`). The project's own dependencies - `npm install`, pip into its venv, `mvn`, `cargo`, `go mod` - are building the code, and pass;
67
+ - installs software outside the project: `sudo`, the system's package managers installing (`brew`, `apt`, `dnf`, `apk`, `pacman`, `choco`, `winget`, ...), toolchain managers installing (`nvm`, `sdk`, `rustup`, `pyenv`, `asdf`, ...), global installs (`npm -g`, `yarn global`, `pip --user`, `pipx`, `gem install`), a script downloaded and run (`curl ... | sh`, `| python3 -`; a response piped to an interpreter given its code by an option - `| python3 -c '...'`, `| python3 -m json.tool`, `| node -e` - is data it reads, and passes), an installer (`.pkg`, `.msi`, `.dmg`, `.run`). The project's own dependencies - `npm install`, pip into its venv, `mvn`, `cargo`, `go mod` - are building the code, and pass;
68
68
  - kills what its pulse did not start: `pkill`, `killall`, `taskkill`, `fuser -k`, or `kill` aimed at a port or name lookup. `kill $!` and `kill %1` pass.
69
69
 
70
- It reads the command as the shell reads its operators: a `>`, `<`, `|`, `&` or `;` inside quotes is text (`grep -rl "</content>" .` redirects nothing), and so is the body of a here-document fed to `cat` or `tee` under a quoted delimiter (`cat > src/App.tsx <<'EOF'`) - the text of a file being written, whose `../lib/logger` is an import, not a path. A body that runs - under an unquoted delimiter, where `$(...)` expands, or fed to a shell or an interpreter - and a `$(...)` in double quotes are checked as commands.
70
+ It reads the command as the shell reads its operators: a `>`, `<`, `|`, `&` or `;` inside quotes is text (`grep -rl "</content>" .` redirects nothing), and so is the body of a here-document fed to `cat` or `tee` under a quoted delimiter (`cat > src/App.tsx <<'EOF'`) - the text of a file being written, whose `../lib/logger` is an import, not a path. A body that runs - under an unquoted delimiter, where `$(...)` expands, or fed to a shell or an interpreter - and a `$(...)` in double quotes are checked as commands. So the installs, the system settings and the kills are looked for a simple command at a time, split where the shell splits - `grep -rn "main\|uvicorn.run" app` is one command, not a `.run` installer - and in the script a shell is handed as a word of its own (`bash -c "cd app; pip install --user x"`, `eval`), which a string hides from the line.
71
71
 
72
72
  On Windows, drive letters, backslashes and any case are read as Windows has them. It knowingly misses a path built at run time (`$(...)`, a variable, a script that reads one from a file): the OS sandbox and the audit are for those.
73
73
 
package/docs/theming.md CHANGED
@@ -70,7 +70,7 @@ With tool rows carrying no background, their state is signalled by the title and
70
70
 
71
71
  ## \*\*\*plain diffs
72
72
 
73
- A \*\*\*plain diff in the panels is not painted with the theme's colours for code: those are made for code, and the turri themes' backgrounds are all the surface colour, so a diff drawn with them would have no fills and hardly any highlighting. It has a palette of its own (`src/regenerate/plain-palette.ts`), one for a dark theme and one for a light, picked by the theme's appearance: a hue for each piece of \*\*\*plain - a section's header, the `# <id>` heading of a functional spec or a scenario (neon, bold; eggplant, bold, on a light theme), a concept, a link, text in quotes or backticks, a front matter key, a module, a comment - at least 7:1 on the surface, and a fill behind each added and removed line: on a dark theme blue whale and eggplant, on a light one neon hover and siesta tan. Every colour reads at least 4.8:1 on blue whale and 5:1 on the light fills; eggplant, the design system's only warm dark fill, takes the pinks and grauzone down to 3.7:1.
73
+ A \*\*\*plain diff in the panels - and \*\*\*plain fenced as ` ```plain ` in the chat - is not painted with the theme's colours for code: those are made for code, and the turri themes' backgrounds are all the surface colour, so a diff drawn with them would have no fills and hardly any highlighting. It has a palette of its own (`src/regenerate/plain-palette.ts`), one for a dark theme and one for a light, picked by the theme's appearance: a hue for each piece of \*\*\*plain - a section's header, the `# <id>` heading of a functional spec or a scenario (neon, bold; eggplant, bold, on a light theme), a concept, a link, text in quotes or backticks, a front matter key, a module, a comment - at least 7:1 on the surface, and a fill behind each added and removed line: on a dark theme blue whale and eggplant, on a light one neon hover and siesta tan. Every colour reads at least 4.8:1 on blue whale and 5:1 on the light fills; eggplant, the design system's only warm dark fill, takes the pinks and grauzone down to 3.7:1.
74
74
 
75
75
  ## The font
76
76
 
package/docs/using.md CHANGED
@@ -15,6 +15,8 @@ Peeking is safe while a question is open - a skill's or the chat's: `ctrl+h` ope
15
15
 
16
16
  While a skill runs, a line above the input shows its phases, every one by name - those done ticked, the one it is in marked, the rest to come - and where it is: the skill's name at the left edge, `phase 2 of 4` at the right, and its phases centred between them, `✓ intent ━━━━ ⠋ stack ──── ○ testing ──── ○ product`. Under it, dimmed, the phase it is in and what it does: `stack - the language, frameworks, storage and architecture`. The phases are the skill's own steps, read from its `SKILL.md`. A skill of one phase, or none, has nothing to be partway through: its line is the spinner and its name alone, `⠹ analyze-func-specs`.
17
17
 
18
+ To bring an existing codebase under \*\*\*plain instead, `/capture` captures it into `plain/`, in the background - nothing is asked, its progress shows above the input, and once it ends turri offers to open again in `plain/`, where its report is told and `/regenerate` builds it; only you start it (see [capture](capture.md)).
19
+
18
20
  `genome/skills/` holds the rest: adding a feature, a concept, a requirement, a resource; splitting a functional spec that is too big; resolving conflicts; checking the environment - see [authoring \*\*\*plain](authoring-plain.md#the-skills). A skill run that is interrupted can be resumed where it stopped. A project can have skills of its own, in `.turri/skills/` or `.agents/skills/` - see [skills and gates](skills-and-gates.md#a-projects-own-skills).
19
21
 
20
22
  ## The tools
@@ -52,6 +54,7 @@ A regeneration takes minutes, so in the TUI every tool that regenerates starts t
52
54
 
53
55
  - **The panel** above the input, while something runs, shows on top what finished - a line a module, the module that finished last on top, its pulses newest first, each with its mark (green, red or amber, as in the side panel), number and kind - what it regenerated is in the side panel - `cognio ✓ 4 conformance · ✓ 3 regenerate · … 2 earlier`, the newest that fit the width - then a rule, and under it each running pulse, the newest first - `cognio · regenerate pulse 5`, `cognio · conformance pulse 6` - its time and cost, and what its agents are doing. A module whose work is being planned into pulses shows at once, before any pulse runs - `shorty · planning the pulses · 12s` - from the moment it is asked for: while its code is deleted for a start from scratch and what is left to regenerate is worked out, as well as while the planner, an agent, cuts it into pulses; a `/regenerate` says it began the moment it is sent. A \*\*\*plain change is looked at quietly, and shows only once the planner runs. Pulses are numbered within their module, as regen numbers them. `ctrl+o` expands the agents' trace alone; what finished stays a line a module. The line of keys under it - `ctrl+o to expand the trace · ctrl+h to peek at regen` - has each key breathing, fully there to a little faint and back, until it is first pressed: once `ctrl+o` has opened the trace, or the side panel has been opened, that key is still for the rest of the session and the other breathes on. What waits is not in it, and it shows no \*\*\*plain diff - the side panel has both. With nothing running it is gone.
54
56
  - **A pulse's change** is what its agent works from, not a text diff of the module's file: the items `<spec change>` gives the agent - only what the pulse's functional specs use, an import's items as well as the module's own, a code pulse's without the test reqs - each in the file it is written in, under its section, in the file's order (`change-view.ts`).
57
+ - **\*\*\*plain in the chat** - a block an agent fences as ` ```plain `, or with no language around a section's header - is highlighted as a \*\*\*plain diff is, by turri's own grammar in the same colours (`src/plain-code-blocks.ts`).
55
58
  - **A \*\*\*plain diff**, in the side panel, reads as an editor shows a diff: its [\*\*\*plain](https://plainlang.org/docs/) highlighted by turri's own grammar, which started from [plyn](https://github.com/plainlang/plyn)'s - section headers, the `# <id>` heading of a functional spec or a scenario, concepts, names in backticks, text in quotes, links, the front matter - each added line filled green and each removed one red, the text on top, the fill the width of the panel ([colours](theming.md#plain-diffs)). It is shown file by file, each file's lines together under its name, with what it adds and takes out - the module being regenerated first, the rest by name, and none the diff does not change. Each line has its number in that file: a \*\*\*plain diff is of \*\*\*plain as read, with what it imports laid in, so a line is placed in the file it is written in - its links read as the parser renders them - and a removed line, in no file now, goes with the change it is part of and has no number. A line is never put in a file on a guess: one that cannot be placed is listed last, under "not found in the spec's files". Where lines of a file are not in the diff, `↕ 28 lines` says how many, as GitHub does - `↑` above the first - and names the section the lines under it are in when it is another than the one above, `↕ 28 lines · ***functional specs***`, as GitHub names a hunk's function: each section is named once.
56
59
  - **The side panel** (`ctrl+h`, as it was left - but on the pulse that last failed, stopped or did not pass, when one has since it was last opened: the live panel that showed it is gone with the last pulse, and its announcement in the chat says `ctrl+h shows this pulse`; **`/pulses`** on the pulses; not `ctrl+j`, which a terminal without the Kitty keyboard protocol sends as a line feed, the same as `shift+enter`, and which a dialog takes for `enter`; both stay [pi](https://pi.dev)'s new-line keys. `ctrl+h` is the byte old terminals sent for backspace; a terminal set to send `^H` for its Backspace key would open the panel on it) takes the whole screen - the panel or the chat, one at a time - or, `s`, sits beside the chat: the chat on the left, the panel in the right half of the screen, and `s` again over the whole screen. It opens as it was last left, for the conversation; a terminal under 104 columns - 100 inside the screen's padding, a blank row above and below everything and two columns either side - has no room for both and shows the panel over the whole screen. It opens on **regen**: the module's \*\*\*plain itself, in full, with how much of it the code has been regenerated from drawn onto it.
57
60
 
@@ -131,7 +134,7 @@ To change [pi](https://pi.dev)'s own default, in `~/.pi/agent/settings.json`:
131
134
  { "defaultProvider": "google", "defaultModel": "gemini-3.1-pro-preview" }
132
135
  ```
133
136
 
134
- A provider failure - no credits, bad key, rate limit - is raised with the provider's own message, rather than surfacing as an agent that said nothing. One that passes - overloaded, rate limited, unreachable, timed out - is waited out first, after [pi](https://pi.dev)'s own retries: six more tries, the wait doubled each time from 15 seconds up to five minutes (15s, 30s, 1m, 2m, 4m, 5m, a tenth either way so parallel jobs do not all come back at once), the agent carrying on where it was. Each wait - [pi](https://pi.dev)'s own retries too - is shown as it happens - a notification in the chat and the job panel's status, an orange line in a headless run - and listed in the run report's `turn_incidents`. So is a provider stalling: a request to the model that nothing has come back on for two minutes (`TURRI_PROVIDER_STALL`, in seconds; 0 never), said once for each silence while the turn goes on waiting. A turn turri stops itself - its time up, the agent going round in a circle - is the work's normal course and is not said, only listed.
137
+ A provider failure - no credits, bad key, rate limit - is raised with the provider's own message, rather than surfacing as an agent that said nothing. One that passes - overloaded, rate limited, unreachable, timed out, its stream cut off part-way - is waited out first, after [pi](https://pi.dev)'s own retries: six more tries, the wait doubled each time from 15 seconds up to five minutes (15s, 30s, 1m, 2m, 4m, 5m, a tenth either way so parallel jobs do not all come back at once), the agent carrying on where it was. Each wait - [pi](https://pi.dev)'s own retries too - is shown as it happens - a notification in the chat and the job panel's status, an orange line in a headless run - and listed in the run report's `turn_incidents`. So is a provider stalling: a request to the model that nothing has come back on for two minutes (`TURRI_PROVIDER_STALL`, in seconds; 0 never), said once for each silence while the turn goes on waiting. A turn turri stops itself - its time up, the agent going round in a circle - is the work's normal course and is not said, only listed.
135
138
 
136
139
  ### Models from a pi extension
137
140
 
@@ -204,6 +207,7 @@ turri conform <file.plain> --from-scratch # its tests folder taken out and wri
204
207
  turri lineage <module> # what each regeneration changed in a module, and when
205
208
  turri cultivate debug-specs # run a skill directly - by name, the project's too, or by its folder
206
209
  turri launch <file.plain> # launch what is regenerated from dist/<module>, here
210
+ turri capture [path] # capture an existing codebase into ***plain, in <path>/plain - offline
207
211
  ```
208
212
 
209
213
  `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.
@@ -0,0 +1,26 @@
1
+ # Capture
2
+
3
+ You are one of the agents of a capture: an existing codebase is captured into ***plain, and from then on the ***plain is the source of truth - the code is regenerated from it, and the original codebase is abandoned. Many agents capture it side by side, each a part, none the whole of it. The harness splits the work, assembles what each agent hands over into ***plain files, and checks it.
4
+
5
+ ## You run offline
6
+
7
+ Nobody can be asked anything, and nobody watches. Where the code leaves something open, decide it yourself - the reading most consistent with the code, its tests and its docs - and say what you decided where your tool asks for assumptions. Never stop to ask.
8
+
9
+ ## What you look at
10
+
11
+ The codebase is read only to you: read, grep, find and ls, no shell - but where your task gives you a shell on a copy of it. You are shown a map of your part of it - folders, files, their sizes and the surfaces the harness found in them: routes, commands, options, screens, environment variables, tables, test names, exports. The map is how you find your way; the code is what you read to answer a question, never what you read through. Follow a surface: a route into its handler, a command into what it runs, grep where the trail leads. Read the parts of a file you need with an offset and a limit, not the whole of a long one. You have a budget of tool calls: spend it on what decides the ***plain, then hand over.
12
+
13
+ ## What the ***plain says
14
+
15
+ ***plain a person has to review is ***plain a person can read. A capture that writes down everything the code does is as unreadable as the code, and nobody reviews it. So - but never at the cost of the interface:
16
+
17
+ - **The interface, whole and exact - never guessed, never obvious.** What a user, a client or a script calls is the contract the regenerated software must keep, call for call: every command and subcommand; every option and argument with each name it has, the value it takes, its choices and its default; every route with its method, path, parameters, the fields it takes and answers, and its status codes; every environment variable and configuration key read; every output format, message and exit code a user or a script sees. Read each from the code that defines it, and follow it to what it does - never infer it from a name, the help text or the docs, never fill it in from a convention, never leave it out as obvious or as the stack's: a stack says how errors are shaped, never which options exist or what they accept. Each part's interface is taken from the code as data, before any feature is written, into its interface reference - a linked resource every functional spec about it carries through the part's interface concept: there the details are exact, and the prose names them. Where the code leaves one open, read on until it does not; what you still cannot settle is said where your tool asks what is uncertain, never settled by guess. The rest of what follows is how short to be about everything else.
18
+ - **What someone sees, not what the code does.** Of each fact ask: *would a user or a client notice if it were different, and would they care?* Function names, file layout, helpers, internal data shapes, retries, logging and utility libraries are the code's business - left out. What a user can do, what they see, the boundary cases and the errors they meet are captured.
19
+ - **Only where the code departs from the default.** The default is what a competent developer builds with no instruction: the stack's conventions, the domain's ("a login rejects a wrong password"), and every functional spec before this one. Cookie-cutter behaviour is one line or none; an odd rule - deleting a list archives its items, an unusual sort order, a 30-day limit - is written down exactly.
20
+ - **Exact where exactness is the contract.** A response's fields, a file format, a command's flags, an error code a client checks: these are captured exactly, in the fewest words that keep them exact - terse, never cut. A literal - a URL, a path, a message - is code in backticks, never a link: ***plain refuses a link to anything but a file of the project.
21
+ - **Edge cases go in scenarios.** A functional spec states the rule; its scenarios pin its edge cases with concrete values - the examples, and what each wrong input answers. Neither is said again in the functional spec. Detail moved to a scenario is still captured, and still readable.
22
+ - **Terse is right.** Clipped bullets, no lead-ins, no rationale, no history, no "the system". Every rule of concise ***plain you are given applies.
23
+
24
+ ## What is left out
25
+
26
+ Behaviour nothing relies on - an incidental order, a leftover endpoint, debug output, dead code - is left out, and said so where your tool asks what you dropped. What you could not make out is captured as best you can, and said so where your tool asks what is uncertain. Both reach the person in the capture's report: a judgement said is one they can check.
@@ -0,0 +1,5 @@
1
+ # Check the conventions against the code
2
+
3
+ The survey settled the conventions below: what every feature of the part does the same way - how an error, a warning and a message are written, the exit code or status of each kind of failure, what changes when there is no terminal, what quiet and debug modes hide or add, and what reaches the other side of every call it makes or answers. Every feature is captured following them, so one that is wrong is wrong everywhere. Check each against the code: start at the files it names, follow the entry point to where it catches errors, writes to its streams and exits, and read the conditions exactly - which flag, which level, which stream, when a terminal matters, which name the program goes by. For what reaches the other side, follow a call to where it leaves - the request built and sent, the response written - and read what is added there: the headers set of its own, how a body is serialised and encoded, how header values are encoded, when a body is read or streamed. A declaration is no evidence, a help text or a docstring neither when the code does otherwise; two conventions that disagree cannot both hold.
4
+
5
+ Call `submit_capture_conventions` once, with every convention as the code has it: each that holds, word for word; each corrected; any the code shows that every feature follows and the survey missed. Each with `where`, the files whose code decides it. In `changes`, what you changed, a line each, with why - the file and what its code does. Never change one that holds.
@@ -0,0 +1,11 @@
1
+ # Check the interface reference against the code
2
+
3
+ Below is part of the software's interface reference as an agent took it from the code, each entry with where it is defined. The reference is given whole to every agent that regenerates or tests the code, and it is the one place its details are written: what it lacks or gets wrong, the regenerated software lacks or gets wrong. Every literal in it was checked to be in the code - so nothing in it is invented; what is left to check is that it is whole and right. Read each entry where it is defined, and follow the code to where each detail is worked out:
4
+
5
+ - **Its help, whole:** the text the program prints for it with `--help` - every paragraph, word for word. Where the code keeps a short help and a long one, the one `--help` prints.
6
+ - **Its choices:** every value it accepts, from wherever the code lists them - a constant elsewhere, the letters of a format. Choices worked out when it runs - filtered by what the machine has, taken from what is installed - go in its details, saying how, never as a fixed list that is not always the list.
7
+ - **Its default, what it takes, whether it repeats, is required or is hidden** - as the code has them; a default worked out when it runs, in its details, saying how.
8
+ - **Before you say what a set, a list or a mapping holds,** grep every line that builds it or adds to it - a set defined in one place is often added to in another, a mapping filtered further down - and read each. Correct an entry only where the code shows it wrong, and say the file and the line that show it.
9
+ - **What was missed:** grep the part for interface no entry holds - environment variables read through a constant or a helper, subcommands, arguments, routes a router adds - and add each.
10
+
11
+ Call `submit_capture_reference_checked` once, with every entry as the code has it - each that holds, word for word; each corrected; each missed - and every exclusion; and in `changes` what you changed, a line each, with why: the file and the line, and what its code does there. Never change one that holds.
@@ -0,0 +1,3 @@
1
+ # Reconcile concepts
2
+
3
+ Agents capturing different features of the same codebase each defined some of the same concepts, in different words. Each concept below has every definition it was given, and the functional specs that use it. Give each concept one definition that serves every one of those uses: one plain sentence that starts with the concept and says what it is, with the attributes the specs rely on. Use only the concepts listed with it. Call `submit_capture_concepts` once, with a definition for every concept.
@@ -0,0 +1,9 @@
1
+ # Divide the features
2
+
3
+ The part was outlined area by area, each area by an agent that saw only its own files - so one behaviour can be in two features: an option parsed in one area and acted on in another, a message built in a third, a command's help beside the command. Each feature is then written by an agent of its own, side by side; a behaviour in two features is written twice, in different words, and the two copies contradict each other. Below is every feature of the part, area by area, in build order, with what it is about and where it is built. Give each behaviour to one feature. Call `submit_capture_owners` once.
4
+
5
+ - `features`: every feature that stays, by its key as listed, with `owns`: one line naming what it alone captures - its commands, options, messages and behaviour - so its writer knows its edges and leaves the rest to the others. A behaviour two features would both capture is in the `owns` of one: the feature that is about it - where a user would look for it - never one that only parses it, passes it on or prints it.
6
+ - `merged`: a feature that is a slice of another's behaviour - the options of what another feature does, the printing of what another sends - is merged `into` the features that take it, with `why`: it is not written, and its files go to them. Merge for that, never because two features are small.
7
+ - Every option, command and route of the part is in the `owns` of one feature: the interface is captured whole, so name in `owns` the options and commands each feature takes.
8
+ - A feature builds only on the features before it: give a behaviour to one that comes after what it needs.
9
+ - You see the outline, not the code: decide from what each feature is about and where it is built. Most features stay as they are, owning what they were outlined for.