@llm4ts/shell 3.2.5 → 3.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.
- package/dist/Cli.d.ts +11 -3
- package/dist/Cli.d.ts.map +1 -1
- package/dist/Cli.js +125 -38
- package/dist/Cli.js.map +1 -1
- package/dist/Config.d.ts +238 -0
- package/dist/Config.d.ts.map +1 -0
- package/dist/Config.js +594 -0
- package/dist/Config.js.map +1 -0
- package/dist/ConfigCommand.d.ts +180 -0
- package/dist/ConfigCommand.d.ts.map +1 -0
- package/dist/ConfigCommand.js +903 -0
- package/dist/ConfigCommand.js.map +1 -0
- package/dist/ConfigEdit.d.ts +79 -0
- package/dist/ConfigEdit.d.ts.map +1 -0
- package/dist/ConfigEdit.js +110 -0
- package/dist/ConfigEdit.js.map +1 -0
- package/dist/ConfigTrust.d.ts +45 -0
- package/dist/ConfigTrust.d.ts.map +1 -0
- package/dist/ConfigTrust.js +72 -0
- package/dist/ConfigTrust.js.map +1 -0
- package/dist/FlowLaunch.d.ts +2 -3
- package/dist/FlowLaunch.d.ts.map +1 -1
- package/dist/FlowLaunch.js +1 -5
- package/dist/FlowLaunch.js.map +1 -1
- package/dist/FlowProcess.d.ts +3 -1
- package/dist/FlowProcess.d.ts.map +1 -1
- package/dist/FlowProcess.js.map +1 -1
- package/dist/Menu.d.ts +1 -1
- package/dist/Menu.d.ts.map +1 -1
- package/dist/Menu.js +33 -6
- package/dist/Menu.js.map +1 -1
- package/dist/RunSupervisor.d.ts +4 -3
- package/dist/RunSupervisor.d.ts.map +1 -1
- package/dist/RunSupervisor.js +26 -13
- package/dist/RunSupervisor.js.map +1 -1
- package/kits/j2ee-nextjs/README.md +2 -1
- package/kits/j2ee-nextjs/fixtures/demo-bank/RUNBOOK.md +32 -14
- package/kits/j2ee-nextjs/fixtures/demo-bank/reset-demo.mjs +3 -1
- package/package.json +8 -4
- package/src/Cli.ts +173 -45
- package/src/Config.ts +868 -0
- package/src/ConfigCommand.ts +1423 -0
- package/src/ConfigEdit.ts +180 -0
- package/src/ConfigTrust.ts +145 -0
- package/src/FlowLaunch.ts +3 -8
- package/src/FlowProcess.ts +3 -1
- package/src/Menu.ts +40 -7
- package/src/RunSupervisor.ts +26 -14
package/src/Cli.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { homedir } from "node:os"
|
|
2
|
-
import {
|
|
2
|
+
import { join, resolve } from "node:path"
|
|
3
3
|
import { fileURLToPath } from "node:url"
|
|
4
4
|
import * as Console from "effect/Console"
|
|
5
5
|
import * as DateTime from "effect/DateTime"
|
|
6
6
|
import * as Effect from "effect/Effect"
|
|
7
7
|
import * as Option from "effect/Option"
|
|
8
|
+
import * as Result from "effect/Result"
|
|
8
9
|
import { FileSystem } from "effect/FileSystem"
|
|
9
10
|
import * as Schema from "effect/Schema"
|
|
10
11
|
import { Argument, Command, Flag } from "effect/cli"
|
|
@@ -49,6 +50,15 @@ import {
|
|
|
49
50
|
type DiscoveredFlow,
|
|
50
51
|
type FlowTierPaths
|
|
51
52
|
} from "./FlowCatalog.ts"
|
|
53
|
+
import {
|
|
54
|
+
flowEnvironment,
|
|
55
|
+
flowNameOf,
|
|
56
|
+
loadConfig,
|
|
57
|
+
prepareLaunch,
|
|
58
|
+
resolvedEnvironment,
|
|
59
|
+
type FlagAssignment
|
|
60
|
+
} from "./Config.ts"
|
|
61
|
+
import { configCommand, configView, parseAssignment, renderDoctorConfig } from "./ConfigCommand.ts"
|
|
52
62
|
import { launchFlow } from "./FlowLaunch.ts"
|
|
53
63
|
import { mcpOptionsFrom } from "./OperatorConfig.ts"
|
|
54
64
|
import { nodeOperatorRuntime, nodeRead, runMcp } from "./OperatorNode.ts"
|
|
@@ -192,31 +202,81 @@ export interface RunFlags {
|
|
|
192
202
|
readonly roster: Option.Option<string>
|
|
193
203
|
readonly executors: Option.Option<string>
|
|
194
204
|
readonly pack: Option.Option<string>
|
|
205
|
+
readonly coder: Option.Option<string>
|
|
195
206
|
readonly ui: "classic" | "tree"
|
|
196
207
|
readonly transcript: boolean
|
|
197
208
|
readonly otel: boolean
|
|
198
209
|
readonly otelContent: Option.Option<"off" | "on" | "full">
|
|
210
|
+
readonly set: ReadonlyArray<string>
|
|
199
211
|
}
|
|
200
212
|
|
|
201
|
-
/**
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
213
|
+
/**
|
|
214
|
+
* The `run` flags as the config's flag layer: each named flag is its
|
|
215
|
+
* setting, each `--set` its `NAME=value`. Fails on a `--set` that is no
|
|
216
|
+
* assignment; whether a name or a value is acceptable is the resolver's call.
|
|
217
|
+
*/
|
|
218
|
+
export const runFlagAssignments = (
|
|
219
|
+
flags: RunFlags
|
|
220
|
+
): Result.Result<ReadonlyArray<FlagAssignment>, string> => {
|
|
221
|
+
const named: ReadonlyArray<FlagAssignment> = [
|
|
222
|
+
...(flags.verbose ? [{ name: "LLM4TS_VERBOSITY", value: "verbose", flag: "--verbose" }] : []),
|
|
223
|
+
...(Option.isSome(flags.roster)
|
|
224
|
+
? [{ name: "LLM4TS_ROSTER", value: flags.roster.value, flag: "--roster" }]
|
|
225
|
+
: []),
|
|
226
|
+
...(Option.isSome(flags.executors)
|
|
227
|
+
? [{ name: "LLM4TS_EXECUTORS", value: flags.executors.value, flag: "--executors" }]
|
|
228
|
+
: []),
|
|
229
|
+
...(Option.isSome(flags.pack)
|
|
230
|
+
? [{ name: "LLM4TS_PACK", value: flags.pack.value, flag: "--pack" }]
|
|
231
|
+
: []),
|
|
232
|
+
...(Option.isSome(flags.coder)
|
|
233
|
+
? [{ name: "LLM4TS_CODER", value: flags.coder.value, flag: "--coder" }]
|
|
234
|
+
: []),
|
|
235
|
+
...(flags.ui === "tree" ? [{ name: "LLM4TS_UI", value: "tree", flag: "--ui" }] : []),
|
|
236
|
+
...(flags.transcript ? [{ name: "LLM4TS_TRANSCRIPT", value: "on", flag: "--transcript" }] : []),
|
|
237
|
+
...(flags.otel ? [{ name: "LLM4TS_OTEL", value: "on", flag: "--otel" }] : []),
|
|
238
|
+
...(Option.isSome(flags.otelContent)
|
|
239
|
+
? [{ name: "LLM4TS_OTEL_CONTENT", value: flags.otelContent.value, flag: "--otel-content" }]
|
|
240
|
+
: [])
|
|
241
|
+
]
|
|
242
|
+
const sets: Array<FlagAssignment> = []
|
|
243
|
+
for (const text of flags.set) {
|
|
244
|
+
const parsed = parseAssignment(text)
|
|
245
|
+
if (Result.isFailure(parsed)) {
|
|
246
|
+
return Result.fail(`--set: ${parsed.failure}`)
|
|
247
|
+
}
|
|
248
|
+
sets.push({ ...parsed.success, flag: "--set" })
|
|
249
|
+
}
|
|
250
|
+
return Result.succeed([...named, ...sets])
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
const launchDeps = { files: nodePlainFileStore }
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* What an in-process verb reads its settings from: the process environment
|
|
257
|
+
* plus the config files' values for `repo`. A file problem is printed and
|
|
258
|
+
* the value it concerns left out, and so is a project file that is not
|
|
259
|
+
* trusted; neither stops a read-only verb.
|
|
260
|
+
*/
|
|
261
|
+
const verbEnvironment = Effect.fn("@llm4ts/shell/Cli.verbEnvironment")(function* (repo: string) {
|
|
262
|
+
const { resolution } = yield* loadConfig({
|
|
263
|
+
repo,
|
|
264
|
+
environment: process.env,
|
|
265
|
+
flags: [],
|
|
266
|
+
...launchDeps
|
|
267
|
+
}).pipe(Effect.mapError((error) => new ShellUsageError({ message: error.message })))
|
|
268
|
+
const said = resolution.problems.filter(
|
|
269
|
+
(problem) => problem.severity === "error" || problem.kind === "untrusted"
|
|
270
|
+
)
|
|
271
|
+
for (const problem of said) {
|
|
272
|
+
yield* Console.error(`llm4ts config: ${problem.message}`)
|
|
273
|
+
}
|
|
274
|
+
return resolvedEnvironment(resolution, process.env)
|
|
218
275
|
})
|
|
219
276
|
|
|
277
|
+
const repoOr = (repo: Option.Option<string>): string =>
|
|
278
|
+
resolve(Option.getOrElse(repo, () => process.cwd()))
|
|
279
|
+
|
|
220
280
|
const runCommand = Command.make(
|
|
221
281
|
"run",
|
|
222
282
|
{
|
|
@@ -239,6 +299,18 @@ const runCommand = Command.make(
|
|
|
239
299
|
"Pack for the modernization flows, forwarded as LLM4TS_PACK: a kit pack name from `llm4ts kits`, kit/pack, or a directory holding pack.md"
|
|
240
300
|
)
|
|
241
301
|
),
|
|
302
|
+
coder: Flag.String("coder").pipe(
|
|
303
|
+
Flag.optional,
|
|
304
|
+
Flag.withDescription(
|
|
305
|
+
"Coding agent for this run (claude, codex, gemini, pi, …), forwarded as LLM4TS_CODER"
|
|
306
|
+
)
|
|
307
|
+
),
|
|
308
|
+
set: Flag.String("set").pipe(
|
|
309
|
+
Flag.atLeast(0),
|
|
310
|
+
Flag.withDescription(
|
|
311
|
+
"NAME=value: any LLM4TS_* setting for this run only, repeatable; wins over the environment and the config files (llm4ts config show lists them)"
|
|
312
|
+
)
|
|
313
|
+
),
|
|
242
314
|
verbose: Flag.Boolean("verbose").pipe(
|
|
243
315
|
Flag.withDefault(false),
|
|
244
316
|
Flag.withDescription("Stream verbose flow output")
|
|
@@ -284,14 +356,25 @@ const runCommand = Command.make(
|
|
|
284
356
|
Effect.gen(function* () {
|
|
285
357
|
const tiers = shellTierPaths()
|
|
286
358
|
const flowPath = yield* resolveFlow(config.flow, tiers)
|
|
287
|
-
const
|
|
359
|
+
const flags = runFlagAssignments(config)
|
|
360
|
+
if (Result.isFailure(flags)) {
|
|
361
|
+
return yield* new ShellUsageError({ message: flags.failure })
|
|
362
|
+
}
|
|
363
|
+
const plan = yield* prepareLaunch({
|
|
364
|
+
repo: repoOr(config.repo),
|
|
365
|
+
flow: flowNameOf(flowPath),
|
|
366
|
+
base: process.env,
|
|
367
|
+
flags: flags.success,
|
|
368
|
+
...launchDeps
|
|
369
|
+
})
|
|
370
|
+
yield* Effect.forEach(plan.notices, (notice) => Console.error(notice), { discard: true })
|
|
288
371
|
const exitCode = yield* launchFlow({
|
|
289
372
|
flowPath,
|
|
290
373
|
taskArgs: [
|
|
291
374
|
...(config.repo._tag === "Some" ? ["--repo", config.repo.value] : []),
|
|
292
375
|
...config.task
|
|
293
376
|
],
|
|
294
|
-
environment
|
|
377
|
+
environment: plan.environment
|
|
295
378
|
})
|
|
296
379
|
yield* Effect.sync(() => {
|
|
297
380
|
process.exitCode = exitCode
|
|
@@ -421,21 +504,39 @@ const refineCommand = Command.make(
|
|
|
421
504
|
}
|
|
422
505
|
const repo = resolve(config.repo._tag === "Some" ? config.repo.value : process.cwd())
|
|
423
506
|
const flowPath = yield* resolveFlow("modernize-refine", shellTierPaths())
|
|
424
|
-
const
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
507
|
+
const flow = flowNameOf(flowPath)
|
|
508
|
+
const plan = yield* prepareLaunch({
|
|
509
|
+
repo,
|
|
510
|
+
flow,
|
|
511
|
+
base: process.env,
|
|
512
|
+
flags: [
|
|
513
|
+
...(config.pack._tag === "Some"
|
|
514
|
+
? [{ name: "LLM4TS_PACK", value: config.pack.value, flag: "--pack" }]
|
|
515
|
+
: []),
|
|
516
|
+
...(config.target._tag === "Some"
|
|
517
|
+
? [
|
|
518
|
+
{
|
|
519
|
+
name: "LLM4TS_TARGET_REPO",
|
|
520
|
+
value: resolve(config.target.value),
|
|
521
|
+
flag: "--target"
|
|
522
|
+
}
|
|
523
|
+
]
|
|
524
|
+
: [])
|
|
525
|
+
],
|
|
526
|
+
...launchDeps
|
|
527
|
+
})
|
|
528
|
+
yield* Effect.forEach(plan.notices, (notice) => Console.error(notice), { discard: true })
|
|
431
529
|
yield* refineSession({
|
|
432
530
|
modDir: join(repo, ModDir),
|
|
433
|
-
environment,
|
|
531
|
+
environment: plan.environment,
|
|
434
532
|
launch: (extra) =>
|
|
435
533
|
launchFlow({
|
|
436
534
|
flowPath,
|
|
437
535
|
taskArgs: ["--repo", repo],
|
|
438
|
-
environment:
|
|
536
|
+
environment: flowEnvironment(plan.resolution, process.env, {
|
|
537
|
+
...extra,
|
|
538
|
+
LLM4TS_FLOW: flow
|
|
539
|
+
})
|
|
439
540
|
}).pipe(Effect.catch((error) => Console.error(error.message).pipe(Effect.as(1))))
|
|
440
541
|
})
|
|
441
542
|
})
|
|
@@ -598,7 +699,7 @@ const watchCommand = Command.make(
|
|
|
598
699
|
Effect.gen(function* () {
|
|
599
700
|
const options = yield* watchOptionsFrom(config)
|
|
600
701
|
yield* makeWatchProgram(
|
|
601
|
-
{ ...options, idleAfterMs: idleAfterFrom(
|
|
702
|
+
{ ...options, idleAfterMs: idleAfterFrom(yield* verbEnvironment(options.repo)) },
|
|
602
703
|
nodeWatchDependencies()
|
|
603
704
|
)
|
|
604
705
|
})
|
|
@@ -676,11 +777,12 @@ const profileCommand = Command.make(
|
|
|
676
777
|
)
|
|
677
778
|
)
|
|
678
779
|
|
|
679
|
-
const rosterSource = (repo: Option.Option<string>) =>
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
780
|
+
const rosterSource = (repo: Option.Option<string>) =>
|
|
781
|
+
Effect.map(verbEnvironment(repoOr(repo)), (environment) => ({
|
|
782
|
+
files: nodePlainFileStore,
|
|
783
|
+
environment,
|
|
784
|
+
workDir: repoOr(repo)
|
|
785
|
+
}))
|
|
684
786
|
|
|
685
787
|
const rosterRepo = Flag.String("repo").pipe(
|
|
686
788
|
Flag.optional,
|
|
@@ -700,7 +802,7 @@ const rosterPauseCommand = Command.make(
|
|
|
700
802
|
(config) =>
|
|
701
803
|
Effect.gen(function* () {
|
|
702
804
|
const exclusion = yield* pauseExecutor(
|
|
703
|
-
rosterSource(config.repo),
|
|
805
|
+
yield* rosterSource(config.repo),
|
|
704
806
|
config.id,
|
|
705
807
|
Option.getOrUndefined(config.for)
|
|
706
808
|
)
|
|
@@ -716,14 +818,14 @@ const rosterResumeCommand = Command.make(
|
|
|
716
818
|
},
|
|
717
819
|
(config) =>
|
|
718
820
|
Effect.gen(function* () {
|
|
719
|
-
yield* resumeExecutor(rosterSource(config.repo), config.id)
|
|
821
|
+
yield* resumeExecutor(yield* rosterSource(config.repo), config.id)
|
|
720
822
|
yield* Console.log(`${config.id} back in the round`)
|
|
721
823
|
})
|
|
722
824
|
).pipe(Command.withDescription("Put an executor back in the pick-up round"))
|
|
723
825
|
|
|
724
826
|
const rosterCommand = Command.make("roster", { repo: rosterRepo }, (config) =>
|
|
725
827
|
Effect.gen(function* () {
|
|
726
|
-
const report = yield* rosterReport(rosterSource(config.repo))
|
|
828
|
+
const report = yield* rosterReport(yield* rosterSource(config.repo))
|
|
727
829
|
yield* Console.log(renderRosterReport(report))
|
|
728
830
|
})
|
|
729
831
|
).pipe(
|
|
@@ -862,7 +964,10 @@ const runGraph = (sub: GraphSubcommand, flags: GraphFlags) =>
|
|
|
862
964
|
Effect.gen(function* () {
|
|
863
965
|
const command = yield* graphCommandFrom(sub, flags)
|
|
864
966
|
yield* Console.log(
|
|
865
|
-
yield* makeGraphProgram(
|
|
967
|
+
yield* makeGraphProgram(
|
|
968
|
+
command,
|
|
969
|
+
nodeGraphDependencies(yield* verbEnvironment(command.repo), shellTierPaths())
|
|
970
|
+
)
|
|
866
971
|
)
|
|
867
972
|
})
|
|
868
973
|
|
|
@@ -969,7 +1074,7 @@ const geminiBridgeCommand = Command.make(
|
|
|
969
1074
|
},
|
|
970
1075
|
(flags) =>
|
|
971
1076
|
Effect.gen(function* () {
|
|
972
|
-
const options = yield* geminiBridgeOptionsFrom(flags)
|
|
1077
|
+
const options = yield* geminiBridgeOptionsFrom(flags, yield* verbEnvironment(process.cwd()))
|
|
973
1078
|
yield* makeGeminiBridgeProgram(options, {
|
|
974
1079
|
executor: nodeProcessExecutor,
|
|
975
1080
|
temporaryFiles: nodeTemporaryFiles,
|
|
@@ -1042,11 +1147,33 @@ const mcpCommand = Command.make(
|
|
|
1042
1147
|
)
|
|
1043
1148
|
)
|
|
1044
1149
|
|
|
1045
|
-
const doctorCommand = Command.make(
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1150
|
+
const doctorCommand = Command.make(
|
|
1151
|
+
"doctor",
|
|
1152
|
+
{
|
|
1153
|
+
repo: Flag.String("repo").pipe(
|
|
1154
|
+
Flag.optional,
|
|
1155
|
+
Flag.withDescription(
|
|
1156
|
+
"Repository whose .llm4ts/config.env applies (defaults to the current directory)"
|
|
1157
|
+
)
|
|
1158
|
+
)
|
|
1159
|
+
},
|
|
1160
|
+
(config) =>
|
|
1161
|
+
Effect.gen(function* () {
|
|
1162
|
+
const view = yield* configView(
|
|
1163
|
+
{
|
|
1164
|
+
...launchDeps,
|
|
1165
|
+
executor: nodeProcessExecutor,
|
|
1166
|
+
environment: process.env,
|
|
1167
|
+
cwd: process.cwd()
|
|
1168
|
+
},
|
|
1169
|
+
repoOr(config.repo)
|
|
1170
|
+
)
|
|
1171
|
+
const report = yield* makeDoctorProgram(
|
|
1172
|
+
undefined,
|
|
1173
|
+
resolvedEnvironment(view.loaded.resolution, process.env)
|
|
1174
|
+
)
|
|
1175
|
+
yield* Console.log(`${report.trimEnd()}\n\n${renderDoctorConfig(view)}`)
|
|
1176
|
+
})
|
|
1050
1177
|
).pipe(Command.withDescription("Report available connectors and credentials"))
|
|
1051
1178
|
|
|
1052
1179
|
export const shellCommand = Command.make("llm4ts", {}, () =>
|
|
@@ -1077,6 +1204,7 @@ export const shellCommand = Command.make("llm4ts", {}, () =>
|
|
|
1077
1204
|
geminiBridgeCommand,
|
|
1078
1205
|
mcpCommand,
|
|
1079
1206
|
toolCommand,
|
|
1207
|
+
configCommand,
|
|
1080
1208
|
doctorCommand
|
|
1081
1209
|
])
|
|
1082
1210
|
)
|