@turri-dev/cli 0.4.3-next.620bae9 → 0.4.3-next.7ada234
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 +1 -0
- package/dist/background-skills.d.ts +4 -1
- package/dist/background-skills.js +9 -1
- package/dist/capture/agents.d.ts +406 -0
- package/dist/capture/agents.js +379 -0
- package/dist/capture/area.d.ts +58 -0
- package/dist/capture/area.js +197 -0
- package/dist/capture/assemble.d.ts +112 -0
- package/dist/capture/assemble.js +453 -0
- package/dist/capture/capture.d.ts +116 -0
- package/dist/capture/capture.js +1315 -0
- package/dist/capture/chat.d.ts +29 -0
- package/dist/capture/chat.js +94 -0
- package/dist/capture/checks.d.ts +142 -0
- package/dist/capture/checks.js +649 -0
- package/dist/capture/config.d.ts +13 -0
- package/dist/capture/config.js +66 -0
- package/dist/capture/interface.d.ts +71 -0
- package/dist/capture/interface.js +199 -0
- package/dist/capture/map.d.ts +56 -0
- package/dist/capture/map.js +530 -0
- package/dist/capture/models.d.ts +4 -0
- package/dist/capture/models.js +16 -0
- package/dist/capture/plan.d.ts +7 -0
- package/dist/capture/plan.js +13 -0
- package/dist/capture/progress.d.ts +111 -0
- package/dist/capture/progress.js +266 -0
- package/dist/capture/python-interface.d.ts +3 -0
- package/dist/capture/python-interface.js +17 -0
- package/dist/capture/report.d.ts +75 -0
- package/dist/capture/report.js +268 -0
- package/dist/capture/runners.d.ts +6 -0
- package/dist/capture/runners.js +59 -0
- package/dist/capture/scripts.d.ts +26 -0
- package/dist/capture/scripts.js +38 -0
- package/dist/capture/state.d.ts +310 -0
- package/dist/capture/state.js +43 -0
- package/dist/capture/trial.d.ts +34 -0
- package/dist/capture/trial.js +89 -0
- package/dist/capture-cli.d.ts +1 -0
- package/dist/capture-cli.js +77 -0
- package/dist/chat-tab-header.d.ts +3 -2
- package/dist/chat-tab-header.js +22 -9
- package/dist/chat-tabs.d.ts +7 -1
- package/dist/chat-tabs.js +10 -6
- package/dist/chat-terminal.js +27 -6
- package/dist/chats.d.ts +14 -8
- package/dist/chats.js +46 -20
- package/dist/cli.js +32 -14
- package/dist/config-edit.js +5 -2
- package/dist/config.d.ts +15 -2
- package/dist/config.js +62 -3
- package/dist/extension.d.ts +2 -1
- package/dist/extension.js +225 -68
- package/dist/identity.js +2 -1
- package/dist/init-config.d.ts +4 -1
- package/dist/init-config.js +31 -4
- package/dist/loop-cli.js +5 -1
- package/dist/loop-tools.js +5 -1
- package/dist/new-project.d.ts +5 -0
- package/dist/new-project.js +11 -0
- package/dist/pi-launch.js +2 -0
- package/dist/pi-themes.d.ts +3 -0
- package/dist/pi-themes.js +21 -0
- package/dist/pi.d.ts +2 -2
- package/dist/pi.js +4 -4
- package/dist/plain-code-blocks.d.ts +14 -0
- package/dist/plain-code-blocks.js +56 -0
- package/dist/pointer-hover.d.ts +1 -1
- package/dist/pointer-hover.js +4 -0
- package/dist/question-dialog.d.ts +5 -0
- package/dist/question-dialog.js +26 -3
- package/dist/regenerate/agent-env.js +5 -1
- package/dist/regenerate/command-check.js +80 -11
- package/dist/regenerate/job-panel.d.ts +5 -107
- package/dist/regenerate/job-panel.js +4 -289
- package/dist/regenerate/loop.js +9 -1
- package/dist/regenerate/side-panel.d.ts +2 -0
- package/dist/regenerate/side-panel.js +32 -5
- package/dist/regenerate/spec-map-view.d.ts +2 -2
- package/dist/regenerate/test-scripts.d.ts +5 -0
- package/dist/regenerate/test-scripts.js +4 -0
- package/dist/reopen.d.ts +29 -0
- package/dist/reopen.js +47 -0
- package/dist/sentinel-chat.js +7 -2
- package/dist/sentinel.d.ts +1 -1
- package/dist/sentinel.js +3 -1
- package/dist/setup.js +9 -1
- package/dist/terminal-notifications.d.ts +37 -0
- package/dist/terminal-notifications.js +164 -0
- package/docs/README.md +2 -0
- package/docs/capture.md +227 -0
- package/docs/chats.md +6 -3
- package/docs/config.md +18 -4
- package/docs/development.md +4 -1
- package/docs/hosting.md +2 -2
- package/docs/launch.md +2 -2
- package/docs/regenerating.md +1 -1
- package/docs/sandbox.md +4 -2
- package/docs/sentinel.md +11 -11
- package/docs/theming.md +3 -3
- package/docs/using.md +7 -3
- package/genome/capture/capture.md +26 -0
- package/genome/capture/check-conventions.md +5 -0
- package/genome/capture/check-reference.md +12 -0
- package/genome/capture/compact.md +7 -0
- package/genome/capture/concepts.md +3 -0
- package/genome/capture/divide.md +9 -0
- package/genome/capture/feature.md +45 -0
- package/genome/capture/interface.md +9 -0
- package/genome/capture/modules.md +25 -0
- package/genome/capture/outline.md +11 -0
- package/genome/capture/python-interface.py +111 -0
- package/genome/capture/readability.md +12 -0
- package/genome/capture/reference.md +10 -0
- package/genome/capture/runners/python-requirements.sh +67 -0
- package/genome/capture/split.md +9 -0
- package/genome/capture/survey.md +39 -0
- package/genome/capture/trial.md +18 -0
- package/genome/capture/verify.md +7 -0
- package/genome/rules/turri-regeneration.md +1 -1
- package/package.json +1 -1
package/dist/init-config.js
CHANGED
|
@@ -4,10 +4,11 @@ import { basename, join, resolve } from "node:path";
|
|
|
4
4
|
import { createInterface } from "node:readline/promises";
|
|
5
5
|
import { load as loadYaml } from "js-yaml";
|
|
6
6
|
import { adoptLegacyConfig, CONFIG_FILE, CONFIG_KEYS, LEGACY_CONFIG_FILE, ROLE_THINKING } from "./config.js";
|
|
7
|
-
import { withTopLevelValue } from "./config-edit.js";
|
|
7
|
+
import { currentValue, withSetting, withTopLevelValue } from "./config-edit.js";
|
|
8
8
|
import { brand } from "./brand.js";
|
|
9
9
|
import { closestModels, piModelCatalogue } from "./model-check.js";
|
|
10
10
|
import { EXTENSION_PROVIDERS } from "./installed-providers.js";
|
|
11
|
+
import { captureDefaults } from "./capture/models.js";
|
|
11
12
|
/** The geographies turri's own pair for each maker is served in - the first the default. Every other: bedrockMakers. */
|
|
12
13
|
export const BEDROCK_REGIONS = {
|
|
13
14
|
anthropic: ["global", "us", "eu", "jp", "au"],
|
|
@@ -345,7 +346,9 @@ export function quickStartConfig(vendor = "other", bedrock, models) {
|
|
|
345
346
|
"",
|
|
346
347
|
"# Optional: each agent role's own model, thinking and turn limit. Without it, every role runs on coding-model and the",
|
|
347
348
|
"# conversation's side on harness-model, each thinking as written here. What an entry leaves out it takes from default.",
|
|
348
|
-
"#
|
|
349
|
+
"# Capture uses three tiers: gather facts, analyse evidence, then reason and write.",
|
|
350
|
+
"models:",
|
|
351
|
+
...Object.entries(captureDefaults(harness, coding)).map(([name, choice]) => ` ${name}: ${choice.model}:${choice.thinking}`),
|
|
349
352
|
`# default: ${coding}`,
|
|
350
353
|
`${column(`# chat: ${harness}`, 72)}# the conversation - as harness-model, which it wins over`,
|
|
351
354
|
`${column(`# sentinel: ${harness}`, 72)}# the sentinel: checks every finished pulse and tests what is launched`,
|
|
@@ -365,6 +368,24 @@ export function quickStartConfig(vendor = "other", bedrock, models) {
|
|
|
365
368
|
}
|
|
366
369
|
/** The quick start config for the mix of vendors: what turri wrote before it asked. */
|
|
367
370
|
export const QUICK_START_CONFIG = quickStartConfig("other");
|
|
371
|
+
/** A capture without a config starts with init-config's settings. Resolve an omitted model from the vendor's pair,
|
|
372
|
+
* including the maker and geography on Bedrock, just as the wizard does. */
|
|
373
|
+
export async function quickStartForCapture(harness, coding) {
|
|
374
|
+
if (harness && coding)
|
|
375
|
+
return quickStartConfig("other", undefined, { harness, coding, strong: harness });
|
|
376
|
+
const spec = harness ?? coding;
|
|
377
|
+
const provider = spec?.split("/")[0] ?? (process.env.AWS_BEARER_TOKEN_BEDROCK || process.env.AWS_PROFILE || process.env.CLAUDE_CODE_USE_BEDROCK === "1" ? "amazon-bedrock" : "other");
|
|
378
|
+
// A custom provider has no default pair. Stay on its named model rather than switching providers.
|
|
379
|
+
if (!Object.hasOwn(VENDORS, provider) && spec)
|
|
380
|
+
return quickStartConfig("other", undefined, { harness: spec, coding: spec, strong: spec });
|
|
381
|
+
const vendor = provider;
|
|
382
|
+
const place = vendor === "amazon-bedrock" && spec ? bedrockPlaceOf(spec) : undefined;
|
|
383
|
+
const chosen = await chosenModels({ vendor, ...(place ? { bedrock: { maker: place.maker, region: place.geography } } : {}) });
|
|
384
|
+
if ("problem" in chosen)
|
|
385
|
+
throw new Error(chosen.problem);
|
|
386
|
+
const models = chosen.models;
|
|
387
|
+
return quickStartConfig(vendor, chosen.bedrock, { ...models, harness: harness ?? models.harness, coding: coding ?? models.coding });
|
|
388
|
+
}
|
|
368
389
|
/** A vendor from what was typed: its number in the list, or its name. */
|
|
369
390
|
export function vendorOf(answer) {
|
|
370
391
|
const typed = answer.trim().toLowerCase();
|
|
@@ -597,9 +618,14 @@ export async function initConfig(dir, options = {}) {
|
|
|
597
618
|
const lines = modelLines(harness, coding);
|
|
598
619
|
// A new file takes what a config.yaml beside it - another tool's, say - says that turri reads too: its testing scripts, say.
|
|
599
620
|
const shared = existing ? { carried: [], left: [] } : sharedWithLegacy(folder);
|
|
600
|
-
|
|
621
|
+
let config = existing
|
|
601
622
|
? withModels(readFileSync(path, "utf8"), lines)
|
|
602
623
|
: shared.carried.reduce((text, [key, value]) => withTopLevelValue(text, key, value), quickStartConfig(vendor, bedrock, models));
|
|
624
|
+
for (const [role, choice] of Object.entries(captureDefaults(harness, coding))) {
|
|
625
|
+
const key = `models.${role}`;
|
|
626
|
+
if (currentValue(config, key) === undefined)
|
|
627
|
+
config = withSetting(config, key, `${choice.model}:${choice.thinking}`);
|
|
628
|
+
}
|
|
603
629
|
writeFileSync(path, config);
|
|
604
630
|
const here = resolve(process.cwd()) === folder;
|
|
605
631
|
const [talk, code] = [harness, coding].map((model, at) => `${model}:${at === 0 ? HARNESS_THINKING : ROLE_THINKING.coding}`);
|
|
@@ -608,10 +634,11 @@ export async function initConfig(dir, options = {}) {
|
|
|
608
634
|
message: [
|
|
609
635
|
"",
|
|
610
636
|
`${brand.success("✓")} ${existing ? `Set the two models in ${brand.bold(path)}` : `Wrote ${brand.bold(path)}`}`,
|
|
611
|
-
` ${brand.muted(`with ${whose(vendor, models, given)}${existing ? " - everything else in it left as it was (--force writes it all again)" : ""}`)}`,
|
|
637
|
+
` ${brand.muted(`with ${whose(vendor, models, given)}${existing ? " - missing capture tiers filled in, everything else in it left as it was (--force writes it all again)" : ""}`)}`,
|
|
612
638
|
"",
|
|
613
639
|
` ${brand.muted("you talk to")} ${talk}`,
|
|
614
640
|
` ${brand.muted("it codes")} ${code}`,
|
|
641
|
+
...["capture-exploration", "capture-analysis", "capture"].map(role => ` ${brand.muted(role)} ${currentValue(config, `models.${role}`)}`),
|
|
615
642
|
...(shared.carried.length > 0
|
|
616
643
|
? [
|
|
617
644
|
"",
|
package/dist/loop-cli.js
CHANGED
|
@@ -2,7 +2,7 @@ import { sweepOrphanedGroups } from "./regenerate/shell.js";
|
|
|
2
2
|
import { refuseTestPlainFile } from "./test-plain-files.js";
|
|
3
3
|
import { createInterface } from "node:readline/promises";
|
|
4
4
|
import { resolve, sep } from "node:path";
|
|
5
|
-
import { configForSpec, inheritModel, modelOnly, modelSpec, projectModels, readProjectConfig, roleModel, ROLE_THINKING, splitModelSpec, } from "./config.js";
|
|
5
|
+
import { brokenConfig, configForSpec, inheritModel, modelOnly, modelSpec, projectModels, readProjectConfig, roleModel, ROLE_THINKING, splitModelSpec, } from "./config.js";
|
|
6
6
|
import { PACKAGE_ROOT } from "./environment.js";
|
|
7
7
|
import { c } from "./module-report.js";
|
|
8
8
|
import { describeTurnIncident, onModelEvent } from "./regenerate/activity.js";
|
|
@@ -26,6 +26,10 @@ import { configKeyOptions, optionValue } from "./cli-options.js";
|
|
|
26
26
|
export async function runLoop(options) {
|
|
27
27
|
const plainFile = resolve(options.plainFile);
|
|
28
28
|
refuseTestPlainFile(plainFile);
|
|
29
|
+
// A config that does not parse is read as empty: refused, rather than every pulse run on defaults - pi's model among them.
|
|
30
|
+
const broken = brokenConfig(projectDirOf(plainFile));
|
|
31
|
+
if (broken !== undefined)
|
|
32
|
+
throw new Error(`Nothing was started: ${broken}`);
|
|
29
33
|
// What a turri that was killed left running - commands' process groups - stopped before anything starts.
|
|
30
34
|
const orphans = sweepOrphanedGroups();
|
|
31
35
|
if (orphans > 0)
|
package/dist/loop-tools.js
CHANGED
|
@@ -3,7 +3,7 @@ import { refuseTestPlainFile } from "./test-plain-files.js";
|
|
|
3
3
|
import { basename, relative, resolve } from "node:path";
|
|
4
4
|
import { defineTool } from "@earendil-works/pi-coding-agent";
|
|
5
5
|
import { Type } from "typebox";
|
|
6
|
-
import { CONFIG_FILE, readProjectConfig, moduleConfigFile, configModuleFor, moduleConfigsOf, withConfigModule } from "./config.js";
|
|
6
|
+
import { brokenConfig, CONFIG_FILE, readProjectConfig, moduleConfigFile, configModuleFor, moduleConfigsOf, withConfigModule } from "./config.js";
|
|
7
7
|
import { checkPlainFile, formatCheckResults } from "./plain/check.js";
|
|
8
8
|
import { describeDrift, describeModules } from "./regenerate/loop.js";
|
|
9
9
|
import { describeJob, pulseName } from "./regenerate/jobs.js";
|
|
@@ -34,6 +34,10 @@ export const MODEL_PARAM = Type.Optional(Type.String({
|
|
|
34
34
|
*/
|
|
35
35
|
export function unbuildableConfig(plainFile) {
|
|
36
36
|
const root = projectDirOf(plainFile);
|
|
37
|
+
// A config that does not parse is read as empty: built with it, every pulse would run on defaults - pi's model among them.
|
|
38
|
+
const broken = brokenConfig(root);
|
|
39
|
+
if (broken !== undefined)
|
|
40
|
+
return broken;
|
|
37
41
|
let own;
|
|
38
42
|
try {
|
|
39
43
|
own = configModuleFor(plainFile);
|
package/dist/new-project.d.ts
CHANGED
|
@@ -3,3 +3,8 @@
|
|
|
3
3
|
* Spring Boot" - and the chat writes the ***plain itself, here, with no skill, regenerating from the first functional spec.
|
|
4
4
|
*/
|
|
5
5
|
export declare const NEW_PROJECT: string;
|
|
6
|
+
/**
|
|
7
|
+
* Bringing an existing codebase under ***plain: the person starts /capture, never the chat - it runs a while, and turns
|
|
8
|
+
* conformance tests on in the project it writes.
|
|
9
|
+
*/
|
|
10
|
+
export declare const CAPTURE_HINT: string;
|
package/dist/new-project.js
CHANGED
|
@@ -29,3 +29,14 @@ export const NEW_PROJECT = [
|
|
|
29
29
|
"go on, or what to change, and every change after is ***plain you write and regenerate.",
|
|
30
30
|
"</new-project>",
|
|
31
31
|
].join("\n");
|
|
32
|
+
/**
|
|
33
|
+
* Bringing an existing codebase under ***plain: the person starts /capture, never the chat - it runs a while, and turns
|
|
34
|
+
* conformance tests on in the project it writes.
|
|
35
|
+
*/
|
|
36
|
+
export const CAPTURE_HINT = [
|
|
37
|
+
"<capture>",
|
|
38
|
+
"When the person wants an existing codebase brought under ***plain - written down as ***plain, to work on from then on",
|
|
39
|
+
"instead of the code - tell them /capture [path] does it: in the background, asking nothing, into <path>/plain, with a",
|
|
40
|
+
"report of what it decided. Only they start it; you cannot.",
|
|
41
|
+
"</capture>",
|
|
42
|
+
].join("\n");
|
package/dist/pi-launch.js
CHANGED
|
@@ -15,6 +15,7 @@ import { withoutResumeLine } from "./resume-line.js";
|
|
|
15
15
|
import { lastRun } from "./chat-records.js";
|
|
16
16
|
import { driveTerminal } from "./chat-terminal.js";
|
|
17
17
|
import { takeOverSettings } from "./pi-settings.js";
|
|
18
|
+
import { quietBrandThemeOverrides } from "./pi-themes.js";
|
|
18
19
|
import turri, { createTurriCore, processSession } from "./extension.js";
|
|
19
20
|
/**
|
|
20
21
|
* pi, started the way its own CLI starts it, for `turri`.
|
|
@@ -45,6 +46,7 @@ ProcessTerminal.prototype.setTitle = function (title) {
|
|
|
45
46
|
SettingsManager.prototype.getFullscreenExitOutput = () => "resume-hint";
|
|
46
47
|
// /settings is turri's, pi's own menu the last entry of it (pi-settings.ts).
|
|
47
48
|
takeOverSettings();
|
|
49
|
+
quietBrandThemeOverrides();
|
|
48
50
|
const write = process.stdout.write.bind(process.stdout);
|
|
49
51
|
process.stdout.write = ((chunk, ...rest) => write(typeof chunk === "string" ? withoutResumeLine(chunk) : chunk, ...rest));
|
|
50
52
|
// 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,3 @@
|
|
|
1
|
+
/** pi already picks the project's theme over the user's, then turri's bundled fallback. In the chat these copies
|
|
2
|
+
* of a brand theme are expected; a broken file or a clash with a theme from elsewhere is still worth showing. */
|
|
3
|
+
export declare function quietBrandThemeOverrides(cwd?: string, agentDir?: string): void;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { join, relative } from "node:path";
|
|
2
|
+
import { DefaultResourceLoader, getAgentDir } from "@earendil-works/pi-coding-agent";
|
|
3
|
+
import { PACKAGE_ROOT, themeFiles } from "./environment.js";
|
|
4
|
+
/** pi already picks the project's theme over the user's, then turri's bundled fallback. In the chat these copies
|
|
5
|
+
* of a brand theme are expected; a broken file or a clash with a theme from elsewhere is still worth showing. */
|
|
6
|
+
export function quietBrandThemeOverrides(cwd = process.cwd(), agentDir = getAgentDir()) {
|
|
7
|
+
const directories = [join(cwd, ".pi", "themes"), join(agentDir, "themes"), join(PACKAGE_ROOT, ".pi", "themes")];
|
|
8
|
+
const files = new Set(themeFiles());
|
|
9
|
+
const expected = ({ type, collision }) => {
|
|
10
|
+
if (type !== "collision" || collision?.resourceType !== "theme")
|
|
11
|
+
return false;
|
|
12
|
+
const file = `${collision.name}.json`;
|
|
13
|
+
const isCopy = (path) => directories.some((dir) => relative(dir, path) === file);
|
|
14
|
+
return files.has(file) && isCopy(collision.winnerPath) && isCopy(collision.loserPath);
|
|
15
|
+
};
|
|
16
|
+
const getThemes = DefaultResourceLoader.prototype.getThemes;
|
|
17
|
+
DefaultResourceLoader.prototype.getThemes = function () {
|
|
18
|
+
const { themes, diagnostics } = getThemes.call(this);
|
|
19
|
+
return { themes, diagnostics: diagnostics.filter((item) => !expected(item)) };
|
|
20
|
+
};
|
|
21
|
+
}
|
package/dist/pi.d.ts
CHANGED
|
@@ -47,7 +47,7 @@ export declare function inheritProviders(source: () => ModelRegistry | undefined
|
|
|
47
47
|
* agent to load when one fits; an agent turri starts has one job, and turri runs its gated skills itself,
|
|
48
48
|
* giving each step to an agent as its task. The conversation keeps them.
|
|
49
49
|
*/
|
|
50
|
-
export declare function subAgentResources(cwd: string, withRules: boolean, system?: string): Promise<DefaultResourceLoader>;
|
|
50
|
+
export declare function subAgentResources(cwd: string, withRules: boolean | readonly string[], system?: string): Promise<DefaultResourceLoader>;
|
|
51
51
|
/** Raised when the provider itself failed, rather than the agent producing a poor answer. */
|
|
52
52
|
export declare class ProviderError extends Error {
|
|
53
53
|
constructor(message: string);
|
|
@@ -181,7 +181,7 @@ export declare function createExecutor(opts: {
|
|
|
181
181
|
*/
|
|
182
182
|
model?: string;
|
|
183
183
|
/** Give it the ***plain rules - for agents that write or edit specs, not code. */
|
|
184
|
-
rules?: boolean;
|
|
184
|
+
rules?: boolean | readonly string[];
|
|
185
185
|
/** Continue the session saved in this file, instead of starting a new one. */
|
|
186
186
|
resumeFrom?: string;
|
|
187
187
|
/** Save its session to disk, debug mode or not: it is picked back up later (a skill's run, resumed). */
|
package/dist/pi.js
CHANGED
|
@@ -92,7 +92,7 @@ const RULES_DIR = join(dirname(dirname(fileURLToPath(import.meta.url))), "genome
|
|
|
92
92
|
*/
|
|
93
93
|
export async function subAgentResources(cwd, withRules, system) {
|
|
94
94
|
// Less any the project leaves out (rules-off).
|
|
95
|
-
const rules = withRules ? renderRulesBlock(loadRules(RULES_DIR, readProjectConfig(projectRootOf(cwd)).rulesOff ?? [])) : "";
|
|
95
|
+
const rules = withRules ? renderRulesBlock(loadRules(RULES_DIR, readProjectConfig(projectRootOf(cwd)).rulesOff ?? []).filter(rule => withRules === true || withRules.includes(rule.name))) : "";
|
|
96
96
|
const extra = [rules, system ?? ""].filter((part) => part !== "");
|
|
97
97
|
const loader = new DefaultResourceLoader({
|
|
98
98
|
cwd,
|
|
@@ -237,8 +237,8 @@ export function providerRetryDelay(attempt, random = Math.random) {
|
|
|
237
237
|
}
|
|
238
238
|
/** How long a request to the model may go without anything coming back before the provider is said to be stalling; 0 never. */
|
|
239
239
|
export const PROVIDER_STALL_MS = Number(process.env.TURRI_PROVIDER_STALL ?? 120) * 1000;
|
|
240
|
-
/** A provider error that passes: overloaded, rate limited, unreachable, timed out. */
|
|
241
|
-
const TRANSIENT_PROVIDER_ERROR = /\b(429|500|502|503|504|529)\b|overloaded|high demand|rate.?limit|too many requests|unavailable|fetch failed|network|connection|timed? ?out|ECONNRESET|socket|terminated/i;
|
|
240
|
+
/** A provider error that passes: overloaded, rate limited, unreachable, timed out, its stream cut off part-way. */
|
|
241
|
+
const TRANSIENT_PROVIDER_ERROR = /\b(429|500|502|503|504|529)\b|overloaded|high demand|rate.?limit|too many requests|unavailable|fetch failed|network|connection|timed? ?out|ECONNRESET|socket|terminated|truncated|stream ended/i;
|
|
242
242
|
/** Wait, unless the job is stopped first. */
|
|
243
243
|
async function waitOrStop(ms) {
|
|
244
244
|
const stop = currentStopSignal();
|
|
@@ -761,7 +761,7 @@ export async function createExecutor(opts) {
|
|
|
761
761
|
// What an agent is shown never holds a credential the project passed: each value is its name (masking.ts).
|
|
762
762
|
customTools: guardRepeats(maskToolResults(withListArguments(withEnvironmentErrors)), () => session, opts.budget),
|
|
763
763
|
sessionManager,
|
|
764
|
-
resourceLoader: await subAgentResources(opts.cwd, opts.rules
|
|
764
|
+
resourceLoader: await subAgentResources(opts.cwd, opts.rules ?? false, [opts.system, opts.task].filter((part) => part !== undefined && part !== "").join("\n\n") || undefined),
|
|
765
765
|
});
|
|
766
766
|
if (opts.task !== undefined)
|
|
767
767
|
pendingTask.set(session, opts.task);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type PlainRole } from "./plain/highlight.ts";
|
|
2
|
+
export declare function isPlainLanguage(lang: string | undefined): boolean;
|
|
3
|
+
/** Whether a fenced block is ***plain: fenced as plain, or fenced with no language around a section's header. */
|
|
4
|
+
export declare function isPlainBlock(lang: string | undefined, text: string): boolean;
|
|
5
|
+
/** Lines of ***plain, each piece painted by its role; the text around them in `rest`. */
|
|
6
|
+
export declare function highlightPlain(code: string, paint: (role: PlainRole, text: string) => string, rest?: (text: string) => string): string[];
|
|
7
|
+
/** What a theme says of itself that the palette needs: dark or light, and how many colours the terminal has. */
|
|
8
|
+
type ThemeLike = {
|
|
9
|
+
appearance?: "dark" | "light";
|
|
10
|
+
getColorMode?(): string;
|
|
11
|
+
};
|
|
12
|
+
/** From now on, a ***plain block in the chat is highlighted - in the colours of the theme `theme` gives at the time. */
|
|
13
|
+
export declare function highlightPlainCodeBlocks(theme: () => ThemeLike | undefined): void;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Markdown } from "@earendil-works/pi-tui";
|
|
2
|
+
import { highlightLines, roleOf } from "./plain/highlight.js";
|
|
3
|
+
import { plainPaint } from "./regenerate/plain-palette.js";
|
|
4
|
+
/**
|
|
5
|
+
* A fenced block of ***plain in the chat - ```plain, as an agent shows a module, or a fence with no language around
|
|
6
|
+
* a section's header - highlighted as turri highlights ***plain everywhere else: by its own grammar
|
|
7
|
+
* (plain/highlight.ts), in the colours of a ***plain diff (plain-palette.ts). pi highlights a code block through highlight.js, which knows no ***plain, and has no hook for
|
|
8
|
+
* a language of an extension's: so pi-tui's Markdown is patched, as chat-terminal.ts patches pi's screen - a ***plain
|
|
9
|
+
* block drawn with a highlighter of turri's in place of the theme's, every other block as pi draws it.
|
|
10
|
+
*/
|
|
11
|
+
/** The fence's languages that are ***plain. */
|
|
12
|
+
const PLAIN_LANGUAGES = new Set(["plain", "***plain"]);
|
|
13
|
+
export function isPlainLanguage(lang) {
|
|
14
|
+
return lang !== undefined && PLAIN_LANGUAGES.has(lang.trim().toLowerCase());
|
|
15
|
+
}
|
|
16
|
+
/** A section's header on a line of its own - `***functional specs***` - which nothing but ***plain writes. */
|
|
17
|
+
const SECTION_HEADER = /^\*\*\*[a-z][a-z ]*\*\*\*[ \t]*$/m;
|
|
18
|
+
/** Whether a fenced block is ***plain: fenced as plain, or fenced with no language around a section's header. */
|
|
19
|
+
export function isPlainBlock(lang, text) {
|
|
20
|
+
return isPlainLanguage(lang) || ((lang ?? "").trim() === "" && SECTION_HEADER.test(text));
|
|
21
|
+
}
|
|
22
|
+
/** Lines of ***plain, each piece painted by its role; the text around them in `rest`. */
|
|
23
|
+
export function highlightPlain(code, paint, rest = (text) => text) {
|
|
24
|
+
return highlightLines(code.split("\n")).map((tokens) => tokens
|
|
25
|
+
.map((token) => {
|
|
26
|
+
const role = roleOf(token.scopes);
|
|
27
|
+
return role !== undefined ? paint(role, token.text) : rest(token.text);
|
|
28
|
+
})
|
|
29
|
+
.join(""));
|
|
30
|
+
}
|
|
31
|
+
let themeNow = () => undefined;
|
|
32
|
+
let patched = false;
|
|
33
|
+
/** From now on, a ***plain block in the chat is highlighted - in the colours of the theme `theme` gives at the time. */
|
|
34
|
+
export function highlightPlainCodeBlocks(theme) {
|
|
35
|
+
themeNow = theme;
|
|
36
|
+
if (patched)
|
|
37
|
+
return;
|
|
38
|
+
patched = true;
|
|
39
|
+
const prototype = Markdown.prototype;
|
|
40
|
+
const renderToken = prototype.renderToken;
|
|
41
|
+
prototype.renderToken = function (token, ...rest) {
|
|
42
|
+
const theme = this.theme;
|
|
43
|
+
const current = themeNow();
|
|
44
|
+
if (token.type !== "code" || !isPlainBlock(token.lang, token.text ?? "") || current === undefined)
|
|
45
|
+
return renderToken.call(this, token, ...rest);
|
|
46
|
+
const paint = plainPaint(current);
|
|
47
|
+
// Drawn by pi, with turri's highlighter in the theme's place for this block alone.
|
|
48
|
+
this.theme = { ...theme, highlightCode: (code) => highlightPlain(code, paint.syntax, theme.codeBlock) };
|
|
49
|
+
try {
|
|
50
|
+
return renderToken.call(this, token, ...rest);
|
|
51
|
+
}
|
|
52
|
+
finally {
|
|
53
|
+
this.theme = theme;
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}
|
package/dist/pointer-hover.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Theme } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
export type ButtonRole = "tab" | "new" | "close" | "panel";
|
|
2
|
+
export type ButtonRole = "tab" | "new" | "close" | "panel" | "regenerating";
|
|
3
3
|
export type ButtonPaint = (text: string, active: boolean, hovered: boolean, role: ButtonRole) => string;
|
|
4
4
|
/** The layout owns the padding, so the entire coloured surface is also the click target. */
|
|
5
5
|
export declare function buttonLabel(theme: Theme, text: string, active: boolean, hovered: boolean, role: ButtonRole): string;
|
package/dist/pointer-hover.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { colorToRgb, parseColor } from "@earendil-works/pi-tui";
|
|
2
|
+
import { BRAND_PINK } from "./regenerate/plain-palette.js";
|
|
2
3
|
const abyss = parseColor("#0a0f1a");
|
|
4
|
+
const pink = parseColor(BRAND_PINK.dark);
|
|
3
5
|
const white = parseColor("#f4f7f9");
|
|
4
6
|
const linear = (byte) => byte <= 10 ? byte / 3294.6 : ((byte / 255 + 0.055) / 1.055) ** 2.4;
|
|
5
7
|
function luminance(color) {
|
|
@@ -11,6 +13,8 @@ function luminance(color) {
|
|
|
11
13
|
const inkSwitch = Math.sqrt((luminance(abyss) + 0.05) * (luminance(white) + 0.05)) - 0.05;
|
|
12
14
|
/** The layout owns the padding, so the entire coloured surface is also the click target. */
|
|
13
15
|
export function buttonLabel(theme, text, active, hovered, role) {
|
|
16
|
+
if (role === "regenerating")
|
|
17
|
+
return theme.style(text, { bg: pink, fg: abyss, bold: true, underline: hovered });
|
|
14
18
|
if (role === "new" || active || hovered) {
|
|
15
19
|
const fill = theme.colors[role === "new" ? "success" : role === "close" && hovered ? "error" : "accent"];
|
|
16
20
|
return theme.style(text, { bg: fill, fg: luminance(fill) > inkSwitch ? abyss : white, bold: true, underline: hovered });
|
|
@@ -18,6 +18,8 @@ export interface QuestionDialogOptions {
|
|
|
18
18
|
question: string;
|
|
19
19
|
/** The choices. Without them, a line to type the answer on. */
|
|
20
20
|
options?: string[];
|
|
21
|
+
/** Draw choices as clickable buttons in the side panel. The padding belongs to the button. */
|
|
22
|
+
choiceButton?(text: string, selected: boolean): string;
|
|
21
23
|
/** The choice the cursor starts on. */
|
|
22
24
|
selected?: number;
|
|
23
25
|
/** The terminal's height, for the window the brief scrolls in. */
|
|
@@ -40,6 +42,9 @@ export declare class QuestionDialog implements Component, Focusable {
|
|
|
40
42
|
private maxScroll;
|
|
41
43
|
private window;
|
|
42
44
|
private answered;
|
|
45
|
+
private choiceLines;
|
|
46
|
+
private choiceTop;
|
|
47
|
+
private pressed;
|
|
43
48
|
private focusedNow;
|
|
44
49
|
constructor(options: QuestionDialogOptions);
|
|
45
50
|
get focused(): boolean;
|
package/dist/question-dialog.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Input, matchesKey, truncateToWidth, wrapTextWithAnsi } from "@earendil-works/pi-tui";
|
|
1
|
+
import { Input, matchesKey, truncateToWidth, visibleWidth, wrapTextWithAnsi } from "@earendil-works/pi-tui";
|
|
2
2
|
/** Lines kept for the conversation above the dialog, so it never takes the whole screen. */
|
|
3
3
|
const KEPT_ABOVE = 4;
|
|
4
4
|
/** **bold** and `code`, as the brief's markdown means them. */
|
|
@@ -15,6 +15,9 @@ export class QuestionDialog {
|
|
|
15
15
|
maxScroll = 0;
|
|
16
16
|
window = 0;
|
|
17
17
|
answered = false;
|
|
18
|
+
choiceLines = [];
|
|
19
|
+
choiceTop = 0;
|
|
20
|
+
pressed;
|
|
18
21
|
focusedNow = false;
|
|
19
22
|
constructor(options) {
|
|
20
23
|
this.options = options;
|
|
@@ -61,16 +64,22 @@ export class QuestionDialog {
|
|
|
61
64
|
const brief = context === "" ? [] : context.split("\n").flatMap((line) => (line.trim() === "" ? [""] : wrapTextWithAnsi(styled(line, style), inner)));
|
|
62
65
|
const question = wrapTextWithAnsi(style.bold(style.accent(this.options.question)), inner);
|
|
63
66
|
const choices = this.options.options ?? [];
|
|
67
|
+
this.choiceLines = [];
|
|
64
68
|
const body = this.input !== undefined
|
|
65
69
|
? this.input.render(inner)
|
|
66
70
|
: // A long option wraps, its lines under its first, rather than cut off where the person cannot read it.
|
|
67
71
|
choices.flatMap((choice, index) => wrapTextWithAnsi(choice, Math.max(1, inner - 2)).map((line, at) => {
|
|
72
|
+
if (this.options.choiceButton) {
|
|
73
|
+
const label = ` ${line} `;
|
|
74
|
+
this.choiceLines.push({ index, width: visibleWidth(label) });
|
|
75
|
+
return this.options.choiceButton(label, index === this.selected);
|
|
76
|
+
}
|
|
68
77
|
const shown = `${at === 0 && index === this.selected ? "›" : " "} ${line}`;
|
|
69
78
|
return index === this.selected ? style.accent(shown) : shown;
|
|
70
79
|
}));
|
|
71
80
|
const hint = this.input !== undefined
|
|
72
81
|
? "enter answers · esc dismisses · ctrl+c declines"
|
|
73
|
-
: "↑↓ choose · enter picks · esc dismisses · ctrl+c declines";
|
|
82
|
+
: this.options.choiceButton ? "↑↓ select · enter or click · esc back" : "↑↓ choose · enter picks · esc dismisses · ctrl+c declines";
|
|
74
83
|
// The brief gets what the question, the options and the hints leave of the screen.
|
|
75
84
|
const fixed = question.length + body.length + 5;
|
|
76
85
|
const room = Math.max(3, this.options.rows() - KEPT_ABOVE - fixed);
|
|
@@ -89,7 +98,9 @@ export class QuestionDialog {
|
|
|
89
98
|
}
|
|
90
99
|
lines.push("");
|
|
91
100
|
}
|
|
92
|
-
lines.push(...question.map(pad)
|
|
101
|
+
lines.push(...question.map(pad));
|
|
102
|
+
this.choiceTop = lines.length;
|
|
103
|
+
lines.push(...body.map(pad), "", pad(style.muted(hint)));
|
|
93
104
|
return lines;
|
|
94
105
|
}
|
|
95
106
|
handleInput(data) {
|
|
@@ -131,6 +142,18 @@ export class QuestionDialog {
|
|
|
131
142
|
}
|
|
132
143
|
}
|
|
133
144
|
handleMouse(event) {
|
|
145
|
+
if (this.options.choiceButton && event.button === "left" && (event.type === "press" || event.type === "click")) {
|
|
146
|
+
const row = this.choiceLines[event.y - this.choiceTop];
|
|
147
|
+
const index = row && event.x >= 2 && event.x < 2 + row.width ? row.index : undefined;
|
|
148
|
+
const down = this.pressed;
|
|
149
|
+
this.pressed = event.type === "press" ? index : undefined;
|
|
150
|
+
if (index === undefined)
|
|
151
|
+
return;
|
|
152
|
+
this.selected = index;
|
|
153
|
+
if (event.type === "click" && down === index)
|
|
154
|
+
this.finish(this.options.options?.[index]);
|
|
155
|
+
return { handled: true };
|
|
156
|
+
}
|
|
134
157
|
if (event.type !== "wheel" || event.wheelDelta === undefined || this.maxScroll === 0)
|
|
135
158
|
return undefined;
|
|
136
159
|
this.scrollBy(event.wheelDelta);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
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
|
-
import { basename, join, resolve } from "node:path";
|
|
4
|
+
import { basename, delimiter, dirname, join, resolve } from "node:path";
|
|
5
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";
|
|
@@ -94,6 +94,10 @@ export function agentEnvironment(moduleDir, options = {}) {
|
|
|
94
94
|
if (ALLOWED.includes(key) || ALLOWED_PREFIXES.some((prefix) => key.startsWith(prefix)))
|
|
95
95
|
env[key] = value;
|
|
96
96
|
}
|
|
97
|
+
// The caller's activated venv is not an agent toolchain. Its bin is on PATH but its config and site-packages are outside
|
|
98
|
+
// the fence. Use the next installed Python; an agent may still create and activate its own venv inside its workspace.
|
|
99
|
+
if (env.PATH)
|
|
100
|
+
env.PATH = env.PATH.split(delimiter).filter((dir) => !(["bin", "scripts"].includes(basename(dir).toLowerCase()) && existsSync(join(dirname(dir), "pyvenv.cfg")))).join(delimiter);
|
|
97
101
|
for (const [key, inHome] of Object.entries(TOOLCHAIN_LOCATORS)) {
|
|
98
102
|
const given = hostEnv[key];
|
|
99
103
|
if (given !== undefined && given !== "")
|
|
@@ -54,12 +54,50 @@ const INSTALLER_FILE = /\.(run|pkg|msi|dmg)$/i;
|
|
|
54
54
|
function words(segment) {
|
|
55
55
|
return (segment.match(/"[^"]*"|'[^']*'|[^\s"']+(?:(?:"[^"]*"|'[^']*')[^\s"']*)*/g) ?? []).map((word) => word.replace(/"([^"]*)"|'([^']*)'/g, "$1$2"));
|
|
56
56
|
}
|
|
57
|
-
/**
|
|
57
|
+
/**
|
|
58
|
+
* The simple commands a command line is made of, in order: split on `;`, `&&`, `||`, `|`, `&`, newlines and subshells
|
|
59
|
+
* where the shell reads them - not in a string, so `grep "a\|b.run"` is one command - each cut from the command itself.
|
|
60
|
+
* A here-document's body that is a file's text is none.
|
|
61
|
+
*/
|
|
58
62
|
function segments(command) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
+
const code = shellCode(command);
|
|
64
|
+
const found = [];
|
|
65
|
+
let start = 0;
|
|
66
|
+
const cut = (end) => {
|
|
67
|
+
if (code.slice(start, end).trim() !== "")
|
|
68
|
+
found.push(command.slice(start, end).trim());
|
|
69
|
+
};
|
|
70
|
+
for (const match of code.matchAll(/&&|\|\||[;|&\n()`]|\$\(/g)) {
|
|
71
|
+
cut(match.index);
|
|
72
|
+
start = match.index + match[0].length;
|
|
73
|
+
}
|
|
74
|
+
cut(code.length);
|
|
75
|
+
return found;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* The simple commands a command line runs: its own, and those of each script it hands a shell as a word - `bash -c
|
|
79
|
+
* "cd app; pip install --user x"`, `eval "..."` - which a string hides from the shell reading the line.
|
|
80
|
+
*/
|
|
81
|
+
function simpleCommands(command, depth = 0) {
|
|
82
|
+
const own = segments(command);
|
|
83
|
+
if (depth >= 3)
|
|
84
|
+
return own;
|
|
85
|
+
return own.flatMap((segment) => {
|
|
86
|
+
const script = scriptOf(segment);
|
|
87
|
+
return script === undefined ? [segment] : [segment, ...simpleCommands(script, depth + 1)];
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
/** The script a simple command hands a shell to run: `sh -c '<script>'`, `bash -lc "<script>"`, `eval <script>`. */
|
|
91
|
+
function scriptOf(segment) {
|
|
92
|
+
const found = programOf(segment);
|
|
93
|
+
if (found === undefined)
|
|
94
|
+
return undefined;
|
|
95
|
+
if (found.program === "eval")
|
|
96
|
+
return found.args.length > 0 ? found.args.join(" ") : undefined;
|
|
97
|
+
if (!/^(ba|z|da|k)?sh$/.test(found.program))
|
|
98
|
+
return undefined;
|
|
99
|
+
const at = found.args.findIndex((arg) => /^-[a-zA-Z]*c[a-zA-Z]*$/.test(arg));
|
|
100
|
+
return at === -1 ? undefined : found.args[at + 1];
|
|
63
101
|
}
|
|
64
102
|
/** A simple command's program and arguments, past assignments, wrappers and their own options. */
|
|
65
103
|
function programOf(segment) {
|
|
@@ -169,9 +207,9 @@ function systemSettingIn(segment) {
|
|
|
169
207
|
* an agent, not the chat, not a launch - what the machine lacks is the person's to install, in their own words.
|
|
170
208
|
*/
|
|
171
209
|
export function machineChange(command) {
|
|
172
|
-
if (
|
|
210
|
+
if (runsDownload(command))
|
|
173
211
|
return "it runs a script downloaded from the web";
|
|
174
|
-
for (const segment of
|
|
212
|
+
for (const segment of simpleCommands(command)) {
|
|
175
213
|
const why = installIn(segment) ?? systemSettingIn(segment);
|
|
176
214
|
if (why !== undefined)
|
|
177
215
|
return why;
|
|
@@ -241,9 +279,40 @@ export function machineChangeReason(why) {
|
|
|
241
279
|
"the same tool (python for python3), a version manager's folder - and use it, or give the person the exact command to " +
|
|
242
280
|
"run themselves, and go on once they say it is done.");
|
|
243
281
|
}
|
|
244
|
-
/** Downloads run as programs: a script piped to a shell, or run from a download. */
|
|
245
|
-
const PIPED_DOWNLOAD = /\b(curl|wget)\b[^|;&\n]*\|\s*(sudo\s+(
|
|
282
|
+
/** Downloads run as programs: a script piped to a shell or an interpreter, or run from a download. */
|
|
283
|
+
const PIPED_DOWNLOAD = /\b(?:curl|wget)\b[^|;&\n]*\|\s*(?:sudo\s+(?:-\S+\s+)*)?((?:ba|z|da|k)?sh|python[\d.]*|perl|ruby|node)\b([^|;&\n]*)/g;
|
|
246
284
|
const RUN_DOWNLOAD = /\b(ba|z|da|k)?sh\s+(-\w+\s+)*["']?\$\(\s*(curl|wget)\b|<\(\s*(curl|wget)\b/;
|
|
285
|
+
/**
|
|
286
|
+
* The option that gives an interpreter its code on the command line, so what is piped to it is data it reads - `curl
|
|
287
|
+
* localhost:8000/links | python3 -c 'import json, sys; ...'`, `| python3 -m json.tool`, `| node -e`, `| perl -ne`.
|
|
288
|
+
*/
|
|
289
|
+
const CODE_OPTIONS = [
|
|
290
|
+
[/^(ba|z|da|k)?sh$/, /^-[a-zA-Z]*c[a-zA-Z]*$/],
|
|
291
|
+
[/^python/, /^-[a-zA-Z]*[cm]$/],
|
|
292
|
+
[/^node$/, /^(-[a-zA-Z]*[ep][a-zA-Z]*|--eval|--print)$/],
|
|
293
|
+
[/^(perl|ruby)$/, /^-[a-zA-Z]*[eE][a-zA-Z]*$/],
|
|
294
|
+
];
|
|
295
|
+
/** Whether a command line runs what it downloads: piped to a shell or an interpreter that runs it, or run from it. */
|
|
296
|
+
function runsDownload(command) {
|
|
297
|
+
if (RUN_DOWNLOAD.test(command))
|
|
298
|
+
return true;
|
|
299
|
+
for (const match of shellCode(command).matchAll(PIPED_DOWNLOAD)) {
|
|
300
|
+
const interpreter = match[1];
|
|
301
|
+
const options = [];
|
|
302
|
+
for (const word of words(match[2])) {
|
|
303
|
+
if (!word.startsWith("-") || word === "-")
|
|
304
|
+
break;
|
|
305
|
+
options.push(word);
|
|
306
|
+
}
|
|
307
|
+
const code = CODE_OPTIONS.find(([program]) => program.test(interpreter))?.[1];
|
|
308
|
+
if (code === undefined || !options.some((option) => code.test(option)))
|
|
309
|
+
return true;
|
|
310
|
+
}
|
|
311
|
+
return simpleCommands(command).some((segment) => {
|
|
312
|
+
const script = scriptOf(segment);
|
|
313
|
+
return script !== undefined && script !== command && runsDownload(script);
|
|
314
|
+
});
|
|
315
|
+
}
|
|
247
316
|
/** Killing by name, or by what holds a port. */
|
|
248
317
|
const KILL_BY_LOOKUP = /\bkill\b[^;&|\n]*(\$\(|`)\s*(lsof|fuser|pgrep|pidof|ss|netstat)\b/;
|
|
249
318
|
const LOOKUP_TO_KILL = /\b(lsof|pgrep|pidof|fuser|ss|netstat)\b[^;&\n]*\|\s*xargs\s+(-\S+\s+)*kill\b/;
|
|
@@ -452,11 +521,11 @@ export function checkCommand(command, fence) {
|
|
|
452
521
|
return refusal("record", `${RECORD_FILE} is the harness's record of what the code is built from: no agent reads or writes it, and nothing in it is yours to go by.`);
|
|
453
522
|
}
|
|
454
523
|
// Installs and kills, a simple command at a time; downloads run as programs, on the whole line.
|
|
455
|
-
if (
|
|
524
|
+
if (runsDownload(command))
|
|
456
525
|
return refusal("install", installReason("it runs a script downloaded from the web"));
|
|
457
526
|
if (KILL_BY_LOOKUP.test(command) || LOOKUP_TO_KILL.test(command))
|
|
458
527
|
return refusal("kill", killReason());
|
|
459
|
-
for (const segment of
|
|
528
|
+
for (const segment of simpleCommands(command)) {
|
|
460
529
|
const why = installIn(segment);
|
|
461
530
|
if (why !== undefined)
|
|
462
531
|
return refusal("install", installReason(why));
|