@turri-dev/cli 0.2.4-next.8422d0f → 0.2.4-next.bc1fc47

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.
Files changed (112) hide show
  1. package/README.md +3 -3
  2. package/dist/chat-idle.d.ts +2 -2
  3. package/dist/chat-idle.js +2 -2
  4. package/dist/chats.d.ts +0 -10
  5. package/dist/chats.js +0 -23
  6. package/dist/cli.js +5 -7
  7. package/dist/config-edit.js +1 -3
  8. package/dist/config.d.ts +20 -22
  9. package/dist/config.js +49 -22
  10. package/dist/conform-cli.js +13 -2
  11. package/dist/conformance-switch.d.ts +7 -17
  12. package/dist/conformance-switch.js +24 -46
  13. package/dist/drift-cli.js +1 -1
  14. package/dist/extension.d.ts +8 -10
  15. package/dist/extension.js +188 -242
  16. package/dist/genome.js +9 -48
  17. package/dist/graph.js +3 -5
  18. package/dist/host-session.d.ts +4 -15
  19. package/dist/host-session.js +2 -4
  20. package/dist/host.d.ts +1 -3
  21. package/dist/host.js +1 -4
  22. package/dist/identity.js +0 -1
  23. package/dist/init-config.d.ts +0 -1
  24. package/dist/init-config.js +2 -9
  25. package/dist/installed-providers.d.ts +1 -1
  26. package/dist/installed-providers.js +1 -1
  27. package/dist/loop-cli.d.ts +4 -3
  28. package/dist/loop-cli.js +13 -11
  29. package/dist/loop-tools.d.ts +28 -5
  30. package/dist/loop-tools.js +87 -22
  31. package/dist/new-project.js +2 -2
  32. package/dist/pi-launch.js +1 -1
  33. package/dist/pi.js +9 -6
  34. package/dist/plain/check.d.ts +1 -8
  35. package/dist/plain/check.js +3 -38
  36. package/dist/regenerate/activity.d.ts +0 -7
  37. package/dist/regenerate/activity.js +2 -20
  38. package/dist/regenerate/agent-shell.js +3 -1
  39. package/dist/regenerate/audit.js +9 -0
  40. package/dist/regenerate/cases.js +7 -0
  41. package/dist/regenerate/chunk-plan.d.ts +5 -0
  42. package/dist/regenerate/chunk-plan.js +16 -1
  43. package/dist/regenerate/drift.d.ts +4 -0
  44. package/dist/regenerate/drift.js +26 -6
  45. package/dist/regenerate/failure-reports.d.ts +28 -0
  46. package/dist/regenerate/failure-reports.js +79 -0
  47. package/dist/regenerate/job-panel.js +3 -1
  48. package/dist/regenerate/jobs-tree.js +1 -1
  49. package/dist/regenerate/jobs.d.ts +2 -0
  50. package/dist/regenerate/jobs.js +4 -0
  51. package/dist/regenerate/ledger-view.d.ts +11 -24
  52. package/dist/regenerate/ledger-view.js +14 -60
  53. package/dist/regenerate/ledger.d.ts +1 -14
  54. package/dist/regenerate/ledger.js +1 -1
  55. package/dist/regenerate/loop.d.ts +46 -60
  56. package/dist/regenerate/loop.js +277 -116
  57. package/dist/regenerate/records.d.ts +11 -0
  58. package/dist/regenerate/records.js +15 -0
  59. package/dist/regenerate/regenerate.d.ts +0 -2
  60. package/dist/regenerate/regenerate.js +4 -15
  61. package/dist/regenerate/renames.js +4 -4
  62. package/dist/regenerate/requires.d.ts +7 -0
  63. package/dist/regenerate/requires.js +24 -18
  64. package/dist/regenerate/spec-map.js +3 -3
  65. package/dist/regenerate/standing.js +1 -1
  66. package/dist/regenerate/submit-work.d.ts +2 -0
  67. package/dist/regenerate/submit-work.js +8 -3
  68. package/dist/regenerate/testing-steps.d.ts +11 -0
  69. package/dist/regenerate/testing-steps.js +22 -3
  70. package/dist/regenerate-cli.js +18 -9
  71. package/dist/self-invocation.d.ts +11 -0
  72. package/dist/self-invocation.js +33 -7
  73. package/dist/sentinel.js +8 -5
  74. package/dist/skill.d.ts +0 -11
  75. package/dist/skill.js +0 -9
  76. package/dist/stacks.js +1 -1
  77. package/dist/tools.js +2 -3
  78. package/dist/turri-versions.js +2 -1
  79. package/docs/README.md +0 -2
  80. package/docs/authoring-plain.md +3 -3
  81. package/docs/chats.md +1 -3
  82. package/docs/config.md +11 -13
  83. package/docs/deploy.md +1 -1
  84. package/docs/development.md +2 -3
  85. package/docs/headless.md +6 -4
  86. package/docs/hosting.md +6 -6
  87. package/docs/parser.md +2 -2
  88. package/docs/regenerating.md +21 -13
  89. package/docs/sentinel.md +4 -4
  90. package/docs/skills-and-gates.md +4 -8
  91. package/docs/using.md +13 -21
  92. package/genome/rules/test-plain-files.md +15 -7
  93. package/genome/rules/turri-regeneration.md +4 -8
  94. package/genome/skills/convert-old-syntax/SKILL.md +5 -5
  95. package/package.json +1 -1
  96. package/dist/advisor-chat.d.ts +0 -63
  97. package/dist/advisor-chat.js +0 -290
  98. package/dist/change-plain-cli.d.ts +0 -1
  99. package/dist/change-plain-cli.js +0 -55
  100. package/dist/ledger-cli.d.ts +0 -1
  101. package/dist/ledger-cli.js +0 -50
  102. package/dist/ledger-tools.d.ts +0 -10
  103. package/dist/ledger-tools.js +0 -64
  104. package/dist/regenerate/advisor-records.d.ts +0 -93
  105. package/dist/regenerate/advisor-records.js +0 -110
  106. package/dist/regenerate/advisor-runs.d.ts +0 -87
  107. package/dist/regenerate/advisor-runs.js +0 -327
  108. package/dist/regenerate/test-advisor.d.ts +0 -101
  109. package/dist/regenerate/test-advisor.js +0 -379
  110. package/dist/spec-tools.d.ts +0 -36
  111. package/dist/spec-tools.js +0 -128
  112. package/docs/test-advisor.md +0 -110
@@ -24,6 +24,17 @@ export { RECORD_FILE } from "./paths.ts";
24
24
  export declare const REGENERATE_AGAIN = "regenerate_again";
25
25
  /** Whether a record's item is marked to regenerate again. */
26
26
  export declare function marksRegenerateAgain(item: unknown): boolean;
27
+ /**
28
+ * A functional spec in the tests record marked to have its conformance tests written again: they are written, and are
29
+ * to be written anew all the same - `conform` with functional specs named, or a module's from scratch. Its code is
30
+ * untouched. The mark makes the tests record differ from what the tests are to be written for at that item, so the
31
+ * work loop plans a conformance pulse for it, and the pulse that writes them writes the item back without it.
32
+ */
33
+ export declare const CONFORM_AGAIN = "conform_again";
34
+ /** Whether a tests record's item is marked to have its conformance tests written again. */
35
+ export declare function marksConformAgain(item: unknown): boolean;
36
+ /** Whether a tests record's item is not written for the code as it is now: marked with its code to regenerate again, or to be written again. */
37
+ export declare function marksTestsAgain(item: unknown): boolean;
27
38
  /**
28
39
  * Whether a functional spec has scenarios - conformance or acceptance - and so is tested: one with an empty test plain
29
40
  * file is not.
@@ -32,6 +32,21 @@ export const REGENERATE_AGAIN = "regenerate_again";
32
32
  export function marksRegenerateAgain(item) {
33
33
  return typeof item === "object" && item !== null && item[REGENERATE_AGAIN] === true;
34
34
  }
35
+ /**
36
+ * A functional spec in the tests record marked to have its conformance tests written again: they are written, and are
37
+ * to be written anew all the same - `conform` with functional specs named, or a module's from scratch. Its code is
38
+ * untouched. The mark makes the tests record differ from what the tests are to be written for at that item, so the
39
+ * work loop plans a conformance pulse for it, and the pulse that writes them writes the item back without it.
40
+ */
41
+ export const CONFORM_AGAIN = "conform_again";
42
+ /** Whether a tests record's item is marked to have its conformance tests written again. */
43
+ export function marksConformAgain(item) {
44
+ return typeof item === "object" && item !== null && item[CONFORM_AGAIN] === true;
45
+ }
46
+ /** Whether a tests record's item is not written for the code as it is now: marked with its code to regenerate again, or to be written again. */
47
+ export function marksTestsAgain(item) {
48
+ return marksRegenerateAgain(item) || marksConformAgain(item);
49
+ }
35
50
  const itemsOf = (tree, heading) => (tree?.[heading] ?? []).slice();
36
51
  /** A tree without the sections it has nothing in, as the parser leaves them out. */
37
52
  function withoutEmpty(tree) {
@@ -10,8 +10,6 @@ import { type TestRemoval, type TestRun, type MissingToolchain } from "./testing
10
10
  * one that fits neither way is refused: rendering it would mean guessing.
11
11
  */
12
12
  export declare function applySpecDiff(diff: string, cwd: string): "applied" | "already applied";
13
- /** Undo a spec diff this process applied, when what it produced cannot be used. */
14
- export declare function revertSpecDiff(diff: string, cwd: string): void;
15
13
  /** The .plain files a diff writes to, relative to where it applies. */
16
14
  export declare function plainFilesOf(diff: string): string[];
17
15
  /** A module's .plain file and every one it imports, transitively - the files its spec is read from. */
@@ -88,20 +88,6 @@ export function applySpecDiff(diff, cwd) {
88
88
  written();
89
89
  }
90
90
  }
91
- /** Undo a spec diff this process applied, when what it produced cannot be used. */
92
- export function revertSpecDiff(diff, cwd) {
93
- const written = conversationWriting(plainFilesOf(diff).map((file) => resolve(cwd, file)));
94
- const dir = mkdtempSync(join(tmpdir(), "turri-diff-"));
95
- const patch = join(dir, "spec.diff");
96
- writeFileSync(patch, diff.endsWith("\n") ? diff : `${diff}\n`);
97
- try {
98
- spawnSync("git", ["apply", "--recount", "--reverse", patch], { cwd, encoding: "utf8" });
99
- }
100
- finally {
101
- rmSync(dir, { recursive: true, force: true });
102
- written();
103
- }
104
- }
105
91
  /** The .plain files a diff writes to, relative to where it applies. */
106
92
  export function plainFilesOf(diff) {
107
93
  const files = new Set();
@@ -584,11 +570,14 @@ export async function renderSpecDiff(options) {
584
570
  // Passing means the harness's own run of the unit testing script passed, last.
585
571
  const unitPassed = verified;
586
572
  const files = diffFiles(digestsBefore, digestFiles(buildDir));
573
+ // The report is what the agent said it did, handed over with submit_work - not what it said along the way, which reads
574
+ // as a plan ("next I'll check...") when its last words came before its last tool calls. Without an account, its words.
575
+ const account = work.last()?.summary.trim();
587
576
  const base = {
588
577
  moduleName,
589
578
  buildDir,
590
579
  diff: applied,
591
- response,
580
+ response: account !== undefined && account !== "" ? account : response,
592
581
  runs,
593
582
  attempts,
594
583
  testRemovals,
@@ -4,7 +4,7 @@ import { ACCEPTANCE_TESTS, CONFORMANCE_TESTS, FUNCTIONAL_REQUIREMENTS, REQUIRED_
4
4
  import { reportActivity } from "./activity.js";
5
5
  import { record } from "./ledger.js";
6
6
  import { abandonWork, landWork, moduleDirOf, startWork } from "./lineage.js";
7
- import { hasScenarios, marksRegenerateAgain, writeCodeRecord, writeTestsRecord } from "./records.js";
7
+ import { hasScenarios, marksRegenerateAgain, marksTestsAgain, writeCodeRecord, writeTestsRecord } from "./records.js";
8
8
  import { listFiles } from "./testing.js";
9
9
  const SECTIONS = [REQUIRED_FUNCTIONAL_SPECS, FUNCTIONAL_REQUIREMENTS];
10
10
  const KINDS = [
@@ -24,7 +24,7 @@ function stable(value) {
24
24
  }
25
25
  /** What of a functional spec the code is built from, but its func-id: its text, its links. */
26
26
  function codeOf(item) {
27
- const { id: _id, [CONFORMANCE_TESTS]: _conformance, [ACCEPTANCE_TESTS]: _acceptance, regenerate_again: _again, ...rest } = item;
27
+ const { id: _id, [CONFORMANCE_TESTS]: _conformance, [ACCEPTANCE_TESTS]: _acceptance, regenerate_again: _again, conform_again: _conform, ...rest } = item;
28
28
  return stable({ ...rest, markdown: String(rest.markdown ?? "").trim() });
29
29
  }
30
30
  const scenariosOf = (item, key) => item?.[key] ?? [];
@@ -58,7 +58,7 @@ export function pureRenames(code, tests, spec, module) {
58
58
  for (const gone of built.filter((item) => !inSpec.has(key(item)) && !marksRegenerateAgain(item))) {
59
59
  const testedItem = tested.find((item) => key(item) === key(gone));
60
60
  // Its tests, when it has them, written for it as it is built: the same text, not marked to be written again.
61
- if (testedItem !== undefined && (marksRegenerateAgain(testedItem) || codeOf(testedItem) !== codeOf(gone)))
61
+ if (testedItem !== undefined && (marksTestsAgain(testedItem) || codeOf(testedItem) !== codeOf(gone)))
62
62
  continue;
63
63
  const match = fresh.find((item) => !taken.has(item) &&
64
64
  moduleOf(item) === moduleOf(gone) &&
@@ -83,7 +83,7 @@ export function pureRenames(code, tests, spec, module) {
83
83
  const testedNow = sectionOf(testsNow, heading).map((item) => {
84
84
  const current = nowByKey.get(key(item));
85
85
  const have = builtNow.get(key(item));
86
- if (current === undefined || have === undefined || marksRegenerateAgain(item) || marksRegenerateAgain(have))
86
+ if (current === undefined || have === undefined || marksTestsAgain(item) || marksRegenerateAgain(have))
87
87
  return item;
88
88
  if (codeOf(item) !== codeOf(current) || codeOf(have) !== codeOf(current))
89
89
  return item;
@@ -90,6 +90,13 @@ export declare function builtTips(plainFile: string, options?: {
90
90
  export declare function copyRequiredCode(from: string, to: string, toModule: string,
91
91
  /** The module the code comes from: its functional specs are what the new one inherits. */
92
92
  fromModule: string): string[];
93
+ /**
94
+ * Copy a required module's conformance tests beside a codebase's code - into its `tests` directory, beside the code -
95
+ * as a codebase built on that module starts from them: their files and notes, and what they are written for as what
96
+ * the module inherits - its conformance suite is the chain's, kept up to date there from then on. `from` and `to` are
97
+ * the two codebases' code folders. Nothing, when the required module has no tests.
98
+ */
99
+ export declare function copyRequiredTests(from: string, to: string, fromModule: string): void;
93
100
  /**
94
101
  * A module the chain requires now that a module built in it was not built on: one required for
95
102
  * the first time - a new module the specs were split into, say - and the built modules above it,
@@ -303,27 +303,33 @@ fromModule) {
303
303
  const at = head(from);
304
304
  const recordStart = () => recordHistory(to, `start from ${source}${at ? ` at ${at}` : ""}`);
305
305
  // So do the conformance tests: they check the code that was just copied, and the new
306
- // module's regression suite has to keep them passing. They sit beside the code, in the
307
- // module's `tests` directory.
306
+ // module's regression suite has to keep them passing.
307
+ copyRequiredTests(from, to, fromModule);
308
+ recordStart();
309
+ return copied;
310
+ }
311
+ /**
312
+ * Copy a required module's conformance tests beside a codebase's code - into its `tests` directory, beside the code -
313
+ * as a codebase built on that module starts from them: their files and notes, and what they are written for as what
314
+ * the module inherits - its conformance suite is the chain's, kept up to date there from then on. `from` and `to` are
315
+ * the two codebases' code folders. Nothing, when the required module has no tests.
316
+ */
317
+ export function copyRequiredTests(from, to, fromModule) {
308
318
  const testsFrom = join(dirname(from), "tests");
309
319
  const testsTo = join(dirname(to), "tests");
310
- if (existsSync(testsFrom)) {
311
- for (const file of listFiles(testsFrom)) {
312
- const target = join(testsTo, file);
313
- mkdirSync(dirname(target), { recursive: true });
314
- copyFileSync(join(testsFrom, file), target);
315
- }
316
- // And their notes, which listFiles leaves out as it does the code's.
317
- if (existsSync(notesPath(testsFrom)) && !existsSync(notesPath(testsTo)))
318
- copyFileSync(notesPath(testsFrom), notesPath(testsTo));
319
- // What they are written for comes with them, as what the new module inherits: its conformance suite is the chain's,
320
- // kept up to date here from now on.
321
- const tested = readRecord(testsFrom);
322
- if (tested !== null)
323
- writeTestsRecord(testsTo, inheritedTestsRecord(tested, fromModule));
320
+ if (!existsSync(testsFrom))
321
+ return;
322
+ for (const file of listFiles(testsFrom)) {
323
+ const target = join(testsTo, file);
324
+ mkdirSync(dirname(target), { recursive: true });
325
+ copyFileSync(join(testsFrom, file), target);
324
326
  }
325
- recordStart();
326
- return copied;
327
+ // And their notes, which listFiles leaves out as it does the code's.
328
+ if (existsSync(notesPath(testsFrom)) && !existsSync(notesPath(testsTo)))
329
+ copyFileSync(notesPath(testsFrom), notesPath(testsTo));
330
+ const tested = readRecord(testsFrom);
331
+ if (tested !== null)
332
+ writeTestsRecord(testsTo, inheritedTestsRecord(tested, fromModule));
327
333
  }
328
334
  /**
329
335
  * A module the chain requires now that a module built in it was not built on: one required for
@@ -9,7 +9,7 @@ import { conformanceDirFor } from "./conformance.js";
9
9
  import { chainSpec } from "./loop.js";
10
10
  import { modulesRoot, projectDirOf } from "./paths.js";
11
11
  import { HISTORY_DIR } from "./lineage.js";
12
- import { codeTree, hasScenarios, marksRegenerateAgain, readRecord, RECORD_FILE } from "./records.js";
12
+ import { codeTree, hasScenarios, marksTestsAgain, readRecord, RECORD_FILE } from "./records.js";
13
13
  import { pureRenames } from "./renames.js";
14
14
  import { specFilesOf } from "./regenerate.js";
15
15
  import { builtTips, resolveRequiresChain } from "./requires.js";
@@ -136,7 +136,7 @@ export function pageItems(input) {
136
136
  }
137
137
  // Conformance tests: of the functional specs, by func-id, those the tests record has as they read now - their text and
138
138
  // their scenarios - as they read before, or taken out. Tests marked to regenerate again were written against code since
139
- // replaced: written for an earlier build, not now.
139
+ // replaced, and those marked to be written again are to be written anew: written for an earlier build, not now.
140
140
  const testedItems = new Map(itemsOf(input.tested ?? null, FUNCTIONAL_REQUIREMENTS).map((item) => [item.id ?? "", item]));
141
141
  const asNow = new Map(itemsOf(now, FUNCTIONAL_REQUIREMENTS).map((item) => [item.id ?? "", item]));
142
142
  const reads = (item) => JSON.stringify({ markdown: item.markdown.trim(), scenarios: scenarioViews(item) });
@@ -150,7 +150,7 @@ export function pageItems(input) {
150
150
  if (item.state === "removed")
151
151
  item.tests = "removed";
152
152
  else
153
- item.tests = !marksRegenerateAgain(tested) && current !== undefined && reads(tested) === reads(current) ? "now" : "older";
153
+ item.tests = !marksTestsAgain(tested) && current !== undefined && reads(tested) === reads(current) ? "now" : "older";
154
154
  }
155
155
  return keyed(items);
156
156
  }
@@ -7,7 +7,7 @@ import { projectPlainFiles } from "./requires.js";
7
7
  export function projectStanding(projectDir, options = {}) {
8
8
  const root = resolve(projectDir);
9
9
  const files = (options.files ?? projectPlainFiles(root)).map((file) => resolve(root, file));
10
- const loop = options.loop ?? createWorkLoop({ registry: createJobRegistry(), cwd: root, dryRun: true });
10
+ const loop = options.loop ?? createWorkLoop({ registry: createJobRegistry(), cwd: root });
11
11
  return withParseCache(() => files.map((plainFile) => {
12
12
  const standing = { plainFile, module: basename(plainFile, PLAIN_SOURCE_FILE_EXTENSION) };
13
13
  try {
@@ -30,6 +30,8 @@ export interface WorkLedger {
30
30
  peek: () => WorkAccount[];
31
31
  /** What was handed over since the last take - and from now, nothing. */
32
32
  take: () => WorkAccount[];
33
+ /** The last account handed over, taken or not: what the agent last said it did. */
34
+ last: () => WorkAccount | undefined;
33
35
  }
34
36
  export declare function createWorkLedger(): WorkLedger;
35
37
  /** The problems, numbered from 1, that no account answered. */
@@ -5,7 +5,9 @@ export const SUBMIT_WORK_NOTE = [
5
5
  "When you are done with a turn - the work written and its tests passing - call submit_work, last: a short summary of",
6
6
  "what you did and why, and after a review, an answer for each problem it raised - fixed, or declined and why. Its",
7
7
  "reviewer gets your account beside the diff of what you changed, and checks the one against the other: say what you",
8
- "did, not what you meant to.",
8
+ "did, not what you meant to. It is also the pulse's report to the person: say what the code does now, and a check you",
9
+ "ran as the check it was - \"breaking the tie order on purpose made 4 tests fail\" - never a bug you planted and undid",
10
+ "as if it were in the code.",
9
11
  ];
10
12
  /** What the agent is told with a review's problems: how it answers them. */
11
13
  export const SUBMIT_AFTER_REVIEW = [
@@ -13,6 +15,7 @@ export const SUBMIT_AFTER_REVIEW = [
13
15
  ];
14
16
  export function createWorkLedger() {
15
17
  let accounts = [];
18
+ let last;
16
19
  const tool = defineTool({
17
20
  name: "submit_work",
18
21
  label: "Submit the work",
@@ -20,7 +23,7 @@ export function createWorkLedger() {
20
23
  "raised, by its number - fixed, or declined and why, and the files. The reviewer checks it against the diff.",
21
24
  promptSnippet: "hand the work over for review - what you did, and your answer to each problem raised",
22
25
  parameters: Type.Object({
23
- summary: Type.String({ description: "What you did in this turn and why, in a few sentences" }),
26
+ summary: Type.String({ description: "What you did in this turn and why, in a few sentences - the pulse's report: what the code does now, a check you ran said as a check" }),
24
27
  answers: Type.Optional(Type.Array(Type.Object({
25
28
  problem: Type.Number({ description: "The problem's number in the review's list" }),
26
29
  outcome: Type.Union([Type.Literal("fixed"), Type.Literal("declined")]),
@@ -29,13 +32,15 @@ export function createWorkLedger() {
29
32
  }), { description: "After a review: one answer for each problem it raised. Omit on a first turn." })),
30
33
  }),
31
34
  async execute(_id, params) {
32
- accounts.push({ summary: params.summary, answers: (params.answers ?? []) });
35
+ last = { summary: params.summary, answers: (params.answers ?? []) };
36
+ accounts.push(last);
33
37
  return { content: [{ type: "text", text: "Handed over." }], details: {}, terminate: true };
34
38
  },
35
39
  });
36
40
  return {
37
41
  tool,
38
42
  peek: () => [...accounts],
43
+ last: () => last,
39
44
  take() {
40
45
  const taken = accounts;
41
46
  accounts = [];
@@ -39,3 +39,14 @@ export declare function testingGap(input: {
39
39
  tree: MarshalledPlainSource;
40
40
  buildDir?: string;
41
41
  }): TestingGap | undefined;
42
+ /**
43
+ * The steps of adding tests a module still has to take before it has anything to test - in their order: its test reqs,
44
+ * the conformance testing script for its stack, the scenarios - from the first one missing. What is said when conform
45
+ * finds no scenarios: the whole way there, not the last step alone.
46
+ */
47
+ export declare function stepsToScenarios(input: {
48
+ moduleName: string;
49
+ plainFile: string;
50
+ tree: MarshalledPlainSource;
51
+ buildDir?: string;
52
+ }): string;
@@ -1,7 +1,7 @@
1
1
  import { existsSync, readFileSync } from "node:fs";
2
- import { dirname, join, resolve } from "node:path";
2
+ import { dirname, join, relative, resolve } from "node:path";
3
3
  import { conformanceTestsOn } from "../conformance-switch.js";
4
- import { stackForModule, stackPinned, withStack } from "../config.js";
4
+ import { stackForModule, stackPinned, testDirOf, withStack } from "../config.js";
5
5
  import { IMPORT_DIRECTIVE, readPlainSourceMetadata } from "../plain/parser.js";
6
6
  import { FUNCTIONAL_REQUIREMENTS, REQUIRED_FUNCTIONAL_SPECS, TEST_REQUIREMENTS } from "../plain/spec.js";
7
7
  import { isStdlibModule, STDLIB_ROOT } from "../plain/stdlib.js";
@@ -93,7 +93,7 @@ export function testingGap(input) {
93
93
  return {
94
94
  step: "test reqs",
95
95
  text: `${moduleName} has scenarios to test - ${named(tested)} - but no ***test reqs***, so its conformance tests cannot be written - the test reqs are ` +
96
- `the first step of adding tests. Next step: ${reqs}, with change_plain${found.script === undefined ? `; then ${scriptStep}` : ""}.`,
96
+ `the first step of adding tests. Next step: ${reqs}${found.script === undefined ? `; then ${scriptStep}` : ""}.`,
97
97
  short: "scenarios not tested: no test reqs",
98
98
  };
99
99
  }
@@ -108,3 +108,22 @@ export function testingGap(input) {
108
108
  }
109
109
  return undefined;
110
110
  }
111
+ /**
112
+ * The steps of adding tests a module still has to take before it has anything to test - in their order: its test reqs,
113
+ * the conformance testing script for its stack, the scenarios - from the first one missing. What is said when conform
114
+ * finds no scenarios: the whole way there, not the last step alone.
115
+ */
116
+ export function stepsToScenarios(input) {
117
+ const { moduleName, plainFile } = input;
118
+ const steps = [];
119
+ if ((input.tree[TEST_REQUIREMENTS] ?? []).length === 0) {
120
+ const conformance = conformanceTemplateOf(plainFile);
121
+ steps.push(conformance !== undefined ? `import the stack's conformance template, ${conformance}` : "write the module's own ***test reqs***");
122
+ }
123
+ if (conformanceScriptOf(plainFile, input.buildDir).script === undefined)
124
+ steps.push("write the conformance testing script with the implement-conformance-testing-script skill");
125
+ const testDir = relative(projectDirOf(resolve(plainFile)), testDirOf(plainFile)) || ".";
126
+ steps.push(`write the scenarios, each functional spec's in ${testDir}/${moduleName}/<func-id>.plain, then regenerate`);
127
+ const order = steps.length > 1 ? "Adding tests is three steps, in this order: the test reqs, the conformance testing script, the scenarios. " : "";
128
+ return `${order}Next step: ${steps.join("; then ")}.`;
129
+ }
@@ -16,7 +16,8 @@ build when none is given), coding-model (the agents that build) and harness-mode
16
16
  0 only when every module is complete: regenerated from the spec as it is, and its conformance tests written
17
17
  for every functional spec's scenarios.
18
18
 
19
- --dry-run plan the work and print the prompt of the first job, and run nothing (turri glimpse)
19
+ --dry-run look ahead: plan the work as regenerate would and print the prompt of each codebase's
20
+ next pulse, starting nothing and changing no code or tests
20
21
  --start-over start over, without asking, a codebase regenerated without a module it now requires -
21
22
  with no terminal to ask and without it, the run stops there
22
23
  --from-scratch delete the module's code and conformance tests (its lineage keeps them) and regenerate all of it
@@ -45,23 +46,31 @@ if (!named) {
45
46
  process.exit(1);
46
47
  }
47
48
  const scratch = options["from-scratch-chain"] !== undefined ? "chain" : options["from-scratch"] !== undefined ? "module" : undefined;
48
- // A dry run starts nothing, and from scratch deletes before it plans: the two do not go together.
49
- if (scratch !== undefined && options["dry-run"] !== undefined) {
49
+ const dryRun = options["dry-run"] !== undefined;
50
+ // A dry run writes nothing: from scratch deletes the code before it plans, and functional specs named are marked in the records first.
51
+ if (scratch !== undefined && dryRun) {
50
52
  console.error(`--from-scratch${scratch === "chain" ? "-chain" : ""} deletes the code before anything is planned: it cannot be a dry run.`);
51
53
  process.exit(1);
52
54
  }
55
+ if (again.length > 0 && dryRun) {
56
+ console.error(`${again.join(", ")} would be marked to regenerate again in the code records before anything is planned: that cannot be a dry run.`);
57
+ process.exit(1);
58
+ }
53
59
  runLoop({
54
60
  plainFile: named,
55
61
  ...(buildDir !== undefined ? { buildDir } : {}),
56
62
  ...(report !== undefined ? { report } : {}),
57
63
  command: ["regenerate", ...process.argv.slice(2)],
58
- dryRun: options["dry-run"] !== undefined,
64
+ dryRun,
59
65
  startOver: options["start-over"] !== undefined,
60
- ask: (loop) => again.length > 0
61
- ? loop.regenerateAgain(named, again)
62
- : scratch !== undefined
63
- ? loop.fromScratch(named, { chain: scratch === "chain" })
64
- : loop.bringUp(named),
66
+ // A dry run is a look ahead: planned as regenerate plans it, nothing started.
67
+ ask: (loop) => dryRun
68
+ ? loop.lookAhead(named)
69
+ : again.length > 0
70
+ ? loop.regenerateAgain(named, again)
71
+ : scratch !== undefined
72
+ ? loop.fromScratch(named, { chain: scratch === "chain" })
73
+ : loop.bringUp(named),
65
74
  }).catch((error) => {
66
75
  console.error(error instanceof Error ? error.message : error);
67
76
  process.exit(1);
@@ -8,6 +8,7 @@
8
8
  * the same build directories. It is never the right call unless the person asked for the
9
9
  * command line, so the harness refuses it and names the tool to use instead.
10
10
  */
11
+ import { type ToolDefinition } from "@earendil-works/pi-coding-agent";
11
12
  /**
12
13
  * What a shell command would run of turri or pi itself, if anything: the subcommand,
13
14
  * or "pi" for another pi. `turri parse`, `drift` and `lineage` are not in it - they start no
@@ -23,3 +24,13 @@ export declare function askedForCommandLine(message: string): boolean;
23
24
  export declare function refusal(what: string, surface?: string): string;
24
25
  /** The instruction that goes into the conversation's system prompt. */
25
26
  export declare const TOOLS_NOT_CLI: string;
27
+ type AnyTool = ToolDefinition<any, any, any>;
28
+ /** What a skill's agent is told when its shell would run turri or another pi. */
29
+ export declare function skillRefusal(what: string): string;
30
+ /**
31
+ * A skill's shell: pi's bash in the project, refusing what its agent never runs there - turri or another pi again
32
+ * (selfInvocation), and a change to the machine's toolchains or settings (machineChange). The conversation's own bash is
33
+ * held to the same by its tool_call guard; a skill runs in a session of its own, which that guard does not see.
34
+ */
35
+ export declare function skillShell(cwd: string): AnyTool;
36
+ export {};
@@ -8,14 +8,14 @@
8
8
  * the same build directories. It is never the right call unless the person asked for the
9
9
  * command line, so the harness refuses it and names the tool to use instead.
10
10
  */
11
+ import { createBashToolDefinition } from "@earendil-works/pi-coding-agent";
12
+ import { machineChange, machineChangeReason } from "./regenerate/command-check.js";
11
13
  /** The tool that does what a turri subcommand does, from inside the conversation. */
12
14
  const TOOL_FOR = {
13
15
  regenerate: "regenerate",
14
- glimpse: "glimpse",
15
16
  conform: "conform",
16
17
  cultivate: "cultivate",
17
18
  release: "release",
18
- "change-plain": "regenerate",
19
19
  chat: "nothing - you are the conversation already",
20
20
  ask: "nothing - you are the conversation already",
21
21
  };
@@ -31,7 +31,6 @@ const NPM_SCRIPT = {
31
31
  const ENTRY = {
32
32
  "regenerate-cli": "regenerate",
33
33
  "conform-cli": "conform",
34
- "change-plain-cli": "change-plain",
35
34
  "cultivate-cli": "cultivate",
36
35
  "release-cli": "release",
37
36
  };
@@ -43,10 +42,10 @@ const AT_COMMAND = String.raw `(?:^|[\s;&|()\x60$])`;
43
42
  * agent - and neither are setup and doctor.
44
43
  */
45
44
  export function selfInvocation(command) {
46
- const cli = new RegExp(`${AT_COMMAND}(?:npx\\s+)?turri\\s+(regenerate|glimpse|conform|cultivate|release|change-plain)\\b`).exec(command);
45
+ const cli = new RegExp(`${AT_COMMAND}(?:npx\\s+)?turri\\s+(regenerate|conform|cultivate|release)\\b`).exec(command);
47
46
  if (cli)
48
47
  return cli[1];
49
- const launcher = new RegExp(`(?:bin/turri\\.mjs|src/cli\\.ts)\\s+(regenerate|glimpse|conform|cultivate|release|change-plain)\\b`).exec(command);
48
+ const launcher = new RegExp(`(?:bin/turri\\.mjs|src/cli\\.ts)\\s+(regenerate|conform|cultivate|release)\\b`).exec(command);
50
49
  if (launcher)
51
50
  return launcher[1];
52
51
  // turri alone, or with options, is the conversation - where a command starts, not a word an argument names (`which turri`).
@@ -83,7 +82,7 @@ const PI_CONFIGURES = new Set([
83
82
  export function askedForCommandLine(message) {
84
83
  const text = message.toLowerCase();
85
84
  return (/\b(headless|command[ -]line|cli|terminal|shell|in bash|via bash|through bash|npm run|nohup)\b/.test(text) ||
86
- /\bturri\s+(regenerate|glimpse|conform|change-plain|cultivate|release)\b/.test(text) ||
85
+ /\bturri\s+(regenerate|conform|cultivate|release)\b/.test(text) ||
87
86
  /(^|\s)turri\s+-p\b/.test(text) ||
88
87
  /(^|\s)pi\s+-p\b/.test(text));
89
88
  }
@@ -102,10 +101,37 @@ export const TOOLS_NOT_CLI = [
102
101
  "<turri-tools>",
103
102
  "In this conversation, you do your work with your tools - regenerate, conform, cultivate and the rest - which run as",
104
103
  "background jobs the user can watch and halt. To try what is regenerated, release it - never by hand in plain_modules. Never",
105
- "run your own command line (turri regenerate, glimpse, conform, change-plain, cultivate, release, turri itself; npm run",
104
+ "run your own command line (turri regenerate, conform, cultivate, release, turri itself; npm run",
106
105
  "regenerate and the like) or start another pi through bash:",
107
106
  "that is a separate headless run the user cannot see or stop. Only when the user explicitly asks for the",
108
107
  "command line, run it. Configuring pi itself - turri install, update, remove, list; pi install, update, list, config, auth; or its settings files -",
109
108
  "is fine; it starts no agent.",
110
109
  "</turri-tools>",
111
110
  ].join("\n");
111
+ /** What a skill's agent is told when its shell would run turri or another pi. */
112
+ export function skillRefusal(what) {
113
+ return (`Not run: that starts ${what === "pi" ? "another agent" : `turri ${what}`} from the shell - a separate, headless run outside the person's session, ` +
114
+ "its pulses and /halt, writing the same codebases as the work loop. A skill starts no pulse: finish your own work, and say in what you " +
115
+ "hand back what should run next - the conversation runs it.");
116
+ }
117
+ /**
118
+ * A skill's shell: pi's bash in the project, refusing what its agent never runs there - turri or another pi again
119
+ * (selfInvocation), and a change to the machine's toolchains or settings (machineChange). The conversation's own bash is
120
+ * held to the same by its tool_call guard; a skill runs in a session of its own, which that guard does not see.
121
+ */
122
+ export function skillShell(cwd) {
123
+ const bash = createBashToolDefinition(cwd);
124
+ return {
125
+ ...bash,
126
+ async execute(toolCallId, params, signal, onUpdate, ctx) {
127
+ const command = String(params.command ?? "");
128
+ const what = selfInvocation(command);
129
+ if (what !== undefined)
130
+ throw new Error(skillRefusal(what));
131
+ const changes = machineChange(command);
132
+ if (changes !== undefined)
133
+ throw new Error(machineChangeReason(changes));
134
+ return bash.execute(toolCallId, params, signal, onUpdate, ctx);
135
+ },
136
+ };
137
+ }
package/dist/sentinel.js CHANGED
@@ -178,11 +178,14 @@ export function sentinelPrompt(cwd, options = {}) {
178
178
  ]),
179
179
  "",
180
180
  "For the pulse:",
181
- "1. Check how it went, from what turri tells you - and, when that is not enough, its log, the ledger (ledger, pulses),",
182
- " diagnose, and the code and the ***plain, which you read.",
181
+ "1. Check how it went, from what turri tells you - and, when that is not enough, the pulse in full (pulses with its id),",
182
+ " its log, and the code and the ***plain, which you read.",
183
183
  "2. When it was released (the message says so - release-after-pulse is on), test what was released: it is running",
184
184
  " where the message says. How far you test is yours to judge, from what the pulse changed and what the ***plain says",
185
- " it should do: that it came up, answers, and does what its ***plain diff says it now does.",
185
+ " it should do: that it came up, answers, and does what its ***plain diff says it now does. Where the ***plain picks",
186
+ " one way among several - which of a tie comes first, how a default is chosen - try an input on which the ways give",
187
+ " different answers, so a pass shows the ***plain's way and no other: a tie whose first word is also first",
188
+ " alphabetically tells \"first in the file\" from nothing.",
186
189
  "3. When something is wrong - the pulse failed or stopped, it did not pass, the release did not come up, the software",
187
190
  " does not do what its ***plain says - find out why. Then:",
188
191
  " - When it is the project's tooling - a testing script, or where config.turri.yaml says the scripts are and which",
@@ -209,7 +212,7 @@ export function sentinelPrompt(cwd, options = {}) {
209
212
  "",
210
213
  "You fix the project's tooling and nothing else. Your file tools read the whole project; write and edit reach only the",
211
214
  "testing scripts and config.turri.yaml - and in it only where the scripts are, and toolchains:. Your shell runs with",
212
- "the project read only. You never change ***plain - it is the person's intent, never yours to fix - and never steer,",
215
+ "the project read only; the files you try a release with go in $TMPDIR - /tmp is outside what it may write. You never change ***plain - it is the person's intent, never yours to fix - and never steer,",
213
216
  "release, or regenerate but by resume after a fix of yours. You install nothing on this machine and change none of",
214
217
  "its settings, nor the person's shell - under no circumstances: that is always the person's, said in a notice. You",
215
218
  "never ask the person questions - a notice is how you reach them.",
@@ -316,7 +319,7 @@ export function sentinelCheckBrief(check, context) {
316
319
  * The tools the sentinel's agent may call: what reads, write and edit for the project's tooling alone, resume, its
317
320
  * notices and its guidance - and what a host gives it.
318
321
  */
319
- export const SENTINEL_TOOLS = ["read", "ls", "grep", "find", "write", "edit", "bash", "read_output", "ledger", "pulses", "diagnose", "parse", "doctor", "web_search", "web_fetch", "resume", "notify_person", "conclude", "keep_guidance"];
322
+ export const SENTINEL_TOOLS = ["read", "ls", "grep", "find", "write", "edit", "bash", "read_output", "pulses", "parse", "doctor", "web_search", "web_fetch", "resume", "notify_person", "conclude", "keep_guidance"];
320
323
  /** A testing script by its name - `run_unittests_python.sh`, `prepare_environment_node.sh` - and a config file of turri's. */
321
324
  const SCRIPT_FILE = /^(run_|prepare_environment).*\.(sh|ps1|bat|cmd)$/;
322
325
  const CONFIG_FILE_NAME = /^config\.turri(\..+)?\.yaml$/;
package/dist/skill.d.ts CHANGED
@@ -69,22 +69,11 @@ export interface Skill {
69
69
  dir: string;
70
70
  allowedTools: string[];
71
71
  steps: StepSpec[];
72
- /**
73
- * Whether `change_plain` needs an answer from the user between two new changes - one answer,
74
- * one change, as an interview writes them. `metadata.paced: false` turns it off, for a skill that
75
- * writes the specs on its own.
76
- */
77
- paced: boolean;
78
72
  /**
79
73
  * The phases the questioning level caps (`metadata.questioning`, questioning.ts): when there are any, the harness asks
80
74
  * the level first, and each of them asks at most as many questions as it allows. Empty: no level is asked.
81
75
  */
82
76
  questioning: string[];
83
- /**
84
- * The steps where each answer is a spec change (`metadata.change-plain-per-answer`): the next question waits until the
85
- * last answer is written with `change_plain`, and changes the agent decides itself need no answer before them.
86
- */
87
- diffPerAnswer: string[];
88
77
  /**
89
78
  * Started only by the person, with its slash command - `/release-notes` - never by the model on its own
90
79
  * (`metadata.command-only: true`): cultivate runs it only when the person has just typed its command.
package/dist/skill.js CHANGED
@@ -109,13 +109,6 @@ export function loadSkill(skillDir) {
109
109
  throw new Error(`${name}: 'metadata.questioning' names unknown step '${stepName}'`);
110
110
  }
111
111
  }
112
- const perAnswer = data.metadata?.["change-plain-per-answer"];
113
- const diffPerAnswer = Array.isArray(perAnswer) ? perAnswer.map(String) : [];
114
- for (const stepName of diffPerAnswer) {
115
- if (!steps.some((s) => s.name === stepName)) {
116
- throw new Error(`${name}: 'metadata.change-plain-per-answer' names unknown step '${stepName}'`);
117
- }
118
- }
119
112
  for (const stepName of gatesByStep.keys()) {
120
113
  if (!steps.some((s) => s.name === stepName)) {
121
114
  throw new Error(`${name}: gate references unknown step '${stepName}'`);
@@ -132,9 +125,7 @@ export function loadSkill(skillDir) {
132
125
  // What a skill may use is what its frontmatter names, and nothing else: no list, no tools.
133
126
  allowedTools: Array.isArray(data["allowed-tools"]) ? data["allowed-tools"] : [],
134
127
  steps,
135
- paced: data.metadata?.paced !== false,
136
128
  questioning: capped,
137
- diffPerAnswer,
138
129
  commandOnly: data.metadata?.["command-only"] === true,
139
130
  background: data.metadata?.background === true,
140
131
  ...(model !== undefined ? { model } : {}),
package/dist/stacks.js CHANGED
@@ -78,7 +78,7 @@ export function registerStacks(pi, cwd) {
78
78
  "For this chat alone - each chat chooses its own; a pulse already running keeps the stack it started with. Without a name, says the stacks and the one chosen.",
79
79
  promptSnippet: "choose the stack - its testing scripts and settings - that everything is built with",
80
80
  promptGuidelines: [
81
- "Switch the stack only when the user asks for it, and say which you chose. A module is built with the stack named after it by itself; to build one whose stack has another name, pass that stack as stack to regenerate, conform, glimpse or change_plain instead: it is pinned to that module's pulses, and this chat's choice stays as it is.",
81
+ "Switch the stack only when the user asks for it, and say which you chose. A module is built with the stack named after it by itself; to build one whose stack has another name, pass that stack as stack to regenerate, conform or pulses instead: it is pinned to that module's pulses, and this chat's choice stays as it is.",
82
82
  ],
83
83
  parameters: Type.Object({
84
84
  name: Type.Optional(Type.String({ description: "The stack to choose, or none. Omitted: the stacks there are, and the one chosen" })),
package/dist/tools.js CHANGED
@@ -155,7 +155,7 @@ function talkBack(talks) {
155
155
  "with ask_user only once it is settled - changed, if what they said calls for it. It was not counted as answered."
156
156
  : "Answer what they said, then ask the question again with ask_user - changed, if what they said calls for it. Put " +
157
157
  "your answer to them in the question's `context`: nothing else you write reaches them. It was not counted as a " +
158
- "question, and nothing is owed for it.";
158
+ "question.";
159
159
  }
160
160
  /** Ends the questions of a phase the questioning level caps: what is left, the agent decides itself. */
161
161
  export function createEndQuestionsTool(questioning) {
@@ -163,8 +163,7 @@ export function createEndQuestionsTool(questioning) {
163
163
  name: "end_questions",
164
164
  label: "End questions",
165
165
  description: "End this phase's questions: you have asked what the person must decide, and you decide what is left " +
166
- "yourself, saying what you chose. Afterwards ask_user asks only the phase's closing confirmation, and " +
167
- "change_plain needs no answer between changes.",
166
+ "yourself, saying what you chose. Afterwards ask_user asks only the phase's closing confirmation.",
168
167
  promptSnippet: "end this phase's questions and decide what is left yourself",
169
168
  parameters: Type.Object({}),
170
169
  async execute() {