@turri-dev/cli 0.2.4-next.8422d0f → 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 +5 -6
- package/dist/bedrock-region.js +3 -3
- package/dist/chat-idle.d.ts +2 -2
- package/dist/chat-idle.js +2 -2
- 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 -12
- package/dist/chats.js +3 -26
- package/dist/cli.js +11 -30
- package/dist/config-edit.d.ts +20 -8
- package/dist/config-edit.js +29 -23
- package/dist/config.d.ts +62 -71
- package/dist/config.js +170 -125
- package/dist/conform-cli.js +14 -3
- package/dist/conformance-switch.d.ts +13 -22
- package/dist/conformance-switch.js +37 -59
- package/dist/drift-cli.js +1 -1
- package/dist/extension.d.ts +8 -10
- package/dist/extension.js +257 -429
- package/dist/genome.js +9 -48
- package/dist/graph.js +3 -5
- package/dist/host-session.d.ts +5 -16
- package/dist/host-session.js +4 -6
- package/dist/host.d.ts +2 -4
- package/dist/host.js +4 -7
- package/dist/identity.js +0 -1
- package/dist/init-config.d.ts +0 -1
- package/dist/init-config.js +3 -10
- package/dist/installed-providers.d.ts +1 -1
- package/dist/installed-providers.js +1 -1
- package/dist/loop-cli.d.ts +4 -3
- package/dist/loop-cli.js +13 -11
- package/dist/loop-tools.d.ts +37 -18
- package/dist/loop-tools.js +118 -58
- package/dist/new-project.js +2 -2
- package/dist/parse-cli.js +2 -2
- package/dist/pi-launch.js +4 -1
- package/dist/pi-settings.d.ts +4 -0
- package/dist/pi-settings.js +39 -0
- package/dist/pi.js +12 -9
- package/dist/plain/check.d.ts +2 -9
- package/dist/plain/check.js +6 -39
- package/dist/plain-files.js +4 -4
- package/dist/regenerate/activity.d.ts +0 -7
- package/dist/regenerate/activity.js +2 -20
- package/dist/regenerate/agent-env.d.ts +1 -1
- package/dist/regenerate/agent-env.js +3 -3
- package/dist/regenerate/agent-shell.js +5 -3
- package/dist/regenerate/audit.js +9 -0
- package/dist/regenerate/base-folder.d.ts +2 -2
- package/dist/regenerate/base-folder.js +1 -1
- package/dist/regenerate/cases.js +7 -0
- package/dist/regenerate/chunk-plan.d.ts +5 -0
- package/dist/regenerate/chunk-plan.js +16 -1
- package/dist/regenerate/drift.d.ts +4 -0
- package/dist/regenerate/drift.js +26 -6
- package/dist/regenerate/failure-reports.d.ts +28 -0
- package/dist/regenerate/failure-reports.js +79 -0
- package/dist/regenerate/job-panel.js +3 -1
- package/dist/regenerate/jobs-tree.js +1 -1
- package/dist/regenerate/jobs.d.ts +4 -2
- package/dist/regenerate/jobs.js +14 -10
- package/dist/regenerate/ledger-view.d.ts +11 -24
- package/dist/regenerate/ledger-view.js +14 -60
- package/dist/regenerate/ledger.d.ts +2 -15
- package/dist/regenerate/ledger.js +1 -1
- package/dist/regenerate/loop.d.ts +48 -62
- package/dist/regenerate/loop.js +296 -131
- 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/records.d.ts +11 -0
- package/dist/regenerate/records.js +15 -0
- package/dist/regenerate/regenerate.d.ts +0 -2
- package/dist/regenerate/regenerate.js +4 -15
- package/dist/regenerate/renames.js +4 -4
- package/dist/regenerate/requires.d.ts +7 -0
- package/dist/regenerate/requires.js +24 -18
- package/dist/regenerate/scripts-being-written.d.ts +4 -4
- package/dist/regenerate/scripts-being-written.js +3 -3
- package/dist/regenerate/spec-map.js +3 -3
- package/dist/regenerate/standing.js +1 -1
- package/dist/regenerate/submit-work.d.ts +2 -0
- package/dist/regenerate/submit-work.js +8 -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 +16 -5
- package/dist/regenerate/testing-steps.js +28 -9
- package/dist/regenerate-cli.js +18 -9
- package/dist/self-invocation.d.ts +11 -0
- package/dist/self-invocation.js +33 -7
- package/dist/sentinel.js +8 -5
- 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/dist/skill.d.ts +0 -11
- package/dist/skill.js +0 -9
- package/dist/tools.js +2 -3
- package/dist/turri-versions.js +2 -1
- package/docs/README.md +2 -4
- package/docs/authoring-plain.md +3 -3
- package/docs/chats.md +4 -7
- package/docs/claude-subscription.md +2 -2
- package/docs/config.md +55 -45
- package/docs/deploy.md +1 -1
- package/docs/development.md +3 -4
- package/docs/headless.md +6 -5
- package/docs/hosting.md +11 -11
- package/docs/parser.md +3 -3
- package/docs/regenerating.md +27 -19
- package/docs/sentinel.md +6 -6
- package/docs/skills-and-gates.md +4 -9
- package/docs/using.md +20 -37
- package/genome/rules/project-model.md +2 -1
- package/genome/rules/test-plain-files.md +15 -7
- package/genome/rules/turri-regeneration.md +6 -9
- package/genome/skills/convert-old-syntax/SKILL.md +5 -5
- 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/advisor-chat.d.ts +0 -63
- package/dist/advisor-chat.js +0 -290
- package/dist/change-plain-cli.d.ts +0 -1
- package/dist/change-plain-cli.js +0 -55
- package/dist/ledger-cli.d.ts +0 -1
- package/dist/ledger-cli.js +0 -50
- package/dist/ledger-tools.d.ts +0 -10
- package/dist/ledger-tools.js +0 -64
- package/dist/regenerate/advisor-records.d.ts +0 -93
- package/dist/regenerate/advisor-records.js +0 -110
- package/dist/regenerate/advisor-runs.d.ts +0 -87
- package/dist/regenerate/advisor-runs.js +0 -327
- package/dist/regenerate/engine.d.ts +0 -52
- package/dist/regenerate/test-advisor.d.ts +0 -101
- package/dist/regenerate/test-advisor.js +0 -379
- package/dist/spec-tools.d.ts +0 -36
- package/dist/spec-tools.js +0 -128
- package/dist/stacks.d.ts +0 -13
- package/dist/stacks.js +0 -96
- package/docs/test-advisor.md +0 -110
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
|
*
|
|
@@ -11,7 +10,7 @@ import { projectDirOf } from "./regenerate/paths.js";
|
|
|
11
10
|
*
|
|
12
11
|
* ```yaml
|
|
13
12
|
* module: prism_cli.plain # what `turri regenerate` builds by default
|
|
14
|
-
* conformance-tests: false # whether scenarios are written and conformance tested - false: none
|
|
13
|
+
* conformance-tests: false # whether scenarios are written and conformance tested - false: none (default: false)
|
|
15
14
|
* test-dir: tests # where the test plain files are, a folder per module: tests/<module>/ (default: tests)
|
|
16
15
|
* base-folder: existing-app # a codebase that requires none starts as a copy of it - code to build on, assets to use
|
|
17
16
|
* harness-model: # the model you chat with in `turri`
|
|
@@ -26,7 +25,6 @@ import { projectDirOf } from "./regenerate/paths.js";
|
|
|
26
25
|
* mutation-testing: false # give the coding agent and the reviewer can_it_fail (default: true)
|
|
27
26
|
* allow-to-stop-jobs: false # stop a running job the spec moved on from (default: true)
|
|
28
27
|
* release-after-pulse: true # release what each pulse lands, as its last stage, before the next pulse (default: false)
|
|
29
|
-
* test-advisor: false # check each new or changed functional spec with no scenarios for whether it needs them - on a yes, the chat writes them (default: true)
|
|
30
28
|
* sentinel: true # a chat of its own every finished pulse goes to, which tests the release and tells you what is wrong: true, false, or ask - the person asked before it first opens in a session (default: ask)
|
|
31
29
|
* rules-off: [integrations] # ***plain rules to leave out of the prompts, by name (default: none)
|
|
32
30
|
* unittests-script: test_scripts/run_unittests.sh # the testing scripts - see test-scripts.ts
|
|
@@ -50,49 +48,51 @@ import { projectDirOf } from "./regenerate/paths.js";
|
|
|
50
48
|
* either of which may be left out; a bare string is the model alone. What a model leaves out it takes
|
|
51
49
|
* from the one it inherits: judge-model from coding-model, coding-model from harness-model. They are
|
|
52
50
|
* defaults: `--harness-model` / `--coding-model` / `--judge-model` on the command line win over them,
|
|
53
|
-
* 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
|
|
54
52
|
* as `coding-model`, which it was before there were two.
|
|
55
53
|
*
|
|
56
54
|
* Keys are written with dashes; underscores are read the same (`conformance_tests`). Keys it
|
|
57
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
|
|
58
56
|
* the wrong type. Everything is optional, and what is given on the command line wins.
|
|
59
57
|
*
|
|
60
|
-
* A
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
* from the
|
|
66
|
-
*
|
|
67
|
-
* 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.
|
|
68
65
|
*/
|
|
69
66
|
/** turri's settings for a project, in a file of its own: a `config.yaml` beside it may be another tool's. */
|
|
70
67
|
export const CONFIG_FILE = "config.turri.yaml";
|
|
71
68
|
/**
|
|
72
69
|
* Where turri's settings were before they had a file of their own. A project with no `config.turri*.yaml` yet is read
|
|
73
|
-
* 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
|
|
74
71
|
* turri writes copies them to the new names (`adoptLegacyConfig`), and from then on the old files are not read.
|
|
75
72
|
*/
|
|
76
73
|
export const LEGACY_CONFIG_FILE = "config.yaml";
|
|
77
|
-
/** A
|
|
78
|
-
export function
|
|
79
|
-
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`;
|
|
80
77
|
}
|
|
81
|
-
function
|
|
82
|
-
return `config.${
|
|
78
|
+
function legacyModuleConfigFile(module) {
|
|
79
|
+
return `config.${module}.yaml`;
|
|
83
80
|
}
|
|
84
81
|
/**
|
|
85
82
|
* The names in a folder - read again only once the folder itself has changed: a name added, removed or renamed in it
|
|
86
|
-
* moves its modification time. Asked many times a look, for every module of every chain.
|
|
83
|
+
* moves its modification time. Asked many times a look, for every module of every chain. A folder changed less than a
|
|
84
|
+
* second before it was read is read again each time: a name added within the same tick of the file system's clock
|
|
85
|
+
* would not move it (readConfigFile).
|
|
87
86
|
*/
|
|
88
87
|
function namesIn(root) {
|
|
89
88
|
try {
|
|
90
89
|
const at = statSync(root).mtimeMs;
|
|
91
90
|
const kept = keptNames.get(root);
|
|
92
|
-
if (kept !== undefined && kept.at === at)
|
|
91
|
+
if (kept !== undefined && kept.at === at && at < kept.readAt - RACY_MS)
|
|
93
92
|
return [...kept.names];
|
|
93
|
+
const readAt = Date.now();
|
|
94
94
|
const names = readdirSync(root);
|
|
95
|
-
keptNames.set(root, { at, names });
|
|
95
|
+
keptNames.set(root, { at, names, readAt });
|
|
96
96
|
if (keptNames.size > 64)
|
|
97
97
|
keptNames.delete(keptNames.keys().next().value);
|
|
98
98
|
return [...names];
|
|
@@ -102,36 +102,36 @@ function namesIn(root) {
|
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
const keptNames = new Map();
|
|
105
|
-
/** The
|
|
106
|
-
function
|
|
105
|
+
/** The modules with a file of their own in the old naming, `config.<module>.yaml`. */
|
|
106
|
+
function legacyModuleConfigs(root) {
|
|
107
107
|
return namesIn(root)
|
|
108
108
|
.map((name) => /^config\.(?!turri(?:\.|$))(.+)\.yaml$/.exec(name)?.[1])
|
|
109
109
|
.filter((name) => name !== undefined)
|
|
110
110
|
.sort();
|
|
111
111
|
}
|
|
112
|
-
/** 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. */
|
|
113
113
|
export function usesLegacyConfig(root) {
|
|
114
114
|
const names = namesIn(root);
|
|
115
115
|
if (names.some((name) => /^config\.turri(?:\..+)?\.yaml$/.test(name)))
|
|
116
116
|
return false;
|
|
117
|
-
return names.includes(LEGACY_CONFIG_FILE) ||
|
|
117
|
+
return names.includes(LEGACY_CONFIG_FILE) || legacyModuleConfigs(root).length > 0;
|
|
118
118
|
}
|
|
119
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. */
|
|
120
120
|
export function projectConfigFile(root) {
|
|
121
121
|
return usesLegacyConfig(root) ? LEGACY_CONFIG_FILE : CONFIG_FILE;
|
|
122
122
|
}
|
|
123
|
-
/** The file a
|
|
124
|
-
export function
|
|
125
|
-
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);
|
|
126
126
|
}
|
|
127
|
-
/** 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. */
|
|
128
128
|
export function hasProjectConfig(root) {
|
|
129
|
-
return existsSync(join(root, CONFIG_FILE)) ||
|
|
129
|
+
return existsSync(join(root, CONFIG_FILE)) || moduleConfigsOf(root).length > 0 || usesLegacyConfig(root);
|
|
130
130
|
}
|
|
131
|
-
/** The
|
|
132
|
-
export function
|
|
131
|
+
/** The modules a project folder has config files for, by name. */
|
|
132
|
+
export function moduleConfigsOf(root) {
|
|
133
133
|
if (usesLegacyConfig(root))
|
|
134
|
-
return
|
|
134
|
+
return legacyModuleConfigs(root);
|
|
135
135
|
return namesIn(root)
|
|
136
136
|
.map((name) => /^config\.turri\.(.+)\.yaml$/.exec(name)?.[1])
|
|
137
137
|
.filter((name) => name !== undefined)
|
|
@@ -139,100 +139,110 @@ export function stacksOf(root) {
|
|
|
139
139
|
}
|
|
140
140
|
/**
|
|
141
141
|
* Before turri first writes a setting in a folder whose settings are still in the old files: config.yaml copied to
|
|
142
|
-
* 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
|
|
143
143
|
* stop being read. The old files are left as they are. Gives back the files written, by name.
|
|
144
144
|
*/
|
|
145
145
|
export function adoptLegacyConfig(root, options = {}) {
|
|
146
146
|
if (!usesLegacyConfig(root))
|
|
147
147
|
return [];
|
|
148
148
|
const copies = [
|
|
149
|
-
// `projectFile: false`: the
|
|
149
|
+
// `projectFile: false`: the modules' files alone - turri init-config writes config.turri.yaml itself.
|
|
150
150
|
...(options.projectFile !== false && existsSync(join(root, LEGACY_CONFIG_FILE)) ? [[LEGACY_CONFIG_FILE, CONFIG_FILE]] : []),
|
|
151
|
-
...
|
|
151
|
+
...legacyModuleConfigs(root).map((module) => [legacyModuleConfigFile(module), moduleConfigFile(module)]),
|
|
152
152
|
];
|
|
153
153
|
for (const [from, to] of copies)
|
|
154
154
|
copyFileSync(join(root, from), join(root, to));
|
|
155
155
|
return copies.map(([, to]) => to);
|
|
156
156
|
}
|
|
157
|
-
/** The
|
|
158
|
-
const
|
|
159
|
-
/**
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
*/
|
|
163
|
-
export function chosenStack() {
|
|
164
|
-
const pinned = pinnedStack.getStore();
|
|
165
|
-
if (pinned !== undefined)
|
|
166
|
-
return pinned.stack;
|
|
167
|
-
const chat = currentChat();
|
|
168
|
-
if (chat !== undefined)
|
|
169
|
-
return chat.stack;
|
|
170
|
-
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;
|
|
171
162
|
}
|
|
172
|
-
/**
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
if (chat !== undefined)
|
|
180
|
-
chat.stack = chosen;
|
|
181
|
-
else if (chosen === undefined)
|
|
182
|
-
delete process.env.TURRI_STACK;
|
|
183
|
-
else
|
|
184
|
-
process.env.TURRI_STACK = chosen;
|
|
185
|
-
}
|
|
186
|
-
/** Run `work` with `stack` as the one chosen, whatever is chosen meanwhile: a pulse keeps the stack it started with. */
|
|
187
|
-
export function withStack(stack, work) {
|
|
188
|
-
return pinnedStack.run({ stack }, work);
|
|
189
|
-
}
|
|
190
|
-
/** Whether a stack is pinned here - named by the call that asked for the work, or kept by the pulse it runs in. */
|
|
191
|
-
export function stackPinned() {
|
|
192
|
-
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;
|
|
193
170
|
}
|
|
194
171
|
/**
|
|
195
|
-
* The
|
|
196
|
-
*
|
|
197
|
-
*
|
|
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.
|
|
198
176
|
*/
|
|
199
|
-
export function
|
|
177
|
+
export function configModuleFor(plainFile) {
|
|
200
178
|
const root = projectDirOf(resolve(plainFile));
|
|
201
|
-
if (
|
|
202
|
-
return
|
|
179
|
+
if (configModulePinned())
|
|
180
|
+
return configModuleOf(root);
|
|
203
181
|
const own = basename(plainFile).replace(/\.plain$/, "");
|
|
204
|
-
|
|
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.`);
|
|
205
198
|
}
|
|
206
|
-
/** The words that choose no stack: the project's config alone. */
|
|
207
|
-
export const NO_STACK = ["none", "off", "base", "-"];
|
|
208
199
|
/**
|
|
209
|
-
*
|
|
210
|
-
*
|
|
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.
|
|
211
203
|
*/
|
|
212
|
-
export function
|
|
213
|
-
const
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
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;
|
|
227
238
|
}
|
|
228
239
|
export const THINKING_LEVELS = ["off", "minimal", "low", "medium", "high", "xhigh", "max"];
|
|
229
240
|
/**
|
|
230
241
|
* The agents turri starts, by what they do - each can be given its own model, thinking and turn limit (`models:`).
|
|
231
242
|
* The code fixer of a conformance run and the repair agent are coding agents; the unit-test and conformance arbiters
|
|
232
|
-
* are both `arbiter`.
|
|
233
|
-
* are `advisor`.
|
|
243
|
+
* are both `arbiter`.
|
|
234
244
|
*/
|
|
235
|
-
export const AGENT_ROLES = ["chat", "sentinel", "planner", "diagnosis", "release", "coding", "conformance", "explorer", "reviewer", "test-reviewer", "judge", "arbiter", "debugger"
|
|
245
|
+
export const AGENT_ROLES = ["chat", "sentinel", "planner", "diagnosis", "release", "coding", "conformance", "explorer", "reviewer", "test-reviewer", "judge", "arbiter", "debugger"];
|
|
236
246
|
/**
|
|
237
247
|
* How hard each role thinks when nothing names a level - not the config's `models:`, nor a `:level` on the model it is
|
|
238
248
|
* given. The agents that do the work - write the code and the tests, explore, release - think little: they work from a
|
|
@@ -244,7 +254,6 @@ export const ROLE_THINKING = {
|
|
|
244
254
|
conformance: "low",
|
|
245
255
|
explorer: "low",
|
|
246
256
|
release: "low",
|
|
247
|
-
advisor: "low",
|
|
248
257
|
reviewer: "medium",
|
|
249
258
|
"test-reviewer": "medium",
|
|
250
259
|
judge: "medium",
|
|
@@ -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) {
|
|
@@ -344,14 +353,6 @@ export function roleModel(config, role) {
|
|
|
344
353
|
const legacy = role === "judge" || role === "test-reviewer" ? config.judgeModel : undefined;
|
|
345
354
|
return inheritModel(own, inheritModel(legacy, choiceOf(models.default)));
|
|
346
355
|
}
|
|
347
|
-
/**
|
|
348
|
-
* What the test advisor's calls run on: `models.advisor` - else `default` - and without either the coding
|
|
349
|
-
* model alone, thinking as the role has it (ROLE_THINKING). Undefined when the config names no model at all.
|
|
350
|
-
*/
|
|
351
|
-
export function advisorModel(config) {
|
|
352
|
-
const coding = projectModels(config).coding?.model;
|
|
353
|
-
return modelSpec(inheritModel(roleModel(config, "advisor"), coding !== undefined ? { model: coding } : undefined));
|
|
354
|
-
}
|
|
355
356
|
/** How long each turn of a role's agents may take, in milliseconds: its own, `default`'s, `turn-limit:`'s - or undefined, the harness's default. */
|
|
356
357
|
export function roleTurnLimitMs(config, role) {
|
|
357
358
|
const models = config.models ?? {};
|
|
@@ -414,7 +415,6 @@ export const CONFIG_KEYS = {
|
|
|
414
415
|
allowToStopJobs: "allow-to-stop-jobs",
|
|
415
416
|
releaseAfterPulse: "release-after-pulse",
|
|
416
417
|
sentinel: "sentinel",
|
|
417
|
-
testAdvisor: "test-advisor",
|
|
418
418
|
testDir: "test-dir",
|
|
419
419
|
conformanceTests: "conformance-tests",
|
|
420
420
|
baseFolder: "base-folder",
|
|
@@ -442,17 +442,17 @@ function text(value) {
|
|
|
442
442
|
return typeof value === "string" && value.trim() !== "" ? value.trim() : undefined;
|
|
443
443
|
}
|
|
444
444
|
/**
|
|
445
|
-
* 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
|
|
446
446
|
* not parse.
|
|
447
447
|
*/
|
|
448
|
-
export function readProjectConfig(root,
|
|
449
|
-
return withRunOverrides(
|
|
448
|
+
export function readProjectConfig(root, module) {
|
|
449
|
+
return withRunOverrides(readLayeredConfig(root, module));
|
|
450
450
|
}
|
|
451
|
-
function
|
|
451
|
+
function readLayeredConfig(root, module) {
|
|
452
452
|
const project = readConfigFile(join(root, projectConfigFile(root)));
|
|
453
|
-
if (
|
|
453
|
+
if (module === undefined)
|
|
454
454
|
return project;
|
|
455
|
-
const own = readConfigFile(join(root,
|
|
455
|
+
const own = readConfigFile(join(root, moduleConfigFileIn(root, module)));
|
|
456
456
|
// The project's alone: one conversation, one module built when none is named.
|
|
457
457
|
const merged = { ...project };
|
|
458
458
|
for (const key of Object.keys(CONFIG_KEYS)) {
|
|
@@ -534,39 +534,55 @@ function withoutUndefined(config) {
|
|
|
534
534
|
}
|
|
535
535
|
/** Where the test plain files are when `test-dir:` does not say. */
|
|
536
536
|
export const DEFAULT_TEST_DIR = "tests";
|
|
537
|
-
/** 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. */
|
|
538
538
|
export function testDirOf(plainFile) {
|
|
539
539
|
return resolve(projectDirOf(resolve(plainFile)), configForSpec(plainFile).testDir ?? DEFAULT_TEST_DIR);
|
|
540
540
|
}
|
|
541
|
-
/** 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`). */
|
|
542
542
|
export function configForSpec(plainFile) {
|
|
543
543
|
const root = projectDirOf(resolve(plainFile));
|
|
544
|
-
|
|
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);
|
|
545
554
|
}
|
|
546
555
|
/**
|
|
547
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
|
|
548
|
-
* changed - its size or its modification time - and each caller given its own copy.
|
|
557
|
+
* changed - its size or its modification time - and each caller given its own copy. A file modified less than a second
|
|
558
|
+
* before it was read is read again each time, as git treats a racily clean file: written again within the same tick of
|
|
559
|
+
* the file system's clock - milliseconds on Linux - and to the same size, its stamp would not change.
|
|
549
560
|
*/
|
|
550
561
|
export function readConfigFile(path) {
|
|
551
562
|
let stamp;
|
|
563
|
+
let modified;
|
|
552
564
|
try {
|
|
553
565
|
const stat = statSync(path);
|
|
554
566
|
if (!stat.isFile())
|
|
555
567
|
return {};
|
|
556
568
|
stamp = `${stat.size}:${stat.mtimeMs}:${stat.ino}`;
|
|
569
|
+
modified = stat.mtimeMs;
|
|
557
570
|
}
|
|
558
571
|
catch {
|
|
559
572
|
return {};
|
|
560
573
|
}
|
|
561
574
|
const kept = keptConfigs.get(path);
|
|
562
|
-
if (kept !== undefined && kept.stamp === stamp)
|
|
575
|
+
if (kept !== undefined && kept.stamp === stamp && modified < kept.readAt - RACY_MS)
|
|
563
576
|
return structuredClone(kept.config);
|
|
577
|
+
const readAt = Date.now();
|
|
564
578
|
const config = readConfigFileNow(path);
|
|
565
|
-
keptConfigs.set(path, { stamp, config });
|
|
579
|
+
keptConfigs.set(path, { stamp, config, readAt });
|
|
566
580
|
if (keptConfigs.size > 64)
|
|
567
581
|
keptConfigs.delete(keptConfigs.keys().next().value);
|
|
568
582
|
return structuredClone(config);
|
|
569
583
|
}
|
|
584
|
+
/** How long before it was read a config file must have last changed for its stamp to be trusted. */
|
|
585
|
+
const RACY_MS = 1_000;
|
|
570
586
|
const keptConfigs = new Map();
|
|
571
587
|
function readConfigFileNow(path) {
|
|
572
588
|
let parsed;
|
|
@@ -589,7 +605,6 @@ function readConfigFileNow(path) {
|
|
|
589
605
|
allowToStopJobs: typeof raw[CONFIG_KEYS.allowToStopJobs] === "boolean" ? raw[CONFIG_KEYS.allowToStopJobs] : undefined,
|
|
590
606
|
releaseAfterPulse: typeof raw[CONFIG_KEYS.releaseAfterPulse] === "boolean" ? raw[CONFIG_KEYS.releaseAfterPulse] : undefined,
|
|
591
607
|
sentinel: typeof raw[CONFIG_KEYS.sentinel] === "boolean" || raw[CONFIG_KEYS.sentinel] === "ask" ? raw[CONFIG_KEYS.sentinel] : undefined,
|
|
592
|
-
testAdvisor: typeof raw[CONFIG_KEYS.testAdvisor] === "boolean" ? raw[CONFIG_KEYS.testAdvisor] : undefined,
|
|
593
608
|
testDir: text(raw[CONFIG_KEYS.testDir]),
|
|
594
609
|
conformanceTests: typeof raw[CONFIG_KEYS.conformanceTests] === "boolean" ? raw[CONFIG_KEYS.conformanceTests] : undefined,
|
|
595
610
|
baseFolder: text(raw[CONFIG_KEYS.baseFolder]),
|
|
@@ -621,3 +636,33 @@ function readConfigFileNow(path) {
|
|
|
621
636
|
turnLimit: turnLimitSetting(raw[CONFIG_KEYS.turnLimit]),
|
|
622
637
|
};
|
|
623
638
|
}
|
|
639
|
+
/** Keys a config file is read for besides CONFIG_KEYS: the older spellings turri still takes. */
|
|
640
|
+
const OLDER_KEYS = ["model", "turn_limit"];
|
|
641
|
+
/**
|
|
642
|
+
* The keys of the project's own config files - config.turri.yaml and each module's - that turri reads nothing of: a setting
|
|
643
|
+
* turri no longer has (`test-advisor`), or one misspelt. Said as turri starts, so a setting the person thinks is on is
|
|
644
|
+
* not silently ignored. config.yaml is left out: it may be another tool's, with keys of its own.
|
|
645
|
+
*/
|
|
646
|
+
export function unknownConfigKeys(root) {
|
|
647
|
+
const known = new Set([...Object.values(CONFIG_KEYS), ...OLDER_KEYS]);
|
|
648
|
+
const found = [];
|
|
649
|
+
for (const file of namesIn(root).filter((name) => /^config\.turri(\.[^.]+)?\.yaml$/.test(name)).sort()) {
|
|
650
|
+
let parsed;
|
|
651
|
+
try {
|
|
652
|
+
parsed = loadYaml(readFileSync(join(root, file), "utf8"));
|
|
653
|
+
}
|
|
654
|
+
catch {
|
|
655
|
+
continue;
|
|
656
|
+
}
|
|
657
|
+
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed))
|
|
658
|
+
continue;
|
|
659
|
+
const keys = Object.keys(parsed).filter((key) => !known.has(key));
|
|
660
|
+
if (keys.length > 0)
|
|
661
|
+
found.push({ file, keys });
|
|
662
|
+
}
|
|
663
|
+
return found;
|
|
664
|
+
}
|
|
665
|
+
/** The banner's line for each config file with keys turri does not read. */
|
|
666
|
+
export function unknownConfigLines(root) {
|
|
667
|
+
return unknownConfigKeys(root).map(({ file, keys }) => `${file} has ${keys.length === 1 ? "a key" : "keys"} turri does not read - ${keys.join(", ")}: no setting turri has, so ${keys.length === 1 ? "it does" : "they do"} nothing. Take ${keys.length === 1 ? "it" : "them"} out, or see docs/config.md for the spelling.`);
|
|
668
|
+
}
|
package/dist/conform-cli.js
CHANGED
|
@@ -7,23 +7,33 @@ 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
|
|
11
|
-
as far as the size guardrail lets.
|
|
10
|
+
script: the refusal names the next step. Every functional spec tested goes in one pulse,
|
|
11
|
+
as far as the size guardrail lets. A functional spec named whose tests are written has them written
|
|
12
|
+
again: deleted and written anew from its scenarios, its code untouched.
|
|
12
13
|
|
|
13
14
|
--one-by-one a pulse a functional spec instead
|
|
15
|
+
--from-scratch take out the tests folder where the module's code lives - the tip of its chain - (its
|
|
16
|
+
lineage keeps it) and write the tests again, starting from a copy of the tests of the
|
|
17
|
+
module the tip requires; the code untouched
|
|
18
|
+
--from-scratch-chain the same, starting from nothing: every functional spec of the chain's tests written again
|
|
14
19
|
--harness-model <p/id> config.turri.yaml's harness-model for this run: the planner, a diagnosis
|
|
15
20
|
--coding-model <p/id> its coding-model, --model too: the agents that build
|
|
16
21
|
--judge-model <p/id> its judge-model: the judge and the test review
|
|
17
22
|
--review <true|false> its review: whether the code and its tests are reviewed once they pass
|
|
18
23
|
--build-dir <dir> as the run ends, export the code there (see turri regenerate --help)
|
|
19
24
|
--report <file.json> write a report of the run there (see turri regenerate --help)`;
|
|
20
|
-
const { positional, options } = parseArgs(process.argv.slice(2), ["--one-by-one"], USAGE, ["--build-dir", "--report", "--harness-model", "--judge-model", "--review"]);
|
|
25
|
+
const { positional, options } = parseArgs(process.argv.slice(2), ["--one-by-one", "--from-scratch", "--from-scratch-chain"], USAGE, ["--build-dir", "--report", "--harness-model", "--judge-model", "--review"]);
|
|
21
26
|
const { report, buildDir } = headlessOptions(options);
|
|
22
27
|
const [plainFile, ...funcIds] = positional;
|
|
23
28
|
if (plainFile === undefined) {
|
|
24
29
|
console.error(USAGE);
|
|
25
30
|
process.exit(1);
|
|
26
31
|
}
|
|
32
|
+
const scratch = options["from-scratch-chain"] !== undefined ? "chain" : options["from-scratch"] !== undefined ? "module" : undefined;
|
|
33
|
+
if (scratch !== undefined && funcIds.length > 0) {
|
|
34
|
+
console.error(`Name functional specs or --from-scratch${scratch === "chain" ? "-chain" : ""}, not both: from scratch writes every one of them again.`);
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
27
37
|
runLoop({
|
|
28
38
|
plainFile,
|
|
29
39
|
...(buildDir !== undefined ? { buildDir } : {}),
|
|
@@ -32,6 +42,7 @@ runLoop({
|
|
|
32
42
|
ask: (loop) => loop.conformance(plainFile, {
|
|
33
43
|
...(funcIds.length > 0 ? { funcIds } : {}),
|
|
34
44
|
...(options["one-by-one"] !== undefined ? { separately: true } : {}),
|
|
45
|
+
...(scratch !== undefined ? { fromScratch: scratch } : {}),
|
|
35
46
|
}),
|
|
36
47
|
}).catch((error) => {
|
|
37
48
|
console.error(error instanceof Error ? error.message : error);
|
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
import { type ToolDefinition } from "@earendil-works/pi-coding-agent";
|
|
2
1
|
/**
|
|
3
|
-
* Whether a project's functional specs are conformance tested: `conformance-tests:` in its config, a
|
|
4
|
-
* project's, false when unset.
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
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
|
+
* 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
|
+
* nothing of conformance testing runs - no conformance pulse, no conformance testing script, the
|
|
6
|
+
* chat's conform refused; the test plain files there are kept, and not tested. The chat never turns them on: it says why
|
|
7
|
+
* it wants them, and the person decides.
|
|
8
8
|
*/
|
|
9
|
-
/**
|
|
10
|
-
export declare const
|
|
11
|
-
/**
|
|
12
|
-
export declare const TURN_ON_TOOL = "turn_on_conformance_tests";
|
|
13
|
-
/** Whether a module's functional specs are conformance tested: its stack's `conformance-tests:` over the project's. */
|
|
9
|
+
/** Why the chat's conform, or a skill that writes the conformance testing script, is refused while they are off. */
|
|
10
|
+
export declare const CONFORMANCE_OFF_REFUSAL: string;
|
|
11
|
+
/** Whether a module's functional specs are conformance tested: its own file's `conformance-tests:` over the project's. */
|
|
14
12
|
export declare function conformanceTestsOn(plainFile: string): boolean;
|
|
15
|
-
/** 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. */
|
|
16
14
|
export declare function conformanceTestsOnIn(project: string): boolean;
|
|
17
15
|
/**
|
|
18
|
-
* Turn conformance testing on: `conformance-tests: true` written where the module's value comes from - its
|
|
19
|
-
* 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.
|
|
20
19
|
*/
|
|
21
20
|
export declare function turnOnConformanceTests(project: string, plainFile?: string): string;
|
|
22
21
|
/**
|
|
@@ -24,11 +23,3 @@ export declare function turnOnConformanceTests(project: string, plainFile?: stri
|
|
|
24
23
|
* turned on, and that it may offer it.
|
|
25
24
|
*/
|
|
26
25
|
export declare function conformanceBlock(on: boolean): string;
|
|
27
|
-
/**
|
|
28
|
-
* turn_on_conformance_tests: the chat turns conformance testing on, the person having asked for it or agreed to it.
|
|
29
|
-
* `turnOn` is the session's (extension.ts `turnOnConformance`): the setting written, every chat's tools switched - the
|
|
30
|
-
* file written, from the project.
|
|
31
|
-
*/
|
|
32
|
-
export declare function turnOnConformanceTestsTool(options: {
|
|
33
|
-
turnOn: (plainFile?: string) => string;
|
|
34
|
-
}): ToolDefinition;
|