fix(cli): lazy load model commands

This commit is contained in:
Vincent Koc
2026-04-26 03:24:10 -07:00
parent c74fb78194
commit c3a81166fc
6 changed files with 34 additions and 9 deletions

View File

@@ -1,5 +1,4 @@
import type { Command } from "commander";
import { modelsListCommand, modelsStatusCommand } from "../commands/models/list.js";
import { defaultRuntime } from "../runtime.js";
import { formatDocsLink } from "../terminal/links.js";
import { theme } from "../terminal/theme.js";
@@ -35,6 +34,7 @@ export function registerModelsCli(program: Command) {
.option("--plain", "Plain line output", false)
.action(async (opts) => {
await runModelsCommand(async () => {
const { modelsListCommand } = await import("../commands/models/list.list-command.js");
await modelsListCommand(opts, defaultRuntime);
});
});
@@ -71,6 +71,7 @@ export function registerModelsCli(program: Command) {
const agent =
resolveOptionFromCommand<string>(command, "agent") ?? (opts.agent as string | undefined);
await runModelsCommand(async () => {
const { modelsStatusCommand } = await import("../commands/models/list.status-command.js");
await modelsStatusCommand(
{
json: Boolean(opts.json),
@@ -270,6 +271,7 @@ export function registerModelsCli(program: Command) {
models.action(async (opts) => {
await runModelsCommand(async () => {
const { modelsStatusCommand } = await import("../commands/models/list.status-command.js");
await modelsStatusCommand(
{
json: Boolean(opts?.statusJson),