@turri-dev/cli 0.2.3 → 0.2.4-next.009bd0c

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 (175) hide show
  1. package/README.md +7 -8
  2. package/dist/bedrock-region.js +3 -3
  3. package/dist/chat-idle.d.ts +2 -2
  4. package/dist/chat-idle.js +2 -2
  5. package/dist/chat-models.d.ts +1 -1
  6. package/dist/chat-models.js +1 -1
  7. package/dist/chat-scope.d.ts +1 -3
  8. package/dist/chat-skills.d.ts +1 -1
  9. package/dist/chat-skills.js +1 -1
  10. package/dist/chats.d.ts +44 -20
  11. package/dist/chats.js +125 -64
  12. package/dist/cli.js +12 -31
  13. package/dist/config-edit.d.ts +20 -8
  14. package/dist/config-edit.js +32 -26
  15. package/dist/config.d.ts +106 -78
  16. package/dist/config.js +267 -133
  17. package/dist/conform-cli.js +14 -3
  18. package/dist/conformance-switch.d.ts +13 -22
  19. package/dist/conformance-switch.js +37 -59
  20. package/dist/drift-cli.js +1 -1
  21. package/dist/extension.d.ts +17 -10
  22. package/dist/extension.js +425 -531
  23. package/dist/genome.js +10 -49
  24. package/dist/graph.js +3 -5
  25. package/dist/host-session.d.ts +11 -21
  26. package/dist/host-session.js +6 -8
  27. package/dist/host.d.ts +4 -4
  28. package/dist/host.js +4 -7
  29. package/dist/identity.js +2 -3
  30. package/dist/init-config.d.ts +1 -2
  31. package/dist/init-config.js +10 -17
  32. package/dist/installed-providers.d.ts +1 -1
  33. package/dist/installed-providers.js +1 -1
  34. package/dist/launch-agent.d.ts +41 -0
  35. package/dist/launch-agent.js +219 -0
  36. package/dist/{release-cli.js → launch-cli.js} +41 -24
  37. package/dist/launch-session.d.ts +58 -0
  38. package/dist/launch-session.js +195 -0
  39. package/dist/launch-tools.d.ts +28 -0
  40. package/dist/launch-tools.js +69 -0
  41. package/dist/launch-track.d.ts +120 -0
  42. package/dist/launch-track.js +298 -0
  43. package/dist/loop-cli.d.ts +4 -3
  44. package/dist/loop-cli.js +17 -15
  45. package/dist/loop-tools.d.ts +45 -21
  46. package/dist/loop-tools.js +155 -90
  47. package/dist/new-project.js +2 -2
  48. package/dist/notice.d.ts +7 -6
  49. package/dist/parse-cli.js +2 -2
  50. package/dist/pi-launch.js +4 -1
  51. package/dist/pi-settings.d.ts +4 -0
  52. package/dist/pi-settings.js +39 -0
  53. package/dist/pi.js +12 -9
  54. package/dist/plain/check.d.ts +2 -9
  55. package/dist/plain/check.js +6 -39
  56. package/dist/plain-files.d.ts +2 -2
  57. package/dist/plain-files.js +7 -7
  58. package/dist/regenerate/activity.d.ts +0 -7
  59. package/dist/regenerate/activity.js +2 -20
  60. package/dist/regenerate/agent-env.d.ts +1 -1
  61. package/dist/regenerate/agent-env.js +3 -3
  62. package/dist/regenerate/agent-shell.js +5 -3
  63. package/dist/regenerate/audit.js +9 -0
  64. package/dist/regenerate/base-folder.d.ts +2 -2
  65. package/dist/regenerate/base-folder.js +1 -1
  66. package/dist/regenerate/cases.js +7 -0
  67. package/dist/regenerate/chunk-plan.d.ts +5 -0
  68. package/dist/regenerate/chunk-plan.js +16 -1
  69. package/dist/regenerate/command-check.d.ts +1 -1
  70. package/dist/regenerate/command-check.js +1 -1
  71. package/dist/regenerate/delivery.d.ts +1 -1
  72. package/dist/regenerate/delivery.js +3 -3
  73. package/dist/regenerate/drift.d.ts +4 -0
  74. package/dist/regenerate/drift.js +26 -6
  75. package/dist/regenerate/failure-reports.d.ts +28 -0
  76. package/dist/regenerate/failure-reports.js +79 -0
  77. package/dist/regenerate/job-panel.js +3 -1
  78. package/dist/regenerate/jobs-tree.js +1 -1
  79. package/dist/regenerate/jobs.d.ts +4 -2
  80. package/dist/regenerate/jobs.js +14 -10
  81. package/dist/regenerate/launch.d.ts +126 -0
  82. package/dist/regenerate/{release.js → launch.js} +60 -48
  83. package/dist/regenerate/ledger-view.d.ts +11 -24
  84. package/dist/regenerate/ledger-view.js +14 -60
  85. package/dist/regenerate/ledger.d.ts +26 -16
  86. package/dist/regenerate/ledger.js +1 -1
  87. package/dist/regenerate/lineage.d.ts +2 -0
  88. package/dist/regenerate/lineage.js +8 -0
  89. package/dist/regenerate/loop.d.ts +54 -67
  90. package/dist/regenerate/loop.js +312 -148
  91. package/dist/regenerate/model-names.d.ts +33 -0
  92. package/dist/regenerate/{engine.js → model-names.js} +2 -28
  93. package/dist/regenerate/paths.d.ts +3 -3
  94. package/dist/regenerate/paths.js +4 -4
  95. package/dist/regenerate/records.d.ts +11 -0
  96. package/dist/regenerate/records.js +15 -0
  97. package/dist/regenerate/regenerate.d.ts +0 -2
  98. package/dist/regenerate/regenerate.js +4 -15
  99. package/dist/regenerate/renames.js +4 -4
  100. package/dist/regenerate/requires.d.ts +7 -0
  101. package/dist/regenerate/requires.js +24 -18
  102. package/dist/regenerate/scripts-being-written.d.ts +4 -4
  103. package/dist/regenerate/scripts-being-written.js +3 -3
  104. package/dist/regenerate/spec-map.js +3 -3
  105. package/dist/regenerate/standing.js +1 -1
  106. package/dist/regenerate/submit-work.d.ts +2 -0
  107. package/dist/regenerate/submit-work.js +8 -3
  108. package/dist/regenerate/test-scripts.d.ts +2 -1
  109. package/dist/regenerate/test-scripts.js +33 -23
  110. package/dist/regenerate/testing-steps.d.ts +16 -5
  111. package/dist/regenerate/testing-steps.js +28 -9
  112. package/dist/regenerate-cli.js +18 -9
  113. package/dist/self-invocation.d.ts +11 -0
  114. package/dist/self-invocation.js +36 -10
  115. package/dist/sentinel-check.d.ts +3 -3
  116. package/dist/sentinel-check.js +3 -3
  117. package/dist/sentinel.d.ts +17 -12
  118. package/dist/sentinel.js +75 -46
  119. package/dist/{config-command.d.ts → settings.d.ts} +13 -8
  120. package/dist/{config-command.js → settings.js} +155 -24
  121. package/dist/setup.d.ts +2 -2
  122. package/dist/setup.js +7 -7
  123. package/dist/skill.d.ts +0 -11
  124. package/dist/skill.js +0 -9
  125. package/dist/tools.js +2 -3
  126. package/dist/turri-versions.js +2 -1
  127. package/docs/README.md +4 -6
  128. package/docs/authoring-plain.md +3 -3
  129. package/docs/chats.md +6 -9
  130. package/docs/claude-subscription.md +2 -2
  131. package/docs/config.md +61 -51
  132. package/docs/development.md +4 -5
  133. package/docs/headless.md +7 -6
  134. package/docs/hosting.md +24 -23
  135. package/docs/launch.md +63 -0
  136. package/docs/parser.md +3 -3
  137. package/docs/regenerating.md +30 -22
  138. package/docs/sandbox.md +3 -3
  139. package/docs/sentinel.md +27 -16
  140. package/docs/skills-and-gates.md +6 -11
  141. package/docs/using.md +25 -42
  142. package/genome/rules/project-model.md +2 -1
  143. package/genome/rules/test-plain-files.md +15 -7
  144. package/genome/rules/turri-regeneration.md +7 -10
  145. package/genome/skills/convert-old-syntax/SKILL.md +5 -5
  146. package/genome/skills/implement-conformance-testing-script/SKILL.md +2 -2
  147. package/genome/skills/implement-unit-testing-script/SKILL.md +3 -3
  148. package/package.json +1 -1
  149. package/dist/advisor-chat.d.ts +0 -63
  150. package/dist/advisor-chat.js +0 -290
  151. package/dist/change-plain-cli.js +0 -55
  152. package/dist/ledger-cli.d.ts +0 -1
  153. package/dist/ledger-cli.js +0 -50
  154. package/dist/ledger-tools.d.ts +0 -10
  155. package/dist/ledger-tools.js +0 -64
  156. package/dist/regenerate/advisor-records.d.ts +0 -93
  157. package/dist/regenerate/advisor-records.js +0 -110
  158. package/dist/regenerate/advisor-runs.d.ts +0 -87
  159. package/dist/regenerate/advisor-runs.js +0 -327
  160. package/dist/regenerate/engine.d.ts +0 -52
  161. package/dist/regenerate/release.d.ts +0 -121
  162. package/dist/regenerate/test-advisor.d.ts +0 -101
  163. package/dist/regenerate/test-advisor.js +0 -379
  164. package/dist/release-agent.d.ts +0 -43
  165. package/dist/release-agent.js +0 -130
  166. package/dist/release-cli.d.ts +0 -1
  167. package/dist/release-tools.d.ts +0 -44
  168. package/dist/release-tools.js +0 -170
  169. package/dist/spec-tools.d.ts +0 -36
  170. package/dist/spec-tools.js +0 -128
  171. package/dist/stacks.d.ts +0 -13
  172. package/dist/stacks.js +0 -96
  173. package/docs/deploy.md +0 -48
  174. package/docs/test-advisor.md +0 -110
  175. /package/dist/{change-plain-cli.d.ts → launch-cli.d.ts} +0 -0
@@ -1,170 +0,0 @@
1
- import { isAbsolute, relative, resolve } from "node:path";
2
- import { refuseTestPlainFile } from "./test-plain-files.js";
3
- import { defineTool } from "@earendil-works/pi-coding-agent";
4
- import { Type } from "typebox";
5
- import { deployLogDir, deployTarget, describeDeployment, exportModule, hostDirOf, listDeployed, shortPath, startDeployed, stopDeployed, } from "./regenerate/release.js";
6
- import { projectDirOf } from "./regenerate/paths.js";
7
- import { haltTool } from "./loop-tools.js";
8
- export function createDeployState() {
9
- return { released: new Map(), guidance: new Map() };
10
- }
11
- /**
12
- * A module's release as it stands, when it is current: its own codebase's last commit is what the last release shipped,
13
- * and nothing that release started has ended. Undefined when it is behind, was never made, or what it started died -
14
- * then it is released again.
15
- */
16
- export function currentRelease(state, plainFile, moduleName) {
17
- let target;
18
- try {
19
- target = deployTarget(plainFile, moduleName);
20
- }
21
- catch {
22
- return undefined;
23
- }
24
- const last = state.released.get(moduleName);
25
- if (target.entry.moduleName !== moduleName || last === undefined || !target.commit.startsWith(last.commit))
26
- return undefined;
27
- const started = listDeployed().filter((item) => item.moduleName === moduleName && (last.at === undefined || item.startedAt >= last.at));
28
- return started.some((item) => item.exited !== undefined) ? undefined : last;
29
- }
30
- /** What the agent is to do once the code is in dist - in the deploy tool's answer, and the CLI agent's prompt. */
31
- export function deployGuide(dir) {
32
- const where = shortPath(dir);
33
- return [
34
- `What to do now, to have the person try it - it runs on this machine, outside the sandbox, from ${where}:`,
35
- `1. Find out how it runs: its README, its manifests (package.json, pyproject.toml, requirements.txt, go.mod, Cargo.toml, pom.xml, build.gradle, docker-compose.yml) and entry points, in ${where}.`,
36
- "2. Check the toolchains it needs are on this machine (`command -v node`, `python3 --version`, `go version`, ...) - under another name too: python where python3 is not, of the version it needs. One missing: you install nothing on the machine and change none of its settings - stop, and tell the person exactly what to install, the command they run themselves (`brew install node`), and that releasing again picks it up.",
37
- "3. Install what it needs into the project yourself, in your shell - dependencies into a virtual environment or node_modules, a build that fetches packages, an image pull. Do not ask the person: do it, and fix what fails - within the project: never a global install, never a system setting.",
38
- "4. Start anything that keeps running - a backend, a frontend's dev server - with activate, with the URL it serves at: never in the shell with & or nohup. An app with a backend and a frontend: start both, the backend first.",
39
- "5. Then tell the person, briefly. Something that serves: only where to open it - the frontend's URL, and the API's in one line when there is one. A CLI or a library: a few commands to paste, run from the folder, with what they print. A port that is taken: say which and by what, and do not move the app to another.",
40
- `Do not change the code in ${where} - it is a copy of what was built, and a fix belongs in the spec. A config file it needs made from its example (a .env from .env.example) is fine.`,
41
- ].join("\n");
42
- }
43
- /**
44
- * What the agent is to do on a guided release: the code is in dist, as on any release, and the guidance takes it on from
45
- * there. The rules of a release to dist hold here too: what keeps running started with activate, and the built code never
46
- * edited - and nothing put to the person.
47
- */
48
- export function guidedGuide(deployment, guidance) {
49
- const host = shortPath(deployment.hostDir ?? deployment.dir);
50
- const dist = shortPath(deployment.dir);
51
- const built = shortPath(deployment.buildDir);
52
- return [
53
- "The guidance for releasing it - follow it:",
54
- guidance.trim(),
55
- "",
56
- `What to do now - on this machine, outside the sandbox, from ${host}:`,
57
- `1. The code to release is in ${dist}: the last commit that landed whole. Take it from there, never from ${built}, where a pulse may be writing. Where the guidance's own tooling reads ${built}, point it at ${dist} if it can take another source; if it cannot, do by hand, from ${dist}, what it does.`,
58
- `2. Read what the guidance leaves open - the scripts, files and commands it names, in ${host} - then do what it says, in its order. Where it says to change the host - a registration, an import, a config entry - change it. Never change ${built} or ${dist}: a fix to the code belongs in the spec.`,
59
- "3. Run the project's scripts and install what it needs into the project yourself, in your shell. Do not ask the person: do it, and fix what fails. A toolchain or system tool the machine lacks you never install, nor change a setting of the machine's: tell the person the command they run themselves.",
60
- "4. Start what keeps running - a start script, a dev server - with activate, with the URL it serves at - never in the shell with & or nohup.",
61
- `5. Then tell the person briefly: what was done, what you changed in ${host} if anything, and where to open it or how to try it. Where the guidance does not fit what you find, say so, and do not guess past it.`,
62
- ].join("\n");
63
- }
64
- function text(value, details = {}) {
65
- return { content: [{ type: "text", text: value }], details };
66
- }
67
- /** The folder a command runs in: dist's, or - guided - the host codebase's, or one inside either. */
68
- function inside(current, dir) {
69
- const base = current.hostDir ?? current.dir;
70
- const target = resolve(base, dir ?? ".");
71
- const within = (root) => {
72
- const rel = relative(root, target);
73
- return !rel.startsWith("..") && !isAbsolute(rel);
74
- };
75
- if (!within(base) && !within(current.dir))
76
- throw new Error(`${dir} is outside ${shortPath(base)}: what release starts runs from there.`);
77
- return target;
78
- }
79
- export function createDeployTools(options) {
80
- const { state } = options;
81
- const needsDeploy = () => {
82
- if (state.current === undefined)
83
- throw new Error("Nothing is released yet: call release first.");
84
- return state.current;
85
- };
86
- const deploy = defineTool({
87
- name: "release",
88
- label: "Release",
89
- description: "Release a module's code for the person to try - the module on top of the spec's requires chain, which holds the " +
90
- "code of the ones below - stopping whatever an earlier release of it started. Before you call it, ask yourself: is " +
91
- "there guidance for releasing this project - in what the person said, the project's AGENTS.md, a skill, or anything " +
92
- "else you were given? An integration a host application loads, say, released with the host's own scripts. If there " +
93
- "is, pass it as guidance, in full. Either way its last commit - what last landed whole - is exported to dist/<module> " +
94
- "first; with guidance it is taken on from there as the guidance says, in the host codebase; without, it is started " +
95
- "from there, as best it can be. Call it when the " +
96
- "person wants to try, run, see or use what was built, and whenever guidance says to release after a pulse: when " +
97
- "the module's last commit is already released it does nothing and says so, so never decide that yourself. It says " +
98
- "what to do next.",
99
- promptSnippet: "release the regenerated code for the person to try - as the project's release guidance says, or to dist/<module> - then activate it",
100
- parameters: Type.Object({
101
- plain_file: Type.Optional(Type.String({ description: "A .plain file of the module. Default: the project's module from config.turri.yaml." })),
102
- in_module: Type.Optional(Type.String({ description: "The codebase to take, when modules built on this one branch" })),
103
- again: Type.Optional(Type.Boolean({ description: "Release even when the module's last commit is already released - only when what the last release said to do was not done." })),
104
- guidance: Type.Optional(Type.String({ description: "The guidance for releasing this project, whole, from wherever it is - the person, AGENTS.md, a skill: the scripts to run and in which order, where the code goes. Omit when there is none." })),
105
- }),
106
- async execute(_id, params) {
107
- const named = params.plain_file ?? options.defaultPlainFile();
108
- if (named === undefined)
109
- throw new Error("Which spec? config.turri.yaml names no module: pass plain_file.");
110
- const plainFile = resolve(options.cwd, named);
111
- refuseTestPlainFile(plainFile);
112
- const target = deployTarget(plainFile, params.in_module);
113
- const guidance = params.guidance?.trim() || undefined;
114
- // Released already: the module's last commit is what the last release shipped. Nothing is exported or stopped -
115
- // releasing it again would only restart what runs - so it is safe to call after every pulse.
116
- const last = state.released.get(target.entry.moduleName);
117
- if (last !== undefined && !params.again && target.commit.startsWith(last.commit) && last.way === (guidance === undefined ? "dist" : "guided")) {
118
- state.current = last;
119
- return text(`Already released: ${target.entry.moduleName}'s last commit, ${last.commit} (${last.subject}), is what the last release shipped, and what that release said to do was done then. Nothing to do - what runs is left running. Say so in a line.`, { module: last.moduleName, commit: last.commit, already: true });
120
- }
121
- // What the last release started runs from what is about to be replaced.
122
- const stopped = await stopDeployed({ moduleName: target.entry.moduleName });
123
- // Always the last commit, clean, in dist first; guidance takes it on from there.
124
- const exported = exportModule(plainFile, params.in_module);
125
- const deployment = guidance === undefined ? exported : { ...exported, way: "guided", hostDir: hostDirOf(plainFile, options.cwd) };
126
- state.current = deployment;
127
- state.released.set(deployment.moduleName, { ...deployment, at: Date.now() });
128
- if (guidance !== undefined)
129
- state.guidance.set(deployment.moduleName, guidance);
130
- return text([
131
- describeDeployment(deployment),
132
- ...(stopped.length > 0 ? [`Stopped what the last release started: ${stopped.join(", ")}.`] : []),
133
- "",
134
- guidance === undefined ? deployGuide(deployment.dir) : guidedGuide(deployment, guidance),
135
- ].join("\n"), { module: deployment.moduleName, way: deployment.way, dir: deployment.dir, ...(deployment.hostDir !== undefined ? { host: deployment.hostDir } : {}), commit: deployment.commit });
136
- },
137
- });
138
- const startTool = defineTool({
139
- name: "activate",
140
- label: "Activate",
141
- description: "Start something that keeps running - a backend, a frontend's dev server - from the deployed folder, on this " +
142
- "machine: in the background, its output kept, stopped on the next release, on /halt and when turri exits. " +
143
- "With `url`, waits until something answers there and says so, or shows the end of its output. A port something " +
144
- "else holds is said, and nothing is started.",
145
- promptSnippet: "start a server of the deployed code, and wait for it to answer",
146
- parameters: Type.Object({
147
- name: Type.String({ description: "A short name for it: backend, frontend, app" }),
148
- command: Type.String({ description: "The command that starts it, as run from its folder" }),
149
- url: Type.Optional(Type.String({ description: "Where it serves, e.g. http://localhost:5173 - it is ready once this answers" })),
150
- dir: Type.Optional(Type.String({ description: "The folder to run it in, relative to the deployed folder - e.g. frontend - never the project's path to the deployed folder (dist/<module>). Default: the deployed folder itself." })),
151
- }),
152
- async execute(_id, params) {
153
- const current = needsDeploy();
154
- const started = await startDeployed({
155
- name: params.name,
156
- command: params.command,
157
- dir: inside(current, params.dir),
158
- root: current.hostDir ?? current.dir,
159
- moduleName: current.moduleName,
160
- logDir: deployLogDir(projectDirOf(current.plainFile)),
161
- ...(params.url !== undefined ? { url: params.url } : {}),
162
- });
163
- return text(started.text, { ok: started.ok, ...(started.process !== undefined ? { pid: started.process.pid, log: started.process.log } : {}) });
164
- },
165
- });
166
- // The one halt: with the pulses in the conversation, and without them for the release agent.
167
- const stopTool = haltTool(options.jobs !== undefined ? { jobs: options.jobs, ...(options.workLoop !== undefined ? { workLoop: options.workLoop } : {}) } : {});
168
- return [deploy, startTool, stopTool];
169
- }
170
- export const DEPLOY_TOOLS = ["release", "activate", "halt"];
@@ -1,36 +0,0 @@
1
- import { type ToolDefinition } from "@earendil-works/pi-coding-agent";
2
- import { type WorkLoop } from "./regenerate/loop.ts";
3
- import { type LiveReviewer } from "./tools.ts";
4
- /** Whether a question has been answered since the last new spec change was written. */
5
- export interface SpecPace {
6
- /** A question was answered; `owesChange` false for one no change comes from - a phase's confirmation, a dismissal. */
7
- answered(owesChange?: boolean): void;
8
- /** Whether an answer has come since the last change, and is not written yet. */
9
- owed(): boolean;
10
- }
11
- type AnyTool = ToolDefinition<any, any, any>;
12
- /**
13
- * Writing a spec change as a diff, and building it, as one step.
14
- *
15
- * In an interview whose unit of work is a spec change, every change is meant to be built the
16
- * moment it is written. Left to two tool calls - change the file, then start the render - the
17
- * second is the one that gets forgotten, and nothing notices. So the diff is applied and its
18
- * build queued in the same call: a change cannot reach the specs without its render being
19
- * started. A new change needs an answer since the last one; a correction does not.
20
- */
21
- export declare function createSpecDiffTools(options: {
22
- loop: WorkLoop;
23
- cwd: string;
24
- liveReview?: LiveReviewer;
25
- /** One new change per answer (the default); false, for a skill that writes the specs on its own. */
26
- paced?: boolean;
27
- /**
28
- * Whether the phase the interview is in lets a change come without an answer before it: one where each answer owes a
29
- * change instead (`owed`, refused a next question until it is written), and the agent writes what it decides itself.
30
- */
31
- free?: () => boolean;
32
- }): {
33
- tools: AnyTool[];
34
- pace: SpecPace;
35
- };
36
- export {};
@@ -1,128 +0,0 @@
1
- import { resolve } from "node:path";
2
- import { defineTool } from "@earendil-works/pi-coding-agent";
3
- import { Type } from "typebox";
4
- import { advisingNote } from "./advisor-chat.js";
5
- import { checkTouchedPlain, formatCheckResults } from "./plain/check.js";
6
- import { applySpecDiff, plainFilesOf, revertSpecDiff } from "./regenerate/regenerate.js";
7
- import { refuseTestPlainFile } from "./test-plain-files.js";
8
- import { describeModules } from "./regenerate/loop.js";
9
- import { reviewNote } from "./tools.js";
10
- import { STACK_PARAM, stacklessBuild, withCallStack } from "./loop-tools.js";
11
- import { stackNamed } from "./config.js";
12
- import { projectDirOf } from "./regenerate/paths.js";
13
- /**
14
- * Writing a spec change as a diff, and building it, as one step.
15
- *
16
- * In an interview whose unit of work is a spec change, every change is meant to be built the
17
- * moment it is written. Left to two tool calls - change the file, then start the render - the
18
- * second is the one that gets forgotten, and nothing notices. So the diff is applied and its
19
- * build queued in the same call: a change cannot reach the specs without its render being
20
- * started. A new change needs an answer since the last one; a correction does not.
21
- */
22
- export function createSpecDiffTools(options) {
23
- const { loop, cwd, liveReview } = options;
24
- const skillPaced = options.paced !== false;
25
- const isPaced = () => skillPaced && options.free?.() !== true;
26
- /** An answer has come since the last change: it is owed one. */
27
- let owed = false;
28
- let answeredSinceLastDiff = true;
29
- const writeDiff = defineTool({
30
- name: "change_plain",
31
- label: "Write spec diff",
32
- description: "Apply a change to the ***plain specs, given as a git diff of the .plain files, and start building it in " +
33
- "the background. The diff is applied with git; if the specs no longer parse, it is undone and nothing is " +
34
- "built. Any section may change - definitions, implementation reqs, functional specs, added, changed or removed - and " +
35
- "every change is built, whatever it touches. A diff may touch test plain files too - tests/<module>/<func-id>.plain, " +
36
- "a functional spec's conformance and acceptance scenarios. A functional spec with none has no test plain file: " +
37
- "write one only to give it scenarios.",
38
- promptSnippet: "apply a git diff of the .plain specs and start building it",
39
- promptGuidelines: [
40
- "Every change to a .plain file in the product phase goes through change_plain, as a git diff with paths relative to the project root. It writes the change and starts its build in one step.",
41
- "A functional spec is a `# <func-id>` heading and its text. One with scenarios has a test plain file, tests/<module>/<func-id>.plain: its `module:` and `func_id:`, then `***conformance tests***` and `***acceptance tests***`, each scenario a `# <scenario-id>` heading and its text - a section only when it has a scenario, an empty one being a syntax error. One with no scenarios has no test plain file. plain_file stays the module's .plain file when the diff touches only its test plain files.",
42
- skillPaced
43
- ? "One change per answer, and a new one only after the user has answered a question about it. Set fixes_earlier to correct something already written."
44
- : "Write the changes one after another, on your own: no answer is needed between them, and none is asked for. Set fixes_earlier to correct something already written.",
45
- "In a project of stacks, the change is built with the stack named after the module - backend.plain with config.turri.backend.yaml - by itself. For a module whose stack has another name, pass it as stack. A change that cannot be built yet for want of a stack is written all the same: carry on, and pass the stack with the next change.",
46
- "To take something out of what is already written and queued - the user drops a page or a feature - write the diff that removes it from every spec that names it, with fixes_earlier. What is left to build is worked out from the spec each time, and a build the change undoes is stopped by itself; never stop builds to drop a change - it stays in the files.",
47
- ],
48
- parameters: Type.Object({
49
- plain_file: Type.String({ description: "The .plain file of the module the change is built for" }),
50
- diff: Type.String({ description: "The change, as a git diff (diff --git a/<file> b/<file> ...)" }),
51
- fixes_earlier: Type.Optional(Type.Boolean({ description: "This corrects something already written - a contradiction, a review finding" })),
52
- stack: STACK_PARAM,
53
- guidance: Type.Optional(Type.String({
54
- description: "How to plan the queue for this change, in a sentence or two - which functional specs go together, what first - as the " +
55
- "user said it or as the interview settled it. A strong preference for the planner. Omit when there is none.",
56
- })),
57
- }),
58
- async execute(_id, params) {
59
- const paced = isPaced();
60
- if (paced && params.fixes_earlier !== true && !answeredSinceLastDiff) {
61
- throw new Error("No question has been answered since the last spec change. Each change comes from its own answer: ask " +
62
- "the user with ask_user first. To correct something already written, set fixes_earlier.");
63
- }
64
- const touched = plainFilesOf(params.diff);
65
- if (touched.length === 0)
66
- throw new Error("The diff changes no .plain file. Nothing was written.");
67
- refuseTestPlainFile(resolve(cwd, params.plain_file));
68
- const result = applySpecDiff(params.diff, cwd);
69
- // A change that breaks a spec is not written at all, so nothing is ever built from a file that cannot be parsed:
70
- // each module it touched is parsed with its test plain files - an import module as the modules that import it
71
- // read it, a test plain file as its module - as parse reads them. A module with no functional specs yet is
72
- // not broken.
73
- const failed = checkTouchedPlain([params.plain_file, ...touched].map((file) => resolve(cwd, file))).filter((check) => !check.ok);
74
- if (failed.length > 0) {
75
- if (result === "applied")
76
- revertSpecDiff(params.diff, cwd);
77
- throw new Error(`Nothing was written: with this change the ***plain no longer checks.\n${formatCheckResults(failed)}`);
78
- }
79
- if (params.fixes_earlier !== true)
80
- answeredSinceLastDiff = false;
81
- owed = false;
82
- liveReview?.notice(`${params.plain_file}, after the change to ${touched.join(", ")}`);
83
- // In the files, the change is work: the loop works out what is left to build and plans it - with the stack the call
84
- // names, else the module's own. A spec change, not a request: a module the person halted stays halted. The change
85
- // is written whatever the stack: one that cannot be built yet is said, and built once it can - nothing is lost.
86
- const building = resolve(cwd, params.plain_file);
87
- let stackless;
88
- try {
89
- stackless = params.stack === undefined ? stacklessBuild(building) : (stackNamed(projectDirOf(building), params.stack), undefined);
90
- }
91
- catch (error) {
92
- stackless = error instanceof Error ? error.message : String(error);
93
- }
94
- const statuses = stackless === undefined
95
- ? await withCallStack(building, params.stack, () => loop.bringUp(params.plain_file, { specChange: true, ...(params.guidance !== undefined ? { guidance: params.guidance } : {}) }))
96
- : [];
97
- const lines = [
98
- result === "applied" ? `Applied the change to ${touched.join(", ")}.` : `The change to ${touched.join(", ")} was already applied.`,
99
- stackless === undefined
100
- ? `Building in the background:\n${describeModules(statuses)}\n`
101
- : `Not built yet - ${stackless} The change is in the spec: pass stack with the next change, or call regenerate with it, and everything written so far is built.\n`,
102
- // An interview goes back to its questions; a skill that writes on its own, straight to its next change - a stop to ask ends it.
103
- paced
104
- ? "Carry on with the interview."
105
- : skillPaced
106
- ? "Carry on: write the next change you decided yourself, or ask the next question - every answer is written as a change before the question after it."
107
- : "Write the next change now, without stopping to ask: this skill goes on until everything it is to write is written.",
108
- ];
109
- // The functional specs the test advisor took up, for the agent to say so rather than offer their scenarios.
110
- const advising = advisingNote(loop, building);
111
- return {
112
- content: [{ type: "text", text: lines.join(" ") + reviewNote(liveReview) + (advising !== "" ? `\n\n${advising}` : "") }],
113
- details: { jobIds: statuses.flatMap((status) => (status.running !== undefined ? [status.running.jobId] : [])), files: touched },
114
- };
115
- },
116
- });
117
- return {
118
- tools: [writeDiff],
119
- pace: {
120
- answered(owesChange = true) {
121
- answeredSinceLastDiff = true;
122
- if (owesChange)
123
- owed = true;
124
- },
125
- owed: () => owed,
126
- },
127
- };
128
- }
package/dist/stacks.d.ts DELETED
@@ -1,13 +0,0 @@
1
- /**
2
- * Choosing a stack: `config.turri.<stack>.yaml` laid over `config.turri.yaml` for everything built from then on - a
3
- * backend's testing scripts, then a frontend's. `/stack` and the `stack` tool in the chat, `--stack <name>` on the
4
- * command line (cli.ts). The choice itself is kept in config.ts (`chooseStack`): in the chat it is made in, for that chat
5
- * alone (chat-scope.ts), each new chat starting from `--stack`.
6
- */
7
- import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
8
- /** The stacks of the projects here: the folder's own, and those of the projects one folder down (specs kept in plain/). */
9
- export declare function knownStacks(root: string): string[];
10
- /** Choose `name` - or none - among the stacks here, and say what is chosen now; a stack the project has no file for is refused. */
11
- export declare function switchStack(root: string, name: string | undefined): string;
12
- /** /stack and the chat's stack tool. */
13
- export declare function registerStacks(pi: ExtensionAPI, cwd: string): void;
package/dist/stacks.js DELETED
@@ -1,96 +0,0 @@
1
- /**
2
- * Choosing a stack: `config.turri.<stack>.yaml` laid over `config.turri.yaml` for everything built from then on - a
3
- * backend's testing scripts, then a frontend's. `/stack` and the `stack` tool in the chat, `--stack <name>` on the
4
- * command line (cli.ts). The choice itself is kept in config.ts (`chooseStack`): in the chat it is made in, for that chat
5
- * alone (chat-scope.ts), each new chat starting from `--stack`.
6
- */
7
- import { readdirSync } from "node:fs";
8
- import { join } from "node:path";
9
- import { defineTool } from "@earendil-works/pi-coding-agent";
10
- import { Type } from "typebox";
11
- import { chooseStack, chosenStack, hasProjectConfig, NO_STACK, stackConfigFile, stacksOf } from "./config.js";
12
- /** The stacks of the projects here: the folder's own, and those of the projects one folder down (specs kept in plain/). */
13
- export function knownStacks(root) {
14
- const below = (() => {
15
- try {
16
- return readdirSync(root, { withFileTypes: true })
17
- .filter((entry) => entry.isDirectory() && !entry.name.startsWith(".") && entry.name !== "node_modules" && entry.name !== "plain_modules")
18
- .map((entry) => join(root, entry.name))
19
- .filter(hasProjectConfig);
20
- }
21
- catch {
22
- return [];
23
- }
24
- })();
25
- return [...new Set([root, ...below].flatMap(stacksOf))].sort();
26
- }
27
- /** Choose `name` - or none - among the stacks here, and say what is chosen now; a stack the project has no file for is refused. */
28
- export function switchStack(root, name) {
29
- const stacks = knownStacks(root);
30
- const wanted = name?.trim() ?? "";
31
- if (wanted === "" || NO_STACK.includes(wanted.toLowerCase())) {
32
- chooseStack(undefined);
33
- return "No stack chosen: everything is built with the project's config.turri.yaml alone, from now on.";
34
- }
35
- if (!stacks.includes(wanted)) {
36
- throw new Error(stacks.length > 0
37
- ? `There is no stack ${wanted} here. The stacks: ${stacks.join(", ")} - or none.`
38
- : `This project has no stacks: a stack is a ${stackConfigFile("<stack>")} beside config.turri.yaml.`);
39
- }
40
- chooseStack(wanted);
41
- return `Stack ${wanted} chosen: everything is built with ${stackConfigFile(wanted)} over config.turri.yaml from now on - a pulse already running keeps the stack it started with.`;
42
- }
43
- /** /stack and the chat's stack tool. */
44
- export function registerStacks(pi, cwd) {
45
- pi.registerCommand("stack", {
46
- description: "Choose the stack everything is built with - its config.turri.<stack>.yaml over config.turri.yaml: /stack [name | none]",
47
- getArgumentCompletions: (prefix) => {
48
- const items = [...knownStacks(cwd), "none"].filter((stack) => stack.startsWith(prefix)).map((stack) => ({ value: stack, label: stack }));
49
- return items.length > 0 ? items : null;
50
- },
51
- handler: async (args, ctx) => {
52
- let name = args.trim();
53
- if (name === "") {
54
- const stacks = knownStacks(cwd);
55
- if (stacks.length === 0)
56
- return ctx.ui.notify(`This project has no stacks: a stack is a ${stackConfigFile("<stack>")} beside config.turri.yaml.`, "info");
57
- const now = chosenStack();
58
- const label = (stack) => `${stack}${stack === now ? " (chosen now)" : ""}`;
59
- const none = `none - config.turri.yaml alone${now === undefined ? " (chosen now)" : ""}`;
60
- const picked = await ctx.ui.select("Build with which stack?", [...stacks.map(label), none]);
61
- if (picked === undefined)
62
- return;
63
- name = picked === none ? "none" : (stacks.find((stack) => label(stack) === picked) ?? "");
64
- }
65
- try {
66
- ctx.ui.notify(switchStack(cwd, name), "info");
67
- }
68
- catch (error) {
69
- ctx.ui.notify(error instanceof Error ? error.message : String(error), "error");
70
- }
71
- },
72
- });
73
- pi.registerTool(defineTool({
74
- name: "stack",
75
- label: "Stack",
76
- description: "Choose the stack everything is built with from now on - the project's config.turri.yaml with the stack's " +
77
- "config.turri.<stack>.yaml over it: its testing scripts, toolchains, models - or none, the project's file alone. " +
78
- "For this chat alone - each chat chooses its own; a pulse already running keeps the stack it started with. Without a name, says the stacks and the one chosen.",
79
- promptSnippet: "choose the stack - its testing scripts and settings - that everything is built with",
80
- promptGuidelines: [
81
- "Switch the stack only when the user asks for it, and say which you chose. A module is built with the stack named after it by itself; to build one whose stack has another name, pass that stack as stack to regenerate, conform, glimpse or change_plain instead: it is pinned to that module's pulses, and this chat's choice stays as it is.",
82
- ],
83
- parameters: Type.Object({
84
- name: Type.Optional(Type.String({ description: "The stack to choose, or none. Omitted: the stacks there are, and the one chosen" })),
85
- }),
86
- async execute(_id, params, _signal, _onUpdate, ctx) {
87
- if (params.name === undefined) {
88
- const stacks = knownStacks(cwd);
89
- const text = stacks.length > 0 ? `The stacks: ${stacks.join(", ")}. Chosen now: ${chosenStack() ?? "none"}.` : "This project has no stacks.";
90
- return { content: [{ type: "text", text }], details: {} };
91
- }
92
- const text = switchStack(cwd, params.name);
93
- return { content: [{ type: "text", text }], details: {} };
94
- },
95
- }));
96
- }
package/docs/deploy.md DELETED
@@ -1,48 +0,0 @@
1
- # Trying what is built: deploy
2
-
3
- Ask to try it - "let me try it", "run the app" - at any time, even while a regeneration is running. The chat calls `deploy`: it puts the module's code, as it was last built, in `dist/<module>` in the project, and starts it on your machine. An app with a backend and a frontend is started whole, and you are told where to open your browser. For a command-line tool or a library you get a few commands to paste, run from `dist/<module>`, and what they print.
4
-
5
- ## When the project says how it is released
6
-
7
- Every release starts the same way: the module's last commit - what last landed whole - goes in `dist/<module>`, as below. Not everything is tried from there, though. An integration that a host application loads goes on into the host's own tree, with the host's own scripts, and then the host is started. So the model asks itself whether there is guidance for how this project is released - in what you said, the project's AGENTS.md, a skill, anything it was given - and passes it to `release` whole:
8
-
9
- - **There is guidance.** The code goes on from `dist/<module>` as the guidance says, on your machine, from the host codebase - the git repository the project is in, or else where **turri** runs: the scripts it names, in their order, and any change it says the host needs. The code is taken from `dist`, never from `plain_modules`, where a pulse may be writing; where the host's tooling reads `plain_modules` itself, the model points it at `dist`, or does by hand from `dist` what it does. Whether to release after every pulse is `release-after-pulse`'s to say - see [after every pulse](#after-every-pulse). The rules below hold as they do for `dist`: the model runs the project's scripts and installs what they need itself, and what keeps running - a start script, a server - is started with `activate`. Nothing built is changed, and nor is the \*\*\*plain: its file tools refuse a `.plain` file - a module or a test plain file - as they refuse `plain_modules`.
10
- - **There is none.** The default: it is started from `dist/<module>`, as below, as best it can be.
11
-
12
- Guidance is whatever says it, in any words - a line in AGENTS.md such as *integrations are released with `scripts/deploy_integrations.sh`, then the app is started with `scripts/start.sh`*, or the same said in the chat.
13
-
14
- With `sentinel: false`, the chat reacts to every pulse that finishes as it finishes, without waiting for you to speak: guidance that says to release after a build - *release each integration once it is regenerated* - is followed then. With the [sentinel](sentinel.md) on - the default - the chat is told only that a pulse landed, and does nothing about it: guidance to follow once a pulse finishes is not followed, and releasing after every pulse is `release-after-pulse`'s. It never has to work out whether what a pulse landed is already out: `release` does. When the module's last commit is what its last release in this conversation shipped, it does nothing - nothing exported, nothing stopped, what runs left running - and says so; `again: true` releases it anyway, for when what that release said to do was not done.
15
-
16
- ## What goes in dist
17
-
18
- - **The module on top.** Code accumulates up a `requires` chain: a module starts from a copy of the code of the one it requires. So deploy always takes the module on top of the `requires` chain - the project's `module` from `config.turri.yaml` unless another module's \*\*\*plain is named. Before the module on top has anything built, it takes the nearest one below it that has, and says so.
19
- - **Its last commit.** Each `plain_modules/<module>` is a git repository (`.plaingit`), and every unit of work starts from a commit and ends with one. What a pulse is writing right now is half-done, so it is left out: deploy exports the commit - `git archive` of `code/` - which is the working tree with every unstaged and untracked change put back, and no `node_modules`, `.venv`, `target` or other build leftovers, whatever the stack. The working tree the pulse is using is never read or touched. The harness's own files - `.turri.json`, the agents' notes - are left out too.
20
- - **Replaced whole.** Each deploy stops what the last one of the module started, empties `dist/<module>` and exports again. Change nothing there you want to keep. `dist/` is not added to `.gitignore`: whether it is committed is yours to decide.
21
-
22
- ## Starting it
23
-
24
- It runs on your machine, outside the [sandbox](sandbox.md) - with your toolchains, where your browser can reach it. The chat reads how the code runs (its README, manifests and entry points), then:
25
-
26
- 1. **Checks the toolchains** it needs (`node`, `python3`, `go`, ...) - under another name too: `python` where `python3` is not, of the version it needs. One is missing: it stops, and tells you the exact command to install it yourself (`brew install node`). turri installs nothing on your machine and changes none of its settings - not the release, not the chat, not any agent: its shell refuses it.
27
- 2. **Installs what it needs into the project.** Dependencies into a virtual environment or `node_modules`, a build that downloads packages, an image pull, a guided release's project scripts: it runs them in its own shell, as any agent with a shell would, and fixes what fails. Nothing is put to you - there is no dialog to answer. Never a global install, never a system setting.
28
- 3. **Starts what serves** with `activate`: in the background, in its own process group, its output in `.turri/deploy/<module>-<name>.log`. It waits until something answers at the server's URL - up to a minute - so the URL you are given has answered once; one that exits first comes back with the end of its output. A port something else holds is said, with what holds it, and nothing is started there: the app is not moved to a port you were not told about. It runs in the deployed folder, or a folder inside it the model names relative to it (`frontend`); a folder that is not there starts nothing, and the model is told so with what the deployed folder holds, to name the right one.
29
-
30
- What it started is listed by the `pulses` tool and by **`/halt`**, and stopped by **`/halt activated <name>`**, by `halt`, by the next deploy of the module, and when the chat exits.
31
-
32
- ## After every pulse
33
-
34
- With `release-after-pulse: true` in `config.turri.yaml`, turri releases what each pulse lands itself, as the pulse's last stage (`releasing what this pulse landed`): the pulse ends once it is released, so the module's next pulse starts on what is out, and the chat - waiting on your answer to a question, say - has no part in it. One release a pulse that lands, in order.
35
-
36
- The release is done by an agent on the coding model, thinking low - it follows steps, and a small model does that well - the same one `turri release` runs, and it finds the guidance as the chat would: what was passed to `release` earlier in the conversation, the project's AGENTS.md and its skills. The setting is the word to release; the guidance says only how - without any, the code goes to `dist/<module>` and is started from there. Its last words go in the pulse's report - "Released after the pulse: ..." - and the [sentinel](sentinel.md) is told what was released and where it runs, and tests it: what needs you comes as a notice in the chat you are in, and the chat you are in says only that it landed and is being tested. With `sentinel: false`, the chat, seeing the report, does not release it again: it says in a line what was released, then does what it was told to do once something is released - a host such as a desktop app tells it, in its `surface`, to open it where the person can watch and say what to test. A release that fails is said there too; what the pulse landed stays.
37
-
38
- Off without the key: releasing after a pulse is then the chat's, when its guidance says so. `turri init-config` writes `release-after-pulse: true`.
39
-
40
- ## On the command line
41
-
42
- ```bash
43
- turri release [file.plain] [--in-module <module>] [--guidance <text>] [--model <provider/id>]
44
- ```
45
-
46
- The same, without the chat: a one-off agent on `coding-model`, thinking low (or `--model`; without either, [pi](https://pi.dev)'s default) is given the project's AGENTS.md and what `--guidance <text>` says, looks for guidance in them, and releases as above - as the guidance says, or to `dist/<module>` - then works out how to start it and starts it here, installing what it needs without asking. It stays in the foreground with the servers' output; `Ctrl-C` stops them. If it does not get there, deploy from the chat instead.
47
-
48
- `turri regenerate`, `change-plain` and `conform` end a build that landed with `To try it: turri release <spec>`.
@@ -1,110 +0,0 @@
1
- # The test advisor
2
-
3
- Which functional specs need explicit testing scenarios is not obvious, and not every one should be tested - only the functionality that matters. The test advisor decides for you: when a functional spec is new or its text changed and it has no scenarios - or when the chat asks - turri checks in the background whether it needs testing. When it does, the chat you are looking at tells you so and writes what testing it takes - the \*\*\*test reqs\*\*\*, the conformance testing script and its scenarios - so the module's conformance pulse runs once its code is built. The advisor decides; the chat is the only writer of the \*\*\*plain. You are never asked anything.
4
-
5
- ## When it runs
6
-
7
- **Only with conformance tests on.** The advisor is there to say which functional specs need scenarios, and scenarios are only tested with `conformance-tests: true` ([config](config.md#conformance-tests)): off - as it is unset - the advisor is off too, by itself and when asked: the chat has no `evaluate_tests`, and a host's `evaluateTests` throws, saying how they are turned on.
8
-
9
- **Two ways in.** By itself, for every new or changed functional spec without scenarios, as below - what `test-advisor: false` turns off. And when the chat asks, with `evaluate_tests`, whatever the setting - see [asking for an evaluation](#asking-for-an-evaluation).
10
-
11
- **Only in the chat and a host.** Never in a headless command - `turri regenerate`, `conform`, `change-plain` and the rest - and never in [pi](https://pi.dev)'s print, json and rpc modes (`turri -p`), which end when the answer is printed. That is decided where the session starts: the terminal's chat and a host's session have one, nothing else does.
12
-
13
- **What it looks at by itself:** a functional spec, in any module, that is new or whose text changed since its code was built - measured against the code record, what the code was built from: text that differs from the record, or a functional spec not built yet. Then against the advisor's file: a text already looked at, under its hash, is not looked at again. So a fresh project's first functional specs are looked at, and a project already built that has no advisor file gets no backlog: only what changes from now on is.
14
-
15
- **What it leaves alone:**
16
- - a functional spec with scenarios of any kind - [today's review](regenerating.md#conformance-tests) of its scenarios covers it when its text changes
17
- - the standard library's templates, which have no functional specs
18
-
19
- **When:** by itself, as soon as the work loop sees a \*\*\*plain change - a `change_plain`, a `regenerate`, a pulse ending - beside the code pulse it plans. The functional spec is marked `pending` in the advisor's file there and then, so quitting loses nothing: the next start in the chat or a host picks up every `pending` entry.
20
-
21
- **Two at a time at most,** outside `parallel-jobs` and the lanes: it never takes a pulse's slot, no pulse waits for it, and it never steers or stops one.
22
-
23
- **A text that changes while it runs throws the work away,** whoever changed it - you, the chat's `change_plain`, a skill: what it had judged for the old text is dropped (`advisor.dropped`), and the new text starts again.
24
-
25
- A failure - a model error, a call that never answered - is dropped quietly: the entry says `failed` and why, `advisor.failed` goes into the ledger, and the same text is not tried again. Nothing is shown.
26
-
27
- ## What you see
28
-
29
- **Being evaluated.** A change's result - `regenerate`'s, `change_plain`'s - names the functional specs the advisor has just taken up, as `evaluate_tests` names the ones it was asked for, and the chat says in a line that testing scenarios are being evaluated for them, and goes on: there is nothing to wait for.
30
-
31
- **A yes** comes back to the chat you are looking at as a message that starts a turn. It holds the report - the questions that were a yes with their evidence, and the inputs to cover - and the chat, asking you nothing, tells you in a line:
32
-
33
- > core:clear-tasks needs testing scenarios - a wrong implementation could look right. Writing them now.
34
-
35
- Then it writes, with `change_plain`, whatever the [step-7 guard](regenerating.md#the-steps-of-adding-tests) would refuse the scenarios for, in turn and only what is missing: the \*\*\*test reqs\*\*\* of the module it is tested in - the top of its chain, where its conformance tests live - the stack's conformance template, `stdlib/<kind>/conformance/<stack>`, imported, or the module's own; the conformance testing script for its stack, with `implement-conformance-testing-script` - in the background, the chat going straight on; then the scenarios, in `tests/<module>/<func-id>.plain`. They cover the report's inputs that are this functional spec's - an agreed one with the readers' output, never a placeholder - and a split one is settled by the reading most consistent with the functional spec and its module, the chat saying which it took. The change is visible as any is, and the conformance pulse follows once the code is built.
36
-
37
- **A no** is one line turri draws itself, starting no turn and reaching no model:
38
-
39
- > core:list-tasks doesn't need testing scenarios - nothing silent to get wrong.
40
-
41
- **Never an interruption.** A verdict that arrives while the chat is busy - its agent working, or you typing - waits until it is idle; verdicts that arrive meanwhile come together, as one turn for every yes and a line for each no. One whose functional spec changed meanwhile, or was given scenarios, is let go. A yes is kept in the advisor's file until a chat has it: one that arrives with no chat open, or whose session ends first, is delivered at the next start, as `pending` work is picked up.
42
-
43
- Asked for scenarios - "write conformance scenarios for core:add-task" - the chat decides and writes them itself, as a \*\*\*plain change you see, whatever `test-advisor` says.
44
-
45
- A host gets the verdicts in its chats the same way - see [hosting](hosting.md).
46
-
47
- ## Asking for an evaluation
48
-
49
- The chat has a tool of its own, `evaluate_tests`: the functional specs as `module:func-id`s - or func-ids, with `plain_file` - and an optional `reason`. It returns at once - "Testing scenarios for core:add-task are being evaluated in the background; the verdict comes back to this chat." - and the verdict comes back as any verdict does. The chat calls it:
50
-
51
- - when you ask whether something needs tests - "does add-task need tests?";
52
- - on its own, as another way of saying what a functional spec means: when pulses keep failing on a complicated one, say, scenarios may pin down what it should do.
53
-
54
- It evaluates even a text the advisor already judged. A functional spec being evaluated already is not started twice, and one that has scenarios is answered at once as such and not evaluated. It works whatever `test-advisor` says. The `reason` - "the coding agent failed three times to implement it" - reaches the classifier as context, never as evidence.
55
-
56
- ## How it decides
57
-
58
- Every step is a plain model call on the advisor's model, answered through one tool and checked by turri - none of them is a skill, and none can touch the project. Each is given the functional spec, its module whole - and for a module below, the tip its scenarios are tested in, whose own functional specs show in the same commands - and the project's own words on what matters: its `AGENTS.md`, and what you said in the conversation about how the work is to be planned. There is no keyword filter and no confidence score.
59
-
60
- **Classifying** is one call with four questions, each yes backed by evidence:
61
-
62
- | question | a yes needs |
63
- | --- | --- |
64
- | silent failure: could a wrong implementation give output that looks right? | one such wrong output |
65
- | divergence: is there an input two reasonable readings answer differently? | the input, and both outputs |
66
- | revisited: is it likely to be changed or built on later? | what would change |
67
- | cost: would a bug cost money, expose something, lose data or harm users' trust? | the consequence |
68
-
69
- A yes whose evidence is empty or malformed - two readings that are the same - counts as no. The verdict is **yes** when silent failure, divergence or cost is a yes; revisited alone, or all four no, is **no**: the coding agent's unit tests are the regression protection there. A no costs one call, and ends there.
70
-
71
- **On a yes, the inputs** the scenarios are to cover are picked by readers that disagree on purpose:
72
-
73
- 1. **Probes:** one call writes concrete boundary inputs, as many as the functional spec has real boundaries - one to ten, never padded to a number - limits, empty and missing values, the cases the wording leaves open - and the divergence's input joins them. Only inputs the functional spec bears on: never a command, flag or alias it does not name.
74
- 2. **Readers:** each predicts every probe's output. There are three - a literal reader, an edge-case hunter, and a reader from another domain - the same call on the same model, differing only by their system prompt. Two run first; when they already disagree on a probe, the third is spared. A reader answers `unspecified` for an input the functional spec says nothing about.
75
- 3. **Comparing,** in code: the outputs are compared with whitespace and case left aside, and any disagreement makes the input a candidate - the union of the readers, never a majority.
76
- 4. **Verifying:** one last call keeps, of each candidate, the readings a reasonable person could hold. A candidate left with one is an agreed input; one left with none is dropped. An input whose `unspecified` holds - every reader's, or one the verifier keeps - is left out: a scenario on it would pin a guess, testing more than the functional spec says.
77
-
78
- The **report** is what the advisor's file keeps: the questions that were a yes with their evidence, and each input, either agreed - with the readers' output - or split, with its readings.
79
-
80
- ## The setting and its model
81
-
82
- `test-advisor: true | false` in `config.turri.yaml`, `true` when it is left out - `/turri-config` sets it. `false` turns off only the advisor's own start: `evaluate_tests` still works, and asked for scenarios, the chat writes them as it always has, whatever the setting says.
83
-
84
- Every call the advisor makes runs on `models.advisor` - see [models per role](config.md#models-per-role). Without one it runs on `default`'s model, else the coding model alone, thinking low.
85
-
86
- ## What it keeps
87
-
88
- What the advisor made of each functional spec is in `.turri/advisor/<module>.json`, in the project - local to this machine, as all of `.turri/` is: another machine starts with none, and looks only at what changes there. One entry a functional spec, by its func-id:
89
-
90
- | | |
91
- | --- | --- |
92
- | `hash` | a hash of the functional spec's text: the entry is about that text, and stale once it changes |
93
- | `state` | `pending` - seen, not finished; `yes`; `no`; or `failed` |
94
- | `report` | the verdict, the questions that were a yes with their evidence, and on a yes the inputs to cover |
95
- | `model`, `at` | what it ran on, and when |
96
- | `tip` | the module at the top of its chain, where its scenarios are tested |
97
- | `undelivered` | a yes no chat has had yet: delivered at the next start |
98
- | `asked` | pending at the chat's asking, with its reason: picked up at the next start whatever `test-advisor` says |
99
-
100
- Deleting the folder loses only what the advisor knows: an entry that is not there is a functional spec it has not looked at.
101
-
102
- ## In the ledger
103
-
104
- Three facts go into [the ledger](using.md#the-ledger), the report staying in the advisor's file:
105
-
106
- | event | |
107
- | --- | --- |
108
- | `advisor.classified` | the functional spec, `module:func-id`, its verdict, the questions that were a yes, and whether the chat asked for it (`asked: true`) or a change started it |
109
- | `advisor.dropped` | the work on a functional spec thrown away, its text changed while it ran |
110
- | `advisor.failed` | why it failed |
File without changes