@turri-dev/cli 0.2.3 → 0.2.4-next.009bd0c
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 +7 -8
- 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/chat-skills.d.ts +1 -1
- package/dist/chat-skills.js +1 -1
- package/dist/chats.d.ts +44 -20
- package/dist/chats.js +125 -64
- package/dist/cli.js +12 -31
- package/dist/config-edit.d.ts +20 -8
- package/dist/config-edit.js +32 -26
- package/dist/config.d.ts +106 -78
- package/dist/config.js +267 -133
- 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 +17 -10
- package/dist/extension.js +425 -531
- package/dist/genome.js +10 -49
- package/dist/graph.js +3 -5
- package/dist/host-session.d.ts +11 -21
- package/dist/host-session.js +6 -8
- package/dist/host.d.ts +4 -4
- package/dist/host.js +4 -7
- package/dist/identity.js +2 -3
- package/dist/init-config.d.ts +1 -2
- package/dist/init-config.js +10 -17
- package/dist/installed-providers.d.ts +1 -1
- package/dist/installed-providers.js +1 -1
- package/dist/launch-agent.d.ts +41 -0
- package/dist/launch-agent.js +219 -0
- package/dist/{release-cli.js → launch-cli.js} +41 -24
- package/dist/launch-session.d.ts +58 -0
- package/dist/launch-session.js +195 -0
- package/dist/launch-tools.d.ts +28 -0
- package/dist/launch-tools.js +69 -0
- package/dist/launch-track.d.ts +120 -0
- package/dist/launch-track.js +298 -0
- package/dist/loop-cli.d.ts +4 -3
- package/dist/loop-cli.js +17 -15
- package/dist/loop-tools.d.ts +45 -21
- package/dist/loop-tools.js +155 -90
- package/dist/new-project.js +2 -2
- package/dist/notice.d.ts +7 -6
- 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.d.ts +2 -2
- package/dist/plain-files.js +7 -7
- 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/command-check.d.ts +1 -1
- package/dist/regenerate/command-check.js +1 -1
- package/dist/regenerate/delivery.d.ts +1 -1
- package/dist/regenerate/delivery.js +3 -3
- 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/launch.d.ts +126 -0
- package/dist/regenerate/{release.js → launch.js} +60 -48
- package/dist/regenerate/ledger-view.d.ts +11 -24
- package/dist/regenerate/ledger-view.js +14 -60
- package/dist/regenerate/ledger.d.ts +26 -16
- package/dist/regenerate/ledger.js +1 -1
- package/dist/regenerate/lineage.d.ts +2 -0
- package/dist/regenerate/lineage.js +8 -0
- package/dist/regenerate/loop.d.ts +54 -67
- package/dist/regenerate/loop.js +312 -148
- 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 +3 -3
- package/dist/regenerate/paths.js +4 -4
- 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 +36 -10
- package/dist/sentinel-check.d.ts +3 -3
- package/dist/sentinel-check.js +3 -3
- package/dist/sentinel.d.ts +17 -12
- package/dist/sentinel.js +75 -46
- 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 +4 -6
- package/docs/authoring-plain.md +3 -3
- package/docs/chats.md +6 -9
- package/docs/claude-subscription.md +2 -2
- package/docs/config.md +61 -51
- package/docs/development.md +4 -5
- package/docs/headless.md +7 -6
- package/docs/hosting.md +24 -23
- package/docs/launch.md +63 -0
- package/docs/parser.md +3 -3
- package/docs/regenerating.md +30 -22
- package/docs/sandbox.md +3 -3
- package/docs/sentinel.md +27 -16
- package/docs/skills-and-gates.md +6 -11
- package/docs/using.md +25 -42
- package/genome/rules/project-model.md +2 -1
- package/genome/rules/test-plain-files.md +15 -7
- package/genome/rules/turri-regeneration.md +7 -10
- 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.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/release.d.ts +0 -121
- package/dist/regenerate/test-advisor.d.ts +0 -101
- package/dist/regenerate/test-advisor.js +0 -379
- package/dist/release-agent.d.ts +0 -43
- package/dist/release-agent.js +0 -130
- package/dist/release-cli.d.ts +0 -1
- package/dist/release-tools.d.ts +0 -44
- package/dist/release-tools.js +0 -170
- 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/deploy.md +0 -48
- package/docs/test-advisor.md +0 -110
- /package/dist/{change-plain-cli.d.ts → launch-cli.d.ts} +0 -0
package/dist/ledger-cli.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { resolve } from "node:path";
|
|
2
|
-
import { readLedger } from "./regenerate/ledger.js";
|
|
3
|
-
import { describePastPulse, describeRuns, ledgerProjects, runViews } from "./regenerate/ledger-view.js";
|
|
4
|
-
const USAGE = `usage: turri ledger [pulse] [--runs <n>] [--json]
|
|
5
|
-
|
|
6
|
-
What turri did here, from the project's ledger (.turri/ledger): the last runs, a line a pulse - how each ended, how
|
|
7
|
-
long it took and what it cost. With a pulse's id, or the start of it, that pulse: its rounds, test runs, verdicts,
|
|
8
|
-
healers, what turri refused and what its history recorded. --json prints the events themselves, a JSON line each.
|
|
9
|
-
|
|
10
|
-
--runs <n> how many runs to show, the most recent first (default 5)
|
|
11
|
-
--json the events, as the ledger has them - the pulse's alone with a pulse`;
|
|
12
|
-
const args = process.argv.slice(2);
|
|
13
|
-
if (args.includes("--help") || args.includes("-h")) {
|
|
14
|
-
console.log(USAGE);
|
|
15
|
-
process.exit(0);
|
|
16
|
-
}
|
|
17
|
-
const runsAt = args.indexOf("--runs");
|
|
18
|
-
const runs = runsAt >= 0 ? Number(args[runsAt + 1]) : 5;
|
|
19
|
-
if (runsAt >= 0 && (!Number.isInteger(runs) || runs < 1)) {
|
|
20
|
-
console.error(`--runs takes a number of runs, at least 1\n\n${USAGE}`);
|
|
21
|
-
process.exit(1);
|
|
22
|
-
}
|
|
23
|
-
const [pulse] = args.filter((arg, at) => !arg.startsWith("-") && (runsAt < 0 || at !== runsAt + 1));
|
|
24
|
-
const projects = ledgerProjects(process.cwd());
|
|
25
|
-
if (projects.length === 0) {
|
|
26
|
-
console.log("No ledger here: turri has not run in this folder, or in a project under it, since the ledger began.");
|
|
27
|
-
process.exit(0);
|
|
28
|
-
}
|
|
29
|
-
if (args.includes("--json")) {
|
|
30
|
-
for (const project of projects)
|
|
31
|
-
for (const entry of readLedger(project, pulse !== undefined ? { job: pulse } : {}))
|
|
32
|
-
console.log(JSON.stringify(entry));
|
|
33
|
-
process.exit(0);
|
|
34
|
-
}
|
|
35
|
-
if (pulse !== undefined) {
|
|
36
|
-
const described = describePastPulse(projects, pulse);
|
|
37
|
-
if (described === undefined) {
|
|
38
|
-
console.error(`The ledger has no pulse ${pulse}.`);
|
|
39
|
-
process.exit(1);
|
|
40
|
-
}
|
|
41
|
-
console.log(described);
|
|
42
|
-
process.exit(0);
|
|
43
|
-
}
|
|
44
|
-
for (const project of projects) {
|
|
45
|
-
if (projects.length > 1)
|
|
46
|
-
console.log(`── ${resolve(project)}\n`);
|
|
47
|
-
console.log(describeRuns(runViews(project).slice(0, runs)));
|
|
48
|
-
if (projects.length > 1)
|
|
49
|
-
console.log("");
|
|
50
|
-
}
|
package/dist/ledger-tools.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { type ToolDefinition } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
type AnyTool = ToolDefinition<any, any, any>;
|
|
3
|
-
/**
|
|
4
|
-
* ledger: what turri did, as the ledger recorded it - in this session and every one before it. One pulse, by its id,
|
|
5
|
-
* as facts; the last runs, a line a pulse; or the events of some kinds, counted and listed. Reads only.
|
|
6
|
-
*/
|
|
7
|
-
export declare function ledgerTool(options: {
|
|
8
|
-
cwd: string;
|
|
9
|
-
}): AnyTool;
|
|
10
|
-
export {};
|
package/dist/ledger-tools.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { defineTool } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
import { Type } from "typebox";
|
|
3
|
-
import { describeEvents, describePastPulse, describeRuns, ledgerProjects, runViews, sinceOf } from "./regenerate/ledger-view.js";
|
|
4
|
-
/** How many runs `ledger` lists when it is asked for none. */
|
|
5
|
-
const RUNS_SHOWN = 3;
|
|
6
|
-
/**
|
|
7
|
-
* ledger: what turri did, as the ledger recorded it - in this session and every one before it. One pulse, by its id,
|
|
8
|
-
* as facts; the last runs, a line a pulse; or the events of some kinds, counted and listed. Reads only.
|
|
9
|
-
*/
|
|
10
|
-
export function ledgerTool(options) {
|
|
11
|
-
return defineTool({
|
|
12
|
-
name: "ledger",
|
|
13
|
-
label: "Ledger",
|
|
14
|
-
description: "What turri did here, as its ledger recorded it - facts, not transcripts - in this session and every earlier one. " +
|
|
15
|
-
"With pulse: that pulse, this session's or an earlier one's - how it ended, its rounds and test runs (how many failed " +
|
|
16
|
-
"the same way), the judge's and the reviews' verdicts, the healers (the debugger, the diagnosis) and whether they " +
|
|
17
|
-
"failed, the model provider's trouble, what turri refused and stopped, what it committed or rolled back, its last " +
|
|
18
|
-
"stages and its log. With kinds (and module, since): how many events of those kinds there were, and the most recent, " +
|
|
19
|
-
"a line each - healer.failed, provider.error, script.run, gate.round, judge.verdict, guard.refused, history.failed, " +
|
|
20
|
-
"job.finished, ...; a group by its first part, healer for every healer event. Otherwise: the last runs, a line a pulse - " +
|
|
21
|
-
"how each ended, how long, what it cost. Starts nothing and calls no model.",
|
|
22
|
-
promptSnippet: "ledger: what turri did - a pulse as facts, the last runs, or events counted by kind - this session and earlier ones",
|
|
23
|
-
promptGuidelines: [
|
|
24
|
-
"Use ledger for what turri recorded of the work - a pulse's rounds, test runs, verdicts, healers and commits, this session's or an earlier one's; how often something happened; what earlier runs did and cost - rather than reading .turri/ledger with the shell. pulses is what is running and planned now; a pulse's whole transcript is its log, which ledger names when it is kept (debug mode).",
|
|
25
|
-
],
|
|
26
|
-
parameters: Type.Object({
|
|
27
|
-
pulse: Type.Optional(Type.String({ description: "A pulse's id, or the start of it: that pulse, as the ledger has it" })),
|
|
28
|
-
kinds: Type.Optional(Type.Array(Type.String(), { description: "Event kinds to count and list - healer.failed, or healer for the whole group" })),
|
|
29
|
-
module: Type.Optional(Type.String({ description: "With kinds: only the events of this module" })),
|
|
30
|
-
since: Type.Optional(Type.String({ description: "With kinds: only events since then - 24h, 7d, 30m, or a date and time" })),
|
|
31
|
-
runs: Type.Optional(Type.Number({ description: `Without pulse or kinds: how many of the last runs to list (default ${RUNS_SHOWN})` })),
|
|
32
|
-
limit: Type.Optional(Type.Number({ description: "With kinds: how many of the most recent events to list (default 20)" })),
|
|
33
|
-
}),
|
|
34
|
-
async execute(_id, params) {
|
|
35
|
-
const text = (body, details = {}) => ({ content: [{ type: "text", text: body }], details });
|
|
36
|
-
const projects = ledgerProjects(options.cwd);
|
|
37
|
-
if (projects.length === 0)
|
|
38
|
-
return text("The ledger is empty here: nothing has run in this folder, or in a project under it, since it began.", { found: false });
|
|
39
|
-
if (params.pulse !== undefined) {
|
|
40
|
-
const described = describePastPulse(projects, params.pulse.trim());
|
|
41
|
-
return described !== undefined ? text(described, { found: true }) : text(`The ledger has no pulse ${params.pulse}.`, { found: false });
|
|
42
|
-
}
|
|
43
|
-
if (params.kinds !== undefined && params.kinds.length > 0) {
|
|
44
|
-
let since;
|
|
45
|
-
if (params.since !== undefined) {
|
|
46
|
-
since = sinceOf(params.since);
|
|
47
|
-
if (since === undefined)
|
|
48
|
-
return text(`since takes 24h, 7d, 30m or a date and time, not ${JSON.stringify(params.since)}.`, { found: false });
|
|
49
|
-
}
|
|
50
|
-
return text(describeEvents(projects, {
|
|
51
|
-
kinds: params.kinds,
|
|
52
|
-
...(params.module !== undefined ? { module: params.module } : {}),
|
|
53
|
-
...(since !== undefined ? { since } : {}),
|
|
54
|
-
...(params.limit !== undefined ? { limit: params.limit } : {}),
|
|
55
|
-
}), { found: true });
|
|
56
|
-
}
|
|
57
|
-
const count = params.runs !== undefined && Number.isFinite(params.runs) ? Math.max(1, Math.floor(params.runs)) : RUNS_SHOWN;
|
|
58
|
-
const runs = projects.flatMap((project) => runViews(project)).sort((a, b) => (b.started?.ts ?? "").localeCompare(a.started?.ts ?? ""));
|
|
59
|
-
const shown = runs.slice(0, count);
|
|
60
|
-
const more = runs.length - shown.length;
|
|
61
|
-
return text(`${describeRuns(shown)}${more > 0 ? `\n\n${more} earlier run${more === 1 ? "" : "s"} beyond these: ask with runs for more.` : ""}`, { found: true, runs: shown.length });
|
|
62
|
-
},
|
|
63
|
-
});
|
|
64
|
-
}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The test advisor's file: `.turri/advisor/<module>.json` in the project - what it made of each functional spec of the
|
|
3
|
-
* module it looked at, by func-id, keyed by a hash of its text (docs/test-advisor.md). Local to this machine: `.turri`
|
|
4
|
-
* ignores itself, so it is never committed - another machine starts with none, and classifies only what changes there.
|
|
5
|
-
*
|
|
6
|
-
* An entry is current while its hash is the functional spec's text's: a text that changes makes it stale, and the
|
|
7
|
-
* functional spec is looked at again. `pending` is written the moment the advisor sees a functional spec, so quitting
|
|
8
|
-
* loses nothing: the next start in the chat or a host picks it up.
|
|
9
|
-
*/
|
|
10
|
-
export declare const ADVISOR_DIR = "advisor";
|
|
11
|
-
/** The four questions, each a yes or a no: could it fail silently, be read two ways, be built on later, cost much when wrong. */
|
|
12
|
-
export declare const ADVISOR_QUESTIONS: readonly ["silent-failure", "divergence", "revisited", "cost"];
|
|
13
|
-
export type AdvisorQuestion = (typeof ADVISOR_QUESTIONS)[number];
|
|
14
|
-
/** A question that was a yes, with its evidence in a line: the wrong output, the input read two ways, what would change, the consequence. */
|
|
15
|
-
export interface AdvisorAnswer {
|
|
16
|
-
question: AdvisorQuestion;
|
|
17
|
-
evidence: string;
|
|
18
|
-
}
|
|
19
|
-
/** An input to cover: one the readers agreed on, with its output, or one they split on, with each reading the verifier kept. */
|
|
20
|
-
export type AdvisorInput = {
|
|
21
|
-
input: string;
|
|
22
|
-
agreed: string;
|
|
23
|
-
} | {
|
|
24
|
-
input: string;
|
|
25
|
-
readings: string[];
|
|
26
|
-
};
|
|
27
|
-
/** What the advisor made of a functional spec: its verdict, the questions that were a yes, and on a yes the inputs to cover. */
|
|
28
|
-
export interface AdvisorReport {
|
|
29
|
-
verdict: "yes" | "no";
|
|
30
|
-
questions: AdvisorAnswer[];
|
|
31
|
-
inputs: AdvisorInput[];
|
|
32
|
-
}
|
|
33
|
-
/** Where an entry is: seen and not finished, classified yes or no, or failed - tried again only once its text changes. */
|
|
34
|
-
export type AdvisorState = "pending" | "yes" | "no" | "failed";
|
|
35
|
-
export interface AdvisorEntry {
|
|
36
|
-
funcId: string;
|
|
37
|
-
/** The hash of the functional spec's text the entry is about (textHash). */
|
|
38
|
-
hash: string;
|
|
39
|
-
state: AdvisorState;
|
|
40
|
-
report?: AdvisorReport;
|
|
41
|
-
/** The model the advisor ran on. */
|
|
42
|
-
model?: string;
|
|
43
|
-
/** When the entry was last written, ISO. */
|
|
44
|
-
at: string;
|
|
45
|
-
/** Why it failed, for a failed one. */
|
|
46
|
-
reason?: string;
|
|
47
|
-
/** The tip's .plain file, from the project: where the chain's scenarios are tested. */
|
|
48
|
-
tip?: string;
|
|
49
|
-
/** A yes not yet handed to a chat: delivered at the next start, as `pending` work is picked up. */
|
|
50
|
-
undelivered?: boolean;
|
|
51
|
-
/** Pending at the chat's asking (evaluate_tests), with why: picked up at the next start whatever `test-advisor` says. */
|
|
52
|
-
asked?: {
|
|
53
|
-
reason?: string;
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
export interface AdvisorFile {
|
|
57
|
-
module: string;
|
|
58
|
-
/** The module's .plain file, from the project. */
|
|
59
|
-
plainFile: string;
|
|
60
|
-
entries: Record<string, AdvisorEntry>;
|
|
61
|
-
}
|
|
62
|
-
/** The hash a functional spec's text is known by: its text, trimmed. */
|
|
63
|
-
export declare function textHash(text: string): string;
|
|
64
|
-
/** The folder of a project's advisor files. */
|
|
65
|
-
export declare function advisorDir(project: string): string;
|
|
66
|
-
/** A module's advisor file. */
|
|
67
|
-
export declare function advisorPath(project: string, module: string): string;
|
|
68
|
-
/** A module's advisor file, or nothing when there is none or it does not read. */
|
|
69
|
-
export declare function readAdvisor(project: string, module: string): AdvisorFile | undefined;
|
|
70
|
-
/** A functional spec's entry, or nothing. */
|
|
71
|
-
export declare function advisorEntry(project: string, module: string, funcId: string): AdvisorEntry | undefined;
|
|
72
|
-
/** Whether an entry is about the text as it is now: one that is not, or none, is stale, and the functional spec is looked at again. */
|
|
73
|
-
export declare function isCurrent(entry: AdvisorEntry | undefined, hash: string): entry is AdvisorEntry;
|
|
74
|
-
/** Write a functional spec's entry, in place of the one it had. `plainFile` is the module's, from the project. */
|
|
75
|
-
export declare function putAdvisorEntry(project: string, module: string, plainFile: string, entry: Omit<AdvisorEntry, "at"> & {
|
|
76
|
-
at?: string;
|
|
77
|
-
}): AdvisorEntry;
|
|
78
|
-
/** Take a functional spec's entry out - its functional spec is gone. */
|
|
79
|
-
export declare function removeAdvisorEntry(project: string, module: string, funcId: string): void;
|
|
80
|
-
/** Every pending entry of a project's advisor files, with the module and its .plain file - what a start picks up. */
|
|
81
|
-
export declare function pendingEntries(project: string): Array<{
|
|
82
|
-
module: string;
|
|
83
|
-
plainFile: string;
|
|
84
|
-
entry: AdvisorEntry;
|
|
85
|
-
}>;
|
|
86
|
-
/** Every yes of a project's advisor files not yet handed to a chat - what a start delivers. */
|
|
87
|
-
export declare function undeliveredEntries(project: string): Array<{
|
|
88
|
-
module: string;
|
|
89
|
-
plainFile: string;
|
|
90
|
-
entry: AdvisorEntry;
|
|
91
|
-
}>;
|
|
92
|
-
/** A yes handed to a chat: the entry for that text no longer kept for the next start. */
|
|
93
|
-
export declare function markDelivered(project: string, module: string, funcId: string, hash: string): void;
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import { createHash } from "node:crypto";
|
|
2
|
-
import { existsSync, readdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
3
|
-
import { join, resolve } from "node:path";
|
|
4
|
-
import { ensureInScratch } from "./paths.js";
|
|
5
|
-
/**
|
|
6
|
-
* The test advisor's file: `.turri/advisor/<module>.json` in the project - what it made of each functional spec of the
|
|
7
|
-
* module it looked at, by func-id, keyed by a hash of its text (docs/test-advisor.md). Local to this machine: `.turri`
|
|
8
|
-
* ignores itself, so it is never committed - another machine starts with none, and classifies only what changes there.
|
|
9
|
-
*
|
|
10
|
-
* An entry is current while its hash is the functional spec's text's: a text that changes makes it stale, and the
|
|
11
|
-
* functional spec is looked at again. `pending` is written the moment the advisor sees a functional spec, so quitting
|
|
12
|
-
* loses nothing: the next start in the chat or a host picks it up.
|
|
13
|
-
*/
|
|
14
|
-
export const ADVISOR_DIR = "advisor";
|
|
15
|
-
/** The four questions, each a yes or a no: could it fail silently, be read two ways, be built on later, cost much when wrong. */
|
|
16
|
-
export const ADVISOR_QUESTIONS = ["silent-failure", "divergence", "revisited", "cost"];
|
|
17
|
-
/** The hash a functional spec's text is known by: its text, trimmed. */
|
|
18
|
-
export function textHash(text) {
|
|
19
|
-
return createHash("sha256").update(text.trim()).digest("hex").slice(0, 16);
|
|
20
|
-
}
|
|
21
|
-
/** The folder of a project's advisor files. */
|
|
22
|
-
export function advisorDir(project) {
|
|
23
|
-
return join(resolve(project), ".turri", ADVISOR_DIR);
|
|
24
|
-
}
|
|
25
|
-
/** A module's advisor file. */
|
|
26
|
-
export function advisorPath(project, module) {
|
|
27
|
-
return join(advisorDir(project), `${module}.json`);
|
|
28
|
-
}
|
|
29
|
-
/** A module's advisor file, or nothing when there is none or it does not read. */
|
|
30
|
-
export function readAdvisor(project, module) {
|
|
31
|
-
try {
|
|
32
|
-
const parsed = JSON.parse(readFileSync(advisorPath(project, module), "utf8"));
|
|
33
|
-
return parsed !== null && typeof parsed === "object" && typeof parsed.entries === "object" && parsed.entries !== null ? parsed : undefined;
|
|
34
|
-
}
|
|
35
|
-
catch {
|
|
36
|
-
return undefined;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
/** A functional spec's entry, or nothing. */
|
|
40
|
-
export function advisorEntry(project, module, funcId) {
|
|
41
|
-
return readAdvisor(project, module)?.entries[funcId];
|
|
42
|
-
}
|
|
43
|
-
/** Whether an entry is about the text as it is now: one that is not, or none, is stale, and the functional spec is looked at again. */
|
|
44
|
-
export function isCurrent(entry, hash) {
|
|
45
|
-
return entry !== undefined && entry.hash === hash;
|
|
46
|
-
}
|
|
47
|
-
/** Write a functional spec's entry, in place of the one it had. `plainFile` is the module's, from the project. */
|
|
48
|
-
export function putAdvisorEntry(project, module, plainFile, entry) {
|
|
49
|
-
const file = readAdvisor(project, module) ?? { module, plainFile, entries: {} };
|
|
50
|
-
const written = { ...entry, at: entry.at ?? new Date().toISOString() };
|
|
51
|
-
file.plainFile = plainFile;
|
|
52
|
-
file.entries[entry.funcId] = written;
|
|
53
|
-
writeAdvisor(project, file);
|
|
54
|
-
return written;
|
|
55
|
-
}
|
|
56
|
-
/** Take a functional spec's entry out - its functional spec is gone. */
|
|
57
|
-
export function removeAdvisorEntry(project, module, funcId) {
|
|
58
|
-
const file = readAdvisor(project, module);
|
|
59
|
-
if (file === undefined || file.entries[funcId] === undefined)
|
|
60
|
-
return;
|
|
61
|
-
delete file.entries[funcId];
|
|
62
|
-
writeAdvisor(project, file);
|
|
63
|
-
}
|
|
64
|
-
function writeAdvisor(project, file) {
|
|
65
|
-
const scratch = join(resolve(project), ".turri");
|
|
66
|
-
ensureInScratch(scratch, advisorDir(project));
|
|
67
|
-
const path = advisorPath(project, file.module);
|
|
68
|
-
// Written whole, then moved in place: a turri killed part-way never leaves half a file.
|
|
69
|
-
const temporary = `${path}.${process.pid}.tmp`;
|
|
70
|
-
writeFileSync(temporary, `${JSON.stringify(file, null, 2)}\n`);
|
|
71
|
-
renameSync(temporary, path);
|
|
72
|
-
}
|
|
73
|
-
/** Every pending entry of a project's advisor files, with the module and its .plain file - what a start picks up. */
|
|
74
|
-
export function pendingEntries(project) {
|
|
75
|
-
return entriesWhere(project, (entry) => entry.state === "pending");
|
|
76
|
-
}
|
|
77
|
-
/** Every yes of a project's advisor files not yet handed to a chat - what a start delivers. */
|
|
78
|
-
export function undeliveredEntries(project) {
|
|
79
|
-
return entriesWhere(project, (entry) => entry.state === "yes" && entry.undelivered === true);
|
|
80
|
-
}
|
|
81
|
-
/** A yes handed to a chat: the entry for that text no longer kept for the next start. */
|
|
82
|
-
export function markDelivered(project, module, funcId, hash) {
|
|
83
|
-
const file = readAdvisor(project, module);
|
|
84
|
-
const entry = file?.entries[funcId];
|
|
85
|
-
if (file === undefined || entry === undefined || entry.hash !== hash || entry.undelivered !== true)
|
|
86
|
-
return;
|
|
87
|
-
const { undelivered: _delivered, ...rest } = entry;
|
|
88
|
-
file.entries[funcId] = rest;
|
|
89
|
-
writeAdvisor(project, file);
|
|
90
|
-
}
|
|
91
|
-
function entriesWhere(project, wanted) {
|
|
92
|
-
const dir = advisorDir(project);
|
|
93
|
-
if (!existsSync(dir))
|
|
94
|
-
return [];
|
|
95
|
-
let names;
|
|
96
|
-
try {
|
|
97
|
-
names = readdirSync(dir).filter((name) => name.endsWith(".json"));
|
|
98
|
-
}
|
|
99
|
-
catch {
|
|
100
|
-
return [];
|
|
101
|
-
}
|
|
102
|
-
return names.flatMap((name) => {
|
|
103
|
-
const file = readAdvisor(project, name.slice(0, -".json".length));
|
|
104
|
-
if (file === undefined)
|
|
105
|
-
return [];
|
|
106
|
-
return Object.values(file.entries)
|
|
107
|
-
.filter(wanted)
|
|
108
|
-
.map((entry) => ({ module: file.module, plainFile: file.plainFile, entry }));
|
|
109
|
-
});
|
|
110
|
-
}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { type AdvisorReport } from "./advisor-records.ts";
|
|
2
|
-
import type { SeenSpec } from "./loop.ts";
|
|
3
|
-
import { type AdvisorCallOptions, type AdvisorSubject } from "./test-advisor.ts";
|
|
4
|
-
/**
|
|
5
|
-
* When the test advisor runs, and on what (docs/test-advisor.md). It watches what the work loop looks at - every
|
|
6
|
-
* ***plain change the loop sees, as it sees it - and takes each functional spec that is new or whose text changed since
|
|
7
|
-
* its code was built (its code record), has no scenarios, and has no entry in the advisor's file for that text. A
|
|
8
|
-
* project already built, with no advisor file, is looked at not at all: only what changes from now on is.
|
|
9
|
-
*
|
|
10
|
-
* Each is marked `pending` in the advisor's file then and there, and judged in the background - two at a time at most,
|
|
11
|
-
* outside `parallel-jobs` and the lanes: no pulse waits for it, and it never steers or stops one. Its work is clear of
|
|
12
|
-
* any pulse: no panel, no log, no stop of a pulse's reaches it. A functional spec whose text changes while it is judged
|
|
13
|
-
* has that work thrown away - whoever changed it - and the new text starts again. What `pending` is left as turri quits,
|
|
14
|
-
* the next start in the chat or a host picks up.
|
|
15
|
-
*
|
|
16
|
-
* The advisor decides and writes nothing in the ***plain: what it made of a functional spec is kept in its file and
|
|
17
|
-
* handed on (`onVerdict`) to the chat the person looks at, which writes the scenarios on a yes. A yes not yet handed to a
|
|
18
|
-
* chat stays marked undelivered, and is handed on again at the next start.
|
|
19
|
-
*
|
|
20
|
-
* It is made only where the session starts in the chat or a host (extension.ts) - never for a headless command, nor
|
|
21
|
-
* pi's print, json and rpc modes - and does nothing in a project whose `test-advisor:` is false.
|
|
22
|
-
*/
|
|
23
|
-
/** How many functional specs the advisor works on at once. */
|
|
24
|
-
export declare const ADVISOR_PARALLEL = 2;
|
|
25
|
-
/** A finished verdict, handed on to the chat: the functional spec, what was made of it, and where its scenarios go. */
|
|
26
|
-
export interface AdvisorVerdict {
|
|
27
|
-
project: string;
|
|
28
|
-
module: string;
|
|
29
|
-
funcId: string;
|
|
30
|
-
/** The module's .plain file. */
|
|
31
|
-
plainFile: string;
|
|
32
|
-
/** The tip's .plain file: where the chain's scenarios are tested, and its test reqs and conformance testing script are. */
|
|
33
|
-
tip: string;
|
|
34
|
-
/** The test plain file its scenarios go in, from the project: `<test-dir>/<module>/<func-id>.plain`. */
|
|
35
|
-
testFile: string;
|
|
36
|
-
/** The hash of the text it judged. */
|
|
37
|
-
hash: string;
|
|
38
|
-
report: AdvisorReport;
|
|
39
|
-
/** Whether it is still about the functional spec as it is now: its text the same, and still with no scenarios. */
|
|
40
|
-
current(): boolean;
|
|
41
|
-
/** Handed to a chat: no longer kept for the next start. */
|
|
42
|
-
delivered(): void;
|
|
43
|
-
}
|
|
44
|
-
export interface TestAdvisorOptions {
|
|
45
|
-
/** Whether a project wants the advisor now. Default: its `test-advisor:` is not false. */
|
|
46
|
-
enabled?: (project: string) => boolean;
|
|
47
|
-
/** The judgement of a functional spec. Default: the model calls of test-advisor.ts. */
|
|
48
|
-
advise?: (subject: AdvisorSubject, options: AdvisorCallOptions) => Promise<AdvisorReport>;
|
|
49
|
-
/** The conversation's own words on what matters for a module - its steering. */
|
|
50
|
-
context?: (plainFile: string) => string[];
|
|
51
|
-
/** A verdict finished - or a yes left undelivered, at the next start: for the chat the person looks at. Not given: only kept. */
|
|
52
|
-
onVerdict?: (verdict: AdvisorVerdict) => void;
|
|
53
|
-
/** How many functional specs at once. Default: ADVISOR_PARALLEL. */
|
|
54
|
-
parallel?: number;
|
|
55
|
-
}
|
|
56
|
-
export interface TestAdvisor {
|
|
57
|
-
/** What the loop looked at: the functional specs to take, and the work whose text changed under it to drop. */
|
|
58
|
-
seen(look: SeenSpec): void;
|
|
59
|
-
/** Pick up what a project's advisor file has pending - the work turri quit in the middle of - and hand on its undelivered yeses. */
|
|
60
|
-
resume(project: string): void;
|
|
61
|
-
/** Resolves once nothing is queued or running. */
|
|
62
|
-
idle(): Promise<void>;
|
|
63
|
-
/** Stop everything, leaving what was running pending. */
|
|
64
|
-
stop(): void;
|
|
65
|
-
/** The functional specs it is judging for now, or about to - `module:func-id`, a project's alone when named. */
|
|
66
|
-
taking(project?: string): string[];
|
|
67
|
-
/**
|
|
68
|
-
* The chat's own way in (evaluate_tests): a functional spec evaluated now - even a text already judged, and whatever
|
|
69
|
-
* `test-advisor` says - its verdict handed on as any is. `already`: it is being evaluated now; `scenarios`: it has some,
|
|
70
|
-
* and is not evaluated; `missing`: its module has no such functional spec.
|
|
71
|
-
*/
|
|
72
|
-
evaluate(asked: EvaluateRequest): "started" | "already" | "scenarios" | "missing";
|
|
73
|
-
}
|
|
74
|
-
/** A functional spec the chat asks the advisor to evaluate. */
|
|
75
|
-
export interface EvaluateRequest {
|
|
76
|
-
module: string;
|
|
77
|
-
funcId: string;
|
|
78
|
-
/** The module's .plain file. */
|
|
79
|
-
plainFile: string;
|
|
80
|
-
/** The tip its scenarios are tested in. Default: the one the advisor last knew, else the module at the top of a chain it is in, else itself. */
|
|
81
|
-
tip?: string;
|
|
82
|
-
/** Why the chat asks - "the coding agent failed three times to implement it" - for the classifier, as context. */
|
|
83
|
-
reason?: string;
|
|
84
|
-
}
|
|
85
|
-
/** Whether a functional spec has scenarios of any kind: then it is tested as the person wants, and today's review covers it. */
|
|
86
|
-
export declare function hasScenarios(item: unknown): boolean;
|
|
87
|
-
export declare function createTestAdvisor(options?: TestAdvisorOptions): TestAdvisor;
|