chore: migrate to oxlint and oxfmt

Co-authored-by: Christoph Nakazawa <christoph.pojer@gmail.com>
This commit is contained in:
Peter Steinberger
2026-01-14 14:31:43 +00:00
parent 912ebffc63
commit c379191f80
1480 changed files with 28608 additions and 43547 deletions

View File

@@ -14,14 +14,8 @@ const EXAMPLES = [
"Send via your web session and print JSON result.",
],
["clawdbot gateway --port 18789", "Run the WebSocket Gateway locally."],
[
"clawdbot --dev gateway",
"Run a dev Gateway (isolated state/config) on ws://127.0.0.1:19001.",
],
[
"clawdbot gateway --force",
"Kill anything bound to the default gateway port, then start it.",
],
["clawdbot --dev gateway", "Run a dev Gateway (isolated state/config) on ws://127.0.0.1:19001."],
["clawdbot gateway --force", "Kill anything bound to the default gateway port, then start it."],
["clawdbot gateway ...", "Gateway control via WebSocket."],
[
'clawdbot agent --to +15555550123 --message "Run summary" --deliver',
@@ -88,8 +82,6 @@ export function configureProgramHelp(program: Command, ctx: ProgramContext) {
program.addHelpText("afterAll", () => {
const docs = formatDocsLink("/cli", "docs.clawd.bot/cli");
return `\n${theme.heading("Examples:")}\n${fmtExamples}\n\n${theme.muted(
"Docs:",
)} ${docs}\n`;
return `\n${theme.heading("Examples:")}\n${fmtExamples}\n\n${theme.muted("Docs:")} ${docs}\n`;
});
}

View File

@@ -1,13 +1,8 @@
export function collectOption(
value: string,
previous: string[] = [],
): string[] {
export function collectOption(value: string, previous: string[] = []): string[] {
return [...previous, value];
}
export function parsePositiveIntOrUndefined(
value: unknown,
): number | undefined {
export function parsePositiveIntOrUndefined(value: unknown): number | undefined {
if (value === undefined || value === null || value === "") return undefined;
if (typeof value === "number") {
if (!Number.isFinite(value)) return undefined;

View File

@@ -8,10 +8,7 @@ export type MessageCliHelpers = {
withMessageBase: (command: Command) => Command;
withMessageTarget: (command: Command) => Command;
withRequiredMessageTarget: (command: Command) => Command;
runMessageAction: (
action: string,
opts: Record<string, unknown>,
) => Promise<void>;
runMessageAction: (action: string, opts: Record<string, unknown>) => Promise<void>;
};
export function createMessageCliHelpers(
@@ -37,10 +34,7 @@ export function createMessageCliHelpers(
"Recipient/channel: E.164 for WhatsApp/Signal, Telegram chat id/@username, Discord/Slack channel/user, or iMessage handle/chat_id",
);
const runMessageAction = async (
action: string,
opts: Record<string, unknown>,
) => {
const runMessageAction = async (action: string, opts: Record<string, unknown>) => {
setVerbose(Boolean(opts.verbose));
const deps = createDefaultDeps();
try {

View File

@@ -1,17 +1,11 @@
import type { Command } from "commander";
import type { MessageCliHelpers } from "./helpers.js";
export function registerMessageDiscordAdminCommands(
message: Command,
helpers: MessageCliHelpers,
) {
export function registerMessageDiscordAdminCommands(message: Command, helpers: MessageCliHelpers) {
const role = message.command("role").description("Role actions");
helpers
.withMessageBase(
role
.command("info")
.description("List roles")
.requiredOption("--guild-id <id>", "Guild id"),
role.command("info").description("List roles").requiredOption("--guild-id <id>", "Guild id"),
)
.action(async (opts) => {
await helpers.runMessageAction("role-info", opts);

View File

@@ -2,10 +2,7 @@ import type { Command } from "commander";
import { collectOption } from "../helpers.js";
import type { MessageCliHelpers } from "./helpers.js";
export function registerMessageEmojiCommands(
message: Command,
helpers: MessageCliHelpers,
) {
export function registerMessageEmojiCommands(message: Command, helpers: MessageCliHelpers) {
const emoji = message.command("emoji").description("Emoji actions");
helpers
@@ -24,28 +21,18 @@ export function registerMessageEmojiCommands(
)
.requiredOption("--emoji-name <name>", "Emoji name")
.requiredOption("--media <path-or-url>", "Emoji media (path or URL)")
.option(
"--role-ids <id>",
"Role id (repeat)",
collectOption,
[] as string[],
)
.option("--role-ids <id>", "Role id (repeat)", collectOption, [] as string[])
.action(async (opts) => {
await helpers.runMessageAction("emoji-upload", opts);
});
}
export function registerMessageStickerCommands(
message: Command,
helpers: MessageCliHelpers,
) {
export function registerMessageStickerCommands(message: Command, helpers: MessageCliHelpers) {
const sticker = message.command("sticker").description("Sticker actions");
helpers
.withMessageBase(
helpers.withRequiredMessageTarget(
sticker.command("send").description("Send stickers"),
),
helpers.withRequiredMessageTarget(sticker.command("send").description("Send stickers")),
)
.requiredOption("--sticker-id <id>", "Sticker id (repeat)", collectOption)
.option("-m, --message <text>", "Optional message body")

View File

@@ -2,10 +2,7 @@ import type { Command } from "commander";
import { collectOption } from "../helpers.js";
import type { MessageCliHelpers } from "./helpers.js";
export function registerMessagePermissionsCommand(
message: Command,
helpers: MessageCliHelpers,
) {
export function registerMessagePermissionsCommand(message: Command, helpers: MessageCliHelpers) {
helpers
.withMessageBase(
helpers.withMessageTarget(
@@ -18,30 +15,15 @@ export function registerMessagePermissionsCommand(
});
}
export function registerMessageSearchCommand(
message: Command,
helpers: MessageCliHelpers,
) {
export function registerMessageSearchCommand(message: Command, helpers: MessageCliHelpers) {
helpers
.withMessageBase(
message.command("search").description("Search Discord messages"),
)
.withMessageBase(message.command("search").description("Search Discord messages"))
.requiredOption("--guild-id <id>", "Guild id")
.requiredOption("--query <text>", "Search query")
.option("--channel-id <id>", "Channel id")
.option(
"--channel-ids <id>",
"Channel id (repeat)",
collectOption,
[] as string[],
)
.option("--channel-ids <id>", "Channel id (repeat)", collectOption, [] as string[])
.option("--author-id <id>", "Author id")
.option(
"--author-ids <id>",
"Author id (repeat)",
collectOption,
[] as string[],
)
.option("--author-ids <id>", "Author id (repeat)", collectOption, [] as string[])
.option("--limit <n>", "Result limit")
.action(async (opts) => {
await helpers.runMessageAction("search", opts);

View File

@@ -1,23 +1,15 @@
import type { Command } from "commander";
import type { MessageCliHelpers } from "./helpers.js";
export function registerMessagePinCommands(
message: Command,
helpers: MessageCliHelpers,
) {
export function registerMessagePinCommands(message: Command, helpers: MessageCliHelpers) {
const withPinsTarget = (command: Command) =>
command.option(
"--channel-id <id>",
"Channel id (defaults to --to; required for WhatsApp)",
);
command.option("--channel-id <id>", "Channel id (defaults to --to; required for WhatsApp)");
const pins = [
helpers
.withMessageBase(
withPinsTarget(
helpers.withMessageTarget(
message.command("pin").description("Pin a message"),
),
helpers.withMessageTarget(message.command("pin").description("Pin a message")),
),
)
.requiredOption("--message-id <id>", "Message id")
@@ -27,9 +19,7 @@ export function registerMessagePinCommands(
helpers
.withMessageBase(
withPinsTarget(
helpers.withMessageTarget(
message.command("unpin").description("Unpin a message"),
),
helpers.withMessageTarget(message.command("unpin").description("Unpin a message")),
),
)
.requiredOption("--message-id <id>", "Message id")
@@ -38,9 +28,7 @@ export function registerMessagePinCommands(
}),
helpers
.withMessageBase(
helpers.withMessageTarget(
message.command("pins").description("List pinned messages"),
),
helpers.withMessageTarget(message.command("pins").description("List pinned messages")),
)
.option("--channel-id <id>", "Channel id (defaults to --to)")
.option("--limit <n>", "Result limit")

View File

@@ -2,15 +2,10 @@ import type { Command } from "commander";
import { collectOption } from "../helpers.js";
import type { MessageCliHelpers } from "./helpers.js";
export function registerMessagePollCommand(
message: Command,
helpers: MessageCliHelpers,
) {
export function registerMessagePollCommand(message: Command, helpers: MessageCliHelpers) {
helpers
.withMessageBase(
helpers.withRequiredMessageTarget(
message.command("poll").description("Send a poll"),
),
helpers.withRequiredMessageTarget(message.command("poll").description("Send a poll")),
)
.requiredOption("--poll-question <text>", "Poll question")
.option(

View File

@@ -1,15 +1,10 @@
import type { Command } from "commander";
import type { MessageCliHelpers } from "./helpers.js";
export function registerMessageReactionsCommands(
message: Command,
helpers: MessageCliHelpers,
) {
export function registerMessageReactionsCommands(message: Command, helpers: MessageCliHelpers) {
helpers
.withMessageBase(
helpers.withMessageTarget(
message.command("react").description("Add or remove a reaction"),
),
helpers.withMessageTarget(message.command("react").description("Add or remove a reaction")),
)
.requiredOption("--message-id <id>", "Message id")
.option("--emoji <emoji>", "Emoji for reactions")

View File

@@ -7,9 +7,7 @@ export function registerMessageReadEditDeleteCommands(
) {
helpers
.withMessageBase(
helpers.withMessageTarget(
message.command("read").description("Read recent messages"),
),
helpers.withMessageTarget(message.command("read").description("Read recent messages")),
)
.option("--limit <n>", "Result limit")
.option("--before <id>", "Read/search before id")

View File

@@ -1,10 +1,7 @@
import type { Command } from "commander";
import type { MessageCliHelpers } from "./helpers.js";
export function registerMessageSendCommand(
message: Command,
helpers: MessageCliHelpers,
) {
export function registerMessageSendCommand(message: Command, helpers: MessageCliHelpers) {
helpers
.withMessageBase(
helpers
@@ -24,11 +21,7 @@ export function registerMessageSendCommand(
)
.option("--reply-to <id>", "Reply-to message id")
.option("--thread-id <id>", "Thread id (Telegram forum thread)")
.option(
"--gif-playback",
"Treat video media as GIF playback (WhatsApp only).",
false,
),
.option("--gif-playback", "Treat video media as GIF playback (WhatsApp only).", false),
)
.action(async (opts) => {
await helpers.runMessageAction("send", opts);

View File

@@ -1,10 +1,7 @@
import type { Command } from "commander";
import type { MessageCliHelpers } from "./helpers.js";
export function registerMessageThreadCommands(
message: Command,
helpers: MessageCliHelpers,
) {
export function registerMessageThreadCommands(message: Command, helpers: MessageCliHelpers) {
const thread = message.command("thread").description("Thread actions");
helpers

View File

@@ -11,10 +11,7 @@ import { autoMigrateLegacyState } from "../../infra/state-migrations.js";
import { defaultRuntime } from "../../runtime.js";
import { emitCliBanner } from "../banner.js";
export function registerPreActionHooks(
program: Command,
programVersion: string,
) {
export function registerPreActionHooks(program: Command, programVersion: string) {
program.hook("preAction", async (_thisCommand, actionCommand) => {
emitCliBanner(programVersion);
if (actionCommand.name() === "doctor") return;

View File

@@ -1,11 +1,7 @@
import type { Command } from "commander";
import { DEFAULT_CHAT_CHANNEL } from "../../channels/registry.js";
import { agentCliCommand } from "../../commands/agent-via-gateway.js";
import {
agentsAddCommand,
agentsDeleteCommand,
agentsListCommand,
} from "../../commands/agents.js";
import { agentsAddCommand, agentsDeleteCommand, agentsListCommand } from "../../commands/agents.js";
import { setVerbose } from "../../globals.js";
import { defaultRuntime } from "../../runtime.js";
import { formatDocsLink } from "../../terminal/links.js";
@@ -14,23 +10,14 @@ import { hasExplicitOptions } from "../command-options.js";
import { createDefaultDeps } from "../deps.js";
import { collectOption } from "./helpers.js";
export function registerAgentCommands(
program: Command,
args: { agentChannelOptions: string },
) {
export function registerAgentCommands(program: Command, args: { agentChannelOptions: string }) {
program
.command("agent")
.description("Run an agent turn via the Gateway (use --local for embedded)")
.requiredOption("-m, --message <text>", "Message body for the agent")
.option(
"-t, --to <number>",
"Recipient number in E.164 used to derive the session key",
)
.option("-t, --to <number>", "Recipient number in E.164 used to derive the session key")
.option("--session-id <id>", "Use an explicit session id")
.option(
"--thinking <level>",
"Thinking level: off | minimal | low | medium | high",
)
.option("--thinking <level>", "Thinking level: off | minimal | low | medium | high")
.option("--verbose <on|off>", "Persist agent verbose level for the session")
.option(
"--channel <channel>",
@@ -61,14 +48,10 @@ Examples:
clawdbot agent --to +15555550123 --message "Trace logs" --verbose on --json
clawdbot agent --to +15555550123 --message "Summon reply" --deliver
${theme.muted("Docs:")} ${formatDocsLink(
"/agent-send",
"docs.clawd.bot/agent-send",
)}`,
${theme.muted("Docs:")} ${formatDocsLink("/agent-send", "docs.clawd.bot/agent-send")}`,
)
.action(async (opts) => {
const verboseLevel =
typeof opts.verbose === "string" ? opts.verbose.toLowerCase() : "";
const verboseLevel = typeof opts.verbose === "string" ? opts.verbose.toLowerCase() : "";
setVerbose(verboseLevel === "on");
// Build default deps (keeps parity with other commands; future-proofing).
const deps = createDefaultDeps();
@@ -107,12 +90,7 @@ ${theme.muted("Docs:")} ${formatDocsLink(
.option("--workspace <dir>", "Workspace directory for the new agent")
.option("--model <id>", "Model id for this agent")
.option("--agent-dir <dir>", "Agent state directory for this agent")
.option(
"--bind <channel[:accountId]>",
"Route channel binding (repeatable)",
collectOption,
[],
)
.option("--bind <channel[:accountId]>", "Route channel binding (repeatable)", collectOption, [])
.option("--non-interactive", "Disable prompts; requires --workspace", false)
.option("--json", "Output JSON summary", false)
.action(async (name, opts, command) => {
@@ -130,9 +108,7 @@ ${theme.muted("Docs:")} ${formatDocsLink(
workspace: opts.workspace as string | undefined,
model: opts.model 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),
json: Boolean(opts.json),
},

View File

@@ -25,9 +25,7 @@ export function registerConfigureCommand(program: Command) {
try {
const sections: string[] = Array.isArray(opts.section)
? opts.section
.map((value: unknown) =>
typeof value === "string" ? value.trim() : "",
)
.map((value: unknown) => (typeof value === "string" ? value.trim() : ""))
.filter(Boolean)
: [];
if (sections.length === 0) {
@@ -35,9 +33,7 @@ export function registerConfigureCommand(program: Command) {
return;
}
const invalid = sections.filter(
(s) => !CONFIGURE_WIZARD_SECTIONS.includes(s as never),
);
const invalid = sections.filter((s) => !CONFIGURE_WIZARD_SECTIONS.includes(s as never));
if (invalid.length > 0) {
defaultRuntime.error(
`Invalid --section: ${invalid.join(", ")}. Expected one of: ${CONFIGURE_WIZARD_SECTIONS.join(", ")}.`,

View File

@@ -9,28 +9,12 @@ export function registerMaintenanceCommands(program: Command) {
program
.command("doctor")
.description("Health checks + quick fixes for the gateway and channels")
.option(
"--no-workspace-suggestions",
"Disable workspace memory system suggestions",
false,
)
.option("--no-workspace-suggestions", "Disable workspace memory system suggestions", false)
.option("--yes", "Accept defaults without prompting", false)
.option("--repair", "Apply recommended repairs without prompting", false)
.option(
"--force",
"Apply aggressive repairs (overwrites custom service config)",
false,
)
.option(
"--non-interactive",
"Run without prompts (safe migrations only)",
false,
)
.option(
"--generate-gateway-token",
"Generate and configure a gateway token",
false,
)
.option("--force", "Apply aggressive repairs (overwrites custom service config)", false)
.option("--non-interactive", "Run without prompts (safe migrations only)", false)
.option("--generate-gateway-token", "Generate and configure a gateway token", false)
.option("--deep", "Scan system services for extra gateway installs", false)
.action(async (opts) => {
try {
@@ -67,16 +51,9 @@ export function registerMaintenanceCommands(program: Command) {
program
.command("reset")
.description("Reset local config/state (keeps the CLI installed)")
.option(
"--scope <scope>",
"config|config+creds+sessions|full (default: interactive prompt)",
)
.option("--scope <scope>", "config|config+creds+sessions|full (default: interactive prompt)")
.option("--yes", "Skip confirmation prompts", false)
.option(
"--non-interactive",
"Disable prompts (requires --scope + --yes)",
false,
)
.option("--non-interactive", "Disable prompts (requires --scope + --yes)", false)
.option("--dry-run", "Print actions without removing files", false)
.action(async (opts) => {
try {

View File

@@ -33,10 +33,7 @@ Examples:
clawdbot message poll --channel discord --to channel:123 --poll-question "Snack?" --poll-option Pizza --poll-option Sushi
clawdbot message react --channel discord --to 123 --message-id 456 --emoji "✅"
${theme.muted("Docs:")} ${formatDocsLink(
"/cli/message",
"docs.clawd.bot/cli/message",
)}`,
${theme.muted("Docs:")} ${formatDocsLink("/cli/message", "docs.clawd.bot/cli/message")}`,
)
.action(() => {
message.help({ error: true });

View File

@@ -16,9 +16,7 @@ function resolveInstallDaemonFlag(
): boolean | undefined {
if (!command || typeof command !== "object") return undefined;
const getOptionValueSource =
"getOptionValueSource" in command
? command.getOptionValueSource
: undefined;
"getOptionValueSource" in command ? command.getOptionValueSource : undefined;
if (typeof getOptionValueSource !== "function") return undefined;
// Commander doesn't support option conflicts natively; keep original behavior.
@@ -33,14 +31,9 @@ function resolveInstallDaemonFlag(
export function registerOnboardCommand(program: Command) {
program
.command("onboard")
.description(
"Interactive wizard to set up the gateway, workspace, and skills",
)
.description("Interactive wizard to set up the gateway, workspace, and skills")
.option("--workspace <dir>", "Agent workspace directory (default: ~/clawd)")
.option(
"--reset",
"Reset config + credentials + sessions + workspace before running wizard",
)
.option("--reset", "Reset config + credentials + sessions + workspace before running wizard")
.option("--non-interactive", "Run without prompts", false)
.option("--flow <flow>", "Wizard flow: quickstart|advanced")
.option("--mode <mode>", "Wizard mode: local|remote")
@@ -52,18 +45,12 @@ export function registerOnboardCommand(program: Command) {
"--token-provider <id>",
"Token provider id (non-interactive; used with --auth-choice token)",
)
.option(
"--token <token>",
"Token value (non-interactive; used with --auth-choice token)",
)
.option("--token <token>", "Token value (non-interactive; used with --auth-choice token)")
.option(
"--token-profile-id <id>",
"Auth profile id (non-interactive; default: <provider>:manual)",
)
.option(
"--token-expires-in <duration>",
"Optional token expiry duration (e.g. 365d, 12h)",
)
.option("--token-expires-in <duration>", "Optional token expiry duration (e.g. 365d, 12h)")
.option("--anthropic-api-key <key>", "Anthropic API key")
.option("--openai-api-key <key>", "OpenAI API key")
.option("--openrouter-api-key <key>", "OpenRouter API key")
@@ -98,9 +85,7 @@ export function registerOnboardCommand(program: Command) {
installDaemon: Boolean(opts.installDaemon),
});
const gatewayPort =
typeof opts.gatewayPort === "string"
? Number.parseInt(opts.gatewayPort, 10)
: undefined;
typeof opts.gatewayPort === "string" ? Number.parseInt(opts.gatewayPort, 10) : undefined;
await onboardCommand(
{
workspace: opts.workspace as string | undefined,
@@ -135,9 +120,7 @@ export function registerOnboardCommand(program: Command) {
tailscaleResetOnExit: Boolean(opts.tailscaleResetOnExit),
reset: Boolean(opts.reset),
installDaemon,
daemonRuntime: opts.daemonRuntime as
| GatewayDaemonRuntime
| undefined,
daemonRuntime: opts.daemonRuntime as GatewayDaemonRuntime | undefined,
skipChannels: Boolean(opts.skipChannels),
skipSkills: Boolean(opts.skipSkills),
skipHealth: Boolean(opts.skipHealth),

View File

@@ -39,10 +39,7 @@ export function registerSetupCommand(program: Command) {
);
return;
}
await setupCommand(
{ workspace: opts.workspace as string | undefined },
defaultRuntime,
);
await setupCommand({ workspace: opts.workspace as string | undefined }, defaultRuntime);
} catch (err) {
defaultRuntime.error(String(err));
defaultRuntime.exit(1);

View File

@@ -13,11 +13,7 @@ export function registerStatusHealthSessionsCommands(program: Command) {
.option("--json", "Output JSON instead of text", false)
.option("--all", "Full diagnosis (read-only, pasteable)", false)
.option("--usage", "Show model provider usage/quota snapshots", false)
.option(
"--deep",
"Probe channels (WhatsApp Web + Telegram + Discord + Slack + Signal)",
false,
)
.option("--deep", "Probe channels (WhatsApp Web + Telegram + Discord + Slack + Signal)", false)
.option("--timeout <ms>", "Probe timeout in milliseconds", "10000")
.option("--verbose", "Verbose logging", false)
.option("--debug", "Alias for --verbose", false)
@@ -38,9 +34,7 @@ Examples:
setVerbose(verbose);
const timeout = parsePositiveIntOrUndefined(opts.timeout);
if (opts.timeout !== undefined && timeout === undefined) {
defaultRuntime.error(
"--timeout must be a positive integer (milliseconds)",
);
defaultRuntime.error("--timeout must be a positive integer (milliseconds)");
defaultRuntime.exit(1);
return;
}
@@ -74,9 +68,7 @@ Examples:
setVerbose(verbose);
const timeout = parsePositiveIntOrUndefined(opts.timeout);
if (opts.timeout !== undefined && timeout === undefined) {
defaultRuntime.error(
"--timeout must be a positive integer (milliseconds)",
);
defaultRuntime.error("--timeout must be a positive integer (milliseconds)");
defaultRuntime.exit(1);
return;
}
@@ -100,14 +92,8 @@ Examples:
.description("List stored conversation sessions")
.option("--json", "Output as JSON", false)
.option("--verbose", "Verbose logging", false)
.option(
"--store <path>",
"Path to session store (default: resolved from config)",
)
.option(
"--active <minutes>",
"Only show sessions updated within the past N minutes",
)
.option("--store <path>", "Path to session store (default: resolved from config)")
.option("--active <minutes>", "Only show sessions updated within the past N minutes")
.addHelpText(
"after",
`