@turri-dev/core 0.1.1-next.8cda3cc → 0.1.1-next.ad4aa8f
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/CHANGELOG.md +56 -0
- package/README.md +17 -11
- package/dist/api/models.d.ts +9 -0
- package/dist/api/models.js +15 -0
- package/dist/api/plain.d.ts +6 -6
- package/dist/api/plain.js +4 -7
- package/dist/api/project.d.ts +35 -0
- package/dist/api/project.js +47 -0
- package/dist/api/session.d.ts +48 -0
- package/dist/api/session.js +17 -0
- package/dist/api/system.d.ts +18 -0
- package/dist/api/system.js +23 -0
- package/dist/btw.d.ts +1 -1
- package/dist/capture/capture.js +11 -8
- package/dist/capture/chat.d.ts +0 -11
- package/dist/capture/chat.js +0 -29
- package/dist/capture/config.d.ts +4 -5
- package/dist/capture/config.js +34 -20
- package/dist/capture/models.d.ts +2 -1
- package/dist/capture/models.js +1 -0
- package/dist/chat-entries.d.ts +81 -39
- package/dist/chat-entries.js +125 -11
- package/dist/chat-model.d.ts +37 -0
- package/dist/chat-model.js +61 -0
- package/dist/chats.d.ts +54 -42
- package/dist/chats.js +86 -80
- package/dist/client.d.ts +30 -0
- package/dist/client.js +12 -0
- package/dist/config-edit.d.ts +54 -1
- package/dist/config-edit.js +103 -33
- package/dist/config.d.ts +12 -9
- package/dist/config.js +38 -9
- package/dist/doctor-checks.d.ts +42 -0
- package/dist/doctor-checks.js +39 -0
- package/dist/environment.d.ts +2 -23
- package/dist/environment.js +5 -68
- package/dist/errors.d.ts +32 -0
- package/dist/errors.js +24 -0
- package/dist/extension.d.ts +23 -16
- package/dist/extension.js +170 -234
- package/dist/identity.d.ts +1 -1
- package/dist/identity.js +13 -9
- package/dist/init-config.d.ts +11 -9
- package/dist/init-config.js +15 -7
- package/dist/launch-session.d.ts +2 -0
- package/dist/launch-session.js +17 -1
- package/dist/loop-tools.js +11 -10
- package/dist/module-check.d.ts +13 -0
- package/dist/module-check.js +117 -0
- package/dist/notice.d.ts +5 -0
- package/dist/parse-tool.js +3 -2
- package/dist/plain/check.d.ts +27 -13
- package/dist/plain/check.js +51 -116
- package/dist/plain/files.d.ts +2 -0
- package/dist/plain/files.js +13 -0
- package/dist/plain/graph.js +2 -2
- package/dist/plain/highlight.d.ts +4 -20
- package/dist/plain/highlight.js +7 -5
- package/dist/project.d.ts +19 -0
- package/dist/project.js +34 -0
- package/dist/quiet.d.ts +0 -2
- package/dist/quiet.js +0 -14
- package/dist/regenerate/command-check.d.ts +0 -8
- package/dist/regenerate/command-check.js +133 -53
- package/dist/regenerate/conversation-writes.d.ts +5 -1
- package/dist/regenerate/conversation-writes.js +7 -3
- package/dist/regenerate/jobs.d.ts +25 -2
- package/dist/regenerate/jobs.js +3 -0
- package/dist/regenerate/launch.d.ts +1 -0
- package/dist/regenerate/launch.js +9 -0
- package/dist/regenerate/ledger-view.d.ts +14 -14
- package/dist/regenerate/ledger.d.ts +1 -0
- package/dist/regenerate/ledger.js +4 -2
- package/dist/regenerate/loop.d.ts +2 -1
- package/dist/regenerate/loop.js +9 -1
- package/dist/regenerate/os-sandbox.d.ts +4 -2
- package/dist/regenerate/os-sandbox.js +0 -1
- package/dist/regenerate/regenerate.js +2 -1
- package/dist/regenerate/requires-chain.d.ts +44 -0
- package/dist/regenerate/requires-chain.js +174 -0
- package/dist/regenerate/requires.d.ts +2 -40
- package/dist/regenerate/requires.js +14 -171
- package/dist/regenerate/resources.d.ts +0 -2
- package/dist/regenerate/resources.js +2 -14
- package/dist/regenerate/shell.js +20 -9
- package/dist/regenerate/spec-map.d.ts +2 -0
- package/dist/regenerate/spec-map.js +4 -0
- package/dist/regenerate/standing.d.ts +5 -2
- package/dist/run-report.js +2 -2
- package/dist/self-invocation.d.ts +1 -1
- package/dist/self-invocation.js +2 -3
- package/dist/sentinel-chat.js +7 -11
- package/dist/sentinel.d.ts +1 -1
- package/dist/sentinel.js +12 -5
- package/dist/session-events.d.ts +14 -0
- package/dist/session.d.ts +594 -0
- package/dist/session.js +672 -0
- package/dist/settings.d.ts +28 -2
- package/dist/settings.js +92 -56
- package/dist/setup.d.ts +6 -30
- package/dist/setup.js +28 -105
- package/dist/stack.d.ts +25 -12
- package/dist/stack.js +77 -12
- package/dist/surface.d.ts +2 -2
- package/dist/surface.js +4 -5
- package/dist/work.d.ts +125 -0
- package/dist/work.js +250 -0
- package/docs/README.md +2 -3
- package/docs/capture.md +4 -4
- package/docs/chats.md +5 -3
- package/docs/claude-subscription.md +2 -2
- package/docs/config.md +4 -4
- package/docs/core.md +105 -128
- package/docs/development.md +9 -9
- package/docs/headless.md +1 -1
- package/docs/installation.md +4 -2
- package/docs/launch.md +2 -2
- package/docs/parser.md +1 -1
- package/docs/regenerating.md +1 -1
- package/docs/sandbox.md +4 -4
- package/docs/sentinel.md +4 -4
- package/docs/skills-and-gates.md +1 -1
- package/docs/using.md +2 -2
- package/genome/rules/integration-embedded-testing.md +3 -3
- package/genome/rules/integration-embedded.md +3 -3
- package/genome/skills/implement-conformance-testing-script/SKILL.md +6 -4
- package/genome/skills/implement-conformance-testing-script/assets/run_conformance_tests_java.sh +13 -11
- package/genome/skills/implement-conformance-testing-script/assets/run_conformance_tests_python.sh +8 -7
- package/genome/skills/implement-unit-testing-script/SKILL.md +7 -5
- package/genome/skills/implement-unit-testing-script/assets/run_unittests_java.sh +9 -13
- package/genome/skills/implement-unit-testing-script/assets/run_unittests_python.sh +1 -1
- package/package.json +19 -32
- package/dist/api/commands.d.ts +0 -45
- package/dist/api/commands.js +0 -54
- package/dist/api/config.d.ts +0 -8
- package/dist/api/config.js +0 -8
- package/dist/api/ledger.d.ts +0 -3
- package/dist/api/ledger.js +0 -3
- package/dist/api/startup.d.ts +0 -8
- package/dist/api/startup.js +0 -8
- package/dist/api/terminal.d.ts +0 -18
- package/dist/api/terminal.js +0 -16
- package/dist/chat-models.d.ts +0 -11
- package/dist/chat-models.js +0 -11
- package/dist/chat-ui.d.ts +0 -33
- package/dist/chat-ui.js +0 -192
- package/dist/headless.d.ts +0 -99
- package/dist/headless.js +0 -226
- package/dist/host-session.d.ts +0 -136
- package/dist/host-session.js +0 -139
- package/dist/host.d.ts +0 -8
- package/dist/host.js +0 -17
- package/dist/index.d.ts +0 -16
- package/dist/index.js +0 -7
- package/dist/notifications.d.ts +0 -21
- package/dist/notifications.js +0 -44
- package/dist/reopen.d.ts +0 -29
- package/dist/reopen.js +0 -47
- package/dist/turri-versions.d.ts +0 -71
- package/dist/turri-versions.js +0 -276
- package/dist/view.d.ts +0 -78
- package/dist/view.js +0 -1
- package/docs/hosting.md +0 -284
package/dist/settings.d.ts
CHANGED
|
@@ -15,11 +15,37 @@ import { type Setting } from "./config-edit.ts";
|
|
|
15
15
|
export interface LiveHooks {
|
|
16
16
|
/** The chat's model is now this - provider/id:thinking - or, undefined, no longer set in the file. */
|
|
17
17
|
chatModel(spec: string | undefined, ctx: ExtensionContext): Promise<string | undefined>;
|
|
18
|
-
/** The coding model changed in the file: one given for this session - --coding-model - gives way to it. */
|
|
19
|
-
codingModel(): string | undefined;
|
|
20
18
|
/** How many pulses run at once: the number, or the machine's default. */
|
|
21
19
|
parallelJobs(count: number | undefined): string | undefined;
|
|
20
|
+
/** harness-model changed: every chat of the person's put on it. */
|
|
21
|
+
harnessChanged?(): Promise<void>;
|
|
22
22
|
}
|
|
23
|
+
/** What a written setting changes as turri runs, outside any chat: the session's. */
|
|
24
|
+
export interface WriteHooks {
|
|
25
|
+
/** The chat that changed it switches to its model - provider/id:thinking - or, undefined, no longer set in the file. */
|
|
26
|
+
chatModel?(spec: string | undefined): Promise<string | undefined>;
|
|
27
|
+
/** harness-model changed: every chat of the person's put on it, not only the one that changed it. */
|
|
28
|
+
harnessChanged?(): Promise<void>;
|
|
29
|
+
/** How many pulses run at once: the number, or the machine's default. */
|
|
30
|
+
parallelJobs(count: number | undefined): string | undefined;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Write a setting - or unset it, `value` undefined - into config.turri.yaml, or `module`'s own file, and change live what
|
|
34
|
+
* turri fixed at its start: the AWS region a Bedrock model needs, a model the session was opened with giving way to the
|
|
35
|
+
* file's, the chat's model, how many pulses run at once. Says what it did and when it takes effect. `chatSpec`: the
|
|
36
|
+
* chat's model as the file has it now.
|
|
37
|
+
*/
|
|
38
|
+
export declare function changeSetting(cwd: string, setting: Setting, value: unknown, module: string | undefined, hooks: WriteHooks & {
|
|
39
|
+
chatSpec?: () => string | undefined;
|
|
40
|
+
}): Promise<{
|
|
41
|
+
file: string;
|
|
42
|
+
said: string;
|
|
43
|
+
}>;
|
|
44
|
+
/**
|
|
45
|
+
* A setting's value as a front end gives it - typed, not typed in - checked as /settings checks what is typed: what to
|
|
46
|
+
* write, undefined to unset it. `known`: whether a model can be reached here. One it cannot take throws `refused`.
|
|
47
|
+
*/
|
|
48
|
+
export declare function givenValue(cwd: string, setting: Setting, value: unknown, known?: (model: string) => boolean): unknown;
|
|
23
49
|
export interface SettingsOptions {
|
|
24
50
|
/** The folder whose config.turri.yaml the chat reads. */
|
|
25
51
|
cwd: string;
|
package/dist/settings.js
CHANGED
|
@@ -2,11 +2,94 @@ import { defineTool } from "@earendil-works/pi-coding-agent";
|
|
|
2
2
|
import { Type } from "typebox";
|
|
3
3
|
import { basename, isAbsolute, join, relative, resolve } from "node:path";
|
|
4
4
|
import { applyBedrockRegion } from "./bedrock-region.js";
|
|
5
|
-
import { CONFIG_FILE, LEGACY_CONFIG_FILE, moduleConfigFile, moduleConfigsOf, splitModelSpec, THINKING_LEVELS, usesLegacyConfig } from "./config.js";
|
|
6
|
-
import { currentValue, dotenvFiles, EFFECT_TEXT, overriddenBy, parseValue, pathOptions, readConfigText, readModuleConfigText, settingOf, settings, shownValue, writeSetting, } from "./config-edit.js";
|
|
5
|
+
import { CONFIG_FILE, configOverrides, dropConfigOverride, LEGACY_CONFIG_FILE, modelSpec, moduleConfigFile, moduleConfigsOf, splitModelSpec, THINKING_LEVELS, usesLegacyConfig } from "./config.js";
|
|
6
|
+
import { currentValue, dotenvFiles, EFFECT_TEXT, overriddenBy, parseValue, pathOptions, readConfigText, readModuleConfigText, settingOf, settings, settingTakes, shownValue, writeSetting, } from "./config-edit.js";
|
|
7
|
+
import { TurriError } from "./errors.js";
|
|
7
8
|
import { PACKAGE_ROOT } from "./environment.js";
|
|
8
9
|
import { describeResolution, resolveModel } from "./regenerate/model-names.js";
|
|
9
10
|
import { loadRules } from "./rules.js";
|
|
11
|
+
/**
|
|
12
|
+
* Write a setting - or unset it, `value` undefined - into config.turri.yaml, or `module`'s own file, and change live what
|
|
13
|
+
* turri fixed at its start: the AWS region a Bedrock model needs, a model the session was opened with giving way to the
|
|
14
|
+
* file's, the chat's model, how many pulses run at once. Says what it did and when it takes effect. `chatSpec`: the
|
|
15
|
+
* chat's model as the file has it now.
|
|
16
|
+
*/
|
|
17
|
+
export async function changeSetting(cwd, setting, value, module, hooks) {
|
|
18
|
+
// The first setting written where the project is still read from config.yaml: copied to config.turri.yaml first.
|
|
19
|
+
const adopting = usesLegacyConfig(cwd);
|
|
20
|
+
const text = writeSetting(cwd, setting.key, value, module);
|
|
21
|
+
const file = module !== undefined ? moduleConfigFile(module) : CONFIG_FILE;
|
|
22
|
+
const notes = [];
|
|
23
|
+
// A model changed: the AWS region its Bedrock models need is worked out again - set, moved or taken back by turri.
|
|
24
|
+
if (setting.key.endsWith("-model") || setting.key.startsWith("models."))
|
|
25
|
+
applyBedrockRegion(cwd);
|
|
26
|
+
// What turri fixed at its start, changed now: a model the session was opened with gives way to the file's.
|
|
27
|
+
if (setting.key === "harness-model" || setting.key === "models.chat") {
|
|
28
|
+
const gave = givenWay(cwd, "harnessModel", "the harness model");
|
|
29
|
+
if (gave !== undefined)
|
|
30
|
+
notes.push(gave);
|
|
31
|
+
const said = await hooks.chatModel?.(hooks.chatSpec?.());
|
|
32
|
+
if (said !== undefined)
|
|
33
|
+
notes.push(said);
|
|
34
|
+
await hooks.harnessChanged?.();
|
|
35
|
+
}
|
|
36
|
+
if (setting.key === "coding-model" || setting.key === "models.coding" || setting.key === "models.default") {
|
|
37
|
+
const gave = givenWay(cwd, "codingModel", "the coding model");
|
|
38
|
+
if (gave !== undefined)
|
|
39
|
+
notes.push(gave);
|
|
40
|
+
}
|
|
41
|
+
if (setting.key === "parallel-jobs") {
|
|
42
|
+
const said = hooks.parallelJobs(typeof value === "number" ? value : undefined);
|
|
43
|
+
if (said !== undefined)
|
|
44
|
+
notes.push(said);
|
|
45
|
+
}
|
|
46
|
+
if (adopting)
|
|
47
|
+
notes.push(`${LEGACY_CONFIG_FILE} was copied to ${CONFIG_FILE} first - turri reads its own file from now on, and leaves ${LEGACY_CONFIG_FILE} as it is.`);
|
|
48
|
+
if (module !== undefined)
|
|
49
|
+
notes.push(`It holds for ${module}.plain and every module built on it that has no file of its own, over ${CONFIG_FILE}.`);
|
|
50
|
+
notes.push(...overriddenBy(cwd, text, setting, module));
|
|
51
|
+
const what = value === undefined ? `${setting.key} unset - ${module !== undefined ? `${CONFIG_FILE}'s holds` : setting.unset}` : `${setting.key}: ${shownValue(value)}`;
|
|
52
|
+
return { file, said: [`${what} - written to ${file}, ${EFFECT_TEXT[setting.effect]}.`, ...notes].join("\n") };
|
|
53
|
+
}
|
|
54
|
+
/** A model this session was opened with, given way to the file's: said, or nothing when there was none. */
|
|
55
|
+
function givenWay(cwd, which, what) {
|
|
56
|
+
const given = modelSpec(configOverrides(cwd)[which]);
|
|
57
|
+
if (given === undefined)
|
|
58
|
+
return undefined;
|
|
59
|
+
dropConfigOverride(cwd, which);
|
|
60
|
+
return `Chosen this session, and given way to the config: ${what} this session was opened with, ${given}.`;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* A setting's value as a front end gives it - typed, not typed in - checked as /settings checks what is typed: what to
|
|
64
|
+
* write, undefined to unset it. `known`: whether a model can be reached here. One it cannot take throws `refused`.
|
|
65
|
+
*/
|
|
66
|
+
export function givenValue(cwd, setting, value, known) {
|
|
67
|
+
if (value === undefined || value === null)
|
|
68
|
+
return undefined;
|
|
69
|
+
if (setting.kind === "list") {
|
|
70
|
+
if (!Array.isArray(value) || !value.every((item) => typeof item === "string"))
|
|
71
|
+
throw new TurriError("refused", `${setting.key} takes ${settingTakes(setting)}.`);
|
|
72
|
+
const unknown = setting.options !== undefined && setting.options.length > 0 ? value.filter((item) => !setting.options.includes(item)) : [];
|
|
73
|
+
if (unknown.length > 0)
|
|
74
|
+
throw new TurriError("refused", `Not one of ${setting.key}'s: ${unknown.join(", ")}. It takes ${setting.options.join(", ")}.`);
|
|
75
|
+
return [...value];
|
|
76
|
+
}
|
|
77
|
+
const typed = String(value);
|
|
78
|
+
const outside = outsideProject(cwd, setting, typed);
|
|
79
|
+
if (outside !== undefined)
|
|
80
|
+
throw new TurriError("refused", outside);
|
|
81
|
+
const parsed = parseValue(setting, typed, known);
|
|
82
|
+
if ("error" in parsed)
|
|
83
|
+
throw new TurriError("refused", parsed.error);
|
|
84
|
+
return "unset" in parsed ? undefined : parsed.value;
|
|
85
|
+
}
|
|
86
|
+
/** Why a path setting's value is refused: it is outside the project. Undefined for one inside, or another kind. */
|
|
87
|
+
function outsideProject(cwd, setting, typed) {
|
|
88
|
+
if (setting.kind !== "path" || /^(unset|default|none|-)$/i.test(typed.trim()))
|
|
89
|
+
return undefined;
|
|
90
|
+
const inside = relative(cwd, resolve(cwd, typed.trim()));
|
|
91
|
+
return inside.startsWith("..") || isAbsolute(inside) ? `${setting.key} takes a path inside the project, from its root - ${typed.trim()} is outside it.` : undefined;
|
|
92
|
+
}
|
|
10
93
|
/** The option that unsets a setting, for a setting. */
|
|
11
94
|
const unsetOption = (setting) => `unset - ${setting.unset}`;
|
|
12
95
|
const TYPE_ANOTHER = "type another…";
|
|
@@ -64,43 +147,8 @@ export function registerSettings(pi, options) {
|
|
|
64
147
|
pi.on("session_start", (_event, ctx) => {
|
|
65
148
|
seen = ctx;
|
|
66
149
|
});
|
|
67
|
-
/**
|
|
68
|
-
|
|
69
|
-
* its start; says what it did and when it takes effect.
|
|
70
|
-
*/
|
|
71
|
-
const change = async (setting, value, ctx, module) => {
|
|
72
|
-
// The first setting written where the project is still read from config.yaml: copied to config.turri.yaml first.
|
|
73
|
-
const adopting = usesLegacyConfig(cwd);
|
|
74
|
-
const text = writeSetting(cwd, setting.key, value, module);
|
|
75
|
-
const file = module !== undefined ? moduleConfigFile(module) : CONFIG_FILE;
|
|
76
|
-
const notes = [];
|
|
77
|
-
// A model changed: the AWS region its Bedrock models need is worked out again - set, moved or taken back by turri.
|
|
78
|
-
if (setting.key.endsWith("-model") || setting.key.startsWith("models."))
|
|
79
|
-
applyBedrockRegion(cwd);
|
|
80
|
-
// What turri fixed at its start, changed now.
|
|
81
|
-
if (setting.key === "harness-model" || setting.key === "models.chat") {
|
|
82
|
-
const said = await options.live.chatModel(options.chatSpec(), ctx);
|
|
83
|
-
if (said !== undefined)
|
|
84
|
-
notes.push(said);
|
|
85
|
-
}
|
|
86
|
-
if (setting.key === "coding-model" || setting.key === "models.coding" || setting.key === "models.default") {
|
|
87
|
-
const said = options.live.codingModel();
|
|
88
|
-
if (said !== undefined)
|
|
89
|
-
notes.push(said);
|
|
90
|
-
}
|
|
91
|
-
if (setting.key === "parallel-jobs") {
|
|
92
|
-
const said = options.live.parallelJobs(typeof value === "number" ? value : undefined);
|
|
93
|
-
if (said !== undefined)
|
|
94
|
-
notes.push(said);
|
|
95
|
-
}
|
|
96
|
-
if (adopting)
|
|
97
|
-
notes.push(`${LEGACY_CONFIG_FILE} was copied to ${CONFIG_FILE} first - turri reads its own file from now on, and leaves ${LEGACY_CONFIG_FILE} as it is.`);
|
|
98
|
-
if (module !== undefined)
|
|
99
|
-
notes.push(`It holds for ${module}.plain and every module built on it that has no file of its own, over ${CONFIG_FILE}.`);
|
|
100
|
-
notes.push(...overriddenBy(cwd, text, setting, module));
|
|
101
|
-
const what = value === undefined ? `${setting.key} unset - ${module !== undefined ? `${CONFIG_FILE}'s holds` : setting.unset}` : `${setting.key}: ${shownValue(value)}`;
|
|
102
|
-
return [`${what} - written to ${file}, ${EFFECT_TEXT[setting.effect]}.`, ...notes].join("\n");
|
|
103
|
-
};
|
|
150
|
+
/** Write a setting - or unset it - and say what it did and when it takes effect. */
|
|
151
|
+
const change = async (setting, value, ctx, module) => (await changeSetting(cwd, setting, value, module, { chatModel: (spec) => options.live.chatModel(spec, ctx), chatSpec: options.chatSpec, parallelJobs: options.live.parallelJobs, ...(options.live.harnessChanged !== undefined ? { harnessChanged: options.live.harnessChanged } : {}) })).said;
|
|
104
152
|
/** Set a setting to what was typed - or unset it - and say what it did and when it takes effect. */
|
|
105
153
|
const apply = async (setting, typed, ctx) => {
|
|
106
154
|
const models = reachable(ctx);
|
|
@@ -183,7 +231,7 @@ export function registerSettings(pi, options) {
|
|
|
183
231
|
return undefined;
|
|
184
232
|
if (chosen === PI_ENTRY) {
|
|
185
233
|
if (!(options.openPiMenu?.() ?? false))
|
|
186
|
-
ctx.ui.notify("pi's own settings open only
|
|
234
|
+
ctx.ui.notify("pi's own settings open only where the app you use has them.", "info");
|
|
187
235
|
return undefined;
|
|
188
236
|
}
|
|
189
237
|
if (chosen === ROLES_ENTRY) {
|
|
@@ -333,11 +381,9 @@ function writtenValue(setting, given, cwd, ctx) {
|
|
|
333
381
|
resolvedModel = resolved.model;
|
|
334
382
|
typed = `${resolvedModel}${level !== undefined ? `:${level}` : ""}`;
|
|
335
383
|
}
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
throw new Error(`${setting.key} takes a path inside the project, from its root - ${typed} is outside it. Nothing was written.`);
|
|
340
|
-
}
|
|
384
|
+
const outside = outsideProject(cwd, setting, typed);
|
|
385
|
+
if (outside !== undefined)
|
|
386
|
+
throw new Error(`${outside} Nothing was written.`);
|
|
341
387
|
const parsed = parseValue(setting, typed, resolvedModel === undefined ? undefined : (model) => model === resolvedModel);
|
|
342
388
|
if ("error" in parsed)
|
|
343
389
|
throw new Error(`${parsed.error} Nothing was written.`);
|
|
@@ -360,17 +406,7 @@ function describeSettings(cwd, rules) {
|
|
|
360
406
|
/** One setting, as the chat is told it: what it does, what it takes, what it is in each file. */
|
|
361
407
|
function describeSetting(cwd, setting) {
|
|
362
408
|
const now = currentValue(readConfigText(cwd), setting.key);
|
|
363
|
-
const takes = setting
|
|
364
|
-
? "true or false"
|
|
365
|
-
: setting.kind === "model"
|
|
366
|
-
? "a model, provider/model-id[:thinking]"
|
|
367
|
-
: setting.kind === "path"
|
|
368
|
-
? "a path from the project root"
|
|
369
|
-
: setting.kind === "list"
|
|
370
|
-
? `a list${setting.options !== undefined ? ` of ${setting.options.join(", ")}` : ""}`
|
|
371
|
-
: setting.options !== undefined
|
|
372
|
-
? `${setting.kind === "number" ? "a number - e.g. " : "one of "}${setting.options.join(", ")}`
|
|
373
|
-
: `a ${setting.kind}`;
|
|
409
|
+
const takes = settingTakes(setting);
|
|
374
410
|
const modules = setting.projectOnly === true ? [] : moduleConfigsOf(cwd).flatMap((module) => {
|
|
375
411
|
const own = currentValue(readModuleConfigText(cwd, module), setting.key);
|
|
376
412
|
return own !== undefined ? [`${moduleConfigFile(module)}: ${shownValue(own)}`] : [];
|
package/dist/setup.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { checkNode, type Check, type Level } from "./node-check.ts";
|
|
2
2
|
import { type Wall } from "./regenerate/os-sandbox.ts";
|
|
3
3
|
import { type ModelAccess } from "./model-check.ts";
|
|
4
|
+
import { type DoctorModels, type DoctorOptions } from "./doctor-checks.ts";
|
|
4
5
|
/**
|
|
5
6
|
* `turri doctor`: whether this machine is ready for turri.
|
|
6
7
|
*
|
|
@@ -13,7 +14,7 @@ import { type ModelAccess } from "./model-check.ts";
|
|
|
13
14
|
* `doctor()` is the checks alone, for the CLI and for a host (src/host.ts): it prints nothing and asks nothing.
|
|
14
15
|
*/
|
|
15
16
|
export { checkNode, type Check, type Level };
|
|
16
|
-
export
|
|
17
|
+
export { asksModels, describeChecks, MARK, verdictOf, type DoctorModels, type DoctorOptions } from "./doctor-checks.ts";
|
|
17
18
|
/** bash: every agent command and every testing script runs with it, on every platform. */
|
|
18
19
|
export declare function checkShell(found?: boolean, platform?: NodeJS.Platform): Check;
|
|
19
20
|
/** git: each module's history, which every pulse starts from and lands in, and the spec diffs the work is planned from. */
|
|
@@ -29,35 +30,18 @@ export declare function checkProject(project: string, machine?: {
|
|
|
29
30
|
has?: (command: string) => boolean;
|
|
30
31
|
exists?: (path: string) => boolean;
|
|
31
32
|
jdk?: () => boolean | Promise<boolean>;
|
|
33
|
+
version?: (toolchain: string) => string | undefined | Promise<string | undefined>;
|
|
32
34
|
}): Promise<Check[]>;
|
|
33
35
|
/**
|
|
34
36
|
* In a project: each model its config.turri.yaml names - or the module config pinned, its file's over it - tried with one short
|
|
35
37
|
* request. A model that answers is ready; one that does not says what the provider said, and what to do about it.
|
|
36
38
|
*/
|
|
37
|
-
export declare function checkProjectModels(project: string, access?: ModelAccess): Promise<Check[]>;
|
|
38
|
-
export interface DoctorOptions {
|
|
39
|
-
/** The project to check. Without it, only the machine. */
|
|
40
|
-
dir?: string;
|
|
41
|
-
/** Ask each model the project's config names for a word - a request a model, which costs money. Off by default. */
|
|
42
|
-
models?: boolean;
|
|
43
|
-
/** The environment whose PATH is looked in - bash, git, the sandbox, the toolchains, what the testing scripts run. */
|
|
44
|
-
env?: NodeJS.ProcessEnv;
|
|
45
|
-
}
|
|
46
|
-
/** The CLI's own: what matters only in a terminal, and models named on the command line - asked of, a project or not. */
|
|
47
|
-
export interface CliOptions {
|
|
48
|
-
cli?: boolean;
|
|
49
|
-
modelsGiven?: boolean;
|
|
50
|
-
}
|
|
51
|
-
/** Whether doctor asks the models: asked to, and a config that names them - or models named on the command line. */
|
|
52
|
-
export declare function asksModels(options: DoctorOptions & CliOptions): options is DoctorOptions & CliOptions & {
|
|
53
|
-
dir: string;
|
|
54
|
-
};
|
|
39
|
+
export declare function checkProjectModels(project: string, access?: ModelAccess, given?: DoctorModels): Promise<Check[]>;
|
|
55
40
|
/**
|
|
56
41
|
* Whether this machine - and, with `dir`, that project - is ready for turri, as checks. It prints nothing and asks
|
|
57
42
|
* nothing, so a host can show them in its own way; `turri doctor` prints the same.
|
|
58
43
|
*/
|
|
59
44
|
export declare function doctor(options?: DoctorOptions): Promise<Check[]>;
|
|
60
|
-
export declare function allChecks(options: DoctorOptions & CliOptions): Promise<Check[]>;
|
|
61
45
|
/** The environment pi-claude-code refuses to run with: each points Claude Code at an API key or another backend, not the subscription. */
|
|
62
46
|
export declare const CLAUDE_CODE_CONFLICTS: string[];
|
|
63
47
|
/** What the Claude subscription check looks at - this machine's, or a test's. */
|
|
@@ -78,7 +62,7 @@ export interface ClaudeCodeProbe {
|
|
|
78
62
|
* pi-claude-code needs, in the order it needs it - its extension installed, Claude Code on the PATH, signed in to a Pro or
|
|
79
63
|
* Max subscription, and nothing in the environment it refuses. Nothing when no model is a claude-code one.
|
|
80
64
|
*/
|
|
81
|
-
export declare function checkClaudeSubscription(project: string, env?: NodeJS.ProcessEnv, probe?: ClaudeCodeProbe): Promise<Check[]>;
|
|
65
|
+
export declare function checkClaudeSubscription(project: string, env?: NodeJS.ProcessEnv, probe?: ClaudeCodeProbe, also?: string[]): Promise<Check[]>;
|
|
82
66
|
/**
|
|
83
67
|
* The base folders the project's config names - its own, and each module's own file's - each there with its files, or not: a codebase
|
|
84
68
|
* that requires nothing starts from one, and its first pulse stops when it is not there. Nothing when none is named.
|
|
@@ -88,12 +72,4 @@ export declare function checkBaseFolders(project: string): Promise<Check[]>;
|
|
|
88
72
|
* The AWS region a project's Bedrock models are called in, when it uses any: turri's, the person's or the profile's - and
|
|
89
73
|
* what is wrong with it, when the models need two, or the person's is not in their geography. Nothing when it uses none.
|
|
90
74
|
*/
|
|
91
|
-
export declare function checkBedrockRegion(project: string, env?: NodeJS.ProcessEnv): Check[];
|
|
92
|
-
/** What the checks add up to: whether turri can run here, and a line saying so - with its marks, uncoloured. */
|
|
93
|
-
export declare function verdictOf(checks: Check[]): {
|
|
94
|
-
ready: boolean;
|
|
95
|
-
limited: boolean;
|
|
96
|
-
text: string;
|
|
97
|
-
};
|
|
98
|
-
/** The checks as plain text, a line each and what to do under it, and the verdict - for a reader that is not a terminal. */
|
|
99
|
-
export declare function describeChecks(checks: Check[]): string;
|
|
75
|
+
export declare function checkBedrockRegion(project: string, env?: NodeJS.ProcessEnv, also?: string[]): Check[];
|
package/dist/setup.js
CHANGED
|
@@ -4,14 +4,13 @@ import { existsSync, statSync } from "node:fs";
|
|
|
4
4
|
import { join, relative, resolve } from "node:path";
|
|
5
5
|
import { ModelRegistry } from "@earendil-works/pi-coding-agent";
|
|
6
6
|
import { EXTENSION_PROVIDERS, installedProviders, runtimeWithProviders } from "./installed-providers.js";
|
|
7
|
-
import { globalExtensionFile, turriIdentity, turriRoot } from "./environment.js";
|
|
8
7
|
import { checkNode } from "./node-check.js";
|
|
9
|
-
import { fetchLatest, newerThan, turrisOnPath, versionFindings } from "./turri-versions.js";
|
|
10
8
|
import { sandboxAvailable, sandboxWithAsync } from "./regenerate/os-sandbox.js";
|
|
11
9
|
import { findTestScripts, onThisMachine } from "./regenerate/test-scripts.js";
|
|
12
10
|
import { CONFIG_FILE, hasProjectConfig, readProjectConfig, moduleConfigFile, configModuleOf, moduleConfigsOf, configProblems } from "./config.js";
|
|
13
11
|
import { checkModels, modelsInUse, piModelAccess } from "./model-check.js";
|
|
14
|
-
import {
|
|
12
|
+
import { asksModels, modelChoices, specsOf } from "./doctor-checks.js";
|
|
13
|
+
import { applyBedrockRegion, bedrockRegionFor, describeBedrockRegion, regionInGeography } from "./bedrock-region.js";
|
|
15
14
|
import { baseFilesAsync } from "./regenerate/base-folder.js";
|
|
16
15
|
import { readScript, scriptAgainstMachine, stackOnMachineAsync } from "./stack.js";
|
|
17
16
|
/**
|
|
@@ -26,7 +25,7 @@ import { readScript, scriptAgainstMachine, stackOnMachineAsync } from "./stack.j
|
|
|
26
25
|
* `doctor()` is the checks alone, for the CLI and for a host (src/host.ts): it prints nothing and asks nothing.
|
|
27
26
|
*/
|
|
28
27
|
export { checkNode };
|
|
29
|
-
export
|
|
28
|
+
export { asksModels, describeChecks, MARK, verdictOf } from "./doctor-checks.js";
|
|
30
29
|
/** bash: every agent command and every testing script runs with it, on every platform. */
|
|
31
30
|
export function checkShell(found = spawnSync("bash", ["--version"], { stdio: "ignore", windowsHide: true }).status === 0, platform = process.platform) {
|
|
32
31
|
if (found)
|
|
@@ -70,17 +69,22 @@ export function checkSandbox(wall = sandboxAvailable(), platform = process.platf
|
|
|
70
69
|
*/
|
|
71
70
|
export async function checkProject(project, machine = {}) {
|
|
72
71
|
const checks = [];
|
|
73
|
-
for (const { module, needs, missing } of await stackOnMachineAsync(project, machine.has, machine.jdk)) {
|
|
72
|
+
for (const { module, needs, missing, older } of await stackOnMachineAsync(project, machine.has, machine.jdk, machine.version)) {
|
|
74
73
|
if (needs.length === 0)
|
|
75
74
|
continue;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
75
|
+
if (missing.length === 0 && older.length === 0) {
|
|
76
|
+
checks.push({ level: "ok", name: `${module}`, detail: `has ${needs.map((need) => need.toolchain).join(", ")}` });
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
const named = (need) => `${need.toolchain}${need.version !== undefined ? ` ${need.version}` : ""}`;
|
|
80
|
+
const lacks = missing.length > 0 ? `${missing.map((need) => `${named(need)} (${need.words.join(", ")})`).join(", ")}, which this machine lacks` : "";
|
|
81
|
+
const old = older.map((need) => `${need.toolchain} ${need.version} (${need.words.join(", ")}), and this machine's is ${need.found}`).join("; ");
|
|
82
|
+
checks.push({
|
|
83
|
+
level: "missing",
|
|
84
|
+
name: `${module}`,
|
|
85
|
+
detail: `its implementation reqs need ${[lacks, old].filter((part) => part !== "").join("; ")}`,
|
|
86
|
+
fix: `install ${[...missing, ...older].map((need) => (need.version !== undefined ? `${need.toolchain} ${need.version} or newer` : need.toolchain)).join(" and ")} on this machine - the agents use its toolchains, and install none`,
|
|
87
|
+
});
|
|
84
88
|
}
|
|
85
89
|
const scripts = findTestScripts(project);
|
|
86
90
|
for (const script of [scripts.unit, scripts.prepare, scripts.conformance]) {
|
|
@@ -121,76 +125,19 @@ async function checkProvider(project = process.cwd()) {
|
|
|
121
125
|
fix: "run `pi` and use /login, or set an API key (ANTHROPIC_API_KEY, OPENAI_API_KEY, GEMINI_API_KEY, ...)",
|
|
122
126
|
};
|
|
123
127
|
}
|
|
124
|
-
/**
|
|
125
|
-
* turri itself: whether it is the newest npm has - asked now - and every turri on the PATH, which runs, and what hides a
|
|
126
|
-
* newer one behind an older (turri-versions.ts). What to do, said under each.
|
|
127
|
-
*/
|
|
128
|
-
async function checkTurri() {
|
|
129
|
-
const own = turriIdentity();
|
|
130
|
-
const onPath = turrisOnPath();
|
|
131
|
-
const latest = own.git_commit === null ? await fetchLatest() : undefined;
|
|
132
|
-
const findings = versionFindings({ ...(latest !== undefined ? { latest } : {}), onPath });
|
|
133
|
-
const version = own.version ?? "?";
|
|
134
|
-
const outdated = findings.find((finding) => finding.kind === "outdated");
|
|
135
|
-
const versionCheck = own.git_commit !== null
|
|
136
|
-
? { level: "info", name: "turri version", detail: `${version}, from a clone - not compared with npm` }
|
|
137
|
-
: outdated !== undefined
|
|
138
|
-
? { level: "limited", name: "turri version", detail: outdated.text, fix: outdated.fixes.join("; ") }
|
|
139
|
-
: latest === undefined
|
|
140
|
-
? { level: "info", name: "turri version", detail: `${version} - npm did not answer, so it is not compared` }
|
|
141
|
-
: own.version !== null && newerThan(latest, own.version)
|
|
142
|
-
? // Older than npm's, with a newer turri installed already: the PATH check says which, and what hides it.
|
|
143
|
-
{ level: "limited", name: "turri version", detail: `${version} - npm has ${latest}, and a newer turri is installed already: see turri on PATH` }
|
|
144
|
-
: { level: "ok", name: "turri version", detail: `${version} - the newest on npm` };
|
|
145
|
-
if (onPath.length === 0) {
|
|
146
|
-
return [
|
|
147
|
-
versionCheck,
|
|
148
|
-
{
|
|
149
|
-
level: "limited",
|
|
150
|
-
name: "turri on PATH",
|
|
151
|
-
detail: "not found",
|
|
152
|
-
// A clone has its sources; the package from npm has only what was compiled from them.
|
|
153
|
-
fix: existsSync(join(turriRoot(), "src")) ? `cd ${turriRoot()} && npm link` : "npm install -g @turri-dev/cli",
|
|
154
|
-
},
|
|
155
|
-
];
|
|
156
|
-
}
|
|
157
|
-
const copies = onPath.map((turri) => `${turri.path} turri ${turri.version ?? "?"} (${[turri.runs ? "runs" : "hidden", ...(turri.self ? ["this one"] : []), ...(turri.clone ? ["a clone"] : [])].join(", ")})`);
|
|
158
|
-
const hidden = findings.filter((finding) => finding.kind !== "outdated");
|
|
159
|
-
const pathCheck = hidden.length > 0
|
|
160
|
-
? // Every turri, then what to do, in order: a step a line.
|
|
161
|
-
{ level: "missing", name: "turri on PATH", detail: hidden[0].text, more: [...copies, ...hidden.flatMap((finding) => finding.fixes).map((fix) => `→ ${fix}`)] }
|
|
162
|
-
: { level: "ok", name: "turri on PATH", detail: onPath.length === 1 ? onPath[0].path : `${onPath.length} turris - the first, which runs, is the newest`, ...(onPath.length > 1 ? { more: copies } : {}) };
|
|
163
|
-
return [versionCheck, pathCheck];
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* turri loaded into every `pi` - a file an older `turri setup` wrote into pi's extensions. turri and pi are kept apart
|
|
167
|
-
* now: `turri` starts pi with turri, and a plain `pi` stays pi. Said only when the file is there, for doctor to remove.
|
|
168
|
-
*/
|
|
169
|
-
function checkGlobal() {
|
|
170
|
-
const file = globalExtensionFile();
|
|
171
|
-
if (file === undefined)
|
|
172
|
-
return [];
|
|
173
|
-
return [
|
|
174
|
-
{
|
|
175
|
-
level: "limited",
|
|
176
|
-
name: "turri in every pi",
|
|
177
|
-
detail: `${file} loads turri into every plain pi too`,
|
|
178
|
-
fix: "turri doctor offers to remove it, below - turri keeps starting with turri",
|
|
179
|
-
},
|
|
180
|
-
];
|
|
181
|
-
}
|
|
182
128
|
/**
|
|
183
129
|
* In a project: each model its config.turri.yaml names - or the module config pinned, its file's over it - tried with one short
|
|
184
130
|
* request. A model that answers is ready; one that does not says what the provider said, and what to do about it.
|
|
185
131
|
*/
|
|
186
|
-
export async function checkProjectModels(project, access) {
|
|
187
|
-
const used = modelsInUse(readProjectConfig(project, configModuleOf(project)));
|
|
132
|
+
export async function checkProjectModels(project, access, given = {}) {
|
|
133
|
+
const used = modelsInUse({ ...readProjectConfig(project, configModuleOf(project)), ...modelChoices(given) });
|
|
188
134
|
if (used.length === 0) {
|
|
189
135
|
return [{ level: "missing", name: "Models", detail: "config.turri.yaml names none", fix: "turri init-config writes the two models - or name them here: --harness-model, --coding-model" }];
|
|
190
136
|
}
|
|
191
137
|
let verdicts;
|
|
192
138
|
try {
|
|
193
|
-
|
|
139
|
+
// The AWS region the Bedrock models need, set as a session sets it as it opens: doctor asks them with none open.
|
|
140
|
+
const region = describeBedrockRegion(applyBedrockRegion(project, { also: specsOf(given) }));
|
|
194
141
|
verdicts = await checkModels(used, access ?? (await piModelAccess()), region !== undefined ? { bedrockRegion: region } : {});
|
|
195
142
|
}
|
|
196
143
|
catch (error) {
|
|
@@ -203,10 +150,6 @@ export async function checkProjectModels(project, access) {
|
|
|
203
150
|
: { level: "missing", name, detail: verdict.spec, more: [verdict.problem], fix: verdict.fix };
|
|
204
151
|
});
|
|
205
152
|
}
|
|
206
|
-
/** Whether doctor asks the models: asked to, and a config that names them - or models named on the command line. */
|
|
207
|
-
export function asksModels(options) {
|
|
208
|
-
return options.models === true && options.dir !== undefined && (hasProjectConfig(options.dir) || options.modelsGiven === true);
|
|
209
|
-
}
|
|
210
153
|
/** Whether `command` runs with `env` - its PATH looked in, as the agents' shells and the testing scripts would. Never holds a host's thread up. */
|
|
211
154
|
async function runs(command, env) {
|
|
212
155
|
return (await spawnAsync(command, ["--version"], { env })).status === 0;
|
|
@@ -216,15 +159,10 @@ async function runs(command, env) {
|
|
|
216
159
|
* nothing, so a host can show them in its own way; `turri doctor` prints the same.
|
|
217
160
|
*/
|
|
218
161
|
export async function doctor(options = {}) {
|
|
219
|
-
return allChecks({ ...options, cli: false, modelsGiven: false });
|
|
220
|
-
}
|
|
221
|
-
export async function allChecks(options) {
|
|
222
162
|
const env = options.env ?? process.env;
|
|
223
163
|
// Each check that runs a command runs it without holding the thread up - a host asks on its own - side by side.
|
|
224
164
|
const [bash, git, wall, provider] = await Promise.all([runs("bash", env), runs("git", env), sandboxWithAsync(env), checkProvider(options.dir)]);
|
|
225
165
|
const checks = [checkNode(), checkShell(bash), checkGit(git), checkSandbox(wall), provider];
|
|
226
|
-
if (options.cli === true)
|
|
227
|
-
checks.push(...(await checkTurri()), ...checkGlobal());
|
|
228
166
|
// In a project: what it needs of this machine, and whether its models answer.
|
|
229
167
|
const project = options.dir;
|
|
230
168
|
if (project === undefined)
|
|
@@ -239,10 +177,11 @@ export async function allChecks(options) {
|
|
|
239
177
|
})));
|
|
240
178
|
if (hasProjectConfig(project) || existsSync(join(project, "plain_modules")))
|
|
241
179
|
checks.push(...(await checkProject(project, { has: (command) => onThisMachine(command, env) !== undefined })));
|
|
180
|
+
const given = options.overrides ?? {};
|
|
242
181
|
if (hasProjectConfig(project))
|
|
243
|
-
checks.push(...checkBedrockRegion(project, env), ...(await checkClaudeSubscription(project, env)), ...(await checkBaseFolders(project)));
|
|
182
|
+
checks.push(...checkBedrockRegion(project, env, specsOf(given)), ...(await checkClaudeSubscription(project, env, undefined, specsOf(given))), ...(await checkBaseFolders(project)));
|
|
244
183
|
if (asksModels(options))
|
|
245
|
-
checks.push(...(await checkProjectModels(project)));
|
|
184
|
+
checks.push(...(await checkProjectModels(project, undefined, given)));
|
|
246
185
|
return checks;
|
|
247
186
|
}
|
|
248
187
|
/** The environment pi-claude-code refuses to run with: each points Claude Code at an API key or another backend, not the subscription. */
|
|
@@ -268,9 +207,9 @@ const claudeCodeProbe = (project) => ({
|
|
|
268
207
|
* pi-claude-code needs, in the order it needs it - its extension installed, Claude Code on the PATH, signed in to a Pro or
|
|
269
208
|
* Max subscription, and nothing in the environment it refuses. Nothing when no model is a claude-code one.
|
|
270
209
|
*/
|
|
271
|
-
export async function checkClaudeSubscription(project, env = process.env, probe = claudeCodeProbe(project)) {
|
|
210
|
+
export async function checkClaudeSubscription(project, env = process.env, probe = claudeCodeProbe(project), also = []) {
|
|
272
211
|
const configs = [readProjectConfig(project), ...moduleConfigsOf(project).map((module) => readProjectConfig(project, module))];
|
|
273
|
-
const named = [...new Set(configs.flatMap((config) => modelsInUse(config)).
|
|
212
|
+
const named = [...new Set([...configs.flatMap((config) => modelsInUse(config)).map((used) => used.spec), ...also].filter((spec) => spec.startsWith("claude-code/")))];
|
|
274
213
|
if (named.length === 0)
|
|
275
214
|
return [];
|
|
276
215
|
const name = "Claude subscription";
|
|
@@ -321,10 +260,10 @@ export async function checkBaseFolders(project) {
|
|
|
321
260
|
* The AWS region a project's Bedrock models are called in, when it uses any: turri's, the person's or the profile's - and
|
|
322
261
|
* what is wrong with it, when the models need two, or the person's is not in their geography. Nothing when it uses none.
|
|
323
262
|
*/
|
|
324
|
-
export function checkBedrockRegion(project, env = process.env) {
|
|
263
|
+
export function checkBedrockRegion(project, env = process.env, also = []) {
|
|
325
264
|
let decided;
|
|
326
265
|
try {
|
|
327
|
-
decided = bedrockRegionFor(project, { env });
|
|
266
|
+
decided = bedrockRegionFor(project, { env, also });
|
|
328
267
|
}
|
|
329
268
|
catch {
|
|
330
269
|
return [];
|
|
@@ -339,19 +278,3 @@ export function checkBedrockRegion(project, env = process.env) {
|
|
|
339
278
|
return [{ level: "missing", name: "AWS region", detail: `${decided.region}, which does not serve ${decided.needs.geography}'s models`, more: [line] }];
|
|
340
279
|
return [{ level: "ok", name: "AWS region", detail: line }];
|
|
341
280
|
}
|
|
342
|
-
/** What the checks add up to: whether turri can run here, and a line saying so - with its marks, uncoloured. */
|
|
343
|
-
export function verdictOf(checks) {
|
|
344
|
-
const missing = checks.filter((check) => check.level === "missing").length;
|
|
345
|
-
if (missing > 0)
|
|
346
|
-
return { ready: false, limited: false, text: `Not ready: ${missing} thing${missing === 1 ? "" : "s"} to fix (✗ above).` };
|
|
347
|
-
return checks.some((check) => check.level === "limited") ? { ready: true, limited: true, text: "Ready, with limits (! above)." } : { ready: true, limited: false, text: "Ready." };
|
|
348
|
-
}
|
|
349
|
-
/** The checks as plain text, a line each and what to do under it, and the verdict - for a reader that is not a terminal. */
|
|
350
|
-
export function describeChecks(checks) {
|
|
351
|
-
const lines = checks.flatMap((check) => [
|
|
352
|
-
`${MARK[check.level]} ${check.name}: ${check.detail}`,
|
|
353
|
-
...(check.more ?? []).map((line) => ` ${line}`),
|
|
354
|
-
...(check.fix && check.level !== "ok" ? [` → ${check.fix}`] : []),
|
|
355
|
-
]);
|
|
356
|
-
return `${lines.join("\n")}\n\n${verdictOf(checks).text}`;
|
|
357
|
-
}
|
package/dist/stack.d.ts
CHANGED
|
@@ -6,12 +6,25 @@
|
|
|
6
6
|
* built with Vite", "Java 21 with Spring Boot". This reads them, and says which toolchain each needs and by which word -
|
|
7
7
|
* a hint for the person, not a verdict: a req can name a technology it does not use.
|
|
8
8
|
*/
|
|
9
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* A toolchain the reqs name: its name, the commands any one of which shows it is there, the words that named it - and
|
|
11
|
+
* the version they pin it to, the highest they name, when they name one (`Go 1.25`, `Java 21`).
|
|
12
|
+
*/
|
|
10
13
|
export interface StackNeed {
|
|
11
14
|
toolchain: string;
|
|
12
15
|
commands: string[];
|
|
13
16
|
words: string[];
|
|
17
|
+
version?: string;
|
|
14
18
|
}
|
|
19
|
+
/** A toolchain this machine has, older than the version its reqs pin: what it has. */
|
|
20
|
+
export type OlderNeed = StackNeed & {
|
|
21
|
+
version: string;
|
|
22
|
+
found: string;
|
|
23
|
+
};
|
|
24
|
+
/** Whether version `a` is older than `b`, segment by segment, as far as `b` says: 1.24.3 is older than 1.25, 1.25.1 is not. */
|
|
25
|
+
export declare function olderThan(a: string, b: string): boolean;
|
|
26
|
+
/** What a toolchain's command says its version is - from its whole output - or nothing when it says none. */
|
|
27
|
+
export declare function versionIn(toolchain: string, output: string): string | undefined;
|
|
15
28
|
/** The toolchains a text of implementation reqs names. */
|
|
16
29
|
export declare function stackOf(text: string): StackNeed[];
|
|
17
30
|
/** The implementation reqs of every module in a project's folder, as the parser has them - imports in. */
|
|
@@ -27,21 +40,21 @@ export declare function projectImplementationReqsAsync(project: string): Promise
|
|
|
27
40
|
module: string;
|
|
28
41
|
reqs: string[];
|
|
29
42
|
}>>;
|
|
30
|
-
/**
|
|
31
|
-
|
|
32
|
-
* macOS a JDK behind `java` (`toolchainCheck`), asked at most once.
|
|
33
|
-
*/
|
|
34
|
-
export declare function stackOnMachine(project: string, has?: (command: string) => boolean, jdk?: () => boolean): Array<{
|
|
43
|
+
/** What a project's modules need of this machine: each module's needs, those the machine lacks, and those it has older. */
|
|
44
|
+
export type MachineNeeds = Array<{
|
|
35
45
|
module: string;
|
|
36
46
|
needs: StackNeed[];
|
|
37
47
|
missing: StackNeed[];
|
|
48
|
+
older: OlderNeed[];
|
|
38
49
|
}>;
|
|
39
|
-
/**
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
50
|
+
/**
|
|
51
|
+
* What a project's modules need of this machine, which of it the machine lacks - `has` finding a command, and on macOS
|
|
52
|
+
* a JDK behind `java` (`toolchainCheck`), asked at most once - and which it has older than their reqs pin: `version`
|
|
53
|
+
* says the machine's, asked at most once a toolchain.
|
|
54
|
+
*/
|
|
55
|
+
export declare function stackOnMachine(project: string, has?: (command: string) => boolean, jdk?: () => boolean, version?: (toolchain: string) => string | undefined): MachineNeeds;
|
|
56
|
+
/** `stackOnMachine`, never holding the host's thread up: the modules parsed one a turn, a JDK and versions asked without blocking. */
|
|
57
|
+
export declare function stackOnMachineAsync(project: string, has?: (command: string) => boolean, jdk?: () => boolean | Promise<boolean>, version?: (toolchain: string) => string | undefined | Promise<string | undefined>): Promise<MachineNeeds>;
|
|
45
58
|
/**
|
|
46
59
|
* The standard library's languages, and what builds and tests their stacks here - every command needed. Python's stacks
|
|
47
60
|
* run through uv, which fetches Python itself; TypeScript's through npm; Java's through the Maven or Gradle wrapper,
|