@turri-dev/cli 0.4.3-next.fd01774 → 0.5.1-next.4bafdf3

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
@@ -39,6 +39,8 @@ turri init-config
39
39
 
40
40
  Choose your model provider, then sign in with `/login` once **turri** has started.
41
41
 
42
+ `turri init-config --global` writes the same into `~/.turri/config.turri.yaml` instead: **turri** reads it under every project's `config.turri.yaml`, and a project's own file overrides any key of it.
43
+
42
44
  ### Build your first app
43
45
 
44
46
  ```bash
@@ -210,7 +212,7 @@ Start at the [documentation index](docs/README.md), or go straight to a page:
210
212
  | [Using **turri**](docs/using.md) | the conversation, skills, tools, pulses and regen, choosing models, the command line |
211
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` |
212
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 |
213
- | [Capture](docs/capture.md) | an existing codebase captured into \*\*\*plain - offline, at any size - to work on from then on instead of the code |
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 |
214
216
  | [Running unattended](docs/headless.md) | regenerating \*\*\*plain overnight or in CI: the command, keeping it running, the results, resuming, rebuilding one functionality |
215
217
  | [Authoring \*\*\*plain](docs/authoring-plain.md) | what \*\*\*plain is made of, the authoring rules, the skills that write and fix it, checking it |
216
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 |
package/dist/banner.js CHANGED
@@ -2,7 +2,8 @@ import { join } from "node:path";
2
2
  import { readdirSync, readFileSync } from "node:fs";
3
3
  import { allocateImageId, Box, getCapabilities, getPngDimensions, renderImage, Text, wrapTextWithAnsi } from "@earendil-works/pi-tui";
4
4
  import { BANNER_ENTRY, VERSION_ENTRY } from "@turri-dev/core";
5
- import { CLI_ROOT } from "./cli-root.js";
5
+ import { coreVersion } from "@turri-dev/core/system";
6
+ import { CLI_ROOT, coreLine, corePlace } from "./cli-root.js";
6
7
  import { bannerWarnings } from "./turri-versions.js";
7
8
  import { brandPink } from "./regenerate/plain-palette.js";
8
9
  import { halfBlocks, JELLYFISH_FRAME_MS, JELLYFISH_REST, JELLYFISH_SEQUENCE, JELLYFISH_TEXT_FRAMES } from "./jellyfish.js";
@@ -16,9 +17,17 @@ import { highlightPlainCodeBlocks } from "./plain-code-blocks.js";
16
17
  let versions;
17
18
  /** Whether what npm said later was told: once, in the chat that heard it first. */
18
19
  let toldLater = false;
20
+ /** The core this process runs, as the banner says it - asked once a process, as a clone's asks git. */
21
+ let core;
19
22
  export function registerBanner(pi, welcomeVisible) {
20
23
  versions ??= bannerWarnings();
21
24
  const { lines: newer, later } = versions;
25
+ try {
26
+ core ??= coreLine(coreVersion(), corePlace());
27
+ }
28
+ catch {
29
+ /* not said: the core could not tell its version */
30
+ }
22
31
  pi.registerEntryRenderer(BANNER_ENTRY, (entry, _options, theme) => {
23
32
  const data = entry.data;
24
33
  if (data === undefined)
@@ -26,6 +35,8 @@ export function registerBanner(pi, welcomeVisible) {
26
35
  const lines = [
27
36
  `${brandPink(theme)("turri")} ${theme.fg("muted", `v${data.version}`)}` +
28
37
  (data.commit !== undefined ? theme.fg("dim", ` from a clone, ${data.commit}${data.changed ? " with changes" : ""}`) : ""),
38
+ // The core under it: a checkout linked in says where it is, and warns when it runs its dist/ rather than its sources.
39
+ ...(core !== undefined ? [theme.fg(core.warn ? "warning" : "dim", core.text)] : []),
29
40
  // A newer turri out, or one installed and hidden behind this one: said first, under the version it is about.
30
41
  ...(data.versions ?? newer).map((line) => theme.fg("warning", line)),
31
42
  // A key renamed is information; one that does not parse stops everything that reads it; the rest are the person's to take out.
@@ -1,77 +1,59 @@
1
- import { relative, resolve } from "node:path";
2
- import { CaptureError, DEFAULT_PARALLEL, runCapture } from "@turri-dev/core/project";
3
- import { c } from "./module-report.js";
4
1
  /**
5
- * `turri capture [path] [--harness-model <m>] [--coding-model <m>] [--into <folder>] [--parallel <n>]`: capture the
6
- * codebase at `path` - the current folder by default - into ***plain in `<path>/plain`, offline: nothing is asked, and
7
- * what was decided is in the report. A capture stopped part-way is gone on with by running it again.
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.
8
5
  */
9
- const USAGE = [
10
- "usage: turri capture [path] [--harness-model <m>] [--coding-model <m>] [--into <folder>] [--parallel <n>]",
6
+ export const CAPTURE_USAGE = [
7
+ "usage: turri capture [path] [--into <folder>] [--harness-model <m>] [--coding-model <m>]",
11
8
  "",
12
- "Capture the codebase at path (the current folder by default) into ***plain, in <path>/plain - nothing is asked:",
13
- "what capture decided, left out or could not capture is in plain/.turri/capture/report.md. Run it again to go on",
14
- "with a capture that was stopped.",
9
+ "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.",
15
13
  "",
16
- " --harness-model <m> the project's harness model; Claude capture defaults to Haiku low / Sonnet low / Opus medium",
17
- " --coding-model <m> the project's coding model; set models.capture-exploration, capture-analysis and capture to override capture's tiers",
18
14
  " --into <folder> where the ***plain goes, instead of <path>/plain",
19
- ` --parallel <n> how many agents work at once (default: ${DEFAULT_PARALLEL})`,
15
+ " --harness-model <m> the model the chat's agent and its writers write on, and the captured project's harness model",
16
+ " --coding-model <m> the captured project's coding model, the one its code is regenerated on",
20
17
  ].join("\n");
21
- function option(args, name) {
22
- const at = args.findIndex((arg) => arg === name || arg.startsWith(`${name}=`));
23
- if (at === -1)
24
- return undefined;
25
- const arg = args[at];
26
- return arg.includes("=") ? arg.slice(arg.indexOf("=") + 1) : args[at + 1];
27
- }
28
- async function main() {
29
- const args = process.argv.slice(2);
30
- if (args.includes("-h") || args.includes("--help")) {
31
- console.log(USAGE);
32
- return 0;
33
- }
34
- // cli.ts hands --coding-model on as --model, as every command's agents take it.
35
- const valued = ["--harness-model", "--model", "--into", "--parallel"];
36
- const positional = args.filter((arg, at) => !arg.startsWith("-") && !valued.includes(args[at - 1] ?? ""));
37
- const unknown = args.filter((arg, at) => arg.startsWith("-") && !valued.some((name) => arg === name || arg.startsWith(`${name}=`)) && !valued.includes(args[at - 1] ?? ""));
38
- if (positional.length > 1 || unknown.length > 0) {
39
- console.error(`${unknown.length > 0 ? `unknown option: ${unknown[0]}` : "capture takes one path"}\n\n${USAGE}`);
40
- return 1;
41
- }
42
- const parallelText = option(args, "--parallel");
43
- const parallel = parallelText !== undefined ? Number.parseInt(parallelText, 10) : undefined;
44
- if (parallel !== undefined && (!Number.isInteger(parallel) || parallel < 1)) {
45
- console.error(`--parallel takes a whole number of at least 1, not ${parallelText}.`);
46
- return 1;
47
- }
48
- const root = resolve(positional[0] ?? ".");
49
- const into = option(args, "--into");
50
- const harnessModel = option(args, "--harness-model");
51
- const codingModel = option(args, "--model");
52
- const started = Date.now();
53
- console.log(c.bold(`capturing ${root}`));
54
- try {
55
- const result = await runCapture({
56
- root,
57
- // The captured project starts as the config in use here: the one turri reads where the command is run.
58
- configFrom: process.cwd(),
59
- ...(into !== undefined ? { plainDir: resolve(into) } : {}),
60
- ...(harnessModel !== undefined ? { model: harnessModel, harnessModel } : {}),
61
- ...(codingModel !== undefined ? { codingModel } : {}),
62
- ...(parallel !== undefined ? { parallel } : {}),
63
- progress: (line) => console.log(c.dim(` ${line}`)),
64
- });
65
- const minutes = Math.round((Date.now() - started) / 60_000);
66
- console.log(`\n${c.success(c.bold(result.summary))} ${c.dim(`(${minutes} min)`)}`);
67
- console.log(c.dim(`the report: ${relative(process.cwd(), result.reportFile) || result.reportFile}`));
68
- return 0;
18
+ /** The options that take a model, passed on to the chat as they are given. */
19
+ const MODEL_OPTIONS = ["--harness-model", "--coding-model"];
20
+ /**
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.
23
+ */
24
+ export function captureArgs(args) {
25
+ let path;
26
+ let into;
27
+ const models = [];
28
+ for (let at = 0; at < args.length; at += 1) {
29
+ const arg = args[at];
30
+ const eq = arg.startsWith("--") ? arg.indexOf("=") : -1;
31
+ const name = eq === -1 ? arg : arg.slice(0, eq);
32
+ if (name === "--into" || MODEL_OPTIONS.includes(name)) {
33
+ const value = eq === -1 ? args[at + 1] : arg.slice(eq + 1);
34
+ if (eq === -1)
35
+ at += 1;
36
+ if (value === undefined || value === "")
37
+ return { problem: `${name} takes a value.` };
38
+ if (name === "--into")
39
+ into = value;
40
+ else
41
+ models.push(name, value);
42
+ }
43
+ else if (arg.startsWith("-")) {
44
+ return { problem: `unknown option: ${arg}` };
45
+ }
46
+ else if (path === undefined) {
47
+ path = arg;
48
+ }
49
+ else {
50
+ return { problem: `capture takes one path, and was given ${path} and ${arg}.` };
51
+ }
69
52
  }
70
- catch (error) {
71
- console.error(`\n${c.error(c.bold("not captured"))} ${error instanceof Error ? error.message : String(error)}`);
72
- if (!(error instanceof CaptureError) && error instanceof Error && error.stack !== undefined)
73
- console.error(c.dim(error.stack));
74
- return 1;
53
+ for (const [what, value] of [["the path", path], ["--into", into]]) {
54
+ 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.` };
75
56
  }
57
+ const command = ["/capture", ...(path !== undefined ? [path] : []), ...(into !== undefined ? ["--into", into] : [])].join(" ");
58
+ return { args: ["-p", command, ...models] };
76
59
  }
77
- process.exit(await main());
@@ -0,0 +1,124 @@
1
+ import { basename } from "node:path";
2
+ import { Text, truncateToWidth } from "@earendil-works/pi-tui";
3
+ import { spinner } from "./terminal-marks.js";
4
+ import { skillProgressLine } from "./skill-progress.js";
5
+ /**
6
+ * A capture's progress above the chat's input, as its agent says it with capture_progress (the core's `captureProgress`
7
+ * events): its plan's phases on the first line, as a skill's are drawn - the ones done ticked, the one it is in turning
8
+ * - and under it the bar across the whole capture, what it is on and how long it has run.
9
+ *
10
+ * capture app ✓ Plan the modules ━━━━ ⠋ Write the modules ──── ○ Check the scenarios phase 2 of 3
11
+ *
12
+ * ██████████▍░░░░░░░░░░░░░ 43% module 4, orders · 3 of 12 · 12m 30s
13
+ *
14
+ * A blank line under the phases and one under the bar give it room, apart from pi's working line below it.
15
+ * The spinner stops while the agent's turn is over - it is asking the person, or was stopped - and the line says it
16
+ * waits. Before the agent gives a plan, the first line is the spinner and the capture's name alone.
17
+ */
18
+ const PLAIN = { heading: (t) => t, done: (t) => t, now: (t) => t, muted: (t) => t };
19
+ /** The cells of the bar. */
20
+ const BAR_CELLS = 24;
21
+ /** A cell's eighths, as the bar fills it: a part done is drawn to an eighth of a cell. */
22
+ const EIGHTHS = ["", "▏", "▎", "▍", "▌", "▋", "▊", "▉"];
23
+ /** The current phase's mark while the agent's turn is over. */
24
+ const PAUSED = "‖";
25
+ /** `40s`, `2m 10s`, `1h 05m`. */
26
+ export function duration(ms) {
27
+ const seconds = Math.max(0, Math.floor(ms / 1000));
28
+ if (seconds < 60)
29
+ return `${seconds}s`;
30
+ const minutes = Math.floor(seconds / 60);
31
+ if (minutes < 60)
32
+ return `${minutes}m ${String(seconds % 60).padStart(2, "0")}s`;
33
+ return `${Math.floor(minutes / 60)}h ${String(minutes % 60).padStart(2, "0")}m`;
34
+ }
35
+ /** `fraction` of the bar, 0 to 1, filled to an eighth of a cell: what is done in its colour, the rest muted. */
36
+ export function progressBar(fraction, style = PLAIN, cells = BAR_CELLS) {
37
+ const eighths = Math.round(Math.min(1, Math.max(0, fraction)) * cells * 8);
38
+ const full = Math.floor(eighths / 8);
39
+ const part = EIGHTHS[eighths % 8];
40
+ const rest = cells - full - (part === "" ? 0 : 1);
41
+ return style.done("█".repeat(full) + part) + style.muted("░".repeat(rest));
42
+ }
43
+ /** The progress as lines across `width`, the spinner at `frame` and the clock at `now`: the phases, the bar, a blank line after each. */
44
+ export function captureProgressLines(progress, at, style = PLAIN) {
45
+ const { phases, current } = progress;
46
+ const titles = phases.map((phase) => phase.title);
47
+ const head = skillProgressLine({ skill: `capture ${basename(progress.root)}`, phases: titles, current, attempt: 1, frame: progress.working ? at.frame : PAUSED }, at.width, style);
48
+ const finished = current >= 0 && current >= phases.length;
49
+ const on = finished ? "done" : (progress.doing ?? titles[current] ?? (phases.length === 0 ? "making its plan" : "about to start"));
50
+ const counts = !finished && progress.done !== undefined && progress.total !== undefined ? ` · ${progress.done} of ${progress.total}` : "";
51
+ const waiting = !progress.working && !finished ? " · waiting" : "";
52
+ const percent = `${String(Math.floor(progress.fraction * 100)).padStart(3)}%`;
53
+ const bar = ` ${progressBar(progress.fraction, style)} ${style.heading(percent)} ${progress.working ? style.now(on) : on}${style.muted(`${counts}${waiting} · ${duration(at.now - progress.started)}`)}`;
54
+ return [head, "", truncateToWidth(bar, at.width, "…"), ""];
55
+ }
56
+ const CAPTURE_WIDGET = "turri-capture";
57
+ /** A capture's progress above the chat's input; null takes it off. */
58
+ export function captureProgress(ui, progress) {
59
+ if (!progress)
60
+ return ui.setWidget(CAPTURE_WIDGET, undefined);
61
+ ui.setWidget(CAPTURE_WIDGET, (tui, theme) => {
62
+ const redraw = setInterval(() => tui.requestRender(), 1000);
63
+ redraw.unref?.();
64
+ const style = {
65
+ heading: (text) => theme.bold(theme.fg("accent", text)),
66
+ done: (text) => theme.fg("success", text),
67
+ now: (text) => theme.bold(theme.fg("accent", text)),
68
+ muted: (text) => theme.fg("muted", text),
69
+ };
70
+ return {
71
+ render: (width) => captureProgressLines(progress, { frame: spinner(Date.now()), now: Date.now(), width }, style),
72
+ invalidate: () => { },
73
+ dispose: () => clearInterval(redraw),
74
+ };
75
+ });
76
+ }
77
+ /** A capture_progress call in the transcript, from its result: one line where it gave a plan or started a phase, else nothing - the bar shows it. */
78
+ export function progressCallLine(details) {
79
+ if (details === undefined)
80
+ return undefined;
81
+ const lines = [
82
+ ...(details.plan !== undefined ? [`capture plan: ${details.plan.map((title, at) => `${at + 1}. ${title}`).join(" ")}`] : []),
83
+ ...(details.started !== undefined ? [`capture phase ${details.started.phase} of ${details.started.of}: ${details.started.title}`] : []),
84
+ ];
85
+ return lines.length > 0 ? lines.join("\n") : undefined;
86
+ }
87
+ /** capture_progress drawn as its result's line, or not at all: the agent calls it as often as the work moves. */
88
+ export function registerCaptureProgressCalls(pi) {
89
+ const nothing = { render: () => [], invalidate: () => { } };
90
+ const renderers = {
91
+ renderShell: "self",
92
+ renderCall: () => nothing,
93
+ renderResult: (result, _options, theme) => {
94
+ const details = result.details;
95
+ const line = details?.failed === true ? undefined : progressCallLine(details);
96
+ return line === undefined ? nothing : new Text(theme.fg("muted", line), 1, 0);
97
+ },
98
+ };
99
+ pi.registerToolRenderer((name, next) => (name === "capture_progress" ? renderers : next()));
100
+ }
101
+ /**
102
+ * A capture's progress as lines for a log - `turri capture` writes them to stderr, unattended: one as the plan is given,
103
+ * a phase starts, or what it is on changes, never the same twice.
104
+ */
105
+ export function progressLogger(write) {
106
+ let last = "";
107
+ return (progress) => {
108
+ if (progress === null)
109
+ return;
110
+ const { phases, current } = progress;
111
+ const percent = `${Math.floor(progress.fraction * 100)}%`;
112
+ const line = phases.length === 0
113
+ ? undefined
114
+ : current < 0
115
+ ? `capture: a plan of ${phases.length} phases - ${phases.map((phase) => phase.title).join(", ")}`
116
+ : current >= phases.length
117
+ ? "capture: every phase done - 100%"
118
+ : `capture: phase ${current + 1} of ${phases.length}, ${phases[current].title} - ${percent}${progress.doing !== undefined ? ` - ${progress.doing}` : ""}${progress.done !== undefined && progress.total !== undefined ? ` (${progress.done} of ${progress.total})` : ""}`;
119
+ if (line === undefined || line === last)
120
+ return;
121
+ last = line;
122
+ write(line);
123
+ };
124
+ }
package/dist/cli-root.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { spawnSync } from "node:child_process";
2
2
  import { existsSync, readdirSync, readFileSync } from "node:fs";
3
3
  import { homedir } from "node:os";
4
- import { dirname, join } from "node:path";
4
+ import { dirname, extname, join } from "node:path";
5
5
  import { fileURLToPath } from "node:url";
6
6
  /**
7
7
  * This turri: the package the person runs - its version and clone, its themes and art, a global pi extension file that
@@ -52,12 +52,52 @@ export function clientInfo(mode, identity = turriIdentity()) {
52
52
  * and pi's beside it. pi's own `--version` says only pi's, which read as turri's.
53
53
  */
54
54
  export function versionLine(core, identity = turriIdentity()) {
55
- const clone = (commit, changed) => (commit !== null ? `, from a clone, ${commit.slice(0, 7)}${changed === true ? " with changes" : ""}` : "");
56
55
  const under = [
57
- ...(core.version !== null ? [`core ${core.version}${clone(core.commit, core.changed)}`] : []),
56
+ ...(core.version !== null ? [`core ${core.version}${fromClone(core.commit, core.changed)}`] : []),
58
57
  ...(core.pi !== null ? [`pi ${core.pi}`] : []),
59
58
  ];
60
- return `turri ${identity.version ?? "0.0.0"}${clone(identity.git_commit, identity.git_dirty)}${under.length > 0 ? ` (${under.join("; ")})` : ""}`;
59
+ return `turri ${identity.version ?? "0.0.0"}${fromClone(identity.git_commit, identity.git_dirty)}${under.length > 0 ? ` (${under.join("; ")})` : ""}`;
60
+ }
61
+ /** A clone's commit, as the version line and the banner say it: nothing when it is no clone. */
62
+ const fromClone = (commit, changed) => (commit !== null ? `, from a clone, ${commit.slice(0, 7)}${changed === true ? " with changes" : ""}` : "");
63
+ /**
64
+ * The core this process imports - inside this turri's node_modules as npm installs it, or a checkout `npm run link:core`
65
+ * linked - and whether Node took its sources, as it does only under `--conditions=turri-source`. Nothing when it cannot be
66
+ * resolved.
67
+ */
68
+ export function corePlace(resolve = () => import.meta.resolve("@turri-dev/core")) {
69
+ let file;
70
+ try {
71
+ file = fileURLToPath(resolve());
72
+ }
73
+ catch {
74
+ return undefined;
75
+ }
76
+ for (let dir = dirname(file);;) {
77
+ try {
78
+ if (JSON.parse(readFileSync(join(dir, "package.json"), "utf8")).name === "@turri-dev/core")
79
+ return { root: dir, sources: extname(file) === ".ts" };
80
+ }
81
+ catch {
82
+ /* not here: up */
83
+ }
84
+ const up = dirname(dir);
85
+ if (up === dir)
86
+ return undefined;
87
+ dir = up;
88
+ }
89
+ }
90
+ /**
91
+ * The banner's line on the core: its version - and, from a clone, its commit, where the clone is and whether its sources
92
+ * run. `warn` when a clone runs from its dist/, which is as old as its last build.
93
+ */
94
+ export function coreLine(core, place) {
95
+ const text = `core ${core.version ?? "?"}${fromClone(core.commit, core.changed)}`;
96
+ if (place === undefined || (core.commit === null && !place.sources))
97
+ return { text, warn: false };
98
+ if (place.sources)
99
+ return { text: `${text} - ${place.root}, from its sources`, warn: false };
100
+ return { text: `${text} - ${place.root}, from its dist/ build, not its sources (NODE_OPTIONS=--conditions=turri-source runs them)`, warn: true };
61
101
  }
62
102
  /** The global pi extension file that loads turri into every `pi`, if there is one - an older `turri setup` wrote it. */
63
103
  export function globalExtensionFile() {
package/dist/cli.js CHANGED
@@ -95,11 +95,11 @@ 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 - offline, with a report of what it decided" },
98
+ capture: { module: "./capture-cli.ts", blurb: "capture an existing codebase 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 = {
102
- "init-config": "write a quick start config.turri.yaml here, from the vendor you use: a strong model to talk to, a smaller one to write the code",
102
+ "init-config": "write a quick start config.turri.yaml here - or, with --global, your ~/.turri one under every project's - from the vendor you use: a strong model to talk to, a smaller one to write the code",
103
103
  doctor: "check what turri needs - in a project, what it needs of this machine, and that its models answer",
104
104
  };
105
105
  /**
@@ -175,6 +175,20 @@ if (command === "init-config") {
175
175
  const { main } = await import("./init-config-cli.js");
176
176
  process.exit(await main(rest));
177
177
  }
178
+ // The chat's /capture, unattended: pi's print mode, turri built in, asks nobody and ends as the capture does.
179
+ if (command === "capture") {
180
+ const { CAPTURE_USAGE, captureArgs } = await import("./capture-cli.js");
181
+ if (rest.includes("-h") || rest.includes("--help")) {
182
+ console.log(CAPTURE_USAGE);
183
+ process.exit(0);
184
+ }
185
+ const run = captureArgs(rest);
186
+ if ("problem" in run) {
187
+ console.error(`${run.problem}\n\n${CAPTURE_USAGE}`);
188
+ process.exit(1);
189
+ }
190
+ chat(run.args);
191
+ }
178
192
  if (command === "doctor") {
179
193
  const { main } = await import("./doctor-cli.js");
180
194
  process.exit(await main(rest));
@@ -1,6 +1,6 @@
1
1
  import { getMarkdownTheme, UserMessageComponent } from "@earendil-works/pi-coding-agent";
2
- import { Box, Text } from "@earendil-works/pi-tui";
3
- import { COMMAND_OUTCOME, SKILL_MESSAGE_ENTRY, SIDE_ENTRY, SKILL_RUN_ENTRY, JOB_ENTRY, HISTORY_ENTRY, JOBS_LIST_ENTRY, MILESTONE_ENTRY, INTERVIEW_ENTRY } from "@turri-dev/core";
2
+ import { Box, Markdown, Text } from "@earendil-works/pi-tui";
3
+ import { CAPTURE_REPORT_MESSAGE, COMMAND_OUTCOME, SKILL_MESSAGE_ENTRY, SIDE_ENTRY, SKILL_RUN_ENTRY, JOB_ENTRY, HISTORY_ENTRY, JOBS_LIST_ENTRY, MILESTONE_ENTRY, INTERVIEW_ENTRY } from "@turri-dev/core";
4
4
  import { PANEL_KEY } from "./terminal-marks.js";
5
5
  /**
6
6
  * A skill's question as the transcript keeps it: who asked, what it said before asking - a brief to confirm, the choices
@@ -39,6 +39,13 @@ export function registerEntries(pi) {
39
39
  });
40
40
  // The sentinel's notices, their answers and its conclusions are the inbox's (terminal-notifications.ts): answered and
41
41
  // read there, and the chat says each conclusion in its own words. No renderer: pi draws none of them in the chat.
42
+ // The report of the capture that wrote this project, in the first chat opened here after it: Markdown, as the agent wrote it.
43
+ pi.registerMessageRenderer(CAPTURE_REPORT_MESSAGE, (message) => {
44
+ const text = typeof message.content === "string" ? message.content : message.content.map((part) => (part.type === "text" ? part.text : "")).join("");
45
+ const box = new Box(1, 0);
46
+ box.addChild(new Markdown(text, 0, 0, getMarkdownTheme()));
47
+ return box;
48
+ });
42
49
  pi.registerEntryRenderer(SKILL_RUN_ENTRY, (entry, _options, theme) => {
43
50
  const data = entry.data;
44
51
  if (data === undefined)
@@ -5,7 +5,7 @@ import { initConfig } from "@turri-dev/core/project";
5
5
  import { brand } from "./brand.js";
6
6
  const USAGE = [
7
7
  "usage: turri init-config [--vendor anthropic|openai|google|amazon-bedrock|other] [--maker <maker>] [--region <geography>]",
8
- " [--harness-model <spec> --coding-model <spec> [--judge-model <spec>]] [--force] [folder]",
8
+ " [--harness-model <spec> --coding-model <spec> [--judge-model <spec>]] [--force] [--global | folder]",
9
9
  "",
10
10
  "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
11
  "writes the code, from the vendor you use. Asked when --vendor is not given and this is a terminal; otherwise other -",
@@ -18,6 +18,9 @@ const USAGE = [
18
18
  "A config.turri.yaml already there keeps everything but its two models; --force writes the whole of it again. A new",
19
19
  "one takes from a config.yaml beside it - another tool's, say - the keys turri reads too, its testing scripts say, and leaves",
20
20
  "config.yaml as it is.",
21
+ "",
22
+ "--global writes your global config instead, ~/.turri/config.turri.yaml: turri reads it under every project's",
23
+ "config.turri.yaml, and a project's own file overrides any key of it.",
21
24
  ].join("\n");
22
25
  /** Ask until the answer is one `read` takes. */
23
26
  async function askUntil(rl, prompt, read, again) {
@@ -127,6 +130,11 @@ export async function main(args) {
127
130
  };
128
131
  const taken = new Set(Object.values(flags).flatMap((flag) => flag.at));
129
132
  const rest = args.filter((arg, index) => !arg.startsWith("-") && !taken.has(index));
133
+ const global = args.includes("--global");
134
+ if (global && rest[0] !== undefined) {
135
+ console.error(`--global writes ~/.turri/config.turri.yaml: name no folder with it.\n\n${USAGE}`);
136
+ return 1;
137
+ }
130
138
  const folder = rest[0] ?? process.cwd();
131
139
  if (!existsSync(folder)) {
132
140
  console.error(`${folder} does not exist.`);
@@ -199,6 +207,7 @@ export async function main(args) {
199
207
  const result = await initConfig(folder, {
200
208
  paint: brand,
201
209
  force,
210
+ ...(global ? { global } : {}),
202
211
  ...(chosen.vendor !== undefined ? { vendor: chosen.vendor } : {}),
203
212
  ...(chosen.bedrock !== undefined ? { bedrock: chosen.bedrock } : {}),
204
213
  ...(chosen.models !== undefined ? { models: chosen.models } : {}),
package/dist/pi-launch.js CHANGED
@@ -20,6 +20,7 @@ import { clientInfo } from "./cli-root.js";
20
20
  import { setProcessTurri } from "./extension.js";
21
21
  import { takeOverSettings } from "./pi-settings.js";
22
22
  import { adoptAsBound } from "./print-mode.js";
23
+ import { progressLogger } from "./capture-progress.js";
23
24
  import { quietBrandThemeOverrides } from "./pi-themes.js";
24
25
  import { takeCaptured } from "./reopen.js";
25
26
  import { createTerminal } from "./terminal-view.js";
@@ -91,7 +92,7 @@ if (interactive) {
91
92
  frontend: { ...terminal.frontend, sessions: driveTerminal(terminal, { restore }) },
92
93
  client: clientInfo("chat"),
93
94
  overrides,
94
- // Opened again in the project a capture wrote (reopen.ts): its report, told in the first chat.
95
+ // Opened again in the project a capture wrote (reopen.ts): its summary, drawn in the first chat.
95
96
  ...(captured !== undefined ? { captured } : {}),
96
97
  });
97
98
  terminal.attach(turri);
@@ -102,6 +103,11 @@ else {
102
103
  const mode = args.find((arg) => arg.startsWith("--mode="))?.slice("--mode=".length) ?? (modeAt !== -1 ? args[modeAt + 1] : undefined) ?? "print";
103
104
  turri = await createTurri({ client: clientInfo(mode), overrides, persist: false });
104
105
  adoptAsBound(turri);
106
+ // `turri capture`, unattended: how far the capture has got, a line on stderr as it moves - stdout is the agent's answer.
107
+ if (mode === "print") {
108
+ const logProgress = progressLogger((line) => process.stderr.write(`${line}\n`));
109
+ turri.on("captureProgress", (event) => logProgress(event.progress));
110
+ }
105
111
  }
106
112
  setProcessTurri(turri);
107
113
  // turri built into pi here, in this process, rather than loaded from a file. An older turri installed into every pi
package/dist/reopen.js CHANGED
@@ -1,13 +1,12 @@
1
1
  import { readFileSync, rmSync, writeFileSync } from "node:fs";
2
- import { relative } from "node:path";
3
2
  /**
4
3
  * turri opened again in another folder, in the same terminal, once its chat has quit: a chat works on the project of
5
4
  * the folder it was opened in, and after a capture the work is in another - `plain/`, a project of its own. `turri`
6
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
7
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
8
- * starts the chat there as it started the first. The session's `openProject` asks for it (terminal-view.ts); the chat
9
- * opened again tells the capture's report (`createTurri({ captured })`). The handoff is the CLI's own, between its two
10
- * processes: the core knows nothing of it.
7
+ * starts the chat there as it started the first. The terminal asks for it as it hears a capture is done (`captureDone`,
8
+ * terminal-view.ts); the chat opened again shows the capture's report (`createTurri({ captured })`). The handoff is the
9
+ * CLI's own, between its two processes: the core knows nothing of it.
11
10
  */
12
11
  /** The file the chat `turri` started writes where it is to open again. */
13
12
  export const REOPEN_FILE_ENV = "TURRI_CLI_REOPEN_FILE";
@@ -65,16 +64,5 @@ export function takeCaptured(env = process.env) {
65
64
  return undefined;
66
65
  }
67
66
  }
68
- /** What the person is asked once a capture in the chat ends: to open turri again in the captured project. */
69
- export function captureOpenQuestion(cwd, dir, summary) {
70
- const folder = `${relative(cwd, dir) || dir}/`;
71
- return {
72
- title: `Open the captured ***plain in ${folder}?`,
73
- message: [
74
- summary,
75
- "",
76
- `turri closes here and opens again in ${folder} - the captured project - where ctrl+h shows its ***plain and /regenerate builds it. Its report is told there.`,
77
- `Not now: it stays here, and \`cd ${folder.slice(0, -1)} && turri\` opens it later.`,
78
- ].join("\n"),
79
- };
80
- }
67
+ /** 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
+ export const CAPTURE_OPEN_QUESTION = "Open turri in the newly captured ***plain project?";
@@ -40,6 +40,8 @@ export function skillProgressLine(progress, width, style = PLAIN) {
40
40
  function whereItIs(progress) {
41
41
  if (progress.current < 0)
42
42
  return "starting";
43
+ if (progress.current >= progress.phases.length)
44
+ return "done";
43
45
  return `phase ${progress.current + 1} of ${progress.phases.length}${progress.attempt > 1 ? `, attempt ${progress.attempt}` : ""}`;
44
46
  }
45
47
  /** Each phase as it is drawn: done ticked, the one it is in marked, the rest to come. */