@turri-dev/cli 0.2.4-next.35ab04b → 0.2.4-next.636a651
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 +2 -2
- package/dist/chat-idle.d.ts +2 -2
- package/dist/chat-idle.js +2 -2
- package/dist/chats.d.ts +0 -10
- package/dist/chats.js +0 -23
- package/dist/cli.js +5 -7
- package/dist/config-edit.js +1 -3
- package/dist/config.d.ts +20 -22
- package/dist/config.js +49 -22
- package/dist/conformance-switch.d.ts +7 -17
- package/dist/conformance-switch.js +24 -46
- package/dist/drift-cli.js +1 -1
- package/dist/extension.d.ts +8 -10
- package/dist/extension.js +157 -217
- package/dist/genome.js +9 -48
- package/dist/graph.js +3 -5
- package/dist/host-session.d.ts +4 -15
- package/dist/host-session.js +2 -4
- package/dist/host.d.ts +1 -3
- package/dist/host.js +1 -4
- package/dist/identity.js +0 -1
- package/dist/init-config.d.ts +0 -1
- package/dist/init-config.js +2 -9
- 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 +26 -3
- package/dist/loop-tools.js +85 -20
- package/dist/new-project.js +2 -2
- package/dist/pi-launch.js +1 -1
- package/dist/pi.js +9 -6
- package/dist/plain/check.d.ts +1 -8
- package/dist/plain/check.js +3 -38
- package/dist/regenerate/activity.d.ts +0 -7
- package/dist/regenerate/activity.js +2 -20
- package/dist/regenerate/agent-shell.js +3 -1
- package/dist/regenerate/audit.js +9 -0
- package/dist/regenerate/chunk-plan.d.ts +5 -0
- package/dist/regenerate/chunk-plan.js +16 -1
- 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 +2 -0
- package/dist/regenerate/jobs.js +4 -0
- package/dist/regenerate/ledger-view.d.ts +11 -24
- package/dist/regenerate/ledger-view.js +14 -60
- package/dist/regenerate/ledger.d.ts +1 -14
- package/dist/regenerate/ledger.js +1 -1
- package/dist/regenerate/loop.d.ts +37 -60
- package/dist/regenerate/loop.js +174 -106
- package/dist/regenerate/regenerate.d.ts +0 -2
- package/dist/regenerate/regenerate.js +4 -15
- 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/testing-steps.d.ts +11 -0
- package/dist/regenerate/testing-steps.js +22 -3
- 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/skill.d.ts +0 -11
- package/dist/skill.js +0 -9
- package/dist/stacks.js +1 -1
- package/dist/tools.js +2 -3
- package/dist/turri-versions.js +2 -1
- package/docs/README.md +0 -2
- package/docs/authoring-plain.md +3 -3
- package/docs/chats.md +1 -3
- package/docs/config.md +11 -13
- package/docs/deploy.md +1 -1
- package/docs/development.md +2 -3
- package/docs/headless.md +5 -4
- package/docs/hosting.md +6 -6
- package/docs/parser.md +2 -2
- package/docs/regenerating.md +14 -12
- package/docs/sentinel.md +4 -4
- package/docs/skills-and-gates.md +4 -8
- package/docs/using.md +10 -18
- package/genome/rules/test-plain-files.md +15 -7
- package/genome/rules/turri-regeneration.md +4 -9
- package/genome/skills/convert-old-syntax/SKILL.md +5 -5
- 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/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/docs/test-advisor.md +0 -110
package/dist/regenerate/loop.js
CHANGED
|
@@ -9,13 +9,13 @@ import { llmChunkAgents, MAX_LINES_PER_JOB, MAX_SPECS_PER_JOB, planChunks, steps
|
|
|
9
9
|
import { commitNotes, landWork, recordHistory, resetToLastCommit } from "./lineage.js";
|
|
10
10
|
import { firstLine, record } from "./ledger.js";
|
|
11
11
|
import { NOTES_FILE, recordPulse } from "./notes.js";
|
|
12
|
-
import {
|
|
12
|
+
import { formatDuration } from "./jobs.js";
|
|
13
13
|
import { moduleLanes } from "./lanes.js";
|
|
14
14
|
import { adoptDigests, chainTree, codeTree, conformanceTarget, marksRegenerateAgain, REGENERATE_AGAIN, inheritedRecord, isOldRecord, notBuilt, readRecord, RECORD_FILE, withResourceDigests, writeCodeRecord, writeTestsRecord, hasScenarios, identityOf, testedFuncIds, } from "./records.js";
|
|
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, stackForModule,
|
|
18
|
+
import { configForSpec, stackForModule, testDirOf, withStack } from "../config.js";
|
|
19
19
|
import { describeSpecChange } from "./prompt.js";
|
|
20
20
|
import { resolveTemplateDirs } from "./paths.js";
|
|
21
21
|
import { builtTips, copyRequiredCode, importingModules, isImportModule, newlyRequired, resolveRequiresChain, startFromScratch } from "./requires.js";
|
|
@@ -28,12 +28,12 @@ import { changesBetween, parseTree, serializeTree } from "./spec-steps.js";
|
|
|
28
28
|
import { hasFiles } from "./testing.js";
|
|
29
29
|
import { makeRenames, pureRenames, renameText } from "./renames.js";
|
|
30
30
|
import { casesOf, codeWork, stillWanted, whyNotWanted } from "./drift.js";
|
|
31
|
-
import { testingGap } from "./testing-steps.js";
|
|
31
|
+
import { stepsToScenarios, testingGap } from "./testing-steps.js";
|
|
32
32
|
import { baseFolderDrift, baseOfCodebase, seedFromBaseFolder } from "./base-folder.js";
|
|
33
33
|
import { BASE_RECORD_FILE } from "./paths.js";
|
|
34
34
|
import { onScriptRunEnded, scriptBeingWritten } from "./scripts-being-written.js";
|
|
35
35
|
import { conformanceTestsOn } from "../conformance-switch.js";
|
|
36
|
-
import {
|
|
36
|
+
import { projectRootFor } from "./test-scripts.js";
|
|
37
37
|
/** What is left to regenerate, as the conversation and the command line read it. */
|
|
38
38
|
export function describeDrift(reports) {
|
|
39
39
|
if (reports.length === 0)
|
|
@@ -294,13 +294,14 @@ export function createWorkLoop(options) {
|
|
|
294
294
|
return testingGap({ moduleName: tip.moduleName, plainFile: tip.plainFile, tree: spec.tree, buildDir: tip.buildDir });
|
|
295
295
|
};
|
|
296
296
|
/**
|
|
297
|
-
* Whether a
|
|
298
|
-
* rather than fail for want of it, and is looked at again once the run ends.
|
|
297
|
+
* Whether a testing script of this kind is being written for a codebase now - one it lacks, or one written over: it waits
|
|
298
|
+
* for it, rather than fail for want of it or run against the old one, and is looked at again once the run ends.
|
|
299
299
|
*/
|
|
300
300
|
const awaitsScript = (state, kind) => {
|
|
301
301
|
const tip = tipEntry(state);
|
|
302
302
|
const root = projectRootFor(tip.plainFile, tip.buildDir);
|
|
303
|
-
|
|
303
|
+
// Lacking the script, or with one being written over: a pulse started now would run without it, or against the old one.
|
|
304
|
+
return scriptBeingWritten(root, kind, stackForModule(tip.plainFile));
|
|
304
305
|
};
|
|
305
306
|
/**
|
|
306
307
|
* The base folder a codebase started from, as its status says it. Counting the files still there looks at each, and the
|
|
@@ -486,20 +487,18 @@ export function createWorkLoop(options) {
|
|
|
486
487
|
options.registry.notify?.();
|
|
487
488
|
}
|
|
488
489
|
};
|
|
489
|
-
/** A dry run's first jobs, by codebase: what each would start. */
|
|
490
|
-
const firsts = new Map();
|
|
491
490
|
const startJob = (state, spec, from, planned) => {
|
|
492
491
|
// Halted while it was being planned: the plan is made, nothing starts.
|
|
493
492
|
if (state.held !== undefined) {
|
|
494
493
|
state.why = state.held.why;
|
|
495
494
|
return;
|
|
496
495
|
}
|
|
497
|
-
|
|
498
|
-
if (
|
|
499
|
-
|
|
500
|
-
state.why = `would start: ${planned.title}`;
|
|
496
|
+
// Looked ahead: the plan is kept, and its first pulse waits for the module to be asked for.
|
|
497
|
+
if (state.lookedAhead === true) {
|
|
498
|
+
state.why = LOOKED_AHEAD;
|
|
501
499
|
return;
|
|
502
500
|
}
|
|
501
|
+
const tip = tipEntry(state);
|
|
503
502
|
const conformance = planned.track === "conformance";
|
|
504
503
|
// A code job can be steered while it regenerates: its target moves with the spec, inside what it regenerates.
|
|
505
504
|
const steering = conformance ? undefined : createSteering(planned.step.tree, tip.moduleName);
|
|
@@ -718,8 +717,8 @@ export function createWorkLoop(options) {
|
|
|
718
717
|
* nothing running there - so the code is taken to be built from them, rather than everything linking one built again.
|
|
719
718
|
*/
|
|
720
719
|
const hashResources = (state, spec) => {
|
|
721
|
-
// A
|
|
722
|
-
if (
|
|
720
|
+
// A look ahead only reads.
|
|
721
|
+
if (state.lookedAhead === true)
|
|
723
722
|
return;
|
|
724
723
|
const code = tipEntry(state).buildDir;
|
|
725
724
|
for (const dir of [code, testsDirOf(state)]) {
|
|
@@ -749,11 +748,15 @@ export function createWorkLoop(options) {
|
|
|
749
748
|
};
|
|
750
749
|
// A testing script written in the background, or not: what waited for it is looked at again - started, or failed for want of it.
|
|
751
750
|
onScriptRunEnded(() => {
|
|
752
|
-
if (asked.size > 0
|
|
751
|
+
if (asked.size > 0 || ahead.size > 0)
|
|
753
752
|
void tick();
|
|
754
753
|
});
|
|
755
754
|
/** The files asked for, each with how: what the loop brings up, worked out again each look. */
|
|
756
755
|
const asked = new Map();
|
|
756
|
+
/** The files looked ahead at and not asked for since: their codebases are looked at, their pulses held. */
|
|
757
|
+
const ahead = new Map();
|
|
758
|
+
/** The codebases a look ahead is planning now: the only looks that plan a codebase held for one. */
|
|
759
|
+
const planningAhead = new Set();
|
|
757
760
|
/**
|
|
758
761
|
* The modules asked for whose plan is not made yet - their code being deleted, what is left being worked out, the
|
|
759
762
|
* planner not started - by name, with since when: each shows as being planned from the moment it is asked for, not
|
|
@@ -776,10 +779,13 @@ export function createWorkLoop(options) {
|
|
|
776
779
|
options.registry.notify?.();
|
|
777
780
|
}
|
|
778
781
|
};
|
|
779
|
-
/**
|
|
780
|
-
|
|
782
|
+
/**
|
|
783
|
+
* The codebases the requests bring up now - where each module's code lives, and what is to be built on it - those
|
|
784
|
+
* asked for and, unless `requests` names others, those looked ahead at.
|
|
785
|
+
*/
|
|
786
|
+
const active = (requests = [...asked, ...ahead]) => {
|
|
781
787
|
const states = new Set();
|
|
782
|
-
for (const [file, request] of
|
|
788
|
+
for (const [file, request] of requests) {
|
|
783
789
|
let chains;
|
|
784
790
|
try {
|
|
785
791
|
chains = chainsFor(file);
|
|
@@ -805,6 +811,9 @@ export function createWorkLoop(options) {
|
|
|
805
811
|
for (const file of [...asked.keys()])
|
|
806
812
|
if (!existsSync(file))
|
|
807
813
|
asked.delete(file);
|
|
814
|
+
for (const file of [...ahead.keys()])
|
|
815
|
+
if (!existsSync(file))
|
|
816
|
+
ahead.delete(file);
|
|
808
817
|
for (const key of [...order]) {
|
|
809
818
|
const state = modules.get(key);
|
|
810
819
|
if (state.running === undefined && !existsSync(tipEntry(state).plainFile))
|
|
@@ -853,14 +862,6 @@ export function createWorkLoop(options) {
|
|
|
853
862
|
}
|
|
854
863
|
const specKey = keyOf(spec);
|
|
855
864
|
state.seen = spec;
|
|
856
|
-
if (options.onSpec !== undefined) {
|
|
857
|
-
try {
|
|
858
|
-
options.onSpec({ chain: state.chain, tree: spec.tree, built: builtOf(state) });
|
|
859
|
-
}
|
|
860
|
-
catch {
|
|
861
|
-
/* what watches the spec never stops the loop */
|
|
862
|
-
}
|
|
863
|
-
}
|
|
864
865
|
if (state.running !== undefined) {
|
|
865
866
|
if (state.running.stopping === true)
|
|
866
867
|
return;
|
|
@@ -947,8 +948,10 @@ export function createWorkLoop(options) {
|
|
|
947
948
|
// A func-id or a scenario-id renamed, and nothing else with it: turri renames it in the records and relabels the tests
|
|
948
949
|
// itself, as one unit of work - no pulse, the code untouched. Failing, it is rolled back whole, and the codebase halts
|
|
949
950
|
// rather than build the functional spec anew.
|
|
950
|
-
|
|
951
|
-
|
|
951
|
+
// Looked ahead, they are not made - a look ahead writes nothing - and the code is planned from as they would leave it.
|
|
952
|
+
const renamed = readRecord(tip.buildDir) === null ? undefined : pureRenames(readRecord(tip.buildDir), readRecord(testsDirOf(state)), spec.tree, tip.moduleName);
|
|
953
|
+
const pending = state.lookedAhead === true && renamed !== undefined && renamed.renames.length > 0 && renamed.code !== null ? renamed.code : undefined;
|
|
954
|
+
if (renamed !== undefined && renamed.renames.length > 0 && state.lookedAhead !== true) {
|
|
952
955
|
const made = makeRenames({ buildDir: tip.buildDir, testsDir: testsDirOf(state), moduleName: tip.moduleName, renamed, place: { project: projectRootOf(tip.buildDir), module: tip.moduleName } });
|
|
953
956
|
if (!made) {
|
|
954
957
|
state.halted = { why: `renaming ${renamed.renames.map(renameText).join(", ")} failed, and was rolled back - it is tried again once the spec changes, or the module is asked for again`, specKey };
|
|
@@ -959,8 +962,10 @@ export function createWorkLoop(options) {
|
|
|
959
962
|
}
|
|
960
963
|
// The module's code first, every job of it; then its conformance tests - once, for the module as built, with one
|
|
961
964
|
// explorer and one run of the whole suite - and only then is anything built on it (waitingOn).
|
|
962
|
-
const from = builtOf(state);
|
|
965
|
+
const from = pending !== undefined ? codeTree(pending) : builtOf(state);
|
|
963
966
|
const codeLeft = codeWork(from, spec.tree).length > 0;
|
|
967
|
+
// Held for a look ahead, a codebase is planned by a look ahead alone: a plan that no longer fits is dropped, not made again.
|
|
968
|
+
const mayPlan = state.lookedAhead !== true || planningAhead.has(state);
|
|
964
969
|
if (state.conformanceHalted !== undefined && state.conformanceHalted.key !== conformanceKey(state))
|
|
965
970
|
state.conformanceHalted = undefined;
|
|
966
971
|
if (!codeLeft && conformanceWanted(state, spec) && state.conformanceHalted === undefined) {
|
|
@@ -971,6 +976,11 @@ export function createWorkLoop(options) {
|
|
|
971
976
|
// Made again when the spec, the tests or the code it was planned against moved: what the tests are written for
|
|
972
977
|
// follows the code, and a plan made before a code pulse landed would test it as it was.
|
|
973
978
|
if (existing === undefined || existing.specKey !== specKey || existing.from !== testedKey || existing.codeKey !== codeKeyOf(state) || existing.jobs.length === 0) {
|
|
979
|
+
if (!mayPlan) {
|
|
980
|
+
state.conformancePlan = undefined;
|
|
981
|
+
state.why = LOOK_AGAIN;
|
|
982
|
+
return;
|
|
983
|
+
}
|
|
974
984
|
state.conformancePlan = { specKey, from: testedKey, codeKey: codeKeyOf(state), jobs: (await planIdle(state, spec, tested, "conformance")).jobs };
|
|
975
985
|
}
|
|
976
986
|
const next = state.conformancePlan.jobs[0];
|
|
@@ -1000,6 +1010,11 @@ export function createWorkLoop(options) {
|
|
|
1000
1010
|
const fromKey = serializeTree(from);
|
|
1001
1011
|
const steeringKey = steeringKeyOf(state);
|
|
1002
1012
|
if (state.plan === undefined || state.plan.specKey !== specKey || state.plan.from !== fromKey || state.plan.steeringKey !== steeringKey || state.plan.jobs.length === 0) {
|
|
1013
|
+
if (!mayPlan) {
|
|
1014
|
+
state.plan = undefined;
|
|
1015
|
+
state.why = LOOK_AGAIN;
|
|
1016
|
+
return;
|
|
1017
|
+
}
|
|
1003
1018
|
const { jobs, notes } = await planIdle(state, spec, from, "code");
|
|
1004
1019
|
state.plan = { specKey, from: fromKey, steeringKey, jobs, notes };
|
|
1005
1020
|
if (jobs.length === 0) {
|
|
@@ -1015,6 +1030,17 @@ export function createWorkLoop(options) {
|
|
|
1015
1030
|
startJob(state, spec, from, state.plan.jobs[0]);
|
|
1016
1031
|
};
|
|
1017
1032
|
const statusOf = (state) => describe(state).status;
|
|
1033
|
+
/** A planned row's codebase and its place there, from its id - `planned-<module>-N`, the longest module name it starts with, as a name may hold a hyphen. */
|
|
1034
|
+
const rowOf = (rowId) => {
|
|
1035
|
+
const state = order
|
|
1036
|
+
.map((key) => modules.get(key))
|
|
1037
|
+
.filter((candidate) => rowId.startsWith(`planned-${tipEntry(candidate).moduleName}-`))
|
|
1038
|
+
.sort((a, b) => tipEntry(b).moduleName.length - tipEntry(a).moduleName.length)[0];
|
|
1039
|
+
if (state === undefined)
|
|
1040
|
+
return undefined;
|
|
1041
|
+
const rest = rowId.slice(`planned-${tipEntry(state).moduleName}-`.length);
|
|
1042
|
+
return /^[1-9]\d*$/.test(rest) ? { state, index: Number(rest) } : undefined;
|
|
1043
|
+
};
|
|
1018
1044
|
/** The modules asked for that the loop holds nothing of yet - turri just opened, say: their code being planned all the same. */
|
|
1019
1045
|
const preparingAlone = () => {
|
|
1020
1046
|
const held = new Set(order.map((key) => tipEntry(modules.get(key)).moduleName));
|
|
@@ -1104,9 +1130,9 @@ export function createWorkLoop(options) {
|
|
|
1104
1130
|
};
|
|
1105
1131
|
/**
|
|
1106
1132
|
* Look after a codebase - its chain up to it - from now on; says its state. `pin`: its stack is worked out again - its
|
|
1107
|
-
* tip's (`stackForModule`)
|
|
1133
|
+
* tip's (`stackForModule`).
|
|
1108
1134
|
*/
|
|
1109
|
-
const track = (chain, askedFile, request, pin) => {
|
|
1135
|
+
const track = (chain, askedFile, request, pin = false) => {
|
|
1110
1136
|
const tip = tipOf(chain);
|
|
1111
1137
|
let state = modules.get(tip.buildDir);
|
|
1112
1138
|
if (state === undefined) {
|
|
@@ -1121,9 +1147,7 @@ export function createWorkLoop(options) {
|
|
|
1121
1147
|
}
|
|
1122
1148
|
state.chain = chain;
|
|
1123
1149
|
state.askedFile = askedFile;
|
|
1124
|
-
|
|
1125
|
-
const keep = pin?.keep === true && !stackPinned() && state.stack?.name !== undefined;
|
|
1126
|
-
if (pin !== undefined && !keep)
|
|
1150
|
+
if (pin)
|
|
1127
1151
|
state.stack = { name: stackForModule(tip.plainFile) };
|
|
1128
1152
|
// Its model as its stack has it: a stack's file can name a coding model of its own.
|
|
1129
1153
|
const model = request.model ?? inStack(state, () => options.modelFor?.(tip.plainFile));
|
|
@@ -1135,29 +1159,92 @@ export function createWorkLoop(options) {
|
|
|
1135
1159
|
};
|
|
1136
1160
|
const loop = {
|
|
1137
1161
|
async bringUp(plainFile, given = {}) {
|
|
1138
|
-
|
|
1139
|
-
|
|
1162
|
+
// Asked for, it shows as being planned at once.
|
|
1163
|
+
return preparingFor(plainFile, async () => {
|
|
1140
1164
|
const files = codebasesOf(resolve(options.cwd, plainFile));
|
|
1141
|
-
for (const file of files)
|
|
1142
|
-
asked.set(file, { ...asked.get(file), ...
|
|
1165
|
+
for (const file of files) {
|
|
1166
|
+
asked.set(file, { ...ahead.get(file), ...asked.get(file), ...given });
|
|
1167
|
+
ahead.delete(file);
|
|
1168
|
+
}
|
|
1143
1169
|
// Asked for, it is built with its stack - the one the call names, its own, or the one chosen now - pinned, whatever
|
|
1144
|
-
// is chosen later
|
|
1145
|
-
const
|
|
1146
|
-
|
|
1147
|
-
// Asked again, a halted codebase is tried again - one the person halted too, unless only its spec changed.
|
|
1170
|
+
// is chosen later.
|
|
1171
|
+
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)))));
|
|
1172
|
+
// Asked again, a halted codebase is tried again - one the person halted too. Looked ahead at, its kept plan starts.
|
|
1148
1173
|
for (const state of states) {
|
|
1149
1174
|
state.halted = undefined;
|
|
1150
|
-
|
|
1151
|
-
|
|
1175
|
+
state.held = undefined;
|
|
1176
|
+
state.lookedAhead = undefined;
|
|
1152
1177
|
// Asked for again: its conformance tests are written for every functional spec with scenarios, not only those conform named.
|
|
1153
|
-
|
|
1154
|
-
state.conformanceOnly = undefined;
|
|
1178
|
+
state.conformanceOnly = undefined;
|
|
1155
1179
|
}
|
|
1156
1180
|
await tick();
|
|
1157
1181
|
return [...new Set(states)].map(statusOf);
|
|
1158
|
-
};
|
|
1159
|
-
|
|
1160
|
-
|
|
1182
|
+
});
|
|
1183
|
+
},
|
|
1184
|
+
async lookAhead(plainFile, given = {}) {
|
|
1185
|
+
// Being planned, it shows so at once; what is planned is said once it is - not as being planned.
|
|
1186
|
+
const states = await preparingFor(plainFile, async () => {
|
|
1187
|
+
const files = codebasesOf(resolve(options.cwd, plainFile));
|
|
1188
|
+
for (const file of files)
|
|
1189
|
+
if (!asked.has(file))
|
|
1190
|
+
ahead.set(file, { ...ahead.get(file), ...given });
|
|
1191
|
+
// Its stack pinned as an ask pins it: the plan is made, and its pulses run, with the stack regenerate would use.
|
|
1192
|
+
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)))));
|
|
1193
|
+
// A chain with a pulse running is being built as asked, and goes on; every other codebase is held - one asked for
|
|
1194
|
+
// earlier too, which would otherwise start the work the look ahead plans.
|
|
1195
|
+
const building = (state) => state.chain.some((entry) => modules.get(entry.buildDir)?.running !== undefined);
|
|
1196
|
+
for (const state of tracked) {
|
|
1197
|
+
if (!building(state))
|
|
1198
|
+
state.lookedAhead = true;
|
|
1199
|
+
planningAhead.add(state);
|
|
1200
|
+
}
|
|
1201
|
+
try {
|
|
1202
|
+
await tick();
|
|
1203
|
+
}
|
|
1204
|
+
finally {
|
|
1205
|
+
for (const state of tracked)
|
|
1206
|
+
planningAhead.delete(state);
|
|
1207
|
+
}
|
|
1208
|
+
return tracked;
|
|
1209
|
+
});
|
|
1210
|
+
return [...new Set(states)].map(statusOf);
|
|
1211
|
+
},
|
|
1212
|
+
async plannedPulse(rowId) {
|
|
1213
|
+
const found = rowOf(rowId);
|
|
1214
|
+
if (found === undefined)
|
|
1215
|
+
return undefined;
|
|
1216
|
+
const { state, index } = found;
|
|
1217
|
+
const { status, jobs } = describe(state);
|
|
1218
|
+
const entry = status.planned[index - 1];
|
|
1219
|
+
if (entry === undefined)
|
|
1220
|
+
return undefined;
|
|
1221
|
+
const tip = tipEntry(state);
|
|
1222
|
+
const pulse = { id: rowId, module: tip.moduleName, plainFile: tip.plainFile, title: entry.title, track: entry.track, cases: entry.cases, index, lookedAhead: state.lookedAhead === true };
|
|
1223
|
+
const job = jobs[index - 1];
|
|
1224
|
+
const why = (text) => ({ ...pulse, why: text });
|
|
1225
|
+
if (entry.planning === true)
|
|
1226
|
+
return why("It is being planned now: its prompt is built once the plan is made.");
|
|
1227
|
+
if (entry.afterCode === true || job === undefined)
|
|
1228
|
+
return why("It is not planned yet: the conformance tests are planned into pulses once the module's code is built, and their prompt is built from that code.");
|
|
1229
|
+
if (state.running !== undefined)
|
|
1230
|
+
return why(`Pulse ${state.running.jobId} is running in this codebase: what this pulse is given depends on what that one lands.`);
|
|
1231
|
+
if (index > 1)
|
|
1232
|
+
return why(`It follows ${index - 1} planned pulse${index === 2 ? "" : "s"} here: its prompt depends on what ${index === 2 ? "that one lands" : "they land"}, and is built when it starts.`);
|
|
1233
|
+
if (job.track === "conformance")
|
|
1234
|
+
return why("A conformance pulse's prompt is built from what the code it tests holds once it is built: it is not shown before.");
|
|
1235
|
+
// The plan as kept, and only while it fits the ***plain and the steering as they are now - else regenerate would plan again.
|
|
1236
|
+
let spec;
|
|
1237
|
+
try {
|
|
1238
|
+
spec = chainSpec(state.chain);
|
|
1239
|
+
}
|
|
1240
|
+
catch (error) {
|
|
1241
|
+
return why(`Its ***plain does not parse now: ${error instanceof Error ? error.message : String(error)}`);
|
|
1242
|
+
}
|
|
1243
|
+
if (state.plan === undefined || !state.plan.jobs.includes(job) || state.plan.specKey !== keyOf(spec) || state.plan.steeringKey !== steeringKeyOf(state)) {
|
|
1244
|
+
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.");
|
|
1245
|
+
}
|
|
1246
|
+
const task = await inStack(state, () => promptOf({ plainFile: tip.plainFile, spec: { ...spec, tree: job.step.tree }, planned: job }));
|
|
1247
|
+
return task !== undefined ? { ...pulse, task } : why("It has no prompt to show.");
|
|
1161
1248
|
},
|
|
1162
1249
|
async regenerateAgain(plainFile, given, request = {}) {
|
|
1163
1250
|
return preparingFor(plainFile, async () => {
|
|
@@ -1271,7 +1358,8 @@ export function createWorkLoop(options) {
|
|
|
1271
1358
|
},
|
|
1272
1359
|
async conformance(plainFile, request = {}) {
|
|
1273
1360
|
const file = resolve(options.cwd, plainFile);
|
|
1274
|
-
asked.set(file, { ...asked.get(file), ...(request.model !== undefined ? { model: request.model } : {}) });
|
|
1361
|
+
asked.set(file, { ...ahead.get(file), ...asked.get(file), ...(request.model !== undefined ? { model: request.model } : {}) });
|
|
1362
|
+
ahead.delete(file);
|
|
1275
1363
|
const own = resolveRequiresChain(file, [], undefined, { allowNoFunctionalities: true });
|
|
1276
1364
|
const self = tipOf(own);
|
|
1277
1365
|
// What the person asks for comes first. Its tests are written in its own codebase, before anything is built on it:
|
|
@@ -1280,7 +1368,7 @@ export function createWorkLoop(options) {
|
|
|
1280
1368
|
// it has, nothing is touched.
|
|
1281
1369
|
if (!conformanceTestsOn(self.plainFile)) {
|
|
1282
1370
|
throw new Error(`Conformance tests are off for ${self.moduleName} (conformance-tests: false, or unset): nothing is conformance tested. ` +
|
|
1283
|
-
"
|
|
1371
|
+
"/conform in the chat turns them on, or conformance-tests: true in config.turri.yaml. Nothing was started.");
|
|
1284
1372
|
}
|
|
1285
1373
|
// Refused before anything is touched: a functional spec not there, nothing to test, or a step of adding tests skipped.
|
|
1286
1374
|
const { named, spec: ownSpec, withScenarios } = conformanceAskedIn(own, request.funcIds);
|
|
@@ -1311,11 +1399,14 @@ export function createWorkLoop(options) {
|
|
|
1311
1399
|
}
|
|
1312
1400
|
}
|
|
1313
1401
|
}
|
|
1314
|
-
const tracked = withParseCache(() => (wentBack ? [own] : chainsFor(file)).flatMap((chain) => toBuild(chain).map((entry) => track(chain.slice(0, chain.indexOf(entry) + 1), file, request,
|
|
1402
|
+
const tracked = withParseCache(() => (wentBack ? [own] : chainsFor(file)).flatMap((chain) => toBuild(chain).map((entry) => track(chain.slice(0, chain.indexOf(entry) + 1), file, request, true))));
|
|
1315
1403
|
// The module asked for, in its own codebase - and those below it: never the codebases built on it.
|
|
1316
1404
|
const asking = tracked.find((state) => tipEntry(state).buildDir === self.buildDir);
|
|
1317
1405
|
const states = asking !== undefined ? tracked.filter((state) => own.some((entry) => entry.buildDir === tipEntry(state).buildDir)) : tracked;
|
|
1318
1406
|
const tip = asking ?? states.at(-1);
|
|
1407
|
+
// Asked for: what a look ahead held here goes on - the modules below with it, or the module waits for them for ever.
|
|
1408
|
+
for (const state of tracked)
|
|
1409
|
+
state.lookedAhead = undefined;
|
|
1319
1410
|
const asks = named !== undefined && named.length > 0 ? named : undefined;
|
|
1320
1411
|
// Its tests are written already, and a codebase built on it holds its code: nothing to write, nothing touched.
|
|
1321
1412
|
if (asking === undefined && asks !== undefined && tip !== undefined) {
|
|
@@ -1468,12 +1559,15 @@ export function createWorkLoop(options) {
|
|
|
1468
1559
|
let before = status.running?.jobId;
|
|
1469
1560
|
if (before !== undefined)
|
|
1470
1561
|
lastOf.set(tip.moduleName, before);
|
|
1562
|
+
// Looked ahead at: every row of it says it waits for the module to be asked for.
|
|
1563
|
+
const held = state.lookedAhead === true && state.running === undefined;
|
|
1471
1564
|
const row = (id, summary, note, waitingOn, conformance = false) => ({
|
|
1472
1565
|
id,
|
|
1473
1566
|
kind: conformance ? "conformance" : "regenerate",
|
|
1474
1567
|
summary,
|
|
1475
1568
|
module: tip.moduleName,
|
|
1476
|
-
note,
|
|
1569
|
+
note: held ? `${LOOKED_AHEAD_NOTE} ${note}` : note,
|
|
1570
|
+
...(held ? { lookedAhead: true } : {}),
|
|
1477
1571
|
...(state.model !== undefined ? { model: state.model } : {}),
|
|
1478
1572
|
status: "queued",
|
|
1479
1573
|
sequence: sequence--,
|
|
@@ -1509,16 +1603,9 @@ export function createWorkLoop(options) {
|
|
|
1509
1603
|
});
|
|
1510
1604
|
})];
|
|
1511
1605
|
},
|
|
1512
|
-
firsts() {
|
|
1513
|
-
return order.flatMap((key) => {
|
|
1514
|
-
const first = firsts.get(key);
|
|
1515
|
-
const tip = tipEntry(modules.get(key));
|
|
1516
|
-
return first === undefined ? [] : [{ module: tip.moduleName, plainFile: tip.plainFile, buildDir: tip.buildDir, ...first }];
|
|
1517
|
-
});
|
|
1518
|
-
},
|
|
1519
1606
|
mapPlan() {
|
|
1520
1607
|
return {
|
|
1521
|
-
files: [...asked.keys()],
|
|
1608
|
+
files: [...asked.keys(), ...[...ahead.keys()].filter((file) => !asked.has(file))],
|
|
1522
1609
|
codebases: order.map((key) => {
|
|
1523
1610
|
const state = modules.get(key);
|
|
1524
1611
|
const tip = tipEntry(state);
|
|
@@ -1580,6 +1667,12 @@ function oldCodebases(chain) {
|
|
|
1580
1667
|
const OLD_RECORDS_WHY = (codebases) => `${codebases.join(", ")} ${codebases.length === 1 ? "was" : "were"} built when functional specs were numbered, before they had func-ids: nothing more is built on ${codebases.length === 1 ? "it" : "them"} - the whole chain is regenerated from scratch once you agree`;
|
|
1581
1668
|
/** Why nothing runs in a codebase whose code - and conformance tests, where they are wanted - is built from its spec as it is. */
|
|
1582
1669
|
export const UP_TO_DATE = "built from the ***plain as it is";
|
|
1670
|
+
/** Why nothing starts in a codebase a look ahead planned: its pulses wait for the module to be asked for. */
|
|
1671
|
+
const LOOKED_AHEAD = "looked ahead - planned, and nothing starts until regenerate, conform or /regenerate asks for it";
|
|
1672
|
+
/** What a planned row of a codebase a look ahead planned says first. */
|
|
1673
|
+
const LOOKED_AHEAD_NOTE = "Planned by a look ahead: it waits for regenerate, conform or /regenerate to start it.";
|
|
1674
|
+
/** Why a codebase held for a look ahead has no plan: its ***plain or steering moved since, and only a look ahead plans it. */
|
|
1675
|
+
const LOOK_AGAIN = "looked ahead, and the ***plain or the steering changed since - look ahead again to plan it, or regenerate it";
|
|
1583
1676
|
/** Why a codebase with work left has no plan: the planner found none. */
|
|
1584
1677
|
/** Why a codebase waits for a testing script being written in the background. */
|
|
1585
1678
|
const SCRIPT_BEING_WRITTEN = (what) => `waiting for its ${what}, which is being written`;
|
|
@@ -1677,9 +1770,11 @@ function conformanceAskedIn(own, funcIds) {
|
|
|
1677
1770
|
const named = funcIds === undefined ? undefined : funcIdsNamed(self.moduleName, [...new Set(funcIds)]);
|
|
1678
1771
|
const spec = chainSpec(own).tree;
|
|
1679
1772
|
const withScenarios = testedFuncIds(spec);
|
|
1773
|
+
// No scenarios: the steps still to take, from the first one missing - the test reqs and the script come before them.
|
|
1774
|
+
const toScenarios = () => stepsToScenarios({ moduleName: self.moduleName, plainFile: self.plainFile, tree: spec, buildDir: self.buildDir });
|
|
1680
1775
|
if (withScenarios.length === 0) {
|
|
1681
|
-
throw new Error(`No functional spec of ${self.moduleName} has scenarios - none has a test plain file - so there is nothing to test
|
|
1682
|
-
"
|
|
1776
|
+
throw new Error(`No functional spec of ${self.moduleName} has scenarios - none has a test plain file - so there is nothing to test. ${toScenarios()} ` +
|
|
1777
|
+
"Their tests are written once the code is built. Nothing was started.");
|
|
1683
1778
|
}
|
|
1684
1779
|
if (named !== undefined && named.length > 0) {
|
|
1685
1780
|
const items = spec[FUNCTIONAL_REQUIREMENTS] ?? [];
|
|
@@ -1688,8 +1783,8 @@ function conformanceAskedIn(own, funcIds) {
|
|
|
1688
1783
|
throw new Error(`${self.moduleName} has no functional spec ${namesOf(self.moduleName, unknown)}. Nothing was started.`);
|
|
1689
1784
|
const untested = named.filter((funcId) => !hasScenarios(items.find((item) => item.id === funcId)));
|
|
1690
1785
|
if (untested.length > 0) {
|
|
1691
|
-
throw new Error(`${namesOf(self.moduleName, untested)} ${untested.length === 1 ? "has" : "have"} no scenarios - no test plain file - so there is nothing to test
|
|
1692
|
-
"
|
|
1786
|
+
throw new Error(`${namesOf(self.moduleName, untested)} ${untested.length === 1 ? "has" : "have"} no scenarios - no test plain file - so there is nothing to test. ${toScenarios()} ` +
|
|
1787
|
+
"Their tests are written once the code is built. Nothing was started.");
|
|
1693
1788
|
}
|
|
1694
1789
|
}
|
|
1695
1790
|
// A step of adding tests skipped - its test reqs, or the conformance testing script for its stack: refused, naming it.
|
|
@@ -1723,54 +1818,24 @@ function casesText(cases) {
|
|
|
1723
1818
|
];
|
|
1724
1819
|
return parts.length > 0 ? parts.join(", ") : "no functional spec - reqs or definitions only";
|
|
1725
1820
|
}
|
|
1726
|
-
/** The codebases the loop looks after, as the person reads them: what runs, what is planned after it, and why nothing does. */
|
|
1727
1821
|
/**
|
|
1728
|
-
* The coding agent's task for a
|
|
1729
|
-
* a conformance
|
|
1822
|
+
* The coding agent's task for a planned code pulse, built as the pulse builds it - with `spec` the ***plain the pulse
|
|
1823
|
+
* would be given - and all it did rolled back. Not for a conformance pulse: its prompt is built from what the code holds
|
|
1824
|
+
* once it is built.
|
|
1730
1825
|
*/
|
|
1731
|
-
|
|
1732
|
-
if (
|
|
1826
|
+
async function promptOf(next) {
|
|
1827
|
+
if (next.planned.track !== "code")
|
|
1733
1828
|
return undefined;
|
|
1734
1829
|
const result = await renderSpecDiff({
|
|
1735
|
-
plainFile:
|
|
1736
|
-
diff:
|
|
1830
|
+
plainFile: next.plainFile,
|
|
1831
|
+
diff: next.planned.step.textDiff,
|
|
1737
1832
|
applied: "already applied",
|
|
1738
|
-
spec:
|
|
1739
|
-
cases:
|
|
1833
|
+
spec: next.spec,
|
|
1834
|
+
cases: next.planned.cases,
|
|
1740
1835
|
dryRun: true,
|
|
1741
1836
|
});
|
|
1742
1837
|
return result.task;
|
|
1743
1838
|
}
|
|
1744
|
-
/**
|
|
1745
|
-
* What bringing a spec's module up would start, in each codebase, and the prompt of each - planned on a loop of its own
|
|
1746
|
-
* that starts nothing. A codebase `busy` says is running a job is left out: a dry run starts from its last commit, and
|
|
1747
|
-
* what the next job there is given depends on what the running one lands.
|
|
1748
|
-
*/
|
|
1749
|
-
export async function previewJobs(options) {
|
|
1750
|
-
const loop = createWorkLoop({
|
|
1751
|
-
registry: createJobRegistry(),
|
|
1752
|
-
cwd: options.cwd,
|
|
1753
|
-
dryRun: true,
|
|
1754
|
-
...(options.model !== undefined ? { modelFor: () => options.model } : {}),
|
|
1755
|
-
...(options.plannerModel !== undefined ? { plannerModel: options.plannerModel } : {}),
|
|
1756
|
-
...(options.steering !== undefined ? { steering: options.steering } : {}),
|
|
1757
|
-
});
|
|
1758
|
-
const statuses = await loop.bringUp(options.plainFile, options.model !== undefined ? { model: options.model } : {});
|
|
1759
|
-
const previews = [];
|
|
1760
|
-
const busy = [];
|
|
1761
|
-
for (const first of loop.firsts()) {
|
|
1762
|
-
if (options.busy?.(first.module) === true) {
|
|
1763
|
-
busy.push(first.module);
|
|
1764
|
-
continue;
|
|
1765
|
-
}
|
|
1766
|
-
const preview = { module: first.module, title: first.planned.title, track: first.planned.track, cases: first.planned.cases };
|
|
1767
|
-
const task = await promptOf(first);
|
|
1768
|
-
if (task !== undefined)
|
|
1769
|
-
preview.task = task;
|
|
1770
|
-
previews.push(preview);
|
|
1771
|
-
}
|
|
1772
|
-
return { statuses, previews, busy };
|
|
1773
|
-
}
|
|
1774
1839
|
/** Nothing runs, is planned or is waiting there, as its code is built from its spec as it is. */
|
|
1775
1840
|
export function isUpToDate(status) {
|
|
1776
1841
|
return status.why === UP_TO_DATE && status.running === undefined && status.planned.length === 0 && status.startOver === undefined;
|
|
@@ -1822,8 +1887,11 @@ export function describeModules(statuses, options = {}) {
|
|
|
1822
1887
|
: ` ${index + 1}. ${job.track === "conformance" ? "conformance tests: " : ""}${job.title} - ${casesText(job.cases)}`));
|
|
1823
1888
|
if (status.planNotes !== undefined)
|
|
1824
1889
|
lines.push(" what the plan did not do as asked:", ...status.planNotes.map((note) => ` - ${note}`));
|
|
1890
|
+
// A look ahead from the command line keeps its plan only while the process lives: the run that starts it plans again.
|
|
1825
1891
|
if (status.why !== undefined)
|
|
1826
|
-
lines.push(
|
|
1892
|
+
lines.push(options.for === "command line" && status.why === LOOKED_AHEAD
|
|
1893
|
+
? ` looked ahead - planned, nothing started: turri regenerate ${basename(status.plainFile)} runs it, planning it again as it starts`
|
|
1894
|
+
: ` ${status.why}`);
|
|
1827
1895
|
if (status.conformanceNote !== undefined)
|
|
1828
1896
|
lines.push(` ${status.conformanceNote}`);
|
|
1829
1897
|
lines.push(...startOver(status));
|
|
@@ -10,8 +10,6 @@ import { type TestRemoval, type TestRun, type MissingToolchain } from "./testing
|
|
|
10
10
|
* one that fits neither way is refused: rendering it would mean guessing.
|
|
11
11
|
*/
|
|
12
12
|
export declare function applySpecDiff(diff: string, cwd: string): "applied" | "already applied";
|
|
13
|
-
/** Undo a spec diff this process applied, when what it produced cannot be used. */
|
|
14
|
-
export declare function revertSpecDiff(diff: string, cwd: string): void;
|
|
15
13
|
/** The .plain files a diff writes to, relative to where it applies. */
|
|
16
14
|
export declare function plainFilesOf(diff: string): string[];
|
|
17
15
|
/** A module's .plain file and every one it imports, transitively - the files its spec is read from. */
|
|
@@ -88,20 +88,6 @@ export function applySpecDiff(diff, cwd) {
|
|
|
88
88
|
written();
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
|
-
/** Undo a spec diff this process applied, when what it produced cannot be used. */
|
|
92
|
-
export function revertSpecDiff(diff, cwd) {
|
|
93
|
-
const written = conversationWriting(plainFilesOf(diff).map((file) => resolve(cwd, file)));
|
|
94
|
-
const dir = mkdtempSync(join(tmpdir(), "turri-diff-"));
|
|
95
|
-
const patch = join(dir, "spec.diff");
|
|
96
|
-
writeFileSync(patch, diff.endsWith("\n") ? diff : `${diff}\n`);
|
|
97
|
-
try {
|
|
98
|
-
spawnSync("git", ["apply", "--recount", "--reverse", patch], { cwd, encoding: "utf8" });
|
|
99
|
-
}
|
|
100
|
-
finally {
|
|
101
|
-
rmSync(dir, { recursive: true, force: true });
|
|
102
|
-
written();
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
91
|
/** The .plain files a diff writes to, relative to where it applies. */
|
|
106
92
|
export function plainFilesOf(diff) {
|
|
107
93
|
const files = new Set();
|
|
@@ -584,11 +570,14 @@ export async function renderSpecDiff(options) {
|
|
|
584
570
|
// Passing means the harness's own run of the unit testing script passed, last.
|
|
585
571
|
const unitPassed = verified;
|
|
586
572
|
const files = diffFiles(digestsBefore, digestFiles(buildDir));
|
|
573
|
+
// The report is what the agent said it did, handed over with submit_work - not what it said along the way, which reads
|
|
574
|
+
// as a plan ("next I'll check...") when its last words came before its last tool calls. Without an account, its words.
|
|
575
|
+
const account = work.last()?.summary.trim();
|
|
587
576
|
const base = {
|
|
588
577
|
moduleName,
|
|
589
578
|
buildDir,
|
|
590
579
|
diff: applied,
|
|
591
|
-
response,
|
|
580
|
+
response: account !== undefined && account !== "" ? account : response,
|
|
592
581
|
runs,
|
|
593
582
|
attempts,
|
|
594
583
|
testRemovals,
|
|
@@ -7,7 +7,7 @@ import { projectPlainFiles } from "./requires.js";
|
|
|
7
7
|
export function projectStanding(projectDir, options = {}) {
|
|
8
8
|
const root = resolve(projectDir);
|
|
9
9
|
const files = (options.files ?? projectPlainFiles(root)).map((file) => resolve(root, file));
|
|
10
|
-
const loop = options.loop ?? createWorkLoop({ registry: createJobRegistry(), cwd: root
|
|
10
|
+
const loop = options.loop ?? createWorkLoop({ registry: createJobRegistry(), cwd: root });
|
|
11
11
|
return withParseCache(() => files.map((plainFile) => {
|
|
12
12
|
const standing = { plainFile, module: basename(plainFile, PLAIN_SOURCE_FILE_EXTENSION) };
|
|
13
13
|
try {
|
|
@@ -30,6 +30,8 @@ export interface WorkLedger {
|
|
|
30
30
|
peek: () => WorkAccount[];
|
|
31
31
|
/** What was handed over since the last take - and from now, nothing. */
|
|
32
32
|
take: () => WorkAccount[];
|
|
33
|
+
/** The last account handed over, taken or not: what the agent last said it did. */
|
|
34
|
+
last: () => WorkAccount | undefined;
|
|
33
35
|
}
|
|
34
36
|
export declare function createWorkLedger(): WorkLedger;
|
|
35
37
|
/** The problems, numbered from 1, that no account answered. */
|
|
@@ -5,7 +5,9 @@ export const SUBMIT_WORK_NOTE = [
|
|
|
5
5
|
"When you are done with a turn - the work written and its tests passing - call submit_work, last: a short summary of",
|
|
6
6
|
"what you did and why, and after a review, an answer for each problem it raised - fixed, or declined and why. Its",
|
|
7
7
|
"reviewer gets your account beside the diff of what you changed, and checks the one against the other: say what you",
|
|
8
|
-
"did, not what you meant to.",
|
|
8
|
+
"did, not what you meant to. It is also the pulse's report to the person: say what the code does now, and a check you",
|
|
9
|
+
"ran as the check it was - \"breaking the tie order on purpose made 4 tests fail\" - never a bug you planted and undid",
|
|
10
|
+
"as if it were in the code.",
|
|
9
11
|
];
|
|
10
12
|
/** What the agent is told with a review's problems: how it answers them. */
|
|
11
13
|
export const SUBMIT_AFTER_REVIEW = [
|
|
@@ -13,6 +15,7 @@ export const SUBMIT_AFTER_REVIEW = [
|
|
|
13
15
|
];
|
|
14
16
|
export function createWorkLedger() {
|
|
15
17
|
let accounts = [];
|
|
18
|
+
let last;
|
|
16
19
|
const tool = defineTool({
|
|
17
20
|
name: "submit_work",
|
|
18
21
|
label: "Submit the work",
|
|
@@ -20,7 +23,7 @@ export function createWorkLedger() {
|
|
|
20
23
|
"raised, by its number - fixed, or declined and why, and the files. The reviewer checks it against the diff.",
|
|
21
24
|
promptSnippet: "hand the work over for review - what you did, and your answer to each problem raised",
|
|
22
25
|
parameters: Type.Object({
|
|
23
|
-
summary: Type.String({ description: "What you did in this turn and why, in a few sentences" }),
|
|
26
|
+
summary: Type.String({ description: "What you did in this turn and why, in a few sentences - the pulse's report: what the code does now, a check you ran said as a check" }),
|
|
24
27
|
answers: Type.Optional(Type.Array(Type.Object({
|
|
25
28
|
problem: Type.Number({ description: "The problem's number in the review's list" }),
|
|
26
29
|
outcome: Type.Union([Type.Literal("fixed"), Type.Literal("declined")]),
|
|
@@ -29,13 +32,15 @@ export function createWorkLedger() {
|
|
|
29
32
|
}), { description: "After a review: one answer for each problem it raised. Omit on a first turn." })),
|
|
30
33
|
}),
|
|
31
34
|
async execute(_id, params) {
|
|
32
|
-
|
|
35
|
+
last = { summary: params.summary, answers: (params.answers ?? []) };
|
|
36
|
+
accounts.push(last);
|
|
33
37
|
return { content: [{ type: "text", text: "Handed over." }], details: {}, terminate: true };
|
|
34
38
|
},
|
|
35
39
|
});
|
|
36
40
|
return {
|
|
37
41
|
tool,
|
|
38
42
|
peek: () => [...accounts],
|
|
43
|
+
last: () => last,
|
|
39
44
|
take() {
|
|
40
45
|
const taken = accounts;
|
|
41
46
|
accounts = [];
|