@llm4ts/shell 3.3.0 → 4.0.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.
- package/README.md +36 -0
- package/dist/Cli.d.ts +4 -4
- package/dist/Cli.d.ts.map +1 -1
- package/dist/Cli.js +5 -4
- package/dist/Cli.js.map +1 -1
- package/dist/CoderChoice.d.ts +2 -4
- package/dist/CoderChoice.d.ts.map +1 -1
- package/dist/CoderChoice.js +8 -12
- package/dist/CoderChoice.js.map +1 -1
- package/dist/Config.d.ts +3 -3
- package/dist/Config.d.ts.map +1 -1
- package/dist/Config.js +8 -6
- package/dist/Config.js.map +1 -1
- package/dist/ConfigEdit.js +4 -4
- package/dist/ConfigEdit.js.map +1 -1
- package/dist/Costs.d.ts +52 -0
- package/dist/Costs.d.ts.map +1 -0
- package/dist/Costs.js +95 -0
- package/dist/Costs.js.map +1 -0
- package/dist/OperatorActTools.d.ts +1 -1
- package/dist/OperatorActTools.d.ts.map +1 -1
- package/dist/OperatorActTools.js +1 -1
- package/dist/OperatorActTools.js.map +1 -1
- package/dist/OperatorConfig.d.ts.map +1 -1
- package/dist/OperatorConfig.js +2 -1
- package/dist/OperatorConfig.js.map +1 -1
- package/dist/OperatorNode.js +2 -2
- package/dist/OperatorNode.js.map +1 -1
- package/dist/OperatorRuns.d.ts +1 -1
- package/dist/OperatorRuns.d.ts.map +1 -1
- package/dist/OperatorRuns.js +1 -1
- package/dist/OperatorRuns.js.map +1 -1
- package/dist/OperatorTools.d.ts +4 -2
- package/dist/OperatorTools.d.ts.map +1 -1
- package/dist/OperatorTools.js +4 -4
- package/dist/OperatorTools.js.map +1 -1
- package/dist/Profile.d.ts +313 -0
- package/dist/Profile.d.ts.map +1 -0
- package/dist/Profile.js +937 -0
- package/dist/Profile.js.map +1 -0
- package/dist/Refine.d.ts.map +1 -1
- package/dist/Refine.js +3 -2
- package/dist/Refine.js.map +1 -1
- package/dist/RunReaders.d.ts +70 -0
- package/dist/RunReaders.d.ts.map +1 -0
- package/dist/RunReaders.js +236 -0
- package/dist/RunReaders.js.map +1 -0
- package/dist/StoryReaders.d.ts +16 -0
- package/dist/StoryReaders.d.ts.map +1 -0
- package/dist/StoryReaders.js +107 -0
- package/dist/StoryReaders.js.map +1 -0
- package/dist/Watch.d.ts +68 -0
- package/dist/Watch.d.ts.map +1 -0
- package/dist/Watch.js +261 -0
- package/dist/Watch.js.map +1 -0
- package/flows/epic-design.js +7 -5
- package/flows/epic-retro.js +3 -2
- package/flows/implement.js +3 -2
- package/flows/issue-pr.js +3 -2
- package/flows/judge-suite.js +2 -2
- package/flows/lib/debt.js +2 -2
- package/flows/lib/epic-design.js +1 -1
- package/flows/lib/epic-retro.js +3 -6
- package/flows/lib/epic-stories.js +53 -118
- package/flows/lib/modernize-extract.js +6 -9
- package/flows/lib/pack-fork.js +8 -10
- package/flows/lib/port.js +8 -10
- package/flows/local.js +3 -2
- package/flows/modernize-bench.js +11 -6
- package/flows/modernize-extract.js +9 -8
- package/flows/modernize-implement.js +5 -8
- package/flows/modernize-pack-check.js +2 -1
- package/flows/modernize-pack-upgrade.js +2 -1
- package/flows/modernize-refine.js +7 -6
- package/flows/modernize-review.js +4 -5
- package/flows/modernize-seed.js +8 -8
- package/flows/modernize-survey.js +5 -8
- package/flows/modernize-verify.js +3 -3
- package/flows/pack-fork.js +5 -4
- package/flows/port-compile.js +4 -3
- package/flows/port-files.js +2 -2
- package/flows/port-guide.js +6 -5
- package/flows/port-ledger.js +3 -3
- package/flows/port-tests.js +5 -4
- package/flows/roundtable.js +2 -2
- package/flows/sdd.js +8 -13
- package/flows/taskforce.js +5 -4
- package/kits/j2ee-nextjs/flows/convert-all.js +8 -7
- package/kits/j2ee-nextjs/flows/convert-feature.js +2 -2
- package/kits/j2ee-nextjs/flows/convert-page.js +2 -2
- package/kits/j2ee-nextjs/flows/lib/convert.js +9 -13
- package/kits/soap-ace/flows/soap-design.js +5 -8
- package/kits/soap-ace/flows/soap-discover.js +4 -3
- package/kits/soap-ace/flows/soap-epic.js +4 -7
- package/kits/soap-ace/flows/soap-explore.js +8 -7
- package/kits/soap-ace/flows/soap-sample.js +10 -10
- package/kits/soap-ace/tools/soap-call.js +3 -2
- package/package.json +4 -24
- package/src/Cli.ts +6 -9
- package/src/CoderChoice.ts +10 -16
- package/src/Config.ts +9 -5
- package/src/ConfigEdit.ts +4 -4
- package/src/Costs.ts +148 -0
- package/src/OperatorActTools.ts +1 -1
- package/src/OperatorConfig.ts +2 -1
- package/src/OperatorNode.ts +2 -2
- package/src/OperatorRuns.ts +1 -1
- package/src/OperatorTools.ts +4 -4
- package/src/Profile.ts +1196 -0
- package/src/Refine.ts +3 -2
- package/src/RunReaders.ts +370 -0
- package/src/StoryReaders.ts +157 -0
- package/src/Watch.ts +451 -0
package/flows/lib/epic-design.js
CHANGED
|
@@ -8,7 +8,7 @@ import { cap } from "@llm4ts/flow/Context";
|
|
|
8
8
|
import { buildLedger, inheritedFrom, ledgerHeadline, renderLedger } from "@llm4ts/flow/CoverageLedger";
|
|
9
9
|
import { parseDecisions, scenarioTitles } from "@llm4ts/flow/Decisions";
|
|
10
10
|
import { assembleBrief, checkEpicBrief, diffBriefs, dispositionWords, EpicBriefProposal, epicBriefProposalJsonSchema, loopAction, normalizeBrief, parseEpicBrief, ProgramSelection, programSelectionJsonSchema, providedPointers, renderBriefProblem, renderEpicBrief, unanswered } from "@llm4ts/flow/EpicBrief";
|
|
11
|
-
import { structuredAndPublish } from "@llm4ts/flow/
|
|
11
|
+
import { structuredAndPublish } from "@llm4ts/flow/Usage";
|
|
12
12
|
import { EpicBriefInvalid, ExtractPackMissing, OpenPointsPending } from "@llm4ts/flow/FlowError";
|
|
13
13
|
import { ScriptUsage } from "@llm4ts/runner";
|
|
14
14
|
import { epicIdFor, epicsDir, loadBriefs } from "./epic-stories.js";
|
package/flows/lib/epic-retro.js
CHANGED
|
@@ -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 {
|
|
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:
|
|
88
|
+
budget: settingValue("LLM4TS_RETRO_CHARS", deps.environment)
|
|
92
89
|
};
|
|
93
90
|
const candidates = retroCandidates(withoutTranscripts);
|
|
94
91
|
if (candidates.length === 0) {
|
|
@@ -12,7 +12,7 @@ import { judge } from "@llm4ts/core/eval/Judge";
|
|
|
12
12
|
import { TokenUsage } from "@llm4ts/core/Models";
|
|
13
13
|
import { cap } from "@llm4ts/flow/Context";
|
|
14
14
|
import { parseEpicBrief, renderEpicBrief, unanswered } from "@llm4ts/flow/EpicBrief";
|
|
15
|
-
import { structuredAndPublish } from "@llm4ts/flow/
|
|
15
|
+
import { structuredAndPublish } from "@llm4ts/flow/Usage";
|
|
16
16
|
import { EpicBriefInvalid, EpicBriefNotApproved, EpicCheckoutDirty, LandingFailed, RefineRefused } from "@llm4ts/flow/FlowError";
|
|
17
17
|
import { Info } from "@llm4ts/flow/FlowEvents";
|
|
18
18
|
import { nodePreflight } from "@llm4ts/flow/NodePreflight";
|
|
@@ -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,
|
|
45
|
-
import { FlowAborted, FlowLlmError, ReviewResult, ScriptUsage,
|
|
45
|
+
import { claude, judgmentConnectorFromEnvironment, pi, 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
|
|
253
|
-
return
|
|
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
|
|
265
|
-
return
|
|
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`
|
|
268
|
-
export const deferFindingsEnabled = (flag, environment) => flag ||
|
|
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
|
|
294
|
-
return
|
|
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
|
|
@@ -562,56 +563,7 @@ export const chooseEpic = (args) => {
|
|
|
562
563
|
return Effect.succeed({ _tag: "Text", prompt: args.defaultEpic });
|
|
563
564
|
};
|
|
564
565
|
// ---- Seats --------------------------------------------------------------------
|
|
565
|
-
/** 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
|
-
};
|
|
578
|
-
/** 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
|
-
};
|
|
591
566
|
// ---- 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
567
|
/**
|
|
616
568
|
* The local single-model server a coder seat points at, if any: pi's
|
|
617
569
|
* `lmstudio/…` and `ollama/…` model specs, codex's `--config model_provider=lmstudio`,
|
|
@@ -642,10 +594,8 @@ export const localCoderServer = (model, flags, environment) => {
|
|
|
642
594
|
* it, a coder's parent directory is the epic checkout, and coders cd there.
|
|
643
595
|
*/
|
|
644
596
|
export const worktreeRootFor = (workDir, epicId, environment) => {
|
|
645
|
-
const
|
|
646
|
-
|
|
647
|
-
? `${workDir.replace(/[\\/]+$/, "")}.worktrees`
|
|
648
|
-
: configured;
|
|
597
|
+
const root = settingValue("LLM4TS_WORKTREE_ROOT", environment) ??
|
|
598
|
+
`${workDir.replace(/[\\/]+$/, "")}.worktrees`;
|
|
649
599
|
return join(root, epicId);
|
|
650
600
|
};
|
|
651
601
|
/**
|
|
@@ -654,8 +604,8 @@ export const worktreeRootFor = (workDir, epicId, environment) => {
|
|
|
654
604
|
* address. Undefined for a hosted provider — there is nothing to poll.
|
|
655
605
|
*/
|
|
656
606
|
export const serverHealthUrl = (server, environment) => {
|
|
657
|
-
const configured = environment
|
|
658
|
-
if (configured !== undefined
|
|
607
|
+
const configured = settingValue("LLM4TS_CODER_HEALTH_URL", environment);
|
|
608
|
+
if (configured !== undefined) {
|
|
659
609
|
return configured;
|
|
660
610
|
}
|
|
661
611
|
switch (server) {
|
|
@@ -1169,8 +1119,8 @@ const hasPackageJson = (dir) => Effect.tryPromise(() => readdir(dir)).pipe(Effec
|
|
|
1169
1119
|
* The value is relative so it applies to every worktree and the epic checkout.
|
|
1170
1120
|
*/
|
|
1171
1121
|
export const appDirFor = (workDir, environment) => Effect.gen(function* () {
|
|
1172
|
-
const configured = environment
|
|
1173
|
-
if (configured !== undefined
|
|
1122
|
+
const configured = settingValue("LLM4TS_APP_DIR", environment);
|
|
1123
|
+
if (configured !== undefined) {
|
|
1174
1124
|
const normalized = normalize(configured);
|
|
1175
1125
|
const relative = normalized.replace(/[\\/]+$/, "");
|
|
1176
1126
|
if (isAbsolute(normalized) || relative === ".." || /^\.\.[\\/]/.test(relative)) {
|
|
@@ -1206,21 +1156,18 @@ export const defaultWorktreeSetup = ["pnpm", "install", "--offline"];
|
|
|
1206
1156
|
* runbook warms the pnpm store once, and a workshop stage has no network.
|
|
1207
1157
|
*/
|
|
1208
1158
|
export const worktreeSetupCommand = (environment, pack) => {
|
|
1209
|
-
const
|
|
1210
|
-
if (
|
|
1159
|
+
const given = settingGiven("LLM4TS_WORKTREE_SETUP", environment);
|
|
1160
|
+
if (given._tag !== "Read") {
|
|
1211
1161
|
return pack === undefined ? defaultWorktreeSetup : pack.setup;
|
|
1212
1162
|
}
|
|
1213
|
-
const parts =
|
|
1214
|
-
.trim()
|
|
1215
|
-
.split(/\s+/)
|
|
1216
|
-
.filter((part) => part.length > 0);
|
|
1163
|
+
const parts = given.value.split(/\s+/).filter((part) => part.length > 0);
|
|
1217
1164
|
return parts.length === 0 ? undefined : parts;
|
|
1218
1165
|
};
|
|
1219
1166
|
/**
|
|
1220
|
-
* `LLM4TS_SETUP_AGENT=
|
|
1167
|
+
* `LLM4TS_SETUP_AGENT=on`: a failed setup gets one coder turn
|
|
1221
1168
|
* to make the worktree ready, then runs again as the check. Off by default.
|
|
1222
1169
|
*/
|
|
1223
|
-
export const setupAgentEnabled = (environment) =>
|
|
1170
|
+
export const setupAgentEnabled = (environment) => settingValue("LLM4TS_SETUP_AGENT", environment);
|
|
1224
1171
|
const output = (result) => result.issues.map((issue) => issue.description).join("\n");
|
|
1225
1172
|
/** Runs the setup command in a worktree; a non-zero exit fails the story with the output. */
|
|
1226
1173
|
export const setupIn = (process, events, command) => (workDir, laneEvents) => Effect.flatMap(lintCommand(process, laneEvents ?? events, command, workDir), (result) => result.isClean
|
|
@@ -1257,15 +1204,9 @@ export const appScripts = (files, appRoot) => files.read(join(appRoot, "package.
|
|
|
1257
1204
|
* `pnpm typecheck` there fails with "Command not found", not a red gate.
|
|
1258
1205
|
*/
|
|
1259
1206
|
export const gateCommands = (environment, scripts, packGates) => {
|
|
1260
|
-
const
|
|
1261
|
-
if (
|
|
1262
|
-
return
|
|
1263
|
-
.split(";")
|
|
1264
|
-
.map((command) => command
|
|
1265
|
-
.trim()
|
|
1266
|
-
.split(/\s+/)
|
|
1267
|
-
.filter((part) => part.length > 0))
|
|
1268
|
-
.filter((command) => command.length > 0);
|
|
1207
|
+
const override = settingValue("LLM4TS_GATES", environment);
|
|
1208
|
+
if (override !== undefined) {
|
|
1209
|
+
return override.map((command) => command.split(/\s+/));
|
|
1269
1210
|
}
|
|
1270
1211
|
if (packGates !== undefined) {
|
|
1271
1212
|
return packGates;
|
|
@@ -1281,7 +1222,7 @@ export const gateCommands = (environment, scripts, packGates) => {
|
|
|
1281
1222
|
* `openPack` would otherwise load `cobol-springboot`, which is the
|
|
1282
1223
|
* modernization flows' default, not an epic's.
|
|
1283
1224
|
*/
|
|
1284
|
-
export const selectedPack = (options) => (options.environment
|
|
1225
|
+
export const selectedPack = (options) => settingValue("LLM4TS_PACK", options.environment) === undefined
|
|
1285
1226
|
? Effect.succeed(undefined)
|
|
1286
1227
|
: Effect.map(openPack({
|
|
1287
1228
|
environment: options.environment,
|
|
@@ -1290,7 +1231,7 @@ export const selectedPack = (options) => (options.environment.LLM4TS_PACK?.trim(
|
|
|
1290
1231
|
}), (opened) => opened.pack);
|
|
1291
1232
|
/** The run's gates: `LLM4TS_GATES`, else the selected pack's `## Gates`, else the defaults. */
|
|
1292
1233
|
export const epicGateCommands = (options) => {
|
|
1293
|
-
const override = (options.environment
|
|
1234
|
+
const override = settingValue("LLM4TS_GATES", options.environment) !== undefined;
|
|
1294
1235
|
return {
|
|
1295
1236
|
commands: gateCommands(options.environment, options.scripts, options.pack === undefined
|
|
1296
1237
|
? undefined
|
|
@@ -1314,33 +1255,27 @@ export const gateListMessage = (resolved) => {
|
|
|
1314
1255
|
/** The gate runner lives in `@llm4ts/flow/Gates` (ADR 0027); re-exported for forks and tests. */
|
|
1315
1256
|
export { gatesIn };
|
|
1316
1257
|
/** `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
|
-
};
|
|
1258
|
+
export const gateTimeoutSeconds = (environment) => Duration.toSeconds(settingValue("LLM4TS_GATE_TIMEOUT", environment));
|
|
1321
1259
|
/** `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
|
-
};
|
|
1260
|
+
export const gateTailChars = (environment) => settingValue("LLM4TS_GATE_TAIL_CHARS", environment);
|
|
1326
1261
|
/** `LLM4TS_REVIEW_VOTES` (default 1): independent votes of the adversarial lens per round. */
|
|
1327
1262
|
export const reviewVotes = (environment) => {
|
|
1328
|
-
const
|
|
1329
|
-
return
|
|
1263
|
+
const votes = settingValue("LLM4TS_REVIEW_VOTES", environment);
|
|
1264
|
+
return votes !== undefined && votes > 1 ? { votes } : {};
|
|
1330
1265
|
};
|
|
1331
1266
|
/** `LLM4TS_REVIEW_FIXER=separate`: review findings go to a fresh fixer chat, not the implementer's. */
|
|
1332
|
-
export const reviewFixer = (environment) => environment
|
|
1267
|
+
export const reviewFixer = (environment) => settingValue("LLM4TS_REVIEW_FIXER", environment) === "separate" ? { fixer: "separate" } : {};
|
|
1333
1268
|
/**
|
|
1334
1269
|
* `LLM4TS_STALL_REPEATS` (default 5) ends a coder turn that repeats one tool
|
|
1335
1270
|
* call that many times in a row; `LLM4TS_STALL_MINUTES` (unset: off) ends a
|
|
1336
1271
|
* turn with no output for that long. ADR 0027 decision 11.
|
|
1337
1272
|
*/
|
|
1338
1273
|
export const stallOptions = (environment) => {
|
|
1339
|
-
const repeats =
|
|
1340
|
-
const
|
|
1274
|
+
const repeats = settingValue("LLM4TS_STALL_REPEATS", environment);
|
|
1275
|
+
const silence = settingValue("LLM4TS_STALL_MINUTES", environment);
|
|
1341
1276
|
return {
|
|
1342
|
-
repeats:
|
|
1343
|
-
...(
|
|
1277
|
+
repeats: repeats >= 2 ? repeats : defaultStallRepeats,
|
|
1278
|
+
...(silence === undefined ? {} : { silence })
|
|
1344
1279
|
};
|
|
1345
1280
|
};
|
|
1346
1281
|
export const gateRunOptions = (environment) => ({ timeout: Duration.seconds(gateTimeoutSeconds(environment)) });
|
|
@@ -1367,7 +1302,7 @@ export const fixPromptOptions = (environment) => ({ tailChars: gateTailChars(env
|
|
|
1367
1302
|
* explainable from them. `LLM4TS_TRANSCRIPT=off` (or `0`, `false`, `no`)
|
|
1368
1303
|
* turns them off; an explicit value is never overridden.
|
|
1369
1304
|
*/
|
|
1370
|
-
export const storiesEnvironment = (environment) => environment.
|
|
1305
|
+
export const storiesEnvironment = (environment) => settingGiven("LLM4TS_TRANSCRIPT", environment)._tag === "Unset"
|
|
1371
1306
|
? { ...environment, LLM4TS_TRANSCRIPT: "on" }
|
|
1372
1307
|
: environment;
|
|
1373
1308
|
const decodeTranscriptLine = Schema.decodeUnknownOption(Schema.fromJsonString(TranscriptEntry));
|
|
@@ -1426,11 +1361,8 @@ export const compactTranscripts = (workDir, runIds) => Effect.reduce(runIds, ()
|
|
|
1426
1361
|
* coder sees up front (0 leaves it out); the executor's default otherwise.
|
|
1427
1362
|
*/
|
|
1428
1363
|
export const storyContextChars = (environment) => {
|
|
1429
|
-
const
|
|
1430
|
-
|
|
1431
|
-
return raw === undefined || raw.length === 0 || !Number.isInteger(value) || value < 0
|
|
1432
|
-
? {}
|
|
1433
|
-
: { contextChars: value };
|
|
1364
|
+
const given = settingGiven("LLM4TS_STORY_CONTEXT_CHARS", environment);
|
|
1365
|
+
return given._tag === "Read" ? { contextChars: given.value } : {};
|
|
1434
1366
|
};
|
|
1435
1367
|
/**
|
|
1436
1368
|
* The repository as the planner and every coder see it before they look: a
|
|
@@ -1501,12 +1433,13 @@ export const epicRunnerOptions = Effect.fn("epic-stories.runnerOptions")(functio
|
|
|
1501
1433
|
};
|
|
1502
1434
|
});
|
|
1503
1435
|
/** `LLM4TS_CODER_MODEL` / `LLM4TS_REASONING_MODEL`: pi takes `provider/model` (e.g. `openai-codex/gpt-5.5`). */
|
|
1504
|
-
const withOptionalModel = (config, model) =>
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1436
|
+
const withOptionalModel = (config, model) => (model === undefined ? config : withModel(config, model));
|
|
1437
|
+
/**
|
|
1438
|
+
* Extra CLI flags on top of a preset's own (`LLM4TS_CODER_FLAGS`,
|
|
1439
|
+
* `LLM4TS_REASONING_FLAGS`). A value may itself carry `=`:
|
|
1440
|
+
* `config=model_provider=lmstudio` is codex's `--config model_provider=lmstudio`.
|
|
1441
|
+
*/
|
|
1442
|
+
const withExtraFlags = (config, flags) => flags === undefined
|
|
1510
1443
|
? config
|
|
1511
1444
|
: CliConnectorConfig.make({ ...config, flags: { ...config.flags, ...flags } });
|
|
1512
1445
|
export const defaultEpic = "Add the retail customer's current account (Conto) with balance and movements, and wire " +
|
|
@@ -1581,10 +1514,12 @@ export const runEpicStories = (options) => Effect.gen(function* () {
|
|
|
1581
1514
|
launchDir: given.workspace,
|
|
1582
1515
|
flowDir: import.meta.dirname
|
|
1583
1516
|
});
|
|
1584
|
-
const coderFlags =
|
|
1585
|
-
const
|
|
1586
|
-
const
|
|
1587
|
-
const
|
|
1517
|
+
const coderFlags = settingValue("LLM4TS_CODER_FLAGS", process.env);
|
|
1518
|
+
const coderModel = settingValue("LLM4TS_CODER_MODEL", process.env);
|
|
1519
|
+
const seats = yield* seatsFromEnvironment({ coder: pi, reasoner: claude });
|
|
1520
|
+
const reasoning = withExtraFlags(withOptionalModel(seats.reasoning, settingValue("LLM4TS_REASONING_MODEL", process.env)), settingValue("LLM4TS_REASONING_FLAGS", process.env));
|
|
1521
|
+
const coder = withExtraFlags(withOptionalModel(seats.coder, coderModel), coderFlags);
|
|
1522
|
+
const localServer = localCoderServer(coderModel, coderFlags ?? {}, process.env);
|
|
1588
1523
|
// A new epic's id (and state folder) is derived from its text; an existing
|
|
1589
1524
|
// one keeps its folder, whatever text is on the command line.
|
|
1590
1525
|
const epicId = choice._tag === "Existing"
|
|
@@ -11,21 +11,18 @@ import { FlowEvents } from "@llm4ts/flow/FlowEvents";
|
|
|
11
11
|
import { closureView } from "@llm4ts/flow/GraphQuery";
|
|
12
12
|
import { renderGraphMermaid } from "@llm4ts/flow/GraphRender";
|
|
13
13
|
import { ReviewIssue } from "@llm4ts/flow/Review";
|
|
14
|
-
import { cachedReview } from "@llm4ts/flow/ReviewCache";
|
|
15
|
-
import { FlowLlmError, Info, ReviewResult, makeChat
|
|
14
|
+
import { cachedReview, fingerprintOf } from "@llm4ts/flow/ReviewCache";
|
|
15
|
+
import { FlowLlmError, Info, ReviewResult, makeChat } 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 = () =>
|
|
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 = () =>
|
|
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());
|
|
@@ -218,7 +215,7 @@ export const makeProgramJudge = (deps) => {
|
|
|
218
215
|
...pack.judgeDimensions.map((dimension) => `${dimension.name} (0..${dimension.maxScore}): ${dimension.rubric}`),
|
|
219
216
|
...(extraRubric === undefined ? [] : [extraRubric])
|
|
220
217
|
].join("\n");
|
|
221
|
-
return yield* cachedReview(files, join(modDirAbs, "gate", `${unit.name}.json`),
|
|
218
|
+
return yield* cachedReview(files, join(modDirAbs, "gate", `${unit.name}.json`), fingerprintOf([source, spec, feature, rubric]), context.events.publish(Info.make({ message: `judging ${unit.name}` })).pipe(Effect.andThen(judgeWithShrink(unit.name, spec, feature, source)), Effect.map((scored) => judgeIssues(pack, scored, unit.name))));
|
|
222
219
|
});
|
|
223
220
|
};
|
|
224
221
|
/**
|
package/flows/lib/pack-fork.js
CHANGED
|
@@ -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
|
|
6
|
-
if (
|
|
7
|
-
return Effect.succeed(
|
|
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 ${
|
|
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
|
|
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
|
|
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
|
|
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:
|
|
142
|
-
concurrency:
|
|
143
|
-
batch:
|
|
144
|
-
votes:
|
|
145
|
-
sourceChars:
|
|
146
|
-
shards:
|
|
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
|
|
6
|
-
const coderModel = process.env
|
|
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({
|
package/flows/modernize-bench.js
CHANGED
|
@@ -25,12 +25,14 @@ 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,
|
|
28
|
+
import { FlowAborted, FlowLlmError, Info, asReadOnly, coderFromEnvironment, makeNodeWorkspace, mergeReviewResults, nodePlainFileStore, openPack, resolveFlowInput, 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";
|
|
35
|
+
import { fingerprintOf } from "@llm4ts/flow/ReviewCache";
|
|
34
36
|
const ModDir = "docs/modernization";
|
|
35
37
|
const BenchFile = "bench-results.jsonl";
|
|
36
38
|
const programName = (relativePath) => {
|
|
@@ -48,19 +50,18 @@ const machine = () => BenchMachine.make({
|
|
|
48
50
|
});
|
|
49
51
|
const program = Effect.gen(function* () {
|
|
50
52
|
const input = yield* resolveFlowInput("Benchmark a modernization extraction run");
|
|
51
|
-
const mode = process.env
|
|
53
|
+
const mode = settingValue("LLM4TS_BENCH_MODE", process.env) ??
|
|
52
54
|
(input.prompt.trim().toLowerCase() === "report" ? "report" : "measure");
|
|
53
55
|
const files = nodePlainFileStore;
|
|
54
56
|
const benchPath = join(input.workspace, BenchFile);
|
|
55
|
-
const coder =
|
|
57
|
+
const coder = yield* coderFromEnvironment();
|
|
56
58
|
const startedAt = new Date();
|
|
57
59
|
if (mode === "report") {
|
|
58
60
|
const records = yield* loadBenchRecords(files, benchPath);
|
|
59
61
|
if (records.length === 0) {
|
|
60
62
|
return yield* FlowAborted.make({ message: `no benchmark records at ${benchPath}` });
|
|
61
63
|
}
|
|
62
|
-
|
|
63
|
-
process.stdout.write(`${renderBenchReport(records, Number.isFinite(projected) && projected > 0 ? projected : undefined)}\n`);
|
|
64
|
+
process.stdout.write(`${renderBenchReport(records, settingValue("LLM4TS_BENCH_PROJECT", process.env))}\n`);
|
|
64
65
|
return;
|
|
65
66
|
}
|
|
66
67
|
yield* runNode({
|
|
@@ -219,7 +220,11 @@ const program = Effect.gen(function* () {
|
|
|
219
220
|
});
|
|
220
221
|
// The fingerprint groups records of the SAME estate so the report can
|
|
221
222
|
// compare providers rather than mixing unrelated fixtures.
|
|
222
|
-
const fingerprint =
|
|
223
|
+
const fingerprint = fingerprintOf([
|
|
224
|
+
pack.name,
|
|
225
|
+
...[...programs].sort(),
|
|
226
|
+
String(quality.sourceLines)
|
|
227
|
+
]).slice(0, 16);
|
|
223
228
|
const finishedAt = new Date();
|
|
224
229
|
const record = BenchRecord.make({
|
|
225
230
|
schemaVersion: CurrentBenchSchema,
|
|
@@ -32,9 +32,9 @@ import * as Effect from "effect/Effect";
|
|
|
32
32
|
import * as Ref from "effect/Ref";
|
|
33
33
|
import * as Semaphore from "effect/Semaphore";
|
|
34
34
|
import { budget, capped } from "@llm4ts/flow/Context";
|
|
35
|
-
import { structuredAndPublish } from "@llm4ts/flow/
|
|
35
|
+
import { structuredAndPublish } from "@llm4ts/flow/Usage";
|
|
36
36
|
import { FlowEvents } from "@llm4ts/flow/FlowEvents";
|
|
37
|
-
import { FlowAborted, Info, ReviewResult, asReadOnly,
|
|
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 {
|
|
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 = () =>
|
|
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(
|
|
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
|
|
80
|
-
const programs = wave === undefined
|
|
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
|
|
100
|
+
const waveScope = wave === undefined
|
|
100
101
|
? undefined
|
|
101
102
|
: (() => {
|
|
102
103
|
const names = new Set(programs.map(programName));
|