@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
|
@@ -1,327 +0,0 @@
|
|
|
1
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
-
import { basename, join, relative, resolve } from "node:path";
|
|
3
|
-
import { advisorModel, configForSpec, readProjectConfig, stackOf, testDirOf } from "../config.js";
|
|
4
|
-
import { plainFileParser } from "../plain/parser.js";
|
|
5
|
-
import { ACCEPTANCE_TESTS, CONFORMANCE_TESTS, FUNCTIONAL_REQUIREMENTS, REQUIRED_FUNCTIONAL_SPECS } from "../plain/spec.js";
|
|
6
|
-
import { tipsAbove } from "../plain/check.js";
|
|
7
|
-
import { conformanceTestsOnIn } from "../conformance-switch.js";
|
|
8
|
-
import { isStdlibModule } from "../plain/stdlib.js";
|
|
9
|
-
import { outsideJobs, withStopSignal } from "./activity.js";
|
|
10
|
-
import { advisorEntry, isCurrent, markDelivered, pendingEntries, putAdvisorEntry, removeAdvisorEntry, textHash, undeliveredEntries, } from "./advisor-records.js";
|
|
11
|
-
import { firstLine, record } from "./ledger.js";
|
|
12
|
-
import { projectDirOf, resolveTemplateDirs } from "./paths.js";
|
|
13
|
-
import { advise as adviseByModel } from "./test-advisor.js";
|
|
14
|
-
/**
|
|
15
|
-
* When the test advisor runs, and on what (docs/test-advisor.md). It watches what the work loop looks at - every
|
|
16
|
-
* ***plain change the loop sees, as it sees it - and takes each functional spec that is new or whose text changed since
|
|
17
|
-
* its code was built (its code record), has no scenarios, and has no entry in the advisor's file for that text. A
|
|
18
|
-
* project already built, with no advisor file, is looked at not at all: only what changes from now on is.
|
|
19
|
-
*
|
|
20
|
-
* Each is marked `pending` in the advisor's file then and there, and judged in the background - two at a time at most,
|
|
21
|
-
* outside `parallel-jobs` and the lanes: no pulse waits for it, and it never steers or stops one. Its work is clear of
|
|
22
|
-
* any pulse: no panel, no log, no stop of a pulse's reaches it. A functional spec whose text changes while it is judged
|
|
23
|
-
* has that work thrown away - whoever changed it - and the new text starts again. What `pending` is left as turri quits,
|
|
24
|
-
* the next start in the chat or a host picks up.
|
|
25
|
-
*
|
|
26
|
-
* The advisor decides and writes nothing in the ***plain: what it made of a functional spec is kept in its file and
|
|
27
|
-
* handed on (`onVerdict`) to the chat the person looks at, which writes the scenarios on a yes. A yes not yet handed to a
|
|
28
|
-
* chat stays marked undelivered, and is handed on again at the next start.
|
|
29
|
-
*
|
|
30
|
-
* It is made only where the session starts in the chat or a host (extension.ts) - never for a headless command, nor
|
|
31
|
-
* pi's print, json and rpc modes - and does nothing in a project whose `test-advisor:` is false.
|
|
32
|
-
*/
|
|
33
|
-
/** How many functional specs the advisor works on at once. */
|
|
34
|
-
export const ADVISOR_PARALLEL = 2;
|
|
35
|
-
/** The functional spec's own place in a module, as its own .plain file has it now - or nothing. */
|
|
36
|
-
function currentItem(plainFile, funcId) {
|
|
37
|
-
try {
|
|
38
|
-
const [, tree] = plainFileParser(basename(plainFile), resolveTemplateDirs(plainFile), { allowNoFunctionalities: true, testDir: testDirOf(plainFile) });
|
|
39
|
-
return (tree[FUNCTIONAL_REQUIREMENTS] ?? []).find((item) => item.id === funcId);
|
|
40
|
-
}
|
|
41
|
-
catch {
|
|
42
|
-
return undefined;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
/** Whether a functional spec has scenarios of any kind: then it is tested as the person wants, and today's review covers it. */
|
|
46
|
-
export function hasScenarios(item) {
|
|
47
|
-
const of = (key) => (item?.[key] ?? []).length;
|
|
48
|
-
return of(CONFORMANCE_TESTS) + of(ACCEPTANCE_TESTS) > 0;
|
|
49
|
-
}
|
|
50
|
-
/** The project's AGENTS.md, whole: its own words on what matters. */
|
|
51
|
-
function agentsText(project) {
|
|
52
|
-
const file = join(project, "AGENTS.md");
|
|
53
|
-
try {
|
|
54
|
-
return existsSync(file) ? [readFileSync(file, "utf8")] : [];
|
|
55
|
-
}
|
|
56
|
-
catch {
|
|
57
|
-
return [];
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
/** Whether a project wants the advisor: it conformance tests (`conformance-tests: true`), and its `test-advisor:` is not false. */
|
|
61
|
-
function wanted(project) {
|
|
62
|
-
try {
|
|
63
|
-
return conformanceTestsOnIn(project) && readProjectConfig(project, stackOf(project)).testAdvisor !== false;
|
|
64
|
-
}
|
|
65
|
-
catch {
|
|
66
|
-
return true;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
export function createTestAdvisor(options = {}) {
|
|
70
|
-
const enabled = options.enabled ?? wanted;
|
|
71
|
-
const advise = options.advise ?? adviseByModel;
|
|
72
|
-
const parallel = options.parallel ?? ADVISOR_PARALLEL;
|
|
73
|
-
const queue = [];
|
|
74
|
-
const running = new Map();
|
|
75
|
-
let idleWaiters = [];
|
|
76
|
-
let stopped = false;
|
|
77
|
-
const keyOf = (project, module, funcId) => `${project}\0${module}:${funcId}`;
|
|
78
|
-
const settleIdle = () => {
|
|
79
|
-
if (queue.length > 0 || running.size > 0)
|
|
80
|
-
return;
|
|
81
|
-
const waiters = idleWaiters;
|
|
82
|
-
idleWaiters = [];
|
|
83
|
-
for (const resolveIdle of waiters)
|
|
84
|
-
resolveIdle();
|
|
85
|
-
};
|
|
86
|
-
/** The work on a functional spec thrown away: its text is not what it was judging any more. */
|
|
87
|
-
const drop = (key, hash) => {
|
|
88
|
-
const at = queue.findIndex((work) => work.key === key && work.hash !== hash);
|
|
89
|
-
if (at !== -1)
|
|
90
|
-
queue.splice(at, 1);
|
|
91
|
-
const work = running.get(key);
|
|
92
|
-
if (work !== undefined && work.hash !== hash && work.dropped !== true) {
|
|
93
|
-
work.dropped = true;
|
|
94
|
-
work.controller.abort();
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
/** Take a functional spec, marked pending at once - unless the same text is taken already. Whether it was taken. */
|
|
98
|
-
const take = (given) => {
|
|
99
|
-
const key = keyOf(given.project, given.module, given.funcId);
|
|
100
|
-
drop(key, given.hash);
|
|
101
|
-
if (queue.some((work) => work.key === key) || running.get(key)?.hash === given.hash)
|
|
102
|
-
return false;
|
|
103
|
-
putAdvisorEntry(given.project, given.module, relative(given.project, given.plainFile), {
|
|
104
|
-
funcId: given.funcId,
|
|
105
|
-
hash: given.hash,
|
|
106
|
-
state: "pending",
|
|
107
|
-
tip: relative(given.project, given.tip),
|
|
108
|
-
...(given.asked !== undefined ? { asked: given.asked } : {}),
|
|
109
|
-
});
|
|
110
|
-
queue.push({ ...given, key, controller: new AbortController() });
|
|
111
|
-
pump();
|
|
112
|
-
return true;
|
|
113
|
-
};
|
|
114
|
-
const pump = () => {
|
|
115
|
-
if (stopped)
|
|
116
|
-
return;
|
|
117
|
-
while (running.size < parallel) {
|
|
118
|
-
// A new text waits for the work on its old one to unwind; the rest go on past it.
|
|
119
|
-
const at = queue.findIndex((work) => !running.has(work.key));
|
|
120
|
-
if (at === -1)
|
|
121
|
-
break;
|
|
122
|
-
const work = queue.splice(at, 1)[0];
|
|
123
|
-
running.set(work.key, work);
|
|
124
|
-
// Clear of any pulse the loop was looking for, and stopped by its own signal alone.
|
|
125
|
-
void outsideJobs(() => withStopSignal(work.controller.signal, () => run(work))).finally(() => {
|
|
126
|
-
if (running.get(work.key) === work)
|
|
127
|
-
running.delete(work.key);
|
|
128
|
-
pump();
|
|
129
|
-
settleIdle();
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
settleIdle();
|
|
133
|
-
};
|
|
134
|
-
const spec = (work) => `${work.module}:${work.funcId}`;
|
|
135
|
-
const place = (work) => ({ project: work.project, module: work.module });
|
|
136
|
-
/** A verdict handed on to the chat: a yes kept undelivered in the advisor's file until a chat has it. */
|
|
137
|
-
const handOn = (given) => {
|
|
138
|
-
if (options.onVerdict === undefined)
|
|
139
|
-
return;
|
|
140
|
-
const { project, module, funcId, plainFile, hash } = given;
|
|
141
|
-
try {
|
|
142
|
-
options.onVerdict({
|
|
143
|
-
...given,
|
|
144
|
-
testFile: relative(project, join(testDirOf(plainFile), module, `${funcId}.plain`)),
|
|
145
|
-
current: () => {
|
|
146
|
-
const item = currentItem(plainFile, funcId);
|
|
147
|
-
return item !== undefined && textHash(item.markdown) === hash && !hasScenarios(item) && advisorEntry(project, module, funcId)?.hash === hash;
|
|
148
|
-
},
|
|
149
|
-
delivered: () => markDelivered(project, module, funcId, hash),
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
catch {
|
|
153
|
-
/* a chat that throws as it is told: the yes stays undelivered, for the next start */
|
|
154
|
-
}
|
|
155
|
-
};
|
|
156
|
-
const run = async (work) => {
|
|
157
|
-
const config = (() => {
|
|
158
|
-
try {
|
|
159
|
-
return configForSpec(work.plainFile);
|
|
160
|
-
}
|
|
161
|
-
catch {
|
|
162
|
-
return {};
|
|
163
|
-
}
|
|
164
|
-
})();
|
|
165
|
-
const model = advisorModel(config);
|
|
166
|
-
const entryOf = (state, more = {}) => {
|
|
167
|
-
putAdvisorEntry(work.project, work.module, relative(work.project, work.plainFile), {
|
|
168
|
-
funcId: work.funcId,
|
|
169
|
-
hash: work.hash,
|
|
170
|
-
state,
|
|
171
|
-
tip: relative(work.project, work.tip),
|
|
172
|
-
...(model !== undefined ? { model } : {}),
|
|
173
|
-
...more,
|
|
174
|
-
});
|
|
175
|
-
};
|
|
176
|
-
try {
|
|
177
|
-
// The setting turns off only what a change starts: the chat's asking stands.
|
|
178
|
-
if (work.asked === undefined && !enabled(work.project))
|
|
179
|
-
return;
|
|
180
|
-
const subject = {
|
|
181
|
-
module: work.module,
|
|
182
|
-
funcId: work.funcId,
|
|
183
|
-
text: work.text,
|
|
184
|
-
moduleText: readFileSync(work.plainFile, "utf8"),
|
|
185
|
-
...(resolve(work.tip) !== resolve(work.plainFile) && existsSync(work.tip) ? { testedIn: { module: basename(work.tip).replace(/\.plain$/, ""), text: readFileSync(work.tip, "utf8") } } : {}),
|
|
186
|
-
context: [...agentsText(work.project), ...(options.context?.(work.plainFile) ?? [])],
|
|
187
|
-
...(work.asked?.reason !== undefined ? { reason: work.asked.reason } : {}),
|
|
188
|
-
};
|
|
189
|
-
const report = await advise(subject, { cwd: work.project, ...(model !== undefined ? { model } : {}) });
|
|
190
|
-
if (work.controller.signal.aborted)
|
|
191
|
-
throw new Error("stopped");
|
|
192
|
-
record({ kind: "advisor.classified", spec: spec(work), verdict: report.verdict, questions: report.questions.map((answered) => answered.question), asked: work.asked !== undefined }, place(work));
|
|
193
|
-
// A yes is kept undelivered until a chat has it; a no is only a line, and nothing is lost when it is not drawn.
|
|
194
|
-
entryOf(report.verdict, { report, ...(report.verdict === "yes" && options.onVerdict !== undefined ? { undelivered: true } : {}) });
|
|
195
|
-
handOn({ project: work.project, module: work.module, funcId: work.funcId, plainFile: work.plainFile, tip: work.tip, hash: work.hash, report });
|
|
196
|
-
}
|
|
197
|
-
catch (error) {
|
|
198
|
-
if (work.dropped === true) {
|
|
199
|
-
record({ kind: "advisor.dropped", spec: spec(work) }, place(work));
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
// Stopped with the session: left pending, for the next start.
|
|
203
|
-
if (stopped || work.controller.signal.aborted)
|
|
204
|
-
return;
|
|
205
|
-
const reason = firstLine(error instanceof Error ? error.message : String(error), 300);
|
|
206
|
-
entryOf("failed", { reason });
|
|
207
|
-
record({ kind: "advisor.failed", spec: spec(work), reason }, place(work));
|
|
208
|
-
}
|
|
209
|
-
};
|
|
210
|
-
const advisor = {
|
|
211
|
-
seen(look) {
|
|
212
|
-
if (stopped)
|
|
213
|
-
return;
|
|
214
|
-
const tip = look.chain.at(-1);
|
|
215
|
-
if (tip === undefined)
|
|
216
|
-
return;
|
|
217
|
-
const project = projectDirOf(tip.plainFile);
|
|
218
|
-
if (!enabled(project))
|
|
219
|
-
return;
|
|
220
|
-
const built = new Map();
|
|
221
|
-
const builtItems = (section) => (look.built[section] ?? []);
|
|
222
|
-
for (const item of builtItems(FUNCTIONAL_REQUIREMENTS))
|
|
223
|
-
built.set(`${tip.moduleName}:${item.id}`, (item.markdown ?? "").trim());
|
|
224
|
-
for (const item of builtItems(REQUIRED_FUNCTIONAL_SPECS))
|
|
225
|
-
built.set(`${item.module}:${item.id}`, (item.markdown ?? "").trim());
|
|
226
|
-
const items = (section, own) => (look.tree[section] ?? []).map((item) => ({ item, module: own ? tip.moduleName : (item.module ?? "") }));
|
|
227
|
-
for (const { item, module } of [...items(REQUIRED_FUNCTIONAL_SPECS, false), ...items(FUNCTIONAL_REQUIREMENTS, true)]) {
|
|
228
|
-
if (module === "" || isStdlibModule(module))
|
|
229
|
-
continue;
|
|
230
|
-
const entry = look.chain.find((link) => link.moduleName === module);
|
|
231
|
-
if (entry === undefined)
|
|
232
|
-
continue;
|
|
233
|
-
const text = item.markdown.trim();
|
|
234
|
-
const hash = textHash(text);
|
|
235
|
-
const key = keyOf(project, module, item.id);
|
|
236
|
-
// Work on a text that is no more is thrown away, wherever the change came from.
|
|
237
|
-
drop(key, hash);
|
|
238
|
-
// Built as it is now: neither new nor changed.
|
|
239
|
-
if (built.get(`${module}:${item.id}`) === text)
|
|
240
|
-
continue;
|
|
241
|
-
// Scenarios of any kind: tested as the person wants, and today's review covers it.
|
|
242
|
-
if (hasScenarios(item))
|
|
243
|
-
continue;
|
|
244
|
-
// Judged already, for this text - or being judged now.
|
|
245
|
-
const known = advisorEntry(project, module, item.id);
|
|
246
|
-
if (isCurrent(known, hash) && (known.state !== "pending" || running.has(key) || queue.some((work) => work.key === key)))
|
|
247
|
-
continue;
|
|
248
|
-
take({ project, module, funcId: item.id, plainFile: resolve(entry.plainFile), tip: resolve(tip.plainFile), text, hash });
|
|
249
|
-
}
|
|
250
|
-
},
|
|
251
|
-
resume(project) {
|
|
252
|
-
if (stopped)
|
|
253
|
-
return;
|
|
254
|
-
// Conformance tests off: the advisor is off with them - nothing pending is picked up, not even what the chat asked for.
|
|
255
|
-
if (options.enabled === undefined && !conformanceTestsOnIn(project))
|
|
256
|
-
return;
|
|
257
|
-
// With the setting off, only what the chat asked for is picked up.
|
|
258
|
-
const wants = enabled(project);
|
|
259
|
-
for (const pending of pendingEntries(project)) {
|
|
260
|
-
if (!wants && pending.entry.asked === undefined)
|
|
261
|
-
continue;
|
|
262
|
-
const plainFile = resolve(project, pending.plainFile);
|
|
263
|
-
const item = currentItem(plainFile, pending.entry.funcId);
|
|
264
|
-
// Gone, or given scenarios meanwhile: nothing is left to pick up.
|
|
265
|
-
if (item === undefined || hasScenarios(item)) {
|
|
266
|
-
removeAdvisorEntry(project, pending.module, pending.entry.funcId);
|
|
267
|
-
continue;
|
|
268
|
-
}
|
|
269
|
-
const text = item.markdown.trim();
|
|
270
|
-
take({
|
|
271
|
-
project,
|
|
272
|
-
module: pending.module,
|
|
273
|
-
funcId: item.id,
|
|
274
|
-
plainFile,
|
|
275
|
-
tip: resolve(project, pending.entry.tip ?? pending.plainFile),
|
|
276
|
-
text,
|
|
277
|
-
hash: textHash(text),
|
|
278
|
-
...(pending.entry.asked !== undefined ? { asked: pending.entry.asked } : {}),
|
|
279
|
-
});
|
|
280
|
-
}
|
|
281
|
-
// A yes no chat had when turri quit: handed on now, while it is still about the functional spec as it is.
|
|
282
|
-
for (const kept of undeliveredEntries(project)) {
|
|
283
|
-
const { entry } = kept;
|
|
284
|
-
const plainFile = resolve(project, kept.plainFile);
|
|
285
|
-
const item = currentItem(plainFile, entry.funcId);
|
|
286
|
-
if (entry.report === undefined || item === undefined || textHash(item.markdown) !== entry.hash || hasScenarios(item)) {
|
|
287
|
-
markDelivered(project, kept.module, entry.funcId, entry.hash);
|
|
288
|
-
continue;
|
|
289
|
-
}
|
|
290
|
-
handOn({ project, module: kept.module, funcId: entry.funcId, plainFile, tip: resolve(project, entry.tip ?? kept.plainFile), hash: entry.hash, report: entry.report });
|
|
291
|
-
}
|
|
292
|
-
},
|
|
293
|
-
idle() {
|
|
294
|
-
if (queue.length === 0 && running.size === 0)
|
|
295
|
-
return Promise.resolve();
|
|
296
|
-
return new Promise((resolveIdle) => idleWaiters.push(resolveIdle));
|
|
297
|
-
},
|
|
298
|
-
taking(project) {
|
|
299
|
-
const mine = (work) => project === undefined || resolve(work.project) === resolve(project);
|
|
300
|
-
return [...new Set([...running.values(), ...queue].filter(mine).map((work) => `${work.module}:${work.funcId}`))];
|
|
301
|
-
},
|
|
302
|
-
evaluate(asked) {
|
|
303
|
-
const plainFile = resolve(asked.plainFile);
|
|
304
|
-
const project = projectDirOf(plainFile);
|
|
305
|
-
const item = currentItem(plainFile, asked.funcId);
|
|
306
|
-
if (item === undefined)
|
|
307
|
-
return "missing";
|
|
308
|
-
if (hasScenarios(item))
|
|
309
|
-
return "scenarios";
|
|
310
|
-
const text = item.markdown.trim();
|
|
311
|
-
const hash = textHash(text);
|
|
312
|
-
const known = advisorEntry(project, asked.module, asked.funcId);
|
|
313
|
-
// The tip its scenarios are tested in: given, else known, else the module at the top of a chain it is in - itself when none is.
|
|
314
|
-
const tip = asked.tip ?? (known?.tip !== undefined ? resolve(project, known.tip) : (tipsAbove(asked.module, project)[0]?.file ?? plainFile));
|
|
315
|
-
const reason = asked.reason?.trim();
|
|
316
|
-
const taken = take({ project, module: asked.module, funcId: asked.funcId, plainFile, tip: resolve(tip), text, hash, asked: reason !== undefined && reason !== "" ? { reason } : {} });
|
|
317
|
-
return taken ? "started" : "already";
|
|
318
|
-
},
|
|
319
|
-
stop() {
|
|
320
|
-
stopped = true;
|
|
321
|
-
queue.length = 0;
|
|
322
|
-
for (const work of running.values())
|
|
323
|
-
work.controller.abort();
|
|
324
|
-
},
|
|
325
|
-
};
|
|
326
|
-
return advisor;
|
|
327
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Which model the agents of a job run on.
|
|
3
|
-
*
|
|
4
|
-
* By default, whatever the conversation is using. The person can say otherwise - "render spec
|
|
5
|
-
* changes with Gemini Flash" - for one kind of work or for all of it, and that holds for the
|
|
6
|
-
* rest of the session, for jobs started from a tool call and for jobs a skill queues alike. A
|
|
7
|
-
* single tool call can also name a model for itself alone.
|
|
8
|
-
*
|
|
9
|
-
* A name is resolved strictly. pi's own pattern matching picks its best guess and says nothing
|
|
10
|
-
* - "gpt-5" becomes a Bedrock model with no credentials, "flash" a GLM one - and a job on a
|
|
11
|
-
* guessed model is worse than a question. So an exact id is taken as it is, a looser name is
|
|
12
|
-
* taken only when it fits exactly one model that has credentials, and anything else comes back
|
|
13
|
-
* as a short list to ask the person about.
|
|
14
|
-
*/
|
|
15
|
-
/** The part of pi's model registry this needs. */
|
|
16
|
-
export interface ModelCatalog {
|
|
17
|
-
getAll(): ReadonlyArray<CatalogModel>;
|
|
18
|
-
hasConfiguredAuth(model: CatalogModel): boolean;
|
|
19
|
-
}
|
|
20
|
-
export interface CatalogModel {
|
|
21
|
-
provider: string;
|
|
22
|
-
id: string;
|
|
23
|
-
name?: string;
|
|
24
|
-
}
|
|
25
|
-
export type ModelResolution = {
|
|
26
|
-
ok: true;
|
|
27
|
-
model: string;
|
|
28
|
-
name: string;
|
|
29
|
-
} | {
|
|
30
|
-
ok: false;
|
|
31
|
-
message: string;
|
|
32
|
-
candidates: string[];
|
|
33
|
-
};
|
|
34
|
-
/** Resolve what the person called a model to one this machine can run, or say why not. */
|
|
35
|
-
export declare function resolveModel(query: string, catalog: ModelCatalog): ModelResolution;
|
|
36
|
-
/** The resolution as text for the agent: the model, or why not and what to ask. */
|
|
37
|
-
export declare function describeResolution(resolution: ModelResolution): string;
|
|
38
|
-
/** Kinds of work a model can be chosen for. */
|
|
39
|
-
export type RenderWork = "spec_changes" | "functionalities";
|
|
40
|
-
export declare const WORK_LABEL: Record<RenderWork | "all", string>;
|
|
41
|
-
/** The models chosen in this session, by kind of work. Unset: the project's, or the conversation's model. */
|
|
42
|
-
export type ModelChoices = Partial<Record<RenderWork | "all", string>>;
|
|
43
|
-
/** The model a job of this kind runs on: chosen for it, chosen for everything, or the chat's. */
|
|
44
|
-
export declare function modelFor(choices: ModelChoices, work: RenderWork, chat: string | undefined): string | undefined;
|
|
45
|
-
/**
|
|
46
|
-
* Where each kind of work runs now, in a line each: chosen in this session, or the default coding
|
|
47
|
-
* model - from `--coding-model` or config.turri.yaml, said which - or the conversation's.
|
|
48
|
-
*/
|
|
49
|
-
export declare function describeChoices(choices: ModelChoices, chat: string | undefined, project?: {
|
|
50
|
-
model: string;
|
|
51
|
-
from: string;
|
|
52
|
-
}): string;
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import { type ChainEntry } from "./requires.ts";
|
|
2
|
-
/**
|
|
3
|
-
* Deploy: a module's code, as its last commit has it, put out in `dist/<module>` for the person to try.
|
|
4
|
-
*
|
|
5
|
-
* A render works in `plain_modules/<module>/code` while the person asks to try what is there, so what
|
|
6
|
-
* is there is half-written. Its last commit is not: every unit of work starts from one and ends with
|
|
7
|
-
* one, and both are runnable. So the commit is exported - git's own list of what it tracks, and
|
|
8
|
-
* nothing else - which is a copy of the working tree with every unstaged and untracked change put
|
|
9
|
-
* back, without a list of what each stack leaves lying around (`node_modules`, `.venv`, `target`). The
|
|
10
|
-
* working tree itself is never read or touched.
|
|
11
|
-
*
|
|
12
|
-
* What starts it runs here, on the person's machine, unfenced: a server the person opens in their
|
|
13
|
-
* browser, with their toolchains. The agent that releases it installs and runs what it needs itself,
|
|
14
|
-
* as any agent with a shell would - nothing is put to the person - and everything started is the
|
|
15
|
-
* harness's to stop: on a redeploy, on /halt, and when turri exits.
|
|
16
|
-
*/
|
|
17
|
-
/**
|
|
18
|
-
* How a module is released - always from its last commit, exported to `dist/<module>` first. `dist`, the default: started
|
|
19
|
-
* from there. `guided`: taken on from there as there is guidance to - the person's, the project's AGENTS.md, a skill -
|
|
20
|
-
* into the host codebase, say.
|
|
21
|
-
*/
|
|
22
|
-
export type ReleaseWay = "dist" | "guided";
|
|
23
|
-
export interface Deployment {
|
|
24
|
-
moduleName: string;
|
|
25
|
-
plainFile: string;
|
|
26
|
-
way: ReleaseWay;
|
|
27
|
-
/** `dist/<module>`, in the project: the module's last commit, exported. */
|
|
28
|
-
dir: string;
|
|
29
|
-
/** Guided: the host codebase the guidance takes the code into, and what release runs and starts runs from. */
|
|
30
|
-
hostDir?: string;
|
|
31
|
-
/** Where the module's code is built: `plain_modules/<module>/code`. */
|
|
32
|
-
buildDir: string;
|
|
33
|
-
commit: string;
|
|
34
|
-
/** The commit's subject: what the last unit of work that landed did. */
|
|
35
|
-
subject: string;
|
|
36
|
-
/** When, as git says it: "3 minutes ago". */
|
|
37
|
-
when: string;
|
|
38
|
-
/** Work under way in the module - changes nobody committed yet - left out. */
|
|
39
|
-
unfinished: boolean;
|
|
40
|
-
/** The module the spec's code lives in had nothing committed yet: the nearest one below it that had, instead. */
|
|
41
|
-
instead?: string;
|
|
42
|
-
/** When the release tool shipped it: what it started since is this release's. */
|
|
43
|
-
at?: number;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Which module to deploy for a spec: the tip of its codebase - code accumulates up a requires chain, so
|
|
47
|
-
* the top module holds everything below it. Before the tip has anything committed, the nearest module
|
|
48
|
-
* below it that has.
|
|
49
|
-
*/
|
|
50
|
-
export declare function deployTarget(plainFile: string, inModule?: string): {
|
|
51
|
-
entry: ChainEntry;
|
|
52
|
-
commit: string;
|
|
53
|
-
instead?: string;
|
|
54
|
-
};
|
|
55
|
-
/**
|
|
56
|
-
* Export the module's code at its last commit into `dist/<module>` - or `into`, `turri regenerate --build-dir` -
|
|
57
|
-
* replacing whatever was there, the harness's own files (what the code is built from, the agents' notes) left out.
|
|
58
|
-
*/
|
|
59
|
-
export declare function exportModule(plainFile: string, inModule?: string, into?: string): Deployment;
|
|
60
|
-
/**
|
|
61
|
-
* The host codebase a guided release works in: the git repository the project is in - an embedded project's host -
|
|
62
|
-
* or else `fallback`, where turri runs.
|
|
63
|
-
*/
|
|
64
|
-
export declare function hostDirOf(plainFile: string, fallback: string): string;
|
|
65
|
-
/** Where a path is, said from the current directory when it is below it. */
|
|
66
|
-
export declare function shortPath(path: string): string;
|
|
67
|
-
/** What was deployed, in a line or three. */
|
|
68
|
-
export declare function describeDeployment(deployment: Deployment): string;
|
|
69
|
-
export interface DeployedProcess {
|
|
70
|
-
name: string;
|
|
71
|
-
moduleName: string;
|
|
72
|
-
command: string;
|
|
73
|
-
/** Where it runs. */
|
|
74
|
-
dir: string;
|
|
75
|
-
url?: string;
|
|
76
|
-
/** Its output, both streams. */
|
|
77
|
-
log: string;
|
|
78
|
-
pid: number;
|
|
79
|
-
startedAt: number;
|
|
80
|
-
/** Set once it has ended. */
|
|
81
|
-
exited?: {
|
|
82
|
-
code: number | null;
|
|
83
|
-
signal: string | null;
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
/** Everything deploy started, running or ended, oldest first. */
|
|
87
|
-
export declare function listDeployed(): DeployedProcess[];
|
|
88
|
-
/** The ones still running. */
|
|
89
|
-
export declare function runningDeployed(moduleName?: string): DeployedProcess[];
|
|
90
|
-
/** Where a project's deployed processes write their output: its scratch, not the code in dist. */
|
|
91
|
-
export declare function deployLogDir(projectDir: string): string;
|
|
92
|
-
/** The end of a log, for when something did not come up. */
|
|
93
|
-
export declare function logTail(log: string, lines?: number, chars?: number): string;
|
|
94
|
-
/** Stop one deployed process, or every one of a module, or every one: politely, then not. Returns the names stopped. */
|
|
95
|
-
export declare function stopDeployed(which?: {
|
|
96
|
-
name?: string;
|
|
97
|
-
moduleName?: string;
|
|
98
|
-
}): Promise<string[]>;
|
|
99
|
-
/** Stop everything at once, without waiting: for when turri itself is going. */
|
|
100
|
-
export declare function stopAllDeployedNow(): void;
|
|
101
|
-
/** How long a server is given to answer at its URL, and to stay up when it has none. */
|
|
102
|
-
export declare const READY_TIMEOUT_MS: number;
|
|
103
|
-
export interface StartResult {
|
|
104
|
-
ok: boolean;
|
|
105
|
-
/** What happened, for the agent and the person. */
|
|
106
|
-
text: string;
|
|
107
|
-
process?: DeployedProcess;
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Start what keeps running, in `dir` - the deployed folder `root`, or one inside it. A folder that is not there starts
|
|
111
|
-
* nothing: said, with what the deployed folder holds, so the agent can name the right one.
|
|
112
|
-
*/
|
|
113
|
-
export declare function startDeployed(input: {
|
|
114
|
-
name: string;
|
|
115
|
-
command: string;
|
|
116
|
-
dir: string;
|
|
117
|
-
moduleName: string;
|
|
118
|
-
logDir: string;
|
|
119
|
-
url?: string;
|
|
120
|
-
root?: string;
|
|
121
|
-
}): Promise<StartResult>;
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import type { AdvisorAnswer, AdvisorInput, AdvisorReport } from "./advisor-records.ts";
|
|
2
|
-
/**
|
|
3
|
-
* The test advisor's judgement of one functional spec: does it need explicit testing scenarios, and if so, which inputs
|
|
4
|
-
* should they cover (docs/test-advisor.md). Every step is a plain model call on `models.advisor`, answered through one
|
|
5
|
-
* tool and checked in code, as the planner's grouping agent is - none is a skill, and none can touch the project.
|
|
6
|
-
*
|
|
7
|
-
* - **Classify:** four questions, each yes carrying its evidence - a wrong output that looks right (silent failure), an
|
|
8
|
-
* input two reasonable readings answer differently (divergence), what would change (revisited), the consequence of a
|
|
9
|
-
* bug (cost). A yes whose evidence is empty or malformed counts as no. Silent failure, divergence or cost make the
|
|
10
|
-
* verdict yes; revisited alone does not - the unit tests are the regression protection.
|
|
11
|
-
* - **On a yes, pick the inputs:** one call writes 1-10 boundary probes (and the divergence's input), readers that
|
|
12
|
-
* differ only by their system prompt each predict every probe's output, code compares them, and any disagreement is a
|
|
13
|
-
* candidate - the union, never a majority. The third reader is spared when the first two already disagree. One last
|
|
14
|
-
* call keeps, of each candidate, the readings a reasonable person could hold.
|
|
15
|
-
*/
|
|
16
|
-
/** The functional spec the advisor looks at, and what it reads it with. */
|
|
17
|
-
export interface AdvisorSubject {
|
|
18
|
-
module: string;
|
|
19
|
-
funcId: string;
|
|
20
|
-
/** The functional spec's text. */
|
|
21
|
-
text: string;
|
|
22
|
-
/** The module's .plain file, whole: its definitions, its reqs, the functional specs around it. */
|
|
23
|
-
moduleText: string;
|
|
24
|
-
/** The project's own words on what matters: its AGENTS.md, the steering given in the conversation. */
|
|
25
|
-
context: string[];
|
|
26
|
-
/** A module below's: the tip its scenarios are tested in - built on it, its own functional specs beside it. */
|
|
27
|
-
testedIn?: {
|
|
28
|
-
module: string;
|
|
29
|
-
text: string;
|
|
30
|
-
};
|
|
31
|
-
/** Why the chat asked for the evaluation (evaluate_tests) - "the coding agent failed three times to implement it" - for the classifier, as context. */
|
|
32
|
-
reason?: string;
|
|
33
|
-
}
|
|
34
|
-
export interface AdvisorCallOptions {
|
|
35
|
-
/** Where the calls run: the project. */
|
|
36
|
-
cwd: string;
|
|
37
|
-
/** The advisor's model (advisorModel) - the `advisor` role's config is laid over it as for any agent. */
|
|
38
|
-
model?: string;
|
|
39
|
-
}
|
|
40
|
-
/** The classification: the verdict, the questions that were a yes with their evidence, and the divergence's input. */
|
|
41
|
-
export interface Classification {
|
|
42
|
-
verdict: "yes" | "no";
|
|
43
|
-
questions: AdvisorAnswer[];
|
|
44
|
-
divergence?: {
|
|
45
|
-
input: string;
|
|
46
|
-
readings: [string, string];
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
/** The fewest and most probes a functional spec is given. */
|
|
50
|
-
export declare const MIN_PROBES = 1;
|
|
51
|
-
export declare const MAX_PROBES = 10;
|
|
52
|
-
/** What a reader answers for an input the functional spec does not settle: a scenario on it would pin a guess. */
|
|
53
|
-
export declare const UNSPECIFIED = "unspecified";
|
|
54
|
-
/** The readers: the same task, decorrelated by their system prompts alone. */
|
|
55
|
-
export declare const READERS: ReadonlyArray<{
|
|
56
|
-
name: string;
|
|
57
|
-
system: string;
|
|
58
|
-
}>;
|
|
59
|
-
/** Text compared as the readers' outputs are: whitespace collapsed, case left aside. */
|
|
60
|
-
export declare function normalised(text: string): string;
|
|
61
|
-
type ClassificationAnswer = {
|
|
62
|
-
silent_failure: {
|
|
63
|
-
answer: boolean;
|
|
64
|
-
wrong_output?: string;
|
|
65
|
-
};
|
|
66
|
-
divergence: {
|
|
67
|
-
answer: boolean;
|
|
68
|
-
input?: string;
|
|
69
|
-
reading_a?: string;
|
|
70
|
-
reading_b?: string;
|
|
71
|
-
};
|
|
72
|
-
revisited: {
|
|
73
|
-
answer: boolean;
|
|
74
|
-
would_change?: string;
|
|
75
|
-
};
|
|
76
|
-
cost: {
|
|
77
|
-
answer: boolean;
|
|
78
|
-
consequence?: string;
|
|
79
|
-
};
|
|
80
|
-
};
|
|
81
|
-
/**
|
|
82
|
-
* The classification, from the call's answer: each yes kept only with its evidence - a yes without it, or with it
|
|
83
|
-
* malformed (two readings that are the same), is a no. The verdict is yes on silent failure, divergence or cost.
|
|
84
|
-
*/
|
|
85
|
-
export declare function classificationOf(answer: ClassificationAnswer): Classification;
|
|
86
|
-
/** Classify a functional spec: one call, four evidence-backed questions. Throws when the call gives no answer. */
|
|
87
|
-
export declare function classify(subject: AdvisorSubject, options: AdvisorCallOptions): Promise<Classification>;
|
|
88
|
-
/**
|
|
89
|
-
* The inputs the readers split on - every probe where any two predictions differ once normalised: the union, never a
|
|
90
|
-
* majority - each with its distinct readings, in the order the readers gave them.
|
|
91
|
-
*/
|
|
92
|
-
export declare function splitInputs(readings: string[][]): Map<number, string[]>;
|
|
93
|
-
/**
|
|
94
|
-
* Pick the inputs a functional spec's scenarios should cover: the probes, the readers' predictions of them, the
|
|
95
|
-
* disagreements in code, and the verifier's word on each. An input the readers agree on comes with their output; one
|
|
96
|
-
* they split on, with every reading the verifier kept - a single reading left is an agreed one, and none left drops it.
|
|
97
|
-
*/
|
|
98
|
-
export declare function pickInputs(subject: AdvisorSubject, classification: Classification, options: AdvisorCallOptions): Promise<AdvisorInput[]>;
|
|
99
|
-
/** The whole judgement: classify, and on a yes pick the inputs. Throws when a call that cannot be done without fails. */
|
|
100
|
-
export declare function advise(subject: AdvisorSubject, options: AdvisorCallOptions): Promise<AdvisorReport>;
|
|
101
|
-
export {};
|