@turri-dev/cli 0.2.4-next.efe96fe → 0.3.0

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 (73) hide show
  1. package/README.md +2 -2
  2. package/dist/chat-skills.d.ts +1 -1
  3. package/dist/chat-skills.js +1 -1
  4. package/dist/chats.d.ts +42 -8
  5. package/dist/chats.js +122 -38
  6. package/dist/cli.js +1 -1
  7. package/dist/config-edit.js +4 -4
  8. package/dist/config.d.ts +48 -11
  9. package/dist/config.js +102 -13
  10. package/dist/extension.d.ts +22 -2
  11. package/dist/extension.js +225 -125
  12. package/dist/genome.js +1 -1
  13. package/dist/host-session.d.ts +6 -5
  14. package/dist/host-session.js +2 -2
  15. package/dist/host.d.ts +2 -0
  16. package/dist/identity.js +2 -2
  17. package/dist/init-config.d.ts +1 -1
  18. package/dist/init-config.js +7 -7
  19. package/dist/launch-agent.d.ts +51 -0
  20. package/dist/launch-agent.js +267 -0
  21. package/dist/{release-cli.js → launch-cli.js} +41 -24
  22. package/dist/launch-session.d.ts +68 -0
  23. package/dist/launch-session.js +217 -0
  24. package/dist/launch-tools.d.ts +28 -0
  25. package/dist/launch-tools.js +69 -0
  26. package/dist/launch-track.d.ts +125 -0
  27. package/dist/launch-track.js +320 -0
  28. package/dist/loop-cli.js +4 -4
  29. package/dist/loop-tools.d.ts +8 -3
  30. package/dist/loop-tools.js +37 -32
  31. package/dist/notice.d.ts +7 -6
  32. package/dist/plain-files.d.ts +2 -2
  33. package/dist/plain-files.js +3 -3
  34. package/dist/regenerate/command-check.d.ts +7 -1
  35. package/dist/regenerate/command-check.js +43 -1
  36. package/dist/regenerate/delivery.d.ts +1 -1
  37. package/dist/regenerate/delivery.js +3 -3
  38. package/dist/regenerate/launch.d.ts +154 -0
  39. package/dist/regenerate/{release.js → launch.js} +195 -51
  40. package/dist/regenerate/ledger.d.ts +32 -1
  41. package/dist/regenerate/lineage.d.ts +2 -0
  42. package/dist/regenerate/lineage.js +8 -0
  43. package/dist/regenerate/loop.d.ts +18 -7
  44. package/dist/regenerate/loop.js +28 -22
  45. package/dist/regenerate/paths.d.ts +2 -2
  46. package/dist/regenerate/paths.js +2 -2
  47. package/dist/self-invocation.js +7 -7
  48. package/dist/sentinel-check.d.ts +3 -3
  49. package/dist/sentinel-check.js +3 -3
  50. package/dist/sentinel.d.ts +18 -12
  51. package/dist/sentinel.js +68 -42
  52. package/docs/README.md +2 -2
  53. package/docs/chats.md +2 -2
  54. package/docs/config.md +9 -9
  55. package/docs/development.md +1 -1
  56. package/docs/headless.md +1 -1
  57. package/docs/hosting.md +14 -13
  58. package/docs/launch.md +67 -0
  59. package/docs/parser.md +1 -1
  60. package/docs/regenerating.md +3 -3
  61. package/docs/sandbox.md +3 -3
  62. package/docs/sentinel.md +24 -12
  63. package/docs/skills-and-gates.md +3 -3
  64. package/docs/using.md +8 -8
  65. package/genome/rules/turri-regeneration.md +1 -1
  66. package/package.json +1 -1
  67. package/dist/regenerate/release.d.ts +0 -121
  68. package/dist/release-agent.d.ts +0 -43
  69. package/dist/release-agent.js +0 -130
  70. package/dist/release-tools.d.ts +0 -44
  71. package/dist/release-tools.js +0 -170
  72. package/docs/deploy.md +0 -48
  73. /package/dist/{release-cli.d.ts → launch-cli.d.ts} +0 -0
package/dist/config.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { AsyncLocalStorage } from "node:async_hooks";
2
- import { copyFileSync, existsSync, readdirSync, readFileSync, statSync } from "node:fs";
2
+ import { copyFileSync, existsSync, readdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
3
3
  import { basename, join, resolve } from "node:path";
4
4
  import { load as loadYaml } from "js-yaml";
5
5
  import { projectDirOf, resolveTemplateDirs } from "./regenerate/paths.js";
@@ -24,8 +24,8 @@ import { projectDirOf, resolveTemplateDirs } from "./regenerate/paths.js";
24
24
  * review: false # review the code and its tests once they pass (default: true)
25
25
  * mutation-testing: false # give the coding agent and the reviewer can_it_fail (default: true)
26
26
  * allow-to-stop-jobs: false # stop a running job the spec moved on from (default: true)
27
- * release-after-pulse: true # release what each pulse lands, as its last stage, before the next pulse (default: false)
28
- * sentinel: true # a chat of its own every finished pulse goes to, which tests the release and tells you what is wrong: true, false, or ask - the person asked before it first opens in a session (default: ask)
27
+ * launch-after-pulse: true # launch what each pulse lands, in the background, the newest commit winning (default: false)
28
+ * sentinel: true # a chat of its own every finished pulse goes to, which tests what is launched and tells you what is wrong: true, false, or ask - the person asked before it first opens in a session (default: ask)
29
29
  * rules-off: [integrations] # ***plain rules to leave out of the prompts, by name (default: none)
30
30
  * unittests-script: test_scripts/run_unittests.sh # the testing scripts - see test-scripts.ts
31
31
  * conformance-tests-script: test_scripts/run_conformance_tests.sh
@@ -142,7 +142,65 @@ export function moduleConfigsOf(root) {
142
142
  * config.turri.yaml, and each config.<module>.yaml to config.turri.<module>.yaml, so nothing is lost when the old files
143
143
  * stop being read. The old files are left as they are. Gives back the files written, by name.
144
144
  */
145
+ /**
146
+ * Keys turri has renamed, old to new - no alias: a project's config.turri.yaml or config.turri.<module>.yaml that still has
147
+ * the old one has it renamed as turri first reads or writes the project's config (`renameOldKeys`), its value and its
148
+ * comment kept. One that sets the new one too is left as it is, the old one said in the banner as doing nothing.
149
+ */
150
+ export const RENAMED_KEYS = { "release-after-pulse": "launch-after-pulse" };
151
+ /** The projects whose config files were looked at for old keys this process, and what was renamed in each - for the banner. */
152
+ const renamedKeys = new Map();
153
+ /**
154
+ * Rename the old keys of `RENAMED_KEYS` in the project's config.turri*.yaml files - once a process, or again with `again`
155
+ * (a file just copied from its old name). A top-level key alone, its line kept but for the key's name; a file that also
156
+ * sets the new key, one that does not parse, or one that cannot be written is left as it is. Returns every key renamed
157
+ * in the project this process.
158
+ */
159
+ export function renameOldKeys(root, options = {}) {
160
+ const dir = resolve(root);
161
+ const done = renamedKeys.get(dir);
162
+ if (done !== undefined && options.again !== true)
163
+ return done;
164
+ const renamed = done ?? [];
165
+ renamedKeys.set(dir, renamed);
166
+ for (const file of namesIn(dir).filter((name) => /^config\.turri(\.[^.]+)?\.yaml$/.test(name))) {
167
+ const path = join(dir, file);
168
+ let text;
169
+ let parsed;
170
+ try {
171
+ text = readFileSync(path, "utf8");
172
+ parsed = loadYaml(text);
173
+ }
174
+ catch {
175
+ continue;
176
+ }
177
+ if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed))
178
+ continue;
179
+ let changed = text;
180
+ const now = [];
181
+ for (const [from, to] of Object.entries(RENAMED_KEYS)) {
182
+ if (!(from in parsed) || to in parsed)
183
+ continue;
184
+ const line = new RegExp(`^${from.replace(/[-]/g, "\\-")}(?=[ \\t]*:)`, "m");
185
+ if (!line.test(changed))
186
+ continue;
187
+ changed = changed.replace(line, to);
188
+ now.push({ file, from, to });
189
+ }
190
+ if (now.length === 0)
191
+ continue;
192
+ try {
193
+ writeFileSync(path, changed);
194
+ renamed.push(...now);
195
+ }
196
+ catch {
197
+ /* a file turri cannot write keeps its old key: the banner says it does nothing */
198
+ }
199
+ }
200
+ return renamed;
201
+ }
145
202
  export function adoptLegacyConfig(root, options = {}) {
203
+ renameOldKeys(root);
146
204
  if (!usesLegacyConfig(root))
147
205
  return [];
148
206
  const copies = [
@@ -152,6 +210,9 @@ export function adoptLegacyConfig(root, options = {}) {
152
210
  ];
153
211
  for (const [from, to] of copies)
154
212
  copyFileSync(join(root, from), join(root, to));
213
+ // What was copied may have keys turri has renamed since.
214
+ if (copies.length > 0)
215
+ renameOldKeys(root, { again: true });
155
216
  return copies.map(([, to]) => to);
156
217
  }
157
218
  /** The module whose config file a pulse runs with: worked out as it was queued, whatever the files say since. */
@@ -242,10 +303,10 @@ export const THINKING_LEVELS = ["off", "minimal", "low", "medium", "high", "xhig
242
303
  * The code fixer of a conformance run and the repair agent are coding agents; the unit-test and conformance arbiters
243
304
  * are both `arbiter`.
244
305
  */
245
- export const AGENT_ROLES = ["chat", "sentinel", "planner", "diagnosis", "release", "coding", "conformance", "explorer", "reviewer", "test-reviewer", "judge", "arbiter", "debugger"];
306
+ export const AGENT_ROLES = ["chat", "sentinel", "planner", "diagnosis", "launch", "coding", "conformance", "explorer", "reviewer", "test-reviewer", "judge", "arbiter", "debugger"];
246
307
  /**
247
308
  * How hard each role thinks when nothing names a level - not the config's `models:`, nor a `:level` on the model it is
248
- * given. The agents that do the work - write the code and the tests, explore, release - think little: they work from a
309
+ * given. The agents that do the work - write the code and the tests, explore, launch - think little: they work from a
249
310
  * spec that leaves little to guess, and every turn of theirs is many. The ones that judge - review, weigh, plan, find a
250
311
  * cause - think more: a wrong call there costs pulses. The conversation keeps its own level, pi's.
251
312
  */
@@ -253,7 +314,7 @@ export const ROLE_THINKING = {
253
314
  coding: "low",
254
315
  conformance: "low",
255
316
  explorer: "low",
256
- release: "low",
317
+ launch: "low",
257
318
  reviewer: "medium",
258
319
  "test-reviewer": "medium",
259
320
  judge: "medium",
@@ -263,7 +324,7 @@ export const ROLE_THINKING = {
263
324
  diagnosis: "medium",
264
325
  };
265
326
  /** The roles on the conversation's side: without their own entry they take the chat's model, not `default`. */
266
- // The release is not: it follows steps - a script, a start command - and runs on the coding model, thinking low. Nor
327
+ // The launch is not: it follows steps - a script, a start command - and runs on the coding model, thinking low. Nor
267
328
  // is the diagnosis: a post-mortem of a job that failed, read by the person - it runs on the coding model, thinking medium.
268
329
  const CHAT_SIDE = ["chat", "sentinel", "planner"];
269
330
  function isThinkingLevel(value) {
@@ -413,7 +474,7 @@ export const CONFIG_KEYS = {
413
474
  review: "review",
414
475
  mutationTesting: "mutation-testing",
415
476
  allowToStopJobs: "allow-to-stop-jobs",
416
- releaseAfterPulse: "release-after-pulse",
477
+ launchAfterPulse: "launch-after-pulse",
417
478
  sentinel: "sentinel",
418
479
  testDir: "test-dir",
419
480
  conformanceTests: "conformance-tests",
@@ -449,6 +510,8 @@ export function readProjectConfig(root, module) {
449
510
  return withRunOverrides(readLayeredConfig(root, module));
450
511
  }
451
512
  function readLayeredConfig(root, module) {
513
+ // A key turri has renamed, renamed in the files as they are first read.
514
+ renameOldKeys(root);
452
515
  const project = readConfigFile(join(root, projectConfigFile(root)));
453
516
  if (module === undefined)
454
517
  return project;
@@ -603,7 +666,7 @@ function readConfigFileNow(path) {
603
666
  review: typeof raw[CONFIG_KEYS.review] === "boolean" ? raw[CONFIG_KEYS.review] : undefined,
604
667
  mutationTesting: typeof raw[CONFIG_KEYS.mutationTesting] === "boolean" ? raw[CONFIG_KEYS.mutationTesting] : undefined,
605
668
  allowToStopJobs: typeof raw[CONFIG_KEYS.allowToStopJobs] === "boolean" ? raw[CONFIG_KEYS.allowToStopJobs] : undefined,
606
- releaseAfterPulse: typeof raw[CONFIG_KEYS.releaseAfterPulse] === "boolean" ? raw[CONFIG_KEYS.releaseAfterPulse] : undefined,
669
+ launchAfterPulse: typeof raw[CONFIG_KEYS.launchAfterPulse] === "boolean" ? raw[CONFIG_KEYS.launchAfterPulse] : undefined,
607
670
  sentinel: typeof raw[CONFIG_KEYS.sentinel] === "boolean" || raw[CONFIG_KEYS.sentinel] === "ask" ? raw[CONFIG_KEYS.sentinel] : undefined,
608
671
  testDir: text(raw[CONFIG_KEYS.testDir]),
609
672
  conformanceTests: typeof raw[CONFIG_KEYS.conformanceTests] === "boolean" ? raw[CONFIG_KEYS.conformanceTests] : undefined,
@@ -644,7 +707,8 @@ const OLDER_KEYS = ["model", "turn_limit"];
644
707
  * not silently ignored. config.yaml is left out: it may be another tool's, with keys of its own.
645
708
  */
646
709
  export function unknownConfigKeys(root) {
647
- const known = new Set([...Object.values(CONFIG_KEYS), ...OLDER_KEYS]);
710
+ // An old name of a renamed key is said on a line of its own (configLines), not as a key turri does not read.
711
+ const known = new Set([...Object.values(CONFIG_KEYS), ...OLDER_KEYS, ...Object.keys(RENAMED_KEYS)]);
648
712
  const found = [];
649
713
  for (const file of namesIn(root).filter((name) => /^config\.turri(\.[^.]+)?\.yaml$/.test(name)).sort()) {
650
714
  let parsed;
@@ -662,7 +726,32 @@ export function unknownConfigKeys(root) {
662
726
  }
663
727
  return found;
664
728
  }
665
- /** The banner's line for each config file with keys turri does not read. */
666
- export function unknownConfigLines(root) {
667
- return unknownConfigKeys(root).map(({ file, keys }) => `${file} has ${keys.length === 1 ? "a key" : "keys"} turri does not read - ${keys.join(", ")}: no setting turri has, so ${keys.length === 1 ? "it does" : "they do"} nothing. Take ${keys.length === 1 ? "it" : "them"} out, or see docs/config.md for the spelling.`);
729
+ /**
730
+ * The banner's lines for the project's config files: each key turri renamed in them this process, each old name left
731
+ * beside its new one - doing nothing - and each file with keys turri does not read.
732
+ */
733
+ export function configLines(root) {
734
+ const renamed = renameOldKeys(root).map(({ file, from, to }) => ({ kind: "renamed", file, text: `${file}: ${from} is called ${to} now - turri renamed it there, its value kept.` }));
735
+ const left = [];
736
+ for (const file of namesIn(root).filter((name) => /^config\.turri(\.[^.]+)?\.yaml$/.test(name)).sort()) {
737
+ let parsed;
738
+ try {
739
+ parsed = loadYaml(readFileSync(join(root, file), "utf8"));
740
+ }
741
+ catch {
742
+ continue;
743
+ }
744
+ if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed))
745
+ continue;
746
+ for (const [from, to] of Object.entries(RENAMED_KEYS)) {
747
+ if (from in parsed && to in parsed)
748
+ left.push({ kind: "old-beside-new", file, text: `${file} has ${from}, the old name of ${to}, which it sets too: ${from} does nothing - take it out.` });
749
+ }
750
+ }
751
+ const unknown = unknownConfigKeys(root).map(({ file, keys }) => ({
752
+ kind: "unknown",
753
+ file,
754
+ text: `${file} has ${keys.length === 1 ? "a key" : "keys"} turri does not read - ${keys.join(", ")}: no setting turri has, so ${keys.length === 1 ? "it does" : "they do"} nothing. Take ${keys.length === 1 ? "it" : "them"} out, or see docs/config.md for the spelling.`,
755
+ }));
756
+ return [...renamed, ...left, ...unknown];
668
757
  }
@@ -6,6 +6,7 @@ import { fromWorkingDir } from "./loop-tools.ts";
6
6
  import { type WorkLoop } from "./regenerate/loop.ts";
7
7
  import { type AskUser, type AskUserIO } from "./ask.ts";
8
8
  import { type TurriCore, type TurriHost } from "./chats.ts";
9
+ import { type Job } from "./regenerate/jobs.ts";
9
10
  /**
10
11
  * Puts a skill step's question to the person, when there is one to ask.
11
12
  *
@@ -70,14 +71,25 @@ export declare function asksOneByOne(words: string): boolean;
70
71
  export declare function shownAfterCommand(pi: ExtensionAPI, ctx: ExtensionContext, command: string, text: string, level: NonNullable<CommandOutcome["level"]>,
71
72
  /** The command is in the chat already, above it (echoCommand): the text alone. */
72
73
  echoed?: boolean, react?: string): void;
74
+ /**
75
+ * What a slash command found for the agent alone - guidance the person need not see: put in the conversation unseen,
76
+ * and the agent started on it - at once when it is idle, else once its turn ends - told what to do with it.
77
+ */
78
+ export declare function toldAfterCommand(pi: ExtensionAPI, command: string, text: string, react: string): void;
73
79
  /**
74
80
  * What the agent does once /regenerate or /conform has started pulses: a command's output alone leaves the chat silent,
75
81
  * and the person wondering whether to wait. It says what runs, and that they need not - and starts nothing itself.
76
82
  */
77
83
  export declare const COMMAND_STARTED_REACTION: string;
78
84
  /**
79
- * What the agent does when /conform started nothing: answers it at once - why, and what would let it start - and offers
80
- * to do that, rather than leave the person with a refusal and a silent chat.
85
+ * What the agent does when /conform found a step of adding tests still to take: takes it at once, asking nothing - the
86
+ * /conform was the person's yes - and says what it writes as the way there, never as a failure: the person saw none.
87
+ */
88
+ export declare const CONFORM_STEPS_REACTION: string;
89
+ /**
90
+ * What the agent does when /conform started nothing for a reason that is not a step of adding tests - a functional spec
91
+ * named that is not there, words it does not take: answers it at once - why, and what would let it start - rather than
92
+ * leave the person with a refusal and a silent chat.
81
93
  */
82
94
  export declare const CONFORM_REFUSED_REACTION: string;
83
95
  export declare const COMMAND_OUTCOME = "turri_command_outcome";
@@ -143,6 +155,14 @@ export declare function projectConfigBlock(root: string): string;
143
155
  */
144
156
  export declare function turnOnConformance(core: TurriCore, plainFile?: string): string;
145
157
  export { fromWorkingDir };
158
+ /**
159
+ * What a chat's agent is told of a pulse it asked for that ended, with the sentinel off. One that landed under
160
+ * launch-after-pulse is being launched as it is told: it says so, and offers nothing else for it - it is told once the
161
+ * launch ends.
162
+ */
163
+ export declare function pulseEndNote(job: Job, options?: {
164
+ launching?: boolean;
165
+ }): string;
146
166
  /**
147
167
  * What the agent is to do with a job that just ended, unasked: what the project's guidance says to do then, or else say
148
168
  * in a line or two what ended - the person saw it end already, in the transcript.