@turri-dev/cli 0.2.4-next.bc1fc47 → 0.2.4-next.d779410
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -6
- package/dist/bedrock-region.js +3 -3
- package/dist/chat-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 -10
- package/dist/chats.js +125 -41
- package/dist/cli.js +7 -24
- package/dist/config-edit.d.ts +20 -8
- package/dist/config-edit.js +32 -24
- package/dist/config.d.ts +90 -60
- package/dist/config.js +224 -117
- package/dist/conform-cli.js +1 -1
- package/dist/conformance-switch.d.ts +7 -6
- package/dist/conformance-switch.js +16 -16
- package/dist/extension.d.ts +10 -1
- package/dist/extension.js +263 -306
- package/dist/genome.js +1 -1
- package/dist/host-session.d.ts +8 -7
- package/dist/host-session.js +4 -4
- package/dist/host.d.ts +3 -1
- package/dist/host.js +3 -3
- package/dist/identity.js +2 -2
- package/dist/init-config.d.ts +1 -1
- package/dist/init-config.js +8 -8
- package/dist/launch-agent.d.ts +51 -0
- package/dist/launch-agent.js +267 -0
- package/dist/{release-cli.js → launch-cli.js} +41 -24
- package/dist/launch-session.d.ts +68 -0
- package/dist/launch-session.js +217 -0
- package/dist/launch-tools.d.ts +28 -0
- package/dist/launch-tools.js +69 -0
- package/dist/launch-track.d.ts +125 -0
- package/dist/launch-track.js +320 -0
- package/dist/loop-cli.js +4 -4
- package/dist/loop-tools.d.ts +17 -16
- package/dist/loop-tools.js +69 -69
- package/dist/notice.d.ts +7 -6
- package/dist/parse-cli.js +2 -2
- package/dist/pi-launch.js +3 -0
- package/dist/pi-settings.d.ts +4 -0
- package/dist/pi-settings.js +39 -0
- package/dist/pi.js +3 -3
- package/dist/plain/check.d.ts +1 -1
- package/dist/plain/check.js +3 -1
- package/dist/plain-files.d.ts +2 -2
- package/dist/plain-files.js +7 -7
- package/dist/regenerate/agent-env.d.ts +1 -1
- package/dist/regenerate/agent-env.js +3 -3
- package/dist/regenerate/agent-shell.js +2 -2
- package/dist/regenerate/base-folder.d.ts +2 -2
- package/dist/regenerate/base-folder.js +1 -1
- package/dist/regenerate/command-check.d.ts +7 -1
- package/dist/regenerate/command-check.js +43 -1
- package/dist/regenerate/delivery.d.ts +1 -1
- package/dist/regenerate/delivery.js +3 -3
- package/dist/regenerate/jobs.d.ts +2 -2
- package/dist/regenerate/jobs.js +10 -10
- package/dist/regenerate/launch.d.ts +154 -0
- package/dist/regenerate/{release.js → launch.js} +195 -51
- package/dist/regenerate/ledger.d.ts +33 -2
- package/dist/regenerate/lineage.d.ts +2 -0
- package/dist/regenerate/lineage.js +8 -0
- package/dist/regenerate/loop.d.ts +9 -8
- package/dist/regenerate/loop.js +43 -40
- 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/scripts-being-written.d.ts +4 -4
- package/dist/regenerate/scripts-being-written.js +3 -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 +6 -6
- package/dist/regenerate/testing-steps.js +8 -8
- package/dist/self-invocation.js +7 -7
- package/dist/sentinel-check.d.ts +3 -3
- package/dist/sentinel-check.js +3 -3
- package/dist/sentinel.d.ts +18 -12
- package/dist/sentinel.js +68 -42
- 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/docs/README.md +4 -4
- package/docs/chats.md +5 -6
- package/docs/claude-subscription.md +2 -2
- package/docs/config.md +58 -46
- package/docs/development.md +2 -2
- package/docs/headless.md +2 -3
- package/docs/hosting.md +20 -19
- package/docs/launch.md +67 -0
- package/docs/parser.md +2 -2
- package/docs/regenerating.md +12 -12
- package/docs/sandbox.md +3 -3
- package/docs/sentinel.md +26 -14
- package/docs/skills-and-gates.md +4 -5
- package/docs/using.md +15 -24
- package/genome/rules/project-model.md +2 -1
- package/genome/rules/turri-regeneration.md +3 -2
- 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/regenerate/engine.d.ts +0 -52
- package/dist/regenerate/release.d.ts +0 -121
- package/dist/release-agent.d.ts +0 -43
- package/dist/release-agent.js +0 -130
- package/dist/release-tools.d.ts +0 -44
- package/dist/release-tools.js +0 -170
- package/dist/stacks.d.ts +0 -13
- package/dist/stacks.js +0 -96
- package/docs/deploy.md +0 -48
- /package/dist/{release-cli.d.ts → launch-cli.d.ts} +0 -0
package/dist/notice.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ export interface NoticeInput {
|
|
|
35
35
|
check?: string;
|
|
36
36
|
/**
|
|
37
37
|
* The person may leave it as the build has it, for good (`{ ignore: true }`): a gap in the ***plain the build settled
|
|
38
|
-
* with an assumption - never something broken, a pulse that went wrong, a
|
|
38
|
+
* with an assumption - never something broken, a pulse that went wrong, a launch that did not come up, nor the
|
|
39
39
|
* question whether to start the sentinel.
|
|
40
40
|
*/
|
|
41
41
|
ignorable?: boolean;
|
|
@@ -85,8 +85,9 @@ export declare function describeNotice(notice: NoticeInput): string;
|
|
|
85
85
|
export declare function wentWrong(job: Job): boolean;
|
|
86
86
|
/**
|
|
87
87
|
* The sentinel done with a pulse - or a check a host asked for: whether what it checked holds, and what it checked and
|
|
88
|
-
* found, in a line or two. `unchecked`: a check that never
|
|
89
|
-
* be opened
|
|
88
|
+
* found, in a line or two. `unchecked`: a pulse or a check that was never checked - the person did not start the
|
|
89
|
+
* sentinel, it could not be opened, nothing of the module is launched to test a check in, or what runs cannot hold a
|
|
90
|
+
* pulse's commit - turri's own word, never the sentinel's.
|
|
90
91
|
*/
|
|
91
92
|
export interface Conclusion {
|
|
92
93
|
/** The pulse: its job id. Undefined for a check. */
|
|
@@ -99,12 +100,12 @@ export interface Conclusion {
|
|
|
99
100
|
pulse?: number;
|
|
100
101
|
}
|
|
101
102
|
/**
|
|
102
|
-
* Functional specs of a module a host asked the sentinel to check, in the module
|
|
103
|
-
*
|
|
103
|
+
* Functional specs of a module a host asked the sentinel to check, in what is launched of the module: its codebase's code,
|
|
104
|
+
* which holds every module its requires chain builds on. Queued with the pulses, in a conversation of its own.
|
|
104
105
|
*/
|
|
105
106
|
export interface SentinelCheck {
|
|
106
107
|
id: string;
|
|
107
|
-
/** The module
|
|
108
|
+
/** The module whose launch is tested, by name. */
|
|
108
109
|
module: string;
|
|
109
110
|
plainFile: string;
|
|
110
111
|
/** The functional specs to test, each `module:func-id` - of the module, or of a module its requires chain builds on. */
|
package/dist/parse-cli.js
CHANGED
|
@@ -5,8 +5,8 @@ const USAGE = `usage: turri parse <file.plain | directory> [options]
|
|
|
5
5
|
Parses ***plain - its syntax and structure, never its code or tests: each module with its test plain files,
|
|
6
6
|
its imports and required modules, every error reported without regenerating anything - and every test plain file
|
|
7
7
|
outside its module's folder. A functional spec with no test plain file is not tested. A module whose
|
|
8
|
-
functional specs have scenarios but which has no test reqs, or no conformance testing script
|
|
9
|
-
|
|
8
|
+
functional specs have scenarios but which has no test reqs, or no conformance testing script,
|
|
9
|
+
is a warning: its conformance tests are not written until it has them. A test plain file or
|
|
10
10
|
test folder is refused: name its module.
|
|
11
11
|
|
|
12
12
|
--template-dir <dir> extra template directory (repeatable)
|
package/dist/pi-launch.js
CHANGED
|
@@ -14,6 +14,7 @@ import "./terminal-images.js";
|
|
|
14
14
|
import { withoutResumeLine } from "./resume-line.js";
|
|
15
15
|
import { lastRun } from "./chat-records.js";
|
|
16
16
|
import { driveTerminal } from "./chat-terminal.js";
|
|
17
|
+
import { takeOverSettings } from "./pi-settings.js";
|
|
17
18
|
import turri, { createTurriCore, processSession } from "./extension.js";
|
|
18
19
|
/**
|
|
19
20
|
* pi, started the way its own CLI starts it, for `turri`.
|
|
@@ -42,6 +43,8 @@ ProcessTerminal.prototype.setTitle = function (title) {
|
|
|
42
43
|
// is answered for this run as `quietStartup` is; the line it prints instead, to resume the session, is left out too:
|
|
43
44
|
// `turri --continue` opens the last run again.
|
|
44
45
|
SettingsManager.prototype.getFullscreenExitOutput = () => "resume-hint";
|
|
46
|
+
// /settings is turri's, pi's own menu the last entry of it (pi-settings.ts).
|
|
47
|
+
takeOverSettings();
|
|
45
48
|
const write = process.stdout.write.bind(process.stdout);
|
|
46
49
|
process.stdout.write = ((chunk, ...rest) => write(typeof chunk === "string" ? withoutResumeLine(chunk) : chunk, ...rest));
|
|
47
50
|
// pi's own keys stand: a new line is shift+enter or ctrl+j. turri's side panel is on ctrl+h (job-panel.ts PANEL_KEY).
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Take pi's /settings over: once a process, every chat's screen. */
|
|
2
|
+
export declare function takeOverSettings(): void;
|
|
3
|
+
/** Open pi's own settings menu on the screen /settings was typed on. False where there is none - a host, print mode. */
|
|
4
|
+
export declare function openPiSettings(): boolean;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { InteractiveMode } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
let piMenu;
|
|
3
|
+
/** Take pi's /settings over: once a process, every chat's screen. */
|
|
4
|
+
export function takeOverSettings() {
|
|
5
|
+
if (piMenu !== undefined)
|
|
6
|
+
return;
|
|
7
|
+
const prototype = InteractiveMode.prototype;
|
|
8
|
+
const own = prototype.showSettingsSelector;
|
|
9
|
+
const conflicts = prototype.getBuiltInCommandConflictDiagnostics;
|
|
10
|
+
const completions = prototype.createBaseAutocompleteProvider;
|
|
11
|
+
const menu = { open: (screen) => own.call(screen) };
|
|
12
|
+
piMenu = menu;
|
|
13
|
+
// A bare /settings: turri's, when the extension has one - pi's menu otherwise, as it was.
|
|
14
|
+
prototype.showSettingsSelector = function () {
|
|
15
|
+
if (this.session.extensionRunner.getCommand("settings") === undefined)
|
|
16
|
+
return own.call(this);
|
|
17
|
+
menu.screen = this;
|
|
18
|
+
void this.session.prompt("/settings");
|
|
19
|
+
};
|
|
20
|
+
prototype.getBuiltInCommandConflictDiagnostics = function (runner) {
|
|
21
|
+
return conflicts.call(this, runner).filter((diagnostic) => !diagnostic.message.includes("'/settings'"));
|
|
22
|
+
};
|
|
23
|
+
// The completions: pi's /settings line gives way to turri's, which pi leaves out as a clash.
|
|
24
|
+
prototype.createBaseAutocompleteProvider = function () {
|
|
25
|
+
const provider = completions.call(this);
|
|
26
|
+
const turri = this.session.extensionRunner.getCommand("settings");
|
|
27
|
+
if (turri === undefined)
|
|
28
|
+
return provider;
|
|
29
|
+
provider.commands = provider.commands.map((command) => command.name === "settings" ? { name: "settings", description: turri.description, getArgumentCompletions: turri.getArgumentCompletions } : command);
|
|
30
|
+
return provider;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/** Open pi's own settings menu on the screen /settings was typed on. False where there is none - a host, print mode. */
|
|
34
|
+
export function openPiSettings() {
|
|
35
|
+
if (piMenu?.screen === undefined)
|
|
36
|
+
return false;
|
|
37
|
+
piMenu.open(piMenu.screen);
|
|
38
|
+
return true;
|
|
39
|
+
}
|
package/dist/pi.js
CHANGED
|
@@ -3,7 +3,7 @@ import { fileURLToPath } from "node:url";
|
|
|
3
3
|
import { createAgentSession, DefaultResourceLoader, getAgentDir, ModelRegistry, SessionManager, } from "@earendil-works/pi-coding-agent";
|
|
4
4
|
import { installedProviders, runtimeWithProviders } from "./installed-providers.js";
|
|
5
5
|
import { loadRules, renderRulesBlock } from "./rules.js";
|
|
6
|
-
import { debugMode, inheritModel,
|
|
6
|
+
import { debugMode, inheritModel, configModuleOf, readProjectConfig, ROLE_THINKING, roleModel, roleTurnLimitMs, splitModelSpec } from "./config.js";
|
|
7
7
|
import { maskToolResults } from "./regenerate/masking.js";
|
|
8
8
|
import { withListArguments } from "./regenerate/list-arguments.js";
|
|
9
9
|
import { checkAgainstScript, ENVIRONMENT_ERROR_TOOL, EnvironmentError, environmentErrorTool, sandboxGapOf } from "./regenerate/environment-error.js";
|
|
@@ -803,11 +803,11 @@ export async function createExecutor(opts) {
|
|
|
803
803
|
}
|
|
804
804
|
return session;
|
|
805
805
|
}
|
|
806
|
-
/** The config an agent working in `cwd` is under: the project's, with the
|
|
806
|
+
/** The config an agent working in `cwd` is under: the project's, with the pulse's module's own file over it. */
|
|
807
807
|
function configForCwd(cwd) {
|
|
808
808
|
try {
|
|
809
809
|
const root = projectRootOf(cwd);
|
|
810
|
-
return readProjectConfig(root,
|
|
810
|
+
return readProjectConfig(root, configModuleOf(root));
|
|
811
811
|
}
|
|
812
812
|
catch {
|
|
813
813
|
return {};
|
package/dist/plain/check.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* the parser can see without generating anything. The parser's errors come one at a time, the first it meets, as the
|
|
7
7
|
* reference gives them. turri's own checks list everything they find at once: every functional spec without a test
|
|
8
8
|
* plain file, and every test plain file that is not where it belongs. A module whose functional specs have scenarios
|
|
9
|
-
* but which has no test reqs, or no conformance testing script
|
|
9
|
+
* but which has no test reqs, or no conformance testing script, passes with a warning.
|
|
10
10
|
*/
|
|
11
11
|
export interface CheckedFunctionalSpec {
|
|
12
12
|
funcId: string;
|
package/dist/plain/check.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
|
|
2
2
|
import { basename, extname, join, relative, resolve, sep } from "node:path";
|
|
3
|
-
import { testDirOf } from "../config.js";
|
|
3
|
+
import { configModuleFor, testDirOf } from "../config.js";
|
|
4
4
|
import { projectDirOf, resolveTemplateDirs } from "../regenerate/paths.js";
|
|
5
5
|
import { isImportModule } from "../regenerate/requires.js";
|
|
6
6
|
import { testingGap } from "../regenerate/testing-steps.js";
|
|
@@ -114,6 +114,8 @@ export function checkPlainFile(file, templateDirs = []) {
|
|
|
114
114
|
testDir,
|
|
115
115
|
requireTestPlainFiles: false,
|
|
116
116
|
});
|
|
117
|
+
// Two config files among the modules it requires: which one builds it cannot be told - an error, as a syntax one is.
|
|
118
|
+
configModuleFor(path);
|
|
117
119
|
// Scenarios with a step of adding tests skipped - the test reqs, or the conformance testing script: a warning, never a failure.
|
|
118
120
|
const gaps = testingGapsOf(moduleName, path, tree, projectDir, templateDirs);
|
|
119
121
|
// A codebase that requires nothing starts from its base folder: one named and not there stops its first pulse.
|
package/dist/plain-files.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type ToolDefinition } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
/**
|
|
3
3
|
* The project's ***plain and what it is built with, and a digest of each: its .plain files, the resources they link,
|
|
4
|
-
* its testing scripts and its config.turri*.yaml. Nothing else is a skill's to change - not the built code, a
|
|
4
|
+
* its testing scripts and its config.turri*.yaml. Nothing else is a skill's to change - not the built code, a launch,
|
|
5
5
|
* what a running app writes. `also`: paths that were among them before, digested while they are there, so one a skill
|
|
6
6
|
* stopped linking or naming is still seen if it changed it.
|
|
7
7
|
*/
|
|
@@ -11,7 +11,7 @@ export declare function changedFiles(before: Map<string, string>, after: Map<str
|
|
|
11
11
|
/**
|
|
12
12
|
* Why a skill's agent may not write a path, or nothing when it may. It writes the project's ***plain: a file of it
|
|
13
13
|
* (`projectFiles`), or a new one - a resource it is about to link, a testing script - anywhere in the project but where
|
|
14
|
-
* what is built,
|
|
14
|
+
* what is built, launched or installed lives. Never an existing file that is not the ***plain's: the code, a launch,
|
|
15
15
|
* what an app it started writes.
|
|
16
16
|
*/
|
|
17
17
|
export declare function plainWriteRefusal(root: string, path: string): string | undefined;
|
package/dist/plain-files.js
CHANGED
|
@@ -2,14 +2,14 @@ import { createHash } from "node:crypto";
|
|
|
2
2
|
import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { basename, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
4
4
|
import { createEditToolDefinition, createWriteToolDefinition } from "@earendil-works/pi-coding-agent";
|
|
5
|
-
import { readProjectConfig,
|
|
5
|
+
import { readProjectConfig, moduleConfigsOf } from "./config.js";
|
|
6
6
|
import { parseMarkdown } from "./plain/markdown.js";
|
|
7
7
|
import { hasScheme, linksIn } from "./plain/parser.js";
|
|
8
8
|
import { insideAny } from "./regenerate/confine.js";
|
|
9
9
|
import { credentialRefusal, isCredentialFile } from "./regenerate/credentials.js";
|
|
10
10
|
import { DIST_DIR, MODULES_DIR } from "./regenerate/paths.js";
|
|
11
11
|
import { PREPARE_NAME, SCRIPTS_DIR, scriptKind } from "./regenerate/test-scripts.js";
|
|
12
|
-
/** A config.turri.yaml, a
|
|
12
|
+
/** A config.turri.yaml, a module's own config.turri.<module>.yaml - what the project's testing scripts are named in. */
|
|
13
13
|
const TURRI_CONFIG_NAME = /^config\.turri(\.[^/]+)?\.yaml$/;
|
|
14
14
|
/** Folders that hold what is built, installed or turri's own - never the project's ***plain. */
|
|
15
15
|
function outsidePlain(path) {
|
|
@@ -18,7 +18,7 @@ function outsidePlain(path) {
|
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
20
|
* The project's ***plain and what it is built with, and a digest of each: its .plain files, the resources they link,
|
|
21
|
-
* its testing scripts and its config.turri*.yaml. Nothing else is a skill's to change - not the built code, a
|
|
21
|
+
* its testing scripts and its config.turri*.yaml. Nothing else is a skill's to change - not the built code, a launch,
|
|
22
22
|
* what a running app writes. `also`: paths that were among them before, digested while they are there, so one a skill
|
|
23
23
|
* stopped linking or naming is still seen if it changed it.
|
|
24
24
|
*/
|
|
@@ -69,8 +69,8 @@ export function projectFiles(root, also = []) {
|
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
// Scripts config.turri*.yaml names, whatever they are called.
|
|
72
|
-
for (const
|
|
73
|
-
const config = readProjectConfig(root,
|
|
72
|
+
for (const module of [undefined, ...moduleConfigsOf(root)]) {
|
|
73
|
+
const config = readProjectConfig(root, module);
|
|
74
74
|
named(config.unittestsScript);
|
|
75
75
|
named(config.conformanceTestsScript);
|
|
76
76
|
named(config.prepareEnvironmentScript);
|
|
@@ -97,7 +97,7 @@ export function changedFiles(before, after) {
|
|
|
97
97
|
/**
|
|
98
98
|
* Why a skill's agent may not write a path, or nothing when it may. It writes the project's ***plain: a file of it
|
|
99
99
|
* (`projectFiles`), or a new one - a resource it is about to link, a testing script - anywhere in the project but where
|
|
100
|
-
* what is built,
|
|
100
|
+
* what is built, launched or installed lives. Never an existing file that is not the ***plain's: the code, a launch,
|
|
101
101
|
* what an app it started writes.
|
|
102
102
|
*/
|
|
103
103
|
export function plainWriteRefusal(root, path) {
|
|
@@ -109,7 +109,7 @@ export function plainWriteRefusal(root, path) {
|
|
|
109
109
|
const inProject = relative(resolve(root), absolute);
|
|
110
110
|
if (outsidePlain(inProject)) {
|
|
111
111
|
return (`${inProject} is not the project's ***plain - ${MODULES_DIR}/, ${DIST_DIR}/ and the hidden folders hold what is ` +
|
|
112
|
-
"built,
|
|
112
|
+
"built, launched and installed, and turri's own. A skill writes .plain files, the resources they link and the testing scripts.");
|
|
113
113
|
}
|
|
114
114
|
if (existsSync(absolute) && !projectFiles(root).has(inProject)) {
|
|
115
115
|
return (`${inProject} is not the project's ***plain: no .plain file links it, and it is not a testing script or a ` +
|
|
@@ -42,7 +42,7 @@ export declare function tidyCaches(scratch: string, keepMb: number): void;
|
|
|
42
42
|
* JVMs' sockets beside it.
|
|
43
43
|
*/
|
|
44
44
|
export declare const DARWIN_TEMP_SUFFIX = "DIRHELPER_USER_DIR_SUFFIX";
|
|
45
|
-
/** What `agent-env:` - the project's, with the
|
|
45
|
+
/** What `agent-env:` - the project's, with the pulse's module's own file's added - passes, and what of it is not there. Reads only. */
|
|
46
46
|
export declare function passedCredentials(module: string, hostEnv: NodeJS.ProcessEnv): {
|
|
47
47
|
values: Record<string, string>;
|
|
48
48
|
missing: MissingCredential[];
|
|
@@ -2,7 +2,7 @@ import { createHash } from "node:crypto";
|
|
|
2
2
|
import { chmodSync, existsSync, lstatSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { homedir } from "node:os";
|
|
4
4
|
import { basename, join, resolve } from "node:path";
|
|
5
|
-
import { DEFAULT_CACHE_KEEP_MB, readProjectConfig,
|
|
5
|
+
import { DEFAULT_CACHE_KEEP_MB, readProjectConfig, configModuleOf } from "../config.js";
|
|
6
6
|
import { registerSecrets } from "./masking.js";
|
|
7
7
|
import { projectRootOf, modulesScratchDir } from "./paths.js";
|
|
8
8
|
/**
|
|
@@ -258,10 +258,10 @@ export const DARWIN_TEMP_SUFFIX = "DIRHELPER_USER_DIR_SUFFIX";
|
|
|
258
258
|
function darwinTempSuffix(module, name) {
|
|
259
259
|
return `turri-${name.replace(/[^\w.-]/g, "_")}-${createHash("sha256").update(resolve(module)).digest("hex").slice(0, 8)}`;
|
|
260
260
|
}
|
|
261
|
-
/** What `agent-env:` - the project's, with the
|
|
261
|
+
/** What `agent-env:` - the project's, with the pulse's module's own file's added - passes, and what of it is not there. Reads only. */
|
|
262
262
|
export function passedCredentials(module, hostEnv) {
|
|
263
263
|
const root = projectRootOf(module);
|
|
264
|
-
const setting = readProjectConfig(root,
|
|
264
|
+
const setting = readProjectConfig(root, configModuleOf(root)).agentEnv;
|
|
265
265
|
const values = {};
|
|
266
266
|
const missing = [];
|
|
267
267
|
if (setting === undefined)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { dirname, join, resolve, sep } from "node:path";
|
|
2
|
-
import { readProjectConfig,
|
|
2
|
+
import { readProjectConfig, configModuleOf } from "../config.js";
|
|
3
3
|
import { reportNote } from "./activity.js";
|
|
4
4
|
import { record } from "./ledger.js";
|
|
5
5
|
import { agentEnvironment, DARWIN_TEMP_SUFFIX, packageCacheDir, TOOLCHAIN_VARIABLES } from "./agent-env.js";
|
|
@@ -32,7 +32,7 @@ export function agentShell(role, options = {}) {
|
|
|
32
32
|
const project = projectRootOf(workdir);
|
|
33
33
|
const { env } = agentEnvironment(moduleDir);
|
|
34
34
|
const root = projectRootOf(moduleDir);
|
|
35
|
-
const toolchains = readProjectConfig(root,
|
|
35
|
+
const toolchains = readProjectConfig(root, configModuleOf(root)).toolchains ?? [];
|
|
36
36
|
const machine = machineFor(env, TOOLCHAIN_VARIABLES, toolchains);
|
|
37
37
|
const writable = writableFor(env, moduleDir);
|
|
38
38
|
const commandFence = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BASE_RECORD_FILE } from "./paths.ts";
|
|
2
2
|
export { BASE_RECORD_FILE };
|
|
3
3
|
/**
|
|
4
|
-
* A base folder (`base-folder:` in config.turri.yaml, a
|
|
4
|
+
* A base folder (`base-folder:` in config.turri.yaml, a module's own in its file): what a codebase that requires no other
|
|
5
5
|
* module starts from instead of nothing - an existing codebase to build on, files to use (images, animations, fonts), or
|
|
6
6
|
* both. It is copied in once, before the codebase's first pulse, and never written to; what was copied is recorded beside
|
|
7
7
|
* the code record, and goes up the chain with the code, so every coding agent of the chain is told where its codebase
|
|
@@ -21,7 +21,7 @@ export declare class MissingBaseFolderError extends Error {
|
|
|
21
21
|
readonly moduleName: string;
|
|
22
22
|
constructor(moduleName: string, named: string, path: string);
|
|
23
23
|
}
|
|
24
|
-
/** The base folder a module's codebase starts from - its
|
|
24
|
+
/** The base folder a module's codebase starts from - its own file's over the project's - as named and as a path; none when the config names none. */
|
|
25
25
|
export declare function baseFolderOf(plainFile: string): {
|
|
26
26
|
named: string;
|
|
27
27
|
path: string;
|
|
@@ -21,7 +21,7 @@ export class MissingBaseFolderError extends Error {
|
|
|
21
21
|
this.moduleName = moduleName;
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
-
/** The base folder a module's codebase starts from - its
|
|
24
|
+
/** The base folder a module's codebase starts from - its own file's over the project's - as named and as a path; none when the config names none. */
|
|
25
25
|
export function baseFolderOf(plainFile) {
|
|
26
26
|
const named = configForSpec(plainFile).baseFolder;
|
|
27
27
|
if (named === undefined)
|
|
@@ -40,11 +40,17 @@ export declare function machineReadable(platform?: NodeJS.Platform): string[];
|
|
|
40
40
|
* Why a command line changes the machine - installs software outside the project, or changes a setting of the
|
|
41
41
|
* machine's or the person's environment - or nothing when it does not. The project's own dependencies, installed into
|
|
42
42
|
* the project (npm install, a venv, mvn, cargo), change nothing of the machine's. turri changes the machine nowhere: not
|
|
43
|
-
* an agent, not the chat, not a
|
|
43
|
+
* an agent, not the chat, not a launch - what the machine lacks is the person's to install, in their own words.
|
|
44
44
|
*/
|
|
45
45
|
export declare function machineChange(command: string): string | undefined;
|
|
46
46
|
/** The .plain file a command line writes - a ***plain module or a test plain file - or nothing when it writes none. */
|
|
47
47
|
export declare function writesPlain(command: string): string | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* The path in plain_modules a command line runs in or from - `cd` there and run something, a program or its arguments
|
|
50
|
+
* there, an environment variable pointing there - or nothing when it only reads there, or does not go there. The code in
|
|
51
|
+
* plain_modules is what a pulse may be writing, and nobody launched it.
|
|
52
|
+
*/
|
|
53
|
+
export declare function runsBuiltCode(command: string): string | undefined;
|
|
48
54
|
/** What turri says when a command would change the machine: what it does instead. */
|
|
49
55
|
export declare function machineChangeReason(why: string): string;
|
|
50
56
|
/** Check one command line against a role's fence: `{ ok: true }`, or which rule it breaks and what to do instead. */
|
|
@@ -166,7 +166,7 @@ function systemSettingIn(segment) {
|
|
|
166
166
|
* Why a command line changes the machine - installs software outside the project, or changes a setting of the
|
|
167
167
|
* machine's or the person's environment - or nothing when it does not. The project's own dependencies, installed into
|
|
168
168
|
* the project (npm install, a venv, mvn, cargo), change nothing of the machine's. turri changes the machine nowhere: not
|
|
169
|
-
* an agent, not the chat, not a
|
|
169
|
+
* an agent, not the chat, not a launch - what the machine lacks is the person's to install, in their own words.
|
|
170
170
|
*/
|
|
171
171
|
export function machineChange(command) {
|
|
172
172
|
if (PIPED_DOWNLOAD.test(command) || RUN_DOWNLOAD.test(command))
|
|
@@ -192,6 +192,48 @@ export function writesPlain(command) {
|
|
|
192
192
|
}
|
|
193
193
|
return undefined;
|
|
194
194
|
}
|
|
195
|
+
/** Programs that only read what they are pointed at: run on built code, they start nothing of it. */
|
|
196
|
+
const READERS = new Set(["ls", "cat", "head", "tail", "less", "more", "grep", "rg", "find", "git", "wc", "diff", "tree", "file", "stat", "du", "jq", "echo", "pwd", "true", "test", "["]);
|
|
197
|
+
/**
|
|
198
|
+
* The path in plain_modules a command line runs in or from - `cd` there and run something, a program or its arguments
|
|
199
|
+
* there, an environment variable pointing there - or nothing when it only reads there, or does not go there. The code in
|
|
200
|
+
* plain_modules is what a pulse may be writing, and nobody launched it.
|
|
201
|
+
*/
|
|
202
|
+
export function runsBuiltCode(command) {
|
|
203
|
+
let inBuilt;
|
|
204
|
+
for (const part of command.split(/&&|\|\||[;|\n]/)) {
|
|
205
|
+
const words = part.trim().split(/\s+/).filter((word) => word !== "").map((word) => word.replace(/^["']|["']$/g, ""));
|
|
206
|
+
let at = 0;
|
|
207
|
+
while (at < words.length && /^[A-Za-z_][A-Za-z0-9_]*=/.test(words[at])) {
|
|
208
|
+
if (words[at].includes("plain_modules"))
|
|
209
|
+
return words[at].slice(words[at].indexOf("=") + 1);
|
|
210
|
+
at += 1;
|
|
211
|
+
}
|
|
212
|
+
const program = words[at];
|
|
213
|
+
if (program === undefined)
|
|
214
|
+
continue;
|
|
215
|
+
const args = words.slice(at + 1);
|
|
216
|
+
if (program === "cd" || program === "pushd") {
|
|
217
|
+
const to = args[0];
|
|
218
|
+
if (to !== undefined && to.includes("plain_modules"))
|
|
219
|
+
inBuilt = to;
|
|
220
|
+
else if (to !== undefined)
|
|
221
|
+
inBuilt = undefined;
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
const name = program.split("/").pop();
|
|
225
|
+
if (program.includes("plain_modules"))
|
|
226
|
+
return program;
|
|
227
|
+
if (READERS.has(name))
|
|
228
|
+
continue;
|
|
229
|
+
const there = args.find((arg) => arg.includes("plain_modules"));
|
|
230
|
+
if (there !== undefined)
|
|
231
|
+
return there;
|
|
232
|
+
if (inBuilt !== undefined)
|
|
233
|
+
return inBuilt;
|
|
234
|
+
}
|
|
235
|
+
return undefined;
|
|
236
|
+
}
|
|
195
237
|
/** What turri says when a command would change the machine: what it does instead. */
|
|
196
238
|
export function machineChangeReason(why) {
|
|
197
239
|
return (`turri changes nothing of this machine's - ${why}. Nothing is installed by turri, and no setting of the machine's or the ` +
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/** A command-line run has no one to ask: the command that
|
|
1
|
+
/** A command-line run has no one to ask: the command that launches what it built. */
|
|
2
2
|
export declare function tryItCommand(plainFile: string): string;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { relative } from "node:path";
|
|
2
2
|
/**
|
|
3
|
-
* How a command-line run that landed code ends: the command that
|
|
3
|
+
* How a command-line run that landed code ends: the command that launches it to try.
|
|
4
4
|
*/
|
|
5
5
|
function shortPath(buildDir) {
|
|
6
6
|
const fromHere = relative(process.cwd(), buildDir);
|
|
7
7
|
return fromHere === "" || fromHere.startsWith("..") ? buildDir : fromHere;
|
|
8
8
|
}
|
|
9
|
-
/** A command-line run has no one to ask: the command that
|
|
9
|
+
/** A command-line run has no one to ask: the command that launches what it built. */
|
|
10
10
|
export function tryItCommand(plainFile) {
|
|
11
|
-
return `To try it: turri
|
|
11
|
+
return `To try it: turri launch ${shortPath(plainFile)}`;
|
|
12
12
|
}
|
|
@@ -46,8 +46,8 @@ export interface Job {
|
|
|
46
46
|
note?: string;
|
|
47
47
|
/** "provider/model-id" its agents run on, when known. */
|
|
48
48
|
model?: string;
|
|
49
|
-
/** The
|
|
50
|
-
|
|
49
|
+
/** The module whose config.turri.<module>.yaml it is built with, over config.turri.yaml - as worked out when it was queued. */
|
|
50
|
+
configModule?: string;
|
|
51
51
|
/** The chat it was asked for in (chat-scope.ts): the one told how it went. */
|
|
52
52
|
chat?: string;
|
|
53
53
|
status: JobStatus;
|
package/dist/regenerate/jobs.js
CHANGED
|
@@ -5,7 +5,7 @@ import { describeEnvironmentError, EnvironmentError, missingCredentials } from "
|
|
|
5
5
|
import { addAgentReport, describeAgents, JobStoppedError, withActivity } from "./activity.js";
|
|
6
6
|
import { projectOfLanes, startJobLog } from "./job-log.js";
|
|
7
7
|
import { firstLine, healing, record } from "./ledger.js";
|
|
8
|
-
import {
|
|
8
|
+
import { debugMode, moduleConfigFile, pinnedConfigModule, withConfigModule } from "../config.js";
|
|
9
9
|
import { currentChat } from "../chat-scope.js";
|
|
10
10
|
import { pulseEnded, pulseWrote } from "./pulse-files.js";
|
|
11
11
|
import { keepFailureReport } from "./failure-reports.js";
|
|
@@ -58,9 +58,9 @@ export function createJobRegistry(options) {
|
|
|
58
58
|
},
|
|
59
59
|
start(input) {
|
|
60
60
|
const id = randomUUID().slice(0, 8);
|
|
61
|
-
// The
|
|
62
|
-
//
|
|
63
|
-
const
|
|
61
|
+
// The config pinned for the work that queues it, as it is queued - not as it starts: a job that waits for a slot is
|
|
62
|
+
// built with the config it was planned with, whatever the files say meanwhile.
|
|
63
|
+
const configModule = pinnedConfigModule();
|
|
64
64
|
const chat = currentChat()?.id;
|
|
65
65
|
const claimed = [...new Set(input.lanes ?? [])];
|
|
66
66
|
const blockers = [
|
|
@@ -82,7 +82,7 @@ export function createJobRegistry(options) {
|
|
|
82
82
|
...(input.diffWhere !== undefined ? { diffWhere: input.diffWhere } : {}),
|
|
83
83
|
...(input.cases !== undefined ? { cases: input.cases } : {}),
|
|
84
84
|
model: input.model,
|
|
85
|
-
...(
|
|
85
|
+
...(configModule !== undefined ? { configModule } : {}),
|
|
86
86
|
...(chat !== undefined ? { chat } : {}),
|
|
87
87
|
...(input.follows !== undefined ? { follows: input.follows } : {}),
|
|
88
88
|
status: blockers.length > 0 || (limit !== undefined && active >= limit) ? "queued" : "running",
|
|
@@ -108,7 +108,7 @@ export function createJobRegistry(options) {
|
|
|
108
108
|
...(input.pulse !== undefined ? { pulse: input.pulse } : {}),
|
|
109
109
|
...(input.title !== undefined ? { title: input.title } : {}),
|
|
110
110
|
...(input.model !== undefined ? { model: input.model } : {}),
|
|
111
|
-
...(
|
|
111
|
+
...(configModule !== undefined ? { configModule } : {}),
|
|
112
112
|
...(input.cases !== undefined ? { cases: input.cases } : {}),
|
|
113
113
|
waitingOn: blockers,
|
|
114
114
|
...(input.follows !== undefined ? { follows: input.follows } : {}),
|
|
@@ -319,9 +319,9 @@ export function createJobRegistry(options) {
|
|
|
319
319
|
// Its log is named only where it is kept: otherwise it goes as the pulse ends.
|
|
320
320
|
const named = log !== undefined && project !== undefined && debugMode(project);
|
|
321
321
|
record({ kind: "job.started", waitedMs: job.startedAt - job.queuedAt, ...(named ? { logFile: log.file } : {}) }, place);
|
|
322
|
-
// What the job's agents start runs until it ends, and no longer (withPulse) - with the
|
|
323
|
-
// with, whatever
|
|
324
|
-
return
|
|
322
|
+
// What the job's agents start runs until it ends, and no longer (withPulse) - with the config it was queued
|
|
323
|
+
// with, whatever the files say while it waits or runs.
|
|
324
|
+
return withConfigModule(configModule, () => (guarded ? runGuarded() : runOnce()));
|
|
325
325
|
})
|
|
326
326
|
.then((outcome) => {
|
|
327
327
|
// Asked to stop, it is stopped - whether its work threw as it unwound or returned what it had.
|
|
@@ -479,7 +479,7 @@ export function pulseName(job) {
|
|
|
479
479
|
}
|
|
480
480
|
/** What the agent is told when it checks on a job. */
|
|
481
481
|
export function describeJob(job) {
|
|
482
|
-
const name = `${pulseName(job)}${job.
|
|
482
|
+
const name = `${pulseName(job)}${job.configModule !== undefined ? ` (built with ${moduleConfigFile(job.configModule)})` : ""}`;
|
|
483
483
|
if (job.status === "queued") {
|
|
484
484
|
return `${name}: queued behind ${job.waitingOn.map((id) => `pulse ${id}`).join(" and ")}. It starts when that finishes.`;
|
|
485
485
|
}
|