@turri-dev/cli 0.5.1 → 0.5.2-next.f7795ce

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.
package/README.md CHANGED
@@ -212,7 +212,7 @@ Start at the [documentation index](docs/README.md), or go straight to a page:
212
212
  | [Using **turri**](docs/using.md) | the conversation, skills, tools, pulses and regen, choosing models, the command line |
213
213
  | [The project config](docs/config.md) | `config.turri.yaml` and a module's own `config.turri.<module>.yaml`: every key, models and their inheritance, conformance, the testing scripts, which file builds a module, the old `config.yaml` |
214
214
  | [Launch](docs/launch.md) | trying what is built: a commit in `dist/<module>`, started on your machine in the background - after every pulse too - nothing installed without asking |
215
- | [Capture](docs/capture.md) | an existing codebase, whole, captured into \*\*\*plain by the chat's agent with sub-agents - to work on from then on instead of the code |
215
+ | [Capture](docs/capture.md) | an existing codebase, whole or piece by piece, captured into \*\*\*plain by the chat's agent with sub-agents - to work on from then on instead of the code |
216
216
  | [Running unattended](docs/headless.md) | regenerating \*\*\*plain overnight or in CI: the command, keeping it running, the results, resuming, rebuilding one functionality |
217
217
  | [Authoring \*\*\*plain](docs/authoring-plain.md) | what \*\*\*plain is made of, the authoring rules, the skills that write and fix it, checking it |
218
218
  | [Regenerating](docs/regenerating.md) | what each build does and in which order: functionalities, modules, regeneration, changes to \*\*\*plain, conformance and acceptance tests, working notes, what the code is built from |
@@ -1,59 +1,103 @@
1
+ import { statSync } from "node:fs";
2
+ import { resolve, sep } from "node:path";
1
3
  /**
2
- * `turri capture [path] [--into <folder>] [--harness-model <m>] [--coding-model <m>]`: the chat's `/capture`, run
3
- * unattended - pi's print mode with turri built in (`turri -p "/capture ..."`), which asks nobody and waits for the
4
- * chat's agent, so turri ends as the capture does (the core's docs/capture.md). cli.ts starts it; this reads its words.
4
+ * `turri capture [path] [what to capture...] [--guide <file>] [--into <folder>] [--harness-model <m>] [--coding-model <m>]`:
5
+ * the chat's `/capture`, run unattended - pi's print mode with turri built in (`turri -p "/capture ..."`), which asks
6
+ * nobody and waits for the chat's agent, so turri ends as the capture does (the core's docs/capture.md). cli.ts starts
7
+ * it; this reads its words.
5
8
  */
6
9
  export const CAPTURE_USAGE = [
7
- "usage: turri capture [path] [--into <folder>] [--harness-model <m>] [--coding-model <m>]",
10
+ "usage: turri capture [path] [what to capture...] [--guide <file>] [--into <folder>] [--harness-model <m>] [--coding-model <m>]",
8
11
  "",
9
12
  "Capture the codebase at path (the current folder by default) into ***plain, in <path>/plain: the chat's /capture,",
10
- "run unattended - nobody is asked, and turri ends as the capture does. The chat's agent captures it from a map of",
11
- "the code, with writers for its parts when it is large; its working files and report are in plain/.turri/capture/.",
12
- "Run it again to go on with a capture that was stopped.",
13
+ "run unattended - nobody is asked, and turri ends as the capture does. With words, the piece of the codebase they",
14
+ "name - a functionality, in your words - built on the pieces captured before it; with none, the whole codebase, or",
15
+ "the rest of it after pieces. The chat's agent captures it from a map of the code, with writers for its parts when it",
16
+ "is large; its working files and report are in plain/.turri/capture/. Run it again to go on with a capture that was",
17
+ "stopped.",
13
18
  "",
19
+ "The first argument is the codebase when it is written as a path - ., .., ./app, ../app, /work/app - or when it is the",
20
+ "only one and names a folder; everything else is what to capture. Given with words, the codebase is written as a path.",
21
+ "",
22
+ " turri capture my-app",
23
+ " turri capture the billing functionality --guide billing.md",
24
+ " turri capture ../my-app the billing functionality",
25
+ "",
26
+ " --guide <file> guidance for the capture, or the piece: how you see the ***plain - the modules, the concepts,",
27
+ " what to leave out, the order to go in",
14
28
  " --into <folder> where the ***plain goes, instead of <path>/plain",
15
29
  " --harness-model <m> the model the chat's agent and its writers write on, and the captured project's harness model",
16
30
  " --coding-model <m> the captured project's coding model, the one its code is regenerated on",
17
31
  ].join("\n");
32
+ /** The options /capture itself takes, each named once. */
33
+ const CAPTURE_OPTIONS = ["--guide", "--into"];
18
34
  /** The options that take a model, passed on to the chat as they are given. */
19
35
  const MODEL_OPTIONS = ["--harness-model", "--coding-model"];
20
36
  /**
21
- * `turri capture`'s words as the chat's: `-p "/capture [path] [--into <folder>]"` and the model options - or what is wrong
22
- * with them. The chat's /capture splits its words on spaces, so a path holding one cannot be given.
37
+ * A word the core's /capture reads as the codebase's folder: `.`, `..`, or one with a slash - or the OS's separator - in
38
+ * it (`captureTarget` in the core's capture.ts).
23
39
  */
24
- export function captureArgs(args) {
25
- let path;
26
- let into;
40
+ function writtenAsPath(word) {
41
+ return word === "." || word === ".." || word.includes("/") || word.includes(sep);
42
+ }
43
+ function isFolder(path) {
44
+ try {
45
+ return statSync(path).isDirectory();
46
+ }
47
+ catch {
48
+ return false;
49
+ }
50
+ }
51
+ /**
52
+ * `turri capture`'s words as the chat's: `-p "/capture [path] [what to capture] [--guide <file>] [--into <folder>]"` and
53
+ * the model options - or what is wrong with them. The first argument is the codebase when it is written as a path, or is
54
+ * the only one and names a folder in `cwd` - `turri capture my-app`, as it always was; everything else that is not an
55
+ * option is what to capture. The core takes the first word of /capture as the codebase only when it is written as a
56
+ * path, so a folder named bare is passed as `./my-app`. The chat's /capture splits its words on spaces, so a path, guide
57
+ * or folder holding one cannot be given.
58
+ */
59
+ export function captureArgs(args, cwd = process.cwd()) {
60
+ const positional = [];
61
+ const given = {};
27
62
  const models = [];
28
63
  for (let at = 0; at < args.length; at += 1) {
29
64
  const arg = args[at];
30
65
  const eq = arg.startsWith("--") ? arg.indexOf("=") : -1;
31
66
  const name = eq === -1 ? arg : arg.slice(0, eq);
32
- if (name === "--into" || MODEL_OPTIONS.includes(name)) {
67
+ if (CAPTURE_OPTIONS.includes(name) || MODEL_OPTIONS.includes(name)) {
33
68
  const value = eq === -1 ? args[at + 1] : arg.slice(eq + 1);
34
69
  if (eq === -1)
35
70
  at += 1;
36
71
  if (value === undefined || value === "")
37
72
  return { problem: `${name} takes a value.` };
38
- if (name === "--into")
39
- into = value;
40
- else
73
+ if (MODEL_OPTIONS.includes(name))
41
74
  models.push(name, value);
75
+ else if (given[name] !== undefined)
76
+ return { problem: `${name} is given twice.` };
77
+ else
78
+ given[name] = value;
42
79
  }
43
80
  else if (arg.startsWith("-")) {
44
81
  return { problem: `unknown option: ${arg}` };
45
82
  }
46
- else if (path === undefined) {
47
- path = arg;
48
- }
49
83
  else {
50
- return { problem: `capture takes one path, and was given ${path} and ${arg}.` };
84
+ positional.push(arg);
51
85
  }
52
86
  }
53
- for (const [what, value] of [["the path", path], ["--into", into]]) {
87
+ const first = positional[0];
88
+ const path = first !== undefined && (writtenAsPath(first) || (positional.length === 1 && isFolder(resolve(cwd, first)))) ? first : undefined;
89
+ const what = (path !== undefined ? positional.slice(1) : positional).join(" ").trim();
90
+ for (const [option, value] of [["the path", path], ["--guide", given["--guide"]], ["--into", given["--into"]]]) {
54
91
  if (value !== undefined && /\s/.test(value))
55
- return { problem: `${what} ${value} holds a space, which /capture cannot take: name it from a folder whose path has none.` };
92
+ return { problem: `${option} ${value} holds a space, which /capture cannot take: name it from a folder whose path has none.` };
56
93
  }
57
- const command = ["/capture", ...(path !== undefined ? [path] : []), ...(into !== undefined ? ["--into", into] : [])].join(" ");
94
+ // The codebase as the core reads it: written as a path - and, before words whose first would read as one, this folder.
95
+ const codebase = path !== undefined ? (writtenAsPath(path) ? path : `.${sep}${path}`) : what !== "" && writtenAsPath(what.split(/\s+/)[0]) ? "." : undefined;
96
+ const command = [
97
+ "/capture",
98
+ ...(codebase !== undefined ? [codebase] : []),
99
+ ...(what !== "" ? [what] : []),
100
+ ...CAPTURE_OPTIONS.flatMap((option) => (given[option] !== undefined ? [option, given[option]] : [])),
101
+ ].join(" ");
58
102
  return { args: ["-p", command, ...models] };
59
103
  }
package/dist/cli.js CHANGED
@@ -95,7 +95,7 @@ const COMMANDS = {
95
95
  lineage: { module: "./lineage-cli.ts", blurb: "a module's lineage: what was regenerated into it, and when" },
96
96
  launch: { module: "./launch-cli.ts", blurb: "launch what is regenerated from dist/<module> on this machine" },
97
97
  cultivate: { module: "./cultivate-cli.ts", blurb: "run a gated skill" },
98
- capture: { module: "./capture-cli.ts", blurb: "capture an existing codebase into ***plain, in <path>/plain - the chat's /capture, unattended" },
98
+ capture: { module: "./capture-cli.ts", blurb: "capture an existing codebase, whole or a piece of it, into ***plain, in <path>/plain - the chat's /capture, unattended" },
99
99
  };
100
100
  /** Getting the machine ready, and checking it is. */
101
101
  const SETUP_COMMANDS = {
@@ -1,11 +1,14 @@
1
+ import { spawn } from "node:child_process";
1
2
  import { existsSync } from "node:fs";
3
+ import { join, relative, resolve } from "node:path";
2
4
  import { createInterface } from "node:readline/promises";
3
5
  import { BEDROCK_DEFAULT, BEDROCK_IN_REGION, VENDORS, bedrockDefaultModels, bedrockMakers, bedrockModels, bedrockModelsIn, bedrockPlaceOf, hasBedrockPreset, makerLabel, piModelCatalogue, bedrockMakerOf, bedrockRegionOf, priced, vendorOf } from "@turri-dev/core/models";
4
- import { initConfig } from "@turri-dev/core/project";
6
+ import { globalModels, initConfig } from "@turri-dev/core/project";
5
7
  import { brand } from "./brand.js";
6
8
  const USAGE = [
7
9
  "usage: turri init-config [--vendor anthropic|openai|google|amazon-bedrock|other] [--maker <maker>] [--region <geography>]",
8
10
  " [--harness-model <spec> --coding-model <spec> [--judge-model <spec>]] [--force] [--global | folder]",
11
+ " turri init-config --existing-codebase [options] [codebase]",
9
12
  "",
10
13
  "Write a quick start config.turri.yaml in the folder, the current one by default: the model you talk to and the one that",
11
14
  "writes the code, from the vendor you use. Asked when --vendor is not given and this is a terminal; otherwise other -",
@@ -15,12 +18,18 @@ const USAGE = [
15
18
  "pair or the catalogue's offered first. --harness-model and --coding-model name the two instead, as provider/model-id",
16
19
  "without a thinking level - amazon-bedrock/global.xai.grok-4.7 - any pi's catalogue has; --judge-model the strong one",
17
20
  "the judging examples name, the harness model unless given. The vendor, maker and region are read from them.",
21
+ "With none of these, and your global config naming both models, the project takes them from there: nothing is asked,",
22
+ "and its file names no models of its own.",
18
23
  "A config.turri.yaml already there keeps everything but its two models; --force writes the whole of it again. A new",
19
24
  "one takes from a config.yaml beside it - another tool's, say - the keys turri reads too, its testing scripts say, and leaves",
20
25
  "config.yaml as it is.",
21
26
  "",
22
27
  "--global writes your global config instead, ~/.turri/config.turri.yaml: turri reads it under every project's",
23
28
  "config.turri.yaml, and a project's own file overrides any key of it.",
29
+ "",
30
+ "--existing-codebase sets turri up to work on a codebase you have - the folder named, the current one by default: the",
31
+ "project goes in plain/ inside it, its config.turri.yaml saying build-into: .., so every module is built in the codebase",
32
+ "itself, on the code there. Then it asks whether to start turri in plain/.",
24
33
  ].join("\n");
25
34
  /** Ask until the answer is one `read` takes. */
26
35
  async function askUntil(rl, prompt, read, again) {
@@ -131,15 +140,22 @@ export async function main(args) {
131
140
  const taken = new Set(Object.values(flags).flatMap((flag) => flag.at));
132
141
  const rest = args.filter((arg, index) => !arg.startsWith("-") && !taken.has(index));
133
142
  const global = args.includes("--global");
143
+ const existingCodebase = args.includes("--existing-codebase");
144
+ if (global && existingCodebase) {
145
+ console.error(`--existing-codebase writes a project's config, --global yours: give one.\n\n${USAGE}`);
146
+ return 1;
147
+ }
134
148
  if (global && rest[0] !== undefined) {
135
149
  console.error(`--global writes ~/.turri/config.turri.yaml: name no folder with it.\n\n${USAGE}`);
136
150
  return 1;
137
151
  }
138
- const folder = rest[0] ?? process.cwd();
139
- if (!existsSync(folder)) {
140
- console.error(`${folder} does not exist.`);
152
+ const given = rest[0] ?? process.cwd();
153
+ if (!existsSync(given)) {
154
+ console.error(`${given} does not exist.`);
141
155
  return 1;
142
156
  }
157
+ // An existing codebase: the project is plain/ in it, built into the codebase around it.
158
+ const folder = existingCodebase ? join(resolve(given), PROJECT_FOLDER) : given;
143
159
  let vendor;
144
160
  if (flags.vendor.value !== undefined) {
145
161
  vendor = vendorOf(flags.vendor.value);
@@ -176,6 +192,8 @@ export async function main(args) {
176
192
  }
177
193
  }
178
194
  const force = args.includes("--force");
195
+ // A project's config with nothing said of the models: your global config's, when it names both - nothing asked.
196
+ const fromGlobal = !global && named === undefined && vendor === undefined && maker === undefined && region === undefined ? globalModels() : undefined;
179
197
  const asking = process.stdin.isTTY && process.stdout.isTTY && named === undefined;
180
198
  let chosen;
181
199
  try {
@@ -190,6 +208,8 @@ export async function main(args) {
190
208
  throw error;
191
209
  }
192
210
  async function chooseVendor() {
211
+ if (fromGlobal !== undefined)
212
+ return { models: fromGlobal };
193
213
  if (named !== undefined) {
194
214
  return {
195
215
  ...(vendor !== undefined ? { vendor } : {}),
@@ -212,7 +232,41 @@ export async function main(args) {
212
232
  ...(chosen.bedrock !== undefined ? { bedrock: chosen.bedrock } : {}),
213
233
  ...(chosen.models !== undefined ? { models: chosen.models } : {}),
214
234
  ...(read !== undefined ? { catalogue: read } : {}),
235
+ ...(existingCodebase ? { buildInto: ".." } : {}),
236
+ ...(fromGlobal !== undefined ? { modelsFromGlobal: true } : {}),
215
237
  });
216
238
  (result.written ? console.log : console.error)(result.message);
217
- return result.written ? 0 : 1;
239
+ if (!result.written)
240
+ return 1;
241
+ if (existingCodebase && process.stdin.isTTY && process.stdout.isTTY && (await askToStart(folder)))
242
+ return startTurriIn(folder);
243
+ return 0;
244
+ }
245
+ /** The project's folder in an existing codebase. */
246
+ const PROJECT_FOLDER = "plain";
247
+ /** Ask whether to start turri in the project's folder now: Enter is yes. */
248
+ async function askToStart(folder) {
249
+ const rl = createInterface({ input: process.stdin, output: process.stdout });
250
+ try {
251
+ const answer = (await rl.question(`${brand.bold(brand.accent(`Start turri in ${relative(process.cwd(), folder) || "."} now?`))} ${brand.muted("[Y/n]")} `)).trim().toLowerCase();
252
+ return answer === "" || answer === "y" || answer === "yes";
253
+ }
254
+ catch {
255
+ // Ctrl+C or Ctrl+D: not now.
256
+ return false;
257
+ }
258
+ finally {
259
+ rl.close();
260
+ }
261
+ }
262
+ /** turri's chat in `folder`, as `turri` there starts it - the same Node, its options, this CLI - until it ends. */
263
+ function startTurriIn(folder) {
264
+ const child = spawn(process.execPath, [...process.execArgv, process.argv[1]], { cwd: folder, stdio: "inherit", env: process.env });
265
+ return new Promise((done) => {
266
+ child.on("exit", (code, signal) => done(code ?? (signal !== null ? 1 : 0)));
267
+ child.on("error", (error) => {
268
+ console.error(`turri could not start in ${folder}: ${error.message}`);
269
+ done(1);
270
+ });
271
+ });
218
272
  }
package/dist/reopen.js CHANGED
@@ -1,4 +1,5 @@
1
- import { readFileSync, rmSync, writeFileSync } from "node:fs";
1
+ import { readFileSync, realpathSync, rmSync, writeFileSync } from "node:fs";
2
+ import { resolve } from "node:path";
2
3
  /**
3
4
  * turri opened again in another folder, in the same terminal, once its chat has quit: a chat works on the project of
4
5
  * the folder it was opened in, and after a capture the work is in another - `plain/`, a project of its own. `turri`
@@ -66,3 +67,17 @@ export function takeCaptured(env = process.env) {
66
67
  }
67
68
  /** What the person is asked once a capture in the chat is done - yes or no: the chat's agent has said where it is, and how to open it later. */
68
69
  export const CAPTURE_OPEN_QUESTION = "Open turri in the newly captured ***plain project?";
70
+ /** What the person is asked once a piece of a capture is done - yes or no: the next piece, or the rest, is captured from there too. */
71
+ export const PIECE_OPEN_QUESTION = "Open turri in the ***plain project captured so far? The capture goes on from there.";
72
+ /** Whether two paths are the same folder - links followed where they exist, so `/tmp` is `/private/tmp` on macOS. */
73
+ export function sameFolder(a, b) {
74
+ const real = (path) => {
75
+ try {
76
+ return realpathSync.native(path);
77
+ }
78
+ catch {
79
+ return resolve(path);
80
+ }
81
+ };
82
+ return real(a) === real(b);
83
+ }
@@ -6,7 +6,7 @@ import { createChatUi } from "./chat-ui.js";
6
6
  import { registerEntries } from "./entry-renderers.js";
7
7
  import { makePanel, registerNotifications, registerPanelKey, terminalAsk } from "./panel-view.js";
8
8
  import { openPiSettings } from "./pi-settings.js";
9
- import { canReopen, CAPTURE_OPEN_QUESTION, capturedEnv, reopenIn } from "./reopen.js";
9
+ import { canReopen, CAPTURE_OPEN_QUESTION, capturedEnv, PIECE_OPEN_QUESTION, reopenIn, sameFolder } from "./reopen.js";
10
10
  import { skillProgress } from "./skill-progress.js";
11
11
  import { captureProgress, registerCaptureProgressCalls } from "./capture-progress.js";
12
12
  import { TerminalNotifications } from "./terminal-notifications.js";
@@ -93,13 +93,18 @@ export function createTerminal() {
93
93
  };
94
94
  /**
95
95
  * A capture in `chat` wrote a project of its own and is done (`captureDone`): turri closes here and opens again there -
96
- * `turri` started this chat, and the person says yes - where the capture's report is shown.
96
+ * `turri` started this chat, and the person says yes - where the capture's report is shown. After a piece the person
97
+ * named (`what`) too: they may open the project to look at what is captured so far, and the capture goes on from there -
98
+ * `/capture` in the project a capture wrote captures more of its codebase into it - so they need not switch back. Not
99
+ * when this chat is already in that project, a piece captured from there.
97
100
  */
98
- const openCaptured = async (chat, dir, summary) => {
101
+ const openCaptured = async (chat, dir, summary, what) => {
102
+ if (sameFolder(dir, turri().cwd))
103
+ return;
99
104
  const ui = drawOn(chat);
100
105
  if (!canReopen() || terminal.leave === undefined || ui === undefined)
101
106
  return;
102
- if ((await ui.select(CAPTURE_OPEN_QUESTION, ["Yes", "No"])) !== "Yes")
107
+ if ((await ui.select(what !== undefined ? PIECE_OPEN_QUESTION : CAPTURE_OPEN_QUESTION, ["Yes", "No"])) !== "Yes")
103
108
  return;
104
109
  if (reopenIn(dir, { env: capturedEnv(summary) }))
105
110
  terminal.leave();
@@ -149,7 +154,7 @@ export function createTerminal() {
149
154
  break;
150
155
  }
151
156
  case "captureDone":
152
- void openCaptured(event.chat, event.plainDir, event.summary);
157
+ void openCaptured(event.chat, event.plainDir, event.summary, event.what);
153
158
  break;
154
159
  case "outOfReach":
155
160
  showOutOfReach(event.chat, event.outOfReach);
package/docs/README.md CHANGED
@@ -49,7 +49,7 @@ turri is the first coding agent with the power of regenerative software: [\*\*\*
49
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 |
50
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` |
51
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, whole, captured into \*\*\*plain by the chat's agent with sub-agents: the steps, explore, how it scales, what it writes, going on |
52
+ | [Capture](capture.md) | an existing codebase, whole or piece by piece, captured into \*\*\*plain by the chat's agent with sub-agents: the steps, pieces and guides, how it scales, what it writes, going on |
53
53
  | [Running unattended](headless.md) | regenerating overnight or in CI: before you leave it, the command, the results, resuming, rebuilding one functionality |
54
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 |
55
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 |
package/docs/capture.md CHANGED
@@ -1,25 +1,35 @@
1
1
  # Capture
2
2
 
3
- Capture takes an existing codebase - the whole of it - and writes down what it does as \*\*\*plain, in a project of its own. From then on you work on the \*\*\*plain: the code is regenerated from it, and the original codebase is abandoned.
3
+ Capture takes an existing codebase - the whole of it, at once or [piece by piece](#piece-by-piece) - and writes down what it does as \*\*\*plain, in a project of its own. From then on you work on the \*\*\*plain: the code is regenerated from it, and the original codebase is abandoned.
4
4
 
5
5
  ```bash
6
6
  cd ~/my-app && turri
7
7
  /capture # in the chat: this folder, into ./plain
8
8
  /capture ../other-app --into ../other-plain
9
+ /capture --guide capture-guide.md # the whole codebase, following your guide
9
10
 
10
- turri capture [path] [--into <folder>] # unattended: nobody is asked, and turri exits as the capture ends
11
+ /capture the billing functionality --guide billing.md # piece by piece: billing first,
12
+ /capture the authoring functionality # then authoring, built on billing,
13
+ /capture # then the rest
14
+
15
+ turri capture [path] [what to capture] [--guide <file>] [--into <folder>] # unattended: nobody is asked, and turri exits as the capture ends
16
+ turri capture my-app # the folder my-app, whole
17
+ turri capture the billing functionality --guide billing.md # a piece of this folder
11
18
  ```
12
19
 
13
- The chat's own agent does the capture, there in the chat, from a map of the code that turri makes with no model. turri tells it what must hold and when it is done; how it gets there is its own - a small codebase it reads and writes itself, a large one it may plan from the map and hand to writers, sub-agents side by side. 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. `turri capture` is the same command run unattended: turri in pi's print mode, `turri -p "/capture [path]"`, which asks nobody and waits for the agent to end.
20
+ `/capture [path] [what to capture, in your words] [--guide <file>] [--into <folder>]`. The first word is the codebase's folder when it is written as a path - `.`, `..`, or with a slash in it: `./app`, `../app`, `/work/app` - so a word of what to capture is never taken for a folder; everything else that is not an option is what to capture, as you wrote it. The options go anywhere.
21
+
22
+ The chat's own agent does the capture, there in the chat, from a map of the code that turri makes with no model. turri tells it what must hold and when it is done; how it gets there is its own - a small codebase it reads and writes itself, a large one it may plan from the map and hand to writers, sub-agents side by side. 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. `turri capture` is the same command run unattended: turri in pi's print mode, `turri -p "/capture [path] [what to capture] [--guide <file>] [--into <folder>]"`, which asks nobody and waits for the agent to end. It takes the same words, with one difference: its first argument is the codebase when it is written as a path, as in the chat, or when it is the only one and names a folder - `turri capture my-app`, passed on written as a path. Given with words, the codebase is written as a path: `turri capture ./my-app the billing functionality`. A path, guide or `--into` folder holding a space cannot be given.
14
23
 
15
24
  ## How it works
16
25
 
17
26
  The harness does what needs no model, then hands the work to the agent (`src/capture/`):
18
27
 
19
- 1. **The checks.** The path must be a folder, and the folder the \*\*\*plain goes into - `<path>/plain`, or `--into` - must be new, empty, or a capture started before. A config in use that does not parse stops it, since the captured project starts as that config.
28
+ 1. **The checks.** The path must be a folder, a `--guide` a file, and the folder the \*\*\*plain goes into - `<path>/plain`, or `--into` - must be new, empty, or a capture started before. A config in use that does not parse stops it, since the captured project starts as that config.
20
29
  2. **The project.** `config.turri.yaml` is written once: the config in use where the capture was started - your models, thinking, reviews, limits - without what was that project's own (its `module`, testing scripts, `base-folder` and `test-dir`) and without what turri does not read - a key it no longer has dropped, an old name of a renamed key written under its new one - with `conformance-tests: true` and the models the session was opened with. With no config in use, `init-config`'s. A `.gitignore` keeps the regenerated code's histories out.
21
- 3. **The map** (`map.ts`), in a second or two even for a hundred thousand lines. Every file of the codebase - what git sees, in a repo; every file but dependencies, caches and turri's own elsewhere - is sorted into code, tests and the rest. Each code file is parsed with [Tree-sitter](#the-map): its definitions, each with its header and lines; the code files it uses, from its imports resolved as its language would; and the tests that use it. Then the code in the order it is built - each file after the files it uses - cut into slices of about 1,000 lines for writers. How many modules and functional specs capture it, the map does not say: that is the agent's to judge. It is written to `plain/.turri/capture/map.md`, and as data to `map.json`.
22
- 4. **The brief.** The chat's agent is told what to capture into where, what must hold, the level the \*\*\*plain is written at, the map's summary, what it has, ways that work, and when it is done (`genome/prompts/capture/capture.md`). It is told hints, never steps: what it reads, in what order, what it plans and keeps on disk, and whether it has help are its own.
30
+ 3. **The piece** (`pieces.ts`): what this `/capture` captures - your words and guide, or the whole codebase - kept in the working folder with the pieces before it ([piece by piece](#piece-by-piece)).
31
+ 4. **The map** (`map.ts`), in a second or two even for a hundred thousand lines. Every file of the codebase - what git sees, in a repo; every file but dependencies, caches and turri's own elsewhere - is sorted into code, tests and the rest. Each code file is parsed with [Tree-sitter](#the-map): its definitions, each with its header and lines; the code files it uses, from its imports resolved as its language would; and the tests that use it. Then the code in the order it is built - each file after the files it uses - cut into slices of about 1,000 lines for writers. How many modules and functional specs capture it, the map does not say: that is the agent's to judge. It is written to `plain/.turri/capture/map.md`, and as data to `map.json`.
32
+ 5. **The brief.** The chat's agent is told what to capture into where - the piece, the pieces before it, your guide - what must hold, the level the \*\*\*plain is written at, the map's summary, what it has, ways that work, and when it is done (`genome/prompts/capture/capture.md`). It is told hints, never steps: what it reads, in what order, what it plans and keeps on disk, and whether it has help are its own.
23
33
 
24
34
  What must hold:
25
35
 
@@ -54,10 +64,37 @@ It is done when:
54
64
  6. **The testing scripts** are written - `submit_capture` waits for any still being written.
55
65
  7. **Every module parses, and every config file does** - a setting changed in a line of its own, every comment line kept whole - and the report is written.
56
66
 
67
+ For a piece, these are the piece's: its modules continue the chain of the pieces before, its code is accounted for - the rest of the codebase is for the pieces to come, neither captured nor said to be left out - its part of the interface is exact, and the report adds it, keeping what it says of the pieces before.
68
+
57
69
  Then it calls `submit_capture`, before it tells you anything ([how it ends](#how-it-ends)).
58
70
 
59
71
  **Attended or not.** In a chat, the agent asks you only what the code cannot tell it and what changes the capture, deciding the rest and saying it in the report. Unattended, it never asks.
60
72
 
73
+ ## Piece by piece
74
+
75
+ A codebase too large, or too tangled, to capture in one go is captured a functionality at a time. Each `/capture` with words is a piece: what you want captured, in your words - not code paths, though you may name some - captured into the same project, built on the pieces before it.
76
+
77
+ ```bash
78
+ /capture the billing functionality: invoices, payments and refunds
79
+ /capture the authoring functionality --guide authoring.md
80
+ /capture # the rest
81
+ ```
82
+
83
+ - **What a piece is, the agent finds.** The map is always of the whole codebase; from your words the agent finds the piece in it - the entry points that do it (commands, routes, the public API, screens), the code they reach and the original's tests of it - writes down which code is the piece's, and captures it, with the code it shares with the rest as far as the piece needs it, for the pieces after to build on. Your words may say how as well as what: the agent takes that as it takes a guide.
84
+ - **Each piece builds on the ones before.** Its modules continue their chain: the first requires the last module of the pieces before, and each adds to the software built so far - the same interface, extended. What is captured is not captured again; an earlier piece's module is changed only where the new piece cannot be captured without it, each change said in the report.
85
+ - **`/capture` alone** captures the whole codebase when there are no pieces, and the rest of it - all the pieces did not capture - after them: done, all the code is accounted for and the codebase can be abandoned.
86
+ - **From the project, too.** In turri opened in the project a capture wrote - `plain/` - `/capture` with no path goes on capturing that project's codebase into it: the next piece with its words, or the rest with none. So you look at what is captured so far and go on from there, never switching back; the codebase is kept in `pieces.json`.
87
+ - **A piece stopped** before it was done - the chat closed, turri quit, the agent ended its turn - is gone on with by `/capture` alone, or by its own words again; a guide given then takes the place of its own. Asking for something else starts a new piece, and the one stopped is left as it was: the new piece finishes what of it it needs, and the rest is yours to ask for again.
88
+ - **Each piece ends with `submit_capture`**, which checks the project as for a whole capture - every module parsing, the testing scripts there, this piece's report - and marks the piece done ([how it ends](#how-it-ends)).
89
+
90
+ turri keeps the pieces in the working folder, `plain/.turri/capture/pieces.json`: each one's words, its guide, when it started and when it was done. A piece asked for with words or a guide has its request in `pieces/<n>/request.md`, which the agent is told to read again once its conversation has been summed up; the agent keeps the piece's own working files beside it, in `pieces/<n>/`. A capture an earlier turri started, which kept no pieces, is one piece of the whole codebase - done if the plan it gave `capture_progress` was.
91
+
92
+ ## A guide
93
+
94
+ `--guide <file>` hands the agent your guidance for the capture, or for a piece: how you see the \*\*\*plain - how the modules are cut and named, the concepts, what to leave out, the order to go in, the stack's conventions. turri reads the file as the capture starts, puts it in the brief whole and keeps it with the piece's request; the agent follows it wherever the capture leaves the choice to it, and gives its writers and helpers what of it bears on their tasks - they know only the tasks it writes. What must hold, holds whatever the guide says: the code is never written, the \*\*\*plain says what the code does now, and every \*\*\*plain rule holds. Where the guide asks for something that does not, the agent keeps to what must hold and tells you why - in the report, unattended.
95
+
96
+ Words given with `/capture` work the same: what to capture, and anything you say of how.
97
+
61
98
  ## How far it has got
62
99
 
63
100
  The agent shows you how far the capture has got with `capture_progress` (`src/capture/progress.ts`). First, from the map and before any other work of the capture, it gives its plan: the phases it will go through - planning the modules, writing them, checking the scenarios, the report - each with its share of the work, the longest the largest. Then it moves it as it goes: each phase as it starts it, how many of that phase's items are done - modules written, scenarios checked - and what it is on now. turri works out the fraction of the whole from that - the shares of the phases behind it and the done part of the one it is in - so every front end draws the same bar.
@@ -74,8 +111,8 @@ The agent ends the capture with `submit_capture`, giving the report in a few lin
74
111
 
75
112
  1. **It waits for the testing scripts.** The testing-script skills run in the background; while either is writing its script for the captured project, `submit_capture` waits for it to land.
76
113
  2. **It checks what it can without a model** (`captureUnfinished` in `src/capture/capture.ts`): the report is written, and in this run - a capture gone on with after one that finished has the earlier run's there, which is not this one's; every config file of the captured project parses - read as empty otherwise, it would regenerate nothing; every module parses in its project, with no step of adding tests skipped; and the unit and conformance testing scripts are there for every module. What is not done goes back to the agent, each with what puts it right, and it calls `submit_capture` again once it has.
77
- 3. **Done, the agent tells you** its summary, the report's path, and that turri opened in `plain/` regenerates it.
78
- 4. **Every front end is told.** As that turn ends, turri sends `captureDone` - the chat, the codebase, the project, the agent's summary and this run's report - once a run, and never for a turn that ended part-way or was stopped. The terminal asks *Open turri in the newly captured \*\*\*plain project?*, yes or no; on a yes, turri closes here and opens again in `plain/`, where the first chat shows the report - its agent reading it too, so it can be asked about - and `/regenerate` builds it. On a no, `cd plain && turri` opens it later. Unattended, nothing is offered: the summary is the run's last words.
114
+ 3. **Done, the agent tells you** its summary, the report's path, and that turri opened in `plain/` regenerates it. A piece is marked done, and the agent tells you how to capture the next piece, or the rest.
115
+ 4. **Every front end is told.** As that turn ends, turri sends `captureDone` - the chat, the codebase, the project, the agent's summary, this run's report and, for a piece you named, `what`, your words - once a run, and never for a turn that ended part-way or was stopped. The terminal asks *Open turri in the newly captured \*\*\*plain project?*, yes or no; on a yes, turri closes here and opens again in `plain/`, where the first chat shows the report - its agent reading it too, so it can be asked about - and `/regenerate` builds it. On a no, `cd plain && turri` opens it later. After a piece you named it asks *Open turri in the \*\*\*plain project captured so far? The capture goes on from there.* - in `plain/` you look at what is captured and capture the next piece, or the rest, from there ([piece by piece](#piece-by-piece)). Nothing is asked when the chat is already in `plain/`. Unattended, nothing is offered: the summary is the run's last words.
79
116
 
80
117
  An agent's `write` and `edit` - the chat's, the testing-script skills' - never leave a config file that parses not parsing: such an edit is refused and the file put back ([a config that does not parse](config.md#a-config-that-does-not-parse)).
81
118
 
@@ -93,7 +130,7 @@ It is a hint, never a gate: a call made by name at runtime or through a framewor
93
130
 
94
131
  ## Coverage
95
132
 
96
- `capture_coverage` is the chat's check, by code, that nothing of the codebase is silently dropped. From `map.json` it says what code no working file names yet: every `path` and `path:start-end` in a Markdown file of the working folder - a plan, the code beside the functional specs that capture it, what is left out, a writer's copy's paths too - counts; by default every such file but the map, or the files and folders `files` names - the writers' folders, to see what they captured rather than what was planned. What is not yet named is listed by definition, `src/greet.py: bye (5-6)`, or - in a file with none - by its stretches of lines.
133
+ `capture_coverage` is the chat's check, by code, that nothing of the codebase is silently dropped. From `map.json` it says what code no working file names yet: every `path` and `path:start-end` in a Markdown file of the working folder - a plan, the code beside the functional specs that capture it, what is left out, a writer's copy's paths too - counts; by default every such file but the map and the pieces' requests - your words, not the capture's account of the code - or the files and folders `files` names - the writers' folders, to see what they captured rather than what was planned. By default it is of all the code; `code` names files and folders of the codebase, as the map names them, to ask of those alone - a piece's code, to see what of it is not captured yet. What is not yet named is listed by definition, `src/greet.py: bye (5-6)`, or - in a file with none - by its stretches of lines.
97
134
 
98
135
  ## Sub-agents
99
136
 
@@ -129,17 +166,19 @@ my-app/
129
166
  map.md, map.json the map of the code
130
167
  report.md the report
131
168
  progress.json the plan and how far it has got
169
+ pieces.json the pieces: each one's words, guide, and when it started and was done
170
+ pieces/<n>/request.md a piece's request - your words and guide - and the agent's files for it
132
171
  ... whatever else the agent keeps: a plan, writers' folders, notes
133
172
  .turri/ledger/ what the capture's chat did, as facts - the ledger
134
173
  ```
135
174
 
136
175
  **The original is left as it was.** turri keeps nothing of its own in the folder a session is opened in unless that folder is a turri project - a config file, or `plain_modules/`: no [ledger](using.md#the-ledger), no record of its chats. A chat capturing a codebase records what it does in the project it writes, from `/capture` on. Opened on a codebase that is a turri project, the session keeps its ledger there as it always does - but the capture's chat records into `plain/`.
137
176
 
138
- **The report** says what was captured, the modules in order, their functional specs, what was left out and why, every decision, what the agent was unsure of, and what to do next.
177
+ **The report** says what was captured, the modules in order, their functional specs, what was left out and why, every decision, what the agent was unsure of, and what to do next - piece by piece, when the codebase was captured in pieces.
139
178
 
140
179
  ## Stopped, run again
141
180
 
142
- A capture stopped part-way - the chat closed, turri quit, the agent ended its turn - goes on: `/capture` again on the same folder maps the code again and briefs the agent to read what is in `plain/` and its working files and go on from them, never redoing what is done. In a chat, saying "go on" does the same. To start over, move `plain/` out of the way. A `plain/` that holds anything but a capture is refused: `--into` names another folder.
181
+ A capture stopped part-way - the chat closed, turri quit, the agent ended its turn - goes on: `/capture` again on the same folder - alone, or with the stopped piece's own words - maps the code again and briefs the agent to read what is in `plain/` and its working files and go on from them, never redoing what is done ([piece by piece](#piece-by-piece)). In a chat, saying "go on" does the same. To start over, move `plain/` out of the way. A `plain/` that holds anything but a capture is refused: `--into` names another folder.
143
182
 
144
183
  ## Models
145
184
 
@@ -147,7 +186,7 @@ The chat's agent writes the \*\*\*plain on `harness-model`, as the chat always r
147
186
 
148
187
  ## After a capture
149
188
 
150
- 1. **Read the \*\*\*plain and the report,** in turri opened in `plain/` - the terminal asks whether to open it there as the capture ends, and its first chat shows the report. From now on the \*\*\*plain is the source of truth.
189
+ 1. **Read the \*\*\*plain and the report,** in turri opened in `plain/` - the terminal asks whether to open it there as the capture ends, and after each piece, and its first chat shows the report. From now on the \*\*\*plain is the source of truth.
151
190
  2. **Regenerate,** first module first: `/regenerate`. Any testing script the report says was not written, ask turri for (`implement-unit-testing-script`, `implement-conformance-testing-script`).
152
191
  3. **Compare with the original**: its own tests, the scenarios' conformance tests, a look at what is launched. Each difference becomes a \*\*\*plain change.
153
192
  4. **Abandon the original** once you are satisfied.
package/docs/config.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  A project says how its \*\*\*plain is built in `config.turri.yaml`, at the project root. Everything in it is optional: with no file at all, turri finds the testing scripts on its own, turns conformance tests on wherever a module has test reqs, and runs on [pi](https://pi.dev)'s configured model. A project whose parts are on different stacks - a backend and a frontend - gives a module a file of its own, `config.turri.<module>.yaml`, beside it, which builds that module and those built on it (see [a module's own config](#a-modules-own-config)). turri never writes a `config.yaml`: it may be another tool's, and is read only by a project that has no file of turri's yet (see [the old config.yaml](#the-old-configyaml)). A key in `config.turri.yaml` or a module's file that turri reads nothing of - a setting it no longer has, like `test-advisor`, or one misspelt - is named in a warning under the banner as turri starts, rather than ignored without a word. A key turri has renamed is renamed in the file itself as turri first reads or writes the project's config - `release-after-pulse`, now `launch-after-pulse` - its value and its comment kept, and the banner says so; a file that sets the new name too is left as it is, the banner saying the old one does nothing.
4
4
 
5
- `turri init-config` starts one: the two models, a strong one to talk to and a smaller one to write the code. It asks which vendor's models you use - `--vendor` says it without asking, and with neither, as from a script, it is `other`:
5
+ `turri init-config` starts one: the two models, a strong one to talk to and a smaller one to write the code. With your global `~/.turri/config.turri.yaml` naming both, and none of `--vendor`, `--maker`, `--region` or the models given, it asks nothing: the project's file names no models of its own - its two lines commented, saying so - and runs on the global ones. It asks which vendor's models you use - `--vendor` says it without asking, and with neither, as from a script, it is `other`:
6
6
 
7
7
  | vendor | harness-model | coding-model | key [pi](https://pi.dev) reads |
8
8
  | --- | --- | --- | --- |
@@ -18,6 +18,8 @@ Amazon Bedrock asks three more things, from [pi](https://pi.dev)'s catalogue: wh
18
18
 
19
19
  `--harness-model` and `--coding-model` name the two models instead, for any vendor: provider/model-id without a thinking level - `turri init-config --harness-model amazon-bedrock/global.xai.grok-4.7 --coding-model amazon-bedrock/global.xai.grok-4.6`. They are written wherever the vendor's own would be - the two models with their thinking, the commented-out `judge-model` and `models:` examples - and the vendor, maker and geography are read from them. `--judge-model` names the strong one the judging examples use, the harness model unless given. Each is checked against [pi](https://pi.dev)'s catalogue first: one it does not have, or that is not a chat model, is named, with the closest it has, and nothing is written.
20
20
 
21
+ `--existing-codebase [codebase]` sets turri up to work on a codebase you have - the folder named, the current one by default: the project goes in `plain/` inside it, its `config.turri.yaml` saying `build-into: ..`, so every module is built in the codebase itself, on the code there, never over it (see [building into a folder](https://github.com/turri-oss/turri-core/blob/main/docs/regenerating.md#building-into-a-folder) in the core's docs). In a terminal it then asks whether to start turri in `plain/`; Enter starts it.
22
+
21
23
  Each is written with how hard it thinks - `harness-model: openai/gpt-6-astra:medium`, `coding-model: openai/gpt-6-luna:low` - so the file shows it. The reviews and judges of a regeneration run on the coding model but think medium (see [models per role](#models-per-role)).
22
24
 
23
25
  They are an example, not a requirement - any model [pi](https://pi.dev) supports works, signed in any way [pi](https://pi.dev) supports; `other` is the starting point for another provider. What we recommend is that split, a capable model to talk to and a smaller, cheaper one for the coding. Once written, it says what to do next: the key to set in your shell - or `/login` in turri, which [pi](https://pi.dev) keeps in `~/.pi/agent/auth.json` - and that the file belongs to that folder: turri reads the nearest `config.turri.yaml` upwards from where it starts, so one written anywhere else is not seen.
package/docs/using.md CHANGED
@@ -15,7 +15,7 @@ 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/`: the chat's agent does it there in the chat, with sub-agents to study the code, and tells you when it is done - turri opened in `plain/` then regenerates it; only you start it (see [capture](capture.md)).
18
+ To bring an existing codebase under \*\*\*plain instead, `/capture` captures it into `plain/` - whole, or a piece at a time, `/capture the billing functionality`: the chat's agent does it there in the chat, with sub-agents to study the code, and tells you when it is done - turri opened in `plain/` then regenerates it, and captures the next piece from there; only you start it (see [capture](capture.md)).
19
19
 
20
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).
21
21
 
@@ -207,7 +207,7 @@ turri conform <file.plain> --from-scratch # its tests folder taken out and wri
207
207
  turri lineage <module> # what each regeneration changed in a module, and when
208
208
  turri cultivate debug-specs # run a skill directly - by name, the project's too, or by its folder
209
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 - unattended
210
+ turri capture [path] [what to capture] # capture an existing codebase into ***plain, in <path>/plain - whole, or the piece named - unattended
211
211
  ```
212
212
 
213
213
  `turri cultivate` runs a skill on the project's harness model, as the chat does, unless `--model` names another: its questions asked at the terminal, and each step, artifact, judge and gate decision printed as it is made. 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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@turri-dev/cli",
3
- "version": "0.5.1",
3
+ "version": "0.5.2-next.f7795ce",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "repository": {
@@ -38,7 +38,7 @@
38
38
  "dependencies": {
39
39
  "@earendil-works/pi-coding-agent": "1.6.0",
40
40
  "@earendil-works/pi-tui": "1.6.0",
41
- "@turri-dev/core": "0.5.1"
41
+ "@turri-dev/core": "0.6.0"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@types/node": "^24.0.0",