@turri-dev/cli 0.2.4-next.8422d0f → 0.2.4-next.bc1fc47
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 -3
- 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/conform-cli.js +13 -2
- 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 +188 -242
- 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 +28 -5
- package/dist/loop-tools.js +87 -22
- 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/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 +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 +46 -60
- package/dist/regenerate/loop.js +277 -116
- 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/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/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 +6 -4
- package/docs/hosting.md +6 -6
- package/docs/parser.md +2 -2
- package/docs/regenerating.md +21 -13
- package/docs/sentinel.md +4 -4
- package/docs/skills-and-gates.md +4 -8
- package/docs/using.md +13 -21
- package/genome/rules/test-plain-files.md +15 -7
- package/genome/rules/turri-regeneration.md +4 -8
- 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/loop-tools.js
CHANGED
|
@@ -3,11 +3,13 @@ import { refuseTestPlainFile } from "./test-plain-files.js";
|
|
|
3
3
|
import { basename, relative, resolve } from "node:path";
|
|
4
4
|
import { defineTool } from "@earendil-works/pi-coding-agent";
|
|
5
5
|
import { Type } from "typebox";
|
|
6
|
-
import { advisingNote } from "./advisor-chat.js";
|
|
7
6
|
import { CONFIG_FILE, readProjectConfig, stackConfigFile, stackForModule, stackNamed, stacksOf, withStack } from "./config.js";
|
|
8
7
|
import { checkPlainFile, formatCheckResults } from "./plain/check.js";
|
|
9
8
|
import { describeDrift, describeModules } from "./regenerate/loop.js";
|
|
10
|
-
import { pulseName } from "./regenerate/jobs.js";
|
|
9
|
+
import { describeJob, pulseName } from "./regenerate/jobs.js";
|
|
10
|
+
import { currentChat } from "./chat-scope.js";
|
|
11
|
+
import { whyFailed } from "./regenerate/diagnose-job.js";
|
|
12
|
+
import { didNotLand } from "./regenerate/failure-reports.js";
|
|
11
13
|
import { stopDeployed } from "./regenerate/release.js";
|
|
12
14
|
import { projectDirOf } from "./regenerate/paths.js";
|
|
13
15
|
import { findTestScripts } from "./regenerate/test-scripts.js";
|
|
@@ -18,15 +20,14 @@ export const GUIDANCE_PARAM = Type.Optional(Type.String({
|
|
|
18
20
|
"the user said it, or as you understood it. A strong preference for the planner, within its limits. Omit when there is none.",
|
|
19
21
|
}));
|
|
20
22
|
export const WORKING_DIR_PARAM = Type.Optional(Type.String({
|
|
21
|
-
description: "The folder
|
|
22
|
-
"(e.g. \"plain\"). plain_file
|
|
23
|
-
"plain/hubspot.plain. Default: where " +
|
|
23
|
+
description: "The folder the .plain files are in, relative to where turri was started - as if it had been started there " +
|
|
24
|
+
"(e.g. \"plain\"). plain_file is then relative to it - hubspot.plain, not plain/hubspot.plain. Default: where " +
|
|
24
25
|
"turri was started.",
|
|
25
26
|
}));
|
|
26
27
|
export const MODEL_PARAM = Type.Optional(Type.String({
|
|
27
28
|
description: "The model for the agents of this one call: a provider/model-id, or its name as the user said it. " +
|
|
28
29
|
"Omitted: the model chosen for this kind of work with engine, else the conversation's. " +
|
|
29
|
-
"To change it for every later
|
|
30
|
+
"To change it for every later pulse, use engine instead.",
|
|
30
31
|
}));
|
|
31
32
|
export const STACK_PARAM = Type.Optional(Type.String({
|
|
32
33
|
description: "In a project of stacks: the stack that builds this module - its config.turri.<stack>.yaml over config.turri.yaml, " +
|
|
@@ -92,13 +93,69 @@ export function fromWorkingDir(cwd, params) {
|
|
|
92
93
|
...(params.build_dir !== undefined ? { build_dir: resolve(base, params.build_dir) } : {}),
|
|
93
94
|
};
|
|
94
95
|
}
|
|
95
|
-
/**
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
96
|
+
/** The calls waiting now, by registry. */
|
|
97
|
+
const waits = new WeakMap();
|
|
98
|
+
/** A call in this chat starts waiting, from the pulses there are now. */
|
|
99
|
+
export function startWait(jobs) {
|
|
100
|
+
const wait = { chat: currentChat()?.id, before: new Set(jobs.list().map((job) => job.id)) };
|
|
101
|
+
const set = waits.get(jobs) ?? new Set();
|
|
102
|
+
set.add(wait);
|
|
103
|
+
waits.set(jobs, set);
|
|
104
|
+
return wait;
|
|
105
|
+
}
|
|
106
|
+
/** A call is done waiting: what ends now is told as any pulse's end is. */
|
|
107
|
+
export function endWait(jobs, wait) {
|
|
108
|
+
waits.get(jobs)?.delete(wait);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Whether a pulse that ended is told by a call still waiting in its chat - its agent is told it in that call's reply, so
|
|
112
|
+
* a turn of its own to say it again would only repeat it.
|
|
113
|
+
*/
|
|
114
|
+
export function toldByWaitingCall(jobs, job) {
|
|
115
|
+
for (const wait of waits.get(jobs) ?? [])
|
|
116
|
+
if (wait.chat === job.chat && !wait.before.has(job.id))
|
|
117
|
+
return true;
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
/** A module's why while it waits for a testing script being written (loop.ts SCRIPT_BEING_WRITTEN). */
|
|
121
|
+
const SCRIPT_WAIT = /, which is being written$/;
|
|
122
|
+
/** How often a waiting call looks again while its module waits for a testing script. */
|
|
123
|
+
const SCRIPT_POLL_MS = 500;
|
|
124
|
+
/** How much of each pulse that ran while a call waited is told: the rest is pulses' with its id. */
|
|
125
|
+
const RAN_CHARS = 3_000;
|
|
126
|
+
/**
|
|
127
|
+
* What the loop is doing for a spec's modules, for the conversation - and, waiting, the pulses that ran meanwhile and how
|
|
128
|
+
* each ended, then how each module stands: `ran` is the registry and the call's wait (startWait).
|
|
129
|
+
*/
|
|
130
|
+
export async function loopReply(loop, statuses, wait, ran) {
|
|
131
|
+
try {
|
|
132
|
+
if (wait) {
|
|
133
|
+
await loop.drain();
|
|
134
|
+
// A module held for a testing script being written - beside this call, by a skill run - starts once it is: a call
|
|
135
|
+
// that waits waits for that too, rather than say it waits and end before its pulse runs.
|
|
136
|
+
while (loop.status().some((status) => statuses.some((asked) => asked.plainFile === status.plainFile) && SCRIPT_WAIT.test(status.why ?? ""))) {
|
|
137
|
+
await new Promise((resolve) => setTimeout(resolve, SCRIPT_POLL_MS));
|
|
138
|
+
await loop.drain();
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
finally {
|
|
143
|
+
if (ran !== undefined)
|
|
144
|
+
endWait(ran.jobs, ran.wait);
|
|
145
|
+
}
|
|
99
146
|
const now = wait ? loop.status().filter((status) => statuses.some((asked) => asked.plainFile === status.plainFile)) : statuses;
|
|
100
147
|
const jobIds = now.flatMap((status) => (status.running !== undefined ? [status.running.jobId] : []));
|
|
148
|
+
const pulses = wait && ran !== undefined ? ran.jobs.list().filter((job) => job.chat === ran.wait.chat && !ran.wait.before.has(job.id)).sort((a, b) => a.sequence - b.sequence) : [];
|
|
149
|
+
const cut = (text) => (text.length > RAN_CHARS ? `${text.slice(0, RAN_CHARS)}\n… cut short: pulses with its id tells the whole of it` : text);
|
|
101
150
|
const text = [
|
|
151
|
+
...(pulses.length > 0
|
|
152
|
+
? [
|
|
153
|
+
`What ran while you waited - ${pulses.length} pulse${pulses.length === 1 ? "" : "s"}:`,
|
|
154
|
+
...pulses.map((job) => `\n<pulse id="${job.id}" landed="${didNotLand(job) ? "no" : "yes"}">\n${cut(didNotLand(job) ? whyFailed(job) : describeJob(job))}\n</pulse>`),
|
|
155
|
+
"",
|
|
156
|
+
"How each module stands now:",
|
|
157
|
+
]
|
|
158
|
+
: []),
|
|
102
159
|
describeModules(now),
|
|
103
160
|
"",
|
|
104
161
|
wait
|
|
@@ -151,11 +208,11 @@ function plainFileOf(cwd, given, what) {
|
|
|
151
208
|
refuseTestPlainFile(plainFile);
|
|
152
209
|
return plainFile;
|
|
153
210
|
}
|
|
154
|
-
/** Whether a /regenerate's words ask for the module from scratch
|
|
211
|
+
/** Whether a /regenerate's words ask for the module from scratch - its code deleted, and all of it regenerated again - or a /conform's, for its conformance tests written again. */
|
|
155
212
|
export function asksFromScratch(words) {
|
|
156
213
|
return FROM_SCRATCH.test(words);
|
|
157
214
|
}
|
|
158
|
-
/** Whether a /regenerate asking for its module from scratch asks for its whole requires chain with it. */
|
|
215
|
+
/** Whether a /regenerate or /conform asking for its module from scratch asks for its whole requires chain with it. */
|
|
159
216
|
export function asksWholeChain(words) {
|
|
160
217
|
return /\bchain\b|\bevery module\b|\ball (the )?modules\b/i.test(words);
|
|
161
218
|
}
|
|
@@ -213,15 +270,23 @@ export function regenerateTool(options) {
|
|
|
213
270
|
const model = options.model !== undefined ? options.model(ctx, plainFile, given.model, work) : given.model;
|
|
214
271
|
const loop = options.loop(ctx);
|
|
215
272
|
const request = { ...(model !== undefined ? { model } : {}), ...(given.guidance !== undefined ? { guidance: given.guidance } : {}) };
|
|
216
|
-
const
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
273
|
+
const wait = options.wait !== undefined ? options.wait(ctx, given.wait) : given.wait === true;
|
|
274
|
+
const waiting = wait && options.jobs !== undefined ? { jobs: options.jobs, wait: startWait(options.jobs) } : undefined;
|
|
275
|
+
let statuses;
|
|
276
|
+
try {
|
|
277
|
+
statuses =
|
|
278
|
+
given.from_scratch !== undefined
|
|
279
|
+
? await loop.fromScratch(plainFile, { ...request, chain: given.from_scratch === "chain" })
|
|
280
|
+
: again.length > 0
|
|
281
|
+
? await loop.regenerateAgain(plainFile, again, request)
|
|
282
|
+
: await loop.bringUp(plainFile, request);
|
|
283
|
+
}
|
|
284
|
+
catch (error) {
|
|
285
|
+
if (waiting !== undefined)
|
|
286
|
+
endWait(waiting.jobs, waiting.wait);
|
|
287
|
+
throw error;
|
|
288
|
+
}
|
|
289
|
+
return loopReply(loop, statuses, wait, waiting);
|
|
225
290
|
});
|
|
226
291
|
},
|
|
227
292
|
});
|
|
@@ -237,7 +302,7 @@ export function driftTool(options) {
|
|
|
237
302
|
"with nothing left, it says the module is fully regenerated. It plans nothing and starts nothing, and calls no model.",
|
|
238
303
|
promptSnippet: "drift: what is left to regenerate in a module, code and conformance tests - starting nothing",
|
|
239
304
|
promptGuidelines: [
|
|
240
|
-
"Use drift when the user asks what is left to build, whether a module is up to date with its spec, or what changed since it was last regenerated. To see the next pulse's prompt
|
|
305
|
+
"Use drift when the user asks what is left to build, whether a module is up to date with its spec, or what changed since it was last regenerated. To see how it is planned into pulses, and the next pulse's prompt, use pulses with plain_file.",
|
|
241
306
|
],
|
|
242
307
|
parameters: Type.Object({
|
|
243
308
|
plain_file: Type.Optional(Type.String({ description: "Path to the .plain file. Omitted: the module the project's config.turri.yaml names" })),
|
package/dist/new-project.js
CHANGED
|
@@ -15,8 +15,8 @@ export const NEW_PROJECT = [
|
|
|
15
15
|
" chosen again.",
|
|
16
16
|
"4. The unit testing script: keep one turri already finds; otherwise start cultivate with implement-unit-testing-script,",
|
|
17
17
|
" plainFile the new module. It runs in the background: go straight on - the module's pulses wait for the script.",
|
|
18
|
-
" Tests only
|
|
19
|
-
" order: the ***test reqs*** - the stack's conformance template - then cultivate with",
|
|
18
|
+
" Tests only once conformance tests are on: they make each change take about twice as long, so the person turns them",
|
|
19
|
+
" on - asked for tests, tell them /conform does - then in this order: the ***test reqs*** - the stack's conformance template - then cultivate with",
|
|
20
20
|
" implement-conformance-testing-script, in the background too, then the scenarios.",
|
|
21
21
|
"5. The first functional spec: the smallest thing that runs and shows something - the server answers GET / with the",
|
|
22
22
|
" app's name, the CLI prints its usage - with no test plain file, unless they asked for tests. parse, fix",
|
package/dist/pi-launch.js
CHANGED
|
@@ -70,7 +70,7 @@ if (interactive) {
|
|
|
70
70
|
args.splice(asked, 1);
|
|
71
71
|
restore = saved;
|
|
72
72
|
}
|
|
73
|
-
driveTerminal(processSession(() => createTurriCore({}, { persist: true
|
|
73
|
+
driveTerminal(processSession(() => createTurriCore({}, { persist: true })),
|
|
74
74
|
// With none of the person's chats saved - only the sentinel's - pi starts a fresh one, and every saved chat is opened beside it.
|
|
75
75
|
restore !== undefined ? { restore, skipFirst: restore.chats.some((chat) => chat.role === undefined) } : {});
|
|
76
76
|
}
|
package/dist/pi.js
CHANGED
|
@@ -8,7 +8,7 @@ import { maskToolResults } from "./regenerate/masking.js";
|
|
|
8
8
|
import { withListArguments } from "./regenerate/list-arguments.js";
|
|
9
9
|
import { checkAgainstScript, ENVIRONMENT_ERROR_TOOL, EnvironmentError, environmentErrorTool, sandboxGapOf } from "./regenerate/environment-error.js";
|
|
10
10
|
import { MODULES_DIR, projectRootOf, sessionsDir } from "./regenerate/paths.js";
|
|
11
|
-
import { currentStopSignal, describeToolCall, describeToolResult, JobStoppedError,
|
|
11
|
+
import { currentStopSignal, describeToolCall, describeToolResult, JobStoppedError, reportActivity, reportNow, reportAgent, reportTranscript, reportModelEvent, reportUsage, } from "./regenerate/activity.js";
|
|
12
12
|
import { debugLogOf, startDebugLog } from "./regenerate/debug-log.js";
|
|
13
13
|
import { firstLine, record } from "./regenerate/ledger.js";
|
|
14
14
|
let thinkingSource;
|
|
@@ -317,6 +317,9 @@ async function askOnce(session, text, onDelta) {
|
|
|
317
317
|
reportNow("thinking");
|
|
318
318
|
}
|
|
319
319
|
else if (update.type === "text_start") {
|
|
320
|
+
// Each message of the turn its own paragraph: the agent's words between tool calls never run into each other.
|
|
321
|
+
if (out !== "" && !/\s$/.test(out))
|
|
322
|
+
out += "\n\n";
|
|
320
323
|
reportNow("writing");
|
|
321
324
|
}
|
|
322
325
|
else if (update.type === "toolcall_start") {
|
|
@@ -330,20 +333,20 @@ async function askOnce(session, text, onDelta) {
|
|
|
330
333
|
lastCallReport = now;
|
|
331
334
|
const block = update.partial.content[update.contentIndex];
|
|
332
335
|
const size = callChars >= 1000 ? `${(callChars / 1000).toFixed(1)}k` : `${callChars}`;
|
|
333
|
-
reportNow(`writing ${block?.name
|
|
336
|
+
reportNow(`writing ${block?.name ?? "a tool"} call · ${size} chars`, { keepSince: true });
|
|
334
337
|
}
|
|
335
338
|
}
|
|
336
339
|
}
|
|
337
340
|
if (event.type === "tool_execution_start") {
|
|
338
341
|
toolStarted.set(event.toolCallId, Date.now());
|
|
339
342
|
const args = JSON.stringify(event.args ?? {});
|
|
340
|
-
transcript({ kind: "tool", text: `${
|
|
343
|
+
transcript({ kind: "tool", text: `${event.toolName} ${clipText(args, MAX_TOOL_ARGS)}`, full: `${event.toolName} ${args}` });
|
|
341
344
|
const took = Date.now() - stepStarted;
|
|
342
345
|
// Which agent made the call, by its role: several work in one pulse.
|
|
343
346
|
const role = agentRoles.get(session);
|
|
344
347
|
const line = `${role !== undefined ? `(${role}) ` : ""}${describeToolCall(event.toolName, event.args)}`;
|
|
345
348
|
reportActivity(took >= 1000 ? `${line} (model ${seconds(took)})` : line);
|
|
346
|
-
reportNow(`running ${
|
|
349
|
+
reportNow(`running ${event.toolName}`);
|
|
347
350
|
}
|
|
348
351
|
if (event.type === "tool_execution_end") {
|
|
349
352
|
failing = event.isError ? (event.toolName === failingTool ? failing + 1 : 1) : 0;
|
|
@@ -352,9 +355,9 @@ async function askOnce(session, text, onDelta) {
|
|
|
352
355
|
// A call its tool refuses never reaches the tool, so no guard on the tools sees it: an agent can
|
|
353
356
|
// make the same bad call, worded a little differently, thousands of times. Its turn ends here, and
|
|
354
357
|
// the harness goes on from there, as after any turn.
|
|
355
|
-
reportActivity(` stopped the agent's turn: ${failing} ${
|
|
358
|
+
reportActivity(` stopped the agent's turn: ${failing} ${event.toolName} calls failed in a row`);
|
|
356
359
|
debugLogOf(session)?.note(`turn stopped: ${failing} ${event.toolName} calls failed in a row`);
|
|
357
|
-
stopTurn(session, `${failing} ${
|
|
360
|
+
stopTurn(session, `${failing} ${event.toolName} calls failed in a row`);
|
|
358
361
|
}
|
|
359
362
|
const output = resultText(event.result);
|
|
360
363
|
const started = toolStarted.get(event.toolCallId);
|
package/dist/plain/check.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Static validation of ***plain, using this repo's own parser - `turri parse`, the chat's `parse`, and the check
|
|
3
|
-
* `
|
|
3
|
+
* `regenerate` runs on the module it is given.
|
|
4
4
|
*
|
|
5
5
|
* It parses each module with its test plain files, resolves its imports and required modules, and reports every error
|
|
6
6
|
* the parser can see without generating anything. The parser's errors come one at a time, the first it meets, as the
|
|
@@ -55,13 +55,6 @@ export declare function resolvePlainTargets(target: string): string[];
|
|
|
55
55
|
* project's test folder, once, at the end.
|
|
56
56
|
*/
|
|
57
57
|
export declare function checkPlainTargets(target: string, templateDirs?: string[]): CheckResult[];
|
|
58
|
-
/**
|
|
59
|
-
* The check of what a ***plain change touched, shared by `change_plain` and `turri change-plain`: each module it
|
|
60
|
-
* touched, an import module as the modules that import it read it, and each test plain file as its module - by its
|
|
61
|
-
* folder - is parsed with its test plain files; a test plain file the change put where it does not belong is refused
|
|
62
|
-
* as `parse` refuses it. A file the change deleted is checked through the module it belonged to.
|
|
63
|
-
*/
|
|
64
|
-
export declare function checkTouchedPlain(paths: string[]): CheckResult[];
|
|
65
58
|
/**
|
|
66
59
|
* One line per file, plus the parser's message under any that failed and turri's next step, or every problem turri
|
|
67
60
|
* found; a module that passed, its functional specs under it, each with its test plain file and its scenarios - and
|
package/dist/plain/check.js
CHANGED
|
@@ -2,12 +2,12 @@ import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
|
|
|
2
2
|
import { basename, extname, join, relative, resolve, sep } from "node:path";
|
|
3
3
|
import { testDirOf } from "../config.js";
|
|
4
4
|
import { projectDirOf, resolveTemplateDirs } from "../regenerate/paths.js";
|
|
5
|
-
import {
|
|
5
|
+
import { isImportModule } from "../regenerate/requires.js";
|
|
6
6
|
import { testingGap } from "../regenerate/testing-steps.js";
|
|
7
7
|
import { missingBaseFolder } from "../regenerate/base-folder.js";
|
|
8
8
|
import { conformanceTestsOn } from "../conformance-switch.js";
|
|
9
9
|
import { testedFuncIds } from "../regenerate/records.js";
|
|
10
|
-
import {
|
|
10
|
+
import { projectModules, strayTestPlainFiles, testPlainFileRefusal } from "../test-plain-files.js";
|
|
11
11
|
import { plainFileParser, PLAIN_SOURCE_FILE_EXTENSION, PREVIOUS_SYNTAX_HINT, readPlainSourceMetadata, REQUIRES_DIRECTIVE } from "./parser.js";
|
|
12
12
|
import { ACCEPTANCE_TESTS, CONFORMANCE_TESTS, getFunctionalSpecs, TEST_PLAIN_FILES, } from "./spec.js";
|
|
13
13
|
/** Whether a parser error is one the previous ***plain syntax makes. */
|
|
@@ -67,7 +67,7 @@ function testingGapsOf(moduleName, path, tree, projectDir, templateDirs) {
|
|
|
67
67
|
if (!conformanceTestsOn(path)) {
|
|
68
68
|
const tested = testedFuncIds(tree);
|
|
69
69
|
return tested.length > 0
|
|
70
|
-
? [`its scenarios are not tested - ${tested.map((funcId) => `${moduleName}:${funcId}`).join(", ")}: conformance tests are off (conformance-tests: false, or unset).
|
|
70
|
+
? [`its scenarios are not tested - ${tested.map((funcId) => `${moduleName}:${funcId}`).join(", ")}: conformance tests are off (conformance-tests: false, or unset). /conform in the chat turns them on, or conformance-tests: true in config.turri.yaml.`]
|
|
71
71
|
: [];
|
|
72
72
|
}
|
|
73
73
|
const tips = tipsAbove(moduleName, projectDir);
|
|
@@ -192,41 +192,6 @@ export function checkPlainTargets(target, templateDirs = []) {
|
|
|
192
192
|
}
|
|
193
193
|
return results;
|
|
194
194
|
}
|
|
195
|
-
/**
|
|
196
|
-
* The check of what a ***plain change touched, shared by `change_plain` and `turri change-plain`: each module it
|
|
197
|
-
* touched, an import module as the modules that import it read it, and each test plain file as its module - by its
|
|
198
|
-
* folder - is parsed with its test plain files; a test plain file the change put where it does not belong is refused
|
|
199
|
-
* as `parse` refuses it. A file the change deleted is checked through the module it belonged to.
|
|
200
|
-
*/
|
|
201
|
-
export function checkTouchedPlain(paths) {
|
|
202
|
-
const modules = new Set();
|
|
203
|
-
const results = [];
|
|
204
|
-
for (const given of paths) {
|
|
205
|
-
const path = resolve(given);
|
|
206
|
-
const place = testPlaceOf(path);
|
|
207
|
-
if (place !== undefined && !place.directory) {
|
|
208
|
-
const stray = strayTestPlainFiles(place.projectDir).find((found) => resolve(place.projectDir, found.file) === path);
|
|
209
|
-
if (stray !== undefined) {
|
|
210
|
-
results.push({ file: path, ok: false, errorType: "a test plain file outside its module's folder", problems: [`${stray.file} - ${stray.problem}`] });
|
|
211
|
-
continue;
|
|
212
|
-
}
|
|
213
|
-
const owner = moduleOfTestPlainFile(path);
|
|
214
|
-
if (owner?.plainFile !== undefined)
|
|
215
|
-
modules.add(owner.plainFile);
|
|
216
|
-
else if (owner !== undefined)
|
|
217
|
-
results.push({ file: path, ok: false, errorType: "a test plain file outside a module's folder", problems: [`${shown(path, place.projectDir)} - no module ${owner.module}`] });
|
|
218
|
-
continue;
|
|
219
|
-
}
|
|
220
|
-
if (!existsSync(path))
|
|
221
|
-
continue;
|
|
222
|
-
const importing = isImportModule(path) ? importingModules(path) : [];
|
|
223
|
-
for (const module of importing.length > 0 ? importing : [path])
|
|
224
|
-
modules.add(resolve(module));
|
|
225
|
-
}
|
|
226
|
-
for (const module of modules)
|
|
227
|
-
results.push(checkPlainFile(module));
|
|
228
|
-
return results;
|
|
229
|
-
}
|
|
230
195
|
/** Columns padded to their widest cell, each line indented under the module's. */
|
|
231
196
|
function columns(rows) {
|
|
232
197
|
const widths = rows.reduce((acc, row) => row.map((cell, index) => Math.max(acc[index] ?? 0, cell.length)), []);
|
|
@@ -205,11 +205,6 @@ export declare function onModelEvent(listener: (event: ModelEvent) => void): ()
|
|
|
205
205
|
export declare function describeTurnIncident(event: ModelEvent): string | undefined;
|
|
206
206
|
export declare function reportModelEvent(event: Omit<ModelEvent, "job">): void;
|
|
207
207
|
export declare function withActivity<T>(sink: ActivitySink, run: () => Promise<T>): Promise<T>;
|
|
208
|
-
/**
|
|
209
|
-
* Run work for no job, whatever job the code that starts it runs for - and clear of any stop signal: the test
|
|
210
|
-
* advisor's, started as the loop looks at a codebase, perhaps as a pulse ends. A pulse's panel, log and stop never reach it.
|
|
211
|
-
*/
|
|
212
|
-
export declare function outsideJobs<T>(run: () => T): T;
|
|
213
208
|
export declare function reportStage(label: string): void;
|
|
214
209
|
export declare function reportActivity(line: string): void;
|
|
215
210
|
/** Say something about the machinery under the work: shown as activity, and kept in the job's log, which the activity is not. */
|
|
@@ -226,8 +221,6 @@ export declare function reportNow(label: string | undefined, options?: {
|
|
|
226
221
|
* the end of it.
|
|
227
222
|
*/
|
|
228
223
|
export declare function withinModules(text: string): string;
|
|
229
|
-
/** A tool's name as the person is shown it. */
|
|
230
|
-
export declare function shownName(name: string): string;
|
|
231
224
|
/** A tool call as one short line. Unknown tools still show up, by name. */
|
|
232
225
|
export declare function describeToolCall(name: string, args: Record<string, unknown> | undefined): string;
|
|
233
226
|
/** The outcome of a test run, or nothing for tools whose outcome is not worth a line. */
|
|
@@ -159,13 +159,6 @@ export function reportModelEvent(event) {
|
|
|
159
159
|
export function withActivity(sink, run) {
|
|
160
160
|
return store.run(sink, run);
|
|
161
161
|
}
|
|
162
|
-
/**
|
|
163
|
-
* Run work for no job, whatever job the code that starts it runs for - and clear of any stop signal: the test
|
|
164
|
-
* advisor's, started as the loop looks at a codebase, perhaps as a pulse ends. A pulse's panel, log and stop never reach it.
|
|
165
|
-
*/
|
|
166
|
-
export function outsideJobs(run) {
|
|
167
|
-
return store.exit(() => stops.exit(run));
|
|
168
|
-
}
|
|
169
162
|
export function reportStage(label) {
|
|
170
163
|
store.getStore()?.stage(label);
|
|
171
164
|
}
|
|
@@ -199,17 +192,6 @@ function clip(text) {
|
|
|
199
192
|
export function withinModules(text) {
|
|
200
193
|
return text.replace(/(?:(?:\/|~\/)(?:[^\s'"`/]+\/)*|(?<![\w.-]))plain_modules\//g, "");
|
|
201
194
|
}
|
|
202
|
-
/**
|
|
203
|
-
* What the person is shown a tool as, where that is not the name its agent calls it by. The agent's name says
|
|
204
|
-
* what the call takes - `change_plain` takes a diff of the spec - and the shown one speaks turri's language.
|
|
205
|
-
*/
|
|
206
|
-
const SHOWN_AS = {
|
|
207
|
-
change_plain: "mutate",
|
|
208
|
-
};
|
|
209
|
-
/** A tool's name as the person is shown it. */
|
|
210
|
-
export function shownName(name) {
|
|
211
|
-
return SHOWN_AS[name] ?? name;
|
|
212
|
-
}
|
|
213
195
|
/** A tool call as one short line. Unknown tools still show up, by name. */
|
|
214
196
|
export function describeToolCall(name, args) {
|
|
215
197
|
const text = (key) => (typeof args?.[key] === "string" ? withinModules(args[key]) : undefined);
|
|
@@ -253,13 +235,13 @@ export function describeToolCall(name, args) {
|
|
|
253
235
|
return `? ask_explorer`;
|
|
254
236
|
default:
|
|
255
237
|
// A hand-over - submit_work, submit_review, a verdict - ends with a check; anything else, a dot.
|
|
256
|
-
return `${/^submit_/.test(name) ? "✓" : "•"} ${
|
|
238
|
+
return `${/^submit_/.test(name) ? "✓" : "•"} ${name}`;
|
|
257
239
|
}
|
|
258
240
|
}
|
|
259
241
|
/** The outcome of a test run, or nothing for tools whose outcome is not worth a line. */
|
|
260
242
|
export function describeToolResult(name, result, isError) {
|
|
261
243
|
if (name !== "run_unit_tests" && name !== "run_conformance_tests") {
|
|
262
|
-
return isError ? ` ✗ ${
|
|
244
|
+
return isError ? ` ✗ ${name} failed` : undefined;
|
|
263
245
|
}
|
|
264
246
|
const exitCode = result?.details?.exitCode;
|
|
265
247
|
if (typeof exitCode !== "number")
|
|
@@ -95,7 +95,9 @@ export function agentShell(role, options = {}) {
|
|
|
95
95
|
const checked = checkCommand(command, commandFence);
|
|
96
96
|
if (!checked.ok) {
|
|
97
97
|
record({ kind: "command.refused", rule: checked.rule });
|
|
98
|
-
|
|
98
|
+
// On one line: a note is a line of the job panel, and a command's newlines would break the screen around it.
|
|
99
|
+
const shown = command.replace(/\s+/g, " ").trim();
|
|
100
|
+
reportNote(` refused an agent's command (${checked.rule}): ${shown.length > 120 ? `${shown.slice(0, 120)}...` : shown}`);
|
|
99
101
|
const output = `Not run: ${checked.reason}`;
|
|
100
102
|
runOptions.onData?.(Buffer.from(output));
|
|
101
103
|
return { exitCode: 126, output };
|
package/dist/regenerate/audit.js
CHANGED
|
@@ -9,6 +9,8 @@ const SKIPPED = new Set([
|
|
|
9
9
|
"node_modules", ".venv", "venv", "__pycache__", ".pytest_cache", ".mypy_cache", ".ruff_cache", ".tox", "target", "build",
|
|
10
10
|
"dist", ".gradle", ".m2", ".cargo", ".next", "coverage", ".git", ".turri", ".plaingit", ".idea", ".vscode",
|
|
11
11
|
]);
|
|
12
|
+
/** How close to the command's start a file's time must be for its time and size alone not to be trusted. */
|
|
13
|
+
const RACY_MS = 1_000;
|
|
12
14
|
/** A file kept whole before the command - at most this big. */
|
|
13
15
|
const MAX_KEPT = 1024 * 1024;
|
|
14
16
|
function stat(path) {
|
|
@@ -156,6 +158,13 @@ export function afterCommand(snapshot) {
|
|
|
156
158
|
continue;
|
|
157
159
|
changed.push(path);
|
|
158
160
|
}
|
|
161
|
+
else if (seen.mtimeMs >= snapshot.at - RACY_MS) {
|
|
162
|
+
// Its time and size as before, but written around when the command started: rewritten to the same size within
|
|
163
|
+
// the same tick of the file system's clock would look the same. What it held before tells - where it was kept.
|
|
164
|
+
const kept = tree.kept?.get(path);
|
|
165
|
+
if (kept !== undefined && !readFileSync(path).equals(kept))
|
|
166
|
+
changed.push(path);
|
|
167
|
+
}
|
|
159
168
|
}
|
|
160
169
|
for (const path of tree.files.keys())
|
|
161
170
|
if (!after.has(path))
|
package/dist/regenerate/cases.js
CHANGED
|
@@ -80,6 +80,8 @@ function scenarioCasesLines(specs, module) {
|
|
|
80
80
|
lines.push(` - added - write a test for each: ${labelled(spec, spec.added, module)}.`);
|
|
81
81
|
if (spec.changed.length > 0)
|
|
82
82
|
lines.push(` - changed - rewrite its tests to the scenario as it reads now: ${labelled(spec, spec.changed, module)}.`);
|
|
83
|
+
if (spec.rewritten.length > 0)
|
|
84
|
+
lines.push(` - written anew - delete every test labelled with it, then write its tests again from the scenario: ${labelled(spec, spec.rewritten, module)}.`);
|
|
83
85
|
if (spec.removed.length > 0)
|
|
84
86
|
lines.push(` - removed - delete every test labelled with it, and its label, and nothing else: ${labelled(spec, spec.removed, module)}.`);
|
|
85
87
|
if (spec.unchanged.length > 0) {
|
|
@@ -91,6 +93,9 @@ function scenarioCasesLines(specs, module) {
|
|
|
91
93
|
if (specs.some((spec) => spec.codeChanged !== undefined)) {
|
|
92
94
|
lines.push("- Where the code changed under unchanged scenarios: their tests were written against the code it replaced. Run them", " against the new code. Those that pass are tests of the new code too - conformance tests are black box - and are", " not rewritten. Fix what fails against its scenario, read with the functional spec's text: what a failing test checks", " that the scenario says stays checked, the test changed only as the new code needs it reached; what it checks that", " the scenario and the specification leave open - a path, a field, a message, a format the old code chose - is the", " new code's choice now: rewrite that check to what the new code does, or take it out. No test may hold the new code", " to what only the old code did.");
|
|
93
95
|
}
|
|
96
|
+
if (specs.some((spec) => spec.rewritten.length > 0)) {
|
|
97
|
+
lines.push("- Written anew: the person asked for these tests to be written again from scratch - their code did not change.", " Delete every test labelled with the scenario first, and what only those tests used, then write the scenario's", " tests from the scenario and the functional spec's text - never from the old tests, and never copying them back.", " A test that comes out as it was has not been written anew. Helpers the other tests use stay as they are.");
|
|
98
|
+
}
|
|
94
99
|
lines.push("- The tests of every other functional spec stay as they are.");
|
|
95
100
|
return lines;
|
|
96
101
|
}
|
|
@@ -126,8 +131,10 @@ export function conformanceReviewCasesBlock(cases, module = "") {
|
|
|
126
131
|
const kept = all((spec) => (spec.codeChanged === undefined ? spec.unchanged : []));
|
|
127
132
|
const rerun = all((spec) => (spec.codeChanged !== undefined ? spec.unchanged : []));
|
|
128
133
|
const removed = all((spec) => spec.removed);
|
|
134
|
+
const rewritten = all((spec) => spec.rewritten);
|
|
129
135
|
return [
|
|
130
136
|
"What this job does to the tests, scenario by scenario - hold it to that:",
|
|
137
|
+
...(rewritten !== "" ? [`- Written anew, as the person asked - their old tests deleted and written again from the scenario, none left as it was: ${rewritten}.`] : []),
|
|
131
138
|
...(kept !== "" ? [`- Unchanged - their tests come out exactly as they were, not rewritten or reworded: ${kept}.`] : []),
|
|
132
139
|
...(rerun !== "" ? [`- Unchanged, the code changed under them - a test changed only where it failed on the new code, and only to what its scenario says: ${rerun}.`] : []),
|
|
133
140
|
...(removed !== "" ? [`- Removed - no test labelled with them is left: ${removed}.`] : []),
|
|
@@ -209,6 +209,11 @@ export declare function placeProblems(input: PlaceInput, answer: PlaceAnswer): s
|
|
|
209
209
|
* spec it changes - else of its first change - and how many more it makes. Never the bare word.
|
|
210
210
|
*/
|
|
211
211
|
export declare function editTitle(changes: SpecChange[]): string;
|
|
212
|
+
/**
|
|
213
|
+
* The title of the pulse that changes what is built, first: what it changes, by name - the functional specs' func-ids,
|
|
214
|
+
* else the kinds of item - so the person reads which, not "changes to what is built".
|
|
215
|
+
*/
|
|
216
|
+
export declare function builtTitle(changes: SpecChange[]): string;
|
|
212
217
|
export declare function planChunks(input: PlanInput, agents?: ChunkAgents, notes?: string[]): Promise<DraftJob[]>;
|
|
213
218
|
export declare function groupPrompt(specs: NewSpec[], steering?: Steering[], maxSpecs?: number, built?: BuiltChange[]): string;
|
|
214
219
|
export declare function placePrompt(input: PlaceInput): string;
|
|
@@ -358,6 +358,21 @@ export function editTitle(changes) {
|
|
|
358
358
|
const more = `, and ${rest.length} more`;
|
|
359
359
|
return `${shortTitle(line, TITLE_CHARS - more.length, TITLE_WORDS - 3).replace(/[.,;:]+$/, "")}${more}`;
|
|
360
360
|
}
|
|
361
|
+
/**
|
|
362
|
+
* The title of the pulse that changes what is built, first: what it changes, by name - the functional specs' func-ids,
|
|
363
|
+
* else the kinds of item - so the person reads which, not "changes to what is built".
|
|
364
|
+
*/
|
|
365
|
+
export function builtTitle(changes) {
|
|
366
|
+
const ids = [...new Set(changes.filter(isFunctionalSpec).map(funcIdOf).filter((id) => id !== undefined))];
|
|
367
|
+
if (ids.length > 0) {
|
|
368
|
+
const named = ids.slice(0, 2).join(", ");
|
|
369
|
+
const others = changes.length - changes.filter(isFunctionalSpec).length;
|
|
370
|
+
const more = ids.length - 2 + others;
|
|
371
|
+
return `Changes to ${named}${more > 0 ? `, and ${more} more` : ""}`;
|
|
372
|
+
}
|
|
373
|
+
const kinds = [...new Set(changes.map((change) => WHAT[change.section] ?? change.section))].map((kind) => `${kind}s`);
|
|
374
|
+
return `Changes to the ${kinds.length > 1 ? `${kinds.slice(0, -1).join(", ")} and ${kinds.at(-1)}` : kinds[0]}`;
|
|
375
|
+
}
|
|
361
376
|
/** A change as the title agent is shown it: what it is, how it changes, its text now - and before, for a change. */
|
|
362
377
|
function titleChangeOf(change) {
|
|
363
378
|
return {
|
|
@@ -553,7 +568,7 @@ async function cut(input, agents, notes) {
|
|
|
553
568
|
const bySpec = new Map(specs.map((change, index) => [index + 1, change]));
|
|
554
569
|
const firstBuilt = () => builtChanges.filter((change) => (builtTo.get(change) ?? "first") === "first");
|
|
555
570
|
const chunksFor = (list) => [
|
|
556
|
-
...(firstBuilt().length > 0 ? [{ title:
|
|
571
|
+
...(firstBuilt().length > 0 ? [{ title: builtTitle(firstBuilt()), specs: [], definitions: [], reqs: [], built: firstBuilt() }] : []),
|
|
557
572
|
...list.map((group) => ({
|
|
558
573
|
title: group.title,
|
|
559
574
|
specs: group.specs.map((number) => bySpec.get(number)),
|
|
@@ -74,12 +74,16 @@ export interface ScenarioRef {
|
|
|
74
74
|
* - `codeChanged`: the functional spec's code moved under its unchanged scenarios - its text or a file it links changed
|
|
75
75
|
* (`text`), it was regenerated again (`again`), or a concept it uses changed (`concept`): their tests are run on the
|
|
76
76
|
* new code, and those that fail are fixed against the scenario.
|
|
77
|
+
* - rewritten: its tests are to be written anew - `conform` named it, or asked for its module from scratch: every one
|
|
78
|
+
* labelled with the scenario deleted and written again from it. A functional spec marked so has every scenario it has
|
|
79
|
+
* now rewritten, and those it no longer has removed.
|
|
77
80
|
*/
|
|
78
81
|
export interface ScenarioCases extends TouchedSpec {
|
|
79
82
|
added: ScenarioRef[];
|
|
80
83
|
changed: ScenarioRef[];
|
|
81
84
|
removed: ScenarioRef[];
|
|
82
85
|
unchanged: ScenarioRef[];
|
|
86
|
+
rewritten: ScenarioRef[];
|
|
83
87
|
codeChanged?: "text" | "again" | "concept";
|
|
84
88
|
}
|
|
85
89
|
/**
|
package/dist/regenerate/drift.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DEFAULT_CONCEPTS, extractConceptsFromDefinition, extractConceptsFromSpecText } from "../plain/concepts.js";
|
|
2
2
|
import { ACCEPTANCE_TESTS, CONFORMANCE_TESTS, DEFINITIONS, FUNCTIONAL_REQUIREMENTS, REQUIRED_FUNCTIONAL_SPECS } from "../plain/spec.js";
|
|
3
|
-
import { codeTree, conformanceTarget, marksRegenerateAgain } from "./records.js";
|
|
3
|
+
import { codeTree, conformanceTarget, marksConformAgain, marksRegenerateAgain } from "./records.js";
|
|
4
4
|
import { applyChanges, changesBetween, isMove, parseTree, resourcesChanged, serializeTree } from "./spec-steps.js";
|
|
5
5
|
/**
|
|
6
6
|
* The work, derived from the records - see docs/regenerating.md. Nothing here is stored: what is left
|
|
@@ -38,15 +38,26 @@ function scenariosIn(item) {
|
|
|
38
38
|
function codeOf(item) {
|
|
39
39
|
if (item === undefined)
|
|
40
40
|
return "";
|
|
41
|
-
const { [CONFORMANCE_TESTS]: _conformance, [ACCEPTANCE_TESTS]: _acceptance, regenerate_again: _again, ...rest } = item;
|
|
41
|
+
const { [CONFORMANCE_TESTS]: _conformance, [ACCEPTANCE_TESTS]: _acceptance, regenerate_again: _again, conform_again: _conform, ...rest } = item;
|
|
42
42
|
return JSON.stringify({ ...rest, markdown: rest.markdown.trim() });
|
|
43
43
|
}
|
|
44
|
-
/**
|
|
45
|
-
|
|
44
|
+
/**
|
|
45
|
+
* A functional spec's scenarios by case, from the item its tests were written for to the one they are to be. `anew`: its
|
|
46
|
+
* tests are written again, every scenario it has now rewritten.
|
|
47
|
+
*/
|
|
48
|
+
function scenarioCasesOf(spec, was, is, code, anew = false) {
|
|
46
49
|
const before = scenariosIn(was);
|
|
47
50
|
const after = scenariosIn(is);
|
|
48
51
|
const plain = ({ kind, id, text }) => ({ kind, id, text });
|
|
49
|
-
const cases = { ...spec, added: [], changed: [], removed: [], unchanged: [] };
|
|
52
|
+
const cases = { ...spec, added: [], changed: [], removed: [], unchanged: [], rewritten: [] };
|
|
53
|
+
if (anew) {
|
|
54
|
+
for (const scenario of after.values())
|
|
55
|
+
cases.rewritten.push(plain(scenario));
|
|
56
|
+
for (const [key, scenario] of before)
|
|
57
|
+
if (!after.has(key))
|
|
58
|
+
cases.removed.push(plain(scenario));
|
|
59
|
+
return cases;
|
|
60
|
+
}
|
|
50
61
|
for (const [key, scenario] of after) {
|
|
51
62
|
const old = before.get(key);
|
|
52
63
|
if (old === undefined)
|
|
@@ -125,6 +136,8 @@ export function casesOf(before, changes, options = {}) {
|
|
|
125
136
|
const patch = [];
|
|
126
137
|
const again = [];
|
|
127
138
|
const removed = [];
|
|
139
|
+
/** Of those regenerated again, the ones whose conformance tests are written anew: conform asked for them again. */
|
|
140
|
+
const anew = new Set();
|
|
128
141
|
/** Each functional spec touched, as the tests record has it and as it is to be: its scenarios' cases are worked out from them. */
|
|
129
142
|
const items = new Map();
|
|
130
143
|
const keyOf = (spec) => `${spec.module ?? ""}:${spec.funcId}`;
|
|
@@ -139,6 +152,13 @@ export function casesOf(before, changes, options = {}) {
|
|
|
139
152
|
const required = change.section === REQUIRED_FUNCTIONAL_SPECS;
|
|
140
153
|
const was = itemOfLine(change.before);
|
|
141
154
|
const is = itemOfLine(change.after);
|
|
155
|
+
// Its conformance tests marked to be written again: written anew, whatever else changed - its code untouched.
|
|
156
|
+
if (change.kind === "change" && is !== undefined && marksConformAgain(was)) {
|
|
157
|
+
const touched = seen(touchedOf(is, required), was, is);
|
|
158
|
+
again.push(touched);
|
|
159
|
+
anew.add(keyOf(touched));
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
142
162
|
// Marked to regenerate again: regenerated again, whatever else changed in its text - its own or, required, another module's.
|
|
143
163
|
if (change.kind === "change" && is !== undefined && marksRegenerateAgain(was)) {
|
|
144
164
|
again.push(seen(touchedOf(is, required), was, is));
|
|
@@ -199,7 +219,7 @@ export function casesOf(before, changes, options = {}) {
|
|
|
199
219
|
const { was, is } = items.get(keyOf(spec)) ?? {};
|
|
200
220
|
return scenarioCasesOf(spec, was, is, was === is ? "concept" : undefined);
|
|
201
221
|
}),
|
|
202
|
-
...again.map((spec) => scenarioCasesOf(spec, items.get(keyOf(spec))?.was, items.get(keyOf(spec))?.is, "again")),
|
|
222
|
+
...again.map((spec) => scenarioCasesOf(spec, items.get(keyOf(spec))?.was, items.get(keyOf(spec))?.is, "again", anew.has(keyOf(spec)))),
|
|
203
223
|
...removed.map((spec) => scenarioCasesOf(spec, items.get(keyOf(spec))?.was, undefined)),
|
|
204
224
|
]
|
|
205
225
|
: undefined;
|