@turri-dev/core 0.1.1-next.8cda3cc → 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.
Files changed (163) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/README.md +17 -11
  3. package/dist/api/models.d.ts +9 -0
  4. package/dist/api/models.js +15 -0
  5. package/dist/api/plain.d.ts +6 -6
  6. package/dist/api/plain.js +4 -7
  7. package/dist/api/project.d.ts +35 -0
  8. package/dist/api/project.js +47 -0
  9. package/dist/api/session.d.ts +48 -0
  10. package/dist/api/session.js +17 -0
  11. package/dist/api/system.d.ts +18 -0
  12. package/dist/api/system.js +23 -0
  13. package/dist/btw.d.ts +1 -1
  14. package/dist/capture/capture.js +11 -8
  15. package/dist/capture/chat.d.ts +0 -11
  16. package/dist/capture/chat.js +0 -29
  17. package/dist/capture/config.d.ts +4 -5
  18. package/dist/capture/config.js +34 -20
  19. package/dist/capture/models.d.ts +2 -1
  20. package/dist/capture/models.js +1 -0
  21. package/dist/chat-entries.d.ts +81 -39
  22. package/dist/chat-entries.js +125 -11
  23. package/dist/chat-model.d.ts +37 -0
  24. package/dist/chat-model.js +61 -0
  25. package/dist/chats.d.ts +54 -42
  26. package/dist/chats.js +86 -80
  27. package/dist/client.d.ts +30 -0
  28. package/dist/client.js +12 -0
  29. package/dist/config-edit.d.ts +54 -1
  30. package/dist/config-edit.js +103 -33
  31. package/dist/config.d.ts +12 -9
  32. package/dist/config.js +38 -9
  33. package/dist/doctor-checks.d.ts +42 -0
  34. package/dist/doctor-checks.js +39 -0
  35. package/dist/environment.d.ts +2 -23
  36. package/dist/environment.js +5 -68
  37. package/dist/errors.d.ts +32 -0
  38. package/dist/errors.js +24 -0
  39. package/dist/extension.d.ts +23 -16
  40. package/dist/extension.js +170 -234
  41. package/dist/identity.d.ts +1 -1
  42. package/dist/identity.js +13 -9
  43. package/dist/init-config.d.ts +11 -9
  44. package/dist/init-config.js +15 -7
  45. package/dist/launch-session.d.ts +2 -0
  46. package/dist/launch-session.js +17 -1
  47. package/dist/loop-tools.js +11 -10
  48. package/dist/module-check.d.ts +13 -0
  49. package/dist/module-check.js +117 -0
  50. package/dist/notice.d.ts +5 -0
  51. package/dist/parse-tool.js +3 -2
  52. package/dist/plain/check.d.ts +27 -13
  53. package/dist/plain/check.js +51 -116
  54. package/dist/plain/files.d.ts +2 -0
  55. package/dist/plain/files.js +13 -0
  56. package/dist/plain/graph.js +2 -2
  57. package/dist/plain/highlight.d.ts +4 -20
  58. package/dist/plain/highlight.js +7 -5
  59. package/dist/project.d.ts +19 -0
  60. package/dist/project.js +34 -0
  61. package/dist/quiet.d.ts +0 -2
  62. package/dist/quiet.js +0 -14
  63. package/dist/regenerate/command-check.d.ts +0 -8
  64. package/dist/regenerate/command-check.js +133 -53
  65. package/dist/regenerate/conversation-writes.d.ts +5 -1
  66. package/dist/regenerate/conversation-writes.js +7 -3
  67. package/dist/regenerate/jobs.d.ts +25 -2
  68. package/dist/regenerate/jobs.js +3 -0
  69. package/dist/regenerate/launch.d.ts +1 -0
  70. package/dist/regenerate/launch.js +9 -0
  71. package/dist/regenerate/ledger-view.d.ts +14 -14
  72. package/dist/regenerate/ledger.d.ts +1 -0
  73. package/dist/regenerate/ledger.js +4 -2
  74. package/dist/regenerate/loop.d.ts +2 -1
  75. package/dist/regenerate/loop.js +9 -1
  76. package/dist/regenerate/os-sandbox.d.ts +4 -2
  77. package/dist/regenerate/os-sandbox.js +0 -1
  78. package/dist/regenerate/regenerate.js +2 -1
  79. package/dist/regenerate/requires-chain.d.ts +44 -0
  80. package/dist/regenerate/requires-chain.js +174 -0
  81. package/dist/regenerate/requires.d.ts +2 -40
  82. package/dist/regenerate/requires.js +14 -171
  83. package/dist/regenerate/resources.d.ts +0 -2
  84. package/dist/regenerate/resources.js +2 -14
  85. package/dist/regenerate/shell.js +20 -9
  86. package/dist/regenerate/spec-map.d.ts +2 -0
  87. package/dist/regenerate/spec-map.js +4 -0
  88. package/dist/regenerate/standing.d.ts +5 -2
  89. package/dist/run-report.js +2 -2
  90. package/dist/self-invocation.d.ts +1 -1
  91. package/dist/self-invocation.js +2 -3
  92. package/dist/sentinel-chat.js +7 -11
  93. package/dist/sentinel.d.ts +1 -1
  94. package/dist/sentinel.js +12 -5
  95. package/dist/session-events.d.ts +14 -0
  96. package/dist/session.d.ts +594 -0
  97. package/dist/session.js +672 -0
  98. package/dist/settings.d.ts +28 -2
  99. package/dist/settings.js +92 -56
  100. package/dist/setup.d.ts +6 -30
  101. package/dist/setup.js +28 -105
  102. package/dist/stack.d.ts +25 -12
  103. package/dist/stack.js +77 -12
  104. package/dist/surface.d.ts +2 -2
  105. package/dist/surface.js +4 -5
  106. package/dist/work.d.ts +125 -0
  107. package/dist/work.js +250 -0
  108. package/docs/README.md +2 -3
  109. package/docs/capture.md +4 -4
  110. package/docs/chats.md +5 -3
  111. package/docs/claude-subscription.md +2 -2
  112. package/docs/config.md +4 -4
  113. package/docs/core.md +105 -128
  114. package/docs/development.md +9 -9
  115. package/docs/headless.md +1 -1
  116. package/docs/installation.md +4 -2
  117. package/docs/launch.md +2 -2
  118. package/docs/parser.md +1 -1
  119. package/docs/regenerating.md +1 -1
  120. package/docs/sandbox.md +4 -4
  121. package/docs/sentinel.md +4 -4
  122. package/docs/skills-and-gates.md +1 -1
  123. package/docs/using.md +2 -2
  124. package/genome/rules/integration-embedded-testing.md +3 -3
  125. package/genome/rules/integration-embedded.md +3 -3
  126. package/genome/skills/implement-conformance-testing-script/SKILL.md +6 -4
  127. package/genome/skills/implement-conformance-testing-script/assets/run_conformance_tests_java.sh +13 -11
  128. package/genome/skills/implement-conformance-testing-script/assets/run_conformance_tests_python.sh +8 -7
  129. package/genome/skills/implement-unit-testing-script/SKILL.md +7 -5
  130. package/genome/skills/implement-unit-testing-script/assets/run_unittests_java.sh +9 -13
  131. package/genome/skills/implement-unit-testing-script/assets/run_unittests_python.sh +1 -1
  132. package/package.json +19 -32
  133. package/dist/api/commands.d.ts +0 -45
  134. package/dist/api/commands.js +0 -54
  135. package/dist/api/config.d.ts +0 -8
  136. package/dist/api/config.js +0 -8
  137. package/dist/api/ledger.d.ts +0 -3
  138. package/dist/api/ledger.js +0 -3
  139. package/dist/api/startup.d.ts +0 -8
  140. package/dist/api/startup.js +0 -8
  141. package/dist/api/terminal.d.ts +0 -18
  142. package/dist/api/terminal.js +0 -16
  143. package/dist/chat-models.d.ts +0 -11
  144. package/dist/chat-models.js +0 -11
  145. package/dist/chat-ui.d.ts +0 -33
  146. package/dist/chat-ui.js +0 -192
  147. package/dist/headless.d.ts +0 -99
  148. package/dist/headless.js +0 -226
  149. package/dist/host-session.d.ts +0 -136
  150. package/dist/host-session.js +0 -139
  151. package/dist/host.d.ts +0 -8
  152. package/dist/host.js +0 -17
  153. package/dist/index.d.ts +0 -16
  154. package/dist/index.js +0 -7
  155. package/dist/notifications.d.ts +0 -21
  156. package/dist/notifications.js +0 -44
  157. package/dist/reopen.d.ts +0 -29
  158. package/dist/reopen.js +0 -47
  159. package/dist/turri-versions.d.ts +0 -71
  160. package/dist/turri-versions.js +0 -276
  161. package/dist/view.d.ts +0 -78
  162. package/dist/view.js +0 -1
  163. package/docs/hosting.md +0 -284
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Who the conversation's agent is: turri, and what it does - first, so it speaks as turri, in the first person. Where
3
- * the person watches the work is the terminal's regen; given a host's surface, that is said in its place.
3
+ * the person watches the work is the front end's surface, in its own words; without one, no view is named.
4
4
  */
5
5
  export declare function conversationIdentity(surface?: string): string;
6
6
  /** turri as the terminal runs it. */
package/dist/identity.js CHANGED
@@ -1,25 +1,24 @@
1
- /** In the terminal: regen, where the person watches the work - the side panel, its key, and the pulses behind it. */
2
- const REGEN = [
3
- "- regen is the side panel (ctrl+h): the spec with each functionality and item marked built, regenerating,",
4
- " planned or waiting - and behind it the pulses (/pulses), every pulse regenerating, planned and finished. Say regen,",
5
- " lowercase. It was the regeneration, the job queue, or the job panel.",
1
+ /** With no front end's words for it: where the person watches the work is not said, and no key or view is named. */
2
+ const NO_SURFACE = [
3
+ "- What the person sees of your work - where they watch it, and what they press - is not said here. Speak of no key,",
4
+ " panel or view: say what happened, and list the pulses with your tools when they ask.",
6
5
  ];
7
- /** In a host: where the person watches the work is the host's to say - its surface, below. */
8
- const HOST_SURFACE = [
6
+ /** Where the person watches the work is the front end's to say - its surface, below. */
7
+ const SURFACE = [
9
8
  "- What the person sees of your work - where they watch it, and what they press - is the app's you run in, and",
10
9
  " <surface> below says it in its own words. Say only what it says, and speak of no key, panel or view it does not",
11
10
  " name.",
12
11
  ];
13
12
  /**
14
13
  * Who the conversation's agent is: turri, and what it does - first, so it speaks as turri, in the first person. Where
15
- * the person watches the work is the terminal's regen; given a host's surface, that is said in its place.
14
+ * the person watches the work is the front end's surface, in its own words; without one, no view is named.
16
15
  */
17
16
  export function conversationIdentity(surface) {
18
17
  const text = surface?.trim() ?? "";
19
18
  const hosted = text !== "";
20
19
  return [
21
20
  ...IDENTITY_BEFORE,
22
- ...(hosted ? HOST_SURFACE : REGEN),
21
+ ...(hosted ? SURFACE : NO_SURFACE),
23
22
  ...IDENTITY_AFTER,
24
23
  ...(hosted ? ["", "<surface>", text, "</surface>"] : []),
25
24
  "</turri>",
@@ -61,6 +60,11 @@ const IDENTITY_BEFORE = [
61
60
  "change inside what the running pulse regenerates steers it, and the rest is planned again around it - the next",
62
61
  "change never waits for the last to land.",
63
62
  "",
63
+ "What the harness tells you itself - a pulse that ended, the sentinel's conclusion, a launch, a notice the person",
64
+ "answered - comes inside <turri-note> tags. A note is never the person's words. Only what is outside a note is the",
65
+ "person's: when their message follows a note in the same turn, it is theirs alone, however close to the note's",
66
+ "subject it seems - answer it as theirs.",
67
+ "",
64
68
  "Your words, and the older ones for the same things - a project's AGENTS.md, a skill, notes or the person may use",
65
69
  "either, and they mean the same:",
66
70
  "- A pulse is one unit of work regenerating the code - a spec diff regenerated in a codebase, or its conformance",
@@ -12,7 +12,7 @@ import { type CatalogueModel, type ModelCatalogue } from "./model-check.ts";
12
12
  * Amazon Bedrock serves many makers' models - Anthropic's, OpenAI's, xAI's, Meta's... - each in a geography, an inference
13
13
  * profile its id starts with (`global.`, `us.`, `eu.`, ...), or in the AWS region it is called in: it asks whose, where, and
14
14
  * which two, from pi's catalogue - turri's own pair offered where it has one. The two models can be given instead, any pair
15
- * pi's catalogue has, and are checked against it. A config.turri.yaml already there keeps everything but the two models; a
15
+ * pi's catalogue has, and are checked against it. An existing file gets the chosen pair and its three capture tiers; a
16
16
  * new one takes from a config.yaml beside it the keys turri reads too.
17
17
  */
18
18
  /** A vendor whose models the quick start config is filled in with. */
@@ -34,11 +34,13 @@ export interface ModelSet {
34
34
  strong: string;
35
35
  }
36
36
  /** The two models given, full specs without a thinking level - `amazon-bedrock/global.xai.grok-4.7`; strong is harness unless named. */
37
- export type ModelChoice = Omit<ModelSet, "strong"> & {
37
+ /** The two models given in place of a vendor's - the strong one, the judging examples', the harness model unless named. */
38
+ export type ModelPair = Omit<ModelSet, "strong"> & {
38
39
  strong?: string;
39
40
  };
40
41
  /** The makers turri has a pair of its own for on Bedrock. */
41
- type PresetMaker = "anthropic" | "openai";
42
+ /** The makers turri has a pair of its own for on Bedrock. */
43
+ export type PresetMaker = "anthropic" | "openai";
42
44
  /** The geographies turri's own pair for each maker is served in - the first the default. Every other: bedrockMakers. */
43
45
  export declare const BEDROCK_REGIONS: Record<PresetMaker, string[]>;
44
46
  /** The geographies an inference profile's id starts with, in the order they are offered. */
@@ -88,7 +90,8 @@ export declare function bedrockModels(choice: {
88
90
  export declare function bedrockDefaultModels(catalogue: ModelCatalogue, choice: BedrockChoice): ModelSet | undefined;
89
91
  /** Bedrock's default: Anthropic's models, anywhere. */
90
92
  export declare const BEDROCK_DEFAULT: Required<BedrockChoice>;
91
- interface VendorPreset {
93
+ /** A vendor's own pair, and how it is named. */
94
+ export interface VendorPreset {
92
95
  label: string;
93
96
  /** The model you talk to: it writes the specs and plans the work. */
94
97
  harness: string;
@@ -161,14 +164,14 @@ export interface Paint {
161
164
  /** No colour at all: the text as it is. */
162
165
  export declare const PLAIN_PAINT: Paint;
163
166
  export interface InitConfigOptions {
164
- /** Write the whole file again, not only the two models of one already there. */
167
+ /** Write the whole file again, not only the project and capture models. */
165
168
  force?: boolean;
166
169
  /** Whose models: read from the models when they are given, other when nothing says. */
167
170
  vendor?: Vendor;
168
171
  /** On Amazon Bedrock: the geography, and whose models - read from the models when they are given. */
169
172
  bedrock?: BedrockChoice;
170
173
  /** The two models - any pair pi's catalogue has as chat models - in place of the vendor's own. */
171
- models?: ModelChoice;
174
+ models?: ModelPair;
172
175
  /** pi's catalogue, to check the models against - read from pi when it is needed and not given. */
173
176
  catalogue?: ModelCatalogue;
174
177
  /** How the message is coloured: plain unless given - `turri init-config` gives turri's colours for a terminal. */
@@ -176,7 +179,7 @@ export interface InitConfigOptions {
176
179
  }
177
180
  /**
178
181
  * Write the quick start config.turri.yaml in `dir`, with what a config.yaml beside it says that turri reads too. One already
179
- * there keeps everything but its two models, which are set to the vendor's - or the ones given - and `force` writes the
182
+ * there gets the new project and capture models, keeping turn limits and other settings; `force` writes the
180
183
  * whole of it again. Says what it did; a model pi's catalogue does not have writes nothing and says so.
181
184
  */
182
185
  export declare function initConfig(dir: string, options?: InitConfigOptions): Promise<{
@@ -190,6 +193,5 @@ export interface Asked {
190
193
  /** Left out with the models named: read from them. */
191
194
  vendor?: Vendor;
192
195
  bedrock?: BedrockChoice;
193
- models?: ModelChoice;
196
+ models?: ModelPair;
194
197
  }
195
- export {};
@@ -6,7 +6,7 @@ import { adoptLegacyConfig, CONFIG_FILE, CONFIG_KEYS, LEGACY_CONFIG_FILE, ROLE_T
6
6
  import { currentValue, withSetting, withTopLevelValue } from "./config-edit.js";
7
7
  import { closestModels, piModelCatalogue } from "./model-check.js";
8
8
  import { EXTENSION_PROVIDERS } from "./installed-providers.js";
9
- import { captureDefaults } from "./capture/models.js";
9
+ import { CAPTURE_ROLES, captureDefaults } from "./capture/models.js";
10
10
  /** The geographies turri's own pair for each maker is served in - the first the default. Every other: bedrockMakers. */
11
11
  export const BEDROCK_REGIONS = {
12
12
  anthropic: ["global", "us", "eu", "jp", "au"],
@@ -601,7 +601,7 @@ export function sharedWithLegacy(folder) {
601
601
  export const PLAIN_PAINT = { accent: (text) => text, success: (text) => text, muted: (text) => text, bold: (text) => text };
602
602
  /**
603
603
  * Write the quick start config.turri.yaml in `dir`, with what a config.yaml beside it says that turri reads too. One already
604
- * there keeps everything but its two models, which are set to the vendor's - or the ones given - and `force` writes the
604
+ * there gets the new project and capture models, keeping turn limits and other settings; `force` writes the
605
605
  * whole of it again. Says what it did; a model pi's catalogue does not have writes nothing and says so.
606
606
  */
607
607
  export async function initConfig(dir, options = {}) {
@@ -622,10 +622,18 @@ export async function initConfig(dir, options = {}) {
622
622
  let config = existing
623
623
  ? withModels(readFileSync(path, "utf8"), lines)
624
624
  : shared.carried.reduce((text, [key, value]) => withTopLevelValue(text, key, value), quickStartConfig(vendor, bedrock, models));
625
+ // Active chat/coding entries take precedence over the top-level pair. The pair just selected must take effect there too.
626
+ for (const [role, value] of [["chat", `${harness}:${HARNESS_THINKING}`], ["coding", `${coding}:${ROLE_THINKING.coding}`]]) {
627
+ const key = `models.${role}`;
628
+ const old = currentValue(config, key);
629
+ if (old !== undefined && old !== value)
630
+ config = withSetting(config, key, value);
631
+ }
625
632
  for (const [role, choice] of Object.entries(captureDefaults(harness, coding))) {
626
633
  const key = `models.${role}`;
627
- if (currentValue(config, key) === undefined)
628
- config = withSetting(config, key, `${choice.model}:${choice.thinking}`);
634
+ const value = `${choice.model}:${choice.thinking}`;
635
+ if (currentValue(config, key) !== value)
636
+ config = withSetting(config, key, value);
629
637
  }
630
638
  writeFileSync(path, config);
631
639
  const here = resolve(process.cwd()) === folder;
@@ -634,12 +642,12 @@ export async function initConfig(dir, options = {}) {
634
642
  written: true,
635
643
  message: [
636
644
  "",
637
- `${paint.success("✓")} ${existing ? `Set the two models in ${paint.bold(path)}` : `Wrote ${paint.bold(path)}`}`,
638
- ` ${paint.muted(`with ${whose(vendor, models, given)}${existing ? " - missing capture tiers filled in, everything else in it left as it was (--force writes it all again)" : ""}`)}`,
645
+ `${paint.success("✓")} ${existing ? `Set the project and capture models in ${paint.bold(path)}` : `Wrote ${paint.bold(path)}`}`,
646
+ ` ${paint.muted(`with ${whose(vendor, models, given)}${existing ? " - everything else in it left as it was (--force writes it all again)" : ""}`)}`,
639
647
  "",
640
648
  ` ${paint.muted("you talk to")} ${talk}`,
641
649
  ` ${paint.muted("it codes")} ${code}`,
642
- ...["capture-exploration", "capture-analysis", "capture"].map(role => ` ${paint.muted(role)} ${currentValue(config, `models.${role}`)}`),
650
+ ...CAPTURE_ROLES.map(role => ` ${paint.muted(role)} ${currentValue(config, `models.${role}`)}`),
643
651
  ...(shared.carried.length > 0
644
652
  ? [
645
653
  "",
@@ -46,6 +46,8 @@ export declare function createSessionLaunches(options: {
46
46
  /** The launch agent's model: the coding model of the codebase. */
47
47
  model: (plainFile: string) => string | undefined;
48
48
  onChange: (launch: Launch) => void;
49
+ /** A launch's agent said more, as it streams. */
50
+ onOutput?: (launch: Launch, text: string) => void;
49
51
  }): SessionLaunches;
50
52
  /**
51
53
  * What the sentinel tests in, whatever is launched: what turri launched, and nothing it starts itself. Said in every
@@ -14,7 +14,8 @@ export function createSessionLaunches(options) {
14
14
  cwd: options.cwd,
15
15
  run: (launch, code, signal, freed) => {
16
16
  const model = options.model(launch.plainFile);
17
- return runLaunchAgent({ launch, code, cwd: options.cwd, signal, freed, ...(model !== undefined ? { model } : {}) });
17
+ const onOutput = options.onOutput;
18
+ return runLaunchAgent({ launch, code, cwd: options.cwd, signal, freed, ...(model !== undefined ? { model } : {}), ...(onOutput !== undefined ? { onDelta: (text) => onOutput(launch, text) } : {}) });
18
19
  },
19
20
  onChange: options.onChange,
20
21
  });
@@ -135,6 +136,21 @@ export function createSessionLaunches(options) {
135
136
  const theirs = new Set(later.flatMap((other) => specsOf(other).map(key)));
136
137
  return { ...base, launch, later, laterSpecs: specsOf(job).filter((spec) => theirs.has(key(spec))) };
137
138
  },
139
+ tryIt(work) {
140
+ let launch;
141
+ if ("job" in work) {
142
+ const landing = landedPulses.get(work.job.id);
143
+ if (landing === undefined || landing.launch === undefined)
144
+ return undefined;
145
+ launch = track.runs(landing.codebase);
146
+ if (launch === undefined || !track.holds(landing.codebase, landing.commit))
147
+ return undefined;
148
+ }
149
+ else
150
+ launch = track.runs(work.check.module);
151
+ const said = launch?.summary?.trim();
152
+ return launch?.status === "launched" && said !== undefined && said !== "" ? said : undefined;
153
+ },
138
154
  resumeText(work) {
139
155
  if ("job" in work) {
140
156
  const landing = landedPulses.get(work.job.id);
@@ -4,7 +4,8 @@ import { basename, relative, resolve } from "node:path";
4
4
  import { defineTool } from "@earendil-works/pi-coding-agent";
5
5
  import { Type } from "typebox";
6
6
  import { brokenConfig, CONFIG_FILE, readProjectConfig, moduleConfigFile, configModuleFor, moduleConfigsOf, withConfigModule } from "./config.js";
7
- import { checkPlainFile, formatCheckResults } from "./plain/check.js";
7
+ import { checkModule } from "./module-check.js";
8
+ import { formatCheckResults } from "./plain/check.js";
8
9
  import { describeDrift, describeModules } from "./regenerate/loop.js";
9
10
  import { describeJob, pulseName } from "./regenerate/jobs.js";
10
11
  import { currentChat } from "./chat-scope.js";
@@ -14,7 +15,7 @@ import { runningLaunched, stopLaunched } from "./regenerate/launch.js";
14
15
  import { projectDirOf } from "./regenerate/paths.js";
15
16
  import { findTestScripts } from "./regenerate/test-scripts.js";
16
17
  import { scriptBeingWritten } from "./regenerate/scripts-being-written.js";
17
- import { surfaceOf } from "./surface.js";
18
+ import { planWork } from "./work.js";
18
19
  export const WORKING_DIR_PARAM = Type.Optional(Type.String({
19
20
  description: "The folder the .plain files are in, relative to where turri was started - as if it had been started there " +
20
21
  "(e.g. \"plain\"). plain_file is then relative to it - hubspot.plain, not plain/hubspot.plain. Default: where " +
@@ -177,7 +178,7 @@ export function stopJob(jobs, named, reason, loop) {
177
178
  const matches = jobs.list().filter((job) => job.id.startsWith(named.trim()));
178
179
  // /pulses is the terminal's: in a host, the pulses tool lists them.
179
180
  if (matches.length === 0)
180
- return `No pulse ${named}. ${surfaceOf(jobs) !== undefined ? "The pulses tool lists them." : "/pulses shows them."}`;
181
+ return `No pulse ${named}. The pulses tool lists them.`;
181
182
  if (matches.length > 1)
182
183
  return `'${named}' matches ${matches.map((job) => job.id).join(", ")}. Give more of the id.`;
183
184
  const target = matches[0];
@@ -254,7 +255,7 @@ export function regenerateTool(options) {
254
255
  async execute(_id, given, _signal, _onUpdate, ctx) {
255
256
  const plainFile = plainFileOf(options.cwd, given, "regenerate");
256
257
  return whenBuildable(plainFile, async () => {
257
- const check = checkPlainFile(plainFile);
258
+ const check = checkModule(plainFile);
258
259
  // The parser's message as it gives it, a test plain file out of place, and turri's next step for the old syntax.
259
260
  if (!check.ok)
260
261
  throw new Error(`${relative(options.cwd, plainFile) || plainFile} does not parse, so nothing can be regenerated from it yet:\n${formatCheckResults([check])}`);
@@ -268,12 +269,12 @@ export function regenerateTool(options) {
268
269
  const waiting = wait && options.jobs !== undefined ? { jobs: options.jobs, wait: startWait(options.jobs) } : undefined;
269
270
  let statuses;
270
271
  try {
271
- statuses =
272
- given.from_scratch !== undefined
273
- ? await loop.fromScratch(plainFile, { ...request, chain: given.from_scratch === "chain" })
274
- : again.length > 0
275
- ? await loop.regenerateAgain(plainFile, again, request)
276
- : await loop.bringUp(plainFile, request);
272
+ statuses = await planWork(loop, "regenerate", {
273
+ plainFile,
274
+ ...request,
275
+ ...(again.length > 0 ? { funcIds: again } : {}),
276
+ ...(given.from_scratch !== undefined ? { fromScratch: given.from_scratch } : {}),
277
+ });
277
278
  }
278
279
  catch (error) {
279
280
  if (waiting !== undefined)
@@ -0,0 +1,13 @@
1
+ import { type CheckResult } from "./plain/check.ts";
2
+ /**
3
+ * A module checked in its project - `turri parse`, the chat's `parse`, and the check `regenerate` runs on the module it
4
+ * is given: the ***plain language's check (`checkPlainFile`), then what the project says of the module. Two config
5
+ * files among the modules it requires fail it, as a syntax error does. A step of adding tests it skipped - scenarios
6
+ * with no test reqs, or no conformance testing script - and a base folder that is not there pass it with a warning.
7
+ */
8
+ export declare function checkModule(file: string, templateDirs?: string[]): CheckResult;
9
+ /**
10
+ * Check a file, or every .plain file directly in a folder, in its project - never a test folder, which holds no module -
11
+ * and then the project's test folder, once, at the end.
12
+ */
13
+ export declare function checkModules(target: string, templateDirs?: string[]): CheckResult[];
@@ -0,0 +1,117 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { basename } from "node:path";
3
+ import { configModuleFor, testDirOf } from "./config.js";
4
+ import { conformanceTestsOn } from "./conformance-switch.js";
5
+ import { checkParsed, checkTargets, failedCheck } from "./plain/check.js";
6
+ import { plainFileParser, PLAIN_SOURCE_FILE_EXTENSION, readPlainSourceMetadata, REQUIRES_DIRECTIVE } from "./plain/parser.js";
7
+ import { missingBaseFolder } from "./regenerate/base-folder.js";
8
+ import { projectDirOf, resolveTemplateDirs } from "./regenerate/paths.js";
9
+ import { testedFuncIds } from "./regenerate/records.js";
10
+ import { isImportModule } from "./regenerate/requires-chain.js";
11
+ import { testingGap } from "./regenerate/testing-steps.js";
12
+ import { projectModules } from "./test-plain-files.js";
13
+ /**
14
+ * A module checked in its project - `turri parse`, the chat's `parse`, and the check `regenerate` runs on the module it
15
+ * is given: the ***plain language's check (`checkPlainFile`), then what the project says of the module. Two config
16
+ * files among the modules it requires fail it, as a syntax error does. A step of adding tests it skipped - scenarios
17
+ * with no test reqs, or no conformance testing script - and a base folder that is not there pass it with a warning.
18
+ */
19
+ export function checkModule(file, templateDirs = []) {
20
+ const { result, parsed } = checkParsed(file, templateDirs);
21
+ if (parsed === undefined)
22
+ return result;
23
+ const { path, moduleName, tree, requiredModules } = parsed;
24
+ try {
25
+ // Two config files among the modules it requires: which one builds it cannot be told.
26
+ configModuleFor(path);
27
+ }
28
+ catch (error) {
29
+ return failedCheck(file, error);
30
+ }
31
+ const warnings = testingGapsOf(moduleName, path, tree, projectDirOf(path), templateDirs);
32
+ // A codebase that requires nothing starts from its base folder: one named and not there stops its first pulse.
33
+ const base = requiredModules.length === 0 && !isImportModule(path) ? missingBaseFolder(path) : undefined;
34
+ if (base !== undefined)
35
+ warnings.push(base);
36
+ // In the order the result is read: what the module is, what it skipped, then its functional specs.
37
+ if (warnings.length === 0)
38
+ return result;
39
+ const { file: checked, ok, moduleName: _name, ...rest } = result;
40
+ return { file: checked, ok, moduleName, warnings, ...rest };
41
+ }
42
+ /**
43
+ * Check a file, or every .plain file directly in a folder, in its project - never a test folder, which holds no module -
44
+ * and then the project's test folder, once, at the end.
45
+ */
46
+ export function checkModules(target, templateDirs = []) {
47
+ return checkTargets(target, (file) => checkModule(file, templateDirs));
48
+ }
49
+ /**
50
+ * The modules of a project whose requires chains a module is in and that nothing requires: the tips its conformance
51
+ * tests are written in, by name with their files. None when nothing requires it - it is a tip itself.
52
+ */
53
+ function tipsAbove(moduleName, projectDir) {
54
+ const modules = projectModules(projectDir);
55
+ const requiredBy = new Map();
56
+ for (const [name, file] of modules) {
57
+ let requires = [];
58
+ try {
59
+ requires = readPlainSourceMetadata(readFileSync(file, "utf8")).metadata[REQUIRES_DIRECTIVE] ?? [];
60
+ }
61
+ catch {
62
+ continue;
63
+ }
64
+ for (const required of requires) {
65
+ const below = basename(required.replace(/^\.\//, ""), PLAIN_SOURCE_FILE_EXTENSION);
66
+ requiredBy.set(below, [...(requiredBy.get(below) ?? []), name]);
67
+ }
68
+ }
69
+ const tips = new Set();
70
+ const seen = new Set();
71
+ const up = (name) => {
72
+ if (seen.has(name))
73
+ return;
74
+ seen.add(name);
75
+ const above = requiredBy.get(name) ?? [];
76
+ if (above.length === 0 && name !== moduleName)
77
+ tips.add(name);
78
+ for (const next of above)
79
+ up(next);
80
+ };
81
+ up(moduleName);
82
+ return [...tips].sort().flatMap((name) => (modules.has(name) ? [{ name, file: modules.get(name) }] : []));
83
+ }
84
+ /**
85
+ * The steps of adding tests a module skipped, as warnings. A module another requires has its conformance tests
86
+ * written in the tips above it, from their test reqs and with their script: it is judged by each of them, which says so.
87
+ */
88
+ function testingGapsOf(moduleName, path, tree, projectDir, templateDirs) {
89
+ // Conformance tests off: no step of adding them is skipped - and scenarios written are said not to be tested.
90
+ if (!conformanceTestsOn(path)) {
91
+ const tested = testedFuncIds(tree);
92
+ return tested.length > 0
93
+ ? [`its scenarios are not tested - ${tested.map((funcId) => `${moduleName}:${funcId}`).join(", ")}: conformance tests are off (conformance-tests: false, or unset). /conform in the chat turns them on, or conformance-tests: true in config.turri.yaml.`]
94
+ : [];
95
+ }
96
+ const tips = tipsAbove(moduleName, projectDir);
97
+ if (tips.length === 0) {
98
+ const gap = testingGap({ moduleName, plainFile: path, tree });
99
+ return gap !== undefined ? [gap.text] : [];
100
+ }
101
+ return tips.flatMap((tip) => {
102
+ let tipTree;
103
+ try {
104
+ [, tipTree] = plainFileParser(basename(tip.file), resolveTemplateDirs(tip.file, templateDirs), {
105
+ allowNoFunctionalities: true,
106
+ testDir: testDirOf(tip.file),
107
+ requireTestPlainFiles: false,
108
+ });
109
+ }
110
+ catch {
111
+ // A tip that does not parse is reported when it is checked itself.
112
+ return [];
113
+ }
114
+ const gap = testingGap({ moduleName: tip.name, plainFile: tip.file, tree: tipTree });
115
+ return gap !== undefined ? [`${moduleName}'s conformance tests are written in ${tip.name}, which requires it: ${gap.text}`] : [];
116
+ });
117
+ }
package/dist/notice.d.ts CHANGED
@@ -98,6 +98,11 @@ export interface Conclusion {
98
98
  summary: string;
99
99
  module?: string;
100
100
  pulse?: number;
101
+ /**
102
+ * How the person tries what was tested themselves, in the words of the launch the sentinel tested it in: where it runs,
103
+ * or the commands to run a command-line tool or a library from `dist/<module>`. Undefined when nothing launched said so.
104
+ */
105
+ tryIt?: string;
101
106
  }
102
107
  /**
103
108
  * Functional specs of a module a host asked the sentinel to check, in what is launched of the module: its codebase's code,
@@ -1,7 +1,8 @@
1
1
  import { resolve } from "node:path";
2
2
  import { defineTool } from "@earendil-works/pi-coding-agent";
3
3
  import { Type } from "typebox";
4
- import { checkPlainTargets, formatCheckResults } from "./plain/check.js";
4
+ import { checkModules } from "./module-check.js";
5
+ import { formatCheckResults } from "./plain/check.js";
5
6
  /** parse, for the conversation and for the skills that write specs alike: it checks the ***plain, never the code. */
6
7
  export function checkPlainTool(cwd) {
7
8
  return defineTool({
@@ -22,7 +23,7 @@ export function checkPlainTool(cwd) {
22
23
  template_dir: Type.Optional(Type.Array(Type.String(), { description: "Extra template directories" })),
23
24
  }),
24
25
  async execute(_id, params) {
25
- const results = checkPlainTargets(resolve(cwd, params.target), (params.template_dir ?? []).map((dir) => resolve(cwd, dir)));
26
+ const results = checkModules(resolve(cwd, params.target), (params.template_dir ?? []).map((dir) => resolve(cwd, dir)));
26
27
  const failed = results.filter((result) => !result.ok).length;
27
28
  const text = results.length === 0
28
29
  ? `No .plain files found in ${params.target}.`
@@ -1,12 +1,13 @@
1
+ import { type MarshalledPlainSource } from "./spec.ts";
1
2
  /**
2
- * Static validation of ***plain, using this repo's own parser - `turri parse`, the chat's `parse`, and the check
3
- * `regenerate` runs on the module it is given.
3
+ * The ***plain language's check of a module, with turri's own parser: it parses the module with its test plain files,
4
+ * resolves its imports and required modules, and reports every error the parser can see without generating anything.
5
+ * The parser's errors come one at a time, the first it meets, as the reference gives them. turri's own checks list
6
+ * everything they find at once: every functional spec without a test plain file, and every test plain file that is not
7
+ * where it belongs.
4
8
  *
5
- * It parses each module with its test plain files, resolves its imports and required modules, and reports every error
6
- * the parser can see without generating anything. The parser's errors come one at a time, the first it meets, as the
7
- * reference gives them. turri's own checks list everything they find at once: every functional spec without a test
8
- * plain file, and every test plain file that is not where it belongs. A module whose functional specs have scenarios
9
- * but which has no test reqs, or no conformance testing script, passes with a warning.
9
+ * What the project adds - its config files, its testing scripts, its base folder - is `checkModule`'s
10
+ * (src/module-check.ts): `turri parse`, the chat's `parse` and the check `regenerate` runs are that one.
10
11
  */
11
12
  export interface CheckedFunctionalSpec {
12
13
  funcId: string;
@@ -37,14 +38,25 @@ export interface CheckResult {
37
38
  export declare function isPreviousSyntaxError(message: string): boolean;
38
39
  /** turri's next step for a module in the previous ***plain syntax. */
39
40
  export declare function previousSyntaxStep(file: string): string;
41
+ /** A module parsed and checked by the language: its result, and - when it parsed - its tree and template folders. */
42
+ export interface ParsedCheck {
43
+ result: CheckResult;
44
+ parsed?: {
45
+ path: string;
46
+ moduleName: string;
47
+ tree: MarshalledPlainSource;
48
+ requiredModules: string[];
49
+ dirs: string[];
50
+ };
51
+ }
52
+ /** The language's check of a module, with what it parsed - for the project's check to go on from. */
53
+ export declare function checkParsed(file: string, templateDirs?: string[]): ParsedCheck;
54
+ /** A check that failed on an error: its message verbatim, and turri's next step when it has one. */
55
+ export declare function failedCheck(file: string, error: unknown): CheckResult;
40
56
  /**
41
- * The modules of a project whose requires chains a module is in and that nothing requires: the tips its conformance
42
- * tests are written in, by name with their files. None when nothing requires it - it is a tip itself.
57
+ * The ***plain language's check of one module: parsed with its test plain files, its imports and required modules
58
+ * resolved. `checkModule` (`@turri-dev/core/project`) adds what the project says of it.
43
59
  */
44
- export declare function tipsAbove(moduleName: string, projectDir: string): Array<{
45
- name: string;
46
- file: string;
47
- }>;
48
60
  export declare function checkPlainFile(file: string, templateDirs?: string[]): CheckResult;
49
61
  /** The check of a project's test folder: every test plain file not where it belongs. Undefined when there is none. */
50
62
  export declare function checkTestFolder(projectDir: string): CheckResult | undefined;
@@ -55,6 +67,8 @@ export declare function resolvePlainTargets(target: string): string[];
55
67
  * project's test folder, once, at the end.
56
68
  */
57
69
  export declare function checkPlainTargets(target: string, templateDirs?: string[]): CheckResult[];
70
+ /** `checkPlainTargets` with each module checked by `check`. */
71
+ export declare function checkTargets(target: string, check: (file: string) => CheckResult): CheckResult[];
58
72
  /**
59
73
  * One line per file, plus the parser's message under any that failed and turri's next step, or every problem turri
60
74
  * found; a module that passed, its functional specs under it, each with its test plain file and its scenarios - and