@turri-dev/cli 0.2.4-next.8422d0f → 0.2.4-next.efe96fe
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -6
- package/dist/bedrock-region.js +3 -3
- package/dist/chat-idle.d.ts +2 -2
- package/dist/chat-idle.js +2 -2
- package/dist/chat-models.d.ts +1 -1
- package/dist/chat-models.js +1 -1
- package/dist/chat-scope.d.ts +1 -3
- package/dist/chats.d.ts +2 -12
- package/dist/chats.js +3 -26
- package/dist/cli.js +11 -30
- package/dist/config-edit.d.ts +20 -8
- package/dist/config-edit.js +29 -23
- package/dist/config.d.ts +62 -71
- package/dist/config.js +170 -125
- package/dist/conform-cli.js +14 -3
- package/dist/conformance-switch.d.ts +13 -22
- package/dist/conformance-switch.js +37 -59
- package/dist/drift-cli.js +1 -1
- package/dist/extension.d.ts +8 -10
- package/dist/extension.js +257 -429
- package/dist/genome.js +9 -48
- package/dist/graph.js +3 -5
- package/dist/host-session.d.ts +5 -16
- package/dist/host-session.js +4 -6
- package/dist/host.d.ts +2 -4
- package/dist/host.js +4 -7
- package/dist/identity.js +0 -1
- package/dist/init-config.d.ts +0 -1
- package/dist/init-config.js +3 -10
- package/dist/installed-providers.d.ts +1 -1
- package/dist/installed-providers.js +1 -1
- package/dist/loop-cli.d.ts +4 -3
- package/dist/loop-cli.js +13 -11
- package/dist/loop-tools.d.ts +37 -18
- package/dist/loop-tools.js +118 -58
- package/dist/new-project.js +2 -2
- package/dist/parse-cli.js +2 -2
- package/dist/pi-launch.js +4 -1
- package/dist/pi-settings.d.ts +4 -0
- package/dist/pi-settings.js +39 -0
- package/dist/pi.js +12 -9
- package/dist/plain/check.d.ts +2 -9
- package/dist/plain/check.js +6 -39
- package/dist/plain-files.js +4 -4
- package/dist/regenerate/activity.d.ts +0 -7
- package/dist/regenerate/activity.js +2 -20
- package/dist/regenerate/agent-env.d.ts +1 -1
- package/dist/regenerate/agent-env.js +3 -3
- package/dist/regenerate/agent-shell.js +5 -3
- package/dist/regenerate/audit.js +9 -0
- package/dist/regenerate/base-folder.d.ts +2 -2
- package/dist/regenerate/base-folder.js +1 -1
- package/dist/regenerate/cases.js +7 -0
- package/dist/regenerate/chunk-plan.d.ts +5 -0
- package/dist/regenerate/chunk-plan.js +16 -1
- package/dist/regenerate/drift.d.ts +4 -0
- package/dist/regenerate/drift.js +26 -6
- package/dist/regenerate/failure-reports.d.ts +28 -0
- package/dist/regenerate/failure-reports.js +79 -0
- package/dist/regenerate/job-panel.js +3 -1
- package/dist/regenerate/jobs-tree.js +1 -1
- package/dist/regenerate/jobs.d.ts +4 -2
- package/dist/regenerate/jobs.js +14 -10
- package/dist/regenerate/ledger-view.d.ts +11 -24
- package/dist/regenerate/ledger-view.js +14 -60
- package/dist/regenerate/ledger.d.ts +2 -15
- package/dist/regenerate/ledger.js +1 -1
- package/dist/regenerate/loop.d.ts +48 -62
- package/dist/regenerate/loop.js +296 -131
- package/dist/regenerate/model-names.d.ts +33 -0
- package/dist/regenerate/{engine.js → model-names.js} +2 -28
- package/dist/regenerate/paths.d.ts +1 -1
- package/dist/regenerate/paths.js +2 -2
- package/dist/regenerate/records.d.ts +11 -0
- package/dist/regenerate/records.js +15 -0
- package/dist/regenerate/regenerate.d.ts +0 -2
- package/dist/regenerate/regenerate.js +4 -15
- package/dist/regenerate/renames.js +4 -4
- package/dist/regenerate/requires.d.ts +7 -0
- package/dist/regenerate/requires.js +24 -18
- package/dist/regenerate/scripts-being-written.d.ts +4 -4
- package/dist/regenerate/scripts-being-written.js +3 -3
- package/dist/regenerate/spec-map.js +3 -3
- package/dist/regenerate/standing.js +1 -1
- package/dist/regenerate/submit-work.d.ts +2 -0
- package/dist/regenerate/submit-work.js +8 -3
- package/dist/regenerate/test-scripts.d.ts +2 -1
- package/dist/regenerate/test-scripts.js +33 -23
- package/dist/regenerate/testing-steps.d.ts +16 -5
- package/dist/regenerate/testing-steps.js +28 -9
- package/dist/regenerate-cli.js +18 -9
- package/dist/self-invocation.d.ts +11 -0
- package/dist/self-invocation.js +33 -7
- package/dist/sentinel.js +8 -5
- package/dist/{config-command.d.ts → settings.d.ts} +13 -8
- package/dist/{config-command.js → settings.js} +155 -24
- package/dist/setup.d.ts +2 -2
- package/dist/setup.js +7 -7
- package/dist/skill.d.ts +0 -11
- package/dist/skill.js +0 -9
- package/dist/tools.js +2 -3
- package/dist/turri-versions.js +2 -1
- package/docs/README.md +2 -4
- package/docs/authoring-plain.md +3 -3
- package/docs/chats.md +4 -7
- package/docs/claude-subscription.md +2 -2
- package/docs/config.md +55 -45
- package/docs/deploy.md +1 -1
- package/docs/development.md +3 -4
- package/docs/headless.md +6 -5
- package/docs/hosting.md +11 -11
- package/docs/parser.md +3 -3
- package/docs/regenerating.md +27 -19
- package/docs/sentinel.md +6 -6
- package/docs/skills-and-gates.md +4 -9
- package/docs/using.md +20 -37
- package/genome/rules/project-model.md +2 -1
- package/genome/rules/test-plain-files.md +15 -7
- package/genome/rules/turri-regeneration.md +6 -9
- package/genome/skills/convert-old-syntax/SKILL.md +5 -5
- package/genome/skills/implement-conformance-testing-script/SKILL.md +2 -2
- package/genome/skills/implement-unit-testing-script/SKILL.md +3 -3
- package/package.json +1 -1
- package/dist/advisor-chat.d.ts +0 -63
- package/dist/advisor-chat.js +0 -290
- package/dist/change-plain-cli.d.ts +0 -1
- package/dist/change-plain-cli.js +0 -55
- package/dist/ledger-cli.d.ts +0 -1
- package/dist/ledger-cli.js +0 -50
- package/dist/ledger-tools.d.ts +0 -10
- package/dist/ledger-tools.js +0 -64
- package/dist/regenerate/advisor-records.d.ts +0 -93
- package/dist/regenerate/advisor-records.js +0 -110
- package/dist/regenerate/advisor-runs.d.ts +0 -87
- package/dist/regenerate/advisor-runs.js +0 -327
- package/dist/regenerate/engine.d.ts +0 -52
- package/dist/regenerate/test-advisor.d.ts +0 -101
- package/dist/regenerate/test-advisor.js +0 -379
- package/dist/spec-tools.d.ts +0 -36
- package/dist/spec-tools.js +0 -128
- package/dist/stacks.d.ts +0 -13
- package/dist/stacks.js +0 -96
- package/docs/test-advisor.md +0 -110
|
@@ -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")
|
|
@@ -42,7 +42,7 @@ export declare function tidyCaches(scratch: string, keepMb: number): void;
|
|
|
42
42
|
* JVMs' sockets beside it.
|
|
43
43
|
*/
|
|
44
44
|
export declare const DARWIN_TEMP_SUFFIX = "DIRHELPER_USER_DIR_SUFFIX";
|
|
45
|
-
/** What `agent-env:` - the project's, with the
|
|
45
|
+
/** What `agent-env:` - the project's, with the pulse's module's own file's added - passes, and what of it is not there. Reads only. */
|
|
46
46
|
export declare function passedCredentials(module: string, hostEnv: NodeJS.ProcessEnv): {
|
|
47
47
|
values: Record<string, string>;
|
|
48
48
|
missing: MissingCredential[];
|
|
@@ -2,7 +2,7 @@ import { createHash } from "node:crypto";
|
|
|
2
2
|
import { chmodSync, existsSync, lstatSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { homedir } from "node:os";
|
|
4
4
|
import { basename, join, resolve } from "node:path";
|
|
5
|
-
import { DEFAULT_CACHE_KEEP_MB, readProjectConfig,
|
|
5
|
+
import { DEFAULT_CACHE_KEEP_MB, readProjectConfig, configModuleOf } from "../config.js";
|
|
6
6
|
import { registerSecrets } from "./masking.js";
|
|
7
7
|
import { projectRootOf, modulesScratchDir } from "./paths.js";
|
|
8
8
|
/**
|
|
@@ -258,10 +258,10 @@ export const DARWIN_TEMP_SUFFIX = "DIRHELPER_USER_DIR_SUFFIX";
|
|
|
258
258
|
function darwinTempSuffix(module, name) {
|
|
259
259
|
return `turri-${name.replace(/[^\w.-]/g, "_")}-${createHash("sha256").update(resolve(module)).digest("hex").slice(0, 8)}`;
|
|
260
260
|
}
|
|
261
|
-
/** What `agent-env:` - the project's, with the
|
|
261
|
+
/** What `agent-env:` - the project's, with the pulse's module's own file's added - passes, and what of it is not there. Reads only. */
|
|
262
262
|
export function passedCredentials(module, hostEnv) {
|
|
263
263
|
const root = projectRootOf(module);
|
|
264
|
-
const setting = readProjectConfig(root,
|
|
264
|
+
const setting = readProjectConfig(root, configModuleOf(root)).agentEnv;
|
|
265
265
|
const values = {};
|
|
266
266
|
const missing = [];
|
|
267
267
|
if (setting === undefined)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { dirname, join, resolve, sep } from "node:path";
|
|
2
|
-
import { readProjectConfig,
|
|
2
|
+
import { readProjectConfig, configModuleOf } from "../config.js";
|
|
3
3
|
import { reportNote } from "./activity.js";
|
|
4
4
|
import { record } from "./ledger.js";
|
|
5
5
|
import { agentEnvironment, DARWIN_TEMP_SUFFIX, packageCacheDir, TOOLCHAIN_VARIABLES } from "./agent-env.js";
|
|
@@ -32,7 +32,7 @@ export function agentShell(role, options = {}) {
|
|
|
32
32
|
const project = projectRootOf(workdir);
|
|
33
33
|
const { env } = agentEnvironment(moduleDir);
|
|
34
34
|
const root = projectRootOf(moduleDir);
|
|
35
|
-
const toolchains = readProjectConfig(root,
|
|
35
|
+
const toolchains = readProjectConfig(root, configModuleOf(root)).toolchains ?? [];
|
|
36
36
|
const machine = machineFor(env, TOOLCHAIN_VARIABLES, toolchains);
|
|
37
37
|
const writable = writableFor(env, moduleDir);
|
|
38
38
|
const commandFence = {
|
|
@@ -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))
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BASE_RECORD_FILE } from "./paths.ts";
|
|
2
2
|
export { BASE_RECORD_FILE };
|
|
3
3
|
/**
|
|
4
|
-
* A base folder (`base-folder:` in config.turri.yaml, a
|
|
4
|
+
* A base folder (`base-folder:` in config.turri.yaml, a module's own in its file): what a codebase that requires no other
|
|
5
5
|
* module starts from instead of nothing - an existing codebase to build on, files to use (images, animations, fonts), or
|
|
6
6
|
* both. It is copied in once, before the codebase's first pulse, and never written to; what was copied is recorded beside
|
|
7
7
|
* the code record, and goes up the chain with the code, so every coding agent of the chain is told where its codebase
|
|
@@ -21,7 +21,7 @@ export declare class MissingBaseFolderError extends Error {
|
|
|
21
21
|
readonly moduleName: string;
|
|
22
22
|
constructor(moduleName: string, named: string, path: string);
|
|
23
23
|
}
|
|
24
|
-
/** The base folder a module's codebase starts from - its
|
|
24
|
+
/** The base folder a module's codebase starts from - its own file's over the project's - as named and as a path; none when the config names none. */
|
|
25
25
|
export declare function baseFolderOf(plainFile: string): {
|
|
26
26
|
named: string;
|
|
27
27
|
path: string;
|
|
@@ -21,7 +21,7 @@ export class MissingBaseFolderError extends Error {
|
|
|
21
21
|
this.moduleName = moduleName;
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
-
/** The base folder a module's codebase starts from - its
|
|
24
|
+
/** The base folder a module's codebase starts from - its own file's over the project's - as named and as a path; none when the config names none. */
|
|
25
25
|
export function baseFolderOf(plainFile) {
|
|
26
26
|
const named = configForSpec(plainFile).baseFolder;
|
|
27
27
|
if (named === undefined)
|
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;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Job } from "./jobs.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Why a pulse did not land, kept past its session.
|
|
4
|
+
*
|
|
5
|
+
* Outside debug mode a pulse's log and transcript go as it ends (pulse-files.ts), and the ledger keeps facts, never
|
|
6
|
+
* what a tool printed. So a pulse of an earlier session would be told as one-line facts alone - its failure's first
|
|
7
|
+
* line, its test runs' exit codes. What `pulses` says of one that did not land - its diagnosis, the stages that went
|
|
8
|
+
* wrong, the last failing test run's output, the last review that sent the work back, the tool calls that failed - is
|
|
9
|
+
* written here as it ends, whatever the debug setting, masked as the logs are: `.turri/pulses/<id>.md`. Kept while the
|
|
10
|
+
* ledger is on, and as long as the project keeps a ledger (`ledger-keep:`, 0 for none); the newest `KEPT` alone.
|
|
11
|
+
*/
|
|
12
|
+
/** The folder, in a project's `.turri`. */
|
|
13
|
+
export declare const REPORTS_DIR = "pulses";
|
|
14
|
+
/** How many reports a project keeps: the newest. */
|
|
15
|
+
export declare const KEPT = 200;
|
|
16
|
+
/** Where a project's reports are. */
|
|
17
|
+
export declare function reportsDir(project: string): string;
|
|
18
|
+
/** Whether a pulse ended without landing: failed, stopped, or finished with nothing landed. */
|
|
19
|
+
export declare function didNotLand(job: Job): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* A pulse has ended: one that failed, or finished with nothing landed, has its report written, and the oldest past
|
|
22
|
+
* `KEPT` go. A stopped one has none - the person halted it, or the ***plain moved on, and the ledger says which. Nothing
|
|
23
|
+
* while the ledger is off, or where the project keeps none. Never throws: a report that cannot be written is never a
|
|
24
|
+
* reason for the pulse to fail.
|
|
25
|
+
*/
|
|
26
|
+
export declare function keepFailureReport(project: string, job: Job): void;
|
|
27
|
+
/** A pulse's report, by its whole id - or undefined when it has none. */
|
|
28
|
+
export declare function failureReport(project: string, id: string): string | undefined;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { existsSync, readdirSync, readFileSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { join, resolve } from "node:path";
|
|
3
|
+
import { readProjectConfig } from "../config.js";
|
|
4
|
+
import { whyFailed } from "./diagnose-job.js";
|
|
5
|
+
import { DEFAULT_LEDGER_KEEP_MB, ledgerRun } from "./ledger.js";
|
|
6
|
+
import { maskSecrets } from "./masking.js";
|
|
7
|
+
import { ensureInScratch } from "./paths.js";
|
|
8
|
+
/**
|
|
9
|
+
* Why a pulse did not land, kept past its session.
|
|
10
|
+
*
|
|
11
|
+
* Outside debug mode a pulse's log and transcript go as it ends (pulse-files.ts), and the ledger keeps facts, never
|
|
12
|
+
* what a tool printed. So a pulse of an earlier session would be told as one-line facts alone - its failure's first
|
|
13
|
+
* line, its test runs' exit codes. What `pulses` says of one that did not land - its diagnosis, the stages that went
|
|
14
|
+
* wrong, the last failing test run's output, the last review that sent the work back, the tool calls that failed - is
|
|
15
|
+
* written here as it ends, whatever the debug setting, masked as the logs are: `.turri/pulses/<id>.md`. Kept while the
|
|
16
|
+
* ledger is on, and as long as the project keeps a ledger (`ledger-keep:`, 0 for none); the newest `KEPT` alone.
|
|
17
|
+
*/
|
|
18
|
+
/** The folder, in a project's `.turri`. */
|
|
19
|
+
export const REPORTS_DIR = "pulses";
|
|
20
|
+
/** How many reports a project keeps: the newest. */
|
|
21
|
+
export const KEPT = 200;
|
|
22
|
+
/** Where a project's reports are. */
|
|
23
|
+
export function reportsDir(project) {
|
|
24
|
+
return join(resolve(project), ".turri", REPORTS_DIR);
|
|
25
|
+
}
|
|
26
|
+
/** Whether a pulse ended without landing: failed, stopped, or finished with nothing landed. */
|
|
27
|
+
export function didNotLand(job) {
|
|
28
|
+
if (job.status === "failed" || job.status === "stopped")
|
|
29
|
+
return true;
|
|
30
|
+
return job.status === "succeeded" && job.details?.landed === false;
|
|
31
|
+
}
|
|
32
|
+
/** Whether the project keeps a ledger, and so its reports. */
|
|
33
|
+
function keeps(project) {
|
|
34
|
+
try {
|
|
35
|
+
return (readProjectConfig(project).ledgerKeep ?? DEFAULT_LEDGER_KEEP_MB) > 0;
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* A pulse has ended: one that failed, or finished with nothing landed, has its report written, and the oldest past
|
|
43
|
+
* `KEPT` go. A stopped one has none - the person halted it, or the ***plain moved on, and the ledger says which. Nothing
|
|
44
|
+
* while the ledger is off, or where the project keeps none. Never throws: a report that cannot be written is never a
|
|
45
|
+
* reason for the pulse to fail.
|
|
46
|
+
*/
|
|
47
|
+
export function keepFailureReport(project, job) {
|
|
48
|
+
if (ledgerRun() === undefined || job.status === "stopped" || !didNotLand(job) || !keeps(project))
|
|
49
|
+
return;
|
|
50
|
+
try {
|
|
51
|
+
const dir = ensureInScratch(join(resolve(project), ".turri"), reportsDir(project));
|
|
52
|
+
writeFileSync(join(dir, `${job.id}.md`), `${maskSecrets(whyFailed(job))}\n`);
|
|
53
|
+
prune(dir);
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
/* kept when it can be: the ledger still has the facts */
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/** The newest `KEPT` reports stay. */
|
|
60
|
+
function prune(dir) {
|
|
61
|
+
const reports = readdirSync(dir)
|
|
62
|
+
.filter((name) => name.endsWith(".md"))
|
|
63
|
+
.map((name) => ({ name, at: statSync(join(dir, name)).mtimeMs }))
|
|
64
|
+
.sort((a, b) => b.at - a.at);
|
|
65
|
+
for (const old of reports.slice(KEPT))
|
|
66
|
+
unlinkSync(join(dir, old.name));
|
|
67
|
+
}
|
|
68
|
+
/** A pulse's report, by its whole id - or undefined when it has none. */
|
|
69
|
+
export function failureReport(project, id) {
|
|
70
|
+
const file = join(reportsDir(project), `${id}.md`);
|
|
71
|
+
if (!existsSync(file))
|
|
72
|
+
return undefined;
|
|
73
|
+
try {
|
|
74
|
+
return readFileSync(file, "utf8").trimEnd();
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -227,7 +227,9 @@ export function jobPanelLines(jobs, options = {}) {
|
|
|
227
227
|
const key = options.keys ?? ((_key, text) => text);
|
|
228
228
|
lines.push(` ${key("trace", `ctrl+o to ${expanded ? "collapse" : "expand"} the trace`)} · ${key("peek", `${PANEL_KEY} to peek at regen`)}`);
|
|
229
229
|
}
|
|
230
|
-
|
|
230
|
+
// A line is one row of the screen: a newline in one - an agent's words, a command - would draw past what the renderer
|
|
231
|
+
// tracks and stay on the screen, so each part is a row of its own.
|
|
232
|
+
return lines.flatMap((line) => line.split(/\r?\n/));
|
|
231
233
|
}
|
|
232
234
|
/**
|
|
233
235
|
* The keys of the line, painted at `now`'s breath: one not pressed yet in the text's colour mixed toward the dim one, one
|
|
@@ -209,7 +209,7 @@ export function jobsTreeLines(jobs, state, width, style) {
|
|
|
209
209
|
});
|
|
210
210
|
// The ledger has more than the runs shown: where to find them.
|
|
211
211
|
if (state.open.earlier && (state.earlierMore ?? 0) > 0) {
|
|
212
|
-
lines.push(style.muted(` ${state.earlierMore} earlier run${state.earlierMore === 1 ? "" : "s"} in the ledger -
|
|
212
|
+
lines.push(style.muted(` ${state.earlierMore} earlier run${state.earlierMore === 1 ? "" : "s"} in the ledger - pulses with runs lists them`));
|
|
213
213
|
}
|
|
214
214
|
return { lines, rowStarts, rows };
|
|
215
215
|
}
|
|
@@ -46,8 +46,8 @@ export interface Job {
|
|
|
46
46
|
note?: string;
|
|
47
47
|
/** "provider/model-id" its agents run on, when known. */
|
|
48
48
|
model?: string;
|
|
49
|
-
/** The
|
|
50
|
-
|
|
49
|
+
/** The module whose config.turri.<module>.yaml it is built with, over config.turri.yaml - as worked out when it was queued. */
|
|
50
|
+
configModule?: string;
|
|
51
51
|
/** The chat it was asked for in (chat-scope.ts): the one told how it went. */
|
|
52
52
|
chat?: string;
|
|
53
53
|
status: JobStatus;
|
|
@@ -60,6 +60,8 @@ export interface Job {
|
|
|
60
60
|
planning?: {
|
|
61
61
|
since: number;
|
|
62
62
|
};
|
|
63
|
+
/** A row of the work loop's planned by a look ahead: it waits for regenerate, conform or /regenerate to start it. */
|
|
64
|
+
lookedAhead?: true;
|
|
63
65
|
/** While queued: the jobs it is waiting for. */
|
|
64
66
|
waitingOn: string[];
|
|
65
67
|
finishedAt?: number;
|
package/dist/regenerate/jobs.js
CHANGED
|
@@ -5,9 +5,10 @@ import { describeEnvironmentError, EnvironmentError, missingCredentials } from "
|
|
|
5
5
|
import { addAgentReport, describeAgents, JobStoppedError, withActivity } from "./activity.js";
|
|
6
6
|
import { projectOfLanes, startJobLog } from "./job-log.js";
|
|
7
7
|
import { firstLine, healing, record } from "./ledger.js";
|
|
8
|
-
import {
|
|
8
|
+
import { debugMode, moduleConfigFile, pinnedConfigModule, withConfigModule } from "../config.js";
|
|
9
9
|
import { currentChat } from "../chat-scope.js";
|
|
10
10
|
import { pulseEnded, pulseWrote } from "./pulse-files.js";
|
|
11
|
+
import { keepFailureReport } from "./failure-reports.js";
|
|
11
12
|
const DEFAULT_TAIL_CHARS = 4000;
|
|
12
13
|
const ACTIVITY_LINES = 10;
|
|
13
14
|
/** A long render's full transcript is kept, up to about this much text. */
|
|
@@ -57,9 +58,9 @@ export function createJobRegistry(options) {
|
|
|
57
58
|
},
|
|
58
59
|
start(input) {
|
|
59
60
|
const id = randomUUID().slice(0, 8);
|
|
60
|
-
// The
|
|
61
|
-
//
|
|
62
|
-
const
|
|
61
|
+
// The config pinned for the work that queues it, as it is queued - not as it starts: a job that waits for a slot is
|
|
62
|
+
// built with the config it was planned with, whatever the files say meanwhile.
|
|
63
|
+
const configModule = pinnedConfigModule();
|
|
63
64
|
const chat = currentChat()?.id;
|
|
64
65
|
const claimed = [...new Set(input.lanes ?? [])];
|
|
65
66
|
const blockers = [
|
|
@@ -81,7 +82,7 @@ export function createJobRegistry(options) {
|
|
|
81
82
|
...(input.diffWhere !== undefined ? { diffWhere: input.diffWhere } : {}),
|
|
82
83
|
...(input.cases !== undefined ? { cases: input.cases } : {}),
|
|
83
84
|
model: input.model,
|
|
84
|
-
...(
|
|
85
|
+
...(configModule !== undefined ? { configModule } : {}),
|
|
85
86
|
...(chat !== undefined ? { chat } : {}),
|
|
86
87
|
...(input.follows !== undefined ? { follows: input.follows } : {}),
|
|
87
88
|
status: blockers.length > 0 || (limit !== undefined && active >= limit) ? "queued" : "running",
|
|
@@ -107,7 +108,7 @@ export function createJobRegistry(options) {
|
|
|
107
108
|
...(input.pulse !== undefined ? { pulse: input.pulse } : {}),
|
|
108
109
|
...(input.title !== undefined ? { title: input.title } : {}),
|
|
109
110
|
...(input.model !== undefined ? { model: input.model } : {}),
|
|
110
|
-
...(
|
|
111
|
+
...(configModule !== undefined ? { configModule } : {}),
|
|
111
112
|
...(input.cases !== undefined ? { cases: input.cases } : {}),
|
|
112
113
|
waitingOn: blockers,
|
|
113
114
|
...(input.follows !== undefined ? { follows: input.follows } : {}),
|
|
@@ -318,9 +319,9 @@ export function createJobRegistry(options) {
|
|
|
318
319
|
// Its log is named only where it is kept: otherwise it goes as the pulse ends.
|
|
319
320
|
const named = log !== undefined && project !== undefined && debugMode(project);
|
|
320
321
|
record({ kind: "job.started", waitedMs: job.startedAt - job.queuedAt, ...(named ? { logFile: log.file } : {}) }, place);
|
|
321
|
-
// What the job's agents start runs until it ends, and no longer (withPulse) - with the
|
|
322
|
-
// with, whatever
|
|
323
|
-
return
|
|
322
|
+
// What the job's agents start runs until it ends, and no longer (withPulse) - with the config it was queued
|
|
323
|
+
// with, whatever the files say while it waits or runs.
|
|
324
|
+
return withConfigModule(configModule, () => (guarded ? runGuarded() : runOnce()));
|
|
324
325
|
})
|
|
325
326
|
.then((outcome) => {
|
|
326
327
|
// Asked to stop, it is stopped - whether its work threw as it unwound or returned what it had.
|
|
@@ -347,6 +348,9 @@ export function createJobRegistry(options) {
|
|
|
347
348
|
// What it wrote for a person goes now, outside debug mode - its log too, which nothing names from then on.
|
|
348
349
|
if (ran && project !== undefined && !pulseEnded({ job: id, project, ...(input.module !== undefined ? { module: input.module } : {}), lanes: claimed }))
|
|
349
350
|
delete finished.logFile;
|
|
351
|
+
// Why one that did not land did not, kept past the session whatever the debug setting (failure-reports.ts).
|
|
352
|
+
if (ran && project !== undefined)
|
|
353
|
+
keepFailureReport(project, finished);
|
|
350
354
|
const outcome = finished.details;
|
|
351
355
|
const stopReason = stopReasons.get(id);
|
|
352
356
|
record({
|
|
@@ -475,7 +479,7 @@ export function pulseName(job) {
|
|
|
475
479
|
}
|
|
476
480
|
/** What the agent is told when it checks on a job. */
|
|
477
481
|
export function describeJob(job) {
|
|
478
|
-
const name = `${pulseName(job)}${job.
|
|
482
|
+
const name = `${pulseName(job)}${job.configModule !== undefined ? ` (built with ${moduleConfigFile(job.configModule)})` : ""}`;
|
|
479
483
|
if (job.status === "queued") {
|
|
480
484
|
return `${name}: queued behind ${job.waitingOn.map((id) => `pulse ${id}`).join(" and ")}. It starts when that finishes.`;
|
|
481
485
|
}
|
|
@@ -3,7 +3,7 @@ import { type Job } from "./jobs.ts";
|
|
|
3
3
|
import { type LedgerEntry } from "./ledger.ts";
|
|
4
4
|
/**
|
|
5
5
|
* What the ledger says of pulses, read back: one pulse - from this session or an earlier one - as the chat and
|
|
6
|
-
*
|
|
6
|
+
* a host are told it, and the runs a project has had, each with its pulses.
|
|
7
7
|
*/
|
|
8
8
|
type Of<K extends LedgerEntry["kind"]> = Extract<LedgerEntry, {
|
|
9
9
|
kind: K;
|
|
@@ -48,14 +48,20 @@ export interface PulseView {
|
|
|
48
48
|
/** A pulse's events, gathered: undefined when the ledger has none of it. `entries` are its run's, oldest first. */
|
|
49
49
|
export declare function pulseView(id: string, entries: LedgerEntry[]): PulseView | undefined;
|
|
50
50
|
/**
|
|
51
|
-
* A pulse from the ledger, for the chat
|
|
51
|
+
* A pulse from the ledger, for the chat's `pulses`: what happened in it, as facts - and, last, the
|
|
52
52
|
* ***plain diff it regenerated, unless `diff` is false.
|
|
53
53
|
*/
|
|
54
54
|
export declare function describePulseView(view: PulseView, options?: {
|
|
55
55
|
diff?: boolean;
|
|
56
56
|
}): string;
|
|
57
|
-
/**
|
|
58
|
-
|
|
57
|
+
/**
|
|
58
|
+
* A pulse the ledger of any of these projects knows, described - or undefined. With `report` (the default), why one
|
|
59
|
+
* that did not land did not, as kept when it ended; without, the ledger's facts alone - for a pulse of this session,
|
|
60
|
+
* whose transcript says why.
|
|
61
|
+
*/
|
|
62
|
+
export declare function describePastPulse(projects: string[], id: string, options?: {
|
|
63
|
+
report?: boolean;
|
|
64
|
+
}): string | undefined;
|
|
59
65
|
/** A run of the project's, and its pulses: runs and pulses the most recent first. */
|
|
60
66
|
export interface RunView {
|
|
61
67
|
run: string;
|
|
@@ -64,7 +70,7 @@ export interface RunView {
|
|
|
64
70
|
pulses: PulseView[];
|
|
65
71
|
}
|
|
66
72
|
export declare function runViews(project: string): RunView[];
|
|
67
|
-
/** The project's last runs, a line a pulse: what `
|
|
73
|
+
/** The project's last runs, a line a pulse: what `pulses` lists of earlier sessions. */
|
|
68
74
|
export declare function describeRuns(runs: RunView[]): string;
|
|
69
75
|
/**
|
|
70
76
|
* The pulses of earlier sessions, for a list beside this session's: the last `runs` runs of these projects that are not
|
|
@@ -78,23 +84,4 @@ export declare function earlierPulses(projects: string[], known: Set<string>, ru
|
|
|
78
84
|
};
|
|
79
85
|
/** A pulse of the ledger's, as the lists show a job: finished as it ended, its time and cost - and nothing to run. */
|
|
80
86
|
export declare function asJob(view: PulseView): Job;
|
|
81
|
-
/** What to count in the ledger: kinds - whole, or a group by what comes before the dot - a module, since when. */
|
|
82
|
-
export interface EventQuery {
|
|
83
|
-
/** `healer.failed`, or `healer` for every healer event. */
|
|
84
|
-
kinds?: string[];
|
|
85
|
-
module?: string;
|
|
86
|
-
/** Only events at or after this time. */
|
|
87
|
-
since?: Date;
|
|
88
|
-
/** How many of the most recent to list, a line each. */
|
|
89
|
-
limit?: number;
|
|
90
|
-
}
|
|
91
|
-
/** One event in a line: when, its pulse and module, its kind, its own fields - the agent's role when it has one. */
|
|
92
|
-
export declare function eventLine(entry: LedgerEntry): string;
|
|
93
|
-
/**
|
|
94
|
-
* The events of these projects' ledgers that `query` asks for: how many of each kind, and the most recent, a line each -
|
|
95
|
-
* or, when no kind asked for is in the ledger, the kinds it has.
|
|
96
|
-
*/
|
|
97
|
-
export declare function describeEvents(projects: string[], query?: EventQuery): string;
|
|
98
|
-
/** `24h`, `7d`, `30m`, or a date and time: the moment it means, or undefined when it means none. */
|
|
99
|
-
export declare function sinceOf(text: string, now?: number): Date | undefined;
|
|
100
87
|
export {};
|