@turri-dev/cli 0.2.4-next.35ab04b → 0.2.4-next.636a651

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 (102) hide show
  1. package/README.md +2 -2
  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/conformance-switch.d.ts +7 -17
  11. package/dist/conformance-switch.js +24 -46
  12. package/dist/drift-cli.js +1 -1
  13. package/dist/extension.d.ts +8 -10
  14. package/dist/extension.js +157 -217
  15. package/dist/genome.js +9 -48
  16. package/dist/graph.js +3 -5
  17. package/dist/host-session.d.ts +4 -15
  18. package/dist/host-session.js +2 -4
  19. package/dist/host.d.ts +1 -3
  20. package/dist/host.js +1 -4
  21. package/dist/identity.js +0 -1
  22. package/dist/init-config.d.ts +0 -1
  23. package/dist/init-config.js +2 -9
  24. package/dist/installed-providers.d.ts +1 -1
  25. package/dist/installed-providers.js +1 -1
  26. package/dist/loop-cli.d.ts +4 -3
  27. package/dist/loop-cli.js +13 -11
  28. package/dist/loop-tools.d.ts +26 -3
  29. package/dist/loop-tools.js +85 -20
  30. package/dist/new-project.js +2 -2
  31. package/dist/pi-launch.js +1 -1
  32. package/dist/pi.js +9 -6
  33. package/dist/plain/check.d.ts +1 -8
  34. package/dist/plain/check.js +3 -38
  35. package/dist/regenerate/activity.d.ts +0 -7
  36. package/dist/regenerate/activity.js +2 -20
  37. package/dist/regenerate/agent-shell.js +3 -1
  38. package/dist/regenerate/audit.js +9 -0
  39. package/dist/regenerate/chunk-plan.d.ts +5 -0
  40. package/dist/regenerate/chunk-plan.js +16 -1
  41. package/dist/regenerate/failure-reports.d.ts +28 -0
  42. package/dist/regenerate/failure-reports.js +79 -0
  43. package/dist/regenerate/job-panel.js +3 -1
  44. package/dist/regenerate/jobs-tree.js +1 -1
  45. package/dist/regenerate/jobs.d.ts +2 -0
  46. package/dist/regenerate/jobs.js +4 -0
  47. package/dist/regenerate/ledger-view.d.ts +11 -24
  48. package/dist/regenerate/ledger-view.js +14 -60
  49. package/dist/regenerate/ledger.d.ts +1 -14
  50. package/dist/regenerate/ledger.js +1 -1
  51. package/dist/regenerate/loop.d.ts +37 -60
  52. package/dist/regenerate/loop.js +174 -106
  53. package/dist/regenerate/regenerate.d.ts +0 -2
  54. package/dist/regenerate/regenerate.js +4 -15
  55. package/dist/regenerate/standing.js +1 -1
  56. package/dist/regenerate/submit-work.d.ts +2 -0
  57. package/dist/regenerate/submit-work.js +8 -3
  58. package/dist/regenerate/testing-steps.d.ts +11 -0
  59. package/dist/regenerate/testing-steps.js +22 -3
  60. package/dist/regenerate-cli.js +18 -9
  61. package/dist/self-invocation.d.ts +11 -0
  62. package/dist/self-invocation.js +33 -7
  63. package/dist/sentinel.js +8 -5
  64. package/dist/skill.d.ts +0 -11
  65. package/dist/skill.js +0 -9
  66. package/dist/stacks.js +1 -1
  67. package/dist/tools.js +2 -3
  68. package/dist/turri-versions.js +2 -1
  69. package/docs/README.md +0 -2
  70. package/docs/authoring-plain.md +3 -3
  71. package/docs/chats.md +1 -3
  72. package/docs/config.md +11 -13
  73. package/docs/deploy.md +1 -1
  74. package/docs/development.md +2 -3
  75. package/docs/headless.md +5 -4
  76. package/docs/hosting.md +6 -6
  77. package/docs/parser.md +2 -2
  78. package/docs/regenerating.md +14 -12
  79. package/docs/sentinel.md +4 -4
  80. package/docs/skills-and-gates.md +4 -8
  81. package/docs/using.md +10 -18
  82. package/genome/rules/test-plain-files.md +15 -7
  83. package/genome/rules/turri-regeneration.md +4 -9
  84. package/genome/skills/convert-old-syntax/SKILL.md +5 -5
  85. package/package.json +1 -1
  86. package/dist/advisor-chat.d.ts +0 -63
  87. package/dist/advisor-chat.js +0 -290
  88. package/dist/change-plain-cli.d.ts +0 -1
  89. package/dist/change-plain-cli.js +0 -55
  90. package/dist/ledger-cli.d.ts +0 -1
  91. package/dist/ledger-cli.js +0 -50
  92. package/dist/ledger-tools.d.ts +0 -10
  93. package/dist/ledger-tools.js +0 -64
  94. package/dist/regenerate/advisor-records.d.ts +0 -93
  95. package/dist/regenerate/advisor-records.js +0 -110
  96. package/dist/regenerate/advisor-runs.d.ts +0 -87
  97. package/dist/regenerate/advisor-runs.js +0 -327
  98. package/dist/regenerate/test-advisor.d.ts +0 -101
  99. package/dist/regenerate/test-advisor.js +0 -379
  100. package/dist/spec-tools.d.ts +0 -36
  101. package/dist/spec-tools.js +0 -128
  102. package/docs/test-advisor.md +0 -110
package/dist/genome.js CHANGED
@@ -1,18 +1,16 @@
1
- import { mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
1
+ import { mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
2
2
  import { join, resolve } from "node:path";
3
3
  import { Command, MemorySaver } from "@langchain/langgraph";
4
4
  import { compileSkill } from "./graph.js";
5
5
  import { createExecutor } from "./pi.js";
6
6
  import { plainWriteTools } from "./plain-files.js";
7
+ import { skillShell } from "./self-invocation.js";
7
8
  import { toolchainsBlock } from "./stack.js";
8
9
  import { clearOfStop, describeToolCall, describeToolResult, withStopSignal } from "./regenerate/activity.js";
9
10
  import { createLiveReviewer } from "./review/live.js";
10
11
  import { loadSkill, readRubric } from "./skill.js";
11
12
  import { createAskUserTool, createEndQuestionsTool, createReviewTools, createWriteArtifactTool, withReviewNote } from "./tools.js";
12
- import { DECLINED, DISMISSED } from "./ask.js";
13
13
  import { createQuestioning, levelOf, questioningQuestion } from "./questioning.js";
14
- import { createSpecDiffTools } from "./spec-tools.js";
15
- const CHANGE_PLAIN = "change_plain";
16
14
  /** The conversation's tools a skill acts on the work loop with - never pi built-ins. */
17
15
  const LOOP_TOOLS = ["regenerate", "drift", "halt", "conform"];
18
16
  /** How much of what the agent said before a question is shown with it: its end, where the brief is. */
@@ -78,41 +76,20 @@ async function runStoppable(opts) {
78
76
  const startQuestioning = (level, from) => (questioning = createQuestioning({ level: levelOf(level), phases: skill.questioning, from, onChange: keepQuestioning }));
79
77
  if (capsQuestions && resumed?.questioning !== undefined)
80
78
  startQuestioning(resumed.questioning.level, resumed.questioning);
81
- // The step running now, and whether each of its answers is a spec change: then the next question waits until the last
82
- // answer is written, and a change the agent decides itself needs no answer before it.
83
- let currentStep = "";
84
- const diffPerAnswer = () => skill.diffPerAnswer.includes(currentStep);
85
- const holdsQuestions = capsQuestions || (skill.diffPerAnswer.length > 0 && opts.askUser !== undefined);
86
79
  const questions = {
87
- refusal: (confirmsPhase) => diffPerAnswer() && diffs?.pace.owed() === true
88
- ? "This question was not asked: the last answer is not in the spec yet. Every answer in this phase is a spec " +
89
- "change, built at once - write it with change_plain first, then ask."
90
- : questioning?.refusal(confirmsPhase),
80
+ refusal: (confirmsPhase) => questioning?.refusal(confirmsPhase),
91
81
  answered: (confirmsPhase) => questioning?.answered(confirmsPhase),
92
82
  end: () => questioning?.end() ?? "No questioning level was chosen: ask what the phase needs.",
93
83
  };
94
- // A skill whose unit of work is a spec change gets change_plain: the change is applied
95
- // and its build queued in one step.
96
- const diffs = opts.renderQueue !== undefined && skill.allowedTools.includes(CHANGE_PLAIN)
97
- ? createSpecDiffTools({
98
- loop: opts.renderQueue,
99
- cwd: opts.cwd,
100
- liveReview: liveProxy,
101
- paced: skill.paced,
102
- free: diffPerAnswer,
103
- })
104
- : undefined;
105
84
  // What the agent says between its questions - a brief to confirm, a plan - reaches the person only with
106
85
  // the next question: the session it talks in is its own, and nobody reads it.
107
86
  let said = "";
108
87
  /** A new message of the agent's has started, and has said nothing yet. */
109
88
  let saidFresh = false;
110
89
  if (opts.askUser !== undefined) {
111
- customTools.push(createAskUserTool(opts.askUser, (answer, confirmsPhase) => {
90
+ customTools.push(createAskUserTool(opts.askUser, () => {
112
91
  said = "";
113
- // A phase's confirmation, or a question dismissed, owes the spec nothing.
114
- diffs?.pace.answered(!confirmsPhase && answer !== DISMISSED && answer !== DECLINED);
115
- }, () => said, holdsQuestions ? questions : undefined));
92
+ }, () => said, capsQuestions ? questions : undefined));
116
93
  if (capsQuestions)
117
94
  customTools.push(createEndQuestionsTool(questions));
118
95
  }
@@ -125,14 +102,15 @@ async function runStoppable(opts) {
125
102
  customTools.push(tool);
126
103
  }
127
104
  }
128
- if (diffs !== undefined)
129
- customTools.push(...diffs.tools);
130
105
  customTools.push(...(opts.sharedTools ?? []));
131
106
  // Its write and edit reach the project's ***plain only - not the code, a release, or what an app it started writes.
132
107
  customTools.push(...plainWriteTools(opts.cwd).filter((tool) => skill.allowedTools.includes(tool.name)));
108
+ // Its shell runs neither turri nor another pi again: that would build outside the session's work loop.
109
+ if (skill.allowedTools.includes("bash"))
110
+ customTools.push(skillShell(opts.cwd));
133
111
  const names = customTools.map((tool) => tool.name);
134
112
  // Tools this harness provides are never pi built-ins, even when it did not provide them.
135
- const builtins = skill.allowedTools.filter((t) => !names.includes(t) && t !== CHANGE_PLAIN && !LOOP_TOOLS.includes(t));
113
+ const builtins = skill.allowedTools.filter((t) => !names.includes(t) && !LOOP_TOOLS.includes(t));
136
114
  const executor = await createExecutor({
137
115
  cwd: opts.cwd,
138
116
  customTools,
@@ -203,11 +181,6 @@ async function runStoppable(opts) {
203
181
  });
204
182
  manifest.sessionFile = executor.sessionFile;
205
183
  writeManifest(runDir, manifest);
206
- // Built renders were lost with the process; queue what the specs hold that is not built.
207
- if (resumed !== undefined && opts.renderQueue !== undefined) {
208
- for (const file of plainFilesIn(opts.cwd))
209
- void opts.renderQueue.bringUp(file, { specChange: true }).catch(() => undefined);
210
- }
211
184
  if (liveStep !== undefined && liveProxy !== undefined) {
212
185
  const continuous = liveStep.gate.continuous;
213
186
  holder.reviewer = createLiveReviewer({
@@ -243,7 +216,6 @@ async function runStoppable(opts) {
243
216
  writeManifest(runDir, manifest);
244
217
  },
245
218
  beforeStep: async (step) => {
246
- currentStep = step;
247
219
  if (!capsQuestions)
248
220
  return;
249
221
  // The first question of the first phase is the harness's: how many the capped phases may ask.
@@ -295,17 +267,6 @@ function writeManifest(runDir, manifest) {
295
267
  manifest.updatedAt = new Date().toISOString();
296
268
  writeFileSync(join(runDir, MANIFEST), JSON.stringify(manifest, null, 2));
297
269
  }
298
- /** The .plain files at the top of a project. */
299
- function plainFilesIn(dir) {
300
- try {
301
- return readdirSync(dir)
302
- .filter((name) => name.endsWith(".plain"))
303
- .map((name) => join(dir, name));
304
- }
305
- catch {
306
- return [];
307
- }
308
- }
309
270
  /** Whether there is a run of this skill here that was interrupted, and could be resumed. */
310
271
  export function interruptedRun(runDir, skillName) {
311
272
  const manifest = readManifest(resolve(runDir));
package/dist/graph.js CHANGED
@@ -49,13 +49,11 @@ export function endsOnQuestion(reply) {
49
49
  return /\?$/.test(last.replace(/[*_`)\]"'\s]+$/, ""));
50
50
  }
51
51
  /** Sent when a step's turn ended on a question in its reply: no one reads it, and the step is not done. */
52
- function unansweredQuestionPrompt(skill, step) {
52
+ function unansweredQuestionPrompt(step) {
53
53
  return [
54
54
  "Your turn ended on a question in your reply. No one reads it: the person sees only what ask_user asks, and",
55
55
  `the step ends when your turn does - so step '${step.name}' would end here, not done.`,
56
- skill.paced
57
- ? "If it is truly the person's to decide, ask it with ask_user. Otherwise decide it yourself."
58
- : `'${skill.name}' asks the person nothing more: decide it yourself, as a careful engineer would, and say what you chose.`,
56
+ "If it is truly the person's to decide, ask it with ask_user. Otherwise decide it yourself.",
59
57
  `Then carry on with step '${step.name}' until all of it is done, and end your turn only then.`,
60
58
  ].join("\n");
61
59
  }
@@ -124,7 +122,7 @@ export function compileSkill(opts) {
124
122
  // A question in the reply reaches no one - the person sees only what ask_user asks - and the step ends with the
125
123
  // turn: back to the work, so a step is not left half done on a question nobody answers.
126
124
  for (let nudges = 0; nudges < QUESTION_NUDGES && endsOnQuestion(reply); nudges += 1) {
127
- reply = await ask(opts.executor, unansweredQuestionPrompt(skill, step));
125
+ reply = await ask(opts.executor, unansweredQuestionPrompt(step));
128
126
  }
129
127
  let artifact = "";
130
128
  try {
@@ -1,7 +1,6 @@
1
1
  import { type AgentSession, type ExtensionFactory, type ExtensionUIContext } from "@earendil-works/pi-coding-agent";
2
2
  import type { AskUserIO } from "./ask.ts";
3
3
  import { type ChatInfo, type TurriHost } from "./chats.ts";
4
- import { type EvaluateOutcome } from "./advisor-chat.ts";
5
4
  import type { JobRegistry } from "./regenerate/jobs.ts";
6
5
  import type { WorkLoop } from "./regenerate/loop.ts";
7
6
  import type { Notice, NoticeAnswer } from "./notice.ts";
@@ -81,16 +80,6 @@ export interface Turri {
81
80
  } | {
82
81
  refused: string;
83
82
  };
84
- /**
85
- * The test advisor asked to evaluate functional specs, as the chat's `evaluate_tests` does - for a host's own way in,
86
- * a button on a functional spec: `module:func-id`s, or func-ids of `plainFile`'s module, even a text judged already and
87
- * whatever `test-advisor` says, `reason` given to it as context. It returns at once; each verdict comes to the chat the
88
- * person looks at, as the advisor's verdicts do - a yes starting a turn that writes the scenarios, a no a line.
89
- */
90
- evaluateTests(funcIds: string[], options?: {
91
- plainFile?: string;
92
- reason?: string;
93
- }): EvaluateOutcome;
94
83
  /**
95
84
  * Every value /turri-config offers for a setting after `typed` - what its completions compute, in their order, but
96
85
  * whole: uncapped, and without "unset", which a host draws itself; the values alone, not `<key> <value>`. A model
@@ -99,10 +88,10 @@ export interface Turri {
99
88
  */
100
89
  settingChoices(key: string, typed?: string): string[];
101
90
  /**
102
- * Conformance tests turned on, as the chat's turn_on_conformance_tests does: `conformance-tests: true` written where
103
- * the module's value comes from - its stack's `config.turri.<stack>.yaml` when that sets the key, else
104
- * `config.turri.yaml` - and every open chat's tools switched (conform and evaluate_tests in, turn_on_conformance_tests
105
- * out), the test advisor starting at its next look. `plainFile`, absolute or from the project, picks the module; omitted,
91
+ * Conformance tests turned on, as /conform does before it tests - the person's decision, a host's switch for it:
92
+ * `conformance-tests: true` written where the module's value comes from - its stack's `config.turri.<stack>.yaml` when
93
+ * that sets the key, else `config.turri.yaml` - the chats' conform no longer refused. `plainFile`, absolute or from the
94
+ * project, picks the module; omitted,
106
95
  * the project's. Returns the file written, from the project. Starts no conformance pulse: that is `conform`'s.
107
96
  */
108
97
  turnOnConformanceTests(plainFile?: string): string;
@@ -1,16 +1,15 @@
1
1
  import { createAgentSession, DefaultResourceLoader, getAgentDir, SessionManager } from "@earendil-works/pi-coding-agent";
2
2
  import { lastRun } from "./chat-records.js";
3
3
  import { interruptChat } from "./chats.js";
4
- import { evaluateTests } from "./advisor-chat.js";
5
4
  import { reachable, ruleNames, settingCandidates } from "./config-command.js";
6
5
  import { settingOf } from "./config-edit.js";
7
- import { createTurriCore, sessionAdvisor, sessionLoop, turnOnConformance } from "./extension.js";
6
+ import { createTurriCore, sessionLoop, turnOnConformance } from "./extension.js";
8
7
  import { stopDeployed } from "./regenerate/release.js";
9
8
  import { prepareCheck } from "./sentinel-check.js";
10
9
  /** turri's session in a host, in the process's working folder - the project's. */
11
10
  export async function createTurri(options = {}) {
12
11
  const { dialogs, uiContext, extensions = [], agentDir = getAgentDir(), sessionDir, restore, ...host } = options;
13
- const core = createTurriCore(host, { persist: true, advisor: true, ...(dialogs !== undefined ? { dialogs } : {}) });
12
+ const core = createTurriCore(host, { persist: true, ...(dialogs !== undefined ? { dialogs } : {}) });
14
13
  const cwd = core.cwd;
15
14
  core.setDriver({
16
15
  async create(chat, sessionFile) {
@@ -73,7 +72,6 @@ export async function createTurri(options = {}) {
73
72
  decline: async (id) => core.decline(id),
74
73
  notices: () => core.notices(),
75
74
  check: (request) => core.check(() => prepareCheck(cwd, request)),
76
- evaluateTests: (funcIds, options) => evaluateTests(cwd, sessionAdvisor(core), funcIds, options),
77
75
  turnOnConformanceTests: (plainFile) => turnOnConformance(core, plainFile),
78
76
  settingChoices: (key, typed = "") => {
79
77
  const setting = settingOf(key, ruleNames());
package/dist/host.d.ts CHANGED
@@ -28,13 +28,11 @@ export { conceptsOf, type ModuleConcept } from "./plain/module-concepts.ts";
28
28
  export { conceptBeingTyped, findConcepts } from "./plain/concepts.ts";
29
29
  export { plainGraph, type PlainConceptNode, type PlainGraph, type PlainItemNode, type PlainLink, type PlainModuleNode, type PlainScenario, type PlainSection, type PlainTestPlainFileNode } from "./plain/graph.ts";
30
30
  export { isStack, STDLIB_KINDS, stdlibTemplates, type StdlibKind, type StdlibTemplate } from "./stdlib.ts";
31
- export { createWorkLoop, describeModules, functionalityCompletion, promptOf, type DriftReport, type ModuleStatus, type WorkLoop } from "./regenerate/loop.ts";
31
+ export { createWorkLoop, describeModules, functionalityCompletion, type DriftReport, type ModuleStatus, type PlannedPulse, type WorkLoop } from "./regenerate/loop.ts";
32
32
  export { projectStanding, type ModuleStanding, type StandingOptions } from "./regenerate/standing.ts";
33
33
  export { requiresOrder } from "./regenerate/requires.ts";
34
34
  export { createJobRegistry, defaultParallelJobs, type Job, type JobRegistry, type PulseCases, type PulseSpec } from "./regenerate/jobs.ts";
35
35
  export { describeTurnIncident, onModelEvent, type TranscriptEntry } from "./regenerate/activity.ts";
36
36
  export { sweepOrphanedGroups } from "./regenerate/shell.ts";
37
- export { readAdvisor, textHash, type AdvisorEntry, type AdvisorFile, type AdvisorReport, type AdvisorState } from "./regenerate/advisor-records.ts";
38
- export type { EvaluateOutcome } from "./advisor-chat.ts";
39
37
  export { ledgerDir, onLedgerEvent, readLedger, type AgentRef, type LedgerEntry, type LedgerEvent, type LedgerKind, type LedgerQuery } from "./regenerate/ledger.ts";
40
38
  export { asJob, describePulseView, describeRuns, earlierPulses, ledgerProjects, pulseView, runViews, type PulseView, type RunView } from "./regenerate/ledger-view.ts";
package/dist/host.js CHANGED
@@ -42,15 +42,12 @@ export { plainGraph } from "./plain/graph.js";
42
42
  // The standard library: every template, what it is, what it imports, and its conformance template or stack.
43
43
  export { isStack, STDLIB_KINDS, stdlibTemplates } from "./stdlib.js";
44
44
  // The work: what is built, what is left, and the jobs that build it.
45
- export { createWorkLoop, describeModules, functionalityCompletion, promptOf } from "./regenerate/loop.js";
45
+ export { createWorkLoop, describeModules, functionalityCompletion } from "./regenerate/loop.js";
46
46
  export { projectStanding } from "./regenerate/standing.js";
47
47
  export { requiresOrder } from "./regenerate/requires.js";
48
48
  export { createJobRegistry, defaultParallelJobs } from "./regenerate/jobs.js";
49
49
  export { describeTurnIncident, onModelEvent } from "./regenerate/activity.js";
50
50
  export { sweepOrphanedGroups } from "./regenerate/shell.js";
51
- // The test advisor: what it made of each functional spec of a module - pending, yes, no or failed, with its report - by
52
- // func-id, an entry current while its hash is textHash of the functional spec's text; and what an evaluation came to.
53
- export { readAdvisor, textHash } from "./regenerate/advisor-records.js";
54
51
  // What turri did, as facts: the ledger, heard live and read back - this session's pulses and every earlier one's.
55
52
  export { ledgerDir, onLedgerEvent, readLedger } from "./regenerate/ledger.js";
56
53
  export { asJob, describePulseView, describeRuns, earlierPulses, ledgerProjects, pulseView, runViews } from "./regenerate/ledger-view.js";
package/dist/identity.js CHANGED
@@ -67,7 +67,6 @@ const IDENTITY_BEFORE = [
67
67
  " allow-to-stop-jobs in config.turri.yaml are about pulses. \"Job\" in what you read is a pulse; say pulse.",
68
68
  ];
69
69
  const IDENTITY_AFTER = [
70
- "- mutate, in a skill's activity, is change_plain: a spec change written and regenerated in one step.",
71
70
  "- Regenerate is the word for what you do to the code: never grow, grew or grown - older text, a tool's description",
72
71
  " or a report may still say it, and means regenerate.",
73
72
  ];
@@ -113,7 +113,6 @@ export declare const DEFAULTS: {
113
113
  readonly allowToStopJobs: true;
114
114
  readonly releaseAfterPulse: true;
115
115
  readonly sentinel: "ask";
116
- readonly testAdvisor: true;
117
116
  readonly testingScriptsRunOn: "in-place";
118
117
  readonly turnLimit: 120;
119
118
  readonly compactAt: 100000;
@@ -229,7 +229,6 @@ export const DEFAULTS = {
229
229
  allowToStopJobs: true,
230
230
  releaseAfterPulse: true,
231
231
  sentinel: "ask",
232
- testAdvisor: true,
233
232
  testingScriptsRunOn: "in-place",
234
233
  turnLimit: 120,
235
234
  compactAt: 100000,
@@ -257,8 +256,8 @@ export function quickStartConfig(vendor = "other", bedrock, models) {
257
256
  "# one to use it. docs/config.md has them all.",
258
257
  "",
259
258
  "# Whether functional specs are conformance tested: black-box tests of the built software against the scenarios of",
260
- "# their test plain files, run with the whole suite as more lands. false: none - no scenarios written or tested, the",
261
- "# test advisor off. Asking for them in the chat turns them on, or true here.",
259
+ "# their test plain files, run with the whole suite as more lands. They make each change take about twice as long.",
260
+ "# false: none - no scenarios written or tested. /conform in the chat turns them on, or true here.",
262
261
  "conformance-tests: false",
263
262
  "",
264
263
  "# Whether the code and its tests are reviewed once they pass - two reviews at most, the second weighed by the arbiter.",
@@ -279,11 +278,6 @@ export function quickStartConfig(vendor = "other", bedrock, models) {
279
278
  "# before it first opens in a session; true: it opens without asking; false: none.",
280
279
  `sentinel: ${DEFAULTS.sentinel}`,
281
280
  "",
282
- "# Whether turri checks, in the background, each new or changed functional spec with no scenarios - could it fail",
283
- "# silently, be read two ways, cost a lot when wrong - and when it needs testing, writes its test reqs, conformance",
284
- "# testing script and scenarios itself. false: only the scenarios you ask for are written.",
285
- `test-advisor: ${DEFAULTS.testAdvisor}`,
286
- "",
287
281
  "# What the testing scripts run on: in-place - the code itself; copy - a fresh copy of it.",
288
282
  `testing-scripts-run-on: ${DEFAULTS.testingScriptsRunOn}`,
289
283
  "",
@@ -366,7 +360,6 @@ export function quickStartConfig(vendor = "other", bedrock, models) {
366
360
  role("judge", strong, "judges a failing conformance run - as judge-model, which it wins over"),
367
361
  role("arbiter", strong, "weighs a second review"),
368
362
  role("debugger", strong, "a fresh look at unit tests that keep failing the same way"),
369
- role("advisor", coding, "the test advisor: which functional specs need scenarios"),
370
363
  "",
371
364
  ].join("\n");
372
365
  }
@@ -5,7 +5,7 @@ import { ModelRegistry, ModelRuntime } from "@earendil-works/pi-coding-agent";
5
5
  *
6
6
  * In a chat, pi loads the person's installed pi packages itself, and turri's agents take the providers from the
7
7
  * conversation's model registry (pi.ts `inheritProviders`). A command with no conversation - `turri regenerate`,
8
- * `turri change-plain`, doctor's model check, init-config - has none: here they are loaded the way pi loads them, once a
8
+ * `turri conform`, doctor's model check, init-config - has none: here they are loaded the way pi loads them, once a
9
9
  * process, and only the providers they register are kept. turri's own extension, when an older turri installed it into
10
10
  * every pi, is loaded as nothing meanwhile (`LOADING_PROVIDERS`): it would start a session of its own.
11
11
  */
@@ -6,7 +6,7 @@ import { createAgentSessionServices, getAgentDir, ModelRegistry, ModelRuntime }
6
6
  *
7
7
  * In a chat, pi loads the person's installed pi packages itself, and turri's agents take the providers from the
8
8
  * conversation's model registry (pi.ts `inheritProviders`). A command with no conversation - `turri regenerate`,
9
- * `turri change-plain`, doctor's model check, init-config - has none: here they are loaded the way pi loads them, once a
9
+ * `turri conform`, doctor's model check, init-config - has none: here they are loaded the way pi loads them, once a
10
10
  * process, and only the providers they register are kept. turri's own extension, when an older turri installed it into
11
11
  * every pi, is loaded as nothing meanwhile (`LOADING_PROVIDERS`): it would start a session of its own.
12
12
  */
@@ -1,11 +1,11 @@
1
1
  import { type DriftReport, type ModuleStatus, type WorkLoop } from "./regenerate/loop.ts";
2
2
  import { type ModuleState } from "./run-report.ts";
3
3
  /**
4
- * What every command that builds - `turri regenerate`, `conform`, `change-plain` - does around its own
4
+ * What every command that builds - `turri regenerate`, `conform` - does around its own
5
5
  * request of the work loop, as the chat does it: the project's models, a job that fails run once more and, failing again,
6
6
  * diagnosed, a line as each job starts and ends; then the loop run until nothing more can start, how each job ended,
7
- * and exit 1 when any failed or a module is not complete. With `dryRun`, the work is planned and the prompt of the first job each codebase would
8
- * start printed, and nothing runs.
7
+ * and exit 1 when any failed or a module is not complete. With `dryRun`, `ask` is a look ahead (`WorkLoop.lookAhead`): the work is
8
+ * planned, the prompt of the next pulse of each codebase printed from the plan kept, and nothing runs.
9
9
  */
10
10
  export declare function runLoop(options: {
11
11
  plainFile: string;
@@ -15,6 +15,7 @@ export declare function runLoop(options: {
15
15
  report?: string;
16
16
  /** The command, as the report gives it: its name and its arguments. */
17
17
  command?: string[];
18
+ /** Plan and print the next pulses, starting nothing - `ask` a look ahead. */
18
19
  dryRun?: boolean;
19
20
  /** Start over, unasked, a codebase that has to be on a module it now requires (`--start-over`). */
20
21
  startOver?: boolean;
package/dist/loop-cli.js CHANGED
@@ -10,18 +10,18 @@ import { ledgerWanted, startLedger } from "./regenerate/ledger.js";
10
10
  import { tryItCommand } from "./regenerate/delivery.js";
11
11
  import { describeDiagnosis, diagnoseFailure } from "./regenerate/diagnose.js";
12
12
  import { createJobRegistry, pulseName } from "./regenerate/jobs.js";
13
- import { createWorkLoop, describeModules, functionalityCompletion, promptOf } from "./regenerate/loop.js";
13
+ import { createWorkLoop, describeModules, functionalityCompletion } from "./regenerate/loop.js";
14
14
  import { MODULES_DIR, projectDirOf } from "./regenerate/paths.js";
15
15
  import { exportModule } from "./regenerate/release.js";
16
16
  import { listFiles } from "./regenerate/testing.js";
17
17
  import { startRunReport } from "./run-report.js";
18
18
  import { configKeyOptions, optionValue } from "./cli-options.js";
19
19
  /**
20
- * What every command that builds - `turri regenerate`, `conform`, `change-plain` - does around its own
20
+ * What every command that builds - `turri regenerate`, `conform` - does around its own
21
21
  * request of the work loop, as the chat does it: the project's models, a job that fails run once more and, failing again,
22
22
  * diagnosed, a line as each job starts and ends; then the loop run until nothing more can start, how each job ended,
23
- * and exit 1 when any failed or a module is not complete. With `dryRun`, the work is planned and the prompt of the first job each codebase would
24
- * start printed, and nothing runs.
23
+ * and exit 1 when any failed or a module is not complete. With `dryRun`, `ask` is a look ahead (`WorkLoop.lookAhead`): the work is
24
+ * planned, the prompt of the next pulse of each codebase printed from the plan kept, and nothing runs.
25
25
  */
26
26
  export async function runLoop(options) {
27
27
  const plainFile = resolve(options.plainFile);
@@ -110,7 +110,6 @@ async function runLoopReporting(options) {
110
110
  cwd: process.cwd(),
111
111
  ...(model !== undefined ? { modelFor: () => model } : {}),
112
112
  ...(planner !== undefined ? { plannerModel: planner } : {}),
113
- ...(options.dryRun === true ? { dryRun: true } : {}),
114
113
  });
115
114
  report?.attach({
116
115
  jobs: () => registry.list(),
@@ -146,13 +145,16 @@ async function runLoopReporting(options) {
146
145
  }
147
146
  }
148
147
  if (options.dryRun === true) {
149
- for (const first of loop.firsts()) {
150
- console.log(`\n${c.bold(`${first.module}: ${first.planned.title}`)}${first.planned.track === "conformance" ? c.dim(" (conformance)") : ""}`);
151
- if (first.planned.track === "conformance") {
152
- console.log(c.dim("A conformance job's prompt is built from what the code it tests holds once it is built: not shown before."));
148
+ // The next pulse of each codebase, from the plan the look ahead kept - the one regenerate would start.
149
+ for (const status of planned) {
150
+ const first = status.planned[0];
151
+ if (first === undefined || first.afterCode === true || first.planning === true)
153
152
  continue;
154
- }
155
- console.log((await promptOf(first)) ?? "(no task)");
153
+ const next = await loop.plannedPulse(`planned-${status.module}-1`);
154
+ if (next === undefined)
155
+ continue;
156
+ console.log(`\n${c.bold(`${next.module}: ${next.title}`)}${next.track === "conformance" ? c.dim(" (conformance)") : ""}`);
157
+ console.log(next.task ?? c.dim(next.why ?? "(no task)"));
156
158
  }
157
159
  process.exit(0);
158
160
  }
@@ -2,7 +2,7 @@ import { type ExtensionContext, type ToolDefinition } from "@earendil-works/pi-c
2
2
  import { Type } from "typebox";
3
3
  import { type ModuleStatus, type WorkLoop } from "./regenerate/loop.ts";
4
4
  import type { RenderWork } from "./regenerate/engine.ts";
5
- import { type JobRegistry } from "./regenerate/jobs.ts";
5
+ import { type Job, type JobRegistry } from "./regenerate/jobs.ts";
6
6
  /**
7
7
  * The tools that act on the work loop - `regenerate`, `drift` and `halt` - defined once, for the conversation and for the
8
8
  * skills alike: a skill that regenerates what a spec holds, or reads how far it is regenerated, uses the conversation's
@@ -37,8 +37,31 @@ export declare function fromWorkingDir<T extends {
37
37
  }>(cwd: string, params: T): T & {
38
38
  base: string;
39
39
  };
40
- /** What the loop is doing for a spec's modules, for the conversation - and, waiting, how each module ended. */
41
- export declare function loopReply(loop: WorkLoop, statuses: ModuleStatus[], wait: boolean): Promise<{
40
+ /**
41
+ * A call that waits for its pulses - print, json and rpc modes, or `wait: true` - in the chat it was made in: every pulse
42
+ * of that chat that was not there when it was made, and ends while it waits, is told in its reply.
43
+ */
44
+ export interface Wait {
45
+ chat: string | undefined;
46
+ before: ReadonlySet<string>;
47
+ }
48
+ /** A call in this chat starts waiting, from the pulses there are now. */
49
+ export declare function startWait(jobs: JobRegistry): Wait;
50
+ /** A call is done waiting: what ends now is told as any pulse's end is. */
51
+ export declare function endWait(jobs: JobRegistry, wait: Wait): void;
52
+ /**
53
+ * Whether a pulse that ended is told by a call still waiting in its chat - its agent is told it in that call's reply, so
54
+ * a turn of its own to say it again would only repeat it.
55
+ */
56
+ export declare function toldByWaitingCall(jobs: JobRegistry, job: Job): boolean;
57
+ /**
58
+ * What the loop is doing for a spec's modules, for the conversation - and, waiting, the pulses that ran meanwhile and how
59
+ * each ended, then how each module stands: `ran` is the registry and the call's wait (startWait).
60
+ */
61
+ export declare function loopReply(loop: WorkLoop, statuses: ModuleStatus[], wait: boolean, ran?: {
62
+ jobs: JobRegistry;
63
+ wait: Wait;
64
+ }): Promise<{
42
65
  content: {
43
66
  type: "text";
44
67
  text: string;
@@ -3,11 +3,13 @@ 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 { advisingNote } from "./advisor-chat.js";
7
6
  import { CONFIG_FILE, readProjectConfig, stackConfigFile, stackForModule, stackNamed, stacksOf, withStack } from "./config.js";
8
7
  import { checkPlainFile, formatCheckResults } from "./plain/check.js";
9
8
  import { describeDrift, describeModules } from "./regenerate/loop.js";
10
- import { pulseName } from "./regenerate/jobs.js";
9
+ import { describeJob, pulseName } from "./regenerate/jobs.js";
10
+ import { currentChat } from "./chat-scope.js";
11
+ import { whyFailed } from "./regenerate/diagnose-job.js";
12
+ import { didNotLand } from "./regenerate/failure-reports.js";
11
13
  import { stopDeployed } from "./regenerate/release.js";
12
14
  import { projectDirOf } from "./regenerate/paths.js";
13
15
  import { findTestScripts } from "./regenerate/test-scripts.js";
@@ -18,15 +20,14 @@ export const GUIDANCE_PARAM = Type.Optional(Type.String({
18
20
  "the user said it, or as you understood it. A strong preference for the planner, within its limits. Omit when there is none.",
19
21
  }));
20
22
  export const WORKING_DIR_PARAM = Type.Optional(Type.String({
21
- description: "The folder to render from, relative to where turri was started - as if it had been started there " +
22
- "(e.g. \"plain\"). plain_file, build_dir and a spec diff's paths are then relative to it - hubspot.plain, not " +
23
- "plain/hubspot.plain. Default: where " +
23
+ description: "The folder the .plain files are in, relative to where turri was started - as if it had been started there " +
24
+ "(e.g. \"plain\"). plain_file is then relative to it - hubspot.plain, not plain/hubspot.plain. Default: where " +
24
25
  "turri was started.",
25
26
  }));
26
27
  export const MODEL_PARAM = Type.Optional(Type.String({
27
28
  description: "The model for the agents of this one call: a provider/model-id, or its name as the user said it. " +
28
29
  "Omitted: the model chosen for this kind of work with engine, else the conversation's. " +
29
- "To change it for every later render, use engine instead.",
30
+ "To change it for every later pulse, use engine instead.",
30
31
  }));
31
32
  export const STACK_PARAM = Type.Optional(Type.String({
32
33
  description: "In a project of stacks: the stack that builds this module - its config.turri.<stack>.yaml over config.turri.yaml, " +
@@ -92,13 +93,69 @@ export function fromWorkingDir(cwd, params) {
92
93
  ...(params.build_dir !== undefined ? { build_dir: resolve(base, params.build_dir) } : {}),
93
94
  };
94
95
  }
95
- /** What the loop is doing for a spec's modules, for the conversation - and, waiting, how each module ended. */
96
- export async function loopReply(loop, statuses, wait) {
97
- if (wait)
98
- await loop.drain();
96
+ /** The calls waiting now, by registry. */
97
+ const waits = new WeakMap();
98
+ /** A call in this chat starts waiting, from the pulses there are now. */
99
+ export function startWait(jobs) {
100
+ const wait = { chat: currentChat()?.id, before: new Set(jobs.list().map((job) => job.id)) };
101
+ const set = waits.get(jobs) ?? new Set();
102
+ set.add(wait);
103
+ waits.set(jobs, set);
104
+ return wait;
105
+ }
106
+ /** A call is done waiting: what ends now is told as any pulse's end is. */
107
+ export function endWait(jobs, wait) {
108
+ waits.get(jobs)?.delete(wait);
109
+ }
110
+ /**
111
+ * Whether a pulse that ended is told by a call still waiting in its chat - its agent is told it in that call's reply, so
112
+ * a turn of its own to say it again would only repeat it.
113
+ */
114
+ export function toldByWaitingCall(jobs, job) {
115
+ for (const wait of waits.get(jobs) ?? [])
116
+ if (wait.chat === job.chat && !wait.before.has(job.id))
117
+ return true;
118
+ return false;
119
+ }
120
+ /** A module's why while it waits for a testing script being written (loop.ts SCRIPT_BEING_WRITTEN). */
121
+ const SCRIPT_WAIT = /, which is being written$/;
122
+ /** How often a waiting call looks again while its module waits for a testing script. */
123
+ const SCRIPT_POLL_MS = 500;
124
+ /** How much of each pulse that ran while a call waited is told: the rest is pulses' with its id. */
125
+ const RAN_CHARS = 3_000;
126
+ /**
127
+ * What the loop is doing for a spec's modules, for the conversation - and, waiting, the pulses that ran meanwhile and how
128
+ * each ended, then how each module stands: `ran` is the registry and the call's wait (startWait).
129
+ */
130
+ export async function loopReply(loop, statuses, wait, ran) {
131
+ try {
132
+ if (wait) {
133
+ await loop.drain();
134
+ // A module held for a testing script being written - beside this call, by a skill run - starts once it is: a call
135
+ // that waits waits for that too, rather than say it waits and end before its pulse runs.
136
+ while (loop.status().some((status) => statuses.some((asked) => asked.plainFile === status.plainFile) && SCRIPT_WAIT.test(status.why ?? ""))) {
137
+ await new Promise((resolve) => setTimeout(resolve, SCRIPT_POLL_MS));
138
+ await loop.drain();
139
+ }
140
+ }
141
+ }
142
+ finally {
143
+ if (ran !== undefined)
144
+ endWait(ran.jobs, ran.wait);
145
+ }
99
146
  const now = wait ? loop.status().filter((status) => statuses.some((asked) => asked.plainFile === status.plainFile)) : statuses;
100
147
  const jobIds = now.flatMap((status) => (status.running !== undefined ? [status.running.jobId] : []));
148
+ const pulses = wait && ran !== undefined ? ran.jobs.list().filter((job) => job.chat === ran.wait.chat && !ran.wait.before.has(job.id)).sort((a, b) => a.sequence - b.sequence) : [];
149
+ const cut = (text) => (text.length > RAN_CHARS ? `${text.slice(0, RAN_CHARS)}\n… cut short: pulses with its id tells the whole of it` : text);
101
150
  const text = [
151
+ ...(pulses.length > 0
152
+ ? [
153
+ `What ran while you waited - ${pulses.length} pulse${pulses.length === 1 ? "" : "s"}:`,
154
+ ...pulses.map((job) => `\n<pulse id="${job.id}" landed="${didNotLand(job) ? "no" : "yes"}">\n${cut(didNotLand(job) ? whyFailed(job) : describeJob(job))}\n</pulse>`),
155
+ "",
156
+ "How each module stands now:",
157
+ ]
158
+ : []),
102
159
  describeModules(now),
103
160
  "",
104
161
  wait
@@ -213,15 +270,23 @@ export function regenerateTool(options) {
213
270
  const model = options.model !== undefined ? options.model(ctx, plainFile, given.model, work) : given.model;
214
271
  const loop = options.loop(ctx);
215
272
  const request = { ...(model !== undefined ? { model } : {}), ...(given.guidance !== undefined ? { guidance: given.guidance } : {}) };
216
- const statuses = given.from_scratch !== undefined
217
- ? await loop.fromScratch(plainFile, { ...request, chain: given.from_scratch === "chain" })
218
- : again.length > 0
219
- ? await loop.regenerateAgain(plainFile, again, request)
220
- : await loop.bringUp(plainFile, request);
221
- const reply = await loopReply(loop, statuses, options.wait !== undefined ? options.wait(ctx, given.wait) : given.wait === true);
222
- // The functional specs the test advisor took up, for the agent to say so rather than offer their scenarios.
223
- const advising = advisingNote(loop, plainFile);
224
- return advising === "" ? reply : { ...reply, content: [...reply.content, { type: "text", text: advising }] };
273
+ const wait = options.wait !== undefined ? options.wait(ctx, given.wait) : given.wait === true;
274
+ const waiting = wait && options.jobs !== undefined ? { jobs: options.jobs, wait: startWait(options.jobs) } : undefined;
275
+ let statuses;
276
+ try {
277
+ statuses =
278
+ given.from_scratch !== undefined
279
+ ? await loop.fromScratch(plainFile, { ...request, chain: given.from_scratch === "chain" })
280
+ : again.length > 0
281
+ ? await loop.regenerateAgain(plainFile, again, request)
282
+ : await loop.bringUp(plainFile, request);
283
+ }
284
+ catch (error) {
285
+ if (waiting !== undefined)
286
+ endWait(waiting.jobs, waiting.wait);
287
+ throw error;
288
+ }
289
+ return loopReply(loop, statuses, wait, waiting);
225
290
  });
226
291
  },
227
292
  });
@@ -237,7 +302,7 @@ export function driftTool(options) {
237
302
  "with nothing left, it says the module is fully regenerated. It plans nothing and starts nothing, and calls no model.",
238
303
  promptSnippet: "drift: what is left to regenerate in a module, code and conformance tests - starting nothing",
239
304
  promptGuidelines: [
240
- "Use drift when the user asks what is left to build, whether a module is up to date with its spec, or what changed since it was last regenerated. To see the next pulse's prompt as well, use glimpse.",
305
+ "Use drift when the user asks what is left to build, whether a module is up to date with its spec, or what changed since it was last regenerated. To see how it is planned into pulses, and the next pulse's prompt, use pulses with plain_file.",
241
306
  ],
242
307
  parameters: Type.Object({
243
308
  plain_file: Type.Optional(Type.String({ description: "Path to the .plain file. Omitted: the module the project's config.turri.yaml names" })),
@@ -15,8 +15,8 @@ export const NEW_PROJECT = [
15
15
  " chosen again.",
16
16
  "4. The unit testing script: keep one turri already finds; otherwise start cultivate with implement-unit-testing-script,",
17
17
  " plainFile the new module. It runs in the background: go straight on - the module's pulses wait for the script.",
18
- " Tests only if the person asked for them: turn conformance tests on first (turn_on_conformance_tests), then in this",
19
- " order: the ***test reqs*** - the stack's conformance template - then cultivate with",
18
+ " Tests only once conformance tests are on: they make each change take about twice as long, so the person turns them",
19
+ " on - asked for tests, tell them /conform does - then in this order: the ***test reqs*** - the stack's conformance template - then cultivate with",
20
20
  " implement-conformance-testing-script, in the background too, then the scenarios.",
21
21
  "5. The first functional spec: the smallest thing that runs and shows something - the server answers GET / with the",
22
22
  " app's name, the CLI prints its usage - with no test plain file, unless they asked for tests. parse, fix",