@turri-dev/cli 0.2.4-next.bc1fc47 → 0.2.4-next.efe96fe
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 +3 -4
- package/dist/bedrock-region.js +3 -3
- package/dist/chat-models.d.ts +1 -1
- package/dist/chat-models.js +1 -1
- package/dist/chat-scope.d.ts +1 -3
- package/dist/chats.d.ts +2 -2
- package/dist/chats.js +3 -3
- package/dist/cli.js +6 -23
- package/dist/config-edit.d.ts +20 -8
- package/dist/config-edit.js +29 -21
- package/dist/config.d.ts +43 -50
- package/dist/config.js +122 -104
- package/dist/conform-cli.js +1 -1
- package/dist/conformance-switch.d.ts +7 -6
- package/dist/conformance-switch.js +16 -16
- package/dist/extension.d.ts +1 -1
- package/dist/extension.js +82 -200
- package/dist/host-session.d.ts +2 -2
- package/dist/host-session.js +2 -2
- package/dist/host.d.ts +1 -1
- package/dist/host.js +3 -3
- package/dist/init-config.js +1 -1
- package/dist/loop-tools.d.ts +9 -13
- package/dist/loop-tools.js +32 -37
- package/dist/parse-cli.js +2 -2
- package/dist/pi-launch.js +3 -0
- package/dist/pi-settings.d.ts +4 -0
- package/dist/pi-settings.js +39 -0
- package/dist/pi.js +3 -3
- package/dist/plain/check.d.ts +1 -1
- package/dist/plain/check.js +3 -1
- package/dist/plain-files.js +4 -4
- package/dist/regenerate/agent-env.d.ts +1 -1
- package/dist/regenerate/agent-env.js +3 -3
- package/dist/regenerate/agent-shell.js +2 -2
- package/dist/regenerate/base-folder.d.ts +2 -2
- package/dist/regenerate/base-folder.js +1 -1
- package/dist/regenerate/jobs.d.ts +2 -2
- package/dist/regenerate/jobs.js +10 -10
- package/dist/regenerate/ledger.d.ts +1 -1
- package/dist/regenerate/loop.d.ts +3 -3
- package/dist/regenerate/loop.js +27 -23
- package/dist/regenerate/model-names.d.ts +33 -0
- package/dist/regenerate/{engine.js → model-names.js} +2 -28
- package/dist/regenerate/paths.d.ts +1 -1
- package/dist/regenerate/paths.js +2 -2
- package/dist/regenerate/scripts-being-written.d.ts +4 -4
- package/dist/regenerate/scripts-being-written.js +3 -3
- package/dist/regenerate/test-scripts.d.ts +2 -1
- package/dist/regenerate/test-scripts.js +33 -23
- package/dist/regenerate/testing-steps.d.ts +6 -6
- package/dist/regenerate/testing-steps.js +8 -8
- package/dist/{config-command.d.ts → settings.d.ts} +13 -8
- package/dist/{config-command.js → settings.js} +155 -24
- package/dist/setup.d.ts +2 -2
- package/dist/setup.js +7 -7
- package/docs/README.md +2 -2
- package/docs/chats.md +3 -4
- package/docs/claude-subscription.md +2 -2
- package/docs/config.md +50 -38
- package/docs/development.md +1 -1
- package/docs/headless.md +1 -2
- package/docs/hosting.md +6 -6
- package/docs/parser.md +1 -1
- package/docs/regenerating.md +9 -9
- package/docs/sentinel.md +2 -2
- package/docs/skills-and-gates.md +1 -2
- package/docs/using.md +8 -17
- package/genome/rules/project-model.md +2 -1
- package/genome/rules/turri-regeneration.md +2 -1
- package/genome/skills/implement-conformance-testing-script/SKILL.md +2 -2
- package/genome/skills/implement-unit-testing-script/SKILL.md +3 -3
- package/package.json +1 -1
- package/dist/regenerate/engine.d.ts +0 -52
- package/dist/stacks.d.ts +0 -13
- package/dist/stacks.js +0 -96
package/dist/config.js
CHANGED
|
@@ -2,8 +2,7 @@ import { AsyncLocalStorage } from "node:async_hooks";
|
|
|
2
2
|
import { copyFileSync, existsSync, readdirSync, readFileSync, statSync } from "node:fs";
|
|
3
3
|
import { basename, join, resolve } from "node:path";
|
|
4
4
|
import { load as loadYaml } from "js-yaml";
|
|
5
|
-
import {
|
|
6
|
-
import { projectDirOf } from "./regenerate/paths.js";
|
|
5
|
+
import { projectDirOf, resolveTemplateDirs } from "./regenerate/paths.js";
|
|
7
6
|
/**
|
|
8
7
|
* The project's `config.turri.yaml`, at its root - the folder that holds `plain_modules` - or, before it had one, its `config.yaml`.
|
|
9
8
|
*
|
|
@@ -49,36 +48,35 @@ import { projectDirOf } from "./regenerate/paths.js";
|
|
|
49
48
|
* either of which may be left out; a bare string is the model alone. What a model leaves out it takes
|
|
50
49
|
* from the one it inherits: judge-model from coding-model, coding-model from harness-model. They are
|
|
51
50
|
* defaults: `--harness-model` / `--coding-model` / `--judge-model` on the command line win over them,
|
|
52
|
-
* and so does a model chosen during the conversation (pi's /model
|
|
51
|
+
* and so does a model chosen during the conversation (pi's /model) or named on a call. `model:` is read
|
|
53
52
|
* as `coding-model`, which it was before there were two.
|
|
54
53
|
*
|
|
55
54
|
* Keys are written with dashes; underscores are read the same (`conformance_tests`). Keys it
|
|
56
55
|
* does not know - another tool's `config.yaml`, read while it is the old file, may carry several - are ignored, and so is a value of
|
|
57
56
|
* the wrong type. Everything is optional, and what is given on the command line wins.
|
|
58
57
|
*
|
|
59
|
-
* A
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
* from the
|
|
65
|
-
*
|
|
66
|
-
* stack's file.
|
|
58
|
+
* A module can have settings of its own in `config.turri.<module>.yaml` beside `config.turri.yaml`:
|
|
59
|
+
* `config.turri.backend.yaml` for `backend.plain` - its testing scripts, its toolchains, its models - laid over
|
|
60
|
+
* `config.turri.yaml` key by key, a model it names taking what it leaves out from the project's. A module with no file
|
|
61
|
+
* of its own takes the one of a module it requires - `config.turri.backend.yaml` builds `backend_auth.plain`, which
|
|
62
|
+
* requires `backend.plain` - and two among the modules it requires is an error (`configModuleFor`). Nobody chooses it:
|
|
63
|
+
* it is worked out from the module, and a pulse keeps the one it started with. `module:`, `harness-model:` and the
|
|
64
|
+
* other settings of the whole project are read from `config.turri.yaml` alone.
|
|
67
65
|
*/
|
|
68
66
|
/** turri's settings for a project, in a file of its own: a `config.yaml` beside it may be another tool's. */
|
|
69
67
|
export const CONFIG_FILE = "config.turri.yaml";
|
|
70
68
|
/**
|
|
71
69
|
* Where turri's settings were before they had a file of their own. A project with no `config.turri*.yaml` yet is read
|
|
72
|
-
* from it - and a `config.<name>.yaml` beside it as the
|
|
70
|
+
* from it - and a `config.<name>.yaml` beside it as the module `<name>`'s - and turri never writes it: the first setting
|
|
73
71
|
* turri writes copies them to the new names (`adoptLegacyConfig`), and from then on the old files are not read.
|
|
74
72
|
*/
|
|
75
73
|
export const LEGACY_CONFIG_FILE = "config.yaml";
|
|
76
|
-
/** A
|
|
77
|
-
export function
|
|
78
|
-
return `config.turri.${
|
|
74
|
+
/** A module's config file's name: `config.turri.backend.yaml` for `backend.plain`. */
|
|
75
|
+
export function moduleConfigFile(module) {
|
|
76
|
+
return `config.turri.${module}.yaml`;
|
|
79
77
|
}
|
|
80
|
-
function
|
|
81
|
-
return `config.${
|
|
78
|
+
function legacyModuleConfigFile(module) {
|
|
79
|
+
return `config.${module}.yaml`;
|
|
82
80
|
}
|
|
83
81
|
/**
|
|
84
82
|
* The names in a folder - read again only once the folder itself has changed: a name added, removed or renamed in it
|
|
@@ -104,36 +102,36 @@ function namesIn(root) {
|
|
|
104
102
|
}
|
|
105
103
|
}
|
|
106
104
|
const keptNames = new Map();
|
|
107
|
-
/** The
|
|
108
|
-
function
|
|
105
|
+
/** The modules with a file of their own in the old naming, `config.<module>.yaml`. */
|
|
106
|
+
function legacyModuleConfigs(root) {
|
|
109
107
|
return namesIn(root)
|
|
110
108
|
.map((name) => /^config\.(?!turri(?:\.|$))(.+)\.yaml$/.exec(name)?.[1])
|
|
111
109
|
.filter((name) => name !== undefined)
|
|
112
110
|
.sort();
|
|
113
111
|
}
|
|
114
|
-
/** Whether a folder's settings are still in the old files: a config.yaml or a config.<
|
|
112
|
+
/** Whether a folder's settings are still in the old files: a config.yaml or a config.<module>.yaml, and no config.turri*.yaml. */
|
|
115
113
|
export function usesLegacyConfig(root) {
|
|
116
114
|
const names = namesIn(root);
|
|
117
115
|
if (names.some((name) => /^config\.turri(?:\..+)?\.yaml$/.test(name)))
|
|
118
116
|
return false;
|
|
119
|
-
return names.includes(LEGACY_CONFIG_FILE) ||
|
|
117
|
+
return names.includes(LEGACY_CONFIG_FILE) || legacyModuleConfigs(root).length > 0;
|
|
120
118
|
}
|
|
121
119
|
/** The file the project's settings are read from, by name: config.turri.yaml, or config.yaml while the folder has only the old files. */
|
|
122
120
|
export function projectConfigFile(root) {
|
|
123
121
|
return usesLegacyConfig(root) ? LEGACY_CONFIG_FILE : CONFIG_FILE;
|
|
124
122
|
}
|
|
125
|
-
/** The file a
|
|
126
|
-
export function
|
|
127
|
-
return usesLegacyConfig(root) ?
|
|
123
|
+
/** The file a module's own settings are read from, by name - the old name while the folder has only the old files. */
|
|
124
|
+
export function moduleConfigFileIn(root, module) {
|
|
125
|
+
return usesLegacyConfig(root) ? legacyModuleConfigFile(module) : moduleConfigFile(module);
|
|
128
126
|
}
|
|
129
|
-
/** Whether a folder holds a project's settings: a config.turri.yaml, a
|
|
127
|
+
/** Whether a folder holds a project's settings: a config.turri.yaml, a module's file, or the old files. */
|
|
130
128
|
export function hasProjectConfig(root) {
|
|
131
|
-
return existsSync(join(root, CONFIG_FILE)) ||
|
|
129
|
+
return existsSync(join(root, CONFIG_FILE)) || moduleConfigsOf(root).length > 0 || usesLegacyConfig(root);
|
|
132
130
|
}
|
|
133
|
-
/** The
|
|
134
|
-
export function
|
|
131
|
+
/** The modules a project folder has config files for, by name. */
|
|
132
|
+
export function moduleConfigsOf(root) {
|
|
135
133
|
if (usesLegacyConfig(root))
|
|
136
|
-
return
|
|
134
|
+
return legacyModuleConfigs(root);
|
|
137
135
|
return namesIn(root)
|
|
138
136
|
.map((name) => /^config\.turri\.(.+)\.yaml$/.exec(name)?.[1])
|
|
139
137
|
.filter((name) => name !== undefined)
|
|
@@ -141,91 +139,102 @@ export function stacksOf(root) {
|
|
|
141
139
|
}
|
|
142
140
|
/**
|
|
143
141
|
* Before turri first writes a setting in a folder whose settings are still in the old files: config.yaml copied to
|
|
144
|
-
* config.turri.yaml, and each config.<
|
|
142
|
+
* config.turri.yaml, and each config.<module>.yaml to config.turri.<module>.yaml, so nothing is lost when the old files
|
|
145
143
|
* stop being read. The old files are left as they are. Gives back the files written, by name.
|
|
146
144
|
*/
|
|
147
145
|
export function adoptLegacyConfig(root, options = {}) {
|
|
148
146
|
if (!usesLegacyConfig(root))
|
|
149
147
|
return [];
|
|
150
148
|
const copies = [
|
|
151
|
-
// `projectFile: false`: the
|
|
149
|
+
// `projectFile: false`: the modules' files alone - turri init-config writes config.turri.yaml itself.
|
|
152
150
|
...(options.projectFile !== false && existsSync(join(root, LEGACY_CONFIG_FILE)) ? [[LEGACY_CONFIG_FILE, CONFIG_FILE]] : []),
|
|
153
|
-
...
|
|
151
|
+
...legacyModuleConfigs(root).map((module) => [legacyModuleConfigFile(module), moduleConfigFile(module)]),
|
|
154
152
|
];
|
|
155
153
|
for (const [from, to] of copies)
|
|
156
154
|
copyFileSync(join(root, from), join(root, to));
|
|
157
155
|
return copies.map(([, to]) => to);
|
|
158
156
|
}
|
|
159
|
-
/** The
|
|
160
|
-
const
|
|
161
|
-
/**
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
*/
|
|
165
|
-
export function chosenStack() {
|
|
166
|
-
const pinned = pinnedStack.getStore();
|
|
167
|
-
if (pinned !== undefined)
|
|
168
|
-
return pinned.stack;
|
|
169
|
-
const chat = currentChat();
|
|
170
|
-
if (chat !== undefined)
|
|
171
|
-
return chat.stack;
|
|
172
|
-
return text(process.env.TURRI_STACK);
|
|
157
|
+
/** The module whose config file a pulse runs with: worked out as it was queued, whatever the files say since. */
|
|
158
|
+
const pinnedConfig = new AsyncLocalStorage();
|
|
159
|
+
/** Inside a pulse - or work pinned like one - the module whose config file it runs with; none outside. */
|
|
160
|
+
export function pinnedConfigModule() {
|
|
161
|
+
return pinnedConfig.getStore()?.module;
|
|
173
162
|
}
|
|
174
|
-
/**
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
if (chat !== undefined)
|
|
182
|
-
chat.stack = chosen;
|
|
183
|
-
else if (chosen === undefined)
|
|
184
|
-
delete process.env.TURRI_STACK;
|
|
185
|
-
else
|
|
186
|
-
process.env.TURRI_STACK = chosen;
|
|
187
|
-
}
|
|
188
|
-
/** Run `work` with `stack` as the one chosen, whatever is chosen meanwhile: a pulse keeps the stack it started with. */
|
|
189
|
-
export function withStack(stack, work) {
|
|
190
|
-
return pinnedStack.run({ stack }, work);
|
|
191
|
-
}
|
|
192
|
-
/** Whether a stack is pinned here - named by the call that asked for the work, or kept by the pulse it runs in. */
|
|
193
|
-
export function stackPinned() {
|
|
194
|
-
return pinnedStack.getStore() !== undefined;
|
|
163
|
+
/** Run `work` with `module`'s config file over the project's, whatever the files say meanwhile: a pulse keeps the one it started with. */
|
|
164
|
+
export function withConfigModule(module, work) {
|
|
165
|
+
return pinnedConfig.run({ module }, work);
|
|
166
|
+
}
|
|
167
|
+
/** Whether a module's config file is pinned here - by the pulse it runs in, or the work that plans it. */
|
|
168
|
+
export function configModulePinned() {
|
|
169
|
+
return pinnedConfig.getStore() !== undefined;
|
|
195
170
|
}
|
|
196
171
|
/**
|
|
197
|
-
* The
|
|
198
|
-
*
|
|
199
|
-
*
|
|
172
|
+
* The module whose config file builds a module - its `config.turri.<module>.yaml` laid over `config.turri.yaml` - or
|
|
173
|
+
* none, `config.turri.yaml` alone. The one pinned, inside a pulse; else the module's own file; else the one file among
|
|
174
|
+
* the modules it requires, all the way down - a module is built on their code, in one codebase, with their testing
|
|
175
|
+
* scripts. Two among them is an error: which one builds it cannot be told. Only `requires` counts, not imports.
|
|
200
176
|
*/
|
|
201
|
-
export function
|
|
177
|
+
export function configModuleFor(plainFile) {
|
|
202
178
|
const root = projectDirOf(resolve(plainFile));
|
|
203
|
-
if (
|
|
204
|
-
return
|
|
179
|
+
if (configModulePinned())
|
|
180
|
+
return configModuleOf(root);
|
|
205
181
|
const own = basename(plainFile).replace(/\.plain$/, "");
|
|
206
|
-
|
|
182
|
+
const files = moduleConfigsOf(root);
|
|
183
|
+
if (files.length === 0)
|
|
184
|
+
return undefined;
|
|
185
|
+
if (files.includes(own))
|
|
186
|
+
return own;
|
|
187
|
+
const below = requiredModulesOf(resolve(plainFile)).filter((name) => files.includes(name));
|
|
188
|
+
if (below.length > 1)
|
|
189
|
+
throw new Error(moduleConfigClash(own, below, root));
|
|
190
|
+
return below[0];
|
|
191
|
+
}
|
|
192
|
+
/** Why a module's config cannot be told: two or more of the modules it requires have a config file of their own. */
|
|
193
|
+
export function moduleConfigClash(module, below, root) {
|
|
194
|
+
const named = below.map((name) => moduleConfigFileIn(root, name)).join(", ");
|
|
195
|
+
return (`${module}.plain requires modules that each have a config file of their own - ${named} - and a module built on others ` +
|
|
196
|
+
`takes theirs, so which builds ${module}.plain cannot be told. Give ${module}.plain its own ${moduleConfigFileIn(root, module)}, ` +
|
|
197
|
+
`or keep only one of them.`);
|
|
207
198
|
}
|
|
208
|
-
/** The words that choose no stack: the project's config alone. */
|
|
209
|
-
export const NO_STACK = ["none", "off", "base", "-"];
|
|
210
199
|
/**
|
|
211
|
-
*
|
|
212
|
-
*
|
|
200
|
+
* Every module a module requires, all the way down, by name - read from each file's frontmatter alone, found as the
|
|
201
|
+
* parser finds them (the module's folder, its template/ folder, PLAIN_TEMPLATE_DIRS). One that is not there, or does
|
|
202
|
+
* not read, ends its branch: the parse says what is wrong with it.
|
|
213
203
|
*/
|
|
214
|
-
export function
|
|
215
|
-
const
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
204
|
+
export function requiredModulesOf(plainFile) {
|
|
205
|
+
const dirs = resolveTemplateDirs(plainFile);
|
|
206
|
+
const found = [];
|
|
207
|
+
const visit = (file) => {
|
|
208
|
+
for (const name of requiresIn(file)) {
|
|
209
|
+
const bare = basename(name.replace(/^\.\//, ""), ".plain");
|
|
210
|
+
if (found.includes(bare))
|
|
211
|
+
continue;
|
|
212
|
+
found.push(bare);
|
|
213
|
+
const next = dirs.map((dir) => join(dir, `${name}.plain`)).find((candidate) => existsSync(candidate));
|
|
214
|
+
if (next !== undefined)
|
|
215
|
+
visit(next);
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
visit(plainFile);
|
|
219
|
+
return found;
|
|
220
|
+
}
|
|
221
|
+
/** The modules a .plain file's frontmatter says it requires. */
|
|
222
|
+
function requiresIn(file) {
|
|
223
|
+
try {
|
|
224
|
+
const match = /^-{3,}[ \t]*\n(?:([\s\S]*?)\n)?-{3,}[ \t]*(?:\n|$)/.exec(readFileSync(file, "utf8"));
|
|
225
|
+
const front = match?.[1] !== undefined ? loadYaml(match[1]) : undefined;
|
|
226
|
+
const requires = front?.requires;
|
|
227
|
+
const names = typeof requires === "string" ? [requires] : Array.isArray(requires) ? requires : [];
|
|
228
|
+
return names.filter((name) => typeof name === "string" && name.trim() !== "").map((name) => name.trim());
|
|
229
|
+
}
|
|
230
|
+
catch {
|
|
231
|
+
return [];
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
/** The module whose config file is pinned here, when the project folder has that file. */
|
|
235
|
+
export function configModuleOf(root) {
|
|
236
|
+
const module = pinnedConfigModule();
|
|
237
|
+
return module !== undefined && moduleConfigsOf(root).includes(module) ? module : undefined;
|
|
229
238
|
}
|
|
230
239
|
export const THINKING_LEVELS = ["off", "minimal", "low", "medium", "high", "xhigh", "max"];
|
|
231
240
|
/**
|
|
@@ -317,7 +326,7 @@ export function projectModels(config) {
|
|
|
317
326
|
* when the project names none.
|
|
318
327
|
*/
|
|
319
328
|
export function skillModel(root, role = "harness") {
|
|
320
|
-
return modelSpec(projectModels(readProjectConfig(root,
|
|
329
|
+
return modelSpec(projectModels(readProjectConfig(root, configModuleOf(root)))[role]);
|
|
321
330
|
}
|
|
322
331
|
/** A role entry's model and thinking alone. */
|
|
323
332
|
function choiceOf(entry) {
|
|
@@ -433,17 +442,17 @@ function text(value) {
|
|
|
433
442
|
return typeof value === "string" && value.trim() !== "" ? value.trim() : undefined;
|
|
434
443
|
}
|
|
435
444
|
/**
|
|
436
|
-
* The project's config - with a
|
|
445
|
+
* The project's config - with a module's own file over it, when one is named - or nothing of it when there is no file or it does
|
|
437
446
|
* not parse.
|
|
438
447
|
*/
|
|
439
|
-
export function readProjectConfig(root,
|
|
440
|
-
return withRunOverrides(
|
|
448
|
+
export function readProjectConfig(root, module) {
|
|
449
|
+
return withRunOverrides(readLayeredConfig(root, module));
|
|
441
450
|
}
|
|
442
|
-
function
|
|
451
|
+
function readLayeredConfig(root, module) {
|
|
443
452
|
const project = readConfigFile(join(root, projectConfigFile(root)));
|
|
444
|
-
if (
|
|
453
|
+
if (module === undefined)
|
|
445
454
|
return project;
|
|
446
|
-
const own = readConfigFile(join(root,
|
|
455
|
+
const own = readConfigFile(join(root, moduleConfigFileIn(root, module)));
|
|
447
456
|
// The project's alone: one conversation, one module built when none is named.
|
|
448
457
|
const merged = { ...project };
|
|
449
458
|
for (const key of Object.keys(CONFIG_KEYS)) {
|
|
@@ -525,14 +534,23 @@ function withoutUndefined(config) {
|
|
|
525
534
|
}
|
|
526
535
|
/** Where the test plain files are when `test-dir:` does not say. */
|
|
527
536
|
export const DEFAULT_TEST_DIR = "tests";
|
|
528
|
-
/** The folder of a module's project's test plain files: `test-dir:` - its
|
|
537
|
+
/** The folder of a module's project's test plain files: `test-dir:` - its own file's over the project's - from the project's folder. */
|
|
529
538
|
export function testDirOf(plainFile) {
|
|
530
539
|
return resolve(projectDirOf(resolve(plainFile)), configForSpec(plainFile).testDir ?? DEFAULT_TEST_DIR);
|
|
531
540
|
}
|
|
532
|
-
/** The config a spec is built with: its project's, with its module's
|
|
541
|
+
/** The config a spec is built with: its project's, with its module's own file over it - or a required module's (`configModuleFor`). */
|
|
533
542
|
export function configForSpec(plainFile) {
|
|
534
543
|
const root = projectDirOf(resolve(plainFile));
|
|
535
|
-
|
|
544
|
+
// Two module files among the modules it requires: the project's alone, read as anything reads it - the parse, and
|
|
545
|
+
// every call that would build the module, refuse it with why (`configModuleFor`).
|
|
546
|
+
let module;
|
|
547
|
+
try {
|
|
548
|
+
module = configModuleFor(plainFile);
|
|
549
|
+
}
|
|
550
|
+
catch {
|
|
551
|
+
module = undefined;
|
|
552
|
+
}
|
|
553
|
+
return readProjectConfig(root, module);
|
|
536
554
|
}
|
|
537
555
|
/**
|
|
538
556
|
* One config file, read, or nothing of it when it is not there or does not parse. Parsed again only once the file has
|
|
@@ -621,7 +639,7 @@ function readConfigFileNow(path) {
|
|
|
621
639
|
/** Keys a config file is read for besides CONFIG_KEYS: the older spellings turri still takes. */
|
|
622
640
|
const OLDER_KEYS = ["model", "turn_limit"];
|
|
623
641
|
/**
|
|
624
|
-
* The keys of the project's own config files - config.turri.yaml and each
|
|
642
|
+
* The keys of the project's own config files - config.turri.yaml and each module's - that turri reads nothing of: a setting
|
|
625
643
|
* turri no longer has (`test-advisor`), or one misspelt. Said as turri starts, so a setting the person thinks is on is
|
|
626
644
|
* not silently ignored. config.yaml is left out: it may be another tool's, with keys of its own.
|
|
627
645
|
*/
|
package/dist/conform-cli.js
CHANGED
|
@@ -7,7 +7,7 @@ as module:func-id, or every one with scenarios - on the code as it is built, as
|
|
|
7
7
|
exactly their conformance and acceptance scenarios, following the spec's test reqs, with the whole suite
|
|
8
8
|
the module inherits, a failure fixed in the test or the code, whichever is wrong. A functional spec with
|
|
9
9
|
no scenarios is refused: write them first. So is a module with no test reqs, or no conformance testing
|
|
10
|
-
script
|
|
10
|
+
script: the refusal names the next step. Every functional spec tested goes in one pulse,
|
|
11
11
|
as far as the size guardrail lets. A functional spec named whose tests are written has them written
|
|
12
12
|
again: deleted and written anew from its scenarios, its code untouched.
|
|
13
13
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Whether a project's functional specs are conformance tested: `conformance-tests:` in its config, a
|
|
3
|
-
* project's, false when unset. Conformance testing is a validation step that makes each change take about twice as long,
|
|
2
|
+
* Whether a project's functional specs are conformance tested: `conformance-tests:` in its config, a module's own file's
|
|
3
|
+
* over the project's, false when unset. Conformance testing is a validation step that makes each change take about twice as long,
|
|
4
4
|
* so it is off until the person turns it on - with /conform, or the setting - and they keep it off to iterate fast. Off,
|
|
5
5
|
* nothing of conformance testing runs - no conformance pulse, no conformance testing script, the
|
|
6
6
|
* chat's conform refused; the test plain files there are kept, and not tested. The chat never turns them on: it says why
|
|
@@ -8,13 +8,14 @@
|
|
|
8
8
|
*/
|
|
9
9
|
/** Why the chat's conform, or a skill that writes the conformance testing script, is refused while they are off. */
|
|
10
10
|
export declare const CONFORMANCE_OFF_REFUSAL: string;
|
|
11
|
-
/** Whether a module's functional specs are conformance tested: its
|
|
11
|
+
/** Whether a module's functional specs are conformance tested: its own file's `conformance-tests:` over the project's. */
|
|
12
12
|
export declare function conformanceTestsOn(plainFile: string): boolean;
|
|
13
|
-
/** Whether the project conformance tests anything: its own config, or a
|
|
13
|
+
/** Whether the project conformance tests anything: its own config, or a module's own file - for the chat's tools, which are the project's. */
|
|
14
14
|
export declare function conformanceTestsOnIn(project: string): boolean;
|
|
15
15
|
/**
|
|
16
|
-
* Turn conformance testing on: `conformance-tests: true` written where the module's value comes from - its
|
|
17
|
-
* when that names the key, else config.turri.yaml - and in effect at once.
|
|
16
|
+
* Turn conformance testing on: `conformance-tests: true` written where the module's value comes from - its config
|
|
17
|
+
* file, its own or one of a module it requires, when that names the key, else config.turri.yaml - and in effect at once.
|
|
18
|
+
* Says which file.
|
|
18
19
|
*/
|
|
19
20
|
export declare function turnOnConformanceTests(project: string, plainFile?: string): string;
|
|
20
21
|
/**
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
2
|
import { join, resolve } from "node:path";
|
|
3
|
-
import { adoptLegacyConfig, CONFIG_FILE, CONFIG_KEYS, configForSpec, readConfigFile, readProjectConfig,
|
|
3
|
+
import { adoptLegacyConfig, CONFIG_FILE, CONFIG_KEYS, configForSpec, readConfigFile, readProjectConfig, moduleConfigFileIn, configModuleFor, moduleConfigsOf } from "./config.js";
|
|
4
4
|
import { withSetting, writeSetting } from "./config-edit.js";
|
|
5
5
|
/**
|
|
6
|
-
* Whether a project's functional specs are conformance tested: `conformance-tests:` in its config, a
|
|
7
|
-
* project's, false when unset. Conformance testing is a validation step that makes each change take about twice as long,
|
|
6
|
+
* Whether a project's functional specs are conformance tested: `conformance-tests:` in its config, a module's own file's
|
|
7
|
+
* over the project's, false when unset. Conformance testing is a validation step that makes each change take about twice as long,
|
|
8
8
|
* so it is off until the person turns it on - with /conform, or the setting - and they keep it off to iterate fast. Off,
|
|
9
9
|
* nothing of conformance testing runs - no conformance pulse, no conformance testing script, the
|
|
10
10
|
* chat's conform refused; the test plain files there are kept, and not tested. The chat never turns them on: it says why
|
|
@@ -14,8 +14,8 @@ import { withSetting, writeSetting } from "./config-edit.js";
|
|
|
14
14
|
export const CONFORMANCE_OFF_REFUSAL = "Conformance tests are off for this project (conformance-tests: false, or unset), and turning them on is the person's " +
|
|
15
15
|
"decision: they make each change take about twice as long, and the person keeps them off to iterate fast. Tell the " +
|
|
16
16
|
"person, in a line or two, why you want conformance tests here; they decide, and turn them on with /conform - which " +
|
|
17
|
-
"also starts them - or /
|
|
18
|
-
/** Whether a module's functional specs are conformance tested: its
|
|
17
|
+
"also starts them - or /settings conformance-tests true. Nothing was started.";
|
|
18
|
+
/** Whether a module's functional specs are conformance tested: its own file's `conformance-tests:` over the project's. */
|
|
19
19
|
export function conformanceTestsOn(plainFile) {
|
|
20
20
|
try {
|
|
21
21
|
return configForSpec(resolve(plainFile)).conformanceTests === true;
|
|
@@ -24,29 +24,29 @@ export function conformanceTestsOn(plainFile) {
|
|
|
24
24
|
return false;
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
/** Whether the project conformance tests anything: its own config, or a
|
|
27
|
+
/** Whether the project conformance tests anything: its own config, or a module's own file - for the chat's tools, which are the project's. */
|
|
28
28
|
export function conformanceTestsOnIn(project) {
|
|
29
29
|
try {
|
|
30
|
-
|
|
31
|
-
return readProjectConfig(project).conformanceTests === true || stacks.some((stack) => readProjectConfig(project, stack).conformanceTests === true);
|
|
30
|
+
return readProjectConfig(project).conformanceTests === true || moduleConfigsOf(project).some((module) => readProjectConfig(project, module).conformanceTests === true);
|
|
32
31
|
}
|
|
33
32
|
catch {
|
|
34
33
|
return false;
|
|
35
34
|
}
|
|
36
35
|
}
|
|
37
36
|
/**
|
|
38
|
-
* Turn conformance testing on: `conformance-tests: true` written where the module's value comes from - its
|
|
39
|
-
* when that names the key, else config.turri.yaml - and in effect at once.
|
|
37
|
+
* Turn conformance testing on: `conformance-tests: true` written where the module's value comes from - its config
|
|
38
|
+
* file, its own or one of a module it requires, when that names the key, else config.turri.yaml - and in effect at once.
|
|
39
|
+
* Says which file.
|
|
40
40
|
*/
|
|
41
41
|
export function turnOnConformanceTests(project, plainFile) {
|
|
42
|
-
const
|
|
43
|
-
if (
|
|
44
|
-
const file = join(project,
|
|
42
|
+
const module = plainFile !== undefined ? configModuleFor(resolve(plainFile)) : undefined;
|
|
43
|
+
if (module !== undefined) {
|
|
44
|
+
const file = join(project, moduleConfigFileIn(project, module));
|
|
45
45
|
if (existsSync(file) && readConfigFile(file).conformanceTests !== undefined) {
|
|
46
46
|
adoptLegacyConfig(project);
|
|
47
|
-
const own = join(project,
|
|
47
|
+
const own = join(project, moduleConfigFileIn(project, module));
|
|
48
48
|
writeFileSync(own, withSetting(readFileSync(own, "utf8"), CONFIG_KEYS.conformanceTests, true));
|
|
49
|
-
return
|
|
49
|
+
return moduleConfigFileIn(project, module);
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
writeSetting(project, CONFIG_KEYS.conformanceTests, true);
|
|
@@ -79,7 +79,7 @@ export function conformanceBlock(on) {
|
|
|
79
79
|
"no conformance testing script either, and conform is refused. Test plain files already there are",
|
|
80
80
|
"kept, and not tested. When you think conformance tests are worth it here - the person asks for tests, a functional spec",
|
|
81
81
|
"could go wrong silently, or the coding agent keeps failing at one - tell them in a line or two why, and what it costs.",
|
|
82
|
-
"They decide, and turn them on with /conform - which also tests what is built - or /
|
|
82
|
+
"They decide, and turn them on with /conform - which also tests what is built - or /settings conformance-tests true.",
|
|
83
83
|
].join("\n"),
|
|
84
84
|
"</conformance-tests>",
|
|
85
85
|
].join("\n");
|
package/dist/extension.d.ts
CHANGED
|
@@ -138,7 +138,7 @@ export declare function projectConfigBlock(root: string): string;
|
|
|
138
138
|
/**
|
|
139
139
|
* Conformance tests turned on, for the session: `conformance-tests: true` written where the module's value comes from
|
|
140
140
|
* (conformance-switch.ts) - what /conform does when they are off, and a host's turnOnConformance. Every chat is told at
|
|
141
|
-
* its next turn. `plainFile`, absolute or from the project, picks the module whose
|
|
141
|
+
* its next turn. `plainFile`, absolute or from the project, picks the module whose own file
|
|
142
142
|
* is written when that names the key. Returns the file written, from the project. Starts no conformance pulse.
|
|
143
143
|
*/
|
|
144
144
|
export declare function turnOnConformance(core: TurriCore, plainFile?: string): string;
|