style: tidy cli formatting

This commit is contained in:
Peter Steinberger
2026-01-08 08:24:57 +01:00
parent c7cade5232
commit 5b397c0f15
7 changed files with 25 additions and 17 deletions

View File

@@ -158,8 +158,7 @@ function buildSkillStatus(
const missingBins = requiredBins.filter((bin) => !hasBinary(bin)); const missingBins = requiredBins.filter((bin) => !hasBinary(bin));
const missingAnyBins = const missingAnyBins =
requiredAnyBins.length > 0 && requiredAnyBins.length > 0 && !requiredAnyBins.some((bin) => hasBinary(bin))
!requiredAnyBins.some((bin) => hasBinary(bin))
? requiredAnyBins ? requiredAnyBins
: []; : [];
const missingOs = const missingOs =

View File

@@ -1127,7 +1127,9 @@ export function registerNodesCli(program: Command) {
defaultRuntime.log("canvas a2ui reset ok"); defaultRuntime.log("canvas a2ui reset ok");
} }
} catch (err) { } catch (err) {
defaultRuntime.error(`nodes canvas a2ui reset failed: ${String(err)}`); defaultRuntime.error(
`nodes canvas a2ui reset failed: ${String(err)}`,
);
defaultRuntime.exit(1); defaultRuntime.exit(1);
} }
}), }),

View File

@@ -23,7 +23,6 @@ import {
} from "../config/config.js"; } from "../config/config.js";
import { danger, setVerbose } from "../globals.js"; import { danger, setVerbose } from "../globals.js";
import { autoMigrateLegacyState } from "../infra/state-migrations.js"; import { autoMigrateLegacyState } from "../infra/state-migrations.js";
import { runProviderLogin, runProviderLogout } from "./provider-auth.js";
import { defaultRuntime } from "../runtime.js"; import { defaultRuntime } from "../runtime.js";
import { isRich, theme } from "../terminal/theme.js"; import { isRich, theme } from "../terminal/theme.js";
import { VERSION } from "../version.js"; import { VERSION } from "../version.js";
@@ -42,6 +41,7 @@ import { registerModelsCli } from "./models-cli.js";
import { registerNodesCli } from "./nodes-cli.js"; import { registerNodesCli } from "./nodes-cli.js";
import { registerPairingCli } from "./pairing-cli.js"; import { registerPairingCli } from "./pairing-cli.js";
import { forceFreePort } from "./ports.js"; import { forceFreePort } from "./ports.js";
import { runProviderLogin, runProviderLogout } from "./provider-auth.js";
import { registerProvidersCli } from "./providers-cli.js"; import { registerProvidersCli } from "./providers-cli.js";
import { registerSkillsCli } from "./skills-cli.js"; import { registerSkillsCli } from "./skills-cli.js";
import { registerTuiCli } from "./tui-cli.js"; import { registerTuiCli } from "./tui-cli.js";
@@ -576,7 +576,12 @@ Examples:
.option("--workspace <dir>", "Workspace directory for the new agent") .option("--workspace <dir>", "Workspace directory for the new agent")
.option("--model <id>", "Model id for this agent") .option("--model <id>", "Model id for this agent")
.option("--agent-dir <dir>", "Agent state directory for this agent") .option("--agent-dir <dir>", "Agent state directory for this agent")
.option("--bind <provider[:accountId]>", "Route provider binding (repeatable)", collectOption, []) .option(
"--bind <provider[:accountId]>",
"Route provider binding (repeatable)",
collectOption,
[],
)
.option("--non-interactive", "Disable prompts; requires --workspace", false) .option("--non-interactive", "Disable prompts; requires --workspace", false)
.option("--json", "Output JSON summary", false) .option("--json", "Output JSON summary", false)
.action(async (name, opts, command) => { .action(async (name, opts, command) => {
@@ -594,7 +599,9 @@ Examples:
workspace: opts.workspace as string | undefined, workspace: opts.workspace as string | undefined,
model: opts.model as string | undefined, model: opts.model as string | undefined,
agentDir: opts.agentDir as string | undefined, agentDir: opts.agentDir as string | undefined,
bind: Array.isArray(opts.bind) ? (opts.bind as string[]) : undefined, bind: Array.isArray(opts.bind)
? (opts.bind as string[])
: undefined,
nonInteractive: Boolean(opts.nonInteractive), nonInteractive: Boolean(opts.nonInteractive),
json: Boolean(opts.json), json: Boolean(opts.json),
}, },

View File

@@ -1,7 +1,7 @@
import { loadConfig } from "../config/config.js"; import { loadConfig } from "../config/config.js";
import { setVerbose } from "../globals.js"; import { setVerbose } from "../globals.js";
import { defaultRuntime, type RuntimeEnv } from "../runtime.js";
import { loginWeb, logoutWeb } from "../provider-web.js"; import { loginWeb, logoutWeb } from "../provider-web.js";
import { defaultRuntime, type RuntimeEnv } from "../runtime.js";
import { resolveWhatsAppAccount } from "../web/accounts.js"; import { resolveWhatsAppAccount } from "../web/accounts.js";
type ProviderAuthOptions = { type ProviderAuthOptions = {
@@ -11,7 +11,9 @@ type ProviderAuthOptions = {
}; };
function normalizeProvider(raw?: string): "whatsapp" | "web" { function normalizeProvider(raw?: string): "whatsapp" | "web" {
const value = String(raw ?? "whatsapp").trim().toLowerCase(); const value = String(raw ?? "whatsapp")
.trim()
.toLowerCase();
if (value === "whatsapp" || value === "web") return value; if (value === "whatsapp" || value === "web") return value;
throw new Error(`Unsupported provider: ${value}`); throw new Error(`Unsupported provider: ${value}`);
} }
@@ -36,7 +38,7 @@ export async function runProviderLogout(
opts: ProviderAuthOptions, opts: ProviderAuthOptions,
runtime: RuntimeEnv = defaultRuntime, runtime: RuntimeEnv = defaultRuntime,
) { ) {
const provider = normalizeProvider(opts.provider); const _provider = normalizeProvider(opts.provider);
// Auth-only flow: resolve account + clear session state only. // Auth-only flow: resolve account + clear session state only.
const cfg = loadConfig(); const cfg = loadConfig();
const account = resolveWhatsAppAccount({ const account = resolveWhatsAppAccount({

View File

@@ -6,11 +6,11 @@ import {
providersRemoveCommand, providersRemoveCommand,
providersStatusCommand, providersStatusCommand,
} from "../commands/providers.js"; } from "../commands/providers.js";
import { listChatProviders } from "../providers/registry.js";
import { danger } from "../globals.js"; import { danger } from "../globals.js";
import { listChatProviders } from "../providers/registry.js";
import { defaultRuntime } from "../runtime.js"; import { defaultRuntime } from "../runtime.js";
import { runProviderLogin, runProviderLogout } from "./provider-auth.js";
import { hasExplicitOptions } from "./command-options.js"; import { hasExplicitOptions } from "./command-options.js";
import { runProviderLogin, runProviderLogout } from "./provider-auth.js";
const optionNamesAdd = [ const optionNamesAdd = [
"provider", "provider",

View File

@@ -59,11 +59,9 @@ describe("agents add command", () => {
it("requires --workspace in non-interactive mode", async () => { it("requires --workspace in non-interactive mode", async () => {
configMocks.readConfigFileSnapshot.mockResolvedValue({ ...baseSnapshot }); configMocks.readConfigFileSnapshot.mockResolvedValue({ ...baseSnapshot });
await agentsAddCommand( await agentsAddCommand({ name: "Work", nonInteractive: true }, runtime, {
{ name: "Work", nonInteractive: true }, hasFlags: false,
runtime, });
{ hasFlags: false },
);
expect(runtime.error).toHaveBeenCalledWith( expect(runtime.error).toHaveBeenCalledWith(
expect.stringContaining("--workspace"), expect.stringContaining("--workspace"),