@turri-dev/core 0.1.1-next.35d4c49 → 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
|
@@ -325,36 +325,54 @@ const DATA_SINKS = new Set(["cat", "tee"]);
|
|
|
325
325
|
* newlines put out of the way - a `>` in `grep "</content>"` redirects nothing, a `;` in a string ends no command - and
|
|
326
326
|
* the body of a here-document fed to cat or tee with a quoted delimiter, so not expanded, is blanked: it is the text of
|
|
327
327
|
* a file being written, and a `../lib/logger` or a `>` in it is code, not a path or a redirection. A `$(...)` in double
|
|
328
|
-
* quotes, an unquoted delimiter's body and a here-document fed to
|
|
329
|
-
*
|
|
328
|
+
* quotes, an unquoted delimiter's body and a here-document fed to a shell run as shell, and are read as they are. One
|
|
329
|
+
* with a quoted delimiter fed to anything else - `python3 - <<'EOF'`, `node`, `ruby` - is that program's code, never the
|
|
330
|
+
* shell's: its operators are put out of the way, and its quotes, so they leave the shell's reading of the rest alone -
|
|
331
|
+
* `bodies` says where each is, a program's paths to be checked and nothing else.
|
|
330
332
|
*/
|
|
331
|
-
|
|
333
|
+
function readShell(command) {
|
|
332
334
|
const lines = command.split("\n");
|
|
333
|
-
|
|
335
|
+
let code = "";
|
|
336
|
+
/** The shell's own text since the last program's body: read as one, a string spanning lines and all. */
|
|
337
|
+
let shell = "";
|
|
338
|
+
const bodies = [];
|
|
339
|
+
const line = (index) => lines[index] + (index < lines.length - 1 ? "\n" : "");
|
|
334
340
|
for (let index = 0; index < lines.length; index += 1) {
|
|
335
|
-
|
|
336
|
-
out.push(line);
|
|
341
|
+
shell += line(index);
|
|
337
342
|
// The here-documents this line opens, in order: each body runs to its delimiter alone on a line.
|
|
338
343
|
const opened = [];
|
|
339
|
-
for (const match of maskQuotes(
|
|
344
|
+
for (const match of maskQuotes(lines[index]).matchAll(HEREDOC)) {
|
|
340
345
|
const quoted = match[2] ?? match[3];
|
|
341
|
-
const before =
|
|
346
|
+
const before = lines[index].slice(0, match.index).split(/&&|\|\||[;|]/).pop() ?? "";
|
|
342
347
|
const program = programOf(before)?.program;
|
|
343
|
-
|
|
348
|
+
const body = quoted === undefined || program === undefined || /^(ba|z|da|k)?sh$/.test(program) ? "shell" : DATA_SINKS.has(program) ? "data" : "program";
|
|
349
|
+
opened.push({ delimiter: quoted ?? match[4], strip: match[1] === "-", body });
|
|
344
350
|
}
|
|
345
351
|
for (const heredoc of opened) {
|
|
346
352
|
while (index + 1 < lines.length) {
|
|
347
353
|
index += 1;
|
|
348
|
-
const
|
|
349
|
-
if ((heredoc.strip ?
|
|
350
|
-
|
|
354
|
+
const text = lines[index];
|
|
355
|
+
if ((heredoc.strip ? text.replace(/^\t+/, "") : text) === heredoc.delimiter) {
|
|
356
|
+
shell += line(index);
|
|
351
357
|
break;
|
|
352
358
|
}
|
|
353
|
-
|
|
359
|
+
if (heredoc.body === "shell")
|
|
360
|
+
shell += line(index);
|
|
361
|
+
else if (heredoc.body === "data")
|
|
362
|
+
shell += line(index).replace(/[^\n]/g, " ");
|
|
363
|
+
else {
|
|
364
|
+
code += maskQuotes(shell);
|
|
365
|
+
shell = "";
|
|
366
|
+
bodies.push({ from: code.length, to: code.length + line(index).length });
|
|
367
|
+
code += line(index).replace(/[<>|&;'"`]/g, " ");
|
|
368
|
+
}
|
|
354
369
|
}
|
|
355
370
|
}
|
|
356
371
|
}
|
|
357
|
-
return maskQuotes(
|
|
372
|
+
return { code: code + maskQuotes(shell), bodies };
|
|
373
|
+
}
|
|
374
|
+
export function shellCode(command) {
|
|
375
|
+
return readShell(command).code;
|
|
358
376
|
}
|
|
359
377
|
/** `text` with what its quotes hold out of the shell's way: operators and newlines in a string are a space each. */
|
|
360
378
|
function maskQuotes(text) {
|
|
@@ -413,29 +431,43 @@ class Paths {
|
|
|
413
431
|
return roots.some((root) => this.within(target, root));
|
|
414
432
|
}
|
|
415
433
|
}
|
|
416
|
-
/**
|
|
417
|
-
|
|
434
|
+
/**
|
|
435
|
+
* A word with its `~` and variables put in: `$HOME` and `$TMPDIR` as the fence has them, and what the command line set
|
|
436
|
+
* itself before it (`D=$TMPDIR/t; cd $D`). Nothing when a variable cannot be known - one from outside the line, one set
|
|
437
|
+
* to `$(...)` - or the word is worked out at run time.
|
|
438
|
+
*/
|
|
439
|
+
function expanded(word, fence, known) {
|
|
418
440
|
let path = word;
|
|
419
|
-
const home = fence.home;
|
|
420
441
|
if (path === "~" || path.startsWith("~/")) {
|
|
421
|
-
if (home === undefined)
|
|
442
|
+
if (fence.home === undefined)
|
|
422
443
|
return undefined;
|
|
423
|
-
path = home + path.slice(1);
|
|
444
|
+
path = fence.home + path.slice(1);
|
|
424
445
|
}
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
446
|
+
let unknown = false;
|
|
447
|
+
path = path.replace(/\$\{([A-Za-z_]\w*)\}|\$([A-Za-z_]\w*)/g, (_whole, braced, bare) => {
|
|
448
|
+
const name = braced ?? bare;
|
|
449
|
+
const value = name === "HOME" ? fence.home : name === "TMPDIR" ? fence.tmp : known.get(name);
|
|
450
|
+
if (value === undefined)
|
|
451
|
+
unknown = true;
|
|
452
|
+
return value ?? "";
|
|
453
|
+
});
|
|
454
|
+
// A variable we cannot know, a substitution or a glob: told apart at run time, by the sandbox.
|
|
455
|
+
return unknown || /[$`]/.test(path) ? undefined : path;
|
|
456
|
+
}
|
|
457
|
+
/** What a word that names a path names, from `cwd`; nothing when it cannot be told - from a folder the line cannot tell, too. */
|
|
458
|
+
function resolveWord(word, cwd, fence, paths, known = new Map()) {
|
|
459
|
+
const path = expanded(word, fence, known);
|
|
460
|
+
if (path === undefined || (cwd === undefined && !paths.path.isAbsolute(path)))
|
|
437
461
|
return undefined;
|
|
438
|
-
return paths.path.resolve(cwd, path);
|
|
462
|
+
return paths.path.resolve(cwd ?? "", path);
|
|
463
|
+
}
|
|
464
|
+
/** The variables a simple command sets, when that is all it does: `D=$TMPDIR/t1`, `export A=1 B=2`. */
|
|
465
|
+
function assignments(segment) {
|
|
466
|
+
const all = words(segment);
|
|
467
|
+
const set = all[0] === "export" ? all.slice(1) : all;
|
|
468
|
+
if (set.length === 0 || !set.every((word) => /^[A-Za-z_]\w*=/.test(word)))
|
|
469
|
+
return undefined;
|
|
470
|
+
return set.map((word) => [word.slice(0, word.indexOf("=")), word.slice(word.indexOf("=") + 1)]);
|
|
439
471
|
}
|
|
440
472
|
/** The words of a command that name paths: absolute, home- or TMPDIR-relative, or climbing with `..` - in quotes too. */
|
|
441
473
|
function pathWords(text, paths, fence) {
|
|
@@ -479,6 +511,20 @@ function pathWords(text, paths, fence) {
|
|
|
479
511
|
return KNOWN_TOPS.has(top) || fenceTops.has(top) || existsSync(`/${top}`);
|
|
480
512
|
});
|
|
481
513
|
}
|
|
514
|
+
/**
|
|
515
|
+
* The options of the programs that write which take the next word as their value - a size, a mode, a date, a reference
|
|
516
|
+
* file - never a file written: `truncate -s 1073741825 big.mp4` writes big.mp4 alone. `-t` names the folder cp, mv,
|
|
517
|
+
* install and ln write into.
|
|
518
|
+
*/
|
|
519
|
+
const VALUE_OPTIONS = {
|
|
520
|
+
truncate: ["-s", "-r"],
|
|
521
|
+
touch: ["-t", "-d", "-r"],
|
|
522
|
+
mkdir: ["-m"],
|
|
523
|
+
install: ["-m", "-o", "-g", "-S", "-t"],
|
|
524
|
+
cp: ["-S", "-t"],
|
|
525
|
+
mv: ["-S", "-t"],
|
|
526
|
+
ln: ["-S", "-t"],
|
|
527
|
+
};
|
|
482
528
|
/** The words a simple command writes to: redirections, tee, the target of cp and mv, a file edited in place. */
|
|
483
529
|
function writeTargets(segment) {
|
|
484
530
|
const targets = [];
|
|
@@ -490,9 +536,24 @@ function writeTargets(segment) {
|
|
|
490
536
|
if (found === undefined)
|
|
491
537
|
continue;
|
|
492
538
|
const { program, args } = found;
|
|
493
|
-
// A redirection among its words - `2>/dev/null`, `>out.txt` - is the shell's, read above: never an operand
|
|
494
|
-
|
|
495
|
-
|
|
539
|
+
// A redirection among its words - `2>/dev/null`, `>out.txt` - is the shell's, read above: never an operand; nor is an
|
|
540
|
+
// option's value.
|
|
541
|
+
const valued = VALUE_OPTIONS[program] ?? [];
|
|
542
|
+
const operands = [];
|
|
543
|
+
let into;
|
|
544
|
+
for (let at = 0; at < args.length; at += 1) {
|
|
545
|
+
const arg = args[at];
|
|
546
|
+
if (valued.includes(arg)) {
|
|
547
|
+
if (arg === "-t" && program !== "touch")
|
|
548
|
+
into = args[at + 1];
|
|
549
|
+
at += 1;
|
|
550
|
+
}
|
|
551
|
+
else if (!arg.startsWith("-") && !/^(\d|&)?[<>]/.test(arg))
|
|
552
|
+
operands.push(arg);
|
|
553
|
+
}
|
|
554
|
+
if (into !== undefined)
|
|
555
|
+
targets.push(into);
|
|
556
|
+
else if (program === "tee")
|
|
496
557
|
targets.push(...operands);
|
|
497
558
|
else if ((program === "cp" || program === "mv" || program === "install" || program === "ln") && operands.length >= 2)
|
|
498
559
|
targets.push(operands[operands.length - 1]);
|
|
@@ -537,30 +598,49 @@ export function checkCommand(command, fence) {
|
|
|
537
598
|
return refusal("kill", killReason());
|
|
538
599
|
}
|
|
539
600
|
}
|
|
540
|
-
// Paths, a simple command at a time from where the cds before it left it - read as the shell reads its operators
|
|
601
|
+
// Paths, a simple command at a time from where the cds before it left it - read as the shell reads its operators, with
|
|
602
|
+
// the variables the line set itself. A cd the line cannot tell - `cd "$(mktemp -d)"` - leaves the folder unknown: what
|
|
603
|
+
// is named from it is told apart at run time, by the sandbox. A program's here-document is checked for its paths alone.
|
|
604
|
+
const { code, bodies } = readShell(command);
|
|
605
|
+
const known = new Map();
|
|
541
606
|
let cwd = fence.cwd;
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
607
|
+
const outside = (word) => {
|
|
608
|
+
const target = resolveWord(word, cwd, fence, paths, known);
|
|
609
|
+
if (target === undefined || paths.inside(target, readable))
|
|
610
|
+
return undefined;
|
|
611
|
+
return refusal("path", `\`${word}\` is outside what this command may reach (${target}). ${reach(fence)} Everything you need from outside them is in your prompt.`);
|
|
612
|
+
};
|
|
613
|
+
let at = 0;
|
|
614
|
+
for (const body of [...bodies, { from: code.length, to: code.length }]) {
|
|
615
|
+
for (const segment of code.slice(at, body.from).split(/&&|\|\||[;\n]/)) {
|
|
616
|
+
for (const word of pathWords(segment, paths, fence)) {
|
|
617
|
+
const refused = outside(word);
|
|
618
|
+
if (refused !== undefined)
|
|
619
|
+
return refused;
|
|
547
620
|
}
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
621
|
+
for (const word of writeTargets(segment)) {
|
|
622
|
+
if (isCredentialFile(word)) {
|
|
623
|
+
return refusal("credential", `${word.split(/[\\/]/).pop()} holds credentials, and they are the person's to provide - never an agent's to write, not even a placeholder. If the software needs one that is missing, say so and name the variable.`);
|
|
624
|
+
}
|
|
625
|
+
const target = resolveWord(word, cwd, fence, paths, known);
|
|
626
|
+
if (target !== undefined && !paths.inside(target, writable)) {
|
|
627
|
+
return refusal("path", `\`${word}\` is outside what this command may write (${target}). ${reach(fence)}`);
|
|
628
|
+
}
|
|
552
629
|
}
|
|
553
|
-
const
|
|
554
|
-
|
|
555
|
-
|
|
630
|
+
for (const [name, value] of assignments(segment) ?? [])
|
|
631
|
+
known.set(name, expanded(value, fence, known));
|
|
632
|
+
const cd = programOf(segment);
|
|
633
|
+
if (cd?.program === "cd") {
|
|
634
|
+
const [to, ...more] = cd.args.filter((arg) => !/^-[LPe@]+$/.test(arg));
|
|
635
|
+
cwd = more.length > 0 || to === "-" ? undefined : to === undefined ? fence.home : resolveWord(to, cwd, fence, paths, known);
|
|
556
636
|
}
|
|
557
637
|
}
|
|
558
|
-
const
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
cwd = to;
|
|
638
|
+
for (const word of pathWords(code.slice(body.from, body.to), paths, fence)) {
|
|
639
|
+
const refused = outside(word);
|
|
640
|
+
if (refused !== undefined)
|
|
641
|
+
return refused;
|
|
563
642
|
}
|
|
643
|
+
at = body.to;
|
|
564
644
|
}
|
|
565
645
|
return { ok: true };
|
|
566
646
|
}
|
|
@@ -4,7 +4,11 @@ export declare function conversationWriting(paths: string[]): () => void;
|
|
|
4
4
|
export declare function conversationCommand(): () => void;
|
|
5
5
|
/** The conversation's turn is over: nothing of its is in progress any more. */
|
|
6
6
|
export declare function conversationSettled(): void;
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* Whether the conversation may have written this file since `since` - a write of its to it, or a command of its own.
|
|
9
|
+
* One that ended in the millisecond `since` names may have come after it: the clock tells them apart no finer, and the
|
|
10
|
+
* person's edit is never undone on a guess.
|
|
11
|
+
*/
|
|
8
12
|
export declare function writtenByConversation(path: string, since: number): boolean;
|
|
9
13
|
/** For tests: forget everything. */
|
|
10
14
|
export declare function resetConversationWrites(): void;
|
|
@@ -80,16 +80,20 @@ export function conversationSettled() {
|
|
|
80
80
|
lastCommandEnd = now;
|
|
81
81
|
commands.clear();
|
|
82
82
|
}
|
|
83
|
-
/**
|
|
83
|
+
/**
|
|
84
|
+
* Whether the conversation may have written this file since `since` - a write of its to it, or a command of its own.
|
|
85
|
+
* One that ended in the millisecond `since` names may have come after it: the clock tells them apart no finer, and the
|
|
86
|
+
* person's edit is never undone on a guess.
|
|
87
|
+
*/
|
|
84
88
|
export function writtenByConversation(path, since) {
|
|
85
89
|
const now = Date.now();
|
|
86
90
|
const live = (running) => now - running.started < STALE_MS;
|
|
87
|
-
if ([...commands].some(live) || lastCommandEnd
|
|
91
|
+
if ([...commands].some(live) || lastCommandEnd >= since)
|
|
88
92
|
return true;
|
|
89
93
|
const key = canonical(path);
|
|
90
94
|
if ([...(writing.get(key) ?? [])].some(live))
|
|
91
95
|
return true;
|
|
92
|
-
return (wrote.get(key) ?? 0)
|
|
96
|
+
return (wrote.get(key) ?? 0) >= since;
|
|
93
97
|
}
|
|
94
98
|
/** For tests: forget everything. */
|
|
95
99
|
export function resetConversationWrites() {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type AgentTally, type BuildingSpec, type SpecConflict, type TranscriptEntry, type UsageReport } from "./activity.ts";
|
|
2
|
+
import type { SpecGap } from "./notes.ts";
|
|
2
3
|
/**
|
|
3
4
|
* Background jobs for conversation mode.
|
|
4
5
|
*
|
|
@@ -104,7 +105,7 @@ export interface Job {
|
|
|
104
105
|
/** What to tell the person when it lands, if shorter than the report. */
|
|
105
106
|
announce?: string;
|
|
106
107
|
error?: string;
|
|
107
|
-
details?:
|
|
108
|
+
details?: JobDetails;
|
|
108
109
|
/**
|
|
109
110
|
* A pulse of an earlier session, as the ledger recorded it - not this session's registry's: shown, never run, halted or
|
|
110
111
|
* waited for. Its run, how and when that run was started, and what the ledger says of it, a line each.
|
|
@@ -122,7 +123,29 @@ export interface JobOutcome {
|
|
|
122
123
|
* can carry detail it needs and the person does not; omitted, the report is shown.
|
|
123
124
|
*/
|
|
124
125
|
announce?: string;
|
|
125
|
-
details?:
|
|
126
|
+
details?: JobDetails;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* What a job's work says of how it went, beside its report - what turri reads to decide what comes next, and a front end
|
|
130
|
+
* to draw it. Each is optional: a job sets those of its kind, and one of an earlier turri may lack any.
|
|
131
|
+
*/
|
|
132
|
+
export interface JobDetails {
|
|
133
|
+
/** It ran to its end and what it built passed its gate. */
|
|
134
|
+
passed?: boolean;
|
|
135
|
+
/** What it built landed: committed in the codebase's history. */
|
|
136
|
+
landed?: boolean;
|
|
137
|
+
/** It had nothing to do, and did nothing: not a failure. */
|
|
138
|
+
skipped?: boolean;
|
|
139
|
+
/** Where its gate stopped one that did not pass. */
|
|
140
|
+
stoppedAt?: "unit tests" | "conformance" | "regression";
|
|
141
|
+
/** A conformance pulse not started: what it was to test is not built - said as a sentence. */
|
|
142
|
+
notBuilt?: string;
|
|
143
|
+
/** How a code pulse went, for its line in the notes: its rounds and test runs. */
|
|
144
|
+
story?: string;
|
|
145
|
+
/** Where the spec said nothing and its agents chose: a question and the assumption made, each. */
|
|
146
|
+
specGaps?: SpecGap[];
|
|
147
|
+
/** The commit it landed on. */
|
|
148
|
+
commit?: string;
|
|
126
149
|
}
|
|
127
150
|
export interface StartJobInput {
|
|
128
151
|
kind: string;
|
package/dist/regenerate/jobs.js
CHANGED
|
@@ -260,6 +260,9 @@ export function createJobRegistry(options) {
|
|
|
260
260
|
continue;
|
|
261
261
|
}
|
|
262
262
|
job.failedForGood = true;
|
|
263
|
+
// What its last attempt said of itself - where its gate stopped it - stays with the job that failed.
|
|
264
|
+
if (outcome?.details !== undefined)
|
|
265
|
+
job.details = outcome.details;
|
|
263
266
|
if (options?.diagnose !== undefined) {
|
|
264
267
|
sink.stage("the pulse failed again - working out why, and what has to be done");
|
|
265
268
|
job.diagnosis = await withActivity(sink, () => healing("diagnosis", () => options.diagnose(job, failures, log?.file), (found) => found));
|
|
@@ -157,6 +157,7 @@ export declare function runningLaunched(moduleName?: string): LaunchedProcess[];
|
|
|
157
157
|
*/
|
|
158
158
|
export declare function followLaunchedLogs(onLine: (name: string, line: string) => void, options?: {
|
|
159
159
|
pollMs?: number;
|
|
160
|
+
signal?: AbortSignal;
|
|
160
161
|
}): Promise<void>;
|
|
161
162
|
/** Where what a project's launches started write their output: its scratch, not the code in dist. */
|
|
162
163
|
export declare function launchLogDir(projectDir: string): string;
|
|
@@ -299,6 +299,11 @@ export function runningLaunched(moduleName) {
|
|
|
299
299
|
export function followLaunchedLogs(onLine, options = {}) {
|
|
300
300
|
const offsets = new Map();
|
|
301
301
|
return new Promise((done) => {
|
|
302
|
+
// Stopped from outside: followed no further.
|
|
303
|
+
options.signal?.addEventListener("abort", () => {
|
|
304
|
+
clearInterval(timer);
|
|
305
|
+
done();
|
|
306
|
+
}, { once: true });
|
|
302
307
|
const tick = () => {
|
|
303
308
|
const running = runningLaunched();
|
|
304
309
|
for (const item of listLaunched()) {
|
|
@@ -326,6 +331,10 @@ export function followLaunchedLogs(onLine, options = {}) {
|
|
|
326
331
|
}
|
|
327
332
|
};
|
|
328
333
|
const timer = setInterval(tick, options.pollMs ?? 500);
|
|
334
|
+
if (options.signal?.aborted === true) {
|
|
335
|
+
clearInterval(timer);
|
|
336
|
+
done();
|
|
337
|
+
}
|
|
329
338
|
});
|
|
330
339
|
}
|
|
331
340
|
/** Where what a project's launches started write their output: its scratch, not the code in dist. */
|
|
@@ -5,7 +5,8 @@ import { type LedgerEntry } from "./ledger.ts";
|
|
|
5
5
|
* What the ledger says of pulses, read back: one pulse - from this session or an earlier one - as the chat and
|
|
6
6
|
* a host are told it, and the runs a project has had, each with its pulses.
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
/** The ledger's entry of one kind. */
|
|
9
|
+
export type LedgerEntryOf<K extends LedgerEntry["kind"]> = Extract<LedgerEntry, {
|
|
9
10
|
kind: K;
|
|
10
11
|
}>;
|
|
11
12
|
/** The projects whose ledgers a folder's pulses may be in: its own, and those of the projects in folders under it. */
|
|
@@ -16,24 +17,24 @@ export interface PulseView {
|
|
|
16
17
|
run: string;
|
|
17
18
|
/** How its run was started - chat, host, regenerate - and when. */
|
|
18
19
|
runMode?: string;
|
|
19
|
-
queued?:
|
|
20
|
+
queued?: LedgerEntryOf<"job.queued"> & {
|
|
20
21
|
module?: string;
|
|
21
22
|
};
|
|
22
|
-
started?:
|
|
23
|
-
finished?:
|
|
23
|
+
started?: LedgerEntryOf<"job.started">;
|
|
24
|
+
finished?: LedgerEntryOf<"job.finished">;
|
|
24
25
|
/** Its ***plain diff as it last was, and how many times steering moved it. */
|
|
25
|
-
diff?:
|
|
26
|
+
diff?: LedgerEntryOf<"job.diff">;
|
|
26
27
|
steered: number;
|
|
27
28
|
stages: string[];
|
|
28
|
-
retried: Array<
|
|
29
|
+
retried: Array<LedgerEntryOf<"job.retried">>;
|
|
29
30
|
rounds: Map<string, {
|
|
30
31
|
round: number;
|
|
31
32
|
of: number;
|
|
32
33
|
}>;
|
|
33
|
-
scripts: Array<
|
|
34
|
+
scripts: Array<LedgerEntryOf<"script.run">>;
|
|
34
35
|
judge: Map<string, number>;
|
|
35
|
-
reviews: Array<
|
|
36
|
-
healers: Array<
|
|
36
|
+
reviews: Array<LedgerEntryOf<"review.verdict">>;
|
|
37
|
+
healers: Array<LedgerEntryOf<"healer.ended"> | LedgerEntryOf<"healer.failed">>;
|
|
37
38
|
provider: {
|
|
38
39
|
retries: number;
|
|
39
40
|
stalls: number;
|
|
@@ -41,8 +42,8 @@ export interface PulseView {
|
|
|
41
42
|
};
|
|
42
43
|
refused: Map<string, number>;
|
|
43
44
|
stopped: string[];
|
|
44
|
-
history: Array<
|
|
45
|
-
environment?:
|
|
45
|
+
history: Array<LedgerEntryOf<"history.committed"> | LedgerEntryOf<"history.failed"> | LedgerEntryOf<"history.reset"> | LedgerEntryOf<"history.rolledBack">>;
|
|
46
|
+
environment?: LedgerEntryOf<"environment.error">;
|
|
46
47
|
usage?: UsageReport;
|
|
47
48
|
}
|
|
48
49
|
/** A pulse's events, gathered: undefined when the ledger has none of it. `entries` are its run's, oldest first. */
|
|
@@ -65,8 +66,8 @@ export declare function describePastPulse(projects: string[], id: string, option
|
|
|
65
66
|
/** A run of the project's, and its pulses: runs and pulses the most recent first. */
|
|
66
67
|
export interface RunView {
|
|
67
68
|
run: string;
|
|
68
|
-
started?:
|
|
69
|
-
ended?:
|
|
69
|
+
started?: LedgerEntryOf<"run.started">;
|
|
70
|
+
ended?: LedgerEntryOf<"run.ended">;
|
|
70
71
|
pulses: PulseView[];
|
|
71
72
|
}
|
|
72
73
|
export declare function runViews(project: string): RunView[];
|
|
@@ -84,4 +85,3 @@ export declare function earlierPulses(projects: string[], known: Set<string>, ru
|
|
|
84
85
|
};
|
|
85
86
|
/** A pulse of the ledger's, as the lists show a job: finished as it ended, its time and cost - and nothing to run. */
|
|
86
87
|
export declare function asJob(view: PulseView): Job;
|
|
87
|
-
export {};
|
|
@@ -4,7 +4,7 @@ import { join, resolve } from "node:path";
|
|
|
4
4
|
import { gunzipSync, gzipSync } from "node:zlib";
|
|
5
5
|
import { currentChat } from "../chat-scope.js";
|
|
6
6
|
import { readProjectConfig } from "../config.js";
|
|
7
|
-
import {
|
|
7
|
+
import { clientIdentity } from "../client.js";
|
|
8
8
|
import { currentPlace, onModelEvent } from "./activity.js";
|
|
9
9
|
import { maskSecrets } from "./masking.js";
|
|
10
10
|
import { ensureInScratch } from "./paths.js";
|
|
@@ -208,11 +208,13 @@ function write(run, project, event, where) {
|
|
|
208
208
|
function openWriter(run, project) {
|
|
209
209
|
const keep = keepOf(project);
|
|
210
210
|
const dir = ledgerDir(project);
|
|
211
|
-
const identity =
|
|
211
|
+
const identity = clientIdentity();
|
|
212
212
|
seq += 1;
|
|
213
213
|
const started = {
|
|
214
214
|
kind: "run.started",
|
|
215
215
|
mode: run.mode,
|
|
216
|
+
// Whose version this is: the session's front end, else the core.
|
|
217
|
+
client: identity.name,
|
|
216
218
|
version: identity.version,
|
|
217
219
|
commit: identity.git_commit,
|
|
218
220
|
dirty: identity.git_dirty,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ChunkAgents } from "./chunk-plan.ts";
|
|
2
2
|
import { type SpecGap } from "./notes.ts";
|
|
3
|
-
import { type Job, type JobRegistry, type PulseCases } from "./jobs.ts";
|
|
3
|
+
import { type Job, type JobDetails, type JobRegistry, type PulseCases } from "./jobs.ts";
|
|
4
4
|
import { type ChainEntry } from "./requires.ts";
|
|
5
5
|
import { type SpecSnapshot } from "./regenerate.ts";
|
|
6
6
|
import { type JobSteering } from "./steering.ts";
|
|
@@ -54,6 +54,7 @@ export type JobRunner = (job: {
|
|
|
54
54
|
report: string;
|
|
55
55
|
story?: string;
|
|
56
56
|
specGaps?: SpecGap[];
|
|
57
|
+
stoppedAt?: NonNullable<JobDetails["stoppedAt"]>;
|
|
57
58
|
}>;
|
|
58
59
|
/** A codebase as the loop sees it, for the person. */
|
|
59
60
|
export interface ModuleStatus {
|
package/dist/regenerate/loop.js
CHANGED
|
@@ -657,6 +657,8 @@ export function createWorkLoop(options) {
|
|
|
657
657
|
...(result.story !== undefined ? { story: result.story } : {}),
|
|
658
658
|
// The spec gaps its agents met, for a headless run to say - in the chat the report puts them to the person.
|
|
659
659
|
...(result.specGaps !== undefined && result.specGaps.length > 0 ? { specGaps: result.specGaps } : {}),
|
|
660
|
+
// Where its gate stopped it - the cause said of a pulse that did not land.
|
|
661
|
+
...(result.stoppedAt !== undefined ? { stoppedAt: result.stoppedAt } : {}),
|
|
660
662
|
},
|
|
661
663
|
};
|
|
662
664
|
},
|
|
@@ -2041,7 +2043,12 @@ const defaultConformanceRunner = async (job, onDelta) => {
|
|
|
2041
2043
|
writeTestsRecord(result.conformanceDir, job.planned.step.tree);
|
|
2042
2044
|
landWork(job.buildDir, `conformance tests: ${job.planned.title}`);
|
|
2043
2045
|
}
|
|
2044
|
-
return {
|
|
2046
|
+
return {
|
|
2047
|
+
landed: result.passed,
|
|
2048
|
+
report: describeSpecDiffConformance(result),
|
|
2049
|
+
...(result.specGaps !== undefined ? { specGaps: result.specGaps } : {}),
|
|
2050
|
+
...(result.stoppedAt !== null ? { stoppedAt: result.stoppedAt } : {}),
|
|
2051
|
+
};
|
|
2045
2052
|
};
|
|
2046
2053
|
/** The functional specs a pulse covers, by case, each with the module whose spec it is: a host's to light and mark. */
|
|
2047
2054
|
export function pulseCases(cases, moduleName) {
|
|
@@ -2073,6 +2080,7 @@ const defaultRunner = async (job, onDelta) => {
|
|
|
2073
2080
|
// Landed code can be tried.
|
|
2074
2081
|
return { landed: result.passed, report: describeSpecDiff(result), story: codeStory(result),
|
|
2075
2082
|
...(result.specGaps !== undefined ? { specGaps: result.specGaps } : {}),
|
|
2083
|
+
...(result.stoppedAt !== null ? { stoppedAt: result.stoppedAt } : {}),
|
|
2076
2084
|
};
|
|
2077
2085
|
};
|
|
2078
2086
|
/** How a code pulse went, for its line in the notes: the rounds it took, its test runs, what the debugger found. */
|
|
@@ -87,7 +87,9 @@ export declare function sandboxWithAsync(env?: NodeJS.ProcessEnv): Promise<Wall>
|
|
|
87
87
|
/** Whether `path` is one of the fence's roots or under one - for the tests and the audit. */
|
|
88
88
|
export declare function underAny(path: string, roots: string[]): boolean;
|
|
89
89
|
/** Where the agents' commands run, in one line for the person: which walls are up, or that only the shared ones are. */
|
|
90
|
-
|
|
90
|
+
/** Where the agents' commands run, as the banner says it: the walls up, and why there is no OS sandbox when there is none. */
|
|
91
|
+
export interface SandboxSummary {
|
|
91
92
|
level: "ok" | "limited";
|
|
92
93
|
text: string;
|
|
93
|
-
}
|
|
94
|
+
}
|
|
95
|
+
export declare function sandboxSummary(wall?: Wall): SandboxSummary;
|
|
@@ -275,7 +275,6 @@ export function underAny(path, roots) {
|
|
|
275
275
|
return target === base || target.startsWith(base + sep);
|
|
276
276
|
});
|
|
277
277
|
}
|
|
278
|
-
/** Where the agents' commands run, in one line for the person: which walls are up, or that only the shared ones are. */
|
|
279
278
|
export function sandboxSummary(wall = sandboxAvailable()) {
|
|
280
279
|
if (wall.kind === "none")
|
|
281
280
|
return { level: "limited", text: `agents' commands run on this machine behind the command check and the audit - no OS sandbox: ${wall.why} (turri doctor)` };
|
|
@@ -29,7 +29,8 @@ import { conversationWriting } from "./conversation-writes.js";
|
|
|
29
29
|
import { resolveTemplateDirs } from "./paths.js";
|
|
30
30
|
import { copyRequiredCode, findCodebaseTip, newlyRequired } from "./requires.js";
|
|
31
31
|
import { baseOfCodebase, inCodebaseOf, seedFromBaseFolder } from "./base-folder.js";
|
|
32
|
-
import {
|
|
32
|
+
import { resourceFile } from "../plain/files.js";
|
|
33
|
+
import { createCopyResourceTool, loadLinkedResources, resourceImages } from "./resources.js";
|
|
33
34
|
import { markTold, waitingSteer } from "./steering.js";
|
|
34
35
|
import { misplacedConformanceTests, misplacedTestsPrompt } from "./test-kinds.js";
|
|
35
36
|
import { sectionsOf } from "./state.js";
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type ParseOptions } from "../plain/parser.ts";
|
|
2
|
+
/**
|
|
3
|
+
* A module's requires chain and a project's build order, from its .plain files alone - kept apart from what builds the
|
|
4
|
+
* chain's codebases, so what only reads ***plain (the parser's entry) loads none of the harness.
|
|
5
|
+
*/
|
|
6
|
+
export interface ChainEntry {
|
|
7
|
+
moduleName: string;
|
|
8
|
+
plainFile: string;
|
|
9
|
+
buildDir: string;
|
|
10
|
+
/** The module whose code is copied in before this one is built. */
|
|
11
|
+
requires: string | null;
|
|
12
|
+
funcIds: string[];
|
|
13
|
+
}
|
|
14
|
+
/** A required module's file: the first template folder that has it. */
|
|
15
|
+
export declare function locateModule(moduleName: string, templateDirs: string[]): string;
|
|
16
|
+
/**
|
|
17
|
+
* The chain to build, bottom first.
|
|
18
|
+
*
|
|
19
|
+
* Depth-first, post-order: everything a module requires is listed before the module
|
|
20
|
+
* itself. The parser has already rejected circular requires, and a module reached twice is
|
|
21
|
+
* emitted once.
|
|
22
|
+
*/
|
|
23
|
+
export declare function resolveRequiresChain(plainFile: string, templateDirs?: string[], buildRoot?: string,
|
|
24
|
+
/** Accept the named module without functional specs yet. Those it requires must have them. */
|
|
25
|
+
options?: ParseOptions): ChainEntry[];
|
|
26
|
+
/** Every .plain file in a project's folder, sorted - the modules a host lists. */
|
|
27
|
+
export declare function projectPlainFiles(projectDir: string): string[];
|
|
28
|
+
/**
|
|
29
|
+
* A project's .plain files in the order they are built: each after every module it requires, as its requires chain has
|
|
30
|
+
* them (`resolveRequiresChain`) - taken in the order given, by name without `files`, each brought in after what it
|
|
31
|
+
* requires. A module whose chain does not resolve - it does not parse, a module it requires is not there, a cycle - goes
|
|
32
|
+
* after what its front matter says it requires, as far as those are found. `files`, absolute or from the project: the
|
|
33
|
+
* ones to order, every other module of a chain left out; without it, every .plain file in the project's folder.
|
|
34
|
+
*/
|
|
35
|
+
export declare function requiresOrder(projectDir: string, options?: {
|
|
36
|
+
files?: string[];
|
|
37
|
+
}): string[];
|
|
38
|
+
/**
|
|
39
|
+
* Whether a .plain file is an import module - one a .plain file imports, or one kept in a `template/` folder - rather than
|
|
40
|
+
* a module of its own. It is no codebase: its reqs and definitions are built in the modules that import it.
|
|
41
|
+
*/
|
|
42
|
+
export declare function isImportModule(plainFile: string): boolean;
|
|
43
|
+
/** The modules of their own that import an import module, through any import modules between. */
|
|
44
|
+
export declare function importingModules(plainFile: string): string[];
|