@llm4ts/shell 3.2.6 → 3.4.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 (105) hide show
  1. package/README.md +36 -0
  2. package/dist/Cli.d.ts +11 -3
  3. package/dist/Cli.d.ts.map +1 -1
  4. package/dist/Cli.js +127 -39
  5. package/dist/Cli.js.map +1 -1
  6. package/dist/CoderChoice.d.ts +2 -4
  7. package/dist/CoderChoice.d.ts.map +1 -1
  8. package/dist/CoderChoice.js +8 -12
  9. package/dist/CoderChoice.js.map +1 -1
  10. package/dist/Config.d.ts +238 -0
  11. package/dist/Config.d.ts.map +1 -0
  12. package/dist/Config.js +594 -0
  13. package/dist/Config.js.map +1 -0
  14. package/dist/ConfigCommand.d.ts +180 -0
  15. package/dist/ConfigCommand.d.ts.map +1 -0
  16. package/dist/ConfigCommand.js +903 -0
  17. package/dist/ConfigCommand.js.map +1 -0
  18. package/dist/ConfigEdit.d.ts +79 -0
  19. package/dist/ConfigEdit.d.ts.map +1 -0
  20. package/dist/ConfigEdit.js +110 -0
  21. package/dist/ConfigEdit.js.map +1 -0
  22. package/dist/ConfigTrust.d.ts +45 -0
  23. package/dist/ConfigTrust.d.ts.map +1 -0
  24. package/dist/ConfigTrust.js +72 -0
  25. package/dist/ConfigTrust.js.map +1 -0
  26. package/dist/FlowLaunch.d.ts +2 -3
  27. package/dist/FlowLaunch.d.ts.map +1 -1
  28. package/dist/FlowLaunch.js +1 -5
  29. package/dist/FlowLaunch.js.map +1 -1
  30. package/dist/FlowProcess.d.ts +3 -1
  31. package/dist/FlowProcess.d.ts.map +1 -1
  32. package/dist/FlowProcess.js.map +1 -1
  33. package/dist/Menu.d.ts +1 -1
  34. package/dist/Menu.d.ts.map +1 -1
  35. package/dist/Menu.js +33 -6
  36. package/dist/Menu.js.map +1 -1
  37. package/dist/OperatorConfig.d.ts.map +1 -1
  38. package/dist/OperatorConfig.js +2 -1
  39. package/dist/OperatorConfig.js.map +1 -1
  40. package/dist/OperatorTools.d.ts +2 -0
  41. package/dist/OperatorTools.d.ts.map +1 -1
  42. package/dist/Refine.d.ts.map +1 -1
  43. package/dist/Refine.js +3 -2
  44. package/dist/Refine.js.map +1 -1
  45. package/dist/RunSupervisor.d.ts +4 -3
  46. package/dist/RunSupervisor.d.ts.map +1 -1
  47. package/dist/RunSupervisor.js +26 -13
  48. package/dist/RunSupervisor.js.map +1 -1
  49. package/flows/epic-design.js +7 -5
  50. package/flows/epic-retro.js +3 -2
  51. package/flows/implement.js +3 -2
  52. package/flows/issue-pr.js +3 -2
  53. package/flows/judge-suite.js +2 -2
  54. package/flows/lib/debt.js +2 -2
  55. package/flows/lib/epic-retro.js +3 -6
  56. package/flows/lib/epic-stories.js +54 -115
  57. package/flows/lib/modernize-extract.js +3 -6
  58. package/flows/lib/pack-fork.js +8 -10
  59. package/flows/lib/port.js +8 -10
  60. package/flows/local.js +3 -2
  61. package/flows/modernize-bench.js +5 -5
  62. package/flows/modernize-extract.js +8 -7
  63. package/flows/modernize-implement.js +4 -6
  64. package/flows/modernize-pack-check.js +2 -1
  65. package/flows/modernize-pack-upgrade.js +2 -1
  66. package/flows/modernize-refine.js +6 -5
  67. package/flows/modernize-review.js +2 -2
  68. package/flows/modernize-seed.js +8 -8
  69. package/flows/modernize-survey.js +4 -7
  70. package/flows/modernize-verify.js +2 -2
  71. package/flows/pack-fork.js +4 -3
  72. package/flows/port-compile.js +4 -3
  73. package/flows/port-files.js +2 -2
  74. package/flows/port-guide.js +5 -4
  75. package/flows/port-ledger.js +2 -2
  76. package/flows/port-tests.js +5 -4
  77. package/flows/roundtable.js +2 -2
  78. package/flows/sdd.js +8 -13
  79. package/flows/taskforce.js +5 -4
  80. package/kits/j2ee-nextjs/README.md +2 -1
  81. package/kits/j2ee-nextjs/fixtures/demo-bank/RUNBOOK.md +32 -14
  82. package/kits/j2ee-nextjs/fixtures/demo-bank/reset-demo.mjs +3 -1
  83. package/kits/j2ee-nextjs/flows/convert-all.js +8 -7
  84. package/kits/j2ee-nextjs/flows/convert-feature.js +2 -2
  85. package/kits/j2ee-nextjs/flows/convert-page.js +2 -2
  86. package/kits/j2ee-nextjs/flows/lib/convert.js +7 -10
  87. package/kits/soap-ace/flows/soap-design.js +5 -8
  88. package/kits/soap-ace/flows/soap-discover.js +4 -3
  89. package/kits/soap-ace/flows/soap-epic.js +4 -7
  90. package/kits/soap-ace/flows/soap-explore.js +8 -7
  91. package/kits/soap-ace/flows/soap-sample.js +10 -10
  92. package/kits/soap-ace/tools/soap-call.js +3 -2
  93. package/package.json +8 -4
  94. package/src/Cli.ts +176 -46
  95. package/src/CoderChoice.ts +10 -16
  96. package/src/Config.ts +868 -0
  97. package/src/ConfigCommand.ts +1423 -0
  98. package/src/ConfigEdit.ts +180 -0
  99. package/src/ConfigTrust.ts +145 -0
  100. package/src/FlowLaunch.ts +3 -8
  101. package/src/FlowProcess.ts +3 -1
  102. package/src/Menu.ts +40 -7
  103. package/src/OperatorConfig.ts +2 -1
  104. package/src/Refine.ts +3 -2
  105. package/src/RunSupervisor.ts +26 -14
@@ -2,7 +2,7 @@
2
2
  import * as Effect from "effect/Effect";
3
3
  import { Dimension, Sample, repeat } from "@llm4ts/core/eval/Eval";
4
4
  import { judge } from "@llm4ts/core/eval/Judge";
5
- import { Info, coderFromEnv, resolveFlowInput, runFlowMain, runNode } from "@llm4ts/runner";
5
+ import { Info, resolveFlowInput, runFlowMain, runNode, coderFromEnvironment } from "@llm4ts/runner";
6
6
  const dimensions = [
7
7
  Dimension.make({
8
8
  name: "correctness",
@@ -19,7 +19,7 @@ const dimensions = [
19
19
  ];
20
20
  const program = Effect.gen(function* () {
21
21
  const input = yield* resolveFlowInput("You can return an unopened item within 30 days with its receipt.");
22
- const selected = coderFromEnv(process.env);
22
+ const selected = yield* coderFromEnvironment();
23
23
  yield* runNode({
24
24
  workDir: input.workDir,
25
25
  workspace: input.workspace,
package/flows/lib/debt.js CHANGED
@@ -5,6 +5,7 @@ import { join } from "node:path";
5
5
  import * as Effect from "effect/Effect";
6
6
  import { Info } from "@llm4ts/flow/FlowEvents";
7
7
  import { countNotPlanned } from "@llm4ts/flow/RefineRound";
8
+ import { settingValue } from "@llm4ts/flow/Settings";
8
9
  import { lastStoryVerdict } from "@llm4ts/flow/Stories";
9
10
  import { ScriptUsage } from "@llm4ts/runner";
10
11
  import { deferringTestsJudge, epicUsage, loadRounds, rubricStoryJudge, unitStateDirs } from "./epic-stories.js";
@@ -109,8 +110,7 @@ export const hardenOptions = {
109
110
  afterUnit: hardenAfterUnit
110
111
  };
111
112
  export const parseStoriesFlags = (argv, environment) => Effect.gen(function* () {
112
- const deferTests = argv.includes("--defer-tests") ||
113
- /^(1|true|on|yes)$/i.test(environment.LLM4TS_DEFER_TESTS?.trim() ?? "");
113
+ const deferTests = argv.includes("--defer-tests") || settingValue("LLM4TS_DEFER_TESTS", environment);
114
114
  const harden = argv.includes("--harden");
115
115
  if (deferTests && harden) {
116
116
  return yield* ScriptUsage.make({
@@ -10,7 +10,8 @@ import * as Effect from "effect/Effect";
10
10
  import { readEpicRuns } from "@llm4ts/flow/EpicRuns";
11
11
  import { Info } from "@llm4ts/flow/FlowEvents";
12
12
  import { readTrace } from "@llm4ts/flow/Replay";
13
- import { RetroProposal, defaultRetroChars, loadEpicFiles, loadStoryFiles, renderRetroDigest, retroCandidates, retroPaths, retroPrompt, retroProposalJsonSchema, validateRetroProposal, writeRetro } from "@llm4ts/flow/Retro";
13
+ import { settingValue } from "@llm4ts/flow/Settings";
14
+ import { RetroProposal, loadEpicFiles, loadStoryFiles, renderRetroDigest, retroCandidates, retroPaths, retroPrompt, retroProposalJsonSchema, validateRetroProposal, writeRetro } from "@llm4ts/flow/Retro";
14
15
  import { makeStoryPlanStore } from "@llm4ts/flow/StoryPlan";
15
16
  import { structuredAndPublish } from "@llm4ts/flow/Usage";
16
17
  import { ScriptUsage } from "@llm4ts/runner/FlowArgs";
@@ -69,10 +70,6 @@ export const resolveRetroTarget = Effect.fn("epic-retro.resolveTarget")(function
69
70
  }
70
71
  return { run, stateDir, plan };
71
72
  });
72
- const retroChars = (environment) => {
73
- const value = Number.parseInt(environment.LLM4TS_RETRO_CHARS ?? "", 10);
74
- return Number.isInteger(value) && value > 0 ? value : defaultRetroChars;
75
- };
76
73
  /** The whole retro: evidence, one structured call, validation, the files. */
77
74
  export const runRetro = Effect.fn("epic-retro.run")(function* (deps) {
78
75
  const { files, target } = deps;
@@ -88,7 +85,7 @@ export const runRetro = Effect.fn("epic-retro.run")(function* (deps) {
88
85
  report: epic.report,
89
86
  board: epic.board,
90
87
  stories,
91
- budget: retroChars(deps.environment)
88
+ budget: settingValue("LLM4TS_RETRO_CHARS", deps.environment)
92
89
  };
93
90
  const candidates = retroCandidates(withoutTranscripts);
94
91
  if (candidates.length === 0) {
@@ -27,6 +27,7 @@ import { BlockedVerdict, StoryState, StoryStateVersion, StoryVerdict } from "@ll
27
27
  import { stableHash } from "@llm4ts/flow/Plan";
28
28
  import { ReviewIssue, reviewRulesPreamble } from "@llm4ts/flow/Review";
29
29
  import { compactGateArtifacts, gatesIn } from "@llm4ts/flow/Gates";
30
+ import { settingGiven, settingValue } from "@llm4ts/flow/Settings";
30
31
  import { defaultStallRepeats } from "@llm4ts/flow/Stall";
31
32
  import { loadTranscript, nodeTranscriptFiles } from "@llm4ts/runner/Transcripts";
32
33
  import { StoryPlan, dependenciesOf, makeStoryPlanStore, parseStoryPlan, isSafeAnchor, pathsNamedIn, pruneReadFirst } from "@llm4ts/flow/StoryPlan";
@@ -41,8 +42,8 @@ import { landEpic } from "@llm4ts/flow/Landing";
41
42
  import { deferredPath, implementStoriesFlow } from "@llm4ts/flow/Stories";
42
43
  import { validateStoryPlan } from "@llm4ts/flow/StoryPlan";
43
44
  import { asReadOnly, nodePlainFileStore, nodeProcessExecutor, openPack, resolveFlowInput, runNode, stage, withModel } from "@llm4ts/runner";
44
- import { claude, coderIds, judgmentConnectorFromEnvironment, pi } from "@llm4ts/runner/Connectors";
45
- import { FlowAborted, FlowLlmError, ReviewResult, ScriptUsage, coderFor, lintCommand } from "@llm4ts/runner";
45
+ import { claude, judgmentConnectorFromEnvironment, pi, coderFromEnvironment, reasonerFromEnvironment as runnerReasonerFromEnvironment, seatsFromEnvironment } from "@llm4ts/runner/Connectors";
46
+ import { FlowAborted, FlowLlmError, ReviewResult, ScriptUsage, lintCommand } from "@llm4ts/runner";
46
47
  export const epicUsage = [
47
48
  "epic-stories flags:",
48
49
  " --plan-only write (or re-validate) the story plan and stop",
@@ -249,8 +250,8 @@ export const mergeRevisionsOption = (flag, environment) => {
249
250
  if (flag !== undefined) {
250
251
  return { mergeRevisions: flag };
251
252
  }
252
- const raw = environment.LLM4TS_MERGE_REVISIONS?.trim() ?? "";
253
- return /^\d+$/u.test(raw) ? { mergeRevisions: Number.parseInt(raw, 10) } : {};
253
+ const given = settingGiven("LLM4TS_MERGE_REVISIONS", environment);
254
+ return given._tag === "Read" ? { mergeRevisions: given.value } : {};
254
255
  };
255
256
  /**
256
257
  * Coders per story (ADR 0034): `--task-concurrency`, else
@@ -261,11 +262,11 @@ export const taskConcurrencyOption = (flag, environment) => {
261
262
  if (flag !== undefined) {
262
263
  return { taskConcurrency: flag };
263
264
  }
264
- const raw = environment.LLM4TS_TASK_CONCURRENCY?.trim() ?? "";
265
- return /^[1-9]\d*$/u.test(raw) ? { taskConcurrency: Number.parseInt(raw, 10) } : {};
265
+ const given = settingGiven("LLM4TS_TASK_CONCURRENCY", environment);
266
+ return given._tag === "Read" ? { taskConcurrency: given.value } : {};
266
267
  };
267
- /** `--defer-findings`, or `LLM4TS_DEFER_FINDINGS` set to 1/true/on/yes (ADR 0031). */
268
- export const deferFindingsEnabled = (flag, environment) => flag || /^(1|true|on|yes)$/i.test(environment.LLM4TS_DEFER_FINDINGS?.trim() ?? "");
268
+ /** `--defer-findings`, or `LLM4TS_DEFER_FINDINGS` on (ADR 0031). */
269
+ export const deferFindingsEnabled = (flag, environment) => flag || settingValue("LLM4TS_DEFER_FINDINGS", environment);
269
270
  /**
270
271
  * The feedback a follow-up round is planned from (ADR 0031): every story's
271
272
  * deferred findings, in plan order. `undefined` when nothing was deferred.
@@ -290,8 +291,8 @@ export const judgeRoundsOption = (flag, environment) => {
290
291
  if (flag !== undefined) {
291
292
  return { judgeRounds: flag };
292
293
  }
293
- const raw = Number.parseInt(environment.LLM4TS_JUDGE_ROUNDS ?? "", 10);
294
- return Number.isInteger(raw) && raw > 0 ? { judgeRounds: raw } : {};
294
+ const rounds = settingValue("LLM4TS_JUDGE_ROUNDS", environment);
295
+ return rounds === undefined ? {} : { judgeRounds: rounds };
295
296
  };
296
297
  /**
297
298
  * Where the lenses run and for how many rounds (ADR 0044): per story unless
@@ -563,55 +564,10 @@ export const chooseEpic = (args) => {
563
564
  };
564
565
  // ---- Seats --------------------------------------------------------------------
565
566
  /** The reasoning seat: `LLM4TS_REASONER`, any coder id, default claude. Unknown names fail typed. */
566
- export const reasonerFromEnvironment = (environment) => {
567
- const requested = (environment.LLM4TS_REASONER ?? "").trim();
568
- if (requested.length === 0) {
569
- return Effect.succeed(claude);
570
- }
571
- const preset = coderFor(requested);
572
- return preset === undefined
573
- ? ScriptUsage.make({
574
- message: `unknown LLM4TS_REASONER '${requested}'; expected ${coderIds.join("|")}`
575
- })
576
- : Effect.succeed(preset);
577
- };
567
+ export const reasonerFromEnvironment = (environment) => runnerReasonerFromEnvironment(environment);
578
568
  /** The coder seat: `LLM4TS_CODER`, default pi — the cheap local typist under a stronger orchestrator. */
579
- export const storyCoderFromEnvironment = (environment) => {
580
- const requested = (environment.LLM4TS_CODER ?? "").trim();
581
- if (requested.length === 0) {
582
- return Effect.succeed(pi);
583
- }
584
- const preset = coderFor(requested);
585
- return preset === undefined
586
- ? ScriptUsage.make({
587
- message: `unknown LLM4TS_CODER '${requested}'; expected ${coderIds.join("|")}`
588
- })
589
- : Effect.succeed(preset);
590
- };
569
+ export const storyCoderFromEnvironment = (environment) => coderFromEnvironment(environment, pi);
591
570
  // ---- Seat flags and local servers --------------------------------------------------
592
- /**
593
- * `LLM4TS_CODER_FLAGS` / `LLM4TS_REASONING_FLAGS`: extra CLI flags for a seat as
594
- * `key=value;key=value` (a bare `key` is a boolean flag). The first `=` splits, so
595
- * a value may itself carry `=`: `config=model_provider=lmstudio` is codex's
596
- * `--config model_provider=lmstudio`.
597
- */
598
- export const flagsFromEnvironment = (raw) => {
599
- const flags = {};
600
- for (const part of (raw ?? "").split(";")) {
601
- const entry = part.trim();
602
- if (entry.length === 0) {
603
- continue;
604
- }
605
- const at = entry.indexOf("=");
606
- if (at < 0) {
607
- flags[entry] = "";
608
- }
609
- else {
610
- flags[entry.slice(0, at).trim()] = entry.slice(at + 1).trim();
611
- }
612
- }
613
- return flags;
614
- };
615
571
  /**
616
572
  * The local single-model server a coder seat points at, if any: pi's
617
573
  * `lmstudio/…` and `ollama/…` model specs, codex's `--config model_provider=lmstudio`,
@@ -642,10 +598,8 @@ export const localCoderServer = (model, flags, environment) => {
642
598
  * it, a coder's parent directory is the epic checkout, and coders cd there.
643
599
  */
644
600
  export const worktreeRootFor = (workDir, epicId, environment) => {
645
- const configured = environment.LLM4TS_WORKTREE_ROOT?.trim();
646
- const root = configured === undefined || configured.length === 0
647
- ? `${workDir.replace(/[\\/]+$/, "")}.worktrees`
648
- : configured;
601
+ const root = settingValue("LLM4TS_WORKTREE_ROOT", environment) ??
602
+ `${workDir.replace(/[\\/]+$/, "")}.worktrees`;
649
603
  return join(root, epicId);
650
604
  };
651
605
  /**
@@ -654,8 +608,8 @@ export const worktreeRootFor = (workDir, epicId, environment) => {
654
608
  * address. Undefined for a hosted provider — there is nothing to poll.
655
609
  */
656
610
  export const serverHealthUrl = (server, environment) => {
657
- const configured = environment.LLM4TS_CODER_HEALTH_URL?.trim();
658
- if (configured !== undefined && configured.length > 0) {
611
+ const configured = settingValue("LLM4TS_CODER_HEALTH_URL", environment);
612
+ if (configured !== undefined) {
659
613
  return configured;
660
614
  }
661
615
  switch (server) {
@@ -1169,8 +1123,8 @@ const hasPackageJson = (dir) => Effect.tryPromise(() => readdir(dir)).pipe(Effec
1169
1123
  * The value is relative so it applies to every worktree and the epic checkout.
1170
1124
  */
1171
1125
  export const appDirFor = (workDir, environment) => Effect.gen(function* () {
1172
- const configured = environment.LLM4TS_APP_DIR?.trim();
1173
- if (configured !== undefined && configured.length > 0) {
1126
+ const configured = settingValue("LLM4TS_APP_DIR", environment);
1127
+ if (configured !== undefined) {
1174
1128
  const normalized = normalize(configured);
1175
1129
  const relative = normalized.replace(/[\\/]+$/, "");
1176
1130
  if (isAbsolute(normalized) || relative === ".." || /^\.\.[\\/]/.test(relative)) {
@@ -1206,21 +1160,18 @@ export const defaultWorktreeSetup = ["pnpm", "install", "--offline"];
1206
1160
  * runbook warms the pnpm store once, and a workshop stage has no network.
1207
1161
  */
1208
1162
  export const worktreeSetupCommand = (environment, pack) => {
1209
- const raw = environment.LLM4TS_WORKTREE_SETUP;
1210
- if (raw === undefined) {
1163
+ const given = settingGiven("LLM4TS_WORKTREE_SETUP", environment);
1164
+ if (given._tag !== "Read") {
1211
1165
  return pack === undefined ? defaultWorktreeSetup : pack.setup;
1212
1166
  }
1213
- const parts = raw
1214
- .trim()
1215
- .split(/\s+/)
1216
- .filter((part) => part.length > 0);
1167
+ const parts = given.value.split(/\s+/).filter((part) => part.length > 0);
1217
1168
  return parts.length === 0 ? undefined : parts;
1218
1169
  };
1219
1170
  /**
1220
- * `LLM4TS_SETUP_AGENT=1` (or `true`/`on`): a failed setup gets one coder turn
1171
+ * `LLM4TS_SETUP_AGENT=on`: a failed setup gets one coder turn
1221
1172
  * to make the worktree ready, then runs again as the check. Off by default.
1222
1173
  */
1223
- export const setupAgentEnabled = (environment) => /^(1|true|on|yes)$/i.test(environment.LLM4TS_SETUP_AGENT?.trim() ?? "");
1174
+ export const setupAgentEnabled = (environment) => settingValue("LLM4TS_SETUP_AGENT", environment);
1224
1175
  const output = (result) => result.issues.map((issue) => issue.description).join("\n");
1225
1176
  /** Runs the setup command in a worktree; a non-zero exit fails the story with the output. */
1226
1177
  export const setupIn = (process, events, command) => (workDir, laneEvents) => Effect.flatMap(lintCommand(process, laneEvents ?? events, command, workDir), (result) => result.isClean
@@ -1257,15 +1208,9 @@ export const appScripts = (files, appRoot) => files.read(join(appRoot, "package.
1257
1208
  * `pnpm typecheck` there fails with "Command not found", not a red gate.
1258
1209
  */
1259
1210
  export const gateCommands = (environment, scripts, packGates) => {
1260
- const raw = environment.LLM4TS_GATES?.trim();
1261
- if (raw !== undefined && raw.length > 0) {
1262
- return raw
1263
- .split(";")
1264
- .map((command) => command
1265
- .trim()
1266
- .split(/\s+/)
1267
- .filter((part) => part.length > 0))
1268
- .filter((command) => command.length > 0);
1211
+ const override = settingValue("LLM4TS_GATES", environment);
1212
+ if (override !== undefined) {
1213
+ return override.map((command) => command.split(/\s+/));
1269
1214
  }
1270
1215
  if (packGates !== undefined) {
1271
1216
  return packGates;
@@ -1281,7 +1226,7 @@ export const gateCommands = (environment, scripts, packGates) => {
1281
1226
  * `openPack` would otherwise load `cobol-springboot`, which is the
1282
1227
  * modernization flows' default, not an epic's.
1283
1228
  */
1284
- export const selectedPack = (options) => (options.environment.LLM4TS_PACK?.trim() ?? "").length === 0
1229
+ export const selectedPack = (options) => settingValue("LLM4TS_PACK", options.environment) === undefined
1285
1230
  ? Effect.succeed(undefined)
1286
1231
  : Effect.map(openPack({
1287
1232
  environment: options.environment,
@@ -1290,7 +1235,7 @@ export const selectedPack = (options) => (options.environment.LLM4TS_PACK?.trim(
1290
1235
  }), (opened) => opened.pack);
1291
1236
  /** The run's gates: `LLM4TS_GATES`, else the selected pack's `## Gates`, else the defaults. */
1292
1237
  export const epicGateCommands = (options) => {
1293
- const override = (options.environment.LLM4TS_GATES?.trim() ?? "").length > 0;
1238
+ const override = settingValue("LLM4TS_GATES", options.environment) !== undefined;
1294
1239
  return {
1295
1240
  commands: gateCommands(options.environment, options.scripts, options.pack === undefined
1296
1241
  ? undefined
@@ -1314,33 +1259,27 @@ export const gateListMessage = (resolved) => {
1314
1259
  /** The gate runner lives in `@llm4ts/flow/Gates` (ADR 0027); re-exported for forks and tests. */
1315
1260
  export { gatesIn };
1316
1261
  /** `LLM4TS_GATE_TIMEOUT` in seconds (default 1200): a gate still running after it is a hang. */
1317
- export const gateTimeoutSeconds = (environment) => {
1318
- const raw = Number.parseInt(environment.LLM4TS_GATE_TIMEOUT ?? "", 10);
1319
- return Number.isFinite(raw) && raw > 0 ? raw : 1200;
1320
- };
1262
+ export const gateTimeoutSeconds = (environment) => Duration.toSeconds(settingValue("LLM4TS_GATE_TIMEOUT", environment));
1321
1263
  /** `LLM4TS_GATE_TAIL_CHARS` (default 4000): how much gate output the fix prompt carries. */
1322
- export const gateTailChars = (environment) => {
1323
- const raw = Number.parseInt(environment.LLM4TS_GATE_TAIL_CHARS ?? "", 10);
1324
- return Number.isFinite(raw) && raw > 0 ? raw : 4000;
1325
- };
1264
+ export const gateTailChars = (environment) => settingValue("LLM4TS_GATE_TAIL_CHARS", environment);
1326
1265
  /** `LLM4TS_REVIEW_VOTES` (default 1): independent votes of the adversarial lens per round. */
1327
1266
  export const reviewVotes = (environment) => {
1328
- const raw = Number.parseInt(environment.LLM4TS_REVIEW_VOTES ?? "", 10);
1329
- return Number.isFinite(raw) && raw > 1 ? { votes: raw } : {};
1267
+ const votes = settingValue("LLM4TS_REVIEW_VOTES", environment);
1268
+ return votes !== undefined && votes > 1 ? { votes } : {};
1330
1269
  };
1331
1270
  /** `LLM4TS_REVIEW_FIXER=separate`: review findings go to a fresh fixer chat, not the implementer's. */
1332
- export const reviewFixer = (environment) => environment.LLM4TS_REVIEW_FIXER?.trim().toLowerCase() === "separate" ? { fixer: "separate" } : {};
1271
+ export const reviewFixer = (environment) => settingValue("LLM4TS_REVIEW_FIXER", environment) === "separate" ? { fixer: "separate" } : {};
1333
1272
  /**
1334
1273
  * `LLM4TS_STALL_REPEATS` (default 5) ends a coder turn that repeats one tool
1335
1274
  * call that many times in a row; `LLM4TS_STALL_MINUTES` (unset: off) ends a
1336
1275
  * turn with no output for that long. ADR 0027 decision 11.
1337
1276
  */
1338
1277
  export const stallOptions = (environment) => {
1339
- const repeats = Number.parseInt(environment.LLM4TS_STALL_REPEATS ?? "", 10);
1340
- const minutes = Number.parseFloat(environment.LLM4TS_STALL_MINUTES ?? "");
1278
+ const repeats = settingValue("LLM4TS_STALL_REPEATS", environment);
1279
+ const silence = settingValue("LLM4TS_STALL_MINUTES", environment);
1341
1280
  return {
1342
- repeats: Number.isFinite(repeats) && repeats >= 2 ? repeats : defaultStallRepeats,
1343
- ...(Number.isFinite(minutes) && minutes > 0 ? { silence: Duration.minutes(minutes) } : {})
1281
+ repeats: repeats >= 2 ? repeats : defaultStallRepeats,
1282
+ ...(silence === undefined ? {} : { silence })
1344
1283
  };
1345
1284
  };
1346
1285
  export const gateRunOptions = (environment) => ({ timeout: Duration.seconds(gateTimeoutSeconds(environment)) });
@@ -1367,7 +1306,7 @@ export const fixPromptOptions = (environment) => ({ tailChars: gateTailChars(env
1367
1306
  * explainable from them. `LLM4TS_TRANSCRIPT=off` (or `0`, `false`, `no`)
1368
1307
  * turns them off; an explicit value is never overridden.
1369
1308
  */
1370
- export const storiesEnvironment = (environment) => environment.LLM4TS_TRANSCRIPT === undefined
1309
+ export const storiesEnvironment = (environment) => settingGiven("LLM4TS_TRANSCRIPT", environment)._tag === "Unset"
1371
1310
  ? { ...environment, LLM4TS_TRANSCRIPT: "on" }
1372
1311
  : environment;
1373
1312
  const decodeTranscriptLine = Schema.decodeUnknownOption(Schema.fromJsonString(TranscriptEntry));
@@ -1426,11 +1365,8 @@ export const compactTranscripts = (workDir, runIds) => Effect.reduce(runIds, ()
1426
1365
  * coder sees up front (0 leaves it out); the executor's default otherwise.
1427
1366
  */
1428
1367
  export const storyContextChars = (environment) => {
1429
- const raw = environment.LLM4TS_STORY_CONTEXT_CHARS?.trim();
1430
- const value = Number(raw ?? "");
1431
- return raw === undefined || raw.length === 0 || !Number.isInteger(value) || value < 0
1432
- ? {}
1433
- : { contextChars: value };
1368
+ const given = settingGiven("LLM4TS_STORY_CONTEXT_CHARS", environment);
1369
+ return given._tag === "Read" ? { contextChars: given.value } : {};
1434
1370
  };
1435
1371
  /**
1436
1372
  * The repository as the planner and every coder see it before they look: a
@@ -1501,12 +1437,13 @@ export const epicRunnerOptions = Effect.fn("epic-stories.runnerOptions")(functio
1501
1437
  };
1502
1438
  });
1503
1439
  /** `LLM4TS_CODER_MODEL` / `LLM4TS_REASONING_MODEL`: pi takes `provider/model` (e.g. `openai-codex/gpt-5.5`). */
1504
- const withOptionalModel = (config, model) => {
1505
- const trimmed = model?.trim();
1506
- return trimmed === undefined || trimmed.length === 0 ? config : withModel(config, trimmed);
1507
- };
1508
- /** Extra CLI flags on top of a preset's own (`LLM4TS_CODER_FLAGS`). */
1509
- const withExtraFlags = (config, flags) => Object.keys(flags).length === 0
1440
+ const withOptionalModel = (config, model) => (model === undefined ? config : withModel(config, model));
1441
+ /**
1442
+ * Extra CLI flags on top of a preset's own (`LLM4TS_CODER_FLAGS`,
1443
+ * `LLM4TS_REASONING_FLAGS`). A value may itself carry `=`:
1444
+ * `config=model_provider=lmstudio` is codex's `--config model_provider=lmstudio`.
1445
+ */
1446
+ const withExtraFlags = (config, flags) => flags === undefined
1510
1447
  ? config
1511
1448
  : CliConnectorConfig.make({ ...config, flags: { ...config.flags, ...flags } });
1512
1449
  export const defaultEpic = "Add the retail customer's current account (Conto) with balance and movements, and wire " +
@@ -1581,10 +1518,12 @@ export const runEpicStories = (options) => Effect.gen(function* () {
1581
1518
  launchDir: given.workspace,
1582
1519
  flowDir: import.meta.dirname
1583
1520
  });
1584
- const coderFlags = flagsFromEnvironment(process.env.LLM4TS_CODER_FLAGS);
1585
- const reasoning = withExtraFlags(withOptionalModel(yield* reasonerFromEnvironment(process.env), process.env.LLM4TS_REASONING_MODEL), flagsFromEnvironment(process.env.LLM4TS_REASONING_FLAGS));
1586
- const coder = withExtraFlags(withOptionalModel(yield* storyCoderFromEnvironment(process.env), process.env.LLM4TS_CODER_MODEL), coderFlags);
1587
- const localServer = localCoderServer(process.env.LLM4TS_CODER_MODEL, coderFlags, process.env);
1521
+ const coderFlags = settingValue("LLM4TS_CODER_FLAGS", process.env);
1522
+ const coderModel = settingValue("LLM4TS_CODER_MODEL", process.env);
1523
+ const seats = yield* seatsFromEnvironment({ coder: pi, reasoner: claude });
1524
+ const reasoning = withExtraFlags(withOptionalModel(seats.reasoning, settingValue("LLM4TS_REASONING_MODEL", process.env)), settingValue("LLM4TS_REASONING_FLAGS", process.env));
1525
+ const coder = withExtraFlags(withOptionalModel(seats.coder, coderModel), coderFlags);
1526
+ const localServer = localCoderServer(coderModel, coderFlags ?? {}, process.env);
1588
1527
  // A new epic's id (and state folder) is derived from its text; an existing
1589
1528
  // one keeps its folder, whatever text is on the command line.
1590
1529
  const epicId = choice._tag === "Existing"
@@ -14,18 +14,15 @@ import { ReviewIssue } from "@llm4ts/flow/Review";
14
14
  import { cachedReview } from "@llm4ts/flow/ReviewCache";
15
15
  import { FlowLlmError, Info, ReviewResult, makeChat, reviewFingerprint } from "@llm4ts/runner";
16
16
  import { packageVersion } from "@llm4ts/flow/Package";
17
+ import { settingValue } from "@llm4ts/flow/Settings";
17
18
  export const ModDir = "docs/modernization";
18
- export const positiveEnvInt = (name, fallback) => {
19
- const raw = Number.parseInt(process.env[name] ?? "", 10);
20
- return Number.isFinite(raw) && raw > 0 ? raw : fallback;
21
- };
22
19
  // Per-program turn budget — bounds a wedged agent, generous for real work.
23
- export const analystTurns = () => positiveEnvInt("LLM4TS_ANALYST_TURNS", 48);
20
+ export const analystTurns = () => settingValue("LLM4TS_ANALYST_TURNS", process.env);
24
21
  /**
25
22
  * Max files named in one program's include closure. A program pulling more
26
23
  * than this gets a bounded, visible subset rather than an unbounded read.
27
24
  */
28
- export const maxClosureFiles = () => positiveEnvInt("LLM4TS_MAX_CLOSURE_FILES", 40);
25
+ export const maxClosureFiles = () => settingValue("LLM4TS_MAX_CLOSURE_FILES", process.env) ?? 40;
29
26
  /** The program's bounded closure as a diagram, placed above the analyst's spec (ADR 0030). */
30
27
  export const closureSection = (graph, program) => {
31
28
  const view = closureView(graph, program, maxClosureFiles());
@@ -1,25 +1,26 @@
1
1
  import * as Effect from "effect/Effect";
2
2
  import * as Schema from "effect/Schema";
3
+ import { settingGiven, settingValue } from "@llm4ts/flow/Settings";
3
4
  import { ScriptUsage } from "@llm4ts/runner";
4
5
  export const parseTargetKind = (environment) => {
5
- const raw = environment.LLM4TS_TARGET_KIND?.trim().toLowerCase();
6
- if (raw === "frontend" || raw === "backend") {
7
- return Effect.succeed(raw);
6
+ const given = settingGiven("LLM4TS_TARGET_KIND", environment);
7
+ if (given._tag === "Read") {
8
+ return Effect.succeed(given.value);
8
9
  }
9
10
  return Effect.fail(ScriptUsage.make({
10
11
  message: "LLM4TS_TARGET_KIND must be 'frontend' or 'backend' " +
11
- `(got ${raw === undefined || raw.length === 0 ? "unset" : `'${raw}'`})`
12
+ `(got ${given._tag === "Unset" ? "unset" : `'${given.text.toLowerCase()}'`})`
12
13
  }));
13
14
  };
14
15
  const forkAsPattern = /^[a-z][a-z0-9-]*$/;
15
16
  export const parseForkAs = (environment) => {
16
- const raw = environment.LLM4TS_FORK_AS?.trim();
17
+ const raw = settingValue("LLM4TS_FORK_AS", environment);
17
18
  if (raw !== undefined && forkAsPattern.test(raw)) {
18
19
  return Effect.succeed(raw);
19
20
  }
20
21
  return Effect.fail(ScriptUsage.make({
21
22
  message: "LLM4TS_FORK_AS must be a lowercase kebab-case name, e.g. 'acmecorp-nextjs' " +
22
- `(got ${raw === undefined || raw.length === 0 ? "unset" : `'${raw}'`})`
23
+ `(got ${raw === undefined ? "unset" : `'${raw}'`})`
23
24
  }));
24
25
  };
25
26
  export const frontendPasses = [
@@ -240,10 +241,7 @@ export const provenanceMarkdown = (kind, selections, feedback) => {
240
241
  }
241
242
  return lines.join("\n");
242
243
  };
243
- export const parseFeedback = (environment) => {
244
- const raw = environment.LLM4TS_FEEDBACK?.trim();
245
- return raw === undefined || raw.length === 0 ? undefined : raw;
246
- };
244
+ export const parseFeedback = (environment) => settingValue("LLM4TS_FEEDBACK", environment);
247
245
  export const readGroundingFiles = (workspace, paths) => Effect.gen(function* () {
248
246
  const sections = [];
249
247
  for (const path of paths) {
package/flows/lib/port.js CHANGED
@@ -8,6 +8,7 @@ import { autonomyContract } from "@llm4ts/flow/AutonomyContract";
8
8
  import { cap } from "@llm4ts/flow/Context";
9
9
  import { FlowAborted } from "@llm4ts/flow/FlowError";
10
10
  import { loadPatternCards } from "@llm4ts/flow/Patterns";
11
+ import { settingValue } from "@llm4ts/flow/Settings";
11
12
  import { PortEntry, linesOf, parseLedger, portStatusInstruction, targetPathOf } from "@llm4ts/flow/Port";
12
13
  import { matchingFiles } from "@llm4ts/flow/SpecChecks";
13
14
  /** Where the port flows keep their state, under the target repository. */
@@ -133,16 +134,13 @@ export const nativeImplementerSystem = (porting) => [
133
134
  implementerDenials
134
135
  ].join("\n");
135
136
  export const portEnv = (environment) => {
136
- const int = (raw, fallback, min = 1) => {
137
- const value = Number.parseInt(raw ?? "", 10);
138
- return Number.isFinite(value) && value >= min ? value : fallback;
139
- };
137
+ const sourceChars = settingValue("LLM4TS_PORT_SOURCE_CHARS", environment);
140
138
  return {
141
- pilot: int(environment.LLM4TS_PORT_PILOT, 0, 1),
142
- concurrency: int(environment.LLM4TS_PORT_CONCURRENCY, 4),
143
- batch: int(environment.LLM4TS_PORT_BATCH, 100),
144
- votes: int(environment.LLM4TS_REVIEW_VOTES, 2),
145
- sourceChars: int(environment.LLM4TS_PORT_SOURCE_CHARS, 120_000, 1_000),
146
- shards: int(environment.LLM4TS_PORT_SHARDS, 0, 1)
139
+ pilot: settingValue("LLM4TS_PORT_PILOT", environment),
140
+ concurrency: settingValue("LLM4TS_PORT_CONCURRENCY", environment),
141
+ batch: settingValue("LLM4TS_PORT_BATCH", environment),
142
+ votes: settingValue("LLM4TS_REVIEW_VOTES", environment) ?? 2,
143
+ sourceChars: sourceChars >= 1_000 ? sourceChars : 120_000,
144
+ shards: settingValue("LLM4TS_PORT_SHARDS", environment)
147
145
  };
148
146
  };
package/flows/local.js CHANGED
@@ -1,9 +1,10 @@
1
1
  // Local-first flow: an LM Studio reasoner drafts the plan, a local pi agent implements it.
2
2
  import * as Effect from "effect/Effect";
3
+ import { settingValue } from "@llm4ts/flow/Settings";
3
4
  import { AssistantMessage, Info, completeAndPublish, resolveFlowInput, runFlowMain, runNode, withModel } from "@llm4ts/runner";
4
5
  import { lmStudio, pi, withTimeoutSeconds } from "@llm4ts/runner/Connectors";
5
- const reasoningModel = process.env.LLM4TS_REASONING_MODEL ?? "qwen/qwen3-coder-30b";
6
- const coderModel = process.env.LLM4TS_CODER_MODEL ?? reasoningModel;
6
+ const reasoningModel = settingValue("LLM4TS_REASONING_MODEL", process.env) ?? "qwen/qwen3-coder-30b";
7
+ const coderModel = settingValue("LLM4TS_CODER_MODEL", process.env) ?? reasoningModel;
7
8
  const program = Effect.gen(function* () {
8
9
  const input = yield* resolveFlowInput("Add a multiply function to the calculator, including focused tests.");
9
10
  yield* runNode({
@@ -25,12 +25,13 @@ import { Sample } from "@llm4ts/core/eval/Eval";
25
25
  import { judge } from "@llm4ts/core/eval/Judge";
26
26
  import { BenchJudge, BenchMachine, BenchQuality, BenchRecord, BenchScore, CurrentBenchSchema, makeBenchPhase, makeBenchTap } from "@llm4ts/flow/Bench";
27
27
  import { loadBenchRecords, appendBenchRecord, renderBenchReport } from "@llm4ts/flow/BenchReport";
28
- import { FlowAborted, FlowLlmError, Info, asReadOnly, coderFromEnv, makeNodeWorkspace, mergeReviewResults, nodePlainFileStore, openPack, resolveFlowInput, reviewFingerprint, runFlowMain, runNode, stage } from "@llm4ts/runner";
28
+ import { FlowAborted, FlowLlmError, Info, asReadOnly, coderFromEnvironment, makeNodeWorkspace, mergeReviewResults, nodePlainFileStore, openPack, resolveFlowInput, reviewFingerprint, runFlowMain, runNode, stage } from "@llm4ts/runner";
29
29
  import { TokensUsed } from "@llm4ts/flow/FlowEvents";
30
30
  import { packageVersion } from "@llm4ts/flow/Package";
31
31
  import { coverage, coverageUnits, features, matchingFiles } from "@llm4ts/flow/SpecChecks";
32
32
  import { legacySourceWorkspaceLimits, workspaceLimitsFromEnv } from "@llm4ts/flow/Workspace";
33
33
  import { ProgramArtifacts, ProgramUnit, extractProgramsResumably } from "@llm4ts/flow/Artifacts";
34
+ import { settingValue } from "@llm4ts/flow/Settings";
34
35
  const ModDir = "docs/modernization";
35
36
  const BenchFile = "bench-results.jsonl";
36
37
  const programName = (relativePath) => {
@@ -48,19 +49,18 @@ const machine = () => BenchMachine.make({
48
49
  });
49
50
  const program = Effect.gen(function* () {
50
51
  const input = yield* resolveFlowInput("Benchmark a modernization extraction run");
51
- const mode = process.env.LLM4TS_BENCH_MODE?.trim() ??
52
+ const mode = settingValue("LLM4TS_BENCH_MODE", process.env) ??
52
53
  (input.prompt.trim().toLowerCase() === "report" ? "report" : "measure");
53
54
  const files = nodePlainFileStore;
54
55
  const benchPath = join(input.workspace, BenchFile);
55
- const coder = coderFromEnv(process.env);
56
+ const coder = yield* coderFromEnvironment();
56
57
  const startedAt = new Date();
57
58
  if (mode === "report") {
58
59
  const records = yield* loadBenchRecords(files, benchPath);
59
60
  if (records.length === 0) {
60
61
  return yield* FlowAborted.make({ message: `no benchmark records at ${benchPath}` });
61
62
  }
62
- const projected = Number.parseInt(process.env.LLM4TS_BENCH_PROJECT ?? "", 10);
63
- process.stdout.write(`${renderBenchReport(records, Number.isFinite(projected) && projected > 0 ? projected : undefined)}\n`);
63
+ process.stdout.write(`${renderBenchReport(records, settingValue("LLM4TS_BENCH_PROJECT", process.env))}\n`);
64
64
  return;
65
65
  }
66
66
  yield* runNode({
@@ -34,7 +34,7 @@ import * as Semaphore from "effect/Semaphore";
34
34
  import { budget, capped } from "@llm4ts/flow/Context";
35
35
  import { structuredAndPublish } from "@llm4ts/flow/Flow";
36
36
  import { FlowEvents } from "@llm4ts/flow/FlowEvents";
37
- import { FlowAborted, Info, ReviewResult, asReadOnly, coderFromEnv, defaultPlanInstructions, loadKitPatternCards, makeNodeWorkspace, mergeReviewResults, nodePlainFileStore, openPack, planFrom, resolveFlowInput, runFlowMain, runNode, stage, withTurnLimit } from "@llm4ts/runner";
37
+ import { FlowAborted, Info, ReviewResult, asReadOnly, coderFromEnvironment, defaultPlanInstructions, loadKitPatternCards, makeNodeWorkspace, mergeReviewResults, nodePlainFileStore, openPack, planFrom, resolveFlowInput, runFlowMain, runNode, stage, withTurnLimit } from "@llm4ts/runner";
38
38
  import { loadPatternCards, matchingPatternCards } from "@llm4ts/flow/Patterns";
39
39
  import { legacySourceWorkspaceLimits, workspaceLimitsFromEnv } from "@llm4ts/flow/Workspace";
40
40
  import { ReviewIssue } from "@llm4ts/flow/Review";
@@ -43,7 +43,8 @@ import { SurveyGraph, closureFor } from "@llm4ts/flow/Survey";
43
43
  import { freshGraph, graphCachePath } from "@llm4ts/flow/GraphCache";
44
44
  import { withDraftApproval, requireApproval } from "@llm4ts/flow/Approval";
45
45
  import { ProgramArtifacts, ProgramUnit, extractProgramsResumably, programArtifactPaths } from "@llm4ts/flow/Artifacts";
46
- import { ModDir, analystSystem, analystTurns, fixTurn, globalFixAsk, judgeIssueProgram, makeProgramJudge, maxClosureFiles, positiveEnvInt, programArtifactsJsonSchema, programAsk, programFixAsk, programName, readmeFor, wavePrograms, closureSection } from "./lib/modernize-extract.js";
46
+ import { settingValue } from "@llm4ts/flow/Settings";
47
+ import { ModDir, analystSystem, analystTurns, fixTurn, globalFixAsk, judgeIssueProgram, makeProgramJudge, maxClosureFiles, programArtifactsJsonSchema, programAsk, programFixAsk, programName, readmeFor, wavePrograms, closureSection } from "./lib/modernize-extract.js";
47
48
  const MaxRounds = 3;
48
49
  /**
49
50
  * Programs extracted (and judged) at once. The programs of a wave are
@@ -52,10 +53,10 @@ const MaxRounds = 3;
52
53
  * time without changing tokens or cost. Default 1 keeps the sequential
53
54
  * narration; the bound is about the coder seat's quota, not correctness.
54
55
  */
55
- const extractConcurrency = () => positiveEnvInt("LLM4TS_EXTRACT_CONCURRENCY", 1);
56
+ const extractConcurrency = () => settingValue("LLM4TS_EXTRACT_CONCURRENCY", process.env);
56
57
  const program = Effect.gen(function* () {
57
58
  const input = yield* resolveFlowInput("Extract the complete behavioural spec pack for this legacy estate");
58
- const coder = withTurnLimit(coderFromEnv(process.env), analystTurns());
59
+ const coder = withTurnLimit(yield* coderFromEnvironment(), analystTurns());
59
60
  const files = nodePlainFileStore;
60
61
  const modDirAbs = join(input.workDir, ModDir);
61
62
  yield* runNode({
@@ -76,8 +77,8 @@ const program = Effect.gen(function* () {
76
77
  yield* stage(context.events, "branch", context.git.checkoutOrCreate("modernize/spec-pack").pipe(Effect.asVoid));
77
78
  const system = analystSystem(pack);
78
79
  const all = yield* stage(context.events, "inventory", matchingFiles(repo, pack.programs ?? pack.sources ?? ".*", pack.exclude));
79
- const wave = process.env.LLM4TS_WAVE?.trim();
80
- const programs = wave === undefined || wave.length === 0
80
+ const wave = settingValue("LLM4TS_WAVE", process.env);
81
+ const programs = wave === undefined
81
82
  ? all
82
83
  : yield* Effect.gen(function* () {
83
84
  yield* stage(context.events, "wave approval", requireApproval(files, join(modDirAbs, "wave-plan.md")));
@@ -96,7 +97,7 @@ const program = Effect.gen(function* () {
96
97
  message: `no source units matched the pack's programs/sources regex under ${input.workDir}`
97
98
  });
98
99
  }
99
- const waveScope = wave === undefined || wave.length === 0
100
+ const waveScope = wave === undefined
100
101
  ? undefined
101
102
  : (() => {
102
103
  const names = new Set(programs.map(programName));
@@ -23,7 +23,7 @@ import * as Effect from "effect/Effect";
23
23
  import { withContract } from "@llm4ts/flow/AutonomyContract";
24
24
  import { Dimension, Sample } from "@llm4ts/core/eval/Eval";
25
25
  import { judge } from "@llm4ts/core/eval/Judge";
26
- import { FlowAborted, FlowLlmError, Info, ReviewResult, asReadOnly, coderFromEnv, implementTaskLoop, lintCommand, loadKitPatternCards, makeChat, makeNodeWorkspace, makePlanStore, mergeReviewResults, minimalReviewers, nodePlainFileStore, nodeProcessExecutor, openPack, resolveFlowInput, reviewAndFixLoop, reviewFingerprint, runFlowMain, runNode, stage } from "@llm4ts/runner";
26
+ import { FlowAborted, FlowLlmError, Info, ReviewResult, asReadOnly, coderFromEnvironment, implementTaskLoop, lintCommand, loadKitPatternCards, makeChat, makeNodeWorkspace, makePlanStore, mergeReviewResults, minimalReviewers, nodePlainFileStore, nodeProcessExecutor, openPack, resolveFlowInput, reviewAndFixLoop, reviewFingerprint, runFlowMain, runNode, stage } from "@llm4ts/runner";
27
27
  import { capped, renderTruncation, truncations, withShrink } from "@llm4ts/flow/Context";
28
28
  import { FlowEvents } from "@llm4ts/flow/FlowEvents";
29
29
  import { judgeAllPrograms } from "@llm4ts/flow/ProgramJudge";
@@ -34,11 +34,9 @@ import { nodePreflight } from "@llm4ts/flow/NodePreflight";
34
34
  import { ReviewIssue } from "@llm4ts/flow/Review";
35
35
  import { checkWall, wallBreachMessage } from "@llm4ts/flow/Wall";
36
36
  import { parseDecisions } from "@llm4ts/flow/Decisions";
37
+ import { settingValue } from "@llm4ts/flow/Settings";
37
38
  const ModDir = "docs/modernization";
38
- const judgeRounds = () => {
39
- const raw = Number.parseInt(process.env.LLM4TS_JUDGE_ROUNDS ?? "", 10);
40
- return Number.isFinite(raw) && raw > 0 ? raw : 2;
41
- };
39
+ const judgeRounds = () => settingValue("LLM4TS_JUDGE_ROUNDS", process.env) ?? 2;
42
40
  const complianceDimensions = [
43
41
  Dimension.make({
44
42
  name: "spec-compliance",
@@ -144,7 +142,7 @@ const recordTruncations = (manifestPath, events) => Effect.gen(function* () {
144
142
  });
145
143
  const program = Effect.gen(function* () {
146
144
  const input = yield* resolveFlowInput("Implement the seeded modernization plan");
147
- const coder = coderFromEnv(process.env);
145
+ const coder = yield* coderFromEnvironment();
148
146
  const files = nodePlainFileStore;
149
147
  const planPath = join(input.workDir, ModDir, "plan.md");
150
148
  yield* runNode({