@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/regenerate/loop.js
CHANGED
|
@@ -15,7 +15,7 @@ import { adoptDigests, chainTree, codeTree, conformanceTarget, CONFORM_AGAIN, ma
|
|
|
15
15
|
import { describeSpecDiffConformance, renderSpecDiffConformance } from "./conform.js";
|
|
16
16
|
import { conformanceDirFor } from "./conformance.js";
|
|
17
17
|
import { modulesRoot, projectRootOf } from "./paths.js";
|
|
18
|
-
import { configForSpec,
|
|
18
|
+
import { configForSpec, configModuleFor, moduleConfigFile, testDirOf, withConfigModule } from "../config.js";
|
|
19
19
|
import { describeSpecChange } from "./prompt.js";
|
|
20
20
|
import { resolveTemplateDirs } from "./paths.js";
|
|
21
21
|
import { builtTips, copyRequiredCode, copyRequiredTests, importingModules, isImportModule, newlyRequired, resolveRequiresChain, startFromScratch } from "./requires.js";
|
|
@@ -241,8 +241,8 @@ export function createWorkLoop(options) {
|
|
|
241
241
|
const tip = tipEntry(state);
|
|
242
242
|
return { project: projectRootOf(tip.buildDir), module: tip.moduleName, job };
|
|
243
243
|
};
|
|
244
|
-
/** `work` with the codebase's
|
|
245
|
-
const
|
|
244
|
+
/** `work` with the codebase's config pinned - its module's own file, or one it requires - once it is worked out. */
|
|
245
|
+
const withModuleConfig = (state, work) => (state.configModule !== undefined ? withConfigModule(state.configModule.name, work) : work());
|
|
246
246
|
const keyOf = (spec) => serializeTree(codeTree(spec.tree));
|
|
247
247
|
/** What a codebase is built from: its record, or - nothing built - what it starts from, the code of the module it requires. */
|
|
248
248
|
const builtOf = (state) => {
|
|
@@ -287,7 +287,7 @@ export function createWorkLoop(options) {
|
|
|
287
287
|
(spec.tree[TEST_REQUIREMENTS] ?? []).length > 0 && readRecord(tipEntry(state).buildDir) !== null && gapOf(state, spec) === undefined;
|
|
288
288
|
/**
|
|
289
289
|
* The step of adding tests a codebase skipped - its functional specs have scenarios, and it has no test reqs or no
|
|
290
|
-
* conformance testing script
|
|
290
|
+
* conformance testing script: no conformance pulse of it starts, in the loop or from conform, and it
|
|
291
291
|
* waits on that step until the spec or the scripts change.
|
|
292
292
|
*/
|
|
293
293
|
const gapOf = (state, spec) => {
|
|
@@ -302,7 +302,7 @@ export function createWorkLoop(options) {
|
|
|
302
302
|
const tip = tipEntry(state);
|
|
303
303
|
const root = projectRootFor(tip.plainFile, tip.buildDir);
|
|
304
304
|
// Lacking the script, or with one being written over: a pulse started now would run without it, or against the old one.
|
|
305
|
-
return scriptBeingWritten(root, kind,
|
|
305
|
+
return scriptBeingWritten(root, kind, configModuleFor(tip.plainFile));
|
|
306
306
|
};
|
|
307
307
|
/**
|
|
308
308
|
* The base folder a codebase started from, as its status says it. Counting the files still there looks at each, and the
|
|
@@ -630,7 +630,7 @@ export function createWorkLoop(options) {
|
|
|
630
630
|
}
|
|
631
631
|
// Nothing here yet, and nothing below: the codebase starts from its base folder, when the config names one.
|
|
632
632
|
if (tip.requires === null && !started(tip))
|
|
633
|
-
|
|
633
|
+
withModuleConfig(state, () => seedFromBaseFolder(tip.buildDir, tip.plainFile, tip.moduleName));
|
|
634
634
|
// A conformance job is shown the spec whole - its test reqs and scenarios are its to write from.
|
|
635
635
|
const result = await (conformance ? runConformance : run)({
|
|
636
636
|
plainFile: tip.plainFile,
|
|
@@ -912,7 +912,7 @@ export function createWorkLoop(options) {
|
|
|
912
912
|
// A codebase left behind - built on since - is not looked at, unless a job of it is still running; what it had
|
|
913
913
|
// planned, or waited for, is no longer shown.
|
|
914
914
|
if (now.has(state) || state.running !== undefined)
|
|
915
|
-
await
|
|
915
|
+
await withModuleConfig(state, () => look(state));
|
|
916
916
|
else {
|
|
917
917
|
state.why = "left behind: the code is built on further up the chain, where changes to it are made";
|
|
918
918
|
state.waitsFor = undefined;
|
|
@@ -1136,7 +1136,7 @@ export function createWorkLoop(options) {
|
|
|
1136
1136
|
}));
|
|
1137
1137
|
};
|
|
1138
1138
|
/** A codebase's status, and beside each job it lists as planned, the planned job it is - none for one being planned or scheduled. */
|
|
1139
|
-
const describe = (state) =>
|
|
1139
|
+
const describe = (state) => withModuleConfig(state, () => describeIn(state));
|
|
1140
1140
|
const describeIn = (state) => {
|
|
1141
1141
|
// What runs next: the code's jobs, then the conformance tests' - the module's, once its code is built - the running job first.
|
|
1142
1142
|
const running = state.running?.planned;
|
|
@@ -1192,7 +1192,7 @@ export function createWorkLoop(options) {
|
|
|
1192
1192
|
plainFile: tip.plainFile,
|
|
1193
1193
|
...(base !== undefined ? { base } : {}),
|
|
1194
1194
|
...(renames.length > 0 ? { renames: renames.map(renameText) } : {}),
|
|
1195
|
-
...(state.
|
|
1195
|
+
...(state.configModule?.name !== undefined ? { configModule: state.configModule.name } : {}),
|
|
1196
1196
|
...(state.running !== undefined
|
|
1197
1197
|
? {
|
|
1198
1198
|
running: {
|
|
@@ -1211,10 +1211,10 @@ export function createWorkLoop(options) {
|
|
|
1211
1211
|
return { status, jobs: shown.map((item) => item.job), ahead: shown.map((item) => (item.entry.afterCode === true ? { title: item.entry.title, specs: item.entry.specs ?? [] } : undefined)) };
|
|
1212
1212
|
};
|
|
1213
1213
|
/**
|
|
1214
|
-
* Look after a codebase - its chain up to it - from now on; says its state.
|
|
1215
|
-
*
|
|
1214
|
+
* Look after a codebase - its chain up to it - from now on; says its state. Its config is worked out again - its tip's
|
|
1215
|
+
* (`configModuleFor`): `asked`, one that cannot be told refuses the ask; otherwise it keeps the one it had.
|
|
1216
1216
|
*/
|
|
1217
|
-
const track = (chain, askedFile, request,
|
|
1217
|
+
const track = (chain, askedFile, request, asked = false) => {
|
|
1218
1218
|
const tip = tipOf(chain);
|
|
1219
1219
|
let state = modules.get(tip.buildDir);
|
|
1220
1220
|
if (state === undefined) {
|
|
@@ -1229,10 +1229,15 @@ export function createWorkLoop(options) {
|
|
|
1229
1229
|
}
|
|
1230
1230
|
state.chain = chain;
|
|
1231
1231
|
state.askedFile = askedFile;
|
|
1232
|
-
|
|
1233
|
-
state.
|
|
1234
|
-
|
|
1235
|
-
|
|
1232
|
+
try {
|
|
1233
|
+
state.configModule = { name: configModuleFor(tip.plainFile) };
|
|
1234
|
+
}
|
|
1235
|
+
catch (error) {
|
|
1236
|
+
if (asked)
|
|
1237
|
+
throw error;
|
|
1238
|
+
}
|
|
1239
|
+
// Its model as its config has it: a module's own file can name a coding model of its own.
|
|
1240
|
+
const model = request.model ?? withModuleConfig(state, () => options.modelFor?.(tip.plainFile));
|
|
1236
1241
|
if (model !== undefined)
|
|
1237
1242
|
state.model = model;
|
|
1238
1243
|
if (request.guidance !== undefined && !state.guidance.includes(request.guidance))
|
|
@@ -1248,8 +1253,7 @@ export function createWorkLoop(options) {
|
|
|
1248
1253
|
asked.set(file, { ...ahead.get(file), ...asked.get(file), ...given });
|
|
1249
1254
|
ahead.delete(file);
|
|
1250
1255
|
}
|
|
1251
|
-
// Asked for,
|
|
1252
|
-
// is chosen later.
|
|
1256
|
+
// Asked for, its config is worked out - its own file, or one of a module it requires - and pinned to its pulses.
|
|
1253
1257
|
const states = withParseCache(() => files.flatMap((file) => chainsFor(file).flatMap((chain) => toBuild(chain).map((entry) => track(chain.slice(0, chain.indexOf(entry) + 1), file, given, true)))));
|
|
1254
1258
|
// Asked again, a halted codebase is tried again - one the person halted too. Looked ahead at, its kept plan starts.
|
|
1255
1259
|
for (const state of states) {
|
|
@@ -1270,7 +1274,7 @@ export function createWorkLoop(options) {
|
|
|
1270
1274
|
for (const file of files)
|
|
1271
1275
|
if (!asked.has(file))
|
|
1272
1276
|
ahead.set(file, { ...ahead.get(file), ...given });
|
|
1273
|
-
// Its
|
|
1277
|
+
// Its config pinned as an ask pins it: the plan is made, and its pulses run, with the config regenerate would use.
|
|
1274
1278
|
const tracked = withParseCache(() => files.flatMap((file) => chainsFor(file).flatMap((chain) => toBuild(chain).map((entry) => track(chain.slice(0, chain.indexOf(entry) + 1), file, given, true)))));
|
|
1275
1279
|
// A chain with a pulse running is being built as asked, and goes on; every other codebase is held - one asked for
|
|
1276
1280
|
// earlier too, which would otherwise start the work the look ahead plans.
|
|
@@ -1325,7 +1329,7 @@ export function createWorkLoop(options) {
|
|
|
1325
1329
|
if (state.plan === undefined || !state.plan.jobs.includes(job) || state.plan.specKey !== keyOf(spec) || state.plan.steeringKey !== steeringKeyOf(state)) {
|
|
1326
1330
|
return why("The ***plain or the steering changed since it was planned: regenerate would plan it again. Look ahead again to see the new plan.");
|
|
1327
1331
|
}
|
|
1328
|
-
const task = await
|
|
1332
|
+
const task = await withModuleConfig(state, () => promptOf({ plainFile: tip.plainFile, spec: { ...spec, tree: job.step.tree }, planned: job }));
|
|
1329
1333
|
return task !== undefined ? { ...pulse, task } : why("It has no prompt to show.");
|
|
1330
1334
|
},
|
|
1331
1335
|
async regenerateAgain(plainFile, given, request = {}) {
|
|
@@ -1384,7 +1388,7 @@ export function createWorkLoop(options) {
|
|
|
1384
1388
|
const tip = tipOf(codebase);
|
|
1385
1389
|
// The codebase as the loop knows it, or - never asked for - as its records have it.
|
|
1386
1390
|
const state = modules.get(tip.buildDir) ?? { chain: codebase, askedFile: file, guidance: [] };
|
|
1387
|
-
return
|
|
1391
|
+
return withModuleConfig(state, () => {
|
|
1388
1392
|
const report = { module: tip.moduleName, plainFile: tip.plainFile, code: undefined, conformance: undefined, ...(conformanceTestsOn(tip.plainFile) ? {} : { conformanceOff: true }) };
|
|
1389
1393
|
let spec;
|
|
1390
1394
|
try {
|
|
@@ -1880,7 +1884,7 @@ function conformanceAskedIn(own, funcIds) {
|
|
|
1880
1884
|
"Their tests are written once the code is built. Nothing was started.");
|
|
1881
1885
|
}
|
|
1882
1886
|
}
|
|
1883
|
-
// A step of adding tests skipped - its test reqs, or the conformance testing script
|
|
1887
|
+
// A step of adding tests skipped - its test reqs, or the conformance testing script: refused, naming it.
|
|
1884
1888
|
const gap = testingGap({ moduleName: self.moduleName, plainFile: self.plainFile, tree: spec, buildDir: self.buildDir });
|
|
1885
1889
|
if (gap !== undefined)
|
|
1886
1890
|
throw new Error(`${gap.text} Nothing was started.`);
|
|
@@ -1964,7 +1968,7 @@ export function describeModules(statuses, options = {}) {
|
|
|
1964
1968
|
// Nothing to do there: said in a sentence, not as a status.
|
|
1965
1969
|
if (isUpToDate(status))
|
|
1966
1970
|
return `${status.module} is up to date: its code is built from the ***plain as it is now in ${basename(status.plainFile)}, so there is nothing to regenerate.`;
|
|
1967
|
-
const lines = [`${status.module} (${basename(status.plainFile)}${status.
|
|
1971
|
+
const lines = [`${status.module} (${basename(status.plainFile)}${status.configModule !== undefined ? `, built with ${moduleConfigFile(status.configModule)}` : ""}):`];
|
|
1968
1972
|
if (status.running !== undefined) {
|
|
1969
1973
|
lines.push(` running: pulse ${status.running.jobId} - ${status.running.title}`);
|
|
1970
1974
|
// Steered, not stopped or planned again: what changed went to its agent.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A model named as the person said it - "gpt 5.5", "gemini flash" - resolved to the one it means: for a pulse a call
|
|
3
|
+
* names a model for, and for a model written into the config with the settings tool.
|
|
4
|
+
*
|
|
5
|
+
* A name is resolved strictly. pi's own pattern matching picks its best guess and says nothing
|
|
6
|
+
* - "gpt-5" becomes a Bedrock model with no credentials, "flash" a GLM one - and a job on a
|
|
7
|
+
* guessed model is worse than a question. So an exact id is taken as it is, a looser name is
|
|
8
|
+
* taken only when it fits exactly one model that has credentials, and anything else comes back
|
|
9
|
+
* as a short list to ask the person about.
|
|
10
|
+
*/
|
|
11
|
+
/** The part of pi's model registry this needs. */
|
|
12
|
+
export interface ModelCatalog {
|
|
13
|
+
getAll(): ReadonlyArray<CatalogModel>;
|
|
14
|
+
hasConfiguredAuth(model: CatalogModel): boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface CatalogModel {
|
|
17
|
+
provider: string;
|
|
18
|
+
id: string;
|
|
19
|
+
name?: string;
|
|
20
|
+
}
|
|
21
|
+
export type ModelResolution = {
|
|
22
|
+
ok: true;
|
|
23
|
+
model: string;
|
|
24
|
+
name: string;
|
|
25
|
+
} | {
|
|
26
|
+
ok: false;
|
|
27
|
+
message: string;
|
|
28
|
+
candidates: string[];
|
|
29
|
+
};
|
|
30
|
+
/** Resolve what the person called a model to one this machine can run, or say why not. */
|
|
31
|
+
export declare function resolveModel(query: string, catalog: ModelCatalog): ModelResolution;
|
|
32
|
+
/** The resolution as text for the agent: the model, or why not and what to ask. */
|
|
33
|
+
export declare function describeResolution(resolution: ModelResolution): string;
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* By default, whatever the conversation is using. The person can say otherwise - "render spec
|
|
5
|
-
* changes with Gemini Flash" - for one kind of work or for all of it, and that holds for the
|
|
6
|
-
* rest of the session, for jobs started from a tool call and for jobs a skill queues alike. A
|
|
7
|
-
* single tool call can also name a model for itself alone.
|
|
2
|
+
* A model named as the person said it - "gpt 5.5", "gemini flash" - resolved to the one it means: for a pulse a call
|
|
3
|
+
* names a model for, and for a model written into the config with the settings tool.
|
|
8
4
|
*
|
|
9
5
|
* A name is resolved strictly. pi's own pattern matching picks its best guess and says nothing
|
|
10
6
|
* - "gpt-5" becomes a Bedrock model with no credentials, "flash" a GLM one - and a job on a
|
|
@@ -94,25 +90,3 @@ export function describeResolution(resolution) {
|
|
|
94
90
|
return `${resolution.model} (${resolution.name})`;
|
|
95
91
|
return [resolution.message, ...resolution.candidates.map((candidate) => `- ${candidate}`)].join("\n");
|
|
96
92
|
}
|
|
97
|
-
export const WORK_LABEL = {
|
|
98
|
-
spec_changes: "spec changes",
|
|
99
|
-
functionalities: "functionalities",
|
|
100
|
-
all: "everything",
|
|
101
|
-
};
|
|
102
|
-
/** The model a job of this kind runs on: chosen for it, chosen for everything, or the chat's. */
|
|
103
|
-
export function modelFor(choices, work, chat) {
|
|
104
|
-
return choices[work] ?? choices.all ?? chat;
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Where each kind of work runs now, in a line each: chosen in this session, or the default coding
|
|
108
|
-
* model - from `--coding-model` or config.turri.yaml, said which - or the conversation's.
|
|
109
|
-
*/
|
|
110
|
-
export function describeChoices(choices, chat, project) {
|
|
111
|
-
const fallback = project !== undefined ? `${project.model} (${project.from})` : `${chat ?? "pi's default model"} (the chat's model)`;
|
|
112
|
-
return ["spec_changes", "functionalities"]
|
|
113
|
-
.map((work) => {
|
|
114
|
-
const chosen = choices[work] ?? choices.all;
|
|
115
|
-
return `- ${WORK_LABEL[work]}: ${chosen ?? fallback}`;
|
|
116
|
-
})
|
|
117
|
-
.join("\n");
|
|
118
|
-
}
|
|
@@ -30,7 +30,7 @@ export declare function defaultBuildDir(moduleName: string, cwd?: string): strin
|
|
|
30
30
|
*/
|
|
31
31
|
/**
|
|
32
32
|
* The project a spec belongs to: the nearest folder, from the spec's own up, that holds a
|
|
33
|
-
* `config.turri.yaml`, a
|
|
33
|
+
* `config.turri.yaml`, a module's `config.turri.<module>.yaml`, the `config.yaml` turri read before it had a file of
|
|
34
34
|
* its own, or a `plain_modules` - where its code is built, its config read, its testing scripts found. Without any, the
|
|
35
35
|
* spec's own folder. So `plain/hubspot.plain`, beside `plain/config.turri.yaml` and `plain/plain_modules`, is built there,
|
|
36
36
|
* wherever turri was started;
|
package/dist/regenerate/paths.js
CHANGED
|
@@ -37,7 +37,7 @@ export function defaultBuildDir(moduleName, cwd = process.cwd()) {
|
|
|
37
37
|
*/
|
|
38
38
|
/**
|
|
39
39
|
* The project a spec belongs to: the nearest folder, from the spec's own up, that holds a
|
|
40
|
-
* `config.turri.yaml`, a
|
|
40
|
+
* `config.turri.yaml`, a module's `config.turri.<module>.yaml`, the `config.yaml` turri read before it had a file of
|
|
41
41
|
* its own, or a `plain_modules` - where its code is built, its config read, its testing scripts found. Without any, the
|
|
42
42
|
* spec's own folder. So `plain/hubspot.plain`, beside `plain/config.turri.yaml` and `plain/plain_modules`, is built there,
|
|
43
43
|
* wherever turri was started;
|
|
@@ -56,7 +56,7 @@ export function projectDirOf(plainFile) {
|
|
|
56
56
|
export function isProjectDir(dir) {
|
|
57
57
|
return existsSync(join(dir, "config.yaml")) || existsSync(join(dir, MODULES_DIR)) || hasModuleConfig(dir);
|
|
58
58
|
}
|
|
59
|
-
/** Whether a folder holds a config file - config.turri.yaml, a
|
|
59
|
+
/** Whether a folder holds a config file - config.turri.yaml, a module's config.turri.<module>.yaml, or one in the old naming - which makes it a project too. */
|
|
60
60
|
function hasModuleConfig(dir) {
|
|
61
61
|
try {
|
|
62
62
|
return readdirSync(dir).some((name) => /^config\..+\.yaml$/.test(name));
|
|
@@ -8,12 +8,12 @@ export interface ScriptBeingWritten {
|
|
|
8
8
|
/** The project's folder. */
|
|
9
9
|
project: string;
|
|
10
10
|
kind: ScriptKind;
|
|
11
|
-
/** The
|
|
12
|
-
|
|
11
|
+
/** The module whose config file it is named in, when the run was for one: its own, or one it requires. */
|
|
12
|
+
configModule?: string;
|
|
13
13
|
}
|
|
14
14
|
/** A script being written from now: what it returns says it is no longer, written or not. */
|
|
15
15
|
export declare function writingScript(run: ScriptBeingWritten): () => void;
|
|
16
|
-
/** Whether a script of this kind is being written for a module of this project
|
|
17
|
-
export declare function scriptBeingWritten(project: string, kind: ScriptKind,
|
|
16
|
+
/** Whether a script of this kind is being written for a module of this project built with this module's config file - one written for none is anyone's. */
|
|
17
|
+
export declare function scriptBeingWritten(project: string, kind: ScriptKind, configModule?: string): boolean;
|
|
18
18
|
/** Told each time a run writing a script ends. Returns what stops it. */
|
|
19
19
|
export declare function onScriptRunEnded(listener: () => void): () => void;
|
|
@@ -18,10 +18,10 @@ export function writingScript(run) {
|
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
|
-
/** Whether a script of this kind is being written for a module of this project
|
|
22
|
-
export function scriptBeingWritten(project, kind,
|
|
21
|
+
/** Whether a script of this kind is being written for a module of this project built with this module's config file - one written for none is anyone's. */
|
|
22
|
+
export function scriptBeingWritten(project, kind, configModule) {
|
|
23
23
|
const folder = resolve(project);
|
|
24
|
-
return [...writing().runs].some((run) => run.project === folder && run.kind === kind && (run.
|
|
24
|
+
return [...writing().runs].some((run) => run.project === folder && run.kind === kind && (run.configModule === undefined || configModule === undefined || run.configModule === configModule));
|
|
25
25
|
}
|
|
26
26
|
/** Told each time a run writing a script ends. Returns what stops it. */
|
|
27
27
|
export function onScriptRunEnded(listener) {
|
|
@@ -60,7 +60,8 @@ export declare function projectRootFor(plainFile: string, buildDir: string): str
|
|
|
60
60
|
/**
|
|
61
61
|
* The project's testing scripts, looked for in this order:
|
|
62
62
|
*
|
|
63
|
-
* 1. `config.turri.yaml` at the project root, with the
|
|
63
|
+
* 1. `config.turri.yaml` at the project root, with the module's own `config.turri.<module>.yaml` over it - or the one of a
|
|
64
|
+
* module it requires (`configModuleFor`) -
|
|
64
65
|
* `unittests-script:` and `conformance-tests-script:`, paths from the root;
|
|
65
66
|
* 2. the project root itself - the one `run_unittests*.sh` / `run_conformance_tests*.sh` there;
|
|
66
67
|
* 3. `test_scripts/` - the one of each there.
|
|
@@ -2,7 +2,7 @@ import { fixMethod } from "./prompt.js";
|
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
3
|
import { accessSync, constants, copyFileSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
4
4
|
import { basename, delimiter, dirname, join, resolve, sep } from "node:path";
|
|
5
|
-
import { CONFIG_FILE, CONFIG_KEYS,
|
|
5
|
+
import { CONFIG_FILE, CONFIG_KEYS, configModuleFor, configModuleOf, configModulePinned, moduleConfigFile, moduleConfigFileIn, moduleConfigsOf, projectConfigFile, readProjectConfig } from "../config.js";
|
|
6
6
|
import { reportActivity, reportLogNote, reportNote } from "./activity.js";
|
|
7
7
|
import { record, signatureHash } from "./ledger.js";
|
|
8
8
|
import { ensureInModulesScratch, modulesScratchDir } from "./paths.js";
|
|
@@ -68,7 +68,8 @@ function onlyScriptIn(dir, kind) {
|
|
|
68
68
|
/**
|
|
69
69
|
* The project's testing scripts, looked for in this order:
|
|
70
70
|
*
|
|
71
|
-
* 1. `config.turri.yaml` at the project root, with the
|
|
71
|
+
* 1. `config.turri.yaml` at the project root, with the module's own `config.turri.<module>.yaml` over it - or the one of a
|
|
72
|
+
* module it requires (`configModuleFor`) -
|
|
72
73
|
* `unittests-script:` and `conformance-tests-script:`, paths from the root;
|
|
73
74
|
* 2. the project root itself - the one `run_unittests*.sh` / `run_conformance_tests*.sh` there;
|
|
74
75
|
* 3. `test_scripts/` - the one of each there.
|
|
@@ -82,18 +83,18 @@ function onlyScriptIn(dir, kind) {
|
|
|
82
83
|
export function findTestScripts(root, plainFile, buildDir) {
|
|
83
84
|
const found = {};
|
|
84
85
|
const notes = {};
|
|
85
|
-
// The
|
|
86
|
-
const
|
|
87
|
-
const config = readProjectConfig(root,
|
|
88
|
-
const file =
|
|
89
|
-
//
|
|
90
|
-
const
|
|
91
|
-
// Where a script is named: the
|
|
92
|
-
const nameIn =
|
|
93
|
-
?
|
|
94
|
-
:
|
|
95
|
-
? "the config.turri.<
|
|
96
|
-
: `${CONFIG_FILE} - or
|
|
86
|
+
// The module's own file over the project's - the one pinned, else the one of the module asked about: its scripts.
|
|
87
|
+
const own = configModulePinned() ? configModuleOf(root) : plainFile !== undefined ? moduleOfSpec(plainFile) : undefined;
|
|
88
|
+
const config = readProjectConfig(root, own);
|
|
89
|
+
const file = own !== undefined ? `${moduleConfigFileIn(root, own)} (over ${projectConfigFile(root)})` : projectConfigFile(root);
|
|
90
|
+
// Modules with files of their own, none of them this one's: its scripts are likely named in theirs.
|
|
91
|
+
const others = own === undefined ? moduleConfigsOf(root) : [];
|
|
92
|
+
// Where a script is named: the module's own file - or, where modules have their own, the one of the module that builds it.
|
|
93
|
+
const nameIn = own !== undefined
|
|
94
|
+
? moduleConfigFileIn(root, own)
|
|
95
|
+
: others.length > 0
|
|
96
|
+
? "the module's own config.turri.<module>.yaml"
|
|
97
|
+
: `${CONFIG_FILE} - or the module's own config.turri.<module>.yaml`;
|
|
97
98
|
if (config.testingScriptsRunOn !== undefined)
|
|
98
99
|
found.runOn = config.testingScriptsRunOn;
|
|
99
100
|
for (const kind of Object.keys(SCRIPT_KEYS)) {
|
|
@@ -146,19 +147,19 @@ export function findTestScripts(root, plainFile, buildDir) {
|
|
|
146
147
|
}
|
|
147
148
|
}
|
|
148
149
|
}
|
|
149
|
-
//
|
|
150
|
-
if (
|
|
150
|
+
// Modules with files of their own, none of them this one's: the note says which name a script, and where its own goes.
|
|
151
|
+
if (others.length > 0) {
|
|
151
152
|
for (const kind of Object.keys(SCRIPT_KEYS)) {
|
|
152
153
|
if (found[kind] !== undefined)
|
|
153
154
|
continue;
|
|
154
|
-
const named =
|
|
155
|
+
const named = others.flatMap((each) => {
|
|
155
156
|
const script = kind === "unit" ? readProjectConfig(root, each).unittestsScript : readProjectConfig(root, each).conformanceTestsScript;
|
|
156
|
-
return script !== undefined ? [`${
|
|
157
|
+
return script !== undefined ? [`${moduleConfigFile(each)} names ${script.trim()}`] : [];
|
|
157
158
|
});
|
|
158
159
|
notes[kind] = [
|
|
159
160
|
...(notes[kind] !== undefined ? [notes[kind]] : []),
|
|
160
|
-
`No
|
|
161
|
-
"
|
|
161
|
+
`No module config file applies here, so ${CONFIG_FILE} alone is read - the modules' own are ${others.map(moduleConfigFile).join(", ")}${named.length > 0 ? `, and ${named.join("; ")}` : ""}. ` +
|
|
162
|
+
"A module takes its own config.turri.<module>.yaml, else the one of a module it requires: name its scripts in its own file - in the chat, the settings tool with module.",
|
|
162
163
|
].join(" ");
|
|
163
164
|
}
|
|
164
165
|
}
|
|
@@ -199,7 +200,7 @@ export class MissingTestScriptError extends Error {
|
|
|
199
200
|
"What to change in the project:",
|
|
200
201
|
`- Add one with the \`${skill}\` skill: it writes \`${SCRIPTS_DIR}/${file}_<language>.sh\`.`,
|
|
201
202
|
`- It is looked for in \`${CONFIG_FILE}\` at the project root (\`${SCRIPT_KEYS[kind]}: <path>\`) - or the module's own`,
|
|
202
|
-
` \`config.turri.<
|
|
203
|
+
` \`config.turri.<module>.yaml\` beside it, or the one of a module it requires - then in the root,`,
|
|
203
204
|
` then in \`${SCRIPTS_DIR}/\` - one ${file}*.sh in either folder is used.`,
|
|
204
205
|
"",
|
|
205
206
|
"Then build again.",
|
|
@@ -332,8 +333,8 @@ function projectOfBuild(buildDir) {
|
|
|
332
333
|
const parts = resolve(buildDir).split(sep);
|
|
333
334
|
const index = parts.lastIndexOf("plain_modules");
|
|
334
335
|
const root = index > 0 ? parts.slice(0, index).join(sep) : dirname(resolve(buildDir));
|
|
335
|
-
// The
|
|
336
|
-
return { root, inPlace: readProjectConfig(root,
|
|
336
|
+
// The module's own file decides, when it says.
|
|
337
|
+
return { root, inPlace: readProjectConfig(root, configModuleOf(root)).testingScriptsRunOn !== "copy" };
|
|
337
338
|
}
|
|
338
339
|
/** The model providers' keys, kept out of what runs on this machine: the tests are agents' code. */
|
|
339
340
|
const PROVIDER_KEY = /^(ANTHROPIC|OPENAI|AZURE_OPENAI|GEMINI|GOOGLE|GOOGLE_GENERATIVE_AI|MISTRAL|GROQ|XAI|OPENROUTER|DEEPSEEK|CEREBRAS|TOGETHER|FIREWORKS)_API_KEY$|^AWS_BEARER_TOKEN_BEDROCK$/;
|
|
@@ -812,3 +813,12 @@ export function failureSignature(run) {
|
|
|
812
813
|
.replace(/\s+/g, " ");
|
|
813
814
|
return [...new Set((telling.length > 0 ? telling : lines.slice(-20)).map(normal))].slice(0, 30).join("\n");
|
|
814
815
|
}
|
|
816
|
+
/** The module whose config file builds a module, for finding its scripts - none when it cannot be told: the parse says why. */
|
|
817
|
+
function moduleOfSpec(plainFile) {
|
|
818
|
+
try {
|
|
819
|
+
return configModuleFor(plainFile);
|
|
820
|
+
}
|
|
821
|
+
catch {
|
|
822
|
+
return undefined;
|
|
823
|
+
}
|
|
824
|
+
}
|
|
@@ -2,7 +2,7 @@ import { type MarshalledPlainSource } from "../plain/spec.ts";
|
|
|
2
2
|
/**
|
|
3
3
|
* The steps of adding tests to a module, and the one it skipped. Nothing about testing exists until the person asks
|
|
4
4
|
* for it; then, in order: its test reqs - the stack's conformance template, or its own - the conformance testing script
|
|
5
|
-
* for
|
|
5
|
+
* for it, and the scenarios in its test plain files. A module whose functional specs have scenarios but which
|
|
6
6
|
* skipped one of the first two has its conformance pulses refused - by the work loop and by `conform` alike - and
|
|
7
7
|
* `parse` and the map say what is missing. A module with no scenarios skipped nothing: it is not tested.
|
|
8
8
|
*/
|
|
@@ -20,8 +20,8 @@ export interface TestingGap {
|
|
|
20
20
|
*/
|
|
21
21
|
export declare function conformanceTemplateOf(plainFile: string): string | undefined;
|
|
22
22
|
/**
|
|
23
|
-
* The conformance testing script a module's tests would run with, looked for
|
|
24
|
-
*
|
|
23
|
+
* The conformance testing script a module's tests would run with, looked for with its config - the one pinned, else the
|
|
24
|
+
* one `configModuleFor` gives it - or nothing, with why when there is a why.
|
|
25
25
|
*/
|
|
26
26
|
export declare function conformanceScriptOf(plainFile: string, buildDir?: string): {
|
|
27
27
|
script?: string;
|
|
@@ -29,9 +29,9 @@ export declare function conformanceScriptOf(plainFile: string, buildDir?: string
|
|
|
29
29
|
};
|
|
30
30
|
/**
|
|
31
31
|
* The step of adding tests a module skipped, when its functional specs have scenarios: no test reqs - its own or
|
|
32
|
-
* imported - or no conformance testing script
|
|
32
|
+
* imported - or no conformance testing script. `tree` is what its conformance tests would be written from:
|
|
33
33
|
* the codebase's spec, the module's own sections with its imports in, and the functional specs it inherits. The script
|
|
34
|
-
* is looked for
|
|
34
|
+
* is looked for with the module's config - the one pinned, else the one `configModuleFor` gives it.
|
|
35
35
|
*/
|
|
36
36
|
export declare function testingGap(input: {
|
|
37
37
|
moduleName: string;
|
|
@@ -41,7 +41,7 @@ export declare function testingGap(input: {
|
|
|
41
41
|
}): TestingGap | undefined;
|
|
42
42
|
/**
|
|
43
43
|
* The steps of adding tests a module still has to take before it has anything to test - in their order: its test reqs,
|
|
44
|
-
*
|
|
44
|
+
* its conformance testing script, the scenarios - from the first one missing. What is said when conform
|
|
45
45
|
* finds no scenarios: the whole way there, not the last step alone.
|
|
46
46
|
*/
|
|
47
47
|
export declare function stepsToScenarios(input: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { existsSync, readFileSync } from "node:fs";
|
|
2
2
|
import { dirname, join, relative, resolve } from "node:path";
|
|
3
3
|
import { conformanceTestsOn } from "../conformance-switch.js";
|
|
4
|
-
import {
|
|
4
|
+
import { configModuleFor, configModulePinned, testDirOf, withConfigModule } from "../config.js";
|
|
5
5
|
import { IMPORT_DIRECTIVE, readPlainSourceMetadata } from "../plain/parser.js";
|
|
6
6
|
import { FUNCTIONAL_REQUIREMENTS, REQUIRED_FUNCTIONAL_SPECS, TEST_REQUIREMENTS } from "../plain/spec.js";
|
|
7
7
|
import { isStdlibModule, STDLIB_ROOT } from "../plain/stdlib.js";
|
|
@@ -50,16 +50,16 @@ export function conformanceTemplateOf(plainFile) {
|
|
|
50
50
|
return conformance !== undefined && existsSync(join(STDLIB_ROOT, `${conformance}.plain`)) ? conformance : undefined;
|
|
51
51
|
}
|
|
52
52
|
/**
|
|
53
|
-
* The conformance testing script a module's tests would run with, looked for
|
|
54
|
-
*
|
|
53
|
+
* The conformance testing script a module's tests would run with, looked for with its config - the one pinned, else the
|
|
54
|
+
* one `configModuleFor` gives it - or nothing, with why when there is a why.
|
|
55
55
|
*/
|
|
56
56
|
export function conformanceScriptOf(plainFile, buildDir) {
|
|
57
|
-
const
|
|
57
|
+
const configModule = configModulePinned() ? undefined : configModuleFor(plainFile);
|
|
58
58
|
const scripts = () => {
|
|
59
59
|
const root = buildDir !== undefined ? projectRootFor(plainFile, buildDir) : projectDirOf(plainFile);
|
|
60
60
|
return findTestScripts(root, plainFile, buildDir);
|
|
61
61
|
};
|
|
62
|
-
const found =
|
|
62
|
+
const found = configModulePinned() ? scripts() : withConfigModule(configModule, scripts);
|
|
63
63
|
return { ...(found.conformance !== undefined ? { script: found.conformance } : {}), ...(found.notes?.conformance !== undefined ? { note: found.notes.conformance } : {}) };
|
|
64
64
|
}
|
|
65
65
|
/** The functional specs of a codebase's tree - its own, or ones it inherits - that have scenarios, as `module:func-id`, a module below's first. */
|
|
@@ -73,9 +73,9 @@ function named(specs) {
|
|
|
73
73
|
}
|
|
74
74
|
/**
|
|
75
75
|
* The step of adding tests a module skipped, when its functional specs have scenarios: no test reqs - its own or
|
|
76
|
-
* imported - or no conformance testing script
|
|
76
|
+
* imported - or no conformance testing script. `tree` is what its conformance tests would be written from:
|
|
77
77
|
* the codebase's spec, the module's own sections with its imports in, and the functional specs it inherits. The script
|
|
78
|
-
* is looked for
|
|
78
|
+
* is looked for with the module's config - the one pinned, else the one `configModuleFor` gives it.
|
|
79
79
|
*/
|
|
80
80
|
export function testingGap(input) {
|
|
81
81
|
const { moduleName, plainFile } = input;
|
|
@@ -110,7 +110,7 @@ export function testingGap(input) {
|
|
|
110
110
|
}
|
|
111
111
|
/**
|
|
112
112
|
* The steps of adding tests a module still has to take before it has anything to test - in their order: its test reqs,
|
|
113
|
-
*
|
|
113
|
+
* its conformance testing script, the scenarios - from the first one missing. What is said when conform
|
|
114
114
|
* finds no scenarios: the whole way there, not the last step alone.
|
|
115
115
|
*/
|
|
116
116
|
export function stepsToScenarios(input) {
|
|
@@ -1,21 +1,26 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ExtensionAPI, type ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
import { type Setting } from "./config-edit.ts";
|
|
3
3
|
/**
|
|
4
|
-
* `/
|
|
5
|
-
* `/
|
|
4
|
+
* `/settings`: every setting of the project's config.turri.yaml from the chat - `/settings` alone lists them,
|
|
5
|
+
* `/settings review` asks for review's value, `/settings review false` sets it. Each is written into the file
|
|
6
6
|
* and takes effect as it says - now, at your next message, at the next pulse - never only once turri starts again:
|
|
7
|
-
* what turri fixes at its start is changed live here (live).
|
|
7
|
+
* what turri fixes at its start is changed live here (live). It takes pi's own /settings over (pi-settings.ts), whose
|
|
8
|
+
* menu is its last entry.
|
|
9
|
+
*
|
|
10
|
+
* The chat's `settings` tool reads them and changes them as the person asks - into config.turri.yaml, or a module's
|
|
11
|
+
* own config.turri.<module>.yaml - a model checked as it is written, by the name the person said. What is the person's
|
|
12
|
+
* alone (`personOnly`) it refuses, and points to /settings.
|
|
8
13
|
*/
|
|
9
14
|
/** What a change does to turri as it runs, beside the file: each says what it did, or nothing. */
|
|
10
15
|
export interface LiveHooks {
|
|
11
16
|
/** The chat's model is now this - provider/id:thinking - or, undefined, no longer set in the file. */
|
|
12
17
|
chatModel(spec: string | undefined, ctx: ExtensionContext): Promise<string | undefined>;
|
|
13
|
-
/** The coding model changed in the file: one
|
|
18
|
+
/** The coding model changed in the file: one given for this session - --coding-model - gives way to it. */
|
|
14
19
|
codingModel(): string | undefined;
|
|
15
20
|
/** How many pulses run at once: the number, or the machine's default. */
|
|
16
21
|
parallelJobs(count: number | undefined): string | undefined;
|
|
17
22
|
}
|
|
18
|
-
export interface
|
|
23
|
+
export interface SettingsOptions {
|
|
19
24
|
/** The folder whose config.turri.yaml the chat reads. */
|
|
20
25
|
cwd: string;
|
|
21
26
|
/** The ***plain rules there are, by name - what rules-off takes. */
|
|
@@ -27,7 +32,7 @@ export interface TurriConfigOptions {
|
|
|
27
32
|
/** The models pi can reach here, signed in: provider/id - from a chat's context, the model registry the chats use. */
|
|
28
33
|
export declare function reachable(ctx: ExtensionContext | undefined): string[];
|
|
29
34
|
/**
|
|
30
|
-
* Every value /
|
|
35
|
+
* Every value /settings offers for a setting after what is typed, in its order - "unset" left out, and uncapped: what
|
|
31
36
|
* its completions show, the first of them, and what a host's settings list shows (host-session.ts `settingChoices`).
|
|
32
37
|
* A model setting's are every model pi can reach, signed in - `models` - and after a colon, that model's thinking levels.
|
|
33
38
|
*/
|
|
@@ -37,4 +42,4 @@ export declare function settingCandidates(setting: Setting, typed: string, where
|
|
|
37
42
|
}): string[];
|
|
38
43
|
/** The ***plain rules there are, by name - what rules-off takes, and its values. */
|
|
39
44
|
export declare function ruleNames(): string[];
|
|
40
|
-
export declare function
|
|
45
|
+
export declare function registerSettings(pi: ExtensionAPI, options: SettingsOptions): void;
|